PWM current shunt RC filter

Discussion in 'Test & Measurement Forum' started by design_12121, Dec 6, 2017.

  1. design_12121

    Thread Starter New Member

    Nov 29, 2017
    13
    0
    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?
     
  2. philba

    Active Member

    Aug 17, 2017
    626
    204
    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.
     
  3. design_12121

    Thread Starter New Member

    Nov 29, 2017
    13
    0
    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.
     
  4. design_12121

    Thread Starter New Member

    Nov 29, 2017
    13
    0
    Update: After the opamp works well but does not show reverse current.

    Hopefully it doesn't break the opamp.
     
  5. Reloadron

    Well-Known Member

    Jan 15, 2015
    2,384
    1,061
    You may find this read to be of some help.

    Ron
     
  6. MrAl

    Distinguished Member

    Jun 17, 2014
    4,057
    879

    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.
     
  7. design_12121

    Thread Starter New Member

    Nov 29, 2017
    13
    0
    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.
     
  8. philba

    Active Member

    Aug 17, 2017
    626
    204
    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.
     
  9. design_12121

    Thread Starter New Member

    Nov 29, 2017
    13
    0
    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.
     
  10. philba

    Active Member

    Aug 17, 2017
    626
    204
    You aren't sampling in the arduino?
     
  11. design_12121

    Thread Starter New Member

    Nov 29, 2017
    13
    0
    No, the arduino ADC isn't stable enough.
     
  12. MrAl

    Distinguished Member

    Jun 17, 2014
    4,057
    879
    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.
     
  13. design_12121

    Thread Starter New Member

    Nov 29, 2017
    13
    0
    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.
     
  14. MrAl

    Distinguished Member

    Jun 17, 2014
    4,057
    879
    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.
     
  15. design_12121

    Thread Starter New Member

    Nov 29, 2017
    13
    0
    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.
     
  16. MrAl

    Distinguished Member

    Jun 17, 2014
    4,057
    879
    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.
     
  17. design_12121

    Thread Starter New Member

    Nov 29, 2017
    13
    0
    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
     
  18. philba

    Active Member

    Aug 17, 2017
    626
    204
    The kid is definitely going places...
     
  19. MrAl

    Distinguished Member

    Jun 17, 2014
    4,057
    879
    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.
     
Loading...