Jump to content
HybridZ

PID Tuning - Getting slow initial gain


BLOZ UP

Recommended Posts

Any engineers out there know how I can have a PD/PID controller ramp up slowly initially?

 

I am controlling two motors and I need it to not just jump up to the PWM specified by the current difference between distance and targetDistance (and speed), which causes jerk on my robot:

 

pwm = Kp * (targetDistance - currentDistance)/targetDistance + Kd * (targetSpeed - currentSpeed)/targetSpeed

 

Do I need the integral part to do this? I thought that's just to avoid overshoot. Right now it hardly ever overshoots--maybe 1-2 motor encoder clicks, which is more than fine for my application. However, the motors jerk on start up which kind of throws it off trajectory.

 

I tried changing it to PID of speed, distance, accel but it did exactly what I thought it would do. Kept on driving past the goal. My goal is to arrive at a certain distance. Although keeping the speed in check would be nice--without limiting the PWM, since the motors don't go the same speed given the same PWM value.

 

I could think of a couple ghetto ways to ramp it up slowly based on time--maybe, but surely there's a more common, elegant solution?

Link to comment
Share on other sites

P/proportional

I/integral

D/derivative

 

P=Amount of distance away from target over (or under)1 usually the larger the number the smaller the movement made.

I=Time component acting usually as multiplier, as offset is noted, each integral time will act as precious p value calculated move plus the new calculated. Big I numbers can keep large swings under control. The longer the value is off setpoint the larger the move made will be. A big number will make slow response a small number will have it twitchy, and can make for radical swings into hysteresis if P number is small (fast acting) and the process is laggy

D=this is derivative, the acts and works of the devil and gives you anticipatory action based on rate of change sensed. Usually if you aren't fuzzy logic, best to leav D alone. Unfortunately PI controllers are either slow or fast and react constant-rate with an offset from setpoint moving linearly.

To get a different rate at start opposed to near target, likely som derivative action will be necessary.

 

Crap, iPhone down to 4%.... crapcrapcrapcarp!

Link to comment
Share on other sites

The proportional part is normalized to percent since the distances can vary from 500 to 8000 or so, and I figured this was an easy way to keep the output within the range of 0-100.

 

Actually, I think I just thought of how to fix it.... I'm doing a PID of distance...

 

I need to control speed. And before setting the output, I can make the desired speed a function of percent done. That should do the ramp up and down for me, and leave the PID to keeping the motors sync'd.

 

Hmm... Now I need to drive all the way back to the lab....

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...