You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old July 3rd, 2004, 10:54 AM   #1
Peter Nachtwey
Member
United States

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: Vancouver, WA, US
Posts: 6,705
PID - Simple Velocity Control

So you thought you would take the weekend off! No way. The link below is saying download me! Give me a try!

The link is to a spreadsheet that simulates a velocity control system instead of a position control system. The simulated system uses the same gain and time constant of last week's system. I even made it do the same motion profile only now it is in term of velocity instead of position. It is important to compare the two systems because you will see that there is a difference. One can see that velocity control systems are much easier to tune that position systems all other things being equal.

Simulations wise, the difference between the two systems is that the velocity control system is a type 0 system whereas the position control is a type 1 system. Type 0 systems are systems like velocity and temperature control where if the control signal is removed, the system will falls back to the original steady state. In the case of a temperature system this is ambient temperature and in the case of a velocity system this is stopped. A type 1 system has an extra integrator. A position system integrates velocity so that the feed back is position. A type one system will not go back to the original steady state. A position system will stop after coasting down when the control signal is removed, but the position will not return to the original starting position. The integrator in the type 1 system adds a pole ( a lag in response ) that makes tuning it harder. See the real poles sheet in the other thread to see what a pole does to the response of a system.

Knowing the type of a system is important when tuning a system. It gives you a clue as to how to adjust the gains.

As I said before the spreadsheet is just a velocity form of the position system of last week. However, it will tune differently. The equations that I use to calculate the gains are different. I leave it to you to find out what this difference is. The lowest ISE ( integrated squared error ) achievable is about 1660. This is because of the step input in the velocity when the target generator starts.

Simple Velocity System using a PID controller.

It will be interesting to hear of the results and the comments about the differences between the position and velocity system.

Have a nice weekend. I plan to hike and see some firework. We have the largest fireworks show west of the Mississippi at Fort Vancouver on the Columbia river. I will be checking in from time to time.
  Reply With Quote
Old July 3rd, 2004, 12:32 PM   #2
Bob O
Member
United States

Bob O is offline
 
Join Date: May 2003
Location:
Posts: 1,532
Kp = 2
ki = 500
kp = 0
ISE = 1604.179
  Reply With Quote
Old July 3rd, 2004, 01:25 PM   #3
duckhunter
Member
United States

duckhunter is offline
 
duckhunter's Avatar
 
Join Date: Jan 2004
Location: Texas
Posts: 1
FUN!!!

Kp 10
Ki 1850
Kd 0
ISE 1602.062

FUN!!! Thank you!

very unstable with any kind of derivative...
  Reply With Quote
Old July 3rd, 2004, 01:54 PM   #4
Peter Nachtwey
Member
United States

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: Vancouver, WA, US
Posts: 6,705
Excellent!

I assume the Kp=0 is really a Kd = 0. Your integrator gain is very aggressive. You beat my calculated solution by quite a bit.

BobO. Try this. Change the COS function to the SIN function in the Target column. You will see your solution works very well when the target speed is ramped up in a sane manner. Then try this: replace the formula in the target column with a fixed speed of 10. Notice that the integrator gain is just a little aggressive and causes a little ringing in response to this step from a speed of 0 to 10.
What results do you get then? My calculated PID gains cause the system to just ramp to the set point velocity without ringing or overshooting. Remember that the ISE does not work well in evaluating step jumps. Copy the ITAE from the other spreadsheet to evaluate. I just look for a critically damped response.

Hmmm, Kd = 0. Interesting. A person whose only experience is tuning velocity systems may come to the conclusion that Kd is NOT needed when tuning a PID. We now know that it depends on the system being tuned. Kd was definitely required to optimally tune the position system.

They key is to know your enemy ( system ).
  Reply With Quote
Old July 3rd, 2004, 02:07 PM   #5
Bob O
Member
United States

Bob O is offline
 
Join Date: May 2003
Location:
Posts: 1,532
Peter,

