• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Arduino pro mini analog inputs

dr pepper

Well-Known Member
Most Helpful Member
Thread starter #1
I constructed a prototype system using an arduino uno, the system has a Lm35 analogue temp sensor as part of the circuit.
The ref for the atod is the internal 1.1v.
The uno works fine, however the pro mini appears to have 10 degrees of noise reading the Lm35 temp.
The system is put together on vero with a 7805 to power things, its well decoupled.
Obviously I have an issue with noise, does the mini have internal reference decoupling?
I tried software averaging over 10 seconds reading every second, its improved but still pants compared to the uno.
 

dr pepper

Well-Known Member
Most Helpful Member
Thread starter #3
That just makes thing even more weird.
I put a 470 ohm in series with the Lm35's power, and a 100 u across the Lm35 power rail too, bit better but still drifty.
I wonder if the 7805 is generating noise, I used some cheap 0.1's for decoupling they might be bad.
I'm not at home right now so I dont have a 'scope to go testing.
I found this, looks like an interesting method, maybe I could use it, it uses the 3.3v o/p, which mine doesnt have, but I could use a volt reference or even a R and a zener, A1 input is connected to the 3.3v regulated o/p, changing the '3.3' I could use what I like below 5v.
float sensorVoltage = analogRead(A0) / (analogRead(A1) * 3.3)
 

dr pepper

Well-Known Member
Most Helpful Member
Thread starter #5
Thats the problem here, the pro mini doesnt have the aref pin brought out, and I dont fancy micro surgery.
 

dr pepper

Well-Known Member
Most Helpful Member
Thread starter #7
May be redacted, but I got your message.
And agreed thats a good approach, I cant see through the black paint on the board, but I dont think theres a cap on vref from what I see, even though the schem says there should be, but these are cheapo boards.
So either I use the 5v rail and suffer the loss in resolution, or bung an op amp on the Lm35 and increase its o/p to 0-5v.
Might try the former first I only want whole degrees not fractions so it might work Ok.
 

dr pepper

Well-Known Member
Most Helpful Member
Thread starter #8
Sussed it.
And I've been here before with other processors, I'm using 2 analogue channels, switching from one to the other is causing a glitch.
I just read 3 times ignoring the first 2 reads, works much better now.
And I dumped the internal ref and use 5v, the resolution is 0.5 degrees, good enough.
 

dknguyen

Well-Known Member
Most Helpful Member
#9
Sussed it.
And I've been here before with other processors, I'm using 2 analogue channels, switching from one to the other is causing a glitch.
I just read 3 times ignoring the first 2 reads, works much better now.
And I dumped the internal ref and use 5v, the resolution is 0.5 degrees, good enough.
Good to know so I can file it away if I run into something like that. Is it in the errata of the MCU?
 

tomizett

Active Member
#10
Also, do you get the same effect by just allowing some settling time after switching inputs (ie, just leaving the converter idle for the same period in stead of reading from it)?
 

Nigel Goodwin

Super Moderator
Most Helpful Member
#12
Sussed it.
And I've been here before with other processors, I'm using 2 analogue channels, switching from one to the other is causing a glitch.
As Pommie has suggested, it sounds like you're not allowing enough time between readings for the sample and hold to charge/discharge.

There's only ONE A2D and sample/hold module, this is multiplexed between the various I/O pins. So when you switch channels you have to wait for the sample and hold to settle to the new reading (while it charges/discharges the internal capacitor), if you don't the readings are completely incorrect.

The time required depends on the specs of the sample and hold, and very much so on the source impedance - with PIC's requiring 2K or less for fastest channel switching.

However, as you're reading an LM35, speed is of no consequence (I don't know what your other reading is from?), so you can take plenty of time for it to settle.

So you MUST:

1) Select the channel you want.
2) Delay while the sample/hold settles (or go and do something else, which is often an option).
3) Only then read the A2D.
 

dr pepper

Well-Known Member
Most Helpful Member
Thread starter #13
Yes I know the chip has one atod, this isnt my first rodeo with micro's.
I messed up assuming the operating system would take care of the acquisition for me, it doesnt, not that theres owt wrong with the o/s.
The Lm35 has sub ohm o/p impedance so you'd think it'd charge the chips i/p pretty quick, must be something in the chip.
I aquired once a second, I changed that to twice a second, but switched to the next i/p after the last conversion, so theres 1/2 a sec between, I used to do this with pic's many moons ago.
 
Last edited:

Nigel Goodwin

Super Moderator
Most Helpful Member
#14
The Lm35 has sub ohm o/p impedance so you'd think it'd charge the chips i/p pretty quick, must be something in the chip.
The spec of the LM35 says it only consumes 60uA from the supply, so I'm dubious about claims of low impedance.

Once a second should be plenty (lot's more than plenty), perhaps you might try connecting a meter between the output of the LM35 and ground, and see how much current it can supply?.
 

gophert

Well-Known Member
Most Helpful Member
#15
A nice overview on ADC is here...
http://gammon.com.au/adc
... one option is to slow the clock speed to allow more time to charge the sample/hold.

Noise on a high impedance source can be quite high (~50 bits) so a buffer may help.

Look at the ADC code (called within AnalogRead()) from the Arduino source code. ...

C:\.....\Arduino\hardware\arduino\cores\arduino\wiring_analog.c
 

MikeMl

Well-Known Member
Most Helpful Member
#16
Have you just simply tried a 10nF to 100nF between the ADC input pin and Vss?
Temperature doesn't change very fast...
 

dr pepper

Well-Known Member
Most Helpful Member
Thread starter #17
I remember on pics shutting the chip down in sleep mode to get the highest accuracy, but I dont need that this time.
All seems to work fine now.
Yep might put a 0.1 on the input just in case some glitches get in, this is used on a vehicle.
 
#18
I had a similar issue when using a temp sensor with my Arduino uno. I ended up using screened cable for the sensor and taking all the grounds to the same pin on the arduino while keeping all wires as short as possible, it seemed to solve the problem for me.
 

Latest threads

EE World Online Articles

Loading

 
Top