Section 2 – MicroMux Operation and Installation
8
'Transmit ATDTnn (where nn = radio address), Receive OK (up to 10 seconds)
SerialOut (Com1,"ATDT0129"+Chr(13),"OK",1,1000)
Delay(0,1000,mSec)
'Transmit ATCN, Receive OK (wait up to 10 seconds)
SerialOut (Com1,"ATCN"+Chr(13),"OK",1,1000)
'Wake up the VW Comm - Try for 5 seconds
ScratchLoc(1) = SerialOut (Com1,"0!","0",50,100)
'Check for valid response
if ScratchLoc(1) <> 0 then
'Send Set Digital Outputs command (Switch to Gage 1)
SerialOut (Com1,"0MM00!","00045",5,50)
'Send Set Up VW Start Freq, End Freq, command
SerialOut (Com1,"0M110400350002550500!","00045",5,50)
ScratchLoc(4)= FormatFloat(Channel, "%2g")
'Send Set Digital Outputs command (Switch to Gage 1)
SerialOut (Com1,"0MM0"+ScratchLoc(4)+"!","00045",5,50)
'Send Take Reading command
SerialOut (Com1,"0M!","00045",5,50)
SerialFlush(com1)
Delay(0,1500,mSec)
'Send Get Readings command
SerialOut (Com1,"0D0!","0",5,50)
'Receive response
SerialIn(sInBuf,Com1,100,CHR(13),75)
'Get length of response buffer
ScratchLoc(3) = Len(sInBuf)
if Len(sInBuf) >= 9 then
'Split out response values
Splitstr(ScratchLoc(4),sInBuf,"",12,0)
'Convert to reading - may be in Digits, Freq, or Period
mlReading=ScratchLoc(4)
Else
'No valid response
mlReading = -99999
EndIf
'Send Set Digital Outputs command (Switch back to Gage 1)
SerialOut (Com1,"0M6000!","00045",5,250)
Else
'No valid response
mlReading = -99998
EndIf
'Close our serial port
SerialClose(Com1)