Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

urgent help in Code!!!!

Status
Not open for further replies.
we are using 8 bits and we tried
voltage = (x/255)*(5.0) and we got much larger numbers that had negative signs in front.
our range on x is 71 - 81
the original code is


while(1)
{
lcd_init();

lcd_goto(0) ;
lcd_puts("welcome " ) ;
lcd_goto(0x40);
x=read_a2d(1);
voltage=(x/255.0)*(5.0);
sprintf(outString,"A2D = %d.%d volts",voltage);
lcd_puts(outString);

}

}
so if i comment out voltage and display x my range is 71-81
 
we are using 8 bits and we tried
voltage = (x/255)*(5.0) and we got much larger numbers that had negative signs in front.
our range on x is 71 - 81

so if i comment out voltage and display x my range is 71-81


So what is your input voltage when you did that?? If I calculate it out it's about 1.3 - 1.5 volts.

Where did you get your calculation info??

Here is a snippet from one of my programs, no guarantee it will help.
{

ConvertADC();
while( BusyADC() );
reslta0 = ReadADC();
reslts0 = (reslta0+1)* .488; // Scale for 5Volts
// reslts0 = (reslta0+1)* 2.44; // Scale for 25Volts
}
 
Last edited:
Status
Not open for further replies.

Latest threads

Back
Top