C caddybran1977 New Member Apr 13, 2009 #121 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 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
binzer Member Apr 13, 2009 #122 caddybran1977 said: 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 Click to expand... 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: Apr 13, 2009
caddybran1977 said: 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 Click to expand... 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 }