Reading Analog pins issue

Hello all, Im having a strange issue arrive when i try an read 2 different pins. Im using an Arduino UNO (Sparkfun Redboard)

So my routine samples a thermistor (temp probe) on A0 every 10ms and returns an average after 200 samples via some fun math... works great, dead on with the temp.

When I add in another routine to read a POT on A1 or any of the pins it affects the reading at A0. The reading on the pot is fine but affects the output to A0???

The Thermistor is on the 3.3V line with an AREF and the POT uses the 5V line... why would this affect the readings at A0? If i pull the jumper from the POT the Thermistor temp/resistance reads normal, place it back on and when i turn the knob the resistance/temp goes up or down...

any advice???

Yes. Post your code. Post your schematic.

When switching between channels of the ADC, it often helps to discard the first reading from each channel (for example, read each channel twice and take only the second reading). Try that and let us know if it helps.

I'm guessing that you're using one of the I/O pins to power your voltage divider for the thermistor circuit. I've seen it done this way before and never understood the reasoning behind it.

BTW. Why the emphasis on your readings being 10ms apart? You could just make 200 consecutive reads for the same purpose. It would likely make your code much less complicated too.

I will post in a few mins, need to get to my laptop.

[quote author=Coding Badly link=msg=2006049 date=1418881792] Yes. Post your code. Post your schematic.

[/quote]

Easy enough to try, let me check it out.

jremington: When switching between channels of the ADC, it often helps to discard the first reading from each channel (for example, read each channel twice and take only the second reading). Try that and let us know if it helps.

No, using the 3.3v w/aref to help with noise... Also tried direct to 5v.... Same issues either way.

Well i found that sampling 10ms apart gave a more stable reading i could sample 200 in a row... I dont think it mattered much. I have a Millis() delay template for my some of my calls so its easy to code. I can fiddle with the millis delay globally so its a but more flexible. However your correct when saying it will be much cleaner. Im usually a KISS (keep it simple stupid) kinda guy but seemed to make sense to keep it.

KenF: I'm guessing that you're using one of the I/O pins to power your voltage divider for the thermistor circuit. I've seen it done this way before and never understood the reasoning behind it.

BTW. Why the emphasis on your readings being 10ms apart? You could just make 200 consecutive reads for the same purpose. It would likely make your code much less complicated too.

Ok so I attached my program... please note i am a NEWBIE and there is a lot of junk in it but feel free to critisize. I use tabs to organize my functions for now, makes it easier for me.

Link to Dropbox, zip of app.

[quote author=Coding Badly date=1418881792 link=msg=2006049] Yes. Post your code. Post your schematic.

[/quote]

Within your thermistor() function you have an error

 thermistorSampleCounter = thermistorSampleCounter++;

Should read

thermistorSampleCounter++;

Thanks Ken, wish that solved the bigger issue but I will take anything!!

KenF: Within your thermistor() function you have an error

 thermistorSampleCounter = thermistorSampleCounter++;

Should read

thermistorSampleCounter++;

I've just spotted another clue (possibly).

fmeroney: When I add in another routine to read a POT on A1 [u]or any of the pins it affects[/u] the reading at A0. The reading on the pot is fine but affects the output to A0???

Surely you only have one pin connected to the pot?

Do you have a schematic of how you have your pot and thermistor connected to the UNO

Well i found that sampling 10ms apart gave a more stable reading

Is that, taking a reading, delaying 10mS and then taking a reading of the same channel? If not that is the way to do it.

You have been asked three times now to post your schematic.

Sorry for it being late, had to make one before I could send it...

Dropbox Link of Schematic

KenF: I've just spotted another clue (possibly).

Surely you only have one pin connected to the pot?

Do you have a schematic of how you have your pot and thermistor connected to the UNO

You are Grumpy, but yes it sampling the same channel A0

Grumpy_Mike: Is that, taking a reading, delaying 10mS and then taking a reading of the same channel? If not that is the way to do it.

You have been asked three times now to post your schematic.

From pg 248 of ATmega328 datasheet:

The ADC is optimized for analog signals with an output impedance of approximately 10 kΩ or less. If such a source is used, the sampling time will be negligible. If a source with higher impedance is used, the sampling time will depend on how long time the source needs to charge the S/H capacitor, with can vary widely. The user is recommended to only use low impedance sources with slowly varying signals, since this minimizes the required charge transfer to the S/H capacitor.

Your thermistor circuit is a 1MΩ/1MΩ divider. You could try connecting a 0.1µF to 1µF capacitor to A0-GND. The A0 signal will then have 100ms to 1sec time constant with lower impedance. If this doesn't work, you may need an op-amp buffer to lower the impedance connected to A0.

You are Grumpy, but yes it sampling the same channel A0

You are obviously a Newbie. When Mike is grumpy, you'll know it. That was not grumpy.

Also, has occurred to you to actually MEASURE the voltage at A0 with a meter under both circumstance ? (please don't tell me you don't have meter).

DITTO the request for a schematic.

Wow, nice find. Let me give that a go. If it doesnt work, maybe a 10k thermistor is a better choice.

Thanks!

dlloyd: From pg 248 of ATmega328 datasheet:

The ADC is optimized for analog signals with an output impedance of approximately 10 kΩ or less. If such a source is used, the sampling time will be negligible. If a source with higher impedance is used, the sampling time will depend on how long time the source needs to charge the S/H capacitor, with can vary widely. The user is recommended to only use low impedance sources with slowly varying signals, since this minimizes the required charge transfer to the S/H capacitor.

Your thermistor circuit is a 1MΩ/1MΩ divider. You could try connecting a 0.1µF to 1µF capacitor to A0-GND. The A0 signal will then have 100ms to 1sec time constant with lower impedance. If this doesn't work, you may need an op-amp buffer to lower the impedance connected to A0.

raschemmel: (please don't tell me you don't have meter).

But just because he doesn't tell you he doesn't have one, won't necessarily mean he has one.... :P

you may need an op-amp buffer to lower the impedance connected to A0.

as in Voltage Follower

Hi, if you use REPLY and not QUICK REPLY you will find a provision called Attachments and other options. Can you please use this to attach you diagrams and pictures, it makes it soooo much easier. Please do not zip unless really necessary.

Thanks Tom........ :)