i am beginner in Controller Programming. I got the task to transform a signal with the ADC in VOLT. Therefore I choose a LCD from electronic Assembly 4x20 and an Arduino Uno.
To check my values I took a multimeter and compared the Volts. Now I find some differences between the ADC values and the multimeter values. A measurement sequence shows, that with rising volts the error rises too... so it seems to be a gain error.
So my question: how I can compensate this gain error?
From your description I don't think the LCD is causing the problem, it is merely making the problem visible.
This appears to be a programming problem and you might get more advice if you try the 'Programming Questions' section of the forum. In any case you are going to have to post your code in order to get back anything more than speculation.
Have you measured the 5V on your Arduino is actually 5.00V? (its unlikely to be exact BTW - but if you measure it you can
put that value into your code in place of 5.0)
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <avr/io.h>
#include <util/delay.h>
#include <D:\lcdlibrary\lcd.h> //from peter fleury
#include <D:\lcdlibrary\lcd.c>
#include <string.h>
#include <stdint.h>
void ADC_Init(void);
double ADC_Read(uint8_t channel);
double ADC_Read_Avg(uint8_t channel, uint8_t average);
int main(void)
{
lcd_init(LCD_DISP_ON);
char adc_dec[20];
char volts[20];
float sensorvalue;
double volt;
lcd_gotoxy(0,0);
lcd_puts("TEST:");
lcd_gotoxy(0,1);
lcd_puts("******************");
lcd_gotoxy(0,2);
lcd_puts("ADC0_Dez:");
lcd_gotoxy(0,3);
lcd_puts("U in Volt:");
ADC_Init();
  while(1)
  {
uint8_t channel = 0;Â Â Â Â //ADC channel
sensorvalue = ADC_Read_Avg(channel,50);
itoa(sensorvalue, adc_dec, 10);
lcd_gotoxy(10,2);
lcd_puts(adc_dec);
//4. Displayline
volt = (sensorvalue*5)/1024; //5V reference
dtostrf(volt, 5, 3, volts); //double to char
lcd_gotoxy(10,3);
lcd_puts(volts);
_delay_ms(1000);
lcd_gotoxy(10,2);
lcd_puts("Â Â Â ");
lcd_gotoxy(10,3);
lcd_puts("Â Â ");
  }
}
void ADC_Init(void) {
 uint16_t result;
Â
Â
 ADMUX = 0b01000000; //intern reference voltage
Â
Â
 // frequence devider
 ADCSRA = (1<<ADPS1) | (1<<ADPS0);
// ADC converting
 ADCSRA |= (1<<ADSC);
 // activate ADC
 ADCSRA |= (1<<ADEN);
Â
 while (ADCSRA & (1<<ADSC) ) {} //waiting for converting
 result = ADCL;
 result = (8<<ADCH);
}
///////////////////////////////////////////////////////////
////////////////ADC Einzelmessung//////////////////////////
///////////////////////////////////////////////////////////
double ADC_Read(uint8_t channel)
{
 //ADCSRA |= (1<<ADEN);
 // choose the channel
 ADMUX = (ADMUX & ~(0x1F)) | (channel & 0x1F);
 ADCSRA |= (1<<ADSC);      //a changing
 while (ADCSRA & (1<<ADSC)){}  //waiting for converting
 return ADCW;          //read out the ADC
}
///////////////////////////////////////////////////////////
/////ADC Mehrfachmessung mit Mittelwertbbildung////////////
///////////////////////////////////////////////////////////
double ADC_Read_Avg( uint8_t channel, uint8_t average ) //average
{
 double result = 0;
Â
Â
 for (uint8_t i = 0; i < average; ++i )
 Â
  result += ADC_Read( channel );
 return (double)( result / average );
}
and with this source code i have a difference between the ADC channel and a multimeter up to 100 mV (rising voltage leads to an rising error/difference).
Can anybody explain me, how I can make a compensation of the gain error?
Now it appears that you are running conventional C code using the Arduino hardware. Again, you might get more advice if you try a different forum, perhaps AVRfreaks at http://www.avrfreaks.net/.
Also, you should highlight the section of your post that is code and then use the 'Code' button which looks like the # symbol. It changes this:
int main(void)
{
lcd_init(LCD_DISP_ON);
char adc_dec[20];
...
to this:
int main(void)
{
 lcd_init(LCD_DISP_ON);Â
 char adc_dec[20];
...
There is a similar button at the AVRfreaks site and most others I would guess.