Today is...
Wednesday, March 21, 2018
Welcome to Control.com, the global online
community of automation professionals.
Featured Video...
EtherCAT with CTC’s master lets your multivendor network play well together...
Help keep our servers running...
PID control using C ....Kp, Ki,Kd????
Need help to find Kp, Ki and Kd for a software (C program) PID control...system does not use a electronic PID control. It only has a sensor to read temp thro ADC and DAC to set the temp.

Hi there:
I am a engg Student working on a project. I need to control the temp of a system and want to use a software PID controller for this purpose. I have written the complete line of code in C. But I was wondering how to find the constants Kp, Ki and Kd value for a system that does not use an electronic PID circuit. I have a ADC and a DAC and a complete circuit !
I just need to find the gains Kp, Ki and Kd to implement my program.

In short:.... I need to know Kp, Ki and Kd for a software (C program) PID controller...system does not use a electronic PID control. It only has a sensor to read temp thro ADC and DAC to set the temp.

Can somebody help! It would be of great help. Thanks

Are you looking for the equations for tuning a PID or something else?

I basically want to know how to find Kp. If I can find Kp, I know of the equation to find Ki and Kd..

The whole point behind tuning a control loop is choosing the right gains and constants. So you have to start with a good assumption and depending upon upon the performance you have to adjust these constants. This is the whole basis behind the control loop tuning. But there are certain guidelines for starters, for making a good initial assumption about these constants. For this you have to give step inputs to your process and find what the response time and time delays are in your process. I hope I have pointed you in the right direction.

Lagan

I get you. Can you direct me in some direct wher I can start with some constants for Kp, Ki and Kd.
And also, if I am to give a step input and find the response time, how can I calculate the Kp from that? Becos, if I can calculate the Kp then Ki and Kd wont be difficult to calculate.

By Daniel Chartier on 25 July, 2002 - 7:26 am

Hello, Ranjit;
There are some well known empiric methods used in industry to approach optimal values for Kp, Ki and Kd. The most widely used is the Ziegler-Nichols openloop tests, described in many engineering manuals and on the following website:
"www.act-control.com/ZN.HTM":http://www.act-control.com/ZN.HTM .

To try them out, you must have manual control of the loop you wish to automate, so you can force step inputs and record (trace) output values that you can use for calculations. Might seem tedious, but it is probably your best bet.

Hope this helps,
Daniel Chartier

