You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For STM32, the timer used by PWM is a 16 bit.
In file spindle_control.c a new type (SPINDLE_PWM_TYPE) has been define to take care of this.
Still in file stepper.c, there are 2 fields that are used to store rpm values (converted in PWM timer values). Those 2 fields should be defined as SPINDLE_PWM_TYPE too.
Otherwise, when frequency is reduced to e.g. 2000Hz, the max value for the timer is 500 and exceed a uint8_t and stepper.c generates wrong PWM.
The 2 fields to redefine are :
Here my changes:
#ifdef VARIABLE_SPINDLE
//uint8_t spindle_pwm; replaced by mstrens for STM32 by next line
SPINDLE_PWM_TYPE spindle_pwm; // SPINDLE_PWM_TYPE is Uint16_t for STM32 and uint8_t for AVR
#endif
and the second:
#ifdef VARIABLE_SPINDLE
float inv_rate; // Used by PWM laser mode to speed up segment calculations.
//uint8_t current_spindle_pwm; // replaced by mstrens by next line for STM32
SPINDLE_PWM_TYPE current_spindle_pwm; // for STM32 SPINDLE_PWM_TYPE must be uint16_t
#endif
The text was updated successfully, but these errors were encountered:
For STM32, the timer used by PWM is a 16 bit.
In file spindle_control.c a new type (SPINDLE_PWM_TYPE) has been define to take care of this.
Still in file stepper.c, there are 2 fields that are used to store rpm values (converted in PWM timer values). Those 2 fields should be defined as SPINDLE_PWM_TYPE too.
Otherwise, when frequency is reduced to e.g. 2000Hz, the max value for the timer is 500 and exceed a uint8_t and stepper.c generates wrong PWM.
The 2 fields to redefine are :
Here my changes:
#ifdef VARIABLE_SPINDLE
//uint8_t spindle_pwm; replaced by mstrens for STM32 by next line
SPINDLE_PWM_TYPE spindle_pwm; // SPINDLE_PWM_TYPE is Uint16_t for STM32 and uint8_t for AVR
#endif
and the second:
#ifdef VARIABLE_SPINDLE
float inv_rate; // Used by PWM laser mode to speed up segment calculations.
//uint8_t current_spindle_pwm; // replaced by mstrens by next line for STM32
SPINDLE_PWM_TYPE current_spindle_pwm; // for STM32 SPINDLE_PWM_TYPE must be uint16_t
#endif
The text was updated successfully, but these errors were encountered: