7
$\begingroup$

I'm trying to build a robot with a differential drive powered by two DC Motors. First I implemented a PID Controller to control the velocity of each motor independently. Estimated the TF using the MATLAB's System Identification Toolbox, of the open loop system by the acquiring the velocity of each wheels encoder in function of the PWM signal applied by an Arduino microcontroller. All went well and i successfully dimensioned the PID gains for this controller.

What I'm trying to accomplish now is to control the exact (angular) position of the DC Motor. I thought in cascading a PID controller in the input of the other already implemented. So this way, I can give a position to the first controller, which will be capable of generate an output reference to the second (velocity) controller so it generates the appropriate PWM value signal to drive the DC Motor accordingly.

Will it work? Is that a good approach? Or should I try to implement a different controller which outputs the PWM signal in response to a position reference signal?

Many thanks for your attention and I hope somebody can help me with these doubts.

$\endgroup$
6
  • 1
    $\begingroup$ Yes. It will work well and is pretty standard in commercial motion controllers. If your velocity loop is working well on a single motor you can put a position loop over it. Having a position controller "fight" with your velocity controller (both controlling the PWM) will not work at all. $\endgroup$
    – Guy Sirton
    Commented Jul 29, 2014 at 22:52
  • $\begingroup$ @GuySirton - I don't think he's talking about fighting controllers. $\endgroup$ Commented Aug 1, 2014 at 22:00
  • $\begingroup$ I am having a very difficult time controlling velocity and position of a servo motor with encoder feedback. I implemente the pid but i can not find suitable gains for it. Can anyone share some code for velocity control? please? Arsh $\endgroup$
    – Arsh
    Commented Jul 7, 2015 at 3:03
  • $\begingroup$ If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. $\endgroup$
    – Mark Omo
    Commented Jul 8, 2015 at 5:29
  • $\begingroup$ Welcome to robotics Arsh, but on Stack exchange answers need to answer the question. If you have a question, it should be asked as a new question (ideally referencing the original question if it related to another one). Take a look at How to Ask and tour for more information on how stack exchange works. Before asking a question though, make sure that it hasn't already been asked and answered: What are good strategies for tuning PID loops?. $\endgroup$
    – Mark Booth
    Commented Jul 8, 2015 at 13:17

2 Answers 2

3
$\begingroup$

I have done this myself, controlling the exact position of a brushless DC motor as its velocity ramps up and down. And I did it using a position controller only. Sounds obvious, but it worked extremely well.

The integral term of the controller is key to this. Since you want the position error to be as close to zero as possible the whole time, but you need a large output from the controller to drive the motor, most of this comes from the I term.

The other thing you need to add is a feed forward term, which feeds some of the demanded acceleration to the output. This will give the controller the extra power it needs to track rapid velocity changes. We could call this an FPID controller.

$\endgroup$
2
  • $\begingroup$ This can work but the more standard approach is profile generation->position loop->velocity loop ... This would work better than just trying to close the loop on position. And yes, feed-forward is also pretty standard and makes a huge difference. The better your feed-forward the less work your control loop has. $\endgroup$
    – Guy Sirton
    Commented Aug 2, 2014 at 6:11
  • $\begingroup$ Hi @Rocketmagnet, I've already implemented the position controller and cascaded it with velocity controller, but I'm having some difficulties trying to tune the (as I explained in my previous comment to @ryan0270), maybe you can help me on that? :\ $\endgroup$
    – rflmota
    Commented Aug 2, 2014 at 16:48
1
$\begingroup$

I'm a little confused, are you trying to control each wheel's exact position or the overall position of the robot. For the former, a cascaded structure makes sense where the robot position control loop defines desired velocities for each motor.

For the latter (which sounds a little strange to me), you should just be able to treat the velocity as the 'D' part of your position controller, and not do a separate velocity controller.

$$ \begin{align} u = - k_p (p - p^d) - k_d (v - v^d) - k_i \int_0^t (p(t) - p^d(t)) dt \end{align} $$ where $p$ and $v$ are the measure position and velocity respectively, and $\cdot^d$ indicates the desired value.

$\endgroup$
2
  • $\begingroup$ I'm actually trying to control each wheel's exact position. I've already implemented the PID controller, but I'm having some troubles tuning it... I've used an 'deadband' limit to which I consider the wheel is in the position required - because my encoders have a big resolution (7800 'ticks'/revolution) and is difficult to stop it on an exact reference 'tick'. However I need to use a pretty large deadband so that the motor doesn't keep oscillating back and forth on the goal position (200 ticks), so I still have a pretty bad resolution, maybe if I can tune the PID better... ? $\endgroup$
    – rflmota
    Commented Jul 29, 2014 at 19:38
  • $\begingroup$ Tuning, in general, is a separate issue. As a starting point, though, make sure you have no integrator and tune P and D until it looks good, but maybe has a constant offset. Then slowly increase the integrator until it starts to look bad and then cut it in half. Also, generally using a deadband like you're doing should be avoided (though sometimes it may be needed). $\endgroup$
    – ryan0270
    Commented Jul 29, 2014 at 22:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.