unsigned char Texte[64];
unsigned char Entree[17];
unsigned char *txt;
float f1;
void Write_Word(unsigned int M,char Sign, char remplis)
{
unsigned int i,k,l;
unsigned long M1;
if (Sign>1) return;
if (Sign==0)
{ M1=M;
ultoa(M1,(char *)Entree);
}
else itoa(M,(char *)Entree);
if (remplis>0)
{
k=strlen(Entree);
for (i=0;i<k;i++) Entree[4-i]=Entree[k-i-1];
for (i=0;i<(5-k);i++) Entree[i]=remplis;
}
Entree[5+Sign]=0;
}
void Print_Values(unsigned int Analog)
{
unsigned int j;
unsigned long w;
f1=(float) Analog;
f1=f1*0.0048875; //finding voltage from ADC reading
f1=f1/4.40; //dividing by amplifying factor
f1=f1/120.0; //dividing by burden resistor value to get secondary current
f1=f1*2500.0;
sprintf(txt,"Methode 1 %s Amps\r\n",fltToa(f1,CRam1,3));
PutStr_RS2(txt);
f1=(float) Analog;
f1=f1*0.02545573;
sprintf(txt,"Methode 2 %s Amps\r\n",fltToa(f1,CRam1,3));
PutStr_RS2(txt);
w=(unsigned long)Analog<<8;
j=(unsigned int)( w/10);
k=sprintf(txt,"Methode 3 % 5u mAmps\r\n",j);
PutStr_RS2(txt);
PutStrR_RS2("Use of Write_Word :");
Write_Word(j,0,32); // space for unmeanless digit
Put_RS2(Entree[0]);
if (j<1000) Put_RS2('0'); else Put_RS2(Entree[1]);
Put_RS2('.');
if (j<100) Put_RS2('0'); else Put_RS2(Entree[2]);
Put_RS2(Entree[3]);
Put_RS2(Entree[4]);
Put_RS2('A');
CRLF2();
}
void main()
{
.....
Print_Values(1023);CRLF2();
Print_Values(100);;CRLF2();
Print_Values(10);;CRLF2();
Print_Values(1);;CRLF2();
while(1);
....