Hello everyone!
I am new to programming the Campbell CR1000 and trying to help a colleague get his system up and running with a serial temperature string. I can't take credit for the majority of this code, only the part that doesn't work - I'm mainly a Labview guy myself.
This is a portion of the real program where a serial address string is sent to a RST_Thermarray that communicates to the cR1000 via RS485. The received string is parsed out to get the temperature (S0375_Temp). I want to add an offset to correct the temp reading, but only the first temperature node gets corrected and the remaining 7 read zero. Any ideas on what's going on? S0379_Temp(1) through (8) read correctly in Public as well as the table. Calibrated_temp(1) is the only one that reads correctly, while 2 thru 8 are written in the table as zeros.
Dim String_0379(8)
Dim S0379_AD(8)
Public S0379_Temp(8)
Public Calibrated_temp(8)
Dim offset(8)
Dim S0379_Res(8)
Public mystring As String * 40, parse(4) As String * 10
Units S0379_Temp() = Deg C
'Define Main Data Table
DataTable (Table1,True,1008)
DataInterval (0,10,Sec,10)
Minimum (1,BattV,FP2,False,False)
Maximum (1,PTemp_C, FP2, False, False)
EndTable
'Define RST Temp String Table
DataTable (TString,True,1008)
DataInterval(0,10,Min,10)
Sample (8,S0379_Temp(),IEEE4) '1-8 RST Thermistor
Sample (8,Calibrated_temp(),IEEE4)
EndTable
'Main Program
BeginProg
SerialOpen (Com4,115200,0,10000,1000)
offset(1)=0.2
offset(2)=0.21
offset(3)=0.22
offset(4)=0.23
offset(5)=0.24
offset(6)=0.25
offset(7)=0.26
offset(8)=0.27
Scan(1,Sec,1,0)
Calibrated_temp()=S0379_Temp()+offset()
* Last updated by: MTUeCe on 4/12/2013 @ 3:53 PM *
The syntax you are using is atypical for Basic languages.
In order to scale each element, you need to loop through the array.
Dim I as Long
For I = 1 to 8
Calibrated_temp(I) = S0379_Temp(I) + offset(I)
Next I