simplefoc / Arduino-FOC

Arduino FOC for BLDC and Stepper motors - Arduino Based Field Oriented Control Algorithm Library
https://docs.simplefoc.com
MIT License
2.03k stars 521 forks source link

Fix overflow in STM32 dead-time calculation #265

Closed runger1101001 closed 1 year ago

runger1101001 commented 1 year ago

In some cases, when PWM frequency is low and dead_zone is set to a high value the max dead-time is exceeded and the calculations result in a dead_time of 0. This adds a check and sets the dead_time to max value (255) if it gets calculated as 0 but dead_zone is non-zero.