Identify Autotune PID algorithm

Go To Last Post
78 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


1. I have checked autotune PID for Delta Temperature PID controller for maintaining temperature of oven.

 

2. We set autotune temperature to 75C & current oven temperature is 38C. In attached graph, y axis is reading of temperature divided by 10 so 700 represent 70.0C & x axis is equal interval of reading every 500millisecond.

 

[moderator: no need to use "attachment" for pictures - you can put them inline like this...]

 

 

3. We started the autotune algorithm and measure temperature with our temperature sensor placed closely to delta sensor and with CRO measured the output signal which turn on/off the relay. 

 

4. Here it goes:

a) First relay is given 100% duty cycle and fully on, upto 75C & temperature keep on increasing

b) At 75C, relay is off completely. Temperature keeps on rising as heater is already heating, it falls to 75 in second stage as in pic.

c) Now again delta PID turn on the relay 100% duty cycle, temperature goes below a bit, since it was already cooling & then start rising again in third stage.

d) In fourth stage, it completely turn off the relay, temperature goes up a bit & then falls down to 75C, at this point delta PID shows Autotune complete

e) Then it try to maintain the temperature by maintaining duty cycle according to PID values calculated. Time period is 20seconds & duty cycle varies. 

 

5) Do anyone know which algorithm it may be?  Since no sine in output is observed so most of algo for PID tune are rejected. So it may be:

a) Cohen-Coon Method (Open-loop Test)

b) Ziegler-Nichols Method( open -loop test)

c) Or it may be Delta own algo

d) ANy other algo which fits such kind of graph

6. If its Delta Algo then its ok, otherwise anyone know what else algo it may be? Or how to tune PID values from it

 

 

Attachment(s): 

Last Edited: Wed. Apr 29, 2020 - 10:37 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Vindhyachal Takniki wrote:
First relay is given 100% duty cycle and fully on, upto 75C & temperature keep on increasing

 

PID, Relay????   You have no P, it's just on/off or bang-bang control, the same as the thermostat in your house! What's to "autotune"?

 

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

While autotune it does complete on/off only. Test many times, different set points, different ovens, all uses same algo as I mentioned.

I suspect it uses  Ziegler-Nichols Method( open -loop test)

 

Since in it:

1.Kp=1.2T/l

2. Ti = 2L

3. Td = 0.5L

As mentioned here:  https://www.google.com/imgres?im...

 

 

Calculated PID values from delta controllers are in test in my post(1) are:

1. P = 18.6

2. I = 251

3. D = 62

 

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the link, that is very interesting!

 

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

PID is "ok" but you can possibly do things a lot better/smarter since you have a controller.  Things that are trivial with code are almost impossible with an analog circuit...the most they can easily muster is PID, you have many more options.

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm with ki0bk / Jim on this.  I think you have over-thought this. 

 

I think it's merely a simple adjustable thermostat -  If too cold, turn on heater; If hot enough, turn off heater.

 

If it is a PID loop, it's miserably underdamped.  You measured 90C in what was supposed to level off at 75!  That's a gargantuan error.  Great theory - but I seriously doubt that's what's going on in practice.  S.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What's to say it's not using fuzzy logic? 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Kartman wrote:

What's to say it's not using fuzzy logic? 

 

The Artificial Intelligence that's in the secret spy satellite with the aliens told me over the 5G network that, "In no way should it be misconstrued that I do not disagree.".   devil   S.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Here is a good article, please read it before you perform any more programming:

 

https://x-engineer.org/graduate-engineering/signals-systems/control-systems/on-off-control-system/

 

 with our temperature sensor placed closely to delta sensor

What are you talking about?  There is only one sensor.

Your post has failed to provide information--WHY?  State in a clear paragraph what you have & what you want to achieve.   What problems are you facing?

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Thu. Apr 30, 2020 - 03:23 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

1. @ Scroungre , In autotune temperature can go high, after autotune is complete, PID values are calculated, and after that if I set 70C, temperature will rise from current_temp to 75C and set there then there is no overshoot.

 

2. @ avrcandies , what is not clear in my post #1. Didnt I mentioned abt delta algo?

Delta has its own sensor with which its calculated autotune PID and then actual temperature maintain.

We placed our sensor close to delta temperature sensor, and noting their reading to get any idea whats happening. 

 

I have trouble understanding which algo may be implemented and I am trying to achive it my self in C language for MCU. 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Delta has its own sensor with which its calculated autotune PID and then actual temperature maintain.

We placed our sensor close to delta temperature sensor, and noting their reading to get any idea whats happening. 

No, your post said nothing about having two sensors, but now your setup is more clear. 

 

So you are saying the system is working perfectly and there is no problem (yes/no)??   

Instead, you are just trying to figure out what their algoritmn is?  Why?  Why not use your own, you will probably have to do that anyway, unless you have their code.

 

Can you vary your heater drive or is is only possible to be only full on and full off?  (full on/off is called bang-bang control)

 

What coding methods have you made so far?  Can you describe what you have tried?

 

Use a solid-state relay, not a mechanical one and you will have more options (no concern then about mechanical wear & tear)

 

 

 

 

   

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Thu. Apr 30, 2020 - 05:08 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@ avrcandies  because its generic temperature sensor reading.

1. Delta PID is very proven and working fine for us also for heater application.

2. We want to write our own autotune PID code

3.We are trying to figure out becuase its mostly proven and used worldwide and trying to get what works best in industry, and given list of probable algo it may be using in my OP.

I suspect its ZN first method(open loop method)

 

4. First trying to understand algo and then we will do code in C for MCu implementation. SSR are most widely used in industrial oven applications. SSR are onlu used in this application.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Delta PID is very proven 

All PID is based on the delta (error) between the setpoint & the measured, so what do you mean?   It has been proven for many decades!

At least you are using SSR---that will allow many other methods, without worrying about wear & tear of relays.

