PWM current shunt RC filter

Thread Starter

design_12121

Joined Nov 29, 2017
16
Hey guys.

I have an arduino switching a PWM load that I need to measure.

So I have a shunt that goes to a differential operational amplifier, then to a data acquisition device.

The problem is the data acquisition device sees the ripple and reports incorrect values.

I was going to fix it with a low pass RC filter set to 20-50hz but i don't know if I should put it before the opamp or after it.

Also current flows both ways through this shunt. Would this cause issues?
 

philba

Joined Aug 17, 2017
959
I have a similar project underway and was thinking of a sample and hold in sync with the PWM rising edge. Haven't tested the idea, though.
 

Thread Starter

design_12121

Joined Nov 29, 2017
16
That would find the on-load. I'm looking for the RMS value.

Update: An RC filter tuned to 2.8Hz before the OpAmp has good response but huge steady state error, both in charge and discharge.
 

MrAl

Joined Jun 17, 2014
13,704
Hey guys.

I have an arduino switching a PWM load that I need to measure.

So I have a shunt that goes to a differential operational amplifier, then to a data acquisition device.

The problem is the data acquisition device sees the ripple and reports incorrect values.

I was going to fix it with a low pass RC filter set to 20-50hz but i don't know if I should put it before the opamp or after it.

Also current flows both ways through this shunt. Would this cause issues?

Hi,

If this is DC current (even though it can flow both ways) then the simple answer is to use an RC filter. The only trick if you dont need super fast response is to use a high value resistor and high value cap so that your time constant averages over some fairly long time, like 1 second or even more. For example, a 10k resistor and 100uf capacitor gives you a 1 second time constant which should be more than enough to average most ripple caused by some AC source.

When you say "RMS" though, that brings up some questions because for one DC is already in RMS form and for any DC with AC riding on it we would need to know more about the frequency content of the AC part in order to be able to calculate RMS. Sometimes a simple answer iis to multiply by a constant, but with more complicated wave forms we need to take many samples over the wave and actually compute the RMS value using a formula that is made just for that.

What this boils down to is you should provide your circuit as it is now and explain what kind of signal you expect to see or what the current looks like without filtering. If there is really a normal AC component, you have to describe that in detail or mention where it is coming from or what is causing this.j

With simple requirements usually a simple circuit will suffice, but with more stringent requirements sometimes a lightly more complicated circuit is required.
 

Thread Starter

design_12121

Joined Nov 29, 2017
16
You may find this read to be of some help.

Ron
My problem with that would be that my data acquisition is capable of adjusting the current through the arduino and a long term moving average would take away a lot of much needed response. The RC filter is working well enough at this point.


Hi,

If this is DC current (even though it can flow both ways) then the simple answer is to use an RC filter. The only trick if you dont need super fast response is to use a high value resistor and high value cap so that your time constant averages over some fairly long time, like 1 second or even more. For example, a 10k resistor and 100uf capacitor gives you a 1 second time constant which should be more than enough to average most ripple caused by some AC source.

When you say "RMS" though, that brings up some questions because for one DC is already in RMS form and for any DC with AC riding on it we would need to know more about the frequency content of the AC part in order to be able to calculate RMS. Sometimes a simple answer iis to multiply by a constant, but with more complicated wave forms we need to take many samples over the wave and actually compute the RMS value using a formula that is made just for that.

What this boils down to is you should provide your circuit as it is now and explain what kind of signal you expect to see or what the current looks like without filtering. If there is really a normal AC component, you have to describe that in detail or mention where it is coming from or what is causing this.j

With simple requirements usually a simple circuit will suffice, but with more stringent requirements sometimes a lightly more complicated circuit is required.
I guess I need the average value rather that the RMS, since it is DC PWM.
The circuit is to charge and discharge a lithium battery at specific rates.

I'm still trying to determine if discharging at 50% PWM duty cycle on a 100A load wears the battery out the at the same rate as a 100% duty cycle 50A load, but that's a discussion for another forum.

For now, I can overlook not seeing charge current through the shunt, so I'd say this problem is solved, unless someone has any insight on an RC filter that does not kill reverse voltage.

Thanks to all the contributors.
 

philba

Joined Aug 17, 2017
959
Then you want to measure peak V and duty of the pulses, which is exactly what I need to measure. An S&H circuit is right, I believe. Then use duty cycle to compute average.
 

