Analog Input Problem

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

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?

  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.

Hi retrolefty,

Actually I noticed this as well.

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.

dcyro:
Hi retrolefty,

Actually I noticed this as well.

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

Hi MarkT,

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

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 :slight_smile:

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. :frowning:

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

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

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

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

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. :roll_eyes:

dcyro

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

Lefty

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

dcyro:
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.

dcyro:
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.

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.

Oh yeah... :blush: they're connected to the source terminal rather than the Drain terminal. Just made a mistake in drawing the circuit. But they're working fine. The only problem is the sensing :frowning:

With the 1.2V Reference, I'll try that. Because I tried using the 3.3V and although the reading seems stable... the output still goes down when the pwm drives the h-bridge.

Here is the corrected version of the circuit diagram.

:drooling_face:

Hi dc42,

I've tried your solution of seperate grounds and it worked! Thanks a lot. I think now my problem is just the timing and the fan. Which is I guess is just my coding and the voltage source for my 5V fan.

Whenever I plug the fan to the arduino it draws up too much power interfering with the sensor and I can't plug it in my external source. Well I think I can just buy a different fan or use a voltage regulator so that I can tap-in to my external source while limiting the voltage. But do you have some insights on how I can fix it without buying a new fan?

Can you provide a link to the specification for the 5V fan?

As you have a 10V supply available (judging from your earlier schematic), how about using a 12V PC fan?

But they're working fine. The only problem is the sensing

No it is not:-

the voltage is around 5.01 V but when I start to drive the h-bridge circuit, the voltage goes to 5.3 V.

That is your problem. This needs to be fixed first before you worry about analogue inputs.
It is a counter intuitive problem, normally voltage goes down when drawing current from a supply.
All the diagrams you posted come up as "image not available" where I am so it is hard to be more specific. I think if you solve this problem then your analogue problems will go away.
So first off lots of decoupling around the H-bridge, and use a star wiring for the ground. That is all the grounds meet at a common point not chained.

Currently, I have this one.

http://db.sanyodenki.co.jp/product_db_e/coolingfan/dcfan/dc_fan_detail.php?master_id=484

But I think I'll be using this one instead. I changed the 10 V to 12 V and so far its working fine.

http://db.sanyodenki.co.jp/product_db_e/coolingfan/dcfan/dc_fan_detail.php?master_id=1926