Why not try one of the algorithms?  You will have to start with one.  Have you even considered a bang-bang?  There is a PWM bang-bang variation (a low freq on/off duty, with overall b-b)...the duty is adjusted 

What power levels is this oven?  1000 W or 10000 W? 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Thu. Apr 30, 2020 - 07:12 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

WOW What a derailed thread this one is!

 

  1. OP wishes to write his own PID Autotuner.
  2. OP has commercial controller from Delta Electronics Inc (A Model No. or link to product page would have been useful).
  3. OP decides to reverse engineer the Autotune algorithm the Delta Controller uses.
  4. OP posts a graph of measurements during the Autotune cycle and asks if any freaks recognise it.
  5. All hell lets loose - telling OP he's doing it wrong.

 

That graph though is interesting it seems the algorithm has measured:

 

  1. Rate of rise of process value with a large error from setpoint at startup
  2. Percentage overshoot from startup once setpoint is reached
  3. Rate of fall of process value from initial overshoot
  4. Percentage undershoot from startup
  5. The same four characteristics again but at setpoint.

 

The above then is the step response from initial conditions and at setpoint.

This is where my control theory knowledge runs out. It was nearly 40 yrs ago I learnt all this and also found it quite a difficult subject.

 

I bet there are some "rules-of-thumb" that apply here because the system is so slow, you may not have to do the full mathematical analysis.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't believe you can determine what algorithm is being used by looking at the autotune cycle.

Any algorithm is going to be observing the delay time (td), rise time (T), and the process gain (K) during the autotune cycle.

How those values are used in coming up with the PID parameters is what will vary in the different algorithms.

 

However, this autotune seems very different from those I have observed.

What I have seen, is that the autotune will target a point 75% to 90% of the process Set Point for determining its parameters.

Once those parameters are established, the controller will then proceed to the process setpoint.

(Perhaps it is just different for my limited experience.)

 

Edit: Where you might be able to determine the algorithm is after the autotune cycle, by observing the controller actions and process responses. (But I would not want to try to figure it out!)

David

Last Edited: Thu. Apr 30, 2020 - 11:59 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

All PID controllers use the delta between the setpoint and measured parameter, each will have its own implementation of the actual control implementation. 

So determining how each tuning is specifically implemented, just from the response, is probably near impossible.   

It could very well be Z-N of some sort.  The some sort part would be very difficult to reverse engineer.

Once it is tuned, you can apply a step input and prob determine what P I D  values are being used & even that may be difficult, unless the oven and heater characteristics are well known.

Why not just try using Z-N & see how well the final results match up?

Is the graph the similar during normal operation?  If so, as mentioned in #2, it looks more like some form of bang-bang control & may not even be PID.

 

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Thu. Apr 30, 2020 - 03:29 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 it looks more like some form of bang-bang control & may not even be PID.

Agreed.

Especially as the dTemp/dTime as the temperature approaches the setpoint is constant until the setpoint is crossed!

 

JC 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DocJC wrote:

 it looks more like some form of bang-bang control & may not even be PID.

Agreed.

Especially as the dTemp/dTime as the temperature approaches the setpoint is constant until the setpoint is crossed!

 

JC 

 

Yep, that bugged me too.  I think the OP's observation that the system stabilizes is more because the oven itself, and its contents, have now come to a reasonably constant value, and so adjusting from there takes very little effort at all, as compared to stone cold.

S.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I found two interesting web pages that go some way to explaining Autotune algorithms.

 

https://www.yokogawa.com/uk/library/resources/media-publications/auto-vs-manual-tuning-for-temperature-loops/

 

https://www.eurotherm.com/en/temperature-control-en/pid-control-made-easy/

 

It seems that for a temperature controller the classical methods take much too long, perhaps several hours; also that because heating and cooling are at very different rates the results from the classical methods are far from optimal. Therefore many manufactures "roll-their-own".

 

The Delta Controller in #1 looks like its using a variation of the Cohen & Coon method as described in the Eurotherm document.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

this seems to me like ZS open loop method:  http://techteach.no/publications...

Curve in post#1 has two curves as mentioned in pdf here.

 

1. Now I trying to understand on which of curve this tangent method is applied?

 

2 Also page 4 mentions the formula for PID values where Kp, Ti & Td are mentioned. Surprisingly delta PID autotune parameters after its completed are:   P = 18.6 , I = 251 , D = 62

In Delta Electronics PID you can check calculated PID values.

 

3. if we look on formula page 4
Ti = 4L
Td = 0.5L

 

 

Calculated PID values from Delta PID are always consistent with this formula, we tried very different set point values.

But Delta PID says its PID values while formula in pdf says its KP,Ti,Td values,  but there is striking matching between values & their formulas. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Calculated PID values from Delta PID are always consistent with this formula, we tried very different set point values.

 Does Delta PID imply one is comparing the differences in pid responses to perform an autotune? Maybe multiple passes each make a small adjustment to the parameters & when the changes are small enough, the tuning stops.  

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Will try to implement below method to find tangent on both curves.

Now in microcontroller instead of curves I have values of temperature in array every 500ms. 

So how to find point of inflection and get values of L & T in this in c code?

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

4. First trying to understand algo and then we will do code in C for MCu implementation. 

It seems strange you were asking to determine "which method", which you seem to have ignored.  Now you ask how to program the method you arbitrarily choose.

Have you done any PID coding at all? What has been implemented so far?  You have an array of numbers (data samples) & will have to calculate best-fit slope  and x-intercept. 

Knowing these, you can calculate the T value given the steady state level & the fitted line.

Take your data and do it by hand first....extract the values & put those settings into your PID system...do you get good control response?

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sat. May 2, 2020 - 07:38 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Vindhyachal Takniki wrote:

this seems to me like ZS open loop method:  http://techteach.no/publications...

Curve in post#1 has two curves as mentioned in pdf here.

I disagree:

In the PDF you linked, Figure-1 is misplaced. It relates to Section-1 where loop stability is discussed. I think you confused Figure-1 as a tuning procedure.

 

