beautypg.com

Sensoray 118 User Manual

Page 15

background image

Sensoray Model 118 Smart A/D™ Instruction Manual

13

Programming

// Send a floating point value to the Smart A/D board.

VOID SendReal( USHORT BasePort, DOUBLE Value )

{

int exponent;

DOUBLE mantissa = frexp( fabs( Value ), &exponent );

if ( exponent < -127 )

{

SendWord(0);

SendWord(0);

}

else

{

SendByte( (UCHAR)( mantissa * 16777216.0 ) );

SendByte( (UCHAR)( mantissa * 65536.0 ) );

SendByte( (UCHAR)( mantissa * 256.0 - ( Value > 0 ? 128.0 : 0.0 ) ) );

SendByte( (UCHAR)( !Value ? 0 : exponent + 128 );

}

}

This manual is related to the following products: