Chapter 6. Controlling DC Motors

One of the best ways to use Arduino is to add it to a small mobile platform and control the speed and direction of the wheels. In this chapter, you'll learn how to use the basic capability of Arduino to control a small DC motor. You'll then take this to the next level, learning how to add more functionality using a shield to control the speed and direction of more powerful DC motors. Then, we'll build a wheeled robot whose speed and direction are controlled by Arduino.

The basics of DC motor

Before you get started with connecting everything and making it all move, let's spend some time understanding some of the basics of DC motor control. Whether you chose a two or four wheeled mobile platform or a tracked platform, the basic movement control is the same. The unit moves by engaging the motors. If the desired direction is straight, the motors are run at the same speed. If you want to turn the unit, the motors are run at different speeds. The unit can actually turn in a circle if you run one motor forward and one backward.

DC motors are fairly straightforward devices. The speed and direction of the motor is controlled by the magnitude and polarity of the voltage applied to its terminals. The higher the voltage, the faster the motor will turn. If you reverse the polarity of the voltage, you can reverse the direction the motor is turning.

However, the magnitude and polarity of the voltage is not the only factor that is important when you think about controlling your motors. The power that your motor can apply to move your platform is also determined by the voltage and the current supplied at its terminals.

There are actually GPIO pins on Arduino that you could use to create the control voltage and drive your motors directly. The challenge with this method is that Arduino cannot normally source enough current and voltage, and your motors will not be able to generate enough power to move a mobile platform.

There are several solutions to this problem. The first is to use a simple transistor circuit and an external voltage source. You'll use this solution in the first example of this chapter. Another solution is to use an H-bridge, a chip that Arduino can control but which is connected to a power source and can provide enough current. The second example in this chapter will show you how to use this sort of chip. The third solution to the problem is to use a shield that contains all the circuitry and can connect to an external power source input so that your Arduino can provide both voltage and current and your platform can move reliably. The last example in this chapter will use a motor controller shield designed for Arduino to make DC motor control simple.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.79.147