{I had written a long post about step responses but replaced with this}

 

You are guilty of not reading the Wikipedia article: https://en.wikipedia.org/wiki/PID_controller .

 

In that there is mention of "Relay (Åström–Hägglund) method" which I hadn't previously heard of, I guess you neither.

... the relay method temporarily operates the process using bang-bang control and measures the resultant oscillations

After reading that section on Wikipedia; I'm convinced  the Delta Controller is certainly using a method based on Åström–Hägglund method.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes its one of following:

1. Cohen-Coon Method (Open-loop Test)
2. Ziegler-Nichols Method( open -loop test)

3.Delta Electroics Own algo

 

My best guess is its ZN open loop due to reason in post#20 I mentioned, and trying to get tangent loop on both curves to get the values.

Yes first want to calculate with values only, will see how close I am & then only will go to c code once its values caluclated on paper are ok.

For this I am trying to read how ot get inflexion point by array of values on paper only.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Vindhyachal Takniki wrote:
Yes its one of following:

 

So sure, but yet so little evidence. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Oh I see!

OP's Post #25 is within a minute of my #24. He couldn't have read it.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

e) Then it try to maintain the temperature by maintaining duty cycle according to PID values calculated. Time period is 20seconds & duty cycle varies. 

 

You say it varies ....you mean changing around constantly during the on time?  That is a method to control the amount of output (0 to 100%)... you don't show that

 

Can you read out the PID values that it came up with?  If so, that would greatly help in figuring out what it did.  You have the curves & then the numbers, rather than just the curve.

Since you can probably set the PID values yourself (if you wanted to), it seems like you'd be able to read out what they are after the tuning.

 

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sat. May 2, 2020 - 04:52 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As I mentioned in post#3,

For above graph calculated values are.   Consider these three as equation (A)  . These values one can read from Delta Electonics PID once autotune is done.

1. P = 18.6

2. I = 251

3. D = 62

 

 

As mentioned here:   https://www.google.com/imgres?imgurl=https%3A%2F%2Fi.stack.imgur.com%2F6G8ma.jpg&imgrefurl=https%3A%2F%2Felectronics.stackexchange.com%2Fquestions%2F396028%2Fpi-controller-design-ziegler-nichols-and-unit-step-response-graphing-for-4th-o&tbnid=hJxsSNRwLRsQvM&vet=12ahUKEwj1_czG5I3pAhVXhksFHfgODUkQMygFegUIARDRAQ..i&docid=viLo3yzUxWK-SM&w=1085&h=872&q=ziegler%20nichols%20first%20method&ved=2ahUKEwj1_czG5I3pAhVXhksFHfgODUkQMygFegUIARDRAQ

 

Consider these three as equation (B)

1.Kp=1.2T/l

2. Ti = 2L

3. Td = 0.5L

 

 

If we look closely equation A2 & A3, are closely related to equation B2 & B3.

We tried on two type ofoven with different set points also, this equation always hold.

However Delta PID mentions it as PID values, while formula wise these are Kp,Ti & Td values.

 

 

 

@ N.Winterbottom  thanks, looking it this method now.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

1. Here is another tuning result,  at 80C tuning, blue axis shows the temerature graph scaled to 1. Temperature 10000 indicates 100.00C.

 

2. Red axis is on/off relay.  This is scaled to 10000.  Off means 0 value & on means 10000 value,  this is scaled so that both curves can be compared. 

 

3. My external sensor has some lag in setting temperature, while delta sensor has less lag so it may happen that:

a) During heat, delta gets to 80C fast, meanwhile my sensor is it 78C around

b) Similarly during cool i.e zero pulse, delta temp falls early then my sensor. 

 

After tuning is PWM start happening which then try to maintain temperatrure with PID

 

Calculcated PID values from Delta Electronics PID : 18,302 & 75.

 

4.I have attached excel:  https://drive.google.com/open?id...

a) First colum, is time, this timestamp is from PC, from MCU I take and send read every 500ms.

b) Second column, is temperature/100

c) Third is pulse ssr on/off

d) Fourth is pulse multipled by 10000 just to scale.

 

 

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have suspect that what Delta electronics write are P,I,D values, are actually Kp,Ti & Td values.

where Ti=Kp/Ki  & Td=kd/Kp

 

In attached pdf, page 3 shows how to calculate Kp,ti & Td values.

Little math & it can be shown that Ti=4*Td always.

 

Delta Electronics PID valies,  "I" is always a multiple of 4 of "D".  

We tried in more than 20 setups all give same relationship.

 

I may be wrong here.

 

 

 

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

3. My external sensor has some lag in setting temperature, while delta sensor has less lag so it may happen that:

Why do you not log the controller sensor?  Then you see what it sees & your hypothesis will be easier to match to the situation. 

 

Also, apparently you mean the controller sensor.  Since we are discussing calculations, calling it a delta sensor implies it is performing some mathematical operation (likewise, you could have a peak sensor, or an rms sensor).  So, avoid any potential confusion in the description. Or just call it the sensed temperature.  

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The relay method mentioned in #24 seems like a good bet.  Astrom is well known in the controls world (IEEE Fellow I'm sure).

Why not go read the referenced article and go with that?   If the control stuff is not your suit go hire someone.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here is another Astrom paper that might bear some fruit, it mentions:

 

Another method is to calculate L as the time interval between the step change and the moment the measurement signal crosses a certain small level. The time constant T is then calculated as the time to reach 63% of the final value. This method is also sensitive, since the calculations are based on a few values of the step response only.

 

 Another method, which is based on determination of areas can be used. See Figure 2b. In this method, gain Kp is first determined from the steady-state value of the step response. Area Ao is then determined.

https://www.sciencedirect.com/science/article/pii/S1474667017507624

 

 

Astrom also says:

Derivative action is quite useful for systems which also has lags as we found in Section 5. Derivative action is, however, of limited value for systems that are dead time dominant.