kd = 0
Call me crazy, but I can't find where you are using the Cos() function.

Thanks,
Bob O.
  Reply With Quote
Old July 3rd, 2004, 03:50 PM   #6
Peter Nachtwey
Member
United States

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: Vancouver, WA, US
Posts: 6,705
Re:Fun

Quote:
Originally posted by duckhunter
Kp 10
Ki 1850
Kd 0
ISE 1602.062

FUN!!! Thank you!

very unstable with any kind of derivative...
Good observation. That IS the point I am making. On some systems like this single pole velocity system, the derivative SHOULD NOT BE USED! This system is the same as the one last week ( same gain and same time constant ). You can see that it makes a BIG difference whether one is controlling position ( TYPE 1 ) or velocity (TYPE 0 ). That is why we will look at many different types of systems over the summer. Eventually you will know which system required which gains. Also notice that Ki is very large compared to Kp

My formulas for calculating critcally damped gains are:

Ki = lambda^2/G
Kp = (2*lambda-alpha)/G
Kd = 0 No surprise here.

Where lambda is desired value for the system's and controller's two real poles. Remember lamda is in radians per second or one over the time constant.

G is the system gain in inches per second per volt. The spread sheet has G set to 2 which means the fastest the system will go is 20 inches
per second because the controller is limited to + or - 10 volts.

Alpha is the exponential frequency in radians per second. It is calculated by : alpha = 1/time constant. In the spread sheet example the time constant is .2 seconds so alpha is equal to 5.

To calculate the PID gains I set the desired response to 20 radians per second for the two real poles. 20 radians per second is equal to a time constant of 1/20 or .05 seconds. Now go back to there real poles spread sheet I previously posted to see the response to a set input.

Using the formulas above I calculated
Kp = 17.5
Ki = 200
Kd = 0

My ISE is 1660.517 but my solution will not over shoot or ring in response to a step input. What both Bob O and duckhunter have discovered is that one can increase the gains a little bit more if the motion profile is relatively smooth.

Bob O, there is a tab in the lower left corner called calculations. Click on it. I use a Graph or interface sheet and a Calculations sheet on all the spread sheets I have posted so far. The Target Velocities are calculated in column C of the Calculations sheet.

I encourage all to play with the target generator column as I suggested in my previous reply to Bob O.
  Reply With Quote
Old July 3rd, 2004, 04:14 PM   #7
Bob O
Member
United States

Bob O is offline
 
Join Date: May 2003
Location:
Posts: 1,532
Peter,

I found it. I originally looked in cell C7 and C8 for a formula and didn’t see anything but a number so I “assumed” the remaining column was the same. Thanks Peter. I will work on this later today.

Bob O.
  Reply With Quote
Old July 3rd, 2004, 09:48 PM   #8
Thomas Sullens
Member
United States

Thomas Sullens is offline
 
Join Date: Feb 2004
Location: Idabel, Ok
Posts: 390
pid

Kp=1
Ki=300
Kd=0
and a pole is / by 0
Thanks
  Reply With Quote
Old July 4th, 2004, 11:04 AM   #9
Peter Nachtwey
Member
United States

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: Vancouver, WA, US
Posts: 6,705
Re: pid, that works too!

Quote:
Originally posted by Thomas Sullens
Kp=1
Ki=300
Kd=0
and a pole is / by 0
Thanks
The mathematical definition of a pole is technically accurate, but it doesn't do much for ones intuitive feel for what a pole really does. Whether the pole is positive or negative make a big difference as to whether the system is stable or not and how fast the system will respond to input. The simple velocity system has a model that looks like this:

Code:
  G
-------
s*tau+1
Since expontial frequency, alpha, is equal to 1/time constant, tau, the equation above can be changed to

