488.2
Gen eral Send/
Re ceive Sys tem
This func tion uses the sta tus reg is ters to syn chro nize the GPIB com mands
and re turn data if a query com mand was used. The sys tem waits un til the
com mand string has been com pleted and then checks to see if any data is on
the GPIB out put buffer. If so, the data is re turned in the Re sult$ ar gu ment
and any er ror code gen er ated in re ceiv ing the data is re turned in the Re -
sult_Code% ar gu ment.
For ex am ple: Use 4882SendReceive(0, 13, “O 1”, Re sult$, Re sult_Code%) to re -
turn a read ing from the ML2400A Se ries.
Note that this func tion is writ ten in “pseudo code” and can not be ex e cuted as
is.
Func tion 4882Sen dRe ceive (Board%, Addr%, cmdstring$, Re sult$, Re -
sult_code%) as in te ger
‘ Set up SRE and ESE val ues first, then pro cess User
’ com mands, then do *OPC
cmd$ = “*ESE 49; *SRE 48; ” + cmdstring$ + “; *OPC”
‘ Send the com mand string
Call DLLsend(Board%, Addr%, cmd$, Len(cmd$), Nlend,
ibsta%, iberr%, ibcntl&)
‘ Wait for ei ther the MAV_bit (Mes sage Avail able)
‘ or/and the ESB_bit (*OPC)
WaitSRQ(Board, Ad dress, MAV_bit + ESB_bit, stb)
If (stb And MAV_bit) Then
‘ Read the data string out from the ML2400A
Re sult_Code% = ReadML2400A(Board, Ad dress, Re sult$)
' If we did not have the ESB_bit set, wait for
‘ it again (*OPC will set this)
If (stb And ESB_bit) = 0 Then WaitSRQ(Board, Ad dress,
ESB_bit, stb)
End if
‘ Check if any thing went wrong by ask ing for the ESB reg is ter
Call DLLsend(Board, Ad dress, “*ESR?”, 5, NLend, ibsta%, iberr%,
ibcntl&)
‘ Wait for it to re turn the data on the out put queue.
WaitSRQ(Board, Ad dress, MAV_bit, stb)
ReadML2400A(Board, Ad dress, ESB)
‘ Read the ESB value
‘ Check the ESB for the OPC bit be ing set
‘ (pend ing com mands com plete).
If (Val(ESB) and 1) Then
4882SendReceive = True
' Ev ery thing sent
end if
6-134 ML2400A OM
PROGRAMMING EXAMPLES GPIB OPERATION