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 ?