Code:
G*alpha
-------
s+alpha
Here one can see that there is a pole at -alpha because if s is equal to -alpha the denominator becomes 0 and the whole term becomes infinite. If you look in the spread sheet you will see that there are terms for calculating coefiecients for the model. This simple velocity model is like the low pass filter you have seen many time on this site.

velocity(n) = K * velocity(n-1) + G * (1-K) * control(n-1)

Where:
G is the gain
K = exp(-alpha*T)
T is the sample time. In the spread sheet it is .010 seconds

The -alpha is the pole and because it is negative, K will always be less than one. This way the velocity will approach 0 when the control goes to 0.

What happens if the pole is positive? What will be the value of K when K = exp(alpha*T). What would happen to the velocity as soon as it is non zero?

Why does the equation above use control(n-1) instead of control(n)?

May are your poles be negative.
  Reply With Quote
Old July 8th, 2004, 02:00 AM   #10
ndzied1
Lifetime Supporting Member
United States

ndzied1 is offline
 
ndzied1's Avatar
 
Join Date: Aug 2002
Location: Chicago, Illinois
Posts: 2,351
Hi Peter,

Wasn't around this past weekend for the fun but I'll try to make up for it.

Attached is a version of your spread sheet with a standard 1/3 1/3 1/3 trapazoidal velocity profile move. I added a close up graph of the rising knee section. With the initial tuning parameters I have entered, there is a pronounced lag and overshoot.

Now we'd like to minimize ISA AND Overshoot (Note, a negative overshoot is actually an undershoot).

More fun for all...
Attached Files
File Type: zip t0p1 pid trapz.zip (145.1 KB, 114 views)
__________________
nOrM
======================
nOrM=Norman Dziedzic Jr.
"I decry the current tendency to seek patents on algorithms. There are better ways to earn a living than to prevent other people from making use of one's contributions to computer science." Donald Knuth
  Reply With Quote
Old July 8th, 2004, 05:52 AM   #11
David_Emmerich
Lifetime Supporting Member
United States

David_Emmerich is offline
 
David_Emmerich's Avatar
 
Join Date: Sep 2002
Location: Smiths Grove, KY
Posts: 670
Hi Peter...These are very interesting...but I enjoyed our beer-30 meeting even more! I will try to post a drawing of that oven control/PID setup when I get a free moment...SWA lost my stuff on the 4th between Portland and Nashville, just got this back today!!! Now they are sending me out to Sacremento on Friday...Again, thanks for these great posts, and the pleasent evening.

David
  Reply With Quote
Old July 8th, 2004, 09:07 AM   #12
Peter Nachtwey
Member
United States

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: Vancouver, WA, US
Posts: 6,705
Good Observation!

Quote:
Originally posted by ndzied1
Hi Peter,

Wasn't around this past weekend for the fun but I'll try to make up for it.
I am sure you can keep up.

Quote:
Originally posted by ndzied1
Attached is a version of your spread sheet with a standard 1/3 1/3 1/3 trapazoidal velocity profile move. I added a close up graph of the rising knee section. With the initial tuning parameters I have entered, there is a pronounced lag and overshoot.

Now we'd like to minimize ISA AND Overshoot (Note, a negative overshoot is actually an undershoot).

More fun for all...
That is why feed forwards are required when following a motion profile! I will get to feed forwards and target generators ( ramping ) later. However, what I wanted people to notice is that the derivative gain should be 0 on a Type 0 single pole system. Obviously, one should have some idea have what kind of system one is tuning so the proper gains are used. Hopefully, everyone tune this type 0 velocity system and now knows the difference between a Type 0 ( velocity and temperature )and Type 1 ( position ) system.

I do hope that others are experimenting with the spread sheets like Norm is. Experimenting is where you can really learn and get experience without fear of things crashing and burning. I think it would be also informative to increase the target generator frequency and see the response. Notice that more gain will be required. In some cases the system gain G will need to be increased in order to follow the sinewave. Anyone who has done hydraulic servo control has seen systems like these that are underdesigned and run in saturation much of the time. The servo motor guys would just have their systems fault from over current protection.

