I am having trouble getting my PID controller to be accurate over a range of values. My goal is to input a duty cycle for a PWM wave, which controls the speed of a fan rotor. The range of possible speeds should be 300RPM to 2700RPM.

Currently the PID controller is achieving accurate speeds when 800 to 1600 RPM is requested, but below those speeds the output is too high, and above those speeds the output is too low. I think this may be because the relationship between duty cycle and rotor speed is not entirely linear.

Here is our current PID equation: duty_cycle = [ speedset + control + 735] / 4300 Speedset is the requested speed, control is the PID control variable, and the constants are from the equation that we found to be mostly accurate for linking duty cycle with output speed (it is however a linear equation, and was not entirely accurate for extremely low and high data points).

The control variable is: control = 0.104*error + 0.104*previous_error + 0.13*next_error

This is my first time working with PID, so please correct me on anything I am doing wrong. Does anyone have any advice for how I might improve the accuracy of the system at very low and very high speeds?

Block diagram of the system

  • \$\begingroup\$ What is your error signal? (what is it's definition: speed - speedset?) \$\endgroup\$ Sep 15, 2016 at 22:16
  • \$\begingroup\$ Could you provide a control block diagram? Have you tried running it open loop with no load? \$\endgroup\$
    – Voltage Spike
    Sep 15, 2016 at 22:25
  • \$\begingroup\$ error = requested speed - actual speed. I can draw up a code block diagram a bit later when I have time, at a group meeting right now. What do you mean with no load? Without the rotor? \$\endgroup\$ Sep 15, 2016 at 22:25
  • \$\begingroup\$ Provide a block diagram with all the elements in your system \$\endgroup\$
    – Voltage Spike
    Sep 15, 2016 at 22:26
  • \$\begingroup\$ I've added in the block diagram one of my group members created :) \$\endgroup\$ Sep 15, 2016 at 22:31

1 Answer 1


Thanks for your help, everyone. I believe I have found and answer by simply adding a conditional that can identify different operating regions (low speed, medium speed and high speed) and uses a different PID equation for each. This has solved the problem.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.