I have tried all the suggested software and hardware resolutions (that I have found) relating to this topic and I still get one analog input being affected by the other analog input.
Here is my application:
I am reading a temperature sensor on pin A0 and a potentiometer (setting the temperature trigger value) on pin A5. When the pot is adjusted so that its value is close to the actual temperature of the sensor (A0), the actual temperature reading shoots up 20 degrees F. Then the value of the temperature sensor begins to oscillate back & forth between that 20 degree range. I continue to turn the pot until the trigger temperature value hits that high erroneous temperature reading from A0 and then the oscillation stops - but pin A0 continues to show the high erroneous temperature value.
I’ve tried the “two readings with 10ms wait time between reads” suggestion, as well as the “100nF between the pins and ground” suggestion. I’ve also tried reading a dummy analog pin (with a pull-down resistor) between reads - but to no avail.
I’m sure I’m not the only one performing this application, so there has to be a solution; something I’m missing. Any help would be much appreciated.
Circuit.pdf (1.02 MB)
Two Analog Inputs.txt (1.88 KB)
Please post your schematic
Sounds like you are triggering something that causes disturbance to the 5V rail and affects the
readings. Measure the 5V with a multimeter and see if it is fluctuating in this circumstance?
[ Also, what value pot are you using and what is the output impedance of the temperature
sensor? (Which sensor?) ]
I'm using a 10K pot and the TMP36 sensor (from Sparkfun). Yes, when I put an oscilloscope on the 5v rail, it fluctuates like crazy as soon as the trigger value (from the pot) equals the temperature sensor's value. I've attached the circuit and the sketch.
jremington, I have attached the schematic and sketch back in my original post. MarkT, I can't find actual values for the output impedance in the spec sheet. All I found was this: "The low output impedance of the TMP35/TMP36/TMP37 and its linear output and precise calibration simplify interfacing to temperature control circuitry and ADCs."
Following MarkT's tip, I found that when I insulate the 5v rail from the LED with a 2.7K resistor, the reading becomes stable. (I should always have a resistor there anyway). My job now is to properly substitute the LED with a relay circuit driven by an NPN transistor.
Thank you all for your help! And I'll report back when I'm successful.