Canary MultiMux User Manual - page 10
Section 2
–
MultiMux Operation and Installation
10
SerialOut (Com3,"P0400 3500 0600 0040 0300"+CHR(13),"",0,0)
'Short delay
Delay (0,200,mSec)
'Clear buffer
SerialFlush(Com3)
'Send VA measurement command
SerialOut (Com3,"VA"+CHR(13),"",0,0)
'Configure serial input for receiving response
SerialIn(sInBuf,Com3,1500,-1,30)
'Check if enough characters received
if Len(sInBuf) >= 30 then
'Process response
Splitstr(ScratchLoc(),sInBuf," ",4,0)
'Convert to digits
ScratchLoc(5) = 1/((((ScratchLoc(3) * 65536) +
ScratchLoc(4))/ScratchLoc(2)) * 0.1356)
ScratchLoc(5) = (ScratchLoc(5) * 1000000)^2
ScratchLoc(5) = ScratchLoc(5) * 0.001
MuxChannel() = ScratchLoc(5) * 0.001
Else
'No VA command response
MuxChannel() = -99.999
EndIf
'Read our YSI44005 type thermistor using VWDSP
'Short delay
Delay(0,50,mSec)
'Clear Buffer
SerialFlush(Com3)
'Send TA measurement command
SerialOut (Com3,"TA"+CHR(13),"",0,0)
'Receive response
SerialIn(sInBuf,Com3,100,-1,18)
'Check if enough characters received
if Len(sInBuf) > 16 then
'Process response
Splitstr(ScratchLoc(),sInBuf," ",2,0)
'Convert to degrees C (>= VWDSP FW version 8) using Steinhart-hart
ScratchLoc(3) = ((ScratchLoc(1) * 65536) + ScratchLoc(2)) / 100
ScratchLoc(4) = ((ScratchLoc(3)/1023)*2.5)
ScratchLoc(5) = ScratchLoc(4) / 6040
ScratchLoc(6) = ScratchLoc(5) * 499
ScratchLoc(7) = (2.5 - ScratchLoc(4) - ScratchLoc(6)) / ScratchLoc(5)
'Finish conversion
MuxChannelTemp() = 1/(.0014051 + (.0002369*Log(ScratchLoc(7))) +
(.0000001019*(Log(ScratchLoc(7))^3))) - 273.2
'Check for error conditions
if MuxChannelTemp() > 100 then MuxChannelTemp() = -99.8
else
'No response from VWDSP
MuxChannelTemp() = -99.9
endif
'End of measurement loop
Next
'Disable VWDSP
PortSet (7,0)
'Close our serial port for VWDSP communication
SerialClose (8)