beautypg.com

Teledyne LeCroy X-STREAM OSCILLOSCOPES Remote Control User Manual

Page 302

background image

A

P P E N D I X

I I :

Waveform Template

296

ISSUED: February 2005

WM-RCM-E Rev D

HOW TO CONSTRUCT A FLOATING POINT NUMBER FROM FOUR BYTES

' Routine to construct a floating point number from four bytes.

Function GetFloat(DescPoint as Integer)

' DescPoint is the address of the byte in the waveform descriptor
' where the data begin.
‘ The data are assumed to be in an array called Desc (0 to 350).

' For example, to calculate VERTICAL_GAIN, DescPoint = 156.

' Constants needed by GetFloat
Mult2 = 1 / 128
Mult3 = Mult2 / 256
Mult4 = Mult3 / 256

' Comm_Order is the variable which provides information
' about the order of the bytes in the descriptor and.
' in the waveform data. Comm_Order is the byte at position
' 34 in the descriptor.

' Set ByteOrd = 1 when Comm_Order = 0 for high byte first.
' Set ByteOrd = -1 when Comm_Order = 1 for low byte first.
' Set ByteOrd3 = 3 * Comm_Order.
' ______________________________________________________________

ByteOrd = 1 - 2 * Comm_Order
ByteOrd3 = 3 * Comm_Order
' ______________________________________________________________

FByte = ByteOrd3 ' Sign started

FDigit = Desc(DescPoint + FByte)
FSign = (FDigit And 128) \ 128
FSign = 1 - 2 * FSign ' Sign completed
' ______________________________________________________________

FExponent = FDigit And 127 ' Exponent started
FExponent = 2 * FExponent

FByte = ByteOrd3 + ByteOrd
FDigit = Desc(DescPoint + FByte)
FExpBit = FDigit And 128

If FExpBit = 128 Then FExpBit = 1

FExponent = FExponent + FExpBit - 127 ' Exponent completed
' ______________________________________________________________