https://www.sciencedirect.com/science/article/pii/S1474667017382162

 

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@ avrcandies  logging Delta Electronics PID temeprature sensor notpossible, as sensor controlelr using it to measure temperture, there is no temperature output from controller.

 

https://www.sciencedirect.com/sc...

This article page 3 mentions for strady statte Kp state to reach, but in our method its oscillatory, since we are assuming Relay on/off completely.

Or i am understanding here wrong?

 

So I took reference from pdf mentioned in #31 post. 

 

 

Here is another good article:  https://www.controleng.com/articles/relay-method-automates-pid-loop-tuning/

but formula are not clear here, due to formatting issues i suppose.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If the controller you have is working fine, why don't you just use that, or get another?  It seems like you are mostly going to be guessing what it is truly doing.  You will never be certain how it calculates internally.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

1. Want to write own PID autotuning algo. Tried earlier with ZS-closed loop and matlab methods but found them difficult to control.

2. This relay method seems very good and in pdf attached it seems like many companies use it also.

3. Tu value :  Page 3 mentions of pdf, in it Tu for control effort seems symmetrical i.e equal Ton & Toff.  But in our case its no equal, should I take it as Tu as in image below? 

4. b value:  Similarly page has formula nad graph: Pu=4*b/pi*a . In my graph "b"  is not symmetrical  . Have mentioned in graph. Will it be same?

5.  a value :  a is amplitude of control voltage. What value should I take here? 

In Delta controller PID, MCU is 3.3V powered, it drives a 12V transistors  which drives a SSR relay to urn on 220Vac/50Hz ac on/off for heater.

So should i take value of a = 1(high) , 3.3V,12V?

 

 

 

 

 

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The solution is quite simple: open the Delta unit up, identify the microcontroller. extract the code and reverse engineer. You'll have a solution much faster than the hit and miss method you're using at the moment.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@kartman , ofcourse we have opened Delta unit and identified the MCU and know its part too.

But we wanted to know exactly which is currently stable product in market and tried to emulate that.

 

Now we are trying to caulcate values based on our understanding as in post#37 , based on pdf we found for relay tuning method.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you want to implement a controller method, why even restrict yourself to PID?   In the days of analog electronics, PID was something that could easily be put into place with some opamps, caps and pots.   However with a micro, not only can you easily implement PID, you can easily implement other things that would take a truckload of opamps to do, if even possible at all.   

 

For example, even the dirt simplest moving average filter  Y(n)= X(n)/2+X(n-1)/2  (avg the current & last data points), which is trivial in software, is nearly impossible to build with just an assortment of opamps.  So software allows you to leave the PID behind in the dirt and develop many improvements previous designers could not imagine. Of course, PID lives on,as they say, not that there is anything wrong with that 

 

Not That There'S Anything Wrong With That Seinfeld GIF by myLAB ...

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Wed. May 6, 2020 - 07:15 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

now i am stuck in calculating values of Ku & Tu by formula, as in post#37.

Many different articles have different formulas for same relay method, we are trying as in pdf attached in that post and see the results.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Well doesn't the article mention it:

At that point, it applies a negative step and waits for the process variable to drop back below the setpoint. Repeating this procedure each time the process variable passes the setpoint in either direction forces the process variable to oscillate out of sync with the control effort but at the same frequency. Although the process variable’s oscillations aren’t strictly sinusoidal, their period turns out to be a close approximation of the ultimate period that Ziegler and Nichols used for their tuning rules. And the amplitude of the process variable’s oscillations relative to the amplitude of the control effort’s oscillations approximates the process’s ultimate gain when multiplied by 4/.

 

What do you mean by "you are stuck"?   If you have you own method you won't be stuck, since you are the one creating it.  You will have a long road trying to match your programming of an algorithm against another unknown algorithm.   If they differ just a little (either the method or any of the numbers), waveforms will be a difficult comparison...so what will you end up finding out? Probably either nothing, confusion, or both!

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Wed. May 6, 2020 - 08:51 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@ avrcandies  , based on that I had marked what I thought of Tu & b values in graph. 

1. Didnt take Tu & b values on first cycle, since its when the heater starts, second cycle can be repeated again and again. I think my understanding here is Tu & b should be second cycle only.

 

2. Now need to know how to select value a? 

a is amplitude of control voltage. What value should I take here? 

In Delta controller PID, MCU is 3.3V powered, it drives a 12V transistors  which drives a SSR relay to urn on 220Vac/50Hz ac on/off for heater.

So should i take value of a = 1(high) , 3.3V,12V?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As mentioned many messages ago, the PID controller typically outputs an analog amount  P+I+D terms to the process, like a gas pedal in your car.  This is what the papers you are following assume.   However, you have a relay control system, on or off.  Thus it is not exactly an apples-to-apples comparison.   If the on/off is PWM'd (looks like they might be doing do that at the far right of your graph) then you might be able to calculate an equivalent PID effect.   As far as a paper to follow, you might be better to look at one referencing using a relay output situation during normal operation (I'm not talking about relay tuning method).

In either case, with this setup, the control effort is the amount of heat (including any pwm factor) you are applying (you can scale any subsequent normal operating calculations to that amount). B/A is a gain ratio, where A is input.    You know the power in (A) & the response out (B).

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Wed. May 6, 2020 - 08:49 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But we wanted to know exactly which is currently stable product in market and tried to emulate that.

44 posts on this Thread and I still don't understand what this is about.

 

Who cares how another vender wrote their control algorithm.

 

What is your ultimate hardware platform, and how will your device compare against the competitor?

 

As mentioned above, there are many control algorithms, and many / all of them need some fine tuning for the best performance based upon your actual hardware.

 

Your goal, I would think, is not to emulate another product, but to exceed its performance.

 

To do that you can start with a clean slate, you don't need to know their algo at all.

 

JC 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


Vindhyachal Takniki wrote:
So should i take value of a = 1(high) , 3.3V,12V?

I can't believe you even suggested 3.3V or 12V. They're clearly silly values.

 

The Delta Manual has this picture:

