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.

New Here? Please read this important info!!!
July 3rd, 2004, 10:54 AM  #1 
Member

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. 
July 3rd, 2004, 12:32 PM  #2 
Member
Join Date: May 2003
Location:
Posts: 1,492

Kp = 2
ki = 500 kp = 0 ISE = 1604.179 
July 3rd, 2004, 01:25 PM  #3 
Member

FUN!!!
Kp 10
Ki 1850 Kd 0 ISE 1602.062 FUN!!! Thank you! very unstable with any kind of derivative... 
July 3rd, 2004, 01:54 PM  #4 
Member

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 ). 
July 3rd, 2004, 02:07 PM  #5 
Member
Join Date: May 2003
Location:
Posts: 1,492

Peter,
kd = 0 Call me crazy, but I can't find where you are using the Cos() function. Thanks, Bob O. 
July 3rd, 2004, 03:50 PM  #6  
Member

Re:Fun
Quote:
My formulas for calculating critcally damped gains are: Ki = lambda^2/G Kp = (2*lambdaalpha)/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. 

July 3rd, 2004, 04:14 PM  #7 
Member
Join Date: May 2003
Location:
Posts: 1,492

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. 
July 3rd, 2004, 09:48 PM  #8 
Member
Join Date: Feb 2004
Location: Idabel, Ok
Posts: 390

pid
Kp=1
Ki=300 Kd=0 and a pole is / by 0 Thanks 
July 4th, 2004, 11:04 AM  #9  
Member

Re: pid, that works too!
Quote:
Code:
G  s*tau+1 Code:
G*alpha  s+alpha velocity(n) = K * velocity(n1) + G * (1K) * control(n1) 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(n1) instead of control(n)? May are your poles be negative. 

July 8th, 2004, 02:00 AM  #10 
Lifetime Supporting Member

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...
__________________
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 
July 8th, 2004, 05:52 AM  #11 
Lifetime Supporting Member

Hi Peter...These are very interesting...but I enjoyed our beer30 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 
July 8th, 2004, 09:07 AM  #12  
Member

Good Observation!
Quote:
Quote:
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 beer30. 

July 8th, 2004, 10:28 AM  #13 
Member
Join Date: May 2003
Location:
Posts: 1,492

Kp = 2.5
Ki = 11 Kd = 0 Overshoot = 0 ISA 53.06 Bob O. 
July 8th, 2004, 12:17 PM  #14 
Member

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*lambdaalpha)/(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*lambdaalpha). 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. 
July 9th, 2004, 03:10 PM  #15 
Member
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? 
Bookmarks 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)  
Thread Tools  
Display Modes  


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 07: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 