Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

not able to get any proper PID output

Status
Not open for further replies.

garg29

Advanced Member level 1
Joined
Nov 17, 2004
Messages
443
Helped
25
Reputation
50
Reaction score
10
Trophy points
1,298
Activity points
3,593
I'm trying to design a temperature controller for a oven with PID action. but the resulting temperature is not stable and varying a lot.

PLEASE help me . what method should i use to get zeigler or some other?


With best regards,
GARG
 
Last edited:

What are your variables? floats? ints? Maybe there's an issue there. Also, your output is in units of 'percent', I don't see how that's scaled to your other parameters. If your SetValue and PresentValue are in units of temperature, then you need to do some scaling.

Barry
 
  • Like
Reactions: garg29

    garg29

    Points: 2
    Helpful Answer Positive Rating
Thanks for replying.My variables are float type .the output has been scaled via PWM output with 100 sec cycle time. Is my function otherwise alright?
 

I'm still not sure your scaling is correct. And when you say '100 sec cycle time' do you mean that's your update rate? If so, that sounds a little slow. And I don't see where you set 'lastErr'.

You may be experiencing 'reset windup'. Let's say your SetValue is 100 (degrees??) and your PresentValue is 50. That means your output is going to be stuck at 100. While the PresentValue rises, your integral term (errSum) is continually growing bigger and bigger and bigger-there's no limit on that. Now let's say that finally PresentValue equals SetValue. The P term and D term (assuming that's valid) will be zero, but you've still got that huge I term driving the output to 100, so you are going to keep heating. Your error will go negative and finally your output will go towards zero, but you may have a large error in the negative direction, so your P term is going to drive your output to zero very quickly, once the I term drops.

Try putting a limit on errSum. And look at your variables while the loop is running, that should tell you a lot.

Barry
 
  • Like
Reactions: garg29

    garg29

    Points: 2
    Helpful Answer Positive Rating
Thanks a lot for your reply .

i am facing problem with the derivative term, even if error is only 1 degree C the equation output of the d term when calculated gives me value around 480 which is always greater than 100.

I tried to write that step of errSum limit.it goes like this:
Code:
if(errSum>(Ti * 100/P))
        	errSum=Ti * 100/P;
        	
        if(errSum<0)
        	errSum=0;




Don't know whether is this correct or not? please check this out and i forgot to issue
lastErr = error;
which i did now.
 
Last edited:

i am facing problem with the derivative term, even if error is only 1 degree C the equation output of the d term when calculated gives me value around 480 which is always greater than 100.
That's what I mean about scaling. I think you need something like:

OutputScaled=output*K

And THEN apply your limits to OutputScaled.
 
  • Like
Reactions: garg29

    garg29

    Points: 2
    Helpful Answer Positive Rating
I understand, that the "output=480" issue has been only caused by calculating the derivative incorrectly (not setting lastErr). Obviously, the derivative term should't depend on the temperature error rather than it's change in time. The wrongly calculated derivative term adds a huge P term that causes instable behaviour.

Apart from this problem, the controller should work. Anti-windup should be applied to the integrator. It normally would stops the integration when the manipulated value (output) reaches it's limits. I agree to barry, that the PWM period is probably somewhat long. I understand, that it has been used already when determining the PID parameters according to Ziegler-Nichols, in so far the additional dead time generated by it is reflected in the paramters.

An elegant method to apply anti-windup together with limiting the manipulated value can be achieved by using a velocity algorithm for the PID.

Scaling should be correct according to the tuning method as well.
 
  • Like
Reactions: garg29

    garg29

    Points: 2
    Helpful Answer Positive Rating
Thankyou barry and FvM for helping me. but still i am not able to get a stable output ,my set point is 120 degree C and i am getting the variations from 118-121 degree C .This was with PI cation and not PID. when i take derivative part in action also, the results are horrible.the variation is from 112- 130 degree C.

With PI action only , it takes long time to reach the set-point.

But i still need higher controlling accuracy.i want the temperature to be maintained at fix 120 degree C.

Regarding the output scaling (as barry says) i dont understand what changes are to be made in the code for doing that as my output is scaled from 0-100. I dont understand this " OutputScaled=output*K " :sad:


I request you to Please Help Me.

with best regards
garg
 
Last edited:

Most temperature controllers work fine with PI, you don't necessarily need PID.

Regarding unstable results, I'm unable to comment it unless seeing a plot of actual temperature and controller output (manipulated value) of your controller.
 
  • Like
Reactions: garg29

    garg29

    Points: 2
    Helpful Answer Positive Rating
Thanks a lot for your reply. I'll try to provide a plot of actual temperature and controller output, but i don't have a data logger for that, but still i'll try to do it some way. But still what about the scaling????

Thanks once again for you continous support.
 

I have previously told my view of scaling. The controller should be operated with the same scaling that has been used during parameter identification.
 
  • Like
Reactions: garg29

    garg29

    Points: 2
    Helpful Answer Positive Rating
Generally speaking, higher Integral gain tends to make it less stable (oscillate), as will higher P. It sounds like your system is just not tuned properly, i.e., your gains are not optimized. I would try making the I gain very small and gradually increase the P gain until it becomes wildly unstable; then back off on your P gain and increase the I gain. (This is very unscientific, but welcome to the real world).

Depending on your system, you may NEVER get the performance you want. By the nature of these systems, the temperature will vary around your setpoint a little bit. How much variation can you tolerate? What kind of disturbances can you expect (like somebody opening the oven door)? There are other factors that will affect your performance: how far is your temperature sensor from the heating element? What are the thermal properties of your oven? etc. There is a certain amount of 'art' to tuning these systems. Here's a link that might give you some information and point you toward a solution PID controller - Wikipedia, the free encyclopedia
 
  • Like
Reactions: garg29

    garg29

    Points: 2
    Helpful Answer Positive Rating
Thanks FvM and Barry for helping me.i have obtained the accuracy of 0.1 degree C but the system takes long time to reach setpoint. i mean the rise time to reach the setpoint is very slow. i have applied only PI . is this problem cause of that?
how to increase the rise time?
 

If you increase your P term, you will rise faster, but you might see some overshoot and ringing, but you may converge to the setpoint faster. Is that a tradeoff you're willing to make?
 
  • Like
Reactions: garg29

    garg29

    Points: 2
    Helpful Answer Positive Rating
you may be right barry. by increasing the P term I may get the results faster but this might be true for the Machine(Oven) on which i am testing my PID Controller but when it will be installed on some other oven with different physical properties the results might not be proper. Don't mind but I want to design a proper PID controller. :) . One more thing barry I still haven't understood the "SCALING". can you explain it in bit layman language.
 

If I understand you correctly, you are testing this on one oven, but are then going to install it on a different one? There is no one set of parameters that will work for all plants (ovens). You have to tune the controller for each different application.

As far as scaling, I simple meant that you were initially limiting your output to 100 PERCENT but your inputs (setvalue and presentvalue) are in some other units (volts/degree?) The 'scaling' is just an overall gain (which could practically be embedded in your P and I gains)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top