## From theory to application

## From theory to application

(OP)

I'm a ME graduate student with an academic focus in dynamic systems and control theory. At this point in my education, I feel comfortable coming up with the equations of motion of a dynamic system and designing a controller using state-feedback to place the poles of the system. However, if someone asked me to build a controller in order to implement my controller design, I would be lost. In other words, I have a large disconnect in my understanding between theory and application.

Can anyone suggest books or methods to help me close the gap? I'm planning on setting up a home electronics lab for <$1000 in order to work on projects, but I need a place to start. The ballbot project sounds interesting, but I think I need to start with more basic experiments.

Thanks

Can anyone suggest books or methods to help me close the gap? I'm planning on setting up a home electronics lab for <$1000 in order to work on projects, but I need a place to start. The ballbot project sounds interesting, but I think I need to start with more basic experiments.

Thanks

## RE: From theory to application

If you have an observer, the simplest way I know is to implement a controller is to find the transfer function of the controller (gain matrix plus observer). Once you have that, you can then implement it with analog components if desired. Alternatively, you can discretize the transfer function using your chosen sampling rate (simple to do in MATLAB/Octave), then implement the resulting discrete-time transfer function as a set of difference equations in a microprocessor.

Those are the simple answers. It can become much more complicated when you begin to take into account scaling of signals, quantization from analog-to-digital conversion, saturation, failure modes, anti-windup mechanisms if you have integration occurring, filtering to reduce noise, desire to use velocity-form algorithms over position-form algorithms for your controller, choosing feedback gains or tuning constants based on whether you're solving a tracking or a regulating problem, etc. Oh, and you need to know how to measure system parameters and size actuators, and these need to be specified during a system design phase. Then there's the fact that that you can usually only model simple systems and won't actually know the state space or transfer function models of many systems before the system has been constructed, if at all. There's a lot of problems to solve to be able to control a system. See how fun this can be?

xnuke

"Live and act within the limit of your knowledge and keep expanding it to the limit of your life." Ayn Rand,

Atlas Shrugged.Please see FAQ731-376: Eng-Tips.com Forum Policies for tips on how to make the best use of Eng-Tips.

## RE: From theory to application

## RE: From theory to application

A state feedback example is fairly easy to describe. Let's assume you have a plant with two states, e.g., a permanent magnet dc motor (position and velocity are usually chosen), that you'll control by linearly manipulating the applied terminal voltage vt. Assume both states are measured, have voltage values that can be read in to a computer via an ADC, and are stored in variables Position and Velocity. Assume also that you've developed a plant model and a state feedback law u = -Kx, e.g., using pole placement or LQR methods. Using the typical control law for state feedback, you'll simply calculate the variable Voltage, e.g., Voltage = -[K(1)*Position+K(2)*Velocity] and write it to the output port that you are controlling to adjust the terminal voltage. Your sample rate should be around ten times faster than the fastest pole in the closed loop system you are concerned about.

An observer-based controller implementation isn't that much harder if you understand controls pretty well. Now, assume that only the velocity of your motor is available for measurement (e.g., via a tachometer connected to the motor shaft), but the velocity signal is very noisy due to unmodeled dynamics. An observer-based controller can help if the plant is observable. The observer will not only provide you an estimate of the position, but can clean up the noisy velocity signal and provide you with a smooth estimate of the velocity. A controller based on a full-state observer contains both the control law u=-Kx and the estimator, possibly designed via LQR and LQG/LTR methods taking advantage of the separation principle that says you can place the poles of the system and the observer using separate calculations. Note that the observer-based controller receives its input from the output of the plant (Velocity, in this case) and gives Voltage as its output. Once you've designed the controller, find the open-loop transfer function of the controller from Velocity to Voltage. Discretize this transfer function using your sample rate. Write both the numerator and denominator of the discretized controller transfer function in terms of z

^{-x}, where x is an integer valued exponent of z.As an example, I'll assume that your observer is second-order (since your plant is also), so if your controller transfer function denominator was z

^{2}+0.5z+0.01 and your numerator was z^{2}+0.4z+0.03 (both completely made up), divide both by z^{2}to obtain 1z^{0}+0.5z^{-1}+0.01z^{-2}and 1z^{0}+0.4z^{-1}+0.03z^{-2}, respectively. Note that I've kept the 1z^{0}terms even though I could have written them as 1; this lets me know these are the present term coefficients.Recalling that the transfer function is the ratio of the output of the controller Voltage to the input of the controller Velocity in the discrete frequency domain, cross multiplying (using *, but meaning multiplication, not meaning conjugation) gives you: (1z

^{0}+0.5z^{-1}+0.01z^{-2})*Voltage = (1z^{0}+0.4z^{-1}+0.03z^{-2})*Velocity.Since a z

^{-x}term means that signal is delayed by x samples, you'll need to have memory locations for the present value of Voltage and the two previous values of Voltage, as well as the present value of Velocity and the two previous values of Velocity as a function of sampling.To implement the controller algorithm I've made up, create a loop in the code that executes at your desired sample rate with the following instructions. Here's some pseudocode:

## CODE

Does that help?

xnuke

"Live and act within the limit of your knowledge and keep expanding it to the limit of your life." Ayn Rand,

Atlas Shrugged.Please see FAQ731-376: Eng-Tips.com Forum Policies for tips on how to make the best use of Eng-Tips.

## RE: From theory to application

## RE: From theory to application