In common with most Temperature Controller manuals it explains Jack S**t but lets assume Pb is "proportional band" and the other descriptions indicate this is a percentage. Therefore a=100.

 

I skipped your attachment in #31 because I thought it was in Italian. It is actually in English and is quite a good explanation.

 

So lets work your numbers through their calcs.

 

Again from the PDF you had in #31

 

 

 

So:

 Î” = 100 (%)

 a = 4 {Estimate in °C from your graph}

 Îµ = 0 {I couldn't see any hysteresis in your graph}

 Pa = 704 {Again; you can do much better from your graph than me (4225 - 2817)/2 }

 

Using:

        4 * Δ           400

Ka = -----------  =  -------- = 31.83

        Ï€ √ a2         Ï€ * 4

 

Pa = 704

 

We can stick these into the table:

 

Kp = 0.6 * Ka = 19.1

Ti = 0.5 * Pa = 352

Td = 0.125 Pa = 88

 

OK - Not hugely different to Delta Calculated Values.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@ N.Winterbottom thanks for reply.

1. How do you come with a=4  (its approx value) . Is it half of min & max diff? 

In graph :

a) setpoint: 80C

b) max temperature in green region: 90.07C  (between pulse high to low and then high again)

c) min temperature in green region: 79.79C   (between pulse high to low and then high again)

d) exact time period as in green arrowed line mentioned : 841 sec

e) there is slight lag between temperature measured by Delta sensor controller and our own sensor placed alongside. So slight error wil be there

 

 

 

2. Tu Time period of pulse can be measured easily as mentioned in arrowed green line.

But I have doubts on how to measure amplitude of temperature varaitions.

 

I have three pdf links, each having below mentions abt amplitude:

a) https://fenix.tecnico.ulisboa.pt...

Its page 3

 

b) second pdf I have attached.   Its page 3

 

c) https://aiecp.files.wordpress.co...   

its page 48

 

 

4. In all images below, all three pdfs mentioned "a" is ampltiude of oscillation of temperature.

But in all they assume some sine wave, so ampltiude of (0 to +peak) & (0 to -peak) seems equal, but in our case its different.

temperature goes higher on positive side i.e  

a) setpoint is 80C, max goes to 90.07

b) setpoint is 80C, min goes to 79.97

 

so in this case what value should I take as amplitude? I have doubt in that?

 

 

 

 

 

 

 

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

Maybe get a really good PID reference like:

https://books.google.com/books?id=edCcDwAAQBAJ&pg=PA99&lpg=PA99&dq=Magnitude+Optimum+Multiple+Integration+(MOMI)%E2%80%9D+method&source=bl&ots=1plDKLj0q_&sig=ACfU3U09-plKEJtGdea3enVV6ht1k7YhOA&hl=en&sa=X&ved=2ahUKEwi2pfXc4KnpAhWQbc0KHQzbDqwQ6AEwBnoECAkQAQ#v=onepage&q=Magnitude%20Optimum%20Multiple%20Integration%20(MOMI)%E2%80%9D%20method&f=false

 

Also, I found another source (different than above link), that gives all the calculations for the following auto tune diagram...however they do calculations quite differently to get the final PID values.  however, they give a long explanation of how they do it with an example.

This is the diagram they calculate from:

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sun. May 10, 2020 - 05:13 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Vindhyachal Takniki wrote:

1. How do you come with a=4  (its approx value) . Is it half of min & max diff? 

I looked at the graph in #1. You said the Setpoint was 75°C and I saw the peak get to 79°C.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


@ N.Winterbottom  Ohok, I thought its graph, in later post.  In first graph I think it was typo. I suppose it was 72C around.

I have seem we get pretty close value if we take a=255. Today we performed three test, 2 on medium size and one on large oven.

 

1. 100C autotune on medium oven.  With a=255, these are values of PID which we get vs values of Delta Electronics PID.

a) Our PID values:  19.677,   294,  73.5

b) Delta values: 20.0,  260,   65

 

 

 

2. 150C autotune on medium oven.  With a=255, these are values of PID which we get vs values of Delta Electronics PID.

a) Our PID values:  19.677,   233.5,   73.5

b) Delta values: 20.0,   232,   58

 

 

 

 

3. 100C autotune on large oven.  With a=255, these are values of PID which we get vs values of Delta Electronics PID.

a) Our PID values:  67.17,   313,   78

b) Delta values: 5.8,   270,   67

 

 

 

Looks like in large oven, our formula some how fails.

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Edit: In above post,  a=255 means the relay output taking it as 255 i.e full 8 bit timer PWM

the amplitude I took is difference between +peak & -peak during entire cycle, not just 0 to +peak.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Edit: Noticed this strange relation between Detla controller PID values, not sure why is that so?

All calculated values of P are:

P = 2*[(+peak)  - (-peak) ]    i.e twice of difference between max and min values.

 

 

This holds true for all the graphs in post#50.

Delta PID controller have WPM timer period set = 20 seconds, tommorow will do more test on different times like 10,5,2 etc

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:

 

Maybe get a really good PID reference like:

https://books.google.com/books?id=edCcDwAAQBAJ&pg=PA99&lpg=PA99&dq=Magnitude+Optimum+Multiple+Integration+(MOMI)%E2%80%9D+method&source=bl&ots=1plDKLj0q_&sig=ACfU3U09-plKEJtGdea3enVV6ht1k7YhOA&hl=en&sa=X&ved=2ahUKEwi2pfXc4KnpAhWQbc0KHQzbDqwQ6AEwBnoECAkQAQ#v=onepage&q=Magnitude%20Optimum%20Multiple%20Integration%20(MOMI)%E2%80%9D%20method&f=false

 

Also, I found another source (different than above link), that gives all the calculations for the following auto tune diagram...however they do calculations quite differently to get the final PID values.  however, they give a long explanation of how they do it with an example.

This is the diagram they calculate from:

 

 

Is your " (an)other source (different than above link)" a secret?

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Looks like in large oven, our formula some how fails.

