Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow center aligned PWM mode #697

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

aq1018
Copy link

@aq1018 aq1018 commented Nov 23, 2023

This PR adds a function called set_center_aligned_mode_selection() to allow CMS selection. Using center aligned mode reduces current harmonics when driving a motor, and allows predictable ADC sampling of motor current at TIM1 counter overflow.

I tested it to be working on a STM32f401 MCU. I logged values in TIM1_UP_TIM10 interrupt and saw the counter value in the CNT register to be alternating between 0 and 65521, indicating the counter is counting up and down. Since I don't have an oscilloscope, I hooked it up with an LED with 1 Hz PWM frequency, and changing the duty cycle between 50% and 10%. The time interval between the LED seem to be consistent, so I'm pretty sure it is working correctly. It would be great if someone can test this out with an actual oscilloscope though.

P.s. This will work great with the already existing complementary channel and dead time features for driving and sensing BLDC motors.

Please let me know if this PR is acceptable, and I'd be happy to make any changes necessary to get this merged.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant