Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Measuring PWM current

  1. #1

    Measuring PWM current

    Hi - I am using a Teensy 3.6 to generate a 20kHz PWM signal and need to measure current being consumed. I understand that measuring PWM current is difficult given you could be measuring at a PWM transition such as rising / falling / low / high. I don't quite know how to approach this. I assume I need a way to measure current only at the high point of the duty cycle, take x number of samples over time and then average the readings.

    At 20kHz I have a .00005s (0.05us) period so somehow I would need to measure at 0.05us periods at the point the PWM signal is high. I am not sure how to do this.

    I am looking at using the INA219 current sensor - http://www.ti.com/lit/gpn/ina219

    https://learn.adafruit.com/adafruit-...kout/downloads

    Any ideas ?

  2. #2
    Senior Member Jp3141's Avatar
    Join Date
    Nov 2012
    Posts
    458
    If you are just interested in the average current, then most measurement systems will actually do this by default -- they don't (instantaneously) sample the signal and then digitize it. For instance, the TI chip you mention will filter (== average) the signal.

    If you are interested in the peak during the PWM, you would have to sample it (use a sample-and-hold IC), or and ADC that can sample and convert quickly and then trigger it during the PWM high. Note that many loads may have a capacitive element to them and the current you measure may not be the value you expect.

  3. #3
    Senior Member
    Join Date
    Mar 2013
    Posts
    651
    You just need to sample the current several times faster then you are switching. The teensy adc can easily sample fast enough as long as you use DMA sampling. You can also take the measured current as a voltage and filter it down to the average. What specifically are you trying to accomplish with the current?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •