Line Following / Position Controller using PID Control System

Discussion in 'The Projects Forum' started by EnginiusXIII, Jul 22, 2008.

  1. EnginiusXIII

    Thread Starter Member

    Oct 2, 2007
    21
    0
    Guys I do need some help here!

    I'm trying to design a basic line following robot using Vexta 450KC Brushless DC Motor with dsPIC30F4011 as its core processor. In my research, what I'm trying to emphasize is on the Proportional Integral Derivative Control System algorithm using C programming. Since I start fresh, it would be great if anyone could guide me throughout my research.

    First of all, I would appreciate if any of you could answer some of my questions.
    1. What reference should I look for in order to prepare myself in this field?
    2. Where can I find the pseudo code or flow chart for the algorithm?
    3. Is there any example that could best describe my research?
    4. What ingredients do I need to be prepare in order to begin my research?

    P/S: If my questions are irrelevant, please forgive me. As for now, what I understand about PID is just the basic.

    Thanks for you time.
    Vincent
     
  2. scubasteve_911

    Senior Member

    Dec 27, 2007
    1,202
    1
    You should understand control theory before you even start deciding what scheme you plan on using. Then, you will be in the position to decide which scheme to evaluate to solve your problem. This scheme could be proportional, proportional-integral, PID, fuzzy, fuzzy-based gain scheduling for PID, neural network decision making... and the list goes on.

    I believe microchip has a PID appnote with source meant to drive a motor, do a google search along that line.

    You seem to have the hardware, you just need to test out your algorithm when it is finished. Then, try to find where your system is unstable or has poor performance, then fix it.

    Are you doing academic research? If so, you should have many professors that are knowledgeable on control system theory. I recommend this route, since I have had similar challenges and my professors were excellent.

    Steve
     
  3. EnginiusXIII

    Thread Starter Member

    Oct 2, 2007
    21
    0
    Well, if it is control theory, I have learned and able to understand most of it.
    Yeah, reading through the PID appnote really does help me on the concept of PID. Maybe I will try look for more information first before I proceed to the algorithm.

    You can category my research as academic research, however to be exact, I'm conducting this research on my on basis. Just part of my hobby and interest toward robotic construction. My aims is to develop smooth and error-free line following with great speed.

    Thank you Steve.
    I will post in later on if I'm stuck.

    Vincent
     
  4. scubasteve_911

    Senior Member

    Dec 27, 2007
    1,202
    1
    Vincent,

    You're welcome!

    Many have tried to make the perfect line following robot for competitions, school, etc. I recommend searching to find out ahead of time all the problems that they encountered. I have seen some pretty great line following robots, it can be a challenge to do quickly, especially with disturbances such as wheel slip, and so on.

    Robotics is a closely coupled field to control theory, but there is much to learn. A good book is "Introductory Robotics" by Selig. It goes over the pretty involved mathematics, which is necessary for any performance robotic system. You can download this if you search on google.

    I mentioned the professors because I have done personal research while in school and have had a lot of good professors take time out of their days on numerous occasions to support my own research. If you have this type of resource, I recommend you exploit it while you can!

    Good luck,

    Stephen
     
  5. EnginiusXIII

    Thread Starter Member

    Oct 2, 2007
    21
    0
    Well, just found and borrowed the book in the local library. Thanks for the recommendation.

    Yeah, actually you hit the jackpot. Through this research, I'm going to build a robot for local competition. So in order to stand out among other, I try to develop PID. Hopefully it'll work.

    Thanks again Stephen

    Vincent
     
  6. scubasteve_911

    Senior Member

    Dec 27, 2007
    1,202
    1
    You're welcome.

    That book isn't really what you want for the line following application, it's more for industrial robotic design.. lots of math, etc. that I still try to repress to this day :)

    I recommend getting your hardware set up as soon as possible. Try to use the most traction possible, high energy density batteries, neodymium motors (brushless would be a plus, but not necessary). Be careful matching the motor load to your wheels, you may need some sort of gearing for an optimal match. Ensure that the vexta driver isn't overkill, otherwise, it may weigh you down. Keep it as low as possible with all high density parts located in the center of gravity of the car.

    I would make the sensor quality as best as possible, which means high bandwidth and low noise. Don't cheap out on the feedback! Use nice optical encoders for the brushless motor(s) (high count and fast). Write an algorithm in your controller that is generic, then you can do experimental tests and tweak the gains.

    Good luck!!

    Stephen
     
  7. nanovate

    Distinguished Member

    May 7, 2007
    665
    1
    Applied Control Theory for Embedded Systems, Tim Wescott, Elsevier 2006, ISBN 0-7506-7839-9

    -- good book on control theory
     
  8. espirit

    New Member

    Jul 26, 2008
    3
    0
    Hello Vincent,

    PID implemetations can be made easily from the formula, but you may need special protections against integrator overflow.
    Take that into account.
    There is a PID.pdf that you may find interesting.

    For driving a motor, the PDFF algorithm is usually better. Just google for it.

    Happy 'controlling'
    AJ
     
  9. EnginiusXIII

    Thread Starter Member

    Oct 2, 2007
    21
    0
    Been away for a while.

    After digging into the book, Introductory Robotic, yeah, it contains lots of math that I don't usually applied in my robot. Well, I found a book Automatic Tuning of PID Controller by K.J Astrom & T. Hagglund and been reading it for now. Will share if I found something new bout it.

    Nanovate, thanks for the recommendation. Will be looking forward to it. Well, reading takes time to accomplish especially during this critical hours where tons of assignment pile up.

    AJ, great bunch of articles you found there. Thanks alot... It is sure helpful.
     
  10. EnginiusXIII

    Thread Starter Member

    Oct 2, 2007
    21
    0
    Is there a way to determine the current position in degree using a row of sensors in the front ?

    I have found a way to control the motor speed using PID. However, the algorithms is used to control speed of both motor. Fortunately, I believe with some modification, I could use it to control position. Therefore, what I would like to control is position in term of degree. So is there a way to determine the position error in term of degree using only a row of sensors?
    Mark! I'm not using any accelerometer or gyroscope which are capable of returning values from 3 axes.

    For example, I assume moving in a straight line is equivalent to move along the x-axis at y=0 with the slope, m = 0. When the slope increases, it means that the vehicle is out of position. So, in order to return back to desired position, I have to correct the error in term of degree...... That's what I have thought of. Therefore, the problem is how to find the error in degree?
     
  11. EnginiusXIII

    Thread Starter Member

    Oct 2, 2007
    21
    0
    Okay, leave aside all those old posts.
    From what I have learned so far, I manage to get the error values for P, I and D and multiply them with their respective gains. The results were then sum up. Basically, the method could be obtained from many other forum's thread.
    _________________________________________________________________________
    first, I assigned every position of my inline array sensors(6) into a value ranging from -5 to 5 with 0 indicates as desired position for my robot. From this value, I could find the proportional error, e = y - x, where y as set position and x as current position. Meanwhile, the derivative error, e(derivative) = e - e(previous) and lastly the integral error, e(integral) = sum of all error. With these errors, I product them with their respective gain P, I and D with a specific value for every gain. These are the value that need to be tuned. After this, the resulted value for P,I and D were being sum up and that is the correction value or PID value that normally being used to control the actuators.
    ________________________________________________________________________

    Since I'm using for line following, I would like to use the correction value to control the speed. The problem I'm facing right now is what is the correct algorithm to control the speed of a differential steering robot using the correction value obtained from PID.

    Based on everyone experience in control system, could you suggest me the formulas to calculate value in speed for both of the actuators which are my brushless dc motor.
    Or any other suggestion other than controlling the speed ?
    Another question is should I use the derivative error to control my acceleration since its value is usually small ? Or a constant acceleration is already good enough ?

    Hope to hearing lots of suggestion soon.

    -Vincent-
     
Loading...