Motion Control and Motor Drives

cancel
Showing results for 
Search instead for 
Did you mean: 

PID Robotic Arm

Hola.

So I am programming a robotic arm to draw a line or curve, but having some issues. 

So this robot is run off of dc motors with encoders. I used these encoders along with some switches that are at specific places relative to what I believe to be the 0 degree position of each motor.

But now I would like it to go to that 0 position from the location of the mechanical switch. 

My first thought was this:

1. I know at how many counts the encoder equates to the '0' position I want.
2. So, I just have my input to my PID as the current position and output the compensation required to achieve the position (?)
3. And just run a constant velocity in a certain direction depending on if overshoot occurred or it hadn't reached that point yet

But then I read online that you could have a position input to your control system that goes into the PID controller and somehow output a prescribed velocity (duty cycle) to attain the point. And as the point got closer and closer the duty cycle would decrease hence the velocity decrease and eventually get to that point.

 My problem is... if the input of a PID is a position then the output must be the compensation for that position correct or not ( a bit hazy on the subject) ?
And if so, then how do I use that information to alter the PWM or velocity of the motor?

Do I output the position from the PID to a trajectory vi used in the robotics module and if so, how?

 

Let me know your thoughts. I would grealty appreciate it.

0 Kudos
Message 1 of 2
(5,933 Views)

The short answers


The output of your PID will not be "compensation". It will output the PWM velocity directly.

 

How you interact with your trajectory generator will depend on the particular interface your trajectory code uses. Often trajectory generators produce position setpoints that ensure that the motor conforms to velocity and acceleration limits. These position setpoints would be fed from your trajectory generator to your PID loop that is controlling position.

 

The long answer


A PI or PID algorithm will take as its input some feedback from a system and output some impetus. For a water tank it might take in temperature and output heater power. For a motion system it might take in position feedback and output a voltage- or in your case a PWM representing velocity.

 

PID control works by trying to reduce the error, the difference between the setpoint and feedback, by multiplying the error by the Gains to produce output in a desired range. More importantly the gains also define the response characteristics of the system- how stable it is, how quickly it responds, how it responds to external noise, etc. For example, you can tune a loop to be very stable but take a long time to reach the setpoint- or a loop that snaps right to the setpoint but oscillates more. There are a lot of tradeoffs to be made. 

 

Your task is to learn how to tune your PID loop. That is, pick gains that will produce an output that reacts as you want to errors.

 

We have a white paper about tuning and how to work with our products. This is by no means an exhaustive course in control theory but it will give you a basic understanding of what effect the individual PID gains have as well as the considerations involved in tuning.

http://www.ni.com/white-paper/2923/en

 

You might consider taking a closer look at the math used to calculate the P, I, and D components of the output. The math isn't complicated and it will do a lot toward helping you understand how the gains are used.

0 Kudos
Message 2 of 2
(5,920 Views)