142
Serial communication
CG Drives & Automation 0-5980-01r2
Programming example:
typedef struct
{
int m:11; // mantissa, -1024..1023
int e: 4; // exponent -8..7
unsigned int f: 1; // format, 1->special emoint format
} eint16;
//---------------------------------------------------------------------------
unsigned short int float_to_eint16(float value)
{
eint16 etmp;
int dec=0;
while (floor(value) != value && dec<16)
{
dec++; value*=10;
}
if (value>=0 && value<=32767 && dec==0)
*(short int *)&etmp=(short int)value;
else if (value>=-1000 && value<0 && dec==0)
{
etmp.e=0;
etmp.f=1;
etmp.m=(short int)value;
}
else
{
etmp.m=0;
etmp.f=1;
etmp.e=-dec;
if (value>=0)
etmp.m=1; // Set sign
else
etmp.m=-1; // Set sign
value=fabs(value);
while (value>1000)
{
etmp.e++; // increase exponent
value=value/10;
}
value+=0.5; // round
etmp.m=etmp.m*value; // make signed
}
R
return (*(unsigned short int *)&etmp);
}
//---------------------------------------------------------------------------
float eint16_to_float(unsigned short int value)
{
float f;
eint16 evalue;
evalue=*(eint16 *)&value;
if (evalue.f)
{
if (evalue.e>=0)
f=(int)evalue.m*pow10(evalue.e);
else
f=(int)evalue.m/pow10(abs(evalue.e));
}
else
f=value;
return f;
}
//---------------------------------------------------------------------------
Содержание emotron TSA Series
Страница 1: ...Emotron TSA Softstarter Instruction manual English Valid from Software version 1 27...
Страница 2: ......
Страница 4: ......
Страница 6: ...2 CG Drives Automation 01 5980 01r2...
Страница 12: ...8 Introduction CG Drives Automation 01 5980 01r2...
Страница 18: ...14 Mounting CG Drives Automation 01 5980 01r2...
Страница 42: ...38 Application guidelines CG Drives Automation 01 5980 01r2...
Страница 46: ...42 Getting started CG Drives Automation 01 5980 01r2...
Страница 70: ...66 Main features CG Drives Automation 01 5980 01r2...
Страница 142: ...138 Functionality CG Drives Automation 01 5980 01r2...
Страница 158: ...154 Troubleshooting Diagnoses and Maintenance CG Drives Automation 01 5980 01r2...
Страница 160: ...156 Options CG Drives Automation 01 5980 01r2...
Страница 168: ...164 Technical data CG Drives Automation 01 5980 01r2...
Страница 202: ...CG Drives Automation 01 5980 01r2 198...
Страница 203: ......