65
6-6 Remote Program Examples using RS-232 interface
Example Using Quick BASIC
DECLARE FUNCTION TKDATA! ()
DECLARE SUB TKECHO ()
'DEMO.BAS - This program set the meter to record Vdc measurement on the primary display
' - and Vac measurement on the secondary display.
' - The results will also be printed on the computer screen.
' - Runs on MS-DOS QBasic 1.1,Microsoft Quick BASIC 4.5
'Notice: - When use this program, the RS-232 of the meter should be set the following
' - parameters.
' - 1. BAUD 9600
' - 2. DATA 8 BIT
' - 3. PRITY NONE
' - 4. STOP 1BIT
' - 5. ECHO OFF
' - 6. PRINT OFF
' - This program uses COM1 to communicate with the meter.
' - Version 1.2 (Modified By CC Tung. May31, 2002)
OPEN "COM1:9600,N,8,1,CD,CS,DS" FOR RANDOM AS #1
'Open COM1 for communication. 9600 baud, no parity, 8 data bits, 1 stop bit, ignore Data Carrier Detect
(DCD),
'Clear To Send (CTS), and Data Set Ready (DSR) signals
CMD$ = "RST" 'Reset the meter.
PRINT #1, CMD$ 'Send command to the meter.
TKECHO 'Waiting "=>" and checking if the command is executed successfully.
TKECHO 'Waiting "*>" to make sure the meter is in power on initial state.
CMD$ = "S101" 'Set primary display to Vdc function, mV range.
PRINT #1, CMD$ 'Send command to the meter.
TKECHO 'Waiting "=>" and checking if the command is executed successfully.
CMD$ = "S21" 'Set secondary display to Vac function, the range will same as primary.
PRINT #1, CMD$ 'Send command to the meter.
TKECHO 'Waiting "=>" and checking if the command is executed successfully.
SLEEP 3 'Wait for 3 sec.
CMD$ = "R1" 'Read primary display reading
PRINT #1, CMD$ 'Send command to the meter.
PRINT TKDATA; "V,"; 'Print the value on computer screen.
TKECHO 'Waiting "=>" and checking if the command is executed successfully.
CMD$ = "R2" 'Read secondary display reading
PRINT #1, CMD$ 'Send command to the meter.
PRINT TKDATA; "V" 'Print the value on computer screen.
TKECHO 'Waiting "=>" and checking if the command is executed successfully.
CLOSE #1 'Release COM1.
END 'End of the program.