# Compensation Issue

• posted

I applied a square wave to my system as the input and the output.

From 0 to 10 the car reaches a steady state value as well as when it

goes from 10 to 20. But 20 to 10 , there is a huge error (20%). But when it goes from 10 to 20, a steady state value is reached, and back from 20 to 10, 20% error is observed.

The compensator that was design for the car is

5.3291 (z-0.41) (z-0.05564)

Gc(z) = // -----------------------------------------------

(z-0.9884) (z+0.997)

The actual implementation is

Kz = .263171; (notice the gain is lower than that of the design)

z1 = -.41 ; z2 = -.05564 ; p1 = -.9884; p2 =.997 ;

uk = (p1+p2)*uk_1 -1.0*(p1*p2)*uk_2 +Kz*(ek + ( z1+z2)*ek_1 + z1*z2*ek_2)

Any ideas, why the discrepancy?

• posted

If you could post a picture to the web someplace, and include a link, it would be helpful. Be sure to include your command that you want to follow.

First some nitpicking:

Your have a discrepancy in your notation. If the 'zn' is supposed to be zeros and the 'pn' is supposed to be poles then

z1 = 0.41, z2 = 0.05564, p1 = 0.9884, p2 = -0.997.

There is also a discrepancy between your transfer function and your difference equation. If your transfer function is

z^2 - 0.4656z + 0.02281 Gc(z) = Kz * ----------------------- z^2 + 0.0086z - 0.98543

then your difference equation should be

u_k = -0.0086 * u_{k-1} + 0.98543 * u_{k-2} + Kz * (e_k - 0.4656 * e_{k-1} + 0.02281 * e_{k-2}).

You have the sign of at least one term reversed in your transfer function.

Actually, you should cascade two 1st-order filters in your difference equation. My paper "Z Transforms for the Embedded System Engineer" at

explains why, as does my book.

That controller has no poles at z = 1. As a consequence, if your system has any disturbances with DC content, or if your plant is not integrating you will never achieve zero steady-state error. Instead, your error will build up to the point where the controller output can cancel the DC content of the disturbance. This is probably what is happening.

See if you can design a plain old PID controller for the thing, and if not try a PID controller with a lead-lag thrown in for some more speed. I'd get it going with a PID at first, then get more fancy after I'd done some measurements.

Now some more nitpicking:

You have a controller pole at -0.997? What are you thinking! I believe that you have done your design using pole placement techniques. Pole placement can be a valuable technique (I've used it myself), but only if you know exactly how tractable your plant is, and define your target pole locations so you're not asking too much of it. What pole placement doesn't do is introduce any sensibility about the fact that plant models can be inaccurate, and will design controllers that are completely unreasonable -- either just plain unstable, or ones that excite plant nonlinearities -- at the drop of a hat.

You should not start out using pole placement. You should either use a robust design technique like H^2 or H-infinity, or you should use the

1950's robust design technique of doing it all on a Bode plot and a Nyquist chart (this is in my book, too). Using a Bode plot is the quickest way I know for getting a known-good system with the best robust performance.
• posted

I did design a PID controller initially. This was the approac I took. First, I did identified the model of the car in s-domain and then designed a controller via Root Loci and simulated in the results (in s-domain). The results were satisfactory. But when I went and implemented the PID controller in Type C, the car was unstable. Then, I converted the PID controller in z-domain and the result was an unstable system. So then I tried to design a digital controller and then converted calculated the difference equation and obtained somewhat satisfactory results.

Is there a special way of implementing a PID controller (digitally)? Do I need an actual integrator of the error? Can I just design the PID controller in the s-domain and then converted it to z-domain, a certain Ts, and implemented according to the difference equation of the transfer in z-domain?

Tim Wescott wrote:

• posted

I designed a PI controller in s-domain. The Gc(s) is

Gc = (336s + 0.5)/s. And then I converted it into z-domain with Ts = .267 seconds and it follows that Gc(z) = (336z-336)/(z-1), which yeilds the following difference equation: uk = uk-1 + 336Ek - 336Ek-1.

So, should I implement that in that in my controller? Is this consider PI controller in the z-domain?

bxa132203 wrote:

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.