I am trying to build a microcontroller based higher payload version of a servo motor using geared induction motor with VFD as a control device.

For this purpose I have selected a 1HP motor running at 1800RPM which is geared down to 30RPM. The position feedback is captured using AS5048 14bit magnetic encoder and Cortex M4 microcontroller.

Since I don't have any idea about State Space Controller and it's implementation using microcontroller, I am planning to implement it using PID controller. I have the following questions related to this

1) Is it possible to implement it using PID controller for varying load without affecting the tuning parameters for a reasonable range of load or does it require changing the parameters on the fly depending on the load?

2) How to select the update rate of PID control loop for motor position control? I am a communicating with the encoder using 400KHz I2C interface and the controller output is given as a voltage signal to the VFD for frequency/speed control.

  • $\begingroup$ Do you know how the load size will change before hand? $\endgroup$
    – koverman47
    Commented Jul 23, 2018 at 22:58

1 Answer 1


Accounting for variable load

In a properly tuned system, the effect of load should mainly affect following error, i.e. how closely actual movement follows desired movement.

Managing load is more about not planning moves which exceed the capabilities of the motor, load and tuning. Ask your system to accelerate too hard, or change acceleration too quickly (high jolt/jerk) and the load could cause the motor to fall behind where it needs to be.

Typically the integral term in your PID is what contributes most to correcting for load induced following error.

Consider a heavy weight on the rim of a lightweight wheel that we want to turn at a constant velocity at 60rpm. Starting with the weight at bottom, we plan 360 waypoints of 1 degree each, with a speed of 360 degrees/second.

At each waypoint, the P term tries to make the motor turn by 1 degree and the D terms tries to keep the speed at 360 degrees/second. With the weight at the bottom, there is no extra load due to gravity, but as the the wheel turns, the action of gravity on the weight will cause the wheel to fall behind where it needs to be.

Since the wheel hasn't quite got as far as it should, the P term will be a little higher than it would be otherwise, similarly as it is running a little slower than it should, the D term will be a little higher. Neither will typically be enough to to completely compensate though.

Note: If you tune P and D aggressively enough to compensate completely for a given load, those terms will almost certainly result in terms which are not aggressive enough for heavier loads and may over-compensate and go unstable for lighter loads. This is one of the reasons why a PID controller is preferable to a PD controller.

This is where the integral term comes in. You tune your PD terms so they don't go unstable at the lightest expected load, and then use the accumulated error to provide the additional lifting force, and limit the following error. As you get closer to peak gravity effect (around 90 degrees), the contribution of the I term will ramp up, and as the wheel turns further and the effect of gravity diminishes, the error will drop and the contribution of the I term will ramp down.

Note that this example also demonstrates that 'following error' is signed - it can be negative.

As the wheel takes the weight over the top, gravity will start accelerating the wheel, rather than decelerating it. Assuming friction is negligible, acceleration due to gravity will mean that the wheel goes slightly further than it should, so the P term will be a little lower than it would be otherwise, similarly as it is running a little faster than it should, the D term will be a little lower, but again it's the mainly accumulated error and the I term which reduces motor torque to compensate for the load.

To summarise, the I term should help compensate for load.

The range of possible loads will be determined by how aggressively you tune your PID terms, and how close your desired performance characteristics (in speed, load and following error) are to the capabilities of your motor - i.e. how much headroom your system has.

The more headroom you have, the softer you can tune your motors and the greater the range of possible loads the system will be able to handle.

PID control rate

Some people say your PID control rate should be as high as possible, but in my experience it's a balancing act depending on your system.

The theory is that the higher the rate of control, the more closely your control loop can track and react to your inputs.

The trouble is, that's fine until you reach the noise floor of the system. If you are working with low resolution encoders, aggressive tuning, a PID loop implemented with integer arithmetic, and your PID control rate is too high, quantisation noise can become significant and your system may not react smoothly to commands to move at slow speeds.

Individually these can all be ameliorated, you can implement PID with floating point arithmetic, tune less aggressively or swap in higher resolution encoders, but don't chase a higher PID control rate than you need.

Note that you cam implement PID loops whose terms are independent of control loop period, but it adds more complexity and more mathematical operations to for normalisation, so it all depends on how much processing headroom your system has.


Your Answer

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

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