Do you know what they do with the PID values?  Since the output is always full on/off it can only be emulating PID..are you assuming (or do you know) the PID is being converted to PWM?

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:
Since the output is always full on/off it can only be emulating PID
54 posts and am I the only one who gets it?  The bang-bang approach is only used during the auto-tune phase.  Once PID values are derived, surely the system operates via PWM or similar.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Once PID values are derived, surely the system operates via PWM or similar

That's a question...what does it do to get from PID values to its output since it can only be on/off...so any calcs are then transformed by some unstated method to some form of on/off. 

It's likely to be a simple linear conversion to duty cycle, but might have other factors, even stepping based on some discrete thresholds of some sort, possibly adding hysteresis, deadbands, etc. 

Any of these would  be part of the control "calcs".

Since the output is always full on/off it can only be emulating PID

I think this is a correct interpretation, if they are using a solid state relay.

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Mon. May 11, 2020 - 09:09 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@ joeymorin yes, during autotuning it follow relay method( as pointed by @ N.Winterbottom ), once its done it gives variable PWM cycle and then maintain temperature to +-1C for heating.

 

We tested on 10second pulse also, proportional band still holds this formula for 2*[(+peak) - (-peak)]

i.e if during second cycle of tuning, max temerature goes to 94C & min is 87C, then P = 2[94-87] = 14

 

Although we are calcuating by Ku=4*d/(pi * a)

Today will try with our formula & check how far we are.

meanwhile sideways also try to understand abt Delta PID algorithm.

 

@ avrcandies can you point to your other source, might be this is what is being used in Delta controller PID?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0



 once its done it gives variable PWM cycle 

Examin that in detail to determine exactly (mathematically) what it is outputting.  For example, it might display numbers scaled differently than some other system does. For all you know it could take the PID numbers, calc, apply them to some fuzzy logic & then you see some on/off patten coming out to drive the heating.   More than likely, it just varies the duty cycle linearly, but that is somewhat guessing as to what probably does. 

-------------

You need to find the article by 

It shows calculations and has many details.  Temperature Control in a Plastic Extruder Control System

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Surely you are "close enough" with your understanding of the Delta Electronics controller by now. You are probably wasting time now trying to exactly match the Pb, Ti, Td calculated by their PID Autotuner. Especially as you/we don't know the inner details of their PID controller algorithm, or any tweaks they may do to improve performance in a particular area.

 

I've forgotten what exactly the scope of your project is. Please re-iterate.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@ N.Winterbottom

You are right , and i said in post#57 now i am trying to write PWM algo to maintain temperature with whatever we are getting at the moment. 

This is very good implementation with some improvement also mentioned.

Will see if i am able to maintain temperature.

 

1. First PID values are calculated manually & PWM algo is implemented to see how far i am to maintain temperature.

2. Once step 1 is succesful, write autotune code in c also 

 

Meanwhile will also try to test other PID controllers from OMRON also.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


I tried to write code for calculating the output 0 to 100% from below function, but value is always greater than 100 to system is always clampled and high.

The code of lots of tweaks as mentioned in this blog:  http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-introduction/  

so its not only Kp,Ki ,kd multiplaction with error.

 

 

 

 

const float32_t c_output_max = 100.0f;
const float32_t c_output_min = 0.0f;

float32_t input_temperature;
float32_t setpoint_temperature;
float32_t output_duty_cycle;

float32_t i_term;
float32_t last_input;

//ku = 12.60633212609071966486208026713f;   units: per degree celsius
//tu = 820  seconds
float32_t kp = 7.563799f;   //kp = 0.6*Ku
float32_t ki = 0.018448f;  // ki = 1.2*Ku/Tu
float32_t kd = 775.289425f;    // ki = 0.075*Ku*Tu


float32_t sample_time = 1.0f;  // 1 second


//sample_time + derivative_kick + On-The-Fly Tuning Changes + integral windup +
void compute_pid_duty_cycle(void)
{  
    float32_t error;
    float32_t d_input;

    /* get error */    
    error = setpoint_temperature - input_temperature;

    /* integral error */
    i_term = i_term + (error * ki);
    if(i_term > c_output_max)
    {
        i_term = c_output_max;
    }    
    else if(i_term < c_output_min)
    {
        i_term = c_output_min;
    }    
    else
    {
    }    
        

/* differential error */    
    d_input = input_temperature - last_input;

/*Compute PID Output*/
    output_duty_cycle = (kp * error) + (i_term) - (kd * d_input);
    if(output_duty_cycle > c_output_max)
    {
        output_duty_cycle = c_output_max;
    }    
    else if(output_duty_cycle < c_output_min)
    {
        output_duty_cycle = c_output_min;
    }    
    else
    {
    }        

    /*Remember some variables for next time*/
    last_input = input_temperature;
    
} /* function ends here */

 

 

Parallel we have tested on another advanced Delta PID DTC1000, and below are tuning results.

Ti & Td match exactly as from DElta electronics PID now.

I was reading Pb is actual proportional band and not proportional gain Kp.

I am reading more on it how to calculate.

 

Another thing is this "I offset" which also calculate after autotuning, dont know what it is.

This Pb gives from 0 to 100%.

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You will have a very long road if you are doing all this coding & hoping to simply compare waveforms.

Just one number or implementation differing slightly & means the switching cycle will differ a slight bit, which will propagate into the next cycle & cascade/buildup & effect the next cycle.

 

If you compare raindrops falling in two areas of the field you might say these waveforms of raindrops barely match at all, yet the same amount of rain fell in both areas & were delivered from the same cloud.

 

Ultimately, you just want to ensure that the temperature is maintained to your satisfaction....but it is not apparent you have defined what satisfactory is!

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@ avrcandies , I wrote code with whatever values of Kp,Ki and Kd we are getting. Issue is its always clampled to 100%.

Need to normalize this output in range 0-100%. Dont understand how to do it.

 

need to maintain temperature within +-1%.

