![](https://pdfstore-manualsonline.prod.a.ki/pdfasset/3/e6/3e68ced7-e780-4a08-9488-535798d1c4ed/3e68ced7-e780-4a08-9488-535798d1c4ed-bg36.png)
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) ’
DIM response AS STRING
*
1033 ’
Trace data response string
DIM peaktop AS STRING
*
10 ’
Peak-to-peak response string
DIM offs AS STRING
*
10 ’
’
CALL Send(0, 8, "
*
RST", 1) ’
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) ’
CALL Receive(0, 8, response$, 256) ’
’
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) ’
CALL Receive(0, 8, peaktop$, 256) ’
ptpeak = VAL(LEFT$(peaktop$, IBCNT%)) ’
CALL Send(0, 8, "SENSe:VOLTage:RANGe:OFFSet?", 1) ’
CALL Receive(0, 8, offs$, 256) ’
offset = VAL(LEFT$(offs$, IBCNT%)) ’
IF sample.length = 1 THEN
FOR i = 1 TO nr.of.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 ’
J = 2
*
i + 2 + nr.of.digits ’
byte1 = ASC(MID$(response$, J, 1)) ’
byte2 = ASC(MID$(response$, J + 1, 1)) ’
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