Optical Tunable Filter OTF-930
9-3
9.2. RS-232C Program
ʻSet Wavelength Routine ʻSubroutine description
Private Sub Wavelength_Set() ʻSets routine name to
Wavelength_Set
ʻDene Variables ʻComment
Dim ans As String * 30 ʻDimensions ans array as
string of length 30
ʻSet Wavelength Subroutine ʻComment
ans = InputBox(“Required Wavelength (nm)”) ʻAsk user for required
wavelength value
Form1.MSComm1.PortOpen = True ʻ
Open Port MSComm1 in Form1
of program
Form1.MSComm1.Output = “WA” + ans + Chr$(&HD) ʻ
Send value of wavelength to
Com port with CR delimiter.
Form1.MSComm1.PortOpen = False ʻ
Close Port MSComm1 in Form1
End Sub ʻEnd Subroutine
ʻREAD POWER (dBm) ROUTINE ʻSubroutine description
Private Sub Power_Read_dBm() ʻSets routine name to
Power_Read_dBm
ʻDene Variables ʻComment
Dim ans As String * 30 ʻDimensions ans array as
String of length 30
ʻRead Power Subroutine ʻComment
Form1.MSComm1.PortOpen = True ʻ
Open port MSComm1 of Form1
Form1.MSComm1.Output = “OP” + Chr$(&HD) ʻ
Set output variable to output
power in dBm (CR delimiter)
The following program provides an example of the use of the Control Commands for
RS-232C communication. The program is written in Visual Basic and has an input
function to set the wavelength and an output function to read the Optical Power.
The
communications port in this example is Com1 and requires the ActiveX MSComm
component to be included in the program.