Sensoray 421 User Manual
Page 24

Page 22
Sensoray Model 421 Instruction Manual
A/D Interface Procedure
FUNCTION Digitize% (Chan%)
‘****************************************************************************
‘ Digitize one 421 analog input channel.
‘
‘ Imports:
‘
Chan% = A/D input channel in the range 0:7.
‘
‘ Exports:
‘
Digitize% = digitized value in the range 0:4095.
‘****************************************************************************
CONST BZ = 2
‘ Status register mask: “A/D busy” flag
OUT CHCTRL, Chan% AND 7
‘ Select analog input channel
‘ NOTE: you may need to insert a settling time delay here, depending on your programming
‘ language and processor speed.
OUT ADSTART, 0
‘ Digitize the input
DO: LOOP WHILE INP(STATUSPORT) AND BZ
‘ Wait for A/D to finish
loResult% = INP(ADLSB)
‘ Read the digitized result
hiResult% = INP(ADMSB)
Digitize% = loResult% + 256 * (hiResult% AND &HF)
‘ Package result for function return
END FUNCTION
Board Reset Procedure
SUB reset421 ()
‘****************************************************************************
‘ Invoke 421 soft reset.
‘****************************************************************************
OUT RESETPORT, 0
‘ Reset 421 board
chctrlImage% = 0
‘ Initialize CHCTRL output port image
For i% = 0 To 2
‘ Initialize relay images
relay%(i%) = 0
Next i%
END SUB