Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

ADC value displaying to LCD as voltage

Status
Not open for further replies.

thannara123

Advanced Member level 5
Joined
Jan 7, 2010
Messages
1,580
Helped
122
Reputation
244
Reaction score
114
Trophy points
1,353
Location
India
Activity points
10,378
I am trying to Displaying ADC value to LCD as voltage ie 00.00Volt.

May i get a tutorial program for it .

I just write the following code .please help me

Code:
void value_coverter(unsigned int adc_value)
{   unsigned char temp[8];
    vout = adc_value * 0.00488;
    int_value = vout;   // only decimal part 
    vout = vout - int_value; // for only fractional part 
    temp[0] = int_value /10; // saving first decimal digit
    temp[1]  = int_value % 10; // saving second digit
    temp[2]  = '.';  // point
    vout = vout * 100; // making fractional part to decimal 
    temp[3] = vout /10;
    //temp[4] = vout % 10;
    for(int i=0; i<4; i++)    
    lcd_data(temp[i]+0x38);    
}

I searched the forum a lot of but I didnt get better one .I want to learn it
 

"0.00488" seems to be a scaling factor. it might be possible that this code is for different circuit. you have to find your scaling factor.
also
"vout" should be float and "int_out" should be integer type.
 

hello,


with this coeff of 0.0048 wich represente 5V/1024
to get maxi= 5.00 , better to scale with 0.488 to get 500.0

you must use floating point variable
Code:
float Vout;
.....

Vout= (float) Adc_value * 0.488;
int_Vout=(unsigned int) Vout;
.. etc ..
 

Just for example, like I'm doing this kind of measure
Code:
float POS9V_Measure (void)
{
	return ((float)ADC_Get_Result(POS9V_MES) * ((R9 + R10) / R10) * VDD) / ADC_RESOLUTION;
}
Where R9 and R10 - value of resistors in devider (1k and 10k for example)
VDD = 3.3V or 5.0V
ADC_RESOLUTION is 4096 for 12 bit, 1024 for 10 bit and 256 for 8 bit
POS9V_MES - adc channel, where devider is connected
Returned value - voltage in volts.
 
Vout is declared a global variable ie float vout .

Easyrider83 is float POS9V_Measure (void) function return a correct float value . Can i give it directly give to lcd to display ?
 

You need to use a conversion function like sprintf(...) to convert the float value to an ascii characterstring in a buffer. You can then write the contents of the buffer to the LCD.
 

Whenever I try sprint() it shows only a question mark .
 

It says 'int sprintf(char *s, const char *format, ..... );' in my copy of 'The Standard C Library'. It's in <stdio.h>.
 

hello

Simplest is the best,

i suppose you have a function to write a string to your LCD !
convert 0 -> 1023 to 0.00 to 5.00


Code:
 float vout;
 unsigned int adc_value;
 unsigned int value;

  void value_converter(unsigned int adc_value)
{   unsigned char temp[8];
    vout = (float) adc_value * 0.488;
    value = (unsigned int) vout;   // only decimal part
       temp[0] =  value/100+48;   //Add 48 to get the ASCII character
       temp[1]='.' ;
       temp[2] = ( value/10)%10+48;
       temp[3] =  value % 10 +48;
       LCD_Write_Text(1,1,temp) ;
     
}


//the test 
  
   LCD_CLS();
   for (i=0;i<1023;i=i+16)
   {
   value_converter(i);
   Delay_ms(500);
   }
   while(1);
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top