I want to control the speed of a motor using PID controller. My problem is, the valid PWM range I can set in my microcontroller is from 0 to 199 but I measure the speed of the motor (using an encoder) in range of ~50 to 6000 RPM.
How can I meaningfully interchange these values?
Example:
I set the target speed to 6000 when motor is at 0RPM. Then the PID starts and at that moment the error is 6000...so the PID gives maximum output which will be 32767. But I only can set the timer PWM from 0~200.
I am using the code in AVR221 application note and there every variable is signed integer (no floating points). My own micro controller is stm32 that can handle floating points efficiently I beleive.