- Is there any particular reason you are using pots instead of fixed resistors?
I tried that before and the tolerance even on the 1% ones was so bad it was hard to get it precise. Much simpler to just trim the bottom pot to output the proportional ADC voltage.
Is it really the resistor tolerance that was bad, or it it the ADC errors that you get from using a high source resistance that was causing the trouble?
- Bear in mind that when you feed the adc from a high source resistance, you get two sources of error, which are the finite input resistance of the ADC (100M according to the datasheet) and the fact that the sampling time is very short and the Arduino ADC code doesn't have any delay between setting the analog mux to the correct channel and starting the conversion. To reduce these errors, connect a capacitor of about 0.1uF between each analog input and ground (also useful for noise suppression), and switch the mux to an unused channel when you are not taking a reading.
Ah thanks yes I already had a 0.1uF on each middle pot pin before the wire going to the analog pin. Should I move this to exactly on the analog pin?
Not necessary unless you have a resistor between the pot and the pin. However, make sure you connect the bottom end of the pot and the ground side of the cap to analog ground, not digital ground.
AceTK: Also to reduce noise I only know to either do an average of the collected figures, do 3 analog reads preceding the one I use and/or run from batteries so there are only stable gently declining volts on vcc. In my current project all 6 analog pins are used. Could I set the mux to something internal like A06 which is AREF I think? Would this remove the need to do the averaging and pre-reads though?
The pre-reads are one way (but not a very good one) of getting round the issue of short sample time and no delay in the analogRead code. A better way is to set the analog mux to the channel you are about to read, then delay, then do the analog read. I found that a delay of about 10us per 100K of source resistance was just about sufficient. However, adding the 0.1uF cap on the input also avoids the need to pre-read.
If you need to do averaging to get stable readings, then either your inputs are picking up noise (which they shouldn't do if you have the 0.1uF caps connected), or the voltage you are reading isn't stable, or the analog Aref isn't stable, or you have noise on the ground line (always use separate analog and digital ground connections to the Arduino).