DC motor control using PID control

N

Thread Starter

n catherwood

I am currently designing a motor control system for a small robot(school project). I plan to use two DC motors, to drive two wheels foward and backward. I also plan to use a pic18 microcontroller for PID control. I'm pretty sure that I am on the right track, however I don't fully understand how a PID is used to do this. The robot will be following a white line on a black surface using a photoelectric line sensor. The data recieved from the line follower will be used to control the motors. Any suggestions or comments would be greatly appreciated.

Thanks for your time.
 
<b>Moderator's note: Mr. Younkin died several years ago. His documents are no longer available</b>

PID control:
I have a document that explains the use of PID in a real world machine application. It is available by email.

George
[email protected]
 
you have to make three modules in your program, one will be the main program which will call all the modules (functions), second will recieve the the data from the sensor and will process it and the it will give the command to the control loop as an output.third will contain the PID control algorithm (which will be a part of control loop) which can be used for controlling of both the motors.
 
If you plan to use a motor for each wheel, you have perform gantry control also. Pls review gantry control method inside this forum.
 
You need to have feedback to close the PID loop. Your output to the motor is current (although physically, using PWM to generate current is more efficient in practice), and your feedback is either position or velocity, and of course if you have position feedback you can get velocity by calculating. You can look in a number of practical and theoretical control books to find out how to do this.

~Ken
 
You don't really need a PID to accomplish this task. Unless you have tight and precise requirements for the robot to stick to the line completely. If you need a closed loop control, a PI may be all you need.

Basically, you need to build a motor controller
for each wheel. The motor controller would have a fast inner current loop. This is where you can put the PI. You can tune the responds of the motors here. It would be easier if you buy a servo controller or drive or go to semiconductor mfr. that make motor driver chips.

Secondly, you need a position outer loop which would be slower than your inner current loop. The sensors will detect whether the motor is on the line or not and tells the motor to turn right or left. The challenge you'll have is to decide which way the robot will turn if it the line makes a 90 degree or worst does an angle reverse.

The simplest way is to: just have the motor turn clockwise until it finds the line and then go straight and if the line turns have it turn cw again until it finds it and go straight. For this you don't need a PID. To go to a robot that sticks closely to the line would increase the complexity of your control algorithm. Have fun and good luck.

OJ
 
The comments fom OJ are right on. Most industrial servos use PI compensation with a current loop, velocity loop, and position loop. I have a document that illustrates the application of PI compensation on a real machine. If interested email me and I will send you a copy by return email.

George Younkin
[email protected]
 
hello

I'm a student of electrical engineering in iran.
I'm trying to build a linefollower robot.
And i used a dc motor for moving.
I need to decrease its speed while turning.
If your document can help me to do that please send it to me.

thanks so much.
 
Hi there,
I'm also building a line following robot, and I used IF-THEN conditions to control the two wheel driving motors, I used a line of 5 Infrared sensors to detect the black line and determine its curvature.

I would like to use PI or PID controller to drive this robot with PWM as close as possible to the line without the zig-zag movevements.

So could you please send me some documents on how to implement any of these control algorithms on a real machine ???
Many thanks in advance.

Asal
[email protected]
 
Top