# PID Parameters Tuning/Meaning in internal algorithm

9 years 11 months ago #29528479
Hello,
I'm trying to tune my HDC2450S's PID, and I can't find in the documentation which way the internal algorithm uses the gains. The classical way makes the formula look like this:

Kp * error + (1 / Ki) * integral(error) + Kd * d/dt ( error )

But the newer implementations of the algorithm are normally something like this:

Kp * error + Ki * integral(error) + Kd * d/dt ( error )

Which of these two would be the way my controller uses the parameters in closed-loop speed mode?

9 years 11 months ago #29528481 by Griffin Baker
Replied by Griffin Baker on topic PID Parameters Tuning/Meaning in internal algorithm
The closed loop speed mode will use the Integral (I) gain over the Proportional (P) gain. Set up your PID to the following and then adjust your I and P gain as needed.

P=0
I=5
D=0

Your I gain should be larger than your P gain. Some motors may take a large I gain with 0 P gain, however in some cases a little P gain may be necessary.

7 years 3 weeks ago #29532263 by Zurad
I am having some problems with correct PID setup. I use SDC2160 controller. Could you explain why the I gain is the most important? I got used to setting PID, starting with P. Using methods like ziegler-nichols. I can't get rid of overshoot and oscilations. I have 2 motors 6000RPM with gear 6:1.

7 years 3 weeks ago #29532264 by blake
Integral gain is the most important for speed control, while Proportional gain will be most important for position control. Other factors weigh into getting optimal speed control in closed loop as well. What are your PID gains set at now? What is the PPR of the encoder you are using? Is the encoder mounted to the shaft of the motor before the step down gear or on the other side of the gear? Does your PPR configuration match that of your encoder specs? Usually oscillations are indicative of to high of proportional gain. The algorithm is overshooting and causing too high of error every time thus having to compensate. Usually with our controllers in speed control if you need to add P gain it should only be in small increments such as .1 or .2.

7 years 3 weeks ago #29532265 by Zurad

Encoder I am using has 500 PPR and is mounted before 6:1 step down gear. (Max RPM before step down gear is 6000 RPM).
Thats my current setup:

setconfig(_MAC, 1, 8000)
setconfig(_MDEC, 1, 30000)
setconfig(_MAC, 2, 8000)
setconfig(_MDEC, 2, 30000)

setconfig(_MMOD, 1, 1)
setconfig(_KP, 1 , 0)
setconfig(_KI, 1 , 2)
setconfig(_KD, 1 , 0)
setconfig(_ICAP, 1, 100)

setconfig(_MMOD, 2, 1)
setconfig(_KP, 2 , 0)
setconfig(_KI, 2 , 2)
setconfig(_KD, 2 , 0)
setconfig(_ICAP, 2 ,100)

7 years 3 weeks ago #29532266 by blake
Cool. I don't see any configs there for the encoder itself. Is your ppr configured to 500? (setconfig(_eppr, 1, 500)?

Just a tip it may be easier to tune your PIDs from the Config tab and then test and adjust as needed rather than trying to do it running a script. I don't know what encoder you are using but I have a motor here in my lab with a 500ppr encoder and am able to get quite accurate and stable speed control out of it so its likely you just need to play around with the gains a bit more.

7 years 3 weeks ago - 7 years 3 weeks ago #29532267 by Zurad
I have this motor(robokits.co.in/motors/encoder-dc-servo/p...0rpm-100w?cPath=2_3&) It says the encoder has 2000PPR, but then it says its 500 lines. Some referances say PPR and lines its the same. I am confused, a little bit. By PPR for quadrature encoder do you mean 500 pulses or lines? When I set the encoder to 2000 PPR it seems that my error is reduced but the motor turns much faster then it should.

EDIT:

I have checked the speed in open loop, and for 2000RPM it is almost as the commanded velocity, so I assume this is set correctly. Now in closed loop at the same parameters my motor rotates much faster, why?