Arduino Current Sensing

Hi all,

I am currently working on sensing the current used by a robotic device. Consider that I am also using external filters and trying different methods to try to get rid of the noise. The idea is to get a “clean” current signal here, but that is made difficult by the amount of noise I am dealing with.

So I decided to build this mini circuit (see attachement) in order to find out whether or not my Arduino (motor shield) itself is contributing to that noise. As you can see in the schematic, I am using a gain 10 Opamp to amplify the signal that I am sending through the 0.1Ω sense resistor. This amplified signal is then monitored using the analog pin A0. The signal that is being send through the sense resistor is alternating on/off, meaning that I turn pin 3 HIGH for about 0.25 sec then turn it LOW for another 0.25 sec and so on and so forth…

After testing it, I realized that I was getting very small numbers (ranging btw 0 and 4). My guess is that the input signal sent trough pin 3 is pretty low. Any idea on what the magnitude of the signal I am sending through RSense is? I would also welcome any other alternatives of the same purpose.

Screen shot 2012-06-28 at 12.18.38 PM.png

I guess you already burnt your pin 13. Putting a HIGH on that pin while it's connected by almost a short circuit to ground is too much current for the pin.

5V / 0.1 ? = 50A theoretically.

The fuse will stop that at 500mA but the pins are designed for a max of 40mA.

Any pin can't source more than 40 mA

No pin can source or sink 40mA or more without risking permanent damage to the chip. It'll certainly manage more that 40mA for a while, but this overloads and overheats the output transistor on the chip.

The sense resistor needs to be in the current path from the power source. You want a gain of more like 50 to 100 for the opamp to be useful since you don't want the sense resistor to drop more than a small fraction of a volt - this means the sense resistor will dissipate less heat.

I’m using an Arduino mega 2560. I decided to now confirm if my Arduino is sensing current that we can verify somehow. I have tried sensing the current using the circuit shown in the schematic below.

The results I obtained are also shown below. I can see the shift in current consumption when a add/remove different loads but my question is is this considred good enough to approve this Arduino for my project? Any other suggestions for a way to find out whether my Arduino mega 2560 is sensing current correctly?

Screen shot 2012-07-05 at 2.24.25 PM.png

Now you are using an inductive load to blow up pin A0! The diode goes across the motor, not in line with it. See examples for controlling a motor or relay from Arduino for the proper circuit.

sorry off topic, but which circuit programm has that schematic of an arduino?

MarkT - I thought the diode accross the transistor would protect it from back voltage coming from the motor shutting off or going reverse?

lax123 - You can build your own schematics at this link

The diode goes across the inductor - it provides a safe path for current to flow on switch off (inductors resist changes to current flow, and will generate very large voltages if there is no path for the current to keep flowing). Where you have the diode it does nothing as the lower terminal of the inductor will _rise+ to 100's or 1000's of volts on a timescale of microseconds when the transistor switches off, instantly destroying transistor and Arduino.

With the diode across the inductor the lower terminal rises to about 0.7V (or more if a slow diode) above the supply and then the diode safely carries the current. Alas this is still enough to damage the Arduino - add a 10k resistor in series with the analog pin.

There are much smarter and safer ways to sense current... maybe you should do a search for chips designed to do this so you don't waste your AVR chips.