Page 1 of 1
Sample ADC while PWM ON phase using MCPWM
Posted: Wed Jul 16, 2025 9:17 pm
by zsp_32
I'm using MCPWM api to control a motor driver DRV8701 and i need to ADC sample the motor current but only during the PWM ON phase. - Is there a way i can trigger an ADC read based on the PWM phase and only read ADC while the PWM is on the ON phase?
- Is there any way i can do this using the ADC continues sampling?
Thanks
Re: Sample ADC while PWM ON phase using MCPWM
Posted: Thu Jul 17, 2025 2:50 am
by Sprite
Not really easily on older chips... however, everything from the C6 on has the event-task system that should make this a lot easier.
Re: Sample ADC while PWM ON phase using MCPWM
Posted: Thu Jul 17, 2025 9:07 am
by MicroController
Can you sample continuously and filter for 'interesting' samples in software? E.g. ignore all values < 10mA and take the average of all other values, or take the maximum value from an X ms period?
Re: Sample ADC while PWM ON phase using MCPWM
Posted: Thu Jul 17, 2025 4:44 pm
by zsp_32
Can you sample continuously and filter for 'interesting' samples in software? E.g. ignore all values < 10mA and take the average of all other values, or take the maximum value from an X ms period?
Yes, this is what i'm currently doing and i was looking to improve this.
Another way i was thinking to deal with this is to wire the PWM out pin to another input pin and trigger an ADC read in an interrupt but i don't think triggering ADC in interrupts is a good idea.