Computer Operations
Computer Interface Commands and Operation
4
4-59
' HYDRALOG.BAS Hydra Program to scan VDC, VAC, OHMS, FREQ or TEMP
' - initializes RS-232 Communications between PC and Hydra
' - configures a number of Hydra channels for one type
' of measurement (e.g., VDC, VAC, temperature, etc.)
' - scan channels 3 times, and display and record measurement
' data in file "TESTDATA.PRN"
' NOTE: Hydra must be set up for RS-232 communications, 9600 baud,
' no parity, 8 bit data
KEY OFF ' Switch keyboard event trapping off
' NOTE: Error message checking is not done here -- QBasic will notify the
' user and exit if there is a problem
' Open Communications port with 9600 baud, no parity, 8 it data,
' ignore Clear to Send, Data Set Ready, and Carrier Detect.
OPEN "COM2:9600,N,8,,cs0,ds0,cd0" FOR RANDOM AS #1
OPEN "testdata.PRN" FOR OUTPUT AS #2 ' Open data file
PRINT #1, "ECHO 0" ' Turn off command echo on Hydra
'-----
' Find out the number of channels the user wants to configure
' NOTE: Channel 0 will not be used
NumChannels = 0
WHILE (NumChannels < 1) OR (NumChannels > 20)
INPUT "Enter the number of channels to be scanned (1-20): ", NumChannels
WEND
'Turn unused channels off
PRINT "(Wait...)"
FOR Index = (NumChannels + 1) TO 20
PRINT #1, "FUNC " + STR$(Index) + ",OFF"
GOSUB CheckResponse
NEXT Index
op52_1f.eps

Figure 4-5. Sample Program (QBASIC) (1 of 3)