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.

5-minute interval data table overwrite


anodler Nov 5, 2014 11:31 PM

Hello,

I'm new to programming and the CR1000 and I'm trying to add a new data table (Table4) to the existing program. I have tried to configure the data table to output a 5-minute history once the five minutes have elapsed, but the data table does not update itself once every five minutes-instead, it adds data every minute. I'm using a scan with a 1-minute interval and attempting to collect temperature data and wind speed data as shown in the program. I used a table size of five so it can hold five records at a time, but once it is collecting data, it holds more than five records, rather than overwriting every five minutes. I've pasted the current program (along with my slight modifications) below.

'CR1000
'Created by Short Cut (2.8)

'Declare Variables and Units
Public BattV
Public PTemp_C
Public Temp_F
Public WS_ms1
Public WS_ms2
Public WS_ms3
Public WS_ms4
Public WS_ms5
Public WS_ms6
Public WS_ms7
Public WS_ms8
Public WindDir9
Public WindDir10
Public temp
Public baropress

Units BattV=Volts
Units PTemp_C=Deg C
Units Temp_F=Deg F
Units WS_ms1=meters/second
Units WS_ms2=meters/second
Units WS_ms3=meters/second
Units WS_ms4=meters/second
Units WS_ms5=meters/second
Units WS_ms6=meters/second
Units WS_ms7=meters/second
Units WS_ms8=meters/second
Units WindDir9=degrees
Units WindDir10=degrees
Units temp=Deg F
Units baropress=inHG

'Define Data Tables
DataTable(Table1,True,-1)
DataInterval(0,0,Min,10)
Sample(1,BattV,FP2)
Sample(1,PTemp_C,FP2)
Sample(1,Temp_F,FP2)
Sample(1,WS_ms1,FP2)
Sample(1,WS_ms2,FP2)
Sample(1,WS_ms3,FP2)
Sample(1,WS_ms4,FP2)
Sample(1,WS_ms5,FP2)
Sample(1,WS_ms6,FP2)
Sample(1,WS_ms7,FP2)
Sample(1,WS_ms8,FP2)
Sample(1,WindDir9,FP2)
Sample(1,WindDir10,FP2)
Sample(1,temp,FP2)
Sample(1,baropress,FP2)
EndTable

DataTable(Table2,True,-1)
DataInterval(0,1440,Min,10)
Minimum(1,BattV,FP2,False,False)
EndTable

DataTable(Table3,True,-1)
DataInterval(0,0,min,10)
Average(1,WS_ms1,FP2,False)
StdDev(1,WS_ms1,FP2,False)
Maximum(1,WS_ms1,FP2,False,False)
Minimum(1,WS_ms1,FP2,False,False)
Average(1,WS_ms2,FP2,False)
StdDev(1,WS_ms2,FP2,False)
Maximum(1,WS_ms2,FP2,False,False)
Minimum(1,WS_ms2,FP2,False,False)
Average(1,WS_ms3,FP2,False)
StdDev(1,WS_ms3,FP2,False)
Maximum(1,WS_ms3,FP2,False,False)
Minimum(1,WS_ms3,FP2,False,False)
Average(1,WS_ms4,FP2,False)
StdDev(1,WS_ms4,FP2,False)
Maximum(1,WS_ms4,FP2,False,False)
Minimum(1,WS_ms4,FP2,False,False)
Average(1,WS_ms5,FP2,False)
StdDev(1,WS_ms5,FP2,False)
Maximum(1,WS_ms5,FP2,False,False)
Minimum(1,WS_ms5,FP2,False,False)
Average(1,WS_ms6,FP2,False)
StdDev(1,WS_ms6,FP2,False)
Maximum(1,WS_ms6,FP2,False,False)
Minimum(1,WS_ms6,FP2,False,False)
Average(1,WS_ms7,FP2,False)
StdDev(1,WS_ms7,FP2,False)
Maximum(1,WS_ms7,FP2,False,False)
Minimum(1,WS_ms7,FP2,False,False)
Average(1,WS_ms8,FP2,False)
StdDev(1,WS_ms8,FP2,False)
Maximum(1,WS_ms8,FP2,False,False)
Minimum(1,WS_ms8,FP2,False,False)
Average(1,WindDir9,FP2,False)
StdDev(1,WindDir9,FP2,False)
Maximum(1,WindDir9,FP2,False,False)
Minimum(1,WindDir9,FP2,False,False)
Average(1,WindDir10,FP2,False)
StdDev(1,WindDir10,FP2,False)
Maximum(1,WindDir10,FP2,False,False)
Minimum(1,WindDir10,FP2,False,False)
Average(1,Temp_F,FP2,False)
StdDev(1,Temp_F,FP2,false)
Maximum(1,Temp_F,FP2,False,False)
Minimum(1,Temp_F,FP2,False,False)
Average(1,baropress,FP2,False)
StdDev(1,baropress,FP2,false)
Maximum(1,baropress,FP2,False,False)
Minimum(1,baropress,FP2,False,False)
EndTable

'Table for past five minute data
DataTable(Table4,True,5)
DataInterval(5,0,Min,0)
Sample(1,Temp_F,FP2)
Sample(1,WS_ms2,FP2)
EndTable

