Hello someone clever!
I am trying to control an ADC input on an Atmega16 with a potentiometer (I need 4 all in all). The problem is that the taper is extremely un-linear (and only) when connected to the input eg. PA0. Have tried with different potentiometers (from 500k down to 10k). Now I have made a simple buffer circuit with a TL074 op amp. When I plug it out of PA0 it is totally smooth but when connected to and ADC input the op amp can't pull it up or down very much (depends of the settings in the ATM, have tried various configurations from not defining the port in/out to setting it to input/output).
Has anyone experience with how to make a working/matching buffer circuit for the ADC input? Would it be better to make it with transistors instead?
Here is the relevant code (don't know if that could have an influence) and a sketch attached.
void ADC_init(void) { ADMUX=(1<<REFS0); ADCSRA=(1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0)|(1<<ADIE); } unsigned int ADC_read(unsigned char ch) { ch = ch & 0b00000111; ADMUX |= ch; ADCSRA|=(1<<ADSC); // start conversion return 0; } ISR(ADC_vect){ ADCSRA|=(1<<ADIF); ledWrite(ADC); //ADCSRA|=(1<<ADSC); }