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.

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

formatting link

explains why, as does my book.

Now to answer your question:

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.

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?

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?

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.