Norm, I am using a naming convention. T0P2 is for a type 0 double pole system. You named your .xls file T0P2 and it is not a Type 0 2 pole system. I like the name in the link. I saved the file as T0P1 PID Trapz.xls I almost over wrote the temperature system I was doing for this week end (T0P2 PID.xls). I am making a spread sheet the simulates the hot rod system Ron Beaufort had last summer.

David, that is the pits. From Sunday to Wednesday? It makes you wonder if the airlines aren't a waste of time. You could have driven home or better yet taken the train, relaxed and enjoyed the scenery. The last time I took the train I was impressed by the comfort and cost relative to flying. I am glad you at least enjoyed beer-30.
  Reply With Quote
Old July 8th, 2004, 10:28 AM   #13
Bob O
Member
United States

Bob O is offline
 
Join Date: May 2003
Location:
Posts: 1,532
Kp = 2.5
Ki = 11
Kd = 0
Overshoot = 0
ISA 53.06

Bob O.
  Reply With Quote
Old July 8th, 2004, 12:17 PM   #14
Peter Nachtwey
Member
United States

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: Vancouver, WA, US
Posts: 6,705
Good, now try this

Vary the ratio of the I gain to the P gain. Notice that Norm's would overshoot at a ratio of 10/1 and yours didn't at 11/2.5. This is a trick. When you make the ratio of the I gain to the P gain higher you increase the responsiveness of the system but also increase the chance of overshoot. If you reduce the ratio of the I gain to the P gain the system response will be much slower. Try Ki = 9 and Kp = 3. Look at Norms 'rising knee'. Now increase the P gain to 4. interesting isn't it? Why? oops. The equation for calculating
Ki and Kp are. I left off the alpha in the denominator while copying in the thread above.

Ki = lambda^2/(G*alpha)
Kp = (2*lambda-alpha)/(G*alpha)

where
-lambda is where the two real poles are located. The larger lambda is the faster the response. Lambda has units of radians/second
G is the system gain in inches per second/volt
alpha is 1/time constant. In the examples, alpha = 5 radians/second.

The ratio of Ki/Kp = (lambda^2)/(2*lambda-alpha). So one can see that as one makes lambda bigger, for faster response, the ratio of Kp to Ki is bigger too.

These formulas are ONLY for a type 0 single pole system.
  Reply With Quote
Old July 9th, 2004, 03:10 PM   #15
vern
Member
Canada

vern is offline
 
Join Date: Jul 2004
Posts: 1
Simplified output math

I created separate columns for the proportional, integral and derivative portions of the control output. It should help people who are not as mathematically inclined to understand a bit more.

I used Norm's idea for the shape of the velocity profile. You can see the separate effects of the P and I portions. The form for the PID output I used gives the same results as Peter's for this profile. I didn't put anything in to limit the output so it won't work for a real application. I really like the way Peter's form for the control output works to prevent the integral windup.

Thanks for starting this Peter. How much do you use system modelling? Do you use it to get a starting point for your gains?
Attached Files
File Type: zip t0p1 pid separated pid outputs.zip (151.4 KB, 109 views)
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
PID - what is it anyway? Ron Beaufort LIVE PLC Questions And Answers 21 November 25th, 2014 06:36 PM
PID - A simple position control simulator Peter Nachtwey LIVE PLC Questions And Answers 34 April 20th, 2007 04:41 PM
PID - Velocity control of a mass on a spring. Peter Nachtwey LIVE PLC Questions And Answers 19 July 22nd, 2004 10:28 AM
PID control using simple control blocks klasse LIVE PLC Questions And Answers 1 April 29th, 2003 05:03 AM
how often should I trigger the PID? Ron Beaufort LIVE PLC Questions And Answers 11 February 22nd, 2003 10:57 AM


All times are GMT -5. The time now is 03:46 AM.


.