Skip to content | Skip to navigation
Powered by RSPowered by RSPowered by RS

RS-EDP Rover using mbed [PID Velocity Control]

Aaron Berk

United Kingdom

Proportional-integral-derivative, or PID, controllers are commonly used in industry to control processes such as temperature regulation, motor speed and flow rate. Here we will see how they can be incorporated into the RS-EDP Rover design to provide repeatable and reliable movement.

In order to drive the rover in a straight line, both its left and right motors need to rotate at the same speed. If one side was to rotate faster than the other, the rover would soon veer off from its current heading.

It is unfortunate that our motors are unlikely to run at the same speed even if they are of the same make and are presented with the same voltage. One reason is the fact that in order to drive forward, both motors will actually need to rotate in different directions (think about the direction of rotation looking at the wheel, face on, from each side), and often motors are better at rotating in one direction than the other.

Other reasons include the fact the "same" motors aren't, in fact, the same, and even slight differences in their manufacture could lead to larger errors further down the line. Most likely running two motors at the same voltage will produce slightly different speeds which over time would harm a goal such as trying to drive in a straight line.

We can use a PID controller to force them to run at the same speed instead of hoping that the same voltage will produce the same speed. By making our motors run at the same speed, they should cause the rover to follow the path of a straight line.

I ported the Arduino PID library by Brett Beauregard to mbed in order take advantage of this powerful control process. You can find the mbed PID library here. An excellent resource for understanding and implementing PID controllers is the controlguru website which contains a clear and easy to digest e-textbook by Douglas Cooper.

I have also written up my experience of implementing a PID controller for velocity control of motors on the mbed cookbook page for the PID library which you can find here. It essentially follows the method of fitting a First Order Plus Dead Time model to step test data as presented on the controlguru website; it should provide a useful recipe in designing a controller for your own application using the mbed.

The graph below shows the result of driving two motors a set distance while controlling their speed using a PI [proportional-integral] controller. The motors end up with a difference of 7 pulses on their quadrature encoders which have 624 counts per revolution; that's an angular distance of 4 degrees or a linear distance of 0.7mm!

 Image

My next post will look at some inertial sensors, namely accelerometers and gyroscopes, and how to fuse their outputs to give orientation data that is more accurate than individual sensor readings.

Other posts in this series:

1. Introduction

2. Chassis

3. Quadrature encoders

4. PID velocity control

5. Inertial measurement unit

6. Rover State Machine

7. Conclusion

8. Technical Details