PID - Simple Velocity Control

Join Date
Apr 2002
Location
No income tax, no capital gains tax. Freedom!
Posts
8,351
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.
 
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 ).
 
Peter,

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

Thanks,
Bob O.
 
Re:Fun

duckhunter said:
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.
 
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.
 
Re: pid, that works too!

Thomas Sullens said:
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.
 
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...
 
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
 
Good Observation!

ndzied1 said:
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.

ndzied1 said:
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.
 
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.
 
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?
 

Similar Topics

Been working with PLCs for a couple of decades, but almost 100% DirectLogic. Have a customer who wanted me to make a couple of simple changes to a...
Replies
3
Views
1,099
Hey All In my down time between projects i enjoy building different types of control systems. I already do it all day for work but like to tinker...
Replies
7
Views
1,684
Hi all. Simple question here. I've seen both sides of the spectrum here and no one can give me a concrete answer. On a AB CLX platform PID...
Replies
16
Views
6,657
The link below is to an Excel spreadsheet. I used Excel 2003. Hopefully those with out Excel can at least use the Excel viewer. I decided to...
Replies
34
Views
22,331
Hello, has anybody done a "user block", that delivers PID functionality? This could have been done using simple control blocks available in...
Replies
1
Views
6,262
Back
Top Bottom