This week we are counting down the Ten Commandments of Digital Control, and we are only one day away from the NUMBER ONE Commandment. Before discussing today’s Commandments, Let’s review the first six:

10. Be prepared…Model-based code generation is coming!

9. Be skeptical…Garbage in, garbage out!

8. Sample often.

7. Sample simultaneously and synchronously.

6. Don’t confuse accuracy with resolution.

5. Use IIR filters instead of FIR filters in closed-loop applications.

Yesterday I mentioned a control structure that can not only improve stability, but can improve the dynamic response of your system as well. This leads to Commandment number 4:

4. Use feed-forward structures to supplement feedback structures whenever possible.

When I took control theory in the late 70’s, we never learned about feedforward systems. Everything was based on feedback and “G/(1+GH)”. If I wanted a stiff response out of my control loop, the only thing I knew to do was to jack up my gain until my system was just shy of oscillation! But then I read an article by Curtis Wilson (no relation) in the mid 90’s about feedforward control, and it changed the way I think about control systems. As an example of how feedforward works, consider that you have a motor where you want to control its current. The feedback approach would involve sampling the motor current, comparing it to your desired current to generate an error signal, and then feeding that error signal into a control structure to drive the motor’s voltage. But the feedforward approach would ask, “what is the equation for motor voltage v(t) as a function of current i(t)?” Once the equation is defined, you simply set i(t) in the equation equal to your commanded current, and solve for the voltage v(t) required to achieve this current. Assuming your transfer function is correct, if you then apply that voltage waveform to the motor winding, you should get the desired current waveform.

Feedforward structures are much faster than feedback structures in most cases. This is because a feedback structure has to first develop an error between the commanded and feedback values before it can generate a response. But the feedforward structure doesn’t work on the principle of error. It simply calculates the theoretical value which needs to be applied to your plant’s input (e.g., voltage) to make its output equal to the commanded input value (e.g., current). And it does this without affecting the stability of your system at all, since it does not utilize a feedback loop!

While feedforward structures are great for designing control systems that respond quickly to input changes, they don’t do so well with unpredictable changes in the load or plant. However, this is an area that feedback structures do very well. So, the ultimate solution is a hybrid approach where you use a feed-forward structure to do the heavy lifting to improve transient response when the input changes quickly, and then use feedback to correct for drifting and other unpredictable low frequency effects. In order for the feedback loop to do this, its gain can be set to a fraction of what it would have to be if it was also responsible for the transient response. And lower gains equal better stability! An example of a hybrid feedback/feed-forward controller is shown below.

3. Use observers to snoop on “shy” signals.

Many times you need access to a reclusive signal that you can’t directly measure, such as the back-EMF signal inside a motor, or the angle of the rotor flux. However, if this signal has a well defined relationship to other signals that you DO have access to, you can use something called an OBSERVER to squeeze the missing signal out of the other signals! I continue to be amazed at how well this works! These little filters are incredibly clever, and can seemingly pull a signal out of thin air. By the way, an observer is an example of a feedback structure working in tandem with a feed-forward structure, just like we talked about in the previous section.

There are many different types of observers…too numerous to cover here. Below is an example of a velocity observer typical of what you might find in a digital control system utilizing an encoder. Trying to squeeze velocity information out of an encoder can be daunting, especially if the encoder is moving very slowly. If you simply measure the difference between encoder counts at each sampling update, you end up with a very quantized velocity signal at low motor speeds. On the other hand, if you measure the time between encoder edge transitions, you have lots of numerical resolution, but your velocity sampling frequency gets trashed at low motor speeds. However, an observer can run at the same sampling frequency as the rest of your control loop, and it creates a velocity signal with as much resolution as you want. The feedforward current input signal allows the observer to estimate the velocity signal with zero or near zero phase lag! This is really cool stuff!

We’ve now made it through eight of the Ten Commandments for digital control, but we’ve managed to steer clear of perhaps the most important single peripheral in a digital control application…the PWM module. Tomorrow we will take aim at this module in an attempt to unlock its digital control secrets. In the meantime…

Keep those motors spinning! :-)