Edit: First goal now is to get this running and see what we will get.

 

 

 

This Delta PID test is entirely separate, just to understand what is being done., Thats why in my post I wrote parallel.

 

 

 

Last Edited: Thu. May 14, 2020 - 03:58 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Need to normalize this output in range 0-100%. Dont understand how to do it.

The output stage is like a gas pedal, the PID makes it press more or less.  You might have some system where 0 to 25 driver input volts means zero to full power, some other system might use 0 to 4V, or 0 to 1V.   The PID adjusts itself & also the tuning takes into account the range (the pid values are just 3 more gain settings).  Of course all that means nothing if the output can only turn on/off....so you fake it using percent on.....for example, you might set it so a value of 5 means full on 100% of the time, then 2.5 cycles on/off 50% of the time, 1 means it's on 20% & off 80%...the freq is typically "slow", depending on the system (in some cases might want faster).  Or you might set things so 1 means on 100%.   The doesn't matter, per se,, it will just affect the scaling of the PID values---they work together to give the desired output.

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Thu. May 14, 2020 - 06:59 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@ avrcandies " The PID adjusts itself & also the tuning takes into account the range (the pid values are just 3 more gain settings).  "

 

This is not happening, my PID out is always more than 100 seems like.

We are keeping 5 second pulse, so if 100% pid output, then full 5 seconds on, 50% PID outout means 2.5second ssr on and 2.5second ssr off.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If the temperature keeps climbing due to the heater being on all the time (too much), then the integrator term (too hot) will build & build towards infinity until you pass your turn off threshold...so it will turn off at some point, even if badly adjusted or your scaling is messed up.

You do have to have numeric polarities correct...if too hot it must turn off, if too cold turn must turn on.  If backwards it will lock up (you have positive feedback, want negative).    If you are driving too slow & get further off the gas you will go slower & get more off the gas & go slower yet....that is a backwards polarity.  Likewise, if you go too fast and apply more gas you go faster and apply more gas & crash.

  

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


Have written below code, but outout is very fluctating and then clamped to either zero or highest.

This is general three gains Kp, Ki and Kd.

 

I think one reason might be: dimensions dont match on both sides . Though i am not sure of this.

 

1. kp has unit : (change in output)/celsius.

since Kp is proportional to D/A  , where D= change in output which we take 0 to 100, since its relay method.

A= change in temperature.

 

2. ki = 1.2*Ku/Tu  so its units: (change in output)/(celsius * second).

 

3. ki = 0.075*Ku*Tu  so its units: (change in output * second)/(celsius).

4.While on left of equation , which is outout it is dimension less or percentage



I have checked another PID controller from another company they also used porportional band, ; https://web-material3.yokogawa.c...

 

But i dont get how to caculate it.

 

Defination sats: " It is amount of change in input (or deviation), as a percent of span, required to cause the control output to change from 0% to 100% "

For example in our test, with set point 70C, max goes to 78.6, minimum goes to 69.0, 

sensor span is -200C to  + 600C

How to calculate it? 

is it : (78.6-69.0)*100/(600+200C)  ??

 

 

 

void compute_pid_duty_cycle(void)
{  
    float32_t error;
    float32_t temp_integral;
    float32_t derivative;

/* get error */    
    error = setpoint_temperature - input_temperature;
    
    if(first_time)
    {
        first_time = 0U;
        previous_err = error;
    }    

/* integral error */
    integral = integral + error;   //dt = 1sec
    temp_integral = integral * ki;  
    
    if(temp_integral > c_output_max)  //integral windup up
    {
        temp_integral = c_output_max;
    }    
    else if(temp_integral < c_output_min)
    {
        temp_integral = c_output_min;
    }    
    else
    {
    }  

/* differential error */  
    derivative = error - previous_err;     //dt = 1seconds

/* Compute PID Output */
    output_duty_cycle = (kp * error) + (temp_integral) + (kd * derivative);
    if(output_duty_cycle > c_output_max)
    {
        output_duty_cycle = c_output_max;
    }    
    else if(output_duty_cycle < c_output_min)
    {
        output_duty_cycle = c_output_min;
    }    
    else
    {
    }        

/* Remember some variables for next time */
    previous_err = error;
    
} /* function ends here */

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Meanwhile will also try to test other PID controllers from OMRON also.

WHY??? You are supposed to be spending your time  making your controller work....Are you pretending to be quality control for Omron?   Just making your own control system work well seems to be enough of a task.

PID has been around for a long time, since opamps.  WIth a processor, you do not even need PID to control temperature, there are many ways to do it.

 

sensor span is -200C to  + 600C

How to calculate it? 

is it : (78.6-69.0)*100/(600+200C)  ??

After 67 posts now you say you're not sure about reading the sensor?  How much time is wasted!!.. Did you not verify the temperature readings before you started?

 

Now ask yourself why do you need to make this control in the first place?...can you just use the one(s) you have? 

 

Have written below code, but outout is very fluctating and then clamped to either zero or highest.

That means very little...what does the final temperature look like? Why forget to post your results??  

Turn your KD down to zero & make your KI very small...what temperature do you get 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sat. May 16, 2020 - 04:58 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


@ avrcandies 1. By reading different established products just trying to see what they are working on, almost all on them have Proprotional band , intergral time and derivative time

Parallel we are trying to get our code working with calculated values of Kp,Ki & Kd.

 

 

 

2. I know how to read temperature sensor reading, this is how to calculate proportional band. Different pdf give different answers on this.

Kp, proportional gains is know how to calculate.

 

 

3. I have kept set point at 40C, and sensor is connected, right now its not in oven, so reading only room temperature.

compute_pid_duty_cycle() is called every 1 second, and output is limited to -100 to +100. 

Since sensor is reading room temperature, so error is almost same. I recorded 100 reading and check "error" is same alsmost, while "output_duty_cycle" pid duty cycle vary a lot from 10% to 100% almost.

 

 

 

 

