Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

decimal places.


Mavada Oct 31, 2010 09:04 AM

Hi,

Ive got a strange issue with the cr1000 datalogger.
My humidity sensor shows in the public dat. file for example 9.342 % while in another .dat (table3.dat) file it shows 9.3 %...

Is there a possibility to adjust the readings in the other .dat file to more than one decimal (9.342)?

* Last updated by: Mavada on 10/31/2010 @ 3:04 AM *


Sam Nov 1, 2010 03:38 AM

Mavada,

Can you post a copy of your CRBasic program (.cr1)?

I'm wondering if "Table3" is processing the humidity, like averaging several reading. If so it would be different than the value in "Public", as "Public" contains the last know, instantaneous humidity value.

Sam


Mavada Nov 1, 2010 09:43 AM

'CR1000
'Created by Short Cut (2.8)

'Declare Variables and Units
Public BattV
Public Windr
Public Temp
Public Vocht
Public Windskm
Public Rain_mm
Public BP_mbar
Public SlrW
Public SlrkJ
Public Tot24
Public Windskn
Public Beaufort

Units BattV=Volts
Units Windr=mV
Units Temp=mV
Units Vocht=mV
Units Windskm=mV
Units Rain_mm=mm
Units BP_mbar=mbar
Units SlrW=W/m^2
Units SlrkJ=kJ/m^2

'Define Data Tables
DataTable(Table1,True,-1)
DataInterval(0,10,Min,10)
Average(1,Windr,FP2,False)
Average(1,Temp,FP2,False)
Maximum(1,Temp,FP2,False,True)
Minimum(1,Temp,FP2,False,True)
Average(1,Vocht,FP2,False)
Maximum(1,Vocht,FP2,False,True)
Minimum(1,Vocht,FP2,False,True)
Average(1,Windskm,FP2,False)
Maximum(1,Windskm,FP2,False,True)
Maximum(1,Windskn,FP2,False,True)
Average(1,Windskn,FP2,False)
Average(1,Beaufort,FP2,False)
Sample(1,BP_mbar,IEEE4)
EndTable

DataTable(Table2,True,-1)
DataInterval(0,1,Min,10)
Minimum(1,BattV,FP2,False,False)
Sample(1,BP_mbar,IEEE4)
Sample(1,Windr,FP2)
Sample(1,SlrW,FP2)
Sample(1,Windskn,FP2)
Sample(1,Vocht,FP2)
Sample(1,Temp,FP2)
EndTable

DataTable(Table3,True,-1)
DataInterval(0,1,sec,10)
Sample(1,BP_mbar,IEEE4)
Sample(1,Windr,FP2)
Sample(1,Temp,FP2)
Sample(1,SlrW,FP2)
Sample(1,Windskn,FP2)
Sample(1,Windskm,FP2)
Sample(1,Beaufort,FP2)
Sample(1,Tot24,FP2)
Sample(1,Vocht,FP2)
EndTable