Hi Daniel Chartier:
Your web site( "http://www.act-control.com/ZN.HTM":http://www.act-control.com/ZN.HTM ) was very useful and I now have have the knowledge I need....or atleast I think I do!!!!!!!
But I have a question for you. Now supposing I give a step input in open loop tuning, say from 30degrees to 40 degrees , and then I draw the graph and find all the valuse of Kp, Ki and Kd. Does this mean that these values will be good, only if run my program for a SETPOINT of 40degrees, and a starting temp of 30degrees? bcos,I see that in the formula(from graph), that the value of time constant T, could vary if the step input was different, say from 30 degrees to 50 degrees.I am right? If now correct me.
It would be great if you can clarify this for me.

emailranjit @hotmail.com

Anybody out there could help answer this question for me!Thanks!

My question is related to the Zeigler Nichols open loop tuning method, also found on the web site: "http://www.act-control.com/ZN.HTM":http://www.act-control.com/ZN.HTM

By Johan Bengtsson on 1 August, 2002 - 3:40 pm

Temperature control is normally a linear process and that effectively means you get the same response everywhere in the working range.

Some things might make in non linear however:
- Heating thru a hot water element where you change the flow of water, in this case the heating power is more or less not linear.
- Some liquid reaches a boiling or freezing point

The general rule is that power->temperature is linear (such as if you use an electrical heater, steam flow, gas or something else giving you a linear control signal -> heating power)

However - there is another issue with your text.
Open loop means you don't use your controller, ie a setpoint change won't do anything at all since the controller is effectively turned off and the
output therefore is not changed. An open loop step response means manually change the output (not the setpoint) from for example 700W to 800W (or whatever is proper for your application) and study the changing temperature.

Closed loop means the controller is working (perhaps not optimized, but at least trying to do it's work).

There seem to be some confusing posts in this thread regarding this. Some methods use an open loop step response, other observes the closed loop and looks for oscillations. Ziegler-Nichols have one method for each, other methods using one or another basic method are described. But the general conclusion is:
Open loop methods: do something with the output (controller in manual ie turned off), measure process value and plot a graph, make measurements in that graph, do some calculations and you get your parameters.
Closed loop methods: insert some parameters, usually a rough guessed gain and the other
turned off to begin with, let the system run and optionally make some disturbances, check for instability, adjust parameters, check again and so on. In some cases you find out all parameters in this way, in other cases you calculate the rest
once you get a system with some certain characteristics.

Ok, a lot of text but I hope it makes it clearer for someone, expecially the original poster!

/Johan Bengtsson

Do you need education in the area of automation?
----------------------------------------
P&L, Innovation in training
Box 252, S-281 23 H=E4ssleholm SWEDEN
Tel: +46 451 49 460, Fax: +46 451 89 833
E-mail: johan.bengtsson @pol.se
Internet: http://www.pol.se/

Thanks a Lot John, that was one piece of text that got me going!
I have done an open loop tuning and the system works very well.
Also, to all the other people who have taken the time to respond to my posting----- "A Big Thank you!"

By Hall, Christopher W on 26 July, 2002 - 3:01 pm

Ranjit

You may be able to get hold of a copy of "Process-Control Systems, Application, Design, Adjustment" by F. G. Shinskey". It was published by McGraw-Hill Book Company. Greg was (maybe still is) a consultant to the Foxboro company for many years and his books are amongst the most readable for process control.

Remember that most PID algorithms are designed to be dimensionless with regard to Gain so that you need to know the range of the input and output
transducers if you wish to perform your calculations in engineering units.

For example a temperature controller may have a gain of 5 with an input range of 150 degrees Celsius and an output range (say to the setpoint of a flow controller adjusting a heating medium) of 25 tonnes/hour. In this case a 1% change in the inlet temperature (1.5 deg C) would produce a 5% change in the setpoint of the flow controller (1.25 t/h). Another way of looking at it would be to say that the gain of the temperature controller is 0.83 tonnes/hour/deg C. All the books I read assume (but generally fail to
mention) that the figures they quote are based on the dimensionless (otherwise known as normalized) approach.

Chris Hall, Control Engineer
Monomers, BP Grangemouth
+44 (0) 1324 49 3862

By Israel Cabrera on 25 July, 2002 - 7:33 am

What about reading some "digital control engineering" literature and find out your transfer Function(discrete) and maybe then some "ziegler&nichols" method can help.

If you have the transfer function of your process(plant) maybe I can help you to calculate those gains. ok?

Israel C.
A control eng. student

By Yosi Feigenbaum on 25 July, 2002 - 11:47 am

I don't know how accuate this is but here goes:

Once you find the ultimate period (Tu) and gain (Ku) of the loop (Use Zeigler-Nichols open loop method) you plug in the following:

For a P only loop: Kp = 0.5 Ku

For a PI loop: Kp = 0.45, Ki = 0.009 Ku/Tu

For a PID loop: Kp = 0.6, Ki = 0.02 Ku/Tu,
Kd = 4.5(Ku)(Tu)

These are rule of thumb calculations.

Good Luck
(8{)} ( .)

Thanks every body for the useful tips and help.
I am heading in the right direction now.

By Ken Irving on 26 July, 2002 - 11:26 am

After seeing all the responses recommending testing and empirical selection of tuning parameters, I'd like to offer a different approach
based on a rough mental model of the system being controlled. Perhaps this is simplistic, but it can yield useful starting values in at least
some situations.

Since Kp relates output effect to input error, one may be able to visualize a reasonable (or maximum, etc.) output effect for some error
value, and thus arrive at a starting Kp value. This should probably be a conservative estimate to avoid initial instability.

If Ki is a pure time parameter, then it relates to the process response time constant, i.e., the time required for an output change to show up in
the measured input. The (initial, rough guess) integral time ought to be at least twice the time constant or the integral effect may be unstable.

Kd is related to the time rate of change of input, so might be chosen relative to how quickly the input is figured to change. Derivative can
be pretty touchy, though, and it may be best to get Kp and Ki working before jumping in with Kd.

The various PID calculation forms mean that these parameters can vary quite a bit between implementations, but if the algorthms are known
then it should be possible to understand their significance in terms of the process units and time factors.

For example, a fan used in HVAC duct static pressure control might change the fan speed 10% in response to 0.1 inch water gage error; the time
constant could be pretty short, on the order to 10s of seconds or less, so an integral time of 30 seconds or so might be ok. Derivative... well,
I usually don't mess much with it, but such a system probably wouldn't ramp faster (or anywhere close to) 1 inch per second, so a derivative
time of 1 second might be a safe (and do-nothing) value. Obviously these sorts of considerations depend on the process under consideration.

Ken

hi i am also going to make same u have but i want to know fully details of yr design so i can help u

By Ibrahim A Fattah on 2 October, 2002 - 6:36 pm

there are many ways to tune your PID one,Z-N method open loop and closed loop,...etc but i can advice you to use a backage called Bestune...it is so useful and i can help you if you can get a copy of that program
thanks
Ibrahim A Fattah
ibr_18_3@yahoo.com

hi

can u send me the c code for your program
vishy (tekky@rediffmail.com)

Hi! Can I get your PID controller code? /Christian