Hi, I'm writing a program for a Geo Precision SDI-12 converter. In these Covid-19 times, i don't have access to a datalogger (Home office).
I'm curious if this will work?
#If ( Sensor_GeoPrecision = TRUE ) Then
For i = 0 To GeoPrecision_Count-1 Step 6 ‘GeoPrecision_Count is 1 to 48
SDI12Recorder (GeoPrecision_tmpr(i+1),SDI12_port,GeoPrecision_SDI_INPUT,"M(i/6)!",1.0,0,6)
Next i
#EndIf
I’m concernd about the expression "M(i/6)!".
The idea is to run the SDI12Recorder with the command "M0!", "M1!", "M2!"...
If not, is there a better way to construct the syntax in a nice and general way?
We are all the same right now. I'm at home with a CR1000X, but no sensor to test it on. I can see the outgoing text from the SDI-12 port, so pretty sure this is Ok. But it will need to be tested with the sensor itself to be certain.
The parameter Command parameter in the SDIRecorder instructin has to be a constant or variable. So, my suggestion would be that you use a string variable for tjis parameter and vary the contents of that.
The following outputs "3M!" on the C1 port and with a bit of manipulation, I am sure you can get it to add in the index value in to it as well.
Public SDIcmd As String * 15
SDIcmd= "M!" & CHR(34)
SDI12Recorder (SDI12Var,C1,3,SDIcmd,1.0,0,-1,0)
Of course, if all else fails, just repeat the SDIRecorder instruction the number of times you need.
Back at the office again :)
Here is a working example program. I have tested this on a CR6, and i assume it will work on a CR1000X as well. Strangely, I did not get it to work on an older CR1000 (OS 32.05). There was a problem with the execution of the SDI12Recorder function and the M0! command. Looking in the Terminal emulator it seems like it sends 1M0! but never the 1D0! Using M1! and M2! it behaves as expected???
'Program to read Geo Precision thermistor string with SDI-12 converter 'http://thermistorstring.com/index.php/additional-string-information/sdi-12-converter '(c) john.hulth@geo.uio.no ConstTable (Station_Constants) Const SCAN_INTERVAL = 20 'Measurement sample interval in Sec Const Logger_CR1000X = FALSE 'CR1000X data logger Const Logger_CR6 = TRUE 'CR6 data logger
Const Logger_CR1000 = FALSE 'CR1000 data logger Const Sensor_GeoPrecision = TRUE 'Geo Precision SDI-12 thermistor string #If ( Logger_CR1000X = TRUE ) Then Const SDI12_port = C1 'Port for SDI-12 sensors (eg. SR50, CS650, SI411...) #EndIf #If ( Logger_CR6 = TRUE ) Then Const SDI12_port = U1 'Port for SDI-12 sensors (eg. SR50, CS650, SI411...) #EndIf
#If ( Logger_CR1000 = TRUE ) Then
Const SDI12_port = 5 'Port for SDI-12 sensors (eg. SR50, CS650, SI411...)
#EndIf #If ( Sensor_GeoPrecision = TRUE ) Then Const GeoPrecision_SDI_INPUT = 1 'SDI-12 adress for Geo Precision Const GeoPrecision_Count = 10 'Number of sensors to meassure Const GP_Sensors_per_command = 9 'Number of sensors read per command 1M0!. 1M1! etc. #EndIf EndConstTable 'Station_Constants #If ( Sensor_GeoPrecision = TRUE ) Then Public GeoPrecision_tmpr(GeoPrecision_Count) : Units GeoPrecision_tmpr = °C 'Measured temperatures Public GeoPrecision_cmd As String * 15 Dim i #EndIf 'Define Data Tables. DataTable (Test,1,-1) 'Set table size to # of records, or -1 to autoallocate. DataInterval (0,SCAN_INTERVAL,Sec,10) #If ( Sensor_GeoPrecision = TRUE ) Then Sample (GeoPrecision_Count,GeoPrecision_tmpr(),IEEE4) #EndIf EndTable 'Main Program BeginProg Scan (SCAN_INTERVAL,Sec,0,0) #If ( Sensor_GeoPrecision = TRUE ) Then SW12 (SW12_1,1) Delay(0,2,Sec) 'Warm-up must be at least 2 sec For i = 0 To GeoPrecision_Count-1 Step GP_Sensors_per_command GeoPrecision_cmd = "M" & i/GP_Sensors_per_command & "!" SDI12Recorder (GeoPrecision_tmpr(i+1),SDI12_port,GeoPrecision_SDI_INPUT,GeoPrecision_cmd,1.0,0,-1,1) Next i SW12 (SW12_1,0) #EndIf 'Call Output Tables CallTable Test NextScan EndProg
The problem I experienced with the CR1000 was due to a timing issue in the SDI12 converter firmware. After updating to v1.2 it also works fine with the CR1000.