Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Understanding PID control

Status
Not open for further replies.

Overclocked

Member
Hi, I am trying to understand how PID works by implementing it with PWM function that controls a heater. Nothing written down yet, just trying to understand it. So I have some sensor, an input variable, I think most of the time its called PV. My set temp would be SV (set variable Im assuming). So far how I want to implement it like so:

As input temp (PV) gets closer to my set temp (SV), the duty cycle of the PWM function would decrease. Consequently, if its near my set temp, the duty cycle would get close to 0. If its over, it would just not provide any pulse until my PV came down.

Difference in temp = SV-PV

Duty Cycle = Difference in temp *some gain variable

As the difference gets smaller, so does the duty cycle of the PWM function, but it seems that Im missing something. If the difference is Large then so is the duty cycle, and thus it heats up quicker. Now I guess if I were to implement this in a micro, this would happen VERY fast and would have a huge over shoot..So I would have to do this in increments of time. Lets say 250mS. I think I would add up those differences in temperature readings, average them and then make adjustments in the formula above..So now it becomes something like:

delta One = SV-PV
delta two = ...
..delta 4

Add it all up and then average it out, Then apply this formula : Duty cycle = average difference in temp * gain of some sort

There would also need to be a special case if PV is larger than SV, resulting in a negative number in software. Probably something like:

Code:
 if PV<0 then set duty cycle to 0

I feel like I am missing something in my understanding as to how PID controllers work.
 
I am currently completing the design of an analog PID controller. I posted about it, somewhere else in this forum.

I adjusted the PWM commanding the heater to be =0 when the error signal is =0.

Anyway, I learnt that one way to adjust it (not tune it) is to adjust what is called the Xp band. It took me a lot to undesrtand what is it.

Please do not take that I am talking as one who knows. I simply keep trying to see how can I adjust it to obtain a certain response in case of a step change of the setpoint.

Right now, working in the interface that would allow to graph values in real time.

Interested on what you intend to do. Please, keep posting.
 
Check out the Pic app AN964 inverted pendulum for details on PID and code in assembly and C.

What is PID?
Proportional, Integral, Derivative.
The terms used for the different aspects/functions of closed loop control.
Max.
 
p = 0-100% (assume a heating controller)
E=MV-SP; Error measured value - Setpoint (can change base don heating/cooling control)
I = Ki*(integral of the error)
D= Kd*(the derivative of the error)
P = Kp * E (the proportial term)

1/Kp = PB or the proportional band

The units of Ki and Kd are (Repeats/min), repeat/s; try to use these units. Sometimes they are input as fractions,

The I term eventually makes the setpoint and measured value agree. Software has to prevent I from getting out of hand. It has to be clamped at +-100% or lower.

The D term prevents overshoot.

I've added other variables, such as p initial and % change/period

There's an equation that ties all of this together. Your basically doing numerical integration and differentiation over some finite time slice. It's advisable to normalize the values of the constants

Never wrote an auto-tune algorithm, but have tuned many controllers manually with time vs temperature plots. You MUST have a step change above the proportional band to test your changes.

proportional band might be a bit hard to understand, but let;s say the PB = 10, which means gain is 1/10. It just means the output will be 0-100% when the error is 0 to 10 degrees. Once I controlled the PB of one controller to change what I was controlling the temperature of. The controller varied the chamber temperature and I wanted the sample temperature. So, I manipulated the chamber temp to vary the sample temp.
 
Status
Not open for further replies.

Latest threads

Back
Top