Thread Starter

design_12121

Joined Nov 29, 2017
16
Then you want to measure peak V and duty of the pulses, which is exactly what I need to measure. An S&H circuit is right, I believe. Then use duty cycle to compute average.
I'm sampling at 50hz because the visual studio program slows down if I raise that. Arduino PWM frequency is 490hz so I'd be undersampling by a long shot. The values will be wrong.
 

MrAl

Joined Jun 17, 2014
13,704
My problem with that would be that my data acquisition is capable of adjusting the current through the arduino and a long term moving average would take away a lot of much needed response. The RC filter is working well enough at this point.

I guess I need the average value rather that the RMS, since it is DC PWM.
The circuit is to charge and discharge a lithium battery at specific rates.

I'm still trying to determine if discharging at 50% PWM duty cycle on a 100A load wears the battery out the at the same rate as a 100% duty cycle 50A load, but that's a discussion for another forum.

For now, I can overlook not seeing charge current through the shunt, so I'd say this problem is solved, unless someone has any insight on an RC filter that does not kill reverse voltage.

Thanks to all the contributors.
Hi,

First, since you need average then a regular passive RC filter can average with little problem. Just choose R and C large enough to filter yet small enough to ensure the response is not too slow. That kind of filter is bi directional too so no problem there.

Charging an Li-ion battery cell is the most dangerous mode of operation, but discharging too fast is also bad. This means you have to be sure that your circuit can do it right or else you could end up with a big fire. Large aircraft have been brought down due to Li-ion battery fires and that was just because of cells in storage.
What this means is that controlling the charge and discharge via a microcontroller is a little risky, but at least you should be sure that there can be no large currents into or out of the battery. The current has to be limited at all times.
The best way to get this is to control the charger, not control the current. If you have a charger already built you can just tell it what to do and it will do it, so you dont have to actually measure the current as direct feedback. The measurement then becomes more like a monitor only.
I am not sure what your actual setup looks like though.

Drawing the max current from a battery is probably harder on the life of the battery, but just how much might be hard to say. What we can say is that the battery will not show the true capacity at full current though and the apparent capacity goes up as the current gets lower. How much better this is depends on the actual battery and it's factor for that, often referred to as the "P" factor. The capacity for most batteries is measured at C/5 so if you discharge at C/5 you get the full rating, but if you discharge any higher than that the capacity drops off and at C/1 iit would be as much as 1/2. You'd have to check your battery specs for that though.
For charging, the charge acceptance goes up with current, so charging at the max current is best for efficiency. Unfortunately that's the worst for safety. It's better to charge most slowly if the efficiency is not bad and the time factor does not becomes a problem in the application.
 

Thread Starter

design_12121

Joined Nov 29, 2017
16
First, since you need average then a regular passive RC filter can average with little problem. Just choose R and C large enough to filter yet small enough to ensure the response is not too slow. That kind of filter is bi directional too so no problem there.
If you read the previous posts, I already have done that and it is working.
Unfortunately, it doesn't seem bidirectional from what I'm seeing but that's not much of an issue at the moment.

Charging an Li-ion battery cell is the most dangerous mode of operation, but discharging too fast is also bad. This means you have to be sure that your circuit can do it right or else you could end up with a big fire.
There are several types of Li-ion batteries. The particular one I'm testing is much more resilient than the Lithium Cobalt Oxide batteries you're likely referring to. We typically charge at up to 5C and discharge at 60C. The purpose of this testing is to see if we can raise that limit.

Thank you for the response.
 

MrAl

Joined Jun 17, 2014
13,704
If you read the previous posts, I already have done that and it is working.
Unfortunately, it doesn't seem bidirectional from what I'm seeing but that's not much of an issue at the moment.


There are several types of Li-ion batteries. The particular one I'm testing is much more resilient than the Lithium Cobalt Oxide batteries you're likely referring to. We typically charge at up to 5C and discharge at 60C. The purpose of this testing is to see if we can raise that limit.

Thank you for the response.
Hello again,

A passive RC filter will be bidirectional. You may have to use a non polarized cap though. Check that.

It does not matter what kind of battery you use, the limits are set by the manufacturer not by the individual. There is risk associated with experiments that go outside the recommended range.
 

