I'm looking for help with skipped scans. I seem to be getting some conflict when mutiple digital sensors are connected to the same port, but are using different scan rates. I would just move them to another port (C5 or C7), but those are needed for pulse counting the tach output of 3 aspirated shields.
I currently have buffer option set to 3. Should I change this? I'm having trouble understanding how that works. Any ideas would be great. I'm using a CR1000X...
Here are how my scans are setup generally:
Main Scan: 3 seconds (buffer option 1, count 0) - AT at 3 levels, Wind 2 levels, Rain, LWS etc.
SlowSequence Scan1: 5 seconds (buffer option 3, count 0) - AT/RH (HygroVue10) - Addr.0 @ C1
SlowSequence Scan2: 10 seconds (buffer option 3, count 0) - Solar and Net Radiation (CS320 ans SN500SS) - Addr. 1 and 2 @C1
Slowsequence Scan3: 120 seconds (buffer option 3, count 0) - Soil (CS655) - Addr. 0-4 @C3
You have timing conflicts from multiple sequences wanting access to the same port. Look at the SemaphoreGet() instruction in CRBasic.
I can confirm that the "Semaphore" instructions helpd to solve my skipped or missing scans. I will add some sample code for reference. The sample program I created uses a 3-second main scan for all analog sensors, a 5-second slow sequence scan for a HygroVue10, a 10-second slow sequence scan for a digital pyranomter and net radiometer, and a 2-minute slow sequence scan for 5 digital soil probes. All 8 digital SDI-12 sensors are connected to C1. Enjoy!
'Michigan State Univesity - Enviroweather 'Datalogger Series: CR1000X 'program name: SemaphoreLocks.cr1x 'created by: Jordan Elzinga 'date: 10/28/2024 ' ' Declare Constants: Const CS320_SN3506 = True ' CS320_SN3506: S/N of CS320 sensor is greater than 3505 Const LWET = 280 ' LWET: leaf wetness - cutoff between wet/dry (e.g. 280 mV) Const MAIN_SCAN = 3 ' MAIN_SCAN: Primary Scan Rate, in seconds (e.g. 3)... used for main program and most analog sensors Const SUB_SCAN1 = 5 ' SUB_SCAN1: SlowSequence Scan Rate, in seconds (e.g. 5)... used for RH - digital Const SUB_SCAN2 = 10 ' SUB_SCAN2: Slow Scan Rate #2, in seconds (e.g. 10)... used for solar radiation - digital Const SUB_SCAN3 = 120 ' SUB_SCAN3: Slow Scan Rate #3, in seconds (e.g. 120)... used for soil sensors - digital Const SDI12_Lock = 1 ' SDI12_Lock: Semaphore lock used for SDI12 instructions on a shared port ' '--- Public variables - useful for maintenance '-basic info Public VOLT ' Logger Battery Voltage '-AT/RH Public HV10_ATMP ' Air Temperature @ 1.5m Public RELH ' Relative Humidity @ 1.5m Public DWPT ' Dew Point @ 1.5m Public VAPR ' Vapour Pressure @ 1.5m '-Wind Speed & Direction Public WSPD ' Wind Speed @ 3m Public WDIR ' Wind Direction @ 3m '-Solar Public SRAD ' Solar Radiation @ 2m Public NRAD ' Net Radiation @ 2m '-Precip Public PCPN ' Precipitation @ 1m '-Leaf Wetness Public LWS0 ' Leaf Wetness @ 1m '-Soil Moisture Public SMST_05CM ' Soil Water Content @ 5cm depth Public SMST_10CM ' Soil Water Content @ 10cm depth Public SMST_20CM ' Soil Water Content @ 20cm depth Public SMST_50CM ' Soil Water Content @ 50cm depth Public SMST_100CM ' Soil Water Content @ 100cm depth '-Soil Temperature Public STMP_05CM ' Soil Temperature @ 5cm depth Public STMP_10CM ' Soil Temperature @ 10cm depth Public STMP_20CM ' Soil Temperature @ 20cm depth Public STMP_50CM ' Soil Temperature @ 50cm depth Public STMP_100CM ' Soil Temperature @ 100cm depth '-Extra Public PanelTemp_C ' Datalogger panel temperature (used to calculate air temp) Public DayOfYear ' Date/Time Info from Logger - "Day of Year" ' '--- More Variables - just not public ones (data arrays) Dim CurrentTime(9) ' Date/Time Info from Logger Dim HygroVue10(4) ' HygroVue10 Temperature/Relative Humidity Sensor (1.5m) Dim CS320(6) ' CS320 Digital Thermopile Pyranometer (2m) Dim SN500Data1(4) ' Net Radiometer - Short and Long wave radiation both Incomming, and Outgoing Dim SN500Data2(2) ' Net Radiometer - Net Radiation for both Short and Long wave Dim ALBD ' Net Radiometer - Albedo (proportion of light that is reflected by the planet) Dim CS65X_0(6) ' CS655 Soil Moisture, Temperature, and EC sensor (@ 5cm depth) Dim CS65X_1(6) ' CS655 Soil Moisture, Temperature, and EC sensor (@ 10cm depth) Dim CS65X_2(6) ' CS655 Soil Moisture, Temperature, and EC sensor (@ 20cm depth) Dim CS65X_3(6) ' CS655 Soil Moisture, Temperature, and EC sensor (@ 50cm depth) Dim CS65X_4(6) ' CS655 Soil Moisture, Temperature, and EC sensor (@ 100cm depth) ' '--- Set readable names for all of the variables stored in arrays (SDI12 sensors etc.) Alias SN500Data1(1)=SWIN ' Incomming Short-wave Radiation Alias SN500Data1(2)=SWOUT ' Outgoing Short-wave Radiation Alias SN500Data1(3)=LWIN ' Incomming Long-wave Radiation Alias SN500Data1(4)=LWOUT ' Outgoing Long-wave Radiation Alias SN500Data2(1)=SWNET ' Short-wave Net Radiation Alias SN500Data2(2)=LWNET ' Long-wave Net Radiation Alias CS320(3)=CS320_TMP ' Sensor Temperature #If CS320_SN3506 Then Alias CS320(4)=CS320_Z ' Sensor Orentation #Else Alias CS320(6)=CS320_Z ' Sensor Orentation #EndIf ' DataTable(Table5, True, -1) '--- Date / Record Info --- DataInterval(0, 5, Min, 10) '--- Standard Station Data --- Average(1, HV10_ATMP, FP2, False) Average(1, RELH, FP2, False) Average(1, DWPT, FP2, False) Average(1, VAPR, FP2, False) Totalize(1, PCPN, FP2, False) Average(1, LWS0, FP2, False) WindVector(1, WSPD, WDIR, FP2, False, 0, 0, 0) Average(1, SRAD, FP2, False) Average(1, NRAD, FP2, False) Average(1, STMP_05CM, FP2, False) Average(1, STMP_10CM, FP2, False) Average(1, STMP_20CM, FP2, False) Average(1, STMP_50CM, FP2, False) Average(1, STMP_100CM, FP2, False) Average(1, SMST_05CM, FP2, False) Average(1, SMST_10CM, FP2, False) Average(1, SMST_20CM, FP2, False) Average(1, SMST_50CM, FP2, False) Average(1, SMST_100CM, FP2, False) '--- Extra Net Radiometer Data Average(1, LWIN, FP2, False) Average(1, LWOUT, FP2, False) Average(1, LWNET, FP2, False) Average(1, SWIN, FP2, False) Average(1, SWOUT, FP2, False) Average(1, SWNET, FP2, False) Average(1, ALBD, FP2, False) '--- Diagnostic Data: Average(1, VOLT, FP2, False) Minimum(1, VOLT, FP2, False, True) Sample(1, CS320_TMP, FP2) Sample(1, CS320_Z, FP2) EndTable ' BeginProg ' Main Scan -- (e.g. every 3 seconds) -- Analog Sensors Scan(MAIN_SCAN, Sec, 1, 0) '-- Record logger status RealTime(CurrentTime) '--- determine Current Time DayOfYear = CurrentTime(9) '--- store day of year publicly Battery(VOLT) '--- determine CR6 Dataloger Battery Voltage PanelTemp(PanelTemp_C, 60) '--- determine CR6 Datalogger Wiring Panel Temperature ' '--- measure Precipitation (TE525) PulseCount(PCPN, 1, C8, 1, 0, 0.254, 0) ' '--- measure Leaf Wetness (LWS-L) BrHalf(LWS0, 1, mV5000, 4, VX1, 1, 2500, False, 10000, 60, 2500, 0) ' '--- measure Wind Speed / Wind Direction PulseCount(WSPD, 1, C3, 1, 1, 0.8, 0.447) If WSPD<0.457 Then WSPD=0 ' adjust for sensor 'dead zone' BrHalf(WDIR, 1, mV5000, 3, VX2, 1, 2500, True, 20000, 15000, 720, 0) If WDIR>=360 OR WDIR<0 Then WDIR=0 ' adjust for sensor 'dead zone' ' '--- Store/Output Data CallTable Table5 NextScan ' SlowSequence '--- Slow Sequence Scan #1 -- (e.g. every 05 seconds) -- Digital (SDI-12) Sensors Scan(SUB_SCAN1, Sec, 3, 0) '--- measure Standard Air Temp/Relative Humidity/Dew Point/Vapour Pressure SemaphoreGet(SDI12_Lock) SDI12Recorder(HygroVue10(), C1, "0", "M3!", 1, 0, -1) SemaphoreRelease(SDI12_Lock) NextScan ' SlowSequence '--- Slow Scan Rate #2 -- (e.g. every 10 seconds) -- Digital (SDI-12) Sensors Scan(SUB_SCAN2, Sec, 3, 0) '--- measure Solar Radiation SemaphoreGet(SDI12_Lock) SDI12Recorder(CS320(), C1, "1", "M4!", 1, 0, -1) SemaphoreRelease(SDI12_Lock) ' '--- measure Net Solar Radiation SemaphoreGet(SDI12_Lock) SDI12Recorder(SN500Data1(),C1,"2","M!",1,0,-1) '-- 'SWIN', 'SWOUT', 'LWIN', and 'LWOUT' SDI12Recorder(SN500Data2(),C1,"2","M1!",1,0,-1) '-- 'SWNET' and 'LWNET' SDI12Recorder(ALBD,C1,"2","M4!",1,0) '-- 'ALBD' SemaphoreRelease(SDI12_Lock) ' NRAD=SWNET+LWNET ' Calculate net radiation 'NRAD' NextScan ' SlowSequence '--- Slow Scan Rate # 3 -- (e.g. every 2 minutes) -- Soil Sensors Scan(SUB_SCAN3, Sec, 3, 0) '--- measure Soil Temperature / Soil Moisture SemaphoreGet(SDI12_Lock) SDI12Recorder(CS65X_0(), C1, "A", "M3!", 1, 0, -1) SDI12Recorder(CS65X_1(), C1, "B", "M3!", 1, 0, -1) SDI12Recorder(CS65X_2(), C1, "C", "M3!", 1, 0, -1) SDI12Recorder(CS65X_3(), C1, "D", "M3!", 1, 0, -1) SDI12Recorder(CS65X_4(), C1, "E", "M3!", 1, 0, -1) SemaphoreRelease(SDI12_Lock) NextScan EndProg
You have time problems due to numerous sequences attempting to access the same port. Consider the SemaphoreGet() instruction in CRBasic.