void compute_pid_duty_cycle(void)
{  
    float32_t error;
    float32_t temp_integral;
    float32_t derivative;

/* get error */    
    error = setpoint_temperature - input_temperature;
    
    if(first_time)
    {
        first_time = 0U;
        previous_err = error;
    }    

/* integral error */
    integral = integral + error;   //dt = 1sec
    temp_integral = integral * ki;  
    
    if(temp_integral > c_output_max)  //integral windup up
    {
        temp_integral = c_output_max;
    }    
    else if(temp_integral < c_output_min)
    {
        temp_integral = c_output_min;
    }    
    else
    {
    }  

/* differential error */  
    derivative = error - previous_err;     //dt = 1seconds

/* Compute PID Output */
    output_duty_cycle = (kp * error) + (temp_integral) + (kd * derivative);
    
    
    if(output_duty_cycle > c_output_max)
    {
        output_duty_cycle = c_output_max;
    }    
    else if(output_duty_cycle < c_output_min)
    {
        output_duty_cycle = c_output_min;
    }    
    else
    {
    }        

/* Remember some variables for next time */
    previous_err = error;
    
} /* function ends here */

 

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Proportional mean just what it says, proportional.

 

example:  Vout=300*err     the controller output is 300 time the present error, it is proportional

 

If the max 100% useable/allowable, Vout is 600, then err has a max allowable of 2

Or you could just talk about percentage out:   Vout (%) = 100/2 * err       so P=proportional band = 2

 

So looking at PWM  600V =100% PWM on at err=2

                

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

I think you're getting confused by textbook examples versus real world practical examples of temperature controller.

 

In your post #31 you attached:

Resumo Alargado - Auto-tuning de Controladores PID pelo método Relay.pdf

In that, the author provides the discrete or digital form for PID:

Notice he calculates the differential using y which I think is the measured process value not the error.

 

Notice also, there is a Kp factor around each term. This effectively results in a Kp factor around the whole controller.

 

In my #24 I referred to the Wikipedia article: https://en.wikipedia.org/wiki/PID_controller . In that same article I find a section titled "Reciprocal gain, a.k.a. proportional band"

 

I shall copy & paste:

Reciprocal gain, a.k.a. proportional band

In many cases, the manipulated variable output by the PID controller is a dimensionless fraction between 0 and 100% of some maximum possible value, and the translation into real units (such as pumping rate or watts of heater power) is outside the PID controller. The process variable, however, is in dimensioned units such as temperature. It is common in this case to express the gain Kp not as "output per degree", but rather in the reciprocal form of a proportional band 100 / Kp, which is "degrees per full output": the range over which the output changes from 0 to 1 (0% to 100%). Beyond this range, the output is saturated, full-off or full-on. The narrower this band, the higher the proportional gain

I think this goes a long way to explain your problems.

 

BTW: A cycle time of 1s seems very fast for a standard temperature control loop. 10 or 20s seems more reasonable. Having said that; I have seen a 1s cycle time controller but that was on a laboratory temperature bath; a precision piece of equipment holding temperature to within 0.02°C. Obviously a specialised controller was used here.

 

 

Last Edited: Sun. May 17, 2020 - 09:55 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@ N.Winterbottom You right,  lot of diff in textbook examples and real world practical examples. :)

1. why y(n) - y(n-1) is taken rather than error, here it is explained:  http://brettbeauregard.com/blog/2011/04/improving-the-beginner%e2%80%99s-pid-derivative-kick/

2. Kp factor with each term is there as it should be since ki=Kp/Ti & kd=KdTd

3. The wikipedia article is true when only P is used, so it mentions Pb=100/Kp

4. In most of reputed brand PID controller Delta, Omron and many others: they all have:

a) Pb with range : 0.1 to 999.9

b) Ti

c) Td

d) Some have offset also 

 

trying to figure this out.

 

We aredoing sampling every 1 second, store it in array for 10 samples i.e 10seconds, then avg it & then update the PWM width of10seconds. 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Don't get too hung up on the names or scaling, you simply have 3 weighted adjustments (variables) to make

 

For example, either of these can give the EXACT same effect

Y =Ae+Be+Ce           A=2, B=3,  C=4

Y= ABCe+BCe+Ce     C=4, B=3/4, A=2/3  

 

You simply have a certain amount of proportional gain, integral gain and derivative gain added together, perhaps with some filtering & limiting.

Why do you keep messing with PID, you can do a lot of other ways more effectively. Since you have a processor rather than fixed PID circuitry, you can make it adaptive to the situation.

 

https://www.sciencedirect.com/science/article/pii/S147466701641476X

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sun. May 17, 2020 - 04:47 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Now I want to understand what is proportional band in PID context?

We did some PID tuning test from Delta Electronics temperature controller, and after a test,  it gives Pb = 40 , Ti = 302 & Td=75

Pb has unit of degree as per manual.

 

So what does it mean that suppose at any given point, set point is 100C.

So PID formula will only apply during (100 - (40/2))  to (100 + (40/2))  . i.e 80C to 120C.

 

If measured temperature is current below 80C, then output is 100% on & if above 120C then output is off completey?

Is this it means?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

proportional band is defined as the amount of change in the controlled variable required to drive the loop output from 0 to 100%.    

We did some PID tuning test from Delta Electronic

So what, WHO CARES?  You seem to be going nowhere---are you having good luck when you run your program? How well does it perform?

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

posted results in post #69.

PWM keeps on varying very significantly.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

posted results in post #69.

PWM keeps on varying very significantly.

You fail to show a graph of your temperature results--why?  Do it for several adjustments...what do you see.  Keep the derivative term low, add just a little integral....what do you get as a temperature result? 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Tue. May 19, 2020 - 10:06 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
/* Compute PID Output */
    output_duty_cycle = (kp * error) + (temp_integral) + (kd * derivative);

So in your example the error stays constant therefore the derivative is zero. The integral should wind up to it's peak value and summed with

(kp * error) which is also constant.

 

This surely is a simple code debugging exercise.