Chapter 6 Application Programs
RS-232 Operation Using QuickBASIC
139
6
RS-232 Operation Using QuickBASIC
The following example shows how to send command instruction and receive
command responses over the RS-232 interface using QuickBASIC.
RS-232 Operation Using QuickBASIC (Program 4)
CLS
LOCATE 1, 1
DIM cmd$(100), resp$(100)
' Set up serial port for 9600 baud, none parity, 8 bits;
' Ignore Request to Send and Carrier Detect; Send line feed,
' enable parity check, reserve 1000 bytes for input buffer
OPEN "com1:9600,n,8,2,rs,cd,lf,pe" FOR RANDOM AS #1 LEN = 1000
'
' Put the power supply into the remote operation mode
PRINT #1, "SYST:REM"
'
'Reset and clear the power supply
PRINT #1, "*RST;*CLS"
'
' Query the power supply's id string
PRINT #1, "*IDN?"
LINE INPUT #1, resp$
PRINT "*IDN? returned: ", resp$
'
' Ask what revision of SCPI the power supply conforms to
PRINT #1, "SYST:VERS?"
LINE INPUT #1, resp$
PRINT "SYST:VERS? returned: ", resp$
'
' Generate a beep
PRINT #1, "SYST:BEEP"
'
' Set the +6V outputs to 3 V, 3 A
PRINT #1, "APPL P6V, 3.0, 3.0"
'
' Enable the outputs
PRINT #1, "OUTP ON"
'
' Query the output voltage for +6V output
PRINT #1, "MEAS:VOLT? P6V"
LINE INPUT #1, resp $
PRINT "MEAS:VOLT? P6V returned: ", resp$
END
End of Program 4