'Main Program
BeginProg
Scan(1,Sec,1,0)
'Default Datalogger Battery Voltage measurement BattV
Battery(BattV)
'Generic 4-20 mA Input measurement Windr
VoltDiff(Windr,1,mV2500,2,True,0,_50Hz,0.18,-89.1)
'Generic 4-20 mA Input measurement Temp
VoltDiff(Temp,1,mV2500,3,True,0,_50Hz,0.05,-65)
'Generic 4-20 mA Input measurement Vocht
VoltDiff(Vocht,1,mV2500,4,True,0,_50Hz,0.05,-25)
'Generic 4-20 mA Input measurement Windskm
VoltDiff(Windskm,1,mV2500,1,True,0,_50Hz,0.081035,-39.9875)
'Generic Tipping Bucket Rain Gauge measurement Rain_mm
PulseCount(Rain_mm,1,1,2,0,0.2,0)
'PTB101B Barometric Pressure Sensor (CSL) measurement BP_mbar
PortSet(1,1)
VoltSE(BP_mbar,1,mV2500,11,1,0,_50Hz,0.184,600)
BP_mbar=BP_mbar*1
'CM3 Pyranometer (CSL) measurements SlrkJ and SlrW
VoltDiff(SlrW,1,mV250,7,True,0,_50Hz,1,0)
If SlrW<0 Then SlrW=0
SlrkJ=SlrW*0.04330879
SlrW=SlrW*43.30879
'24 hour running total calculation Tot24
Tot24=Tot24+Rain_mm
If IfTime(24,1440,Min) Then Tot24=0
'User Entered Calculation
Windskn=(Windskm/1.852)
'User Entered Calculation
If Windskm<1 Then
'User Entered Calculation
Beaufort=0
'User Entered Calculation
ElseIf Windskm<6 Then
'User Entered Calculation
Beaufort=1
'User Entered Calculation
ElseIf Windskm<12 Then
'User Entered Calculation
Beaufort=2
'User Entered Calculation
ElseIf Windskm<20 Then
'User Entered Calculation
Beaufort=3
'User Entered Calculation
ElseIf Windskm<29 Then
'User Entered Calculation
Beaufort=4
'User Entered Calculation
ElseIf Windskm<39 Then
'User Entered Calculation
Beaufort=5
'User Entered Calculation
ElseIf Windskm<50 Then
'User Entered Calculation
Beaufort=6
'User Entered Calculation
ElseIf Windskm<62 Then
'User Entered Calculation
Beaufort=7
'User Entered Calculation
ElseIf Windskm<75 Then
'User Entered Calculation
Beaufort=8
'User Entered Calculation
ElseIf Windskm<89 Then
'User Entered Calculation
Beaufort=9
'User Entered Calculation
ElseIf Windskm<103 Then
'User Entered Calculation
Beaufort=10
'User Entered Calculation
ElseIf Windskm<117 Then
'User Entered Calculation
Beaufort=11
'User Entered Calculation
ElseIf Windskm>117 Then
'User Entered Calculation
Beaufort=12
'User Entered Calculation
EndIf
'Call Data Tables and Store Data
CallTable(Table1)
CallTable(Table2)
CallTable(Table3)
NextScan
EndProg


Mavada Nov 1, 2010 09:47 AM

Humidity is called Vocht in the programm...


aps Nov 1, 2010 12:09 PM

You are storing data in the storage Table in FP2 format which is a compact way of storing numbers, but limits the resolution of numbers stored to 3/4 digits. Please see the manual for more details. For a number in the range of 9.3 you should see 3 digits but if the last digit is zero, i.e. 9.30, whatever display software you are using is likely to have dropped the trailing zero.

If you want the same resolution as data is displayed in the public table use the IEEE4 output type. This will use twice as much memory though.


Mavada Nov 1, 2010 01:03 PM

OK thank you very much, it works!!!

Another question is: i want to add a page in RTMC which shows the minimum, maximum, averages for the day. I know how to add a page, but how do i add this in my programm?

And how do i programm the datarange for the day, for example: the day starts at 20.00 and ends on the next day at 20.00
So the minimum, maximum, averages are in that range of time and must be reset after the 20.00 hour...to start the new day...

And i want to display the maximum, minimum, average every hour, while it shows the max, min. av. at the moment, and store it after the hour. In other words, i want to see the max, min. or average at the moment (running max. min. and average), and after the hour the definitive value.


Mavada Nov 1, 2010 01:06 PM

I forgot another question: how do i get a average value to show in non decimal value, so when the average is 5,5
i want it to show 6 and 5,4 must be 5....


GeodeNZ Nov 1, 2010 04:02 PM

I do this by using an additional variable declared as a long. Then I'll make this long variable = to the variable in question.


Mavada Nov 1, 2010 06:18 PM

OK what is a long...


GeodeNZ Nov 2, 2010 04:49 PM

A long is a variable type (4 byte integer, hence it truncates the decimal portion of the value). The CR1000 manual discusses all the variable types available.

You create an extra variable for displaying the non decimal value. This way you save the precision of the original measurement, but also have a non decimal for other purposes, such as for displays etc.
hth


Mavada Nov 3, 2010 08:45 AM

But how do i get it in my crbasic programm, can someone give me an example to get it in my programm...


Sam Nov 3, 2010 04:01 PM

"i want to add a page in RTMC which shows the minimum, maximum, averages for the day. I know how to add a page, but how do i add this in my programm?"

There are a variety of ways to track and display Minimums, Maximums, and Averages for the day.

#1) This type of data can be calculated and displayed by RTMC from your raw table data. Please refer to RTMC's help. In RTMC help, do an *INDEX* search for the phrase "expressions". Following the examples, I was able to create a digital display in RTMC that tracked the 24 hour, running, maximum voltage by setting the data source to the following. Of course "Server:CR1000.Test.Voltage(1)" will be be different for your program and application.

