Hi,
When the error is zero the proportional term will be zero. When the error is negative the proportional output should be negative (even if you clamp the final output to positive values).1) When the error is -ve or zero (i.e. current value is greater than or equal to the set point )then should proportional drive become zero? (i.e. if error.15=1 then prop_drive=0)
Just a matter of taste. Since PBP doesn't support floating point numbers natively you're going to end up with integers anyway. The more resolution you have the better control you'll be able to get.2) Can Kp be a positive integer between 1 to 100 or is it better to have it as 1-10 with 2 decimal digit. i.e 1.12/2.34/5.88 ....etc?
That's up to you really. If the gain actually IS 5 then the output will gat saturated. But if the gain is represented as you outline above, where 5 might mean 0.5 or 0.05 then the P-term would be 108 or 10.3) How does a 0-255 duty cycle relates to value in few hundreds or thousands of proportional drive? For example, if MAX set point is 55 degrees or 416 ADC value and current reading is 200, error is 216, lets say kp is 5 then proportional drive will be 216 x 5 which is far higher than MAX duty cycle of 255. So how do I relate the drive to a number between 0-255?
If large changes in setpoint is to be expected while the regulator is working then I'd suggest you implement some sort of ramp with a slope that the system is capable of following otherwise you'll get into situations as above where there's a HUGE error resulting in a saturated output and integrator windup (which you need to cater for). So, if you (the user) change the setpoint from 100 to 200 then allow the system to internally ramp the setpoint for the regulator up from 100 to 200 along a slope that whatever it is you're regulating can actually follow.
/Henrik.
Bookmarks