Section 5 GPIB
5-36
2) Program example using Visual Basic
Sub SAMP2 ()
ADRS%=8
Cls
Call SendIFC(0) : Interface clear
If ibsta% And EERR Then
Call FRRMSG(ADRS%, "Error: IFC")
End If
Call DevClear(0, ADRS%) : Device clear
If ibsta% And EERR Then
Call ERRMSG(ADRS%, "Error: DCL")
End If
: Specifies presets, status clear, and terminator
Call Send(0, ADRS%, "*RST;*CLS;TRM 1", NLend)
If ibsta% And EERR Then
Call ERRMSG(ADRS%, "Error: SENDING COMMAND")
End If
Call Send(0, ADRS%, "ESE2 2;*SRE 4", NLend) : Statistics processing end event status
: Statistics processing end event status
Call Send(0, ADRS%, "INPCH 2", NLend) : Input channel Input2
Call Send(0, ADRS%, "STS 2", NLend) : Sets Max statistics processing
Call Send(0, ADRS%, "SMP 3;RES 4;SH 1", NLend) : Sets 10 ms sample rate, 10 Hz resolution,
: hold
For I%=1 To 10
FREQ$=Space$(40)
Call Send(0, ADRS% "*CLS;*TRG", NLend) : Status clear and trigger command
Call Waisrq(ADRS%)
Call Send(0, ADRS%, "MSTA?", NLend) : Reads statistics processing
Call Receive(0, ADRS%, FREQ$, STOPend)
Print FREQ$
Next I%
Call ibonl(ADRS%, 0)
End Sub
Sub Waisrq (ADR%) : SRQ routine
Do
Call WaitSRQ(0, SRQasserted%)
If SRQasserted%=0 Then
Call ERRMSG(ADRS%, "Error: did not assert SRQ. ")
End If
Call ReadStatusByte(0, ADR%, Status%)
If ibsta% And EERR Then
Call ERRMSG(ADRS%, "Error: could not read STB.")
End If
Loop Until (Status% And &H4)=&H4
Call Send(0, ADRS%, "*CLS", NLend)
End Sub