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.
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)
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.
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.
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.
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)?
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.
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.
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?.
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.
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.