Download Print this page

Icon Process Controls ProCon DO3000-C Series Quick Start Manual page 24

Dissolved oxygen controller

Advertisement

ProCon
— DO3000-C Series
®
Dissolved Oxygen Controller
void memcpy(void *dest,void *src,int n)
{
char *pd = (char *)dest; char *ps = (char *)src;
for(int i=0;i<n;i++) *pd++ = *ps++;
}
And then make a call to the above memcpy(outdata,&floatdata,4);
Example: Compile binary floating-point number 0100 0010 0111 1011 0110 0110 0110 10B to decimal number
Step 1: Divide the binary floating-point number 0100 0010 0111 1011 0110 0110 0110B into symbol bit, exponential bit and mantis-
sa bit.
0
10000100
11110110110011001100110B
1-bit sign + 8-bit index + 23-bit tail sign bit S: 0 denotes positive number
Index position E: 10000100B =1×2
=128+0+0+0+0+4+0+0=132
Mantissa bits M: 11110110110011001100110B =8087142
Step 2: Calculate the decimal number
D = (−1)×(1.0 + M/223)×2E−127
= (−1)0×(1.0 + 8087142/223)×2132−127
= 1×1.964062452316284×32
= 62.85
Reference Code:
float floatTOdecimal(long int byte0, long int byte1, long int byte2, long int byte3)
{
long int realbyte0,realbyte1,realbyte2,realbyte3; char S;
long int E,M;
float D; realbyte0 = byte3; realbyte1 = byte2; realbyte2 = byte1; realbyte3 = byte0;
if((realbyte0&0x80)==0)
{
S = 0;//positive number
}
else
{
S = 1;//negative number
}
E = ((realbyte0<<1)|(realbyte1&0x80)>>7)-127;
M = ((realbyte1&0x7f) << 16) | (realbyte2<< 8)| realbyte3;
D = pow(-1,S)*(1.0 + M/pow(2,23))* pow(2,E);
return D;
}
Function description: parameters byte0, byte1, byte2, byte3 represent 4 bytes of binary floating point number.
The decimal number converted from the return value.
For example, the user sends the command to get the temperature value and dissolved oxygen value to the probe. The4 bytes
representing the temperature value in the received response frame are 0x00, 0x00, 0x8d and 0x41. Then the user can get the
decimal number of the corresponding temperature value through the following call statement.
That is temperature = 17.625.
Float temperature = floatTOdecimal( 0x00, 0x00, 0x8d, 0x41)
25-0671 © Icon Process Controls Ltd.
+0×26+0×25+0×24 + 0 × 23+1×22+0×21+0×20
7
24

Advertisement

loading
Need help?

Need help?

Do you have a question about the ProCon DO3000-C Series and is the answer not in the manual?