'OXYBase RS485 'defining variables Public SendText As String * 256 Public ReceiveText As String * 128 Public SerialError As Long Public SplitText(6) As String * 16 Public OXYBaseAmp As Long Public OXYBasePhase As Float Public OXYBaseTemp As Float Public OXYBaseOxygen As Float Public OXYBaseError As Long Public RawString As String *128 Public PTemp, batt_volt 'defines the data table DataTable (OXYbaseRS485,1,-1) Sample(1, batt_volt, FP2) Sample(1, PTemp, FP2) Sample(1, RawString, String) Sample(1, OXYBaseAmp, Long) Sample(1, OXYBasePhase, FP2) Sample(1, OXYBaseTemp, FP2) Sample(1, OXYBaseOxygen, FP2) Sample(1, OXYBaseError, Long) EndTable Sub OXYBaseSerialSetup 'subroutine to initialize the RS485 interface SerialClose(ComC5) SerialOpen (ComC5,19200,16,20,512,4) SendText="mode0001"+CHR(13) Call OXYBaseSend EndSub Sub OXYBaseSend 'subroutine to send texts SerialError=SerialOut (ComC5,SendText,"",1,100) EndSub Sub OXYBaseData 'subroutine to receive data SendText="data"+CHR(13) ReceiveText="" Call OXYBaseSend EndSub BeginProg Call OXYBaseSerialSetup Scan (10, sec, 0, 0) 'exemplary 10 sec as interval Call OXYBaseData 'sending "data" to the OXYBase results in sending of the data as an ASCII-String SerialIn(RawString,ComC5, 200,13,256) 'reading in the string SplitStr(SplitText(),RawString, CHR(59),6,0) 'splitting the string into the value parts OXYBaseAmp=Mid(SplitText(2),1,7) OXYBasePhase=Mid(SplitText(3),1,7) OXYBaseTemp=Mid(SplitText(4),1,7) OXYBaseOxygen=Mid(SplitText(5),1,7) OXYBaseError=Mid(SplitText(6),1,7) 'recalculating data OXYBasePhase=OXYBasePhase/100 OXYBaseTemp=OXYBaseTemp/100 OXYBaseOxygen=OXYBaseOxygen/100 'getting board data: temperature and voltage PanelTemp(PTemp, 250) Battery(batt_volt) 'storing the obtained values in the data table CallTable OXYBaseRS485 NextScan