Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

current sensing using ADC of microcontroller

Status
Not open for further replies.

bishalpaudel

New Member
I need a current sensor for MPPT based charge controller of max 10A current flowing.
Since the controller shouldn't be expensive, I don't want dedicated current sensors. So I have 2 alternatives:
1) Measuring voltage across Rsense using Op-amp.
2) Measuring voltage across Rsense by ADC of microcontroller.
I was wondered why no one is talking about using micro-controller for current sensing.
Upto now I plan to go for option 2. But please if there are certain things I must consider or if you have a better option, please suggest.

Bishal Paudel
 
I need a current sensor for MPPT based charge controller of max 10A current flowing.
Since the controller shouldn't be expensive, I don't want dedicated current sensors. So I have 2 alternatives:
1) Measuring voltage across Rsense using Op-amp.
2) Measuring voltage across Rsense by ADC of microcontroller.
I was wondered why no one is talking about using micro-controller for current sensing.
Upto now I plan to go for option 2. But please if there are certain things I must consider or if you have a better option, please suggest.

No one is talking about it because it's too obvious to need discussion :D

As in any scheme you simply measure the voltage dropped across a resistor - but you still need an opamp in order to reduce the voltage loss across the resistor to a manageable value (directly feeding the ADC and losing 5V across the resistor isn't generally very practical).
 
I think I will use 0.01ohm resistor (or 0.001 if I get one), so the max voltage i can drop is 1V (or 0.1V for 0.001ohm) and I believe ADC is quite accurate for this resolution.
 
1 to 10mΩ and ZXCT1009 high-side current monitor
 
Last edited:
I think I will use 0.01ohm resistor (or 0.001 if I get one), so the max voltage i can drop is 1V (or 0.1V for 0.001ohm) and I believe ADC is quite accurate for this resolution.
For 0.001 ohm, every Ampere will produce 1mV across your shunt resistor. If you ADC is 10bit and has a 1.024V reference, then your resolution will be 1 Amp. If you get a 12bit ADC, then your resolution will be 250mA. ADCs will have error and likely will jump around due to noise, which will result in your signal jumping around a significant amount.

I you used an amplifier to increase the voltage across the shunt by ~100x, then you'd get a resolution of 10mA (10bit) or 2.5mA (12bit).
 
The first question to ask is where in the circuit you are sensing the current. If one end of the sense resistor is at ground, then you can use the ADC directly, provided you can live with the resolution.

But if you need to do high side sensing, then you need additional circuitry. This can be a differential op-amp, or a high side current sense device like the ZXCT1009 that Mike mentioned. Then you need to know at what voltage above ground the sense resistor is at. The ZXCT1009 has a max of 20V. Fine if you're running a 12V nominal, but won't work (without additional circuitry) for a 24V system. I'm currently using the ZXCT1107 since it is usable up to 36V.

If you need to work at a higher voltage, or you need isolation between the power and measurement circuits, then you'll probably want a hall effect based current sensor.

https://www.allegromicro.com/ has some IC solutions.

**broken link removed** has some torroid modules you loop your power wire through.
 
have you looked at any current shunt monitors? I've had really good results w/ the ina226, as long as you don't mind using I2C. the price is decent also, you only need the one sense resistor and the req'd i2c p/u resistors.
 
Hello there,


You didnt specify what resolution you needed, and it also depends on how much voltage you can afford to loose across the sense resistor. For example, if you can afford a full 1 volt then you might use a 0.1 ohm resistor although it would have to be able to handle the power too, and you'd still need an amplifier.

For 0.010 ohm sense resistor, 10 amps produces 0.1 volts, and that multiplied by 50 gives you 5 volts, so the resolution with a 10 bit ADC is around 5mv, which represents 10ma:
10 amps, 5 volts
1 amp, 0.5 volts
0.1 amp, 0.050 volts
0.01 amp, 0.005 volts

Note however that when we get down to this kind of resolution, input offset of the op amp used for the amplifier becomes important. You should use a chopper stabilized auto adjust offset op amp for best results because even a small offset like 1mv on the input creates an error of 50mv on the output. If you dont need super perfect accuracy then you can get away with a different op amp.

Also, the resistor used as the sense resistor should be grossly overrated to prevent too much heating. Ideally one made for current sensing should be used, possibly a four wire type device.

You can also investigate the current system before added a resistor to see if there is already a series resistor in there. If there is, you can measure the voltage across that to get the current.
 
Here's my basic circuit I think I would start with. Please suggest, I am poor in circuit design. sensors.JPG
 
As Mr. Al has mentioned the input offset voltage becomes important at these voltage and amplification levels.

At 10 amps, the 0.01 ohm resistor develops 100 mV. The LM2904 has an offset of 7 mV, so right there you have degraded the accuracy 7%.
Although you could perform a self-calibration routine in software to take into account that, offset is temperature dependent and thus you would have to recalibrate often.

A better solution is to go to a more modern amplifier like the TLC2272, with only 0.95 mV offset. Less than 1% error is perfectly acceptable for most applications.

Of course, if you even less error, use a chopper stabilized opamp like Mr Al suggests. You can easily find devices with offsets well below 0.1 mV.

Now, I have something for you that most likely you have not considered:
where are you going to connect the opamp's ground, to the battery's negative or the load's negative?
??

It makes a subtle but significant difference. Think about it.
 
Hello again,


I happened to spot another small problem with the circuit posted. The gain works out to around 134 which means that with 10 amps the sense resistor drops 0.100 volts and the gain takes that up to 13.4v which looks too high depending on the voltage supply source for the op amp. A better choice for the gain would be 100 which would limit the output of the op amp to 10 volts. That works as long as you always have at least 11.5 volts available in the system for the op amp supply voltage.

And as for the input offset, even if there is only 5mv that amplifies to 0.5 volts which represents an error of 500ma in the measurement with a full scale of 10 amps.

So the minimum changes should be:
1. Go with a better op amp unless around 5 percent error is acceptable.
2. Lower the gain to 100 if the max supply is 11.5, but lower if the max supply is less.

As schmitt trigger said, we can not tell where the ground is for the circuit. I assume it is at the input solar panel negative terminal. So the op amp ground connects there too.
 
You should also look into Hall Effect current Measuring devices by Allegro. Probably a much better choice overall.

Hi,

I second that vote, unless we need really really good accuracy, which we usually dont.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top