USING THE COMBISCOPE INSTRUMENTS 3 - 35
PROGRAM EXAMPLE:
In this program example a trace of 512 samples from the actual signal at input
channel 1 is read. The received data block is converted to an array of voltages. After
each sample conversion the voltage value is printed. This program example works
for traces of 512 samples, consisting of 8 bits (1 byte) or 16 bits (2 bytes) samples.
Note: The program is supplied on floppy under file name EXCNVTRC.BAS.
DIM sample(512) ’
Array of sample voltages
DIM response AS STRING
*
1033 ’
Trace data response string
DIM peaktop AS STRING
*
10 ’
Peak-to-peak response string
DIM offs AS STRING
*
10 ’
Offset response string
’
CALL Send(0, 8, "
*
RST", 1) ’
Resets the instrument
CALL Send(0, 8, "CONFigure:AC (@1)", 1) ’
Configures for optimal AC-RMS settings
’
Signal-offset also becomes zero
CALL Send(0, 8, "INITiate", 1) ’
Initiates single acquisition
CALL Send(0, 8, "
*
WAI;TRACe? CH1", 1) ’
Requests channel 1 trace
CALL Receive(0, 8, response$, 256) ’
Reads channel 1 trace
’
nr.of.digits = VAL(MID$(response$, 2, 1))
nr.of.bytes = VAL(MID$(response$, 3, nr.of.digits)) - 2
sample.length = ASC(MID$(response$, 3 + nr.of.digits, 1))
nr.of.samples = nr.of.bytes / (sample.length / 8)
CALL Send(0, 8, "SENSe:VOLTage:RANGe:PTPeak?", 1) ’
Queries ptp
CALL Receive(0, 8, peaktop$, 256) ’
Reads ptp
ptpeak = VAL(LEFT$(peaktop$, IBCNT%)) ’
IBCNT% = length
CALL Send(0, 8, "SENSe:VOLTage:RANGe:OFFSet?", 1) ’
Queries offset
CALL Receive(0, 8, offs$, 256) ’
Reads offset
offset = VAL(LEFT$(offs$, IBCNT%)) ’
IBCNT% = length
IF sample.length = 1 THEN
FOR i = 1 TO nr.of.samples ’
1-byte samples
trace% = ASC(MID$(response$, i + 3 + nr.of.digits, 1))
IF trace% > 127 THEN trace% = trace% - 256
END IF
sample(i) = trace% / 200
*
ptpeak - offset
PRINT sample(i);
NEXT i
ELSE
FOR i = 1 TO nr.of.samples ’
2-byte samples
J = 2
*
i + 2 + nr.of.digits ’
Pointer to next sample
byte1 = ASC(MID$(response$, J, 1)) ’
M.S.B.
byte2 = ASC(MID$(response$, J + 1, 1)) ’
L.S.B.
IF byte1 < 128 THEN trace% = byte1
*
256 + byte2
ELSE trace% = (byte1 - 256)
*
256 + byte2
END IF
sample(i) = trace% / 51200
*
ptpeak - offset
PRINT sample(i);
NEXT i
END IF