Conversion Of 16-Bit Samples To Integer - Fluke CombiScope PM3370B User Manual

Autoranging instrument
Hide thumbs Also See for CombiScope PM3370B:
Table of Contents

Advertisement

USING THE COMBISCOPE INSTRUMENTS
3.4.3.2

Conversion of 16-bit samples to integer

As an example a conversion of a trace of 512 "16-bit" samples is shown. The
format is as follows:
# 4 1 0 2 6 <16> <msb 1> <lsb 1> . . . <msb 512> <lsb 512> <checksum> <NL>
PROGRAM EXAMPLE:
In this example a trace acquisition of 2 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 samples is printed. The conversion from double byte (byte1 = msb
and byte2 = lsb) to integer is done as follows (refer to figure 3.12):
If byte1 < 128 then integer = byte1
If byte1
128 then integer = (byte1 - 256)
Example: byte1 = 255 & byte2 = 32 --> integer = (255 - 256)
DIM trace(512)
DIM response AS STRING * 1033
CALL Send(0, 8, " * RST", 1)
CALL Send(0, 8, "INITiate", 1)
CALL Send(0, 8, " * WAI;TRACe? CH1", 1)
CALL Receive(0, 8, response$, 256)
PRINT "Number of trace bytes ="; IBCNT%
'
'The contents of the response$ string of this example will be as follows:
'# 4 1 0 2 6 <16> <msb1> <lsb1> ... <msb512> <lsb512> <sum> <10>
'
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
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(i) = byte1 * 256 + byte2
ELSE trace(i) = (byte1 - 256) * 256 + byte2
END IF
NEXT i
trace bytes
256 + byte2.
*
256 + byte2.
*
trace sample 512
trace sample 1
byte with decimal value 16
number of trace bytes (1026)
number of digits of 1026
256 + 32 = - 224.
*
'Array of 512 integers
'Trace response buffer
'Resets the instrument
'Sets 16 bit sample data format
'Single shot initiation
'Queries for channel 1 trace
'Reads the channel 1 trace
'IBCNT% = length of trace buffer
'Pointer to next sample
'Most Significant Byte
'Least Significant Byte
3 - 33

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents