Go Down

### Topic: Analog Input Problem (Read 5287 times)previous topic - next topic

#### dcyro

##### Dec 03, 2012, 08:12 am
Hi All,

I really need help on this.

Background:
I have tried to make thermoelectric cooler system wherein I provide pwm outputs and fed to an H-Bridge Circuit that would power a peltier element based on the feedback temperature sensed by my tempretaure sensor (LM35). I followed the system logic accordingly with the same system that can be found in the internet.

Problem:
(1) The readings from my temperature sensor varies from one Analog Input to the other. I have connected the same node, to all the analog Inputs and treated their conversion all the same but they vary in results. It wouldn't be a big problem if they just vary only by a bit. But I noticed that whole 3 of the analog inputs have generally the same value, the others dis agree to these values by +/- 100 mV which in my set-up would be a problem.

(2) The readings from when the system is just reading the temperature inputs vs when the system is reading and producing pwm signals is a lot different. The idle temperature I read is about 22-23 deg C. But when I apply the pwm signal as part of the system, the Temperature it reads becomes 10-15 deg C. I'm not sure if its loading / harmonics affecting the system. Can anyone enlighten me on this one?

(3) The voltage reading from the analog inputs vs the voltage reading from my multimeter also varies. (e.g. multimeter: 0.265 V, in the system: 0.229 V) The values are close if you think of it but with the voltage reading accuracy I need, this is quite a problem.

I'm hoping someone can help me with my problem =(

Thanks!

#### retrolefty

#1
##### Dec 03, 2012, 12:38 pm
Quote
I'm hoping someone can help me with my problem

Not sure it's a problem or just board to board variation. Keep in mind that the standard analogRead() with the default reference used relies on whatever specific board voltage your board has. USB voltage and vary from 4.5 to 5.25 and still be in spec. The on-board +5vdc voltage regulator will rarely be exactly 5.000 volts as it too has a standard tolerance. Now there are several things that one can do to improve the situation such as using a different internal or external voltage reference for the ADC. Or perhaps measure the boards actual Vcc and compensate in software for any slight offset. And lastly my favorite is to use an external I2C or SPI ADC module with better resolution and accuracy they the built in AVR ADC.

As far as your multimeter Vs AVR readings, I would tend to go with your multimeter, but really it gets down to what 'standard' should you use in your overall instrumentation check outs and calibrations. A rule of thumb in the calibration business is that your 'standard references' need to be 10X more accurate then that which you are calibrating.
Lefty

#### MarkT

#2
##### Dec 03, 2012, 04:05 pm
You haven't said what temperature sensor, how its wired etc - please tell us more, it really helps.

A first guess is that you haven't taken any steps to prevent interference from your high power PWM circuitry being picked up
by the temperature sensing analog circuitry.  Switching large currents is usually the recipe for interference.  Is the H-bridge decoupled?
Is the high current circuitry kept away from the temperature sensor?
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

#### dc42

#3
##### Dec 04, 2012, 01:46 am
1. My guess is that you haven't really connected all the analog inputs together securely, but some of them are floating instead. If you read a floating pin, you will generally get a reading close to but not the same as the previous pin you read.

2. You need to separate the ground wires. Dedicate one of the Arduino ground pins to connecting the ground side of the temp sensor (and any other analog inputs you have). Use the other ground pin(s) to connect power to the Arduino (if not using USB power) and the ground side of output devices and your Peltier supply.

3. See Lefty's comment on the accuracy and stability of 5V supply. You might want to use the 3.3V pin as the voltage reference instead.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

#### dcyro

#4
##### Dec 04, 2012, 03:12 am
Hi retrolefty,

Actually I noticed this as well.

Quote
The on-board +5vdc voltage regulator will rarely be exactly 5.000 volts as it too has a standard tolerance.

I do have some questions over this, during idle time, the voltage is around 5.01 V but when I start to drive the h-bridge circuit, the voltage goes to 5.3 V. Is the arduino driving in more voltage from my usb connection?

Another weird thing with multimeter vs arduino readings is during idle time the difference in the readings is around 20 mV but when I drive the h-bridge, the reading is quite a bit different of about 300-500 mV instead of the usual 0.26 V (multimeter) it turns into 0.50+ V (multimeter) which I'm thinking is maybe tied with the voltage in the supply. While this seems a bit logical, the arduino  goes from 0.22 V to 0.15 V which I think is really weird.

I'm sorry I'm a bit of a noob with arduino and I can't really tell why this happens.

#### retrolefty

#5
##### Dec 04, 2012, 03:23 am

Hi retrolefty,

Actually I noticed this as well.

Quote
The on-board +5vdc voltage regulator will rarely be exactly 5.000 volts as it too has a standard tolerance.

I do have some questions over this, during idle time, the voltage is around 5.01 V but when I start to drive the h-bridge circuit, the voltage goes to 5.3 V. Is the arduino driving in more voltage from my usb connection?

Another weird thing with multimeter vs arduino readings is during idle time the difference in the readings is around 20 mV but when I drive the h-bridge, the reading is quite a bit different of about 300-500 mV instead of the usual 0.26 V (multimeter) it turns into 0.50+ V (multimeter) which I'm thinking is maybe tied with the voltage in the supply. While this seems a bit logical, the arduino  goes from 0.22 V to 0.15 V which I think is really weird.

I'm sorry I'm a bit of a noob with arduino and I can't really tell why this happens.

