I purchased a ACS711 Hall effect-based linear current sensor (http://www.pololu.com/product/2197) and when i read the input it's basically always the same. After doing some research I think it's because there is only a 10bit AD converter and since the current is only changing a little bit it's not enough to catch the change. For my situation I'm pulling around 40-90ma idle and when the motor turns on it jumps up so I want this sensor to see that but it only jumps up to about 120ma. Any tips on how to fix this? Maybe a different sensor? Can I use an amplifier to boost the analog signal?
2You definitely want a different sensor for this. Your current sensor isn't sensitive enough for the current application.– Ignacio Vazquez-AbramsJan 5, 2015 at 3:26
Are you sensing the right line? Because, a motor using only 30-80mA doesn't sound right?– JasmineJan 5, 2015 at 16:19
If you have a transistor, simply amplify the voltage. This allows you set different reference voltages– xyzJan 8, 2015 at 17:49
@Jasmine yeah. I typically have to use 2A adapters for motors. Check that out.– xyzJan 8, 2015 at 17:51
In default configuration, the Arduino's ADC has a range of 0v-Vcc (5v or 3.3v depending on the model). If you are sure your input voltages will always be way lower than Vcc, spreading the ADC's resolution over that range is a waste of accuracy. What you need to do is to properly configure your analog reference voltage.
Basically, this is a way of telling your Arduino "instead of spreading your ADC's bits over a range of 0v to Vcc, just cram all that accuracy between 0v and
- Measure the highest analog output your sensor will give.
- Setup a voltage divider to output a little more than that
- Connect the voltage divider's output to the AREF pin
And that's basically it. As noted, in this specific case you'd probably be better off buying another sensor altogether. However, you won't always have that luxury, and knowing how to set the analog voltage reference always comes in handy.
The problem with this is that the sensor produces voltage offsets from Vcc/2, so your ADC has to support voltages of 0 to about Vcc/2 - ie: you can get only about a resolution gain of 2. To do better you need differential inputs rather than single ended (eg: having the ADC 0-1024 counts span 2.2v - 2.7v if Vcc=5V). That could be done with op amps, or using a different Arduino. I guess I'll write up the latter, since it takes a bit more explaining.– ZephFeb 10, 2015 at 6:05
First, let's look at where you are now. The sensor you have reports current changes at 110mV per amp.
That means 40mA => 4.4mv, 90mA => 9.9mv, and 120mA => 13.2mv -- all very small voltages and small changes in voltage.
Let's work backward, tho. A 5V Arduino in typical ADC mode has a resolution of about 5 mV (5 V / 1024 counts), whilea 3.3V Arduino would have a resolution of about 3.3 mv). Divide those step sizes by 0.11V/A sensitivity and you'll see that a different of 1 count on the ADC will represent about 45ma (5V Vcc) or 30 ma (3.3V Vcc). But there is always inaccuracy and noise, so it's going to be hard to reliably distinguish between 90mA and 120 mA (using your figures).
You can improve that somewhat by switching to a sensor with higher sensitivity (and lower maximum range) like https://www.pololu.com/product/1185 which improves the sensitivity to 185 mV per amp. The step size of the ADC converters would translate to about 26 mA (@5V) or 17.5 mA (@3.3V). That's still pretty tight.
You might be able to manage with the more sensitive sensor and a 3.3V Arduino - if you use capacitors to filter out the electrical noise on the sensor to ADC input, and you average multiple readings in your code to further smooth the values. But it would be marginal.
So you need to amplify the sensor. Yes, you could do that with an external amplifier, like an op Amp. A transistor is more difficult because you need it to stay fairly linear which gets trickier, and you may need more than one stage - so an op amp is easier.
There's another tricky factor - you need to compare the voltage from the sensor to some reference - Vcc/2 for your sensor, and 2.5V for the more sensitive one. The current is proportional to the difference between the sensor reading and that reference (the current going one way for sensor output above reference, the other way for sensor output below reference).
I'll mention another option - you could use an Arduino Mega or Leonardo. These chips offer the option of differential inputs (one pin goes to the signal, and one to the reference), and they have built in selectable amplifiers with up to 200x amplification. That should give you plenty of resolution, without needing to use external active analog circuitry.
You will still need to filter the sensor output to smooth spikes from the motor (current spikes translated to voltage spikes by the sensor). You may need to also filter the Arduino Aref input with a cap.
Suppose you were to use an Arduino Mega or Leonard with the sensor you have. You'd want a Vcc/2 reference, which could simply be two identical resistors (say 10K ohm) between Vcc and Ground as a voltage divider (and maybe a cap to ground for filtering). You would still probably need to calibrate by finding the ADC value for no current as your reference and subtract that from the reading you get when current is flowing.