StartRelativeToNewest(nsecPerDay,ordercollected); MaxRunOverTime("Server:CR1000.Test.Voltage(1)",Timestamp("Server:CR1000.Test.Voltage(1)"),nsecPerDay)


#2) Minimums, Maximums, and Averages can all be easily programmed using ShorCut. Simply highlight the sensor/measurement you wish to store and click either Minimum, Maximum, or Average. This value will be valid over the "Store Every" interval.

#3) Minimums, Maximums, and Averages can all be easily programmed using the CRBasic Editor. All of the available DataTable modifiers can be found in the instruction pane, simply filter by "DataTables/Output Processing". Using those instructions, I created the following code that demonstrates finding 24 hour Min, Max, and Avg for battery voltage.

Public PTemp, batt_volt
DataTable (Test,1,1000)
DataInterval (0,24,Hr,10)
Minimum (1,batt_volt,FP2,0,False)
Maximum (1,batt_volt,FP2,0,False)
Average (1,batt_volt,FP2,False)
EndTable
BeginProg
Scan (1,Sec,0,0)
PanelTemp (PTemp,250)
Battery (batt_volt)
CallTable Test
NextScan
EndProg

#4) Other instructions you may wish to explore include

* AvgRun - can be used to keep a running average over a set time period. For example:

Public batt_volt, batt_volt_avgrun
BeginProg
Scan (1,Hr,0,0)
Battery (batt_volt)
AvgRun (batt_volt_avgrun,1,batt_volt,24)
NextScan
EndProg

* IF/ELSE , TIMEINTOINTERVAL - can be used to track max and mins when put together logically. For example:

Public batt_volt, batt_volt_min, batt_volt_max
BeginProg
Battery (batt_volt)
Scan (1,Hr,0,0)
Battery (batt_volt)
If batt_volt < batt_volt_min Then batt_volt_min = batt_volt
If batt_volt > batt_volt_max Then batt_volt_max = batt_volt
If TimeIntoInterval (0,24,Hr) Then
batt_volt_min = batt_volt
batt_volt_max = batt_volt
EndIf
NextScan
EndProg


"And how do i programm the datarange for the day, for example: the day starts at 20.00 and ends on the next day at 20.00 So the minimum, maximum, averages are in that range of time and must be reset after the 20.00 hour...to start the new day..."

Using the previous examples:

#2) In ShortCut, click "Advanced Output" and change Time settings to "20 Hours Into a 24 Hour Interval"

#3) Similarly to shortcut, edit to read:
DataTable (Test,1,1000)
DataInterval (20,24,Hr,10)
Minimum (1,batt_volt,FP2,0,False)
Maximum (1,batt_volt,FP2,0,False)
Average (1,batt_volt,FP2,False)
EndTable

#4)Edit to read:
Public batt_volt, batt_volt_min, batt_volt_max
Public batt_volt_sum, batt_volt_avg, batt_avg_cntr
BeginProg
Battery (batt_volt)
Scan (1,Hr,0,0)
Battery (batt_volt)
batt_avg_cntr = batt_avg_cntr + 1
batt_volt_sum = batt_volt_sum + batt_volt
batt_volt_avg = batt_volt_sum / batt_avg_cntr
If batt_volt < batt_volt_min Then batt_volt_min = batt_volt
If batt_volt > batt_volt_max Then batt_volt_max = batt_volt
If TimeIntoInterval (20,24,Hr) Then
batt_volt_sum = 0
batt_avg_cntr = 0
batt_volt_min = batt_volt
batt_volt_max = batt_volt
EndIf
NextScan
EndProg

"And i want to display the maximum, minimum, average every hour, while it shows the max, min. av. at the moment, and store it after the hour. In other words, i want to see the max, min. or average at the moment (running max. min. and average), and after the hour the definitive value."

See #4) example directly above


Sam Nov 3, 2010 04:11 PM

"I forgot another question: how do i get a average value to show in non decimal value, so when the average is 5,5
i want it to show 6 and 5,4 must be 5..."

I would say the best thing to do is format it in RTMC. If you format and save your raw data, you can never go back.

Using RTMC - See help index, search for "expressions" and see "Round" and "FormatFloat". Here is an example.

FormatFloat(Round("Server:CR1000.Test.Voltage(1)",0),$"%2.0G")

Log in or register to post/reply in the forum.