It's kind of hard to diagnosis problems like this over a forum posting. A complete wiring drawing of everything could help. I do know that peltier elements tend to draw a lot of current (they are a very inefficient device) so maybe when driving them via H-drive you are causing ripple voltage to appear on the +5vdc bus. A multimeter is not the best instrument to try and troubleshoot this kind of problem, rather an oscilloscope would actually let you see what is happening to the voltage bus. Also how you have your external grounds wired can cause 'noise' problems that would show up on analogRead values.

Lefty

#### dcyro

#6
##### Dec 04, 2012, 03:47 am
Hi MarkT,

As I have said the temperature sensor I used is an LM35. Here is the Circuit configuration:

Quote
A first guess is that you haven't taken any steps to prevent interference from your high power PWM circuitry being picked up
by the temperature sensing analog circuitry.  Switching large currents is usually the recipe for interference.  Is the H-bridge decoupled?
Is the high current circuitry kept away from the temperature sensor?

With this, I guess I haven't done this part. I just thought to test this first before I do anything else. If however this is causing the problem, do you have any advise so that I can avoid this situation? I haven't decoupled the h-bridge and the sensor is quite near the temperature sensor.

Here is the physical set-up:

Hope you can help

#### dcyro

#7
##### Dec 04, 2012, 03:56 am
Hi lefty,

Here is the circuit diagram for the whole set-up.

And I posted the same physical set-up as well on my previous post. All grounds are shared in my protoboard bus. The +bus of my protoboard is connected to the 10V source and I just connected the 5V on some pins in my protoboard.

Yup I think a multimeter can't really help that much here. But I have to make do with the materials I have.

I'm thinking to use op-amps to amplify the LM35 output to a more decent range of voltages instead of using the mV range. Do you think this can help?

dcyro

#### retrolefty

#8
##### Dec 04, 2012, 04:00 am
Is that the actual schematic of the H-drive controller? If so it looks to be subjectable to shoot-through currents and other nasties that could raise havoc with the reset of the system.

Lefty

#### dcyro

#9
##### Dec 04, 2012, 04:05 am
Yes, its the rough design I made. It's able to drive the peltier. Do you have any advise to work against current shoots?

dcyro

#### retrolefty

#10
##### Dec 04, 2012, 04:30 am
What current is the peltier element drawing? There are many commercial H-drive units avalible at very good prices depending on voltage/current ratings, especially from the Asian seller on E-bay.

Lefty

#### dcyro

#11
##### Dec 04, 2012, 04:39 am
At 100% pwm, the current is about 1.7 A. At idle operation the circuit draws 0.01 A. I actually had an HIP4081 before... but something went wrong with it and its now broken.

dcyro

#### retrolefty

#12
##### Dec 04, 2012, 05:17 am
Lots on inexpensive H-drive modules on E-bay. Examples:

http://www.ebay.com/itm/Stepper-DC-Motor-Driver-Board-L298N-Controller-Module-Based-on-L298N-/251174990481?pt=LH_DefaultDomain_0&hash=item3a7b323291

http://www.ebay.com/itm/DC-12-30V-5A-H-bridge-Brush-Motor-Driver-PWM-Brake-For-Smart-Car-Arduino-/170916785405?pt=LH_DefaultDomain_0&hash=item27cb6f2cfd

Lefty

#### dcyro

#13
##### Dec 04, 2012, 08:05 am
Just a thought occured to me... the sampling of the arduino ADC usually takes how long? I actually find it interesting that whenever I sample the 6 channels altogether, there will be some discrepancy on one to three pins... maybe when I turn-on the pwm  it consumes a bit more processing power and thus would need to take longer / more cycles to get the analog voltage?

What do you guys think?

dcyro

#### dc42

#14
##### Dec 04, 2012, 10:05 am

Just a thought occured to me... the sampling of the arduino ADC usually takes how long? I actually find it interesting that whenever I sample the 6 channels altogether, there will be some discrepancy on one to three pins... maybe when I turn-on the pwm  it consumes a bit more processing power and thus would need to take longer / more cycles to get the analog voltage?

The time taken to read the analog voltage depends only on the clock frequency, which is pretty much fixes by the resonator. If you just happened to be sampling the analog inputs at the PWM frequency, then current on the ground line or variation in Vcc caused by the PWM could result in different reading on different pins, because each pin would be reading the voltage during a different part of the PWM cycle. But it's very unlilely that you would get such synchronisation by accident.

I'm thinking to use op-amps to amplify the LM35 output to a more decent range of voltages instead of using the mV range. Do you think this can help?

I can't see any purpose in doing that unless you need to increase the resolution of the sensor. OTOH you might want to use the internal 1.2V analog reference for the ADC, that will increase the resolution anyway and avoid the reading depending on the 5V supply. But you'll have to calibrate the sensor, because although the 1.2V reference is quite stable, its actual value varies between chips.

BTW I usually suggest using the LM34 (Fahrenheit) sensor in preference to the LM35. It can measure temperatures below 0degC without a negative supply, and it has more than double the sensitivity. You need to do some maths in the Arduino to calculate the temperature, so you can calculate it in whatever units you like.

See point #2 in my reply #3 about using a separate ground for the sensor.

Your schematic in reply #7 can't be right, because it has the gates of the upper mosfets in the H-bridge connected to ground. Like lefty, I suggest you use a ready-built H-bridge, or at least an H-bridge chip - preferably a mosfet-based on such as MC33926 or BD6222.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Go Up

Please enter a valid email to subscribe