Electronics > Microcontrollers

Measuring current with a microcontroller

(1/5) > >>

samu1214:
Hi!

I'm doing a project that involves sensing current. I'm charging a battery and I need to control how much current and voltage I'm giving out.

I thought that it would be okay to use an SCR like a 40tps controlled by an MOC3021 optocoupler.

The part I have doubts about: I know because of common-mode voltage that current with a shunt and a simple operational amplifier has to be measured at the low side of the battery ( - ).

I saw a lot of circuits that are especially made for sensing the current with a external shunt, but do I need this if I'm okay with an error of about 3%? I want to measure around 30 A max and 1 A min. I saw some shunts of 0.5 mΩ and 9 W; that will be fine.

I have a lot of trouble to find and understand the dedicated amplifiers for that. Could you suggest a circuit with an LM358 for instance that will be good for my requirements or do I need a dedicated one?

Edit: I saw that the LM358 has an input offset of 2mV, and if i have 1Amp trough the SHUNT it will be 1mV, so its not enough... I saw something about the ACS711, what do you think about?

Thanks! ;D

peter-h:
You can buy 4 terminal resistors down to milliohms. Needs to be 4 terminal although for applications where you can factory-calibrate the scale and don't care about the tempco (or have a temp sensor so could compensate) you could just use a copper track and it would save you using some weird component.

Low side sensing is simpler, if you can arrange it. But high side is also easy if you can find a supply rail which is a few volts higher still (normally that needs a DC-DC converter, a diode-capacitor pump, or some such).

LM358 does most jobs, senses below GND rail, and is an excellent commodity-grade part which will never become unobtainable, but as you can see you will have a tradeoff between the precision achievable, and how much the shunt needs to drop (which will eventually drive some temp rise on the shunt).

There are loads of better op-amps. I currently use a TLV2333 which is super accurate (chopper stabilised). The TI version is better than the NXP version. But not cheap. Avoid parts from Maxim, LT, Analog. Go for something common as muck.

What micro are you using (what ADC spec)?

coppice:

--- Quote from: peter-h on May 24, 2023, 03:46:56 pm ---You can buy 4 terminal resistors down to milliohms. Needs to be 4 terminal although for applications where you can factory-calibrate the scale and don't care about the tempco (or have a temp sensor so could compensate) you could just use a copper track and it would save you using some weird component.

--- End quote ---
When tellng people that, its important to point out the resistive temperature coefficient of copper 0.4%/C. Most people are unaware just how much copper changes.

You can generally buy two terminal resistors down to 0.5 milliohms, and 4 terminal ones down to <100 microohms. Watch out when using those 2 terminal ones, to keep all copper out of the measurement path, or copper's horrible temperature coefficient will spoil the accuracy of the resistor. See https://www.analog.com/en/analog-dialogue/articles/optimize-high-current-sensing-accuracy.html for some good guidance.

samu1214:
Yes, but the problem its that the 4 terminal resistors are a little bit to expensive, and i need a basic circuit for a PIC16f15223 ( 10bits ADC ) that measure the current with no so high precision. So i need the less components possible, that no generate noise in the ground, and i can get the components everytime, that no goes off stock. I think also about the copper track in the pcb, but what op-amp i should use, what consideration when designing the copper traces i need? I know that the copper its horrible when it gets hot, but i need something thats not require too much components. What do you think?

peter-h:

--- Quote ---resistive temperature coefficient of copper 0.4%/C
--- End quote ---

Yes, which is why I mentioned measuring Tamb.


--- Quote ---but what op-amp i should use
--- End quote ---

How much do you want to spend? If you can drop say 100mV on the shunt, and are happy with say 3% accuracy, an LM358 will do. If you can do factory calibration, you can do a lot better because then you are down to tempco of the Vos of the op-amp.

100mV at 30A is 3 watts though, which is a LOT, so you need to get that down 10x. Either a cheap amp and factory cal, or a decent amp.

This is the basic idea



I see from the DS that Vref can be just over 1V, or multiples. You need to arrange the gain so that at 30A you still have a margin on the ADC range.

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod