Author Topic: Incremental (velocity) PID tuning  (Read 12427 times)

0 Members and 1 Guest are viewing this topic.

Offline night_soulTopic starter

  • Beginner
  • *
  • Posts: 5
  • Helpful? 0
Incremental (velocity) PID tuning
« on: October 23, 2010, 09:35:00 AM »
Hello I have trouble to tune an incremental also called velocity PID controller and want to ask if they are tuned in the same manner as the  the positional.
The algorithm is:

PID=PID_last + Kp (e-e1) + Ki (e) + Kd (e- 2*e1+e2).

I know that for tuning you start with Ki and Kd =0 and start increasing Kp until you get some oscillations around the set point. Then increment the Kd to reduce the oscillations and finally Ki to reduce the error stationary error.

I start this way but I cannot make it oscillate, it is either too slow almost not reacting or fast passing over the set point and overshooting too much.

Is this type of PID also tuned that way or should I start with some other parameter other than Kp?

I would appreciate any help and tips.

Thanks 

Offline TrickyNekro

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,208
  • Helpful? 15
  • Hardware and Firmware Designer
    • The Hellinic Robots Portal
Re: Incremental (velocity) PID tuning
« Reply #1 on: October 27, 2010, 07:00:19 AM »
That means that you're actually using huge gain values.... Also slew rate might easy up your life...

This velocity PID... I guess you include time.... how large are the time slots? You have to use a timer for precise time slots...
No question about it....

I'll check what this velocity PID is... although I don't like the sound of it.... It kinda tells me you are not using a timer for you main program and that's bad :-p


What is your system? Is it a motor checking RPM, is it something else??? You may get away with a PID for servo.... which doesn't include time in the calculations only position... (cause velocity is the first derivative of position)...

So... I'm waiting for an update here really....
For whom the interrupts toll...

Offline night_soulTopic starter

  • Beginner
  • *
  • Posts: 5
  • Helpful? 0
Re: Incremental (velocity) PID tuning
« Reply #2 on: October 27, 2010, 07:30:52 AM »
Thanks for replying. The algorithm derivation you can check it out here:

 http://lorien.ncl.ac.uk/ming/digicont/digimath/dpid1.htm

I am not including any time steps but using the gains instead.

I want to control the position of a quadcopter that has to hover over a camera. I want to keep centered with respect to the camera. I saw that people already used this type of PID to achieve similar results but I am having a lot of trouble to find the correct gains.

Cheers,

Offline TrickyNekro

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,208
  • Helpful? 15
  • Hardware and Firmware Designer
    • The Hellinic Robots Portal
Re: Incremental (velocity) PID tuning
« Reply #3 on: October 27, 2010, 08:41:47 AM »
Hehe! My first google result... well...

I guess you are using two dimensions to center it to the camera.... So let the center be the set point right?
Use the simple PID it will do most of the work don't worry....
So:

error_x = center_x - camera_x
error_y = center_y - camera_y

Be careful here the camera resolution plays major part in how corresponding the PID algo will be...
and then...

Drive = Kp * error (for each axis)
Drive = Drive + Ki * (previous_error + error)
Drive = Drive + Kd * (error - previous_error)

Whether you use ABS or not it's up to the variables you are using....

So yup you can start with Ki and Kd equal zero....
And I heavily insist that you do time slots.... It's very critical it that your main code has a certain frequency...
I know this might be a pain if you are using a PC to do the calculations but time slots are very critical....
Or else you should use the more mathematical form of PID but you are also obliged to measure time....
But I do heavily insist on using time slots...

And start with small gain values... The more often your program is updated (thus you need a fixed program frequency) the smaller the values of the gain values must be....

Amen! Keep us updated!!!
For whom the interrupts toll...

Offline night_soulTopic starter

  • Beginner
  • *
  • Posts: 5
  • Helpful? 0
Re: Incremental (velocity) PID tuning
« Reply #4 on: October 29, 2010, 02:03:23 AM »
Thanx a lot!

Then I will try with the simple PID. I will try also the timer just I have a doubt where should I start and stop the timer? When I start the camera and identify the helicopter? or every time I want to calculate the PID output? Also it affects if the algorithm doesn't take the same time always?

Cheers,

Offline TrickyNekro

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,208
  • Helpful? 15
  • Hardware and Firmware Designer
    • The Hellinic Robots Portal
Re: Incremental (velocity) PID tuning
« Reply #5 on: October 29, 2010, 05:41:20 PM »
Since both Integral and derivative part of the PID controller are time dependent yes it should make a difference...

The proportional part is time dependent too, but you can get away with nicely calculated gain...
A timer should give you the best results...

Why do you have to start and stop a timer.... You kinda don't... only wait until it reaches a certain value and then zero it...
I pretty much guess you are using an OS so timers don't come in handy with them.

A "simple" PID that runs faster than it's sensor input is kinda useless... You should match the PID frequency with the camera refresh rate...

I'm not very familiar with camera systems but you are using Hue saturation luminance right? RGB can be very problematic from what I have heard....
For whom the interrupts toll...

Offline airuno2l

  • Jr. Member
  • **
  • Posts: 12
  • Helpful? 0
Re: Incremental (velocity) PID tuning
« Reply #6 on: November 04, 2010, 04:56:45 PM »
Wikipedia has a good description on how to tune PID, I've used it quite a few times.

http://en.wikipedia.org/wiki/PID_controller#Manual_tuning

As for the time steps, you really don't need them as long as your errors are calculated at fixed time intervals apart.

One last thing is that I have never had much luck using derivative error in PID velocity controllers since the control loop needs such a high frequency and taking the derivative of a noisy signal makes a REALLY noisy control. Also, I've never had a problem using just a PI control. This should work well especially for your case because the derivative part really just helps get the velocity from one value to another quickly, while the other two take care of holding the velocity constant...which I think is most important with helicopters.  
« Last Edit: November 04, 2010, 04:59:26 PM by airuno2l »