I'm trying some simple stuff here. I want to write the Telegram output with 20Hz of a Thies 3d Sonic Anemometer to the CR6 logger. I've set up the ComC1 as RS485 Full Duplex, hooked it up accordingly.
I've set up the Thies to stream data in a given telegram style with 20Hz, 38 bytes per scan, SerialOpen() with buffer size 100. The telegram is then parsed into the variables.
'Declare Variables and Units Public BattV Public PTemp_C Public Vx Public Vy Public Vz Public Tv Public Status Public CS Public RawString As String * 50 Public NBytesReturned Units BattV=Volts Units PTemp_C=Deg C Units Vx=m/s Units Vy=m/s Units Vz=m/s Units Tv=Deg C 'Define Data Table for 20Hz output data DataTable(TwentyHz,True,-1) DataInterval(0,50,mSec,10) CardOut(1,-1) Sample(1,Vx,IEEE4) Sample(1,Vy,IEEE4) Sample(1,Vz,IEEE4) Sample(1,Tv,FP2) Sample(1,Status,FP2) Sample(1,CS,FP2) Sample(1,NBytesReturned, FP2) EndTable 'Datatable for ten minutes data DataTable(TenMin,True,-1) DataInterval(0,1,Min,10) CardOut(1,-1) Average(1,Vx,FP2,False) StdDev(1,Vx,FP2,False) Average(1,Vy,FP2,False) StdDev(1,Vy,FP2,False) Average(1,Vz,FP2,False) StdDev(1,Vz,FP2,False) Average(1,Tv,FP2,False) Average(1,BattV,FP2,False) Minimum(1,BattV,FP2,False,False) Maximum(1,PTemp_C,FP2,False,False) EndTable 'Main Program BeginProg SerialOpen(ComC1,9600,0,0,100) 'Main Scan Scan(50,mSec,40,0) Battery(BattV) 'Default CR6 Datalogger Battery Voltage measurement 'BattV' PanelTemp(PTemp_C,15000) 'Default CR6 Datalogger Wiring Panel Temperature measurement 'PTemp_C' SerialInRecord(ComC1,RawString,&h02,0,&h0D03,NBytesReturned,01) Vx=Mid(RawString,1,7) Vy=Mid(RawString,9,7) Vz=Mid(RawString,17,7) Tv=Mid(RawString,25,5) Status=Mid(RawString,31,2) CS=HexToDec(Mid(RawString,34,2)) 'Call Data Tables and Store Data CallTable TwentyHz CallTable TenMin NextScan EndProg
With that, the data is recorded, however, every 18-22th value is a column of NAN in each variable. The 10Min Table (currently set to 1min in the interval for testing purposes) is only full of NAN values.
How would I go about to remove the NAN-values? I suppose the NAN records originate from a clock difference (Sensor is configured to output at 20Hz). Do I need to adjust buffer values or change the sensor output to slightly higher than 20Hz?
When I tried a workaround, to poll the sensor (without telegram streaming now on the sensor side), however, I don't get any telegram returned.
(^ same as above) 'Main Program BeginProg SerialOpen(ComC1,9600,0,0,100) 'Main Scan Scan(50,mSec,40,0) Battery(BattV) 'Default CR6 Datalogger Battery Voltage measurement 'BattV' PanelTemp(PTemp_C,15000) 'Default CR6 Datalogger Wiring Panel Temperature measurement 'PTemp_C' SerialOut(ComC1,"00TR00005",0,0,0) Delay(0,25,mSec) SerialInRecord(ComC1,RawString,&h02,0,&h0D03,NBytesReturned,01) Vx=Mid(RawString,1,7) Vy=Mid(RawString,9,7) Vz=Mid(RawString,17,7) Tv=Mid(RawString,25,5) Status=Mid(RawString,31,2) CS=HexToDec(Mid(RawString,34,2)) 'Call Data Tables and Store Data CallTable TwentyHz CallTable TenMin NextScan EndProg
He Delay 25ms is there as the sensor itself has a Response Delay of 20ms programmed currently, so I figured upon receiving the instruction, it waits 20ms to output it, so the logger should wait 25ms for it.
I've also tried SerialOutBlock(ComC1,"00TR00005",9), but no luck.
Any help with my issue would be appreciated!
You can filter the NAN values out from your averages etc. The last parameter of the Average instruction in the disable parameter. You can put in an expression in place of False to not include the value when it is NAN.
Yes, the NAN values you are getting probably are because of clock differences. If you are fine with 10Hz data, you could just undersample. Running the datalogger on a 10Hz scan, with the sensor outputting at 20Hz, means there should always be a value available. If undersampling isn't an option, count up the number of NAN values discarded for diagnostic reasons.
You can refer to the Campbell Scientific manual for the Windsonic1 for an example program filtering NAN values.
Hi! Thanks for your answer!
Thank you for the tip, that seemed to have to done the trick. Also for the 20Hz table Nan values, I found that my Sensor was not configured correctly. It was ocnfigured to Output at a period of 20ms which would be 50 Hz, not a frequency of 20Hz. Switching to an output interval of 50ms at the sensor gets rid of the problem. To be honest I don't really know why, because effectively the logger was undersampling. The Buffer was not large enough to hold 3 messages, which would occasionally be the case, but I only parse the first 38 bytes anyway, so I don't have an explanation for it.
Hi, I know its been a while since this question, but I was facing this problem with the thies 3d anomometer recently. I have to poll the telegram from the sensor since I have more than one sensor per logger, so the way it worked is to use the carriege return <CR> after the comand 00TR00005, like this:
After that the sensor started to give to my logger the data.
I alos am trying to get a Thies 3d ultrasocnic to work and am having troubles. Would it be possible to share the setup commands used on the 3d sensor. I have been trying various options and am still not getting reliably aligned data upon polling.
This may be old and you don't need it any more, but I saw that the "TenMinute" table is set up wrong.
It is set as a 1 minute interval with 10 lapses.
It says: the following:
'Datatable for ten minutes data DataTable(TenMin,True,-1) DataInterval(0,1,Min,10)
To be a 10 minutes table, it should say: