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.

coordinating data collection with different scan rates


pfjessen Jun 16, 2020 09:01 PM

I'm trying to collect some 20 Hz data from a serial port along with some 1 hz analog temperature data and 1 minute panel temp and battery voltage data. using a CR6

We want to collect at a 50% duty cycle to save power so at top of the hour collect N points (2^15) of 20 hz data along with the 1 Hz temperature and 1 minute panel temp/battery voltage. At the end of the N point collection want everything to basically go to sleep for the rest of the hour. (close serial ports and power down instruments using  SW12 command).

What I've tried is a 1 hour main scan, then a 50 msec subscan to get the 20 Hz data, then slow sequences to get the 1 Hz and 1 minute data. What happens with the psuedo code I have below is that the slow sequence scans start as soon as the program starts. At the top of the hour the subscan for the 20 Hz data starts and both SlowSequence scans stop, then when the 20 Hz data finishes collecting, the slow sequence scans start again.

Any suggestions would be appreciated!

Psuedo code I have is:

N=2^15

Nmin=Floor(N/20/60)

Nsecs=Floor(N/20)

DataTable(oneMin,True,-1)
TableFile("CRD:oneMin_",64,-2,Nmin,0,Day,0,0) ' data collected for Nmin minutes
Sample(1,BattV,IEEE4)
Sample(1,PTempC,IEEE4)
EndTable

' One Hz, HC2S3 T/H

DataTable(OneHz,True,-1)
TableFile("CRD:OneHz_",64,-2,Nsecs,0,Hr,0,0) '1638 seconds in 27.306 minutes
Sample(1,AirTC,IEEE4)
Sample(1,RH,IEEE4)
EndTable

' 20 Hz table for Sonic anemometer
' Twenty Hz ASCII (RM Young)
DataTable (Raw_SON,True,-1)
'TableFile("filename",Option,MaxFiles,NumRec/TimeIntoInterval,Interval,Units,
' OutStat,LastFileName)
TableFile("CRD:Raw_SON_",64,-2,N,0,Min,0,0)
Sample (5,SonicA(),FP2)
EndTable

BeginProgram
count=0
Scan(1,hr,1,0) Unending hourly scan
Subscan(50,Msec,N) ' N=2^15
count=count+1
'read 20 Hz data from serial port '
SerialInRecord (ComC3,RMY1,0,36,&H0D,RMY_NByteRet,11)
SplitStr (SonicA(),RMY1,"String",5,0)
CallTable Raw_SON
NextSubScan
' do some processing of the 20 Hz data'
NextScan

SlowSequence
Scan(1,sec,1,0)
'read some 1 Hz temperature and humidity data
CallTable OneHz
NextScan
EndSequence

SlowSequence
Scan(1,min,1,0)
'read panel temp and battery voltage at 1 minute interval
CallTable OneMin
NextScan
EndSequence


JDavis Jun 17, 2020 10:40 PM

Anything in a slow sequence is lower priority than your main scan. So, it gets put on hold during the measurements happening in the main scan. You may have to work in the temperature and humidity into your main scan.


pfjessen Jun 17, 2020 10:55 PM

Thanks for replying. Any ideas on how to do that? Scanning the slower sensors at 20 Hz I think would give us screwy results. 

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