'Main Program
BeginProg
'SetStatus("UsrDriveSize","100000")
Scan(1,Min,1,0)
'Default Datalogger Battery Voltage measurement BattV
Battery(BattV)
'Wiring Panel Temperature measurement PTemp_C
PanelTemp(PTemp_C,_60Hz)
'Type T (copper-constantan) Thermocouple measurements Temp_F
TCDiff(Temp_F,1,mV2_5C,1,TypeT,PTemp_C,True,0,_60Hz,1.8,32)
'NRG #40 Wind Speed Sensor measurements WS_ms1
PulseCount(WS_ms1,1,11,0,1,0.758,0.35)
If WS_ms1<0.36 Then WS_ms1=0
'A100L2 Switching Anemometer measurement WS_ms2
PulseCount(WS_ms2,1,12,0,1,0.09730,0.1824)
If WS_ms2<0.01 Then WS_ms2=0
'NRG #40 Wind Speed Sensor measurements WS_ms3
PulseCount(WS_ms3,1,13,0,1,0.757,0.39)
If WS_ms3<0.36 Then WS_ms3=0
'A100L2 Switching Anemometer measurement WS_ms4
PulseCount(WS_ms4,1,14,0,1,0.09767,0.1832)
If WS_ms4<0.01 Then WS_ms4=0
'NRG #40 Wind Speed Sensor measurements WS_ms5
PulseCount(WS_ms5,1,15,0,1,0.763,0.33)
If WS_ms5<0.36 Then WS_ms5=0
'A100L2 Switching Anemometer measurement WS_ms6
PulseCount(WS_ms6,1,16,0,1,0.09783,0.1769)
If WS_ms6<0.01 Then WS_ms6=0
'NRG #40 Wind Speed Sensor measurements WS_ms7
PulseCount(WS_ms7,1,17,0,1,0.764,0.32)
If WS_ms7<0.36 Then WS_ms7=0
'A100L2 Switching Anemometer measurement WS_ms8
PulseCount(WS_ms8,1,18,0,1,0.09786,0.1475)
If WS_ms8<0.01 Then WS_ms8=0
'NRG #200P Wind Direction Sensor measurements WindDir9
BrHalf(WindDir9,1,mV2500,3,1,1,2500,True,0,_60Hz,360,0)
If WindDir9>=360 Then WindDir9=0
'NRG #200P Wind Direction Sensor measurements WindDir10
BrHalf(WindDir10,1,mV2500,4,1,1,2500,True,0,_60Hz,360,0)
If WindDir10>=360 Then WindDir10=0
'Generic Single-Ended Voltage measurements temp
VoltSe(temp,1,mV2500,5,True,0,_60Hz,0.1,-123.5)
'Generic Single-Ended Voltage measurements baropress
VoltSe(baropress,1,mv5000,6,True,0,_60Hz,0.00643458366394043,3.0445135894775)
'Call Data Tables and Store Data
CallTable(Table1)
CallTable(Table2)
CallTable(Table3)
CallTable(Table4)
NextScan

EndProg

Also for reference, this is the output I'm currently receiving. The records keep coming in until the I change the program and send it to the CR1000, where it starts again with another record number zero.

2014-11-05 09:01:00 0 48.31 0
2014-11-05 09:02:00 1 48.33 4.104
2014-11-05 09:03:00 2 48.35 4.235
2014-11-05 09:04:00 3 48.44 4.386
2014-11-05 09:05:00 4 48.41 4.563
2014-11-05 09:06:00 5 48.38 4.318
2014-11-05 09:07:00 6 48.44 4.298
2014-11-05 09:08:00 7 48.5 4.438
2014-11-05 09:09:00 8 48.48 4.319

Thank you for your help and I appreciate your time!


jra Nov 6, 2014 12:02 AM

Change this line:
DataInterval(5,0,Min,0)
to
DataInterval(0,5,Min,0)
In CRBasic right-click on the DataInterval instruction to see what each of the parameters does. Use your F1 key to get context sensitive help.

Also, you probably want more than 5 records in your table.
Change this:
DataTable(Table4,True,5)
to
DataTable(Table4,True,-1)

These video tutorials will help, especially CRBasic Features and CRBasic Help:
https://www.youtube.com/playlist?list=PLR_Ted9kITyIPGJ0VQiUM9OqIRTt2B_wR

* Last updated by: Janet on 11/5/2014 @ 5:12 PM *


anodler Nov 6, 2014 07:21 PM

Thank you for the help in your previous post. I watched the youtube videos for additional help, but I still have some questions. I'd like to change the table to output 24-hour data per my boss's instruction. For example, I would like the table to output data from 12:00 am on November 7th to 12:00 am on November 8th. However, I want the data table to print the data at 12:00 am on November 8th (making it the past 24 hours worth of data). From this point on, I want to record data but print the new data table once a day, at midnight, for the previous day. In this instance, the scan interval will be kept at 10 minutes. Please let me know if my modifications are correct so far. I changed the scan interval to 10 minutes. I changed the data table size to 144 (1440 minutes per day so 144 scans in 10 minute increments). I also changed the data interval to 0 minutes which will make it the same as the scan interval (10 minutes) so I'm hoping the data interval will collect 144 data points for each variable during the course of the day. I've reposted the portion of the program that I edited below. Unfortunately, because of the modifications, I won't be able to see the final output for 24 hours, so any help you can give me before then would be greatly appreciated. Thank you!

'Table for 24-hour data
DataTable(Table4,True,144)
DataInterval(0,0,Min,0)
Sample(1,Temp_F,FP2)
Sample(1,WS_ms2,FP2)
EndTable

'Main Program
BeginProg
'SetStatus("UsrDriveSize","100000")
Scan(10,Min,1,0)


Sam Nov 10, 2014 12:52 AM

if i understand your question correctly, change

DataInterval(0,0,Min,0)

to

DataInterval(0,24,Hr,0)

or

DataInterval(0,1,Day,0)

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