beautypg.com

Sensoray 518 User Manual

Page 35

background image

34

Set Coefficients

This command defines the linearization coefficients for a channel previously declared as a
USER-DEFINED RESISTIVE SENSOR. Three coefficients are specified. The three values
belong to a polynomial of the form:

Each coefficient is represented by four bytes coded in the coprocessor’s internal floating point
format. The first three bytes constitute the mantissa, while the fourth byte represents the
exponent. See chapter 6 for further details on user-defined resistive sensors.

COMMAND: (192 + CHAN),
(A_M0),(A_M1),(A_M2),(A_EXP),
(B_M0),(B_M1),(B_M2),(B_EXP),
(C_M0),(C_M1),(C_M2),(C_EXP)

RESPONSE: NONE

The following code segment will convert a real value to the coprocessor’s internal floating point
format and handshake the resulting four bytes onto the coprocessor. This procedure is used in the
example that follows. You may use this procedure as is or adapt it to whatever programming
environment you may be using.

SUB Send518Real (Number!)

IF Number! <> 0 THEN
Exponent! = INT(LOG(2! * ABS(Number!)) / LOG(2!) + .0000001)
Mantissa& = ABS(Number!) / (2 ^ Exponent!) * 256 ^ 3
IF Number! > 0 THEN Mantissa& = Mantissa& AND &H7FFFFF
MantByte0& = Mantissa& AND &HFF&
MantByte1& = (Mantissa& AND &HFF00&) \ 256
MantByte2& = (Mantissa& AND &HFF0000) \ 256 ^ 2
ELSE
MantByte0& = 0
MantByte1& = 0
MantByte2& = 0
Exponent = -128
END IF

CALL Send518Byte(MantByte0)
CALL Send518Byte(MantByte1)
CALL Send518Byte(MantByte2)
CALL Send518Byte(128 + Exponent)

END SUB