Electronics > Beginners
PID control coefficients - discrete form
(1/1)
illusive:
Hello everybody,
I'm trying to implement a PID control in my microcontroller algorithm. I've done quite a bit of reading the past few days and i have managed to write the PID code structure. Now i have to use one of the more popular experimental methods (Ziegler-Nichols, Cohen-Coon) to get the parameters for the controller, but i'm hitting a wall here. All of these methods describes the tuning processand and calculates the values (Kp, Ti, Td) in the continuous time domain, so all the values i calculate cannot be directly used in the software. I have found books and papersdescribing the approximation process with far to much math and at in the and i'm still not too sure that i can use that information correctly. I'm also finding some simple answers like:

Ki = Proportional gain / Ti
Kd = Proportional gain * Td

I'm manly using the Atmel application note:
AVR221: Discrete PID Controller on tinyAVR and megaAVR devices - https://homepages.uni-regensburg.de/~erc24492/PID-Regler/Atmel-2558-Discrete-PID-Controller-on-tinyAVR-and-megaAVR_ApplicationNote_AVR221.pdf
In this documents the converted coefficients are given as:

Ki=(Kp*T)/Ti
Kd=(Kp*Td)/T

where T is the samplig period.

Can someone recommend me which whay to take, will these simple formulas save the day or do i need to dive in the textbooks? Thanks!
JS:
There are several approximations to take a system from the continuous time domain to the discrete time domain. If you really want to learn about this you should look at Z transformation and ω tranformation.

If you're just trying to take the PID to the μC the first approximation is using it as it is, but only works if the sampling rate is much faster than the speed of the system. Otherwise it becomes unstable and you need to work a bit more.

JS

IanB:

--- Quote from: illusive on September 01, 2018, 12:40:56 pm ---Can someone recommend me which whay to take, will these simple formulas save the day or do i need to dive in the textbooks? Thanks!

--- End quote ---

You are over thinking this. First of all, if you approximate the continuous form of a PID algorithm in the discrete time domain (all real industrial controllers do this), then the tuning will work out fine as long as the sampling interval is short enough (e.g. at least 10x faster than the dominant time constant of your system).

Secondly, if you use the manual tuning method or Ziegler-Nichols method (see Wikipedia article), then you do the tuning with the actual controller online, so the sample interval is automatically taken into account. In the real world people tend to tune the controller less aggressively than theory indicates, so don't worry too much about stability. Just de-tune it a bit if you see too much overshoot or oscillation.

Tuning controllers is an art, not a science. If you try to apply too much science you will just make things too complicated.
Navigation
Message Index
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod