2.6 Sample Program
The following shows an example of controlling the AQ6370C/AQ6370D/AQ6373/AQ6373B/
AQ6375/AQ6375B remotely using the GP-IB port. The sample program uses Visual Basic
6.0 as the programming language. Also, a GP-IB board by National Instruments (hereinafter,
“NI”) is used as the GP-IB controller and the NI-supplied driver is used as a library.
Sample Program 1
The program sets the measurement conditions (center wavelength, span, sensitivity,
and the sampling number) and then performs a sweep. After completing this sweep, the
program executes a thresh-based spectrum width analysis and then outputs the results
to the screen.
Const BOARD_ID = 0 ' GP-IB Interface card
Address
Const osa = 1 ' OSA GP-IB Address
Private Sub AQ637XTEST()
Dim intData As Integer
Dim dblMeanWL As Double
Dim dblSpecWd As Double
Dim strData As String
' === GP-IB Interface setting ===
' send IFC
Call SendIFC(BOARD_ID)
' assert th REN GPIB line
intAddrList(0) = NOADDR
Call EnableRemote(BOARD_ID, intAddrList())
' GPIB time out setting
Call ibtmo(BOARD_ID, T30s) ' Time out = 30sec
' === Set the measurement parameter ===
Call SendGPIB(osa, "*RST") ' Setting initialize
Call SendGPIB(osa, "CFORM1") ' Command mode
set(AQ637X mode)
Call SendGPIB(osa, ":sens:wav:cent 1550nm") ' sweep center wl
Call SendGPIB(osa, ":sens:wav:span 10nm") ' sweep span
Call SendGPIB(osa, ":sens:sens mid") ' sens mode = MID
Call SendGPIB(osa, ":sens:sweep:points:auto on")
' Sampling Point = AUTO
' === Sweep execute ===
Call SendGPIB(osa, ":init:smode 1") ' single sweep mode
Call SendGPIB(osa, "*CLS") ' status clear
Call SendGPIB(osa, ":init") ' sweep start
' === Wait for sweep complete ===
Do
Call SendGPIB(osa, ":stat:oper:even?") ' get Operation Event
Register
strData = RecieveGPIB(osa)
intData = Val(strData)
Loop While ((intData And 1) <> 1) ' Bit0: Sweep status
' === Analysis ===
Call SendGPIB(osa, ":calc:category swth") ' Spectrum width
analysis(THRESH type)
Call SendGPIB(osa, ":calc") ' Analysis Execute
Call SendGPIB(osa, ":calc:data?") ' get data
strData = RecieveGPIB(osa)