Thread Starter

design_12121

Joined Nov 29, 2017
16
Hello again,

A passive RC filter will be bidirectional. You may have to use a non polarized cap though. Check that.
Oh you're correct. I'm using an electrolytic at the moment. Good catch.

It does not matter what kind of battery you use, the limits are set by the manufacturer not by the individual. There is risk associated with experiments that go outside the recommended range.
I am the manufacturer. :)
Also it definitely matters what battery you use. Different cathodes, electrolytes, and dimensions greatly change the performance of the battery.
 

MrAl

Joined Jun 17, 2014
13,704
Oh you're correct. I'm using an electrolytic at the moment. Good catch.


I am the manufacturer. :)
Also it definitely matters what battery you use. Different cathodes, electrolytes, and dimensions greatly change the performance of the battery.
Hi,

Yes i mean the manufacturer of the battery itself.
If they make the battery they usually provide spec's although some are better than others.
 

Thread Starter

design_12121

Joined Nov 29, 2017
16
Hi,

Yes i mean the manufacturer of the battery itself.
If they make the battery they usually provide spec's although some are better than others.
Specs don't come out of nowhere, my friend. Someone does testing like this, change the chemistry if need to be, then retest. If the battery proves to be capable of sustaining a certain rating without fast deterioration, it will be sold as such.
In this case, I am that someone. I don't know why it's so hard for you to believe haha
 

MrAl

Joined Jun 17, 2014
13,704
Specs don't come out of nowhere, my friend. Someone does testing like this, change the chemistry if need to be, then retest. If the battery proves to be capable of sustaining a certain rating without fast deterioration, it will be sold as such.
In this case, I am that someone. I don't know why it's so hard for you to believe haha
Hello again,

You sure about that? I am pretty sure i saw them written in the sky the other day after a plane flew by :)

Seriously i may have missed that you were testing the battery. I originally thought you were manufacturing something that ran on a battery. No problem though if you are the one that is to spec this battery, i have no problem with that whatsoever. It may have something to do with the wording though too.
When i test a battery like an alkaline, if it doesnt work i just change to Li-ion and that's how i test a battery. Wait, what? If i am testingt a battery how do i change to another chemistry? A battery to be tested has a certain chemistry period.
So i can understand that you are testing a battery for future sale, but perhaps you can explain how you get the option to "change the chemistry". Is it a battery for a certain application perhaps?
Do you also test at various discharge rates? That could be very informative to customers.
 

Thread Starter

design_12121

Joined Nov 29, 2017
16
The kid is definitely going places...
Great comment. You must be proud.

Hello again,

You sure about that? I am pretty sure i saw them written in the sky the other day after a plane flew by :)

Seriously i may have missed that you were testing the battery. I originally thought you were manufacturing something that ran on a battery. No problem though if you are the one that is to spec this battery, i have no problem with that whatsoever. It may have something to do with the wording though too.
When i test a battery like an alkaline, if it doesnt work i just change to Li-ion and that's how i test a battery. Wait, what? If i am testingt a battery how do i change to another chemistry? A battery to be tested has a certain chemistry period.
So i can understand that you are testing a battery for future sale, but perhaps you can explain how you get the option to "change the chemistry". Is it a battery for a certain application perhaps?
Do you also test at various discharge rates? That could be very informative to customers.
I did not open the post with "I am a battery manufacturer" because that is irrelevant, as is this discussion we are currently having.

There is a lot that goes into the design of a battery. I'm sure you can find a lot of info about that with a simple search.
There are internal differences that dictate the C rating of a battery. There are also differences that dictate the capacity. Doping with different compounds, changing SEI dimensions, changing actual cell dimensions, etc..
There are theoretical ways to estimate performance based on these and a lot of university level research is behind every change but at the end of the day, real world validation is key. You make 1, test, if it does okay at X C for Y seconds, the customer will be happy. Otherwise you change Z and make a new one. Test to see if it does okay at X C for Y seconds.
The batteries I'm currently working on are large prismatic cells and have quite a punch so our regular testing equipment can't really test their current limits.
And we obviously test at different discharge rates and sell based on the .1C capacity but some customers care more about power density than energy density(capacity). Your low rate lithium cobalt sells won't do what these cells do no matter how high their capacity.
 
Top