PID Parameters Tuning/Meaning in internal algorithm

6 years 3 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?

Please Log in or Create an account to join the conversation.

• Griffin Baker
6 years 3 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.

Please Log in or Create an account to join the conversation.

3 years 4 months 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.

Please Log in or Create an account to join the conversation.

3 years 4 months 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.

Please Log in or Create an account to join the conversation.

3 years 4 months ago #29532265 by Zurad
Thank for you reply!

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)

Please Log in or Create an account to join the conversation.

3 years 4 months 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.

Please Log in or Create an account to join the conversation.

3 years 4 months ago - 3 years 4 months 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?

Please Log in or Create an account to join the conversation.

3 years 4 months ago #29532269 by blake
PPR (Pulses Per Revolution), is an parameter related to the encoder itself. This means that for every full 360 degree revolution of the motor shaft your encoder will pulse the number of times as indicated by the ppr. So, if the spec sheet says that the encoder has 2000ppr then this is the number you want to configure to the encoder input of the motor controller. This is good by the way as 2000ppr is obviously a much higher resolution than 500ppr would, thus it will give you more accurate and precise speed data.

Your motor spins faster in closed loop than in open loop because when you are giving commands in closed loop speed mode they are relative to whatever you have configured as your max RPM. In open loop it is just sending commands proportional to your power supply. Please take some time to read through Section 8 (page 87) of our User Manual so that you can really understand how closed loop speed mode works, this will help you.

Please Log in or Create an account to join the conversation.

Moderators: tonysantoni
Time to create page: 0.105 seconds
Go to top