Gpib operation programming examples – Anritsu ML2430A User Manual

Page 218

Advertising
background image

488.2

General Send/

Receive System

This function uses the status registers to synchronize the GPIB commands and
return data if a query command was used. The system waits until the command
string has been completed and then checks to see if any data is on the GPIB out-
put buffer. If so, the data is returned in the Result$ argument and any error code
generated in receiving the data is returned in the Result_Code% argument.

For example: Use 4882SendReceive(0, 13, “O 1”, Result$, Result_Code%) to re-
turn a reading from the ML2430A Series.

Note that this function is written in “pseudo code” and cannot be executed as is.

Function 4882SendReceive (Board%, Addr%, cmdstring$, Result$, Re-
sult_code%) as integer

Set up SRE and ESE values first, then process User

commands, then do *OPC

cmd$ = “*ESE 49; *SRE 48; ” + cmdstring$ + “; *OPC”

Send the command string

Call DLLsend(Board%, Addr%, cmd$, Len(cmd$), Nlend,
ibsta%, iberr%, ibcntl&)

Wait for either the MAV_bit (Message Available)

or/and the ESB_bit (*OPC)

WaitSRQ(Board, Address, MAV_bit + ESB_bit, stb)

If (stb And MAV_bit) Then

Read the data string out from the ML2430A

Result_Code% = ReadML2430A(Board, Address, Result$)

'

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, Address,
ESB_bit, stb)

End if

Check if anything went wrong by asking for the ESB register

Call DLLsend(Board, Address, “*ESR?”, 5, NLend, ibsta%, iberr%, ibcntl&)

Wait for it to return the data on the output queue.

WaitSRQ(Board, Address, MAV_bit, stb)

ReadML2430A(Board, Address, ESB)

Read the ESB value

Check the ESB for the OPC bit being set

(pending commands complete).

If (Val(ESB) and 1) Then

4882SendReceive = True
'

Everything sent

end if

Now check if anything has gone wrong.

If (Val(ESB) And CMD_ERR_bit) Then

4882SendReceive = Command_Error

ElseIf (Val(ESB) And EXEC_ERR_bit) Then

ML2430A OM

6-131

GPIB OPERATION

PROGRAMMING EXAMPLES

Advertising