Fluke PM-3380B Sander User Manual


 
3 - 32 USING THE COMBISCOPE INSTRUMENTS
3.4.3.1 Conversion of 8-bit samples to integer
As an example a conversion of a trace of 512 "8-bit" samples is shown. The
format is as follows:
PROGRAM EXAMPLE:
In this example a trace acquisition of 1 byte samples is done. Thereafter, the trace
data is read and converted to integer samples in the array "trace", and the number
of trace bytes and trace samples is printed. The conversion from single byte value
to integer is done as follows (refer to figure 3.12):
If byte
128 then integer = byte - 256.
Example: byte = 255 --> integer = 255 - 256 = -1.
DIM trace(512)
Array of 512 integers
DIM response AS STRING
*
520
Trace response buffer
CALL Send(0, 8, "
*
RST", 1)
Resets the instrument
CALL Send(0, 8, "FORMat INTeger,8", 1)
Data format of 8-bits samples
CALL Send(0, 8, "INITiate", 1)
Single shot initiation
CALL Send(0, 8, "
*
WAI;TRACe? CH1", 1)
Queries for channel 1 trace
CALL Receive(0, 8, response$, 256)
Reads the channel 1 trace
PRINT "Number of read bytes ="; IBCNT%
IBCNT% = number of read bytes
The contents of the response$ string of this example will be as follows:
# 3 5 1 4 <8> <byte 1> ... <byte 512> <checksum> <10> ’<10> is terminating LF
nr.of.digits = VAL(MID$(response$, 2, 1))
nr.of.bytes = VAL(MID$(response$, 3, nr.of.digits)) - 2
PRINT "Number of trace bytes ="; nr.of.bytes
sample.length = ASC(MID$(response$, 3 + nr.of.digits, 1))
nr.of.samples = nr.of.bytes / (sample.length / 8)
PRINT "Number of trace samples ="; nr.of.samples
FOR i = 1 TO nr.of.samples
trace(i) = ASC(MID$(response$, i + 3 + nr.of.digits, 1))
IF trace(i) > 127 THEN
trace(i) = trace(i) - 256
END IF
NEXT i
trace bytes
# 3 5 1 4 <8> <byte 1> . . . <byte 512> <checksum> <NL
>
trace sample 512
trace sample 1
byte with decimal value 8
number of trace bytes (514)
number of digits of 514