Sample ADC while PWM ON phase using MCPWM

zsp_32
Posts: 4
Joined: Wed Apr 28, 2021 10:38 am

Sample ADC while PWM ON phase using MCPWM

Postby zsp_32 » Wed Jul 16, 2025 9:17 pm

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

Sprite
Espressif staff
Espressif staff
Posts: 10593
Joined: Thu Nov 26, 2015 4:08 am

Re: Sample ADC while PWM ON phase using MCPWM

Postby Sprite » Thu Jul 17, 2025 2:50 am

Not really easily on older chips... however, everything from the C6 on has the event-task system that should make this a lot easier.

MicroController
Posts: 2661
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Sample ADC while PWM ON phase using MCPWM

Postby MicroController » Thu Jul 17, 2025 9:07 am

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?

zsp_32
Posts: 4
Joined: Wed Apr 28, 2021 10:38 am

Re: Sample ADC while PWM ON phase using MCPWM

Postby zsp_32 » Thu Jul 17, 2025 4:44 pm

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.

Who is online

Users browsing this forum: Applebot, PerplexityBot, Qwantbot, Semrush [Bot] and 6 guests