285
Chapter 6 Application Programs
Example: Microsoft Visual Basic for Windows
4
6
’
’ Using the Status Registers
’
Arb.Output "apply:sin 10e3,1,0" ’ 10kHz Sine wave; 1Vpp
Arb.Output "trig:sour bus" ’ Bus Trigger in Burst
Arb.Output "burst:ncycles 50000" ’ 50000 cycles x 0.1ms = 5s
Arb.Output "burst:stat on" ’ Turn ON burst mode
Arb.Output "*ese 1" ’ Operation complete enabled
Arb.Output "*sre 32" ’ Operation complete sets SRQ
Check_Errors ’ Routine checks for errors
Arb.Output "*trg;*opc" ’ Trigger burst
’ *OPC signals end of *TRG
Dim Stats As Integer ’ Variable to store status
Dim Done As Boolean ’ Controls While loop
Done = False
While Not Done
Arb.Output "*stb?" ’ Request status byte
Arb.Enter Stats ’ Read status byte
If Stats And 64 Then ’ Test Master Summary bit
Done = True
End If
Wend
MsgBox "Done", vbOKOnly, "33250A "
cmdStart.Enabled = True
End Sub
Private Sub Form_Load()
Dim IdStr As String
m_Count = 1
Arb.Output "*IDN?" ’ Query instrument information
Arb.Enter IdStr ’ Read result into IdStr
Caption = IdStr ’ Make that data the message on box
End Sub
Sub Check_Errors()
Dim ErrVal(0 To 1)
With Arb
.Output "syst:err?" ’ Query any errors data
.Enter ErrVal ’ Read: Errnum,"Error String"
While ErrVal(0) <> 0 ’ End if find: 0,"No Error"
lstErrors.AddItem ErrVal(0) & "," & ErrVal(1) ’ Display errors
lstErrors.Refresh ’ Update the box
.Output "SYST:ERR?" ’ Request error message
.Enter ErrVal ’ Read error message
Wend
End With
End Sub
Continued...