Chapter 3. Let's Get Moving

At this point, you are probably sick of blinking LEDs and want to use your Arduino to start driving some motors, right? Well, this chapter discusses some of the important robotic parts that we must use in order to get an Arduino robot moving. First we start with the various types and applications of electric motors, then we discuss the circuits that make them move. Lastly this chapter includes a brief description of the materials that we need to use to complete the projects in this book.

Electric Motors

There are many different types of robots that have different levels of intelligence and mobility, but the common thread that you will find in almost every robot is a motor of some kind. An electric motor is used to convert electrical heat into rotational motion using a carefully arranged set of magnets and coil windings. By energizing the magnets with electricity, the coil winding spins—a motor typically has an output shaft attached to this magnet, so you can mount a wheel or gear on the end.

A motor has several ratings such as speed (RPM), voltage, amperage, and total power. We can usually determine whether or not a motor will suit our particular needs by combining the specifications that are important to our project. The speed in RPM of the motor gives us an idea of how fast it will be able to move, the voltage determines its potential power, and the watt rating tells us what combination of voltage and amperage we can use to power the motor without overheating it.

This book focuses on mobile robotics, so only DC power sources are used. Although AC motors are useful (washing machines, air conditioning equipment, kitchen appliances, power tools, and so on), they are most efficiently operated when plugged into an appropriate AC power source. Because we use DC batteries for all of our bots, we use only motors that use DC power (though there are several types—see Figure 3-1).

DC motors come in all shapes and sizes. The large motor is made for an electric scooter, the 2 in the center are small hobby motors, and the 2 on the right are DC servo motors.

Figure 3.1. DC motors come in all shapes and sizes. The large motor is made for an electric scooter, the 2 in the center are small hobby motors, and the 2 on the right are DC servo motors.

Each different type of DC motor is used for a specific range of applications, though they can also be manipulated for use in a variety of different robotic tasks. The simplest of electric motors is the standard brushed DC motor, which is commonly used for high-speed applications, or high torque when gearing is used. Brushed DC motors are not only used in many of the projects in this book, but they are also commonly used in gear motors and servo motors.

There are also DC motors that do not have brushes, but operate by constantly changing the electro-magnetic field around the output shaft using a special driving sequence. Both stepper motors and brushless DC (BLDC) motors use this concept and typically have between three and six wires for operation. These types of motors cannot be driven directly by a constant power source; they instead require the use of a series of amplifiers and a micro-controller input signal.

Brushed DC Motor (Permanent Magnet Type)

The Permanent Magnet Direct Current (PMDC) motor, commonly known as just a brushed DC motor, is used in electronic devices, robotics, and toys (see Figure 3-1). The typical DC motor has only one motor coil with two wires for operation. This is by far the easiest type of motor to drive, control, and manipulate. You can also reverse the rotational direction of a DC motor output shaft by reversing the polarity of the voltage to the motor terminals.

Most DC motors have brushes that physically touch a set of spinning electrical contacts, called commutators that are electrically connected to the motor coil winding. When each brush touches a different commutator, the electrical current is passed through the motor coil, which forces the motor output shaft to spin about its axis. Permanent Magnet DC motors typically have two magnets attached to the inside of the motor casing and the coil winding and commutator mounted to the output shaft—the brushes are typically spring loaded to keep them securely mated to the commutator contacts while spinning (see Figure 3-2).

A typical DC motor disassembled for viewing. The inside of the motor casing (left) has two permanent magnets attached and a hole for the output shaft to come through. The coil winding (center) is wrapped around the commutator, which is mounted to the output shaft. The brushes (right) are attached to the ends of the motor terminals, which are mounted to the motor's plastic end cap.

Figure 3.2. A typical DC motor disassembled for viewing. The inside of the motor casing (left) has two permanent magnets attached and a hole for the output shaft to come through. The coil winding (center) is wrapped around the commutator, which is mounted to the output shaft. The brushes (right) are attached to the ends of the motor terminals, which are mounted to the motor's plastic end cap.

A DC motor consumes as much power as it needs at a given voltage and consumes more (current) as its workload increases. A typical DC motor draws anywhere from 50mA to 50 amps of current and have speeds ranging from 1,000RPM to 20,000RPM. Using gears, we can transform the available power of a motor from high-speed, low-torque (ideal for flat grounds) into low-speed, high-torque (ideal for hills), or vice versa, which can extend the usability of the motor's power.

Because brushed DC motors use physical contact to transfer power from the motor terminals through the coil, periodic changing of the motor brushes is necessary for frequently used motors. Many DC motors have easily accessible brushes that can be replaced in a matter of minutes.

Brushless Motors

A brushless DC (BLDC) motor uses an electro-magnetic field created by energizing one of three common motor coils in sequence in order to spin the output shaft. The fact that there are no brushes means that these motors have a longer life cycle and higher reliability, giving them an advantage over the standard brushed DC motor. Because of their abnormal coil setup, they cannot be operated with the same simplicity of a standard brushed DC motor, and instead must use a specialized three-phase driver circuit.

Hobby grade BLDC motors are rated by how many RPMs they produce per volt that is present at the motor terminals, denoted "Kv". For instance, a brushless motor with a 1000Kv rating operated at 12 volts, produces 12,000RPM (12 volts × 1000Kv = 12,000RPM). These motors are commonly used to replace brushed DC motors where longevity and reliability are preferred over being easy to drive and inexpensive. They have almost completely replaced DC motors for use in computer hard drives, cooling fans, and CD/DVD ROM drives (see Figure 3-3). We use a brushless DC motor to power the Robo-boat in Chapter 9.

Brushless DC motors are commonly used for PC cooling fans and hobby airplanes. The brushless PC fan in this picture was dismantled due to a broken fan blade. You can also see the brushless DC hobby airplane motor with a BLDC 30A motor controller.

Figure 3.3. Brushless DC motors are commonly used for PC cooling fans and hobby airplanes. The brushless PC fan in this picture was dismantled due to a broken fan blade. You can also see the brushless DC hobby airplane motor with a BLDC 30A motor controller.

Stepper Motors

Stepper motors are brushless DC motors that have two or more independent coils instead of three common coils like a BLDC motor. These coils must be energized at set intervals to keep the motor shaft spinning, much like the BLDC motor. This means that you cannot simply apply power to the wires and watch the motor spin. These motors must be driven using a special sequence and timing provided by the Arduino.

Stepper motors have a defined number of steps or magnetic intervals; each time a coil is switched in sequence, the motor shaft rotates one step. The number of degrees per step determines how many steps are in each rotation of the output shaft. The more steps the motor is capable of, the higher the resolution or more precision it has. This is common with Computer Numeric Controlled (CNC) machines that use two or more stepper motors to control the exact X and Y coordinates of the machine head—they can return to any exact spot on the grid by counting the X and Y steps to that position.

Stepper motors are available in the following two basic types:

  • Bipolar: These stepper motors have two coils that are typically identified by having exactly four wires (see Figure 3-4). Each set of wires is connected to a motor coil and can be identified by measuring the coil resistance with a multi-meter. Each coil in the stepper motor must be switched in a special sequence in order to turn the output shaft—requiring that each of the four motor wires must be driven by its own signal amplifier to operate the motor (or a dual motor-controller).

  • Unipolar: These stepper motors also have two coils, but they additionally have two windings in each coil—so this motor has three wires per coil (x2), totaling six wires. You can usually connect the two common wires from each coil together, resulting in a five-wire motor—some motors have this already done internally. This motor has a constant positive power supply to the common wire from each coil and an N-type transistor switch at each of the negative coil wires. With the appropriate switching sequence from the Arduino, this type of stepper motor is easy to drive.

A few bipolar stepper motors, noted as having four wires on each motor

Figure 3.4. A few bipolar stepper motors, noted as having four wires on each motor

Stepper motors are commonly used for high-precision applications like computer printer heads, CNC machines, and some robotic applications.

Gear Motors

The power of a motor at a given energy can be arranged to have either high speed or high torque. Think of an 18-speed mountain bike to visualize how this works: If you put the bike in first gear, your pedaling will provide a high torque that can enable you to ride up a steep hill with ease at the expense of going slowly. If you put the bike in eighteenth gear, it will be nearly impossible to pedal up a steep hill but will yield excellent speed on flat ground or going downhill.

The power produced by an electric motor can be manipulated in the same way. To convert the power, we must use a series of gears connected to the motor's output shaft or buy a motor with gears built onto the output shaft, called a gear-motor. A gear motor reduces the speed of the motor output shaft from its normally high speed (1,000–20,000RPM) to a slower output speed that is more manageable for a mobile robot (see Figure 3-5).

Here you can see a small DC gear motor (left) and again with the DC motor removed from the plastic gear box.

Figure 3.5. Here you can see a small DC gear motor (left) and again with the DC motor removed from the plastic gear box.

A gear motor can be any type of electric motor, as long as it has a gear box that reduces the output speed of the motor shaft. Each gear motor should have what a gear ratio that specifies the ratio of input speed to output speed of the motor output shaft. For instance, a gear motor with a 100:1 gear ratio implies that the actual DC motor output shaft must spin 100 times to make the geared output shaft complete one revolution.

Servo Motors

A servo motor is a special type of DC motor that uses an encoder to determine the position of the output shaft. Hobby servo motors consist of a small DC motor, speed-reducing gear box, potentiometer shaft encoder, and motor drive circuitry, making them easy to interface directly to the Arduino (see Figure 3-6). The motor drive circuitry is not only used to decode the input signal (R/C servo pulse), but also to drive the DC motor.

These motors can move to a specific position quickly and require only three wires to interface with the Arduino (signal, power, and ground). The signal used to operate the servo is a precisely timed pulse of electricity that ranges from 1 milliseconds to 2 milliseconds – where a 1.5mS pulse yields the center position of the servo motor. The servo motor looks for an update with a new pulse about 50 times per second, or every 20 milliseconds.

A dismantled view of the larger Servo motor from Figure 3-1 reveals the gears, potentiometer, circuit board, and DC motor that are normally packed inside the plastic casing.

Figure 3.6. A dismantled view of the larger Servo motor from Figure 3-1 reveals the gears, potentiometer, circuit board, and DC motor that are normally packed inside the plastic casing.

These motors are intended for use in hobby cars, planes, boats, and helicopters, but have made their way into robotics for their precision, durability, and ease of use. You can find a general-purpose servo motor at your local hobby store for around $15 or at several online retailers for around $5 each.

Hobby servo motors were designed to emulate the position of an R/C transmitter control stick. If the control stick is moved to its upward most position, the servo motor output shaft will likewise move 90 degrees in one direction. If the control stick is moved to its downward most position, the servo motor output shaft will move 90 degrees in the other direction. The total range of most hobby servo motors is about 180 degrees total (1/2 of a complete rotation). Trying to make the output shaft move any farther than its stopping point will likely result in a stripped gear.

Continuous Rotation

It is true that the output shaft of most hobby servo motors can rotate only from 0–180 degrees—but by hacking the internal components of the servo, we can alter its operation to rotate continuously like a normal gear-motor. To do this, we simply disconnect the shaft encoder (potentiometer) and place a resistor divider in its place (a pair of resistors connected together), which tells the controller board that the motor is at the center position at all times. If any pulse signal above 1.5ms is received, it will move the motor forward continuously—likewise if the pulse is below 1.5ms, it will spin in reverse. This can give us the ability to control either forward or reverse continuous rotation of a servo motor.

You can also modify a hobby servo motor to operate as a standard DC gear motor (as in the Chapter 4) by completely removing the servo control circuitry and building your own. This method requires removing the potentiometer and all the electronic components, leaving only the two wires from the DC motor itself and all of the gearing. If there are any plastic stops that keep the output shaft from rotating completely, they should be removed as well. This enables you to drive the motor with full-speed control using a simple transistor amplifier.

Linear Actuators

A linear actuator is an electric DC motor that converts rotational motion into a linear motion. This is usually accomplished using an Acme threaded rod or other screw drive mechanism. These motors are useful for vertically lifting loads or moving an object back and forth (like a steering wheel). These can be used to automatically open a door or gate, raise/lower a hinged load, or move an object back and forth (see Figure 3-7).

Linear actuator motor from a power wheelchair, used adjust the incline of the seat

Figure 3.7. Linear actuator motor from a power wheelchair, used adjust the incline of the seat

The stroke of a linear actuator refers to the maximum distance it can extend. The speed of the actuator tells you how fast it will travel, usually rated in inches/second. The power of the actuator is determined by the power rating of the motor that is driving it and is usually rated by the maximum load capacity in pounds that the actuator can lift. It is typically fine to use a relay to control a linear actuator for simple On/Off control, unless you need extremely precise control in which case you should use a motor-controller.

Calculating Power

Because the amperage of a motor varies depending on the load, most DC motors list the voltage level at which it can safely operate. Although DC motors are usually forgiving and can be slightly over-powered without causing problems, an excess voltage level can burn up the motor coil.

As discussed in Chapter 1, the amperage that is consumed by a motor is dependent on the voltage level and the internal resistance of the motors coil. After the operating voltage is decided, you can measure the motor's coil to determine its resistance, and lastly use the voltage and resistance to calculate the amperage of the motor. With the amperage and voltage known, you can select a properly sized motor-controller for the motor.

Driving

The DC motor is the simplest motor to power; apply a positive signal to one wire and a negative signal to the other and your motor should move, as shown in Figure 3-8. If you swap the polarity of the wires, the motor will spin in the opposite direction.

The speed of the motor is dependent on the positive supply voltage level—the higher the voltage, the faster the motor shaft spins. The power of the motor is its capability to maintain its speed, even under a load and that is determined by the amperage available from the power source—as the workload of the motor increases, more amperage is drawn from the batteries.

To power a DC motor, simply connect one wire to the Positive supply and the other wire to the Negative supply.

Figure 3.8. To power a DC motor, simply connect one wire to the Positive supply and the other wire to the Negative supply.

Some of our robots have powerful motors that can operate at up to 24vdc—if the entire 24 volts is applied to the motor all at once, it is likely to spin the tires or pop a wheelie! We don't want to break any of our equipment or hit anyone nearby because our bot launches when we turn the motors on, so we will use a motor-controller to vary the voltage to the motor from 0v to the power supply voltage (in most cases, 6v, 12v, or 24v). This enables the bot to start slowly and work its way up to full speed, which causes less strain on the batteries during start-up and provides more precise control.

We can vary the voltage level to the motors by using a pulse-width modulation PWM signal to determine the output duty-cycle, or percentage of On time. Because using PWM means that the output is either fully on or fully off, the motors receive as much amperage as the power supply allows for the given duty-cycle, and the power can be varied from 0% to 100% for full speed control.

Finding the Right Motor

DC motors are in virtually any device that has moving parts—you can harvest useful DC motors from old cassette tape players, VCRs, toys, and cordless tools. Salvaging a DC motor is usually easy because they are rarely ever soldered to a printed circuit board (PCB), so you simply unplug the wires and remove any fasteners that are holding the motor in place. If the wires are soldered into place, just cut them leaving as much wire connected to the motor as possible (unless you plan on soldering your own wires to the motor terminals). Once removed, you can test the motor by powering it with a 6v or 12v battery (depending on its size).

As previously mentioned, gear-motors reduce the speed of a motor shaft to a usable RPM for driving a robot. When salvaging parts, you might come across a motor assembly that has plastic or metal reducing gears attached to the motor; you can re-use these gears and create your own makeshift gear-motor. Gear-motors and gear assemblies can also be found at surplus and commercial websites.

Surplus:

  • www.allelectronics.com

  • www.goldmine-elec.com

  • www.alltronics.com

Commercial:

  • www.Sparkfun.com

  • www.trossenrobotics.com

  • www.pololu.com

  • www.superdroidrobots.com

  • www.robotmarketplace.com

You can find 12v automotive windshield-wiper motors at your local junkyard that can be used as drive motors for a medium-sized bot. You can also find powerful motors at your local thrift-store by looking for cordless drills that have bad battery packs or cosmetic blemishes, but working motors and gear boxes.

The H-Bridge

When driving a DC motor in only one direction, we do not need any special circuitry to switch the motor on or off; a simple switch in series with one motor terminal will do. But to reverse the polarity of the voltage of the motor terminal, we need a half-bridge circuit or push-pull driver. This circuit uses two switches (S1 and S3 as shown in Figure 3-9) to provide a path from one motor terminal to either the Positive voltage supply or the Negative voltage supply (Ground). By using only one of these switches at a time, a short-circuit is avoided—the other motor terminal is permanently connected to either VIN or GND

Various half-bridge states

Figure 3.9. Various half-bridge states

The bridge is used to route the correct polarity to the motor terminals at the appropriate time. To avoid a short-circuit, you should never close both switches on the same side of the bridge (both the positive and negative) at the same time (see Figure 3-12). To control the polarity to both motor terminals, we need two identical half-bridges arranged in an H-bridge (see Figure 3-10).

Notice how the circuit looks like the letter "H," which is why they call it an H-bridge.

Figure 3.10. Notice how the circuit looks like the letter "H," which is why they call it an H-bridge.

For the motor to spin, the battery current must flow from the Positive supply, through the Motor, and to the Ground supply to complete the circuit. To make this happen we must open one switch from each side of the bridge, one Low-side and an opposite High-side—that means we can either turn on S1 and S4 to go Forward, or we can turn on S2 and S3 to go in Reverse. The direction of the current flow through the motor terminals determines the direction that the motor spins. We can manipulate the flow of the current by closing the two corresponding switches together to give us directional control of the motor. If all four switches are open (disconnected), the motor is coasting, meaning there is no path for the current to travel.

Generating a Brake

There is also an acceptable condition called electric-braking, which refers to connecting both motor terminals to the same voltage supply—as opposed to leaving them disconnected. Because most DC motors act as a generator if you spin the motor shaft, by connecting both terminals to either the Positive supply or the Ground supply, we are essentially trying to force the generated electricity back into the same supply (see Figure 3-11). This results in the motor resisting to spin—that is, it will keep the motor shaft from moving by forcing opposing voltages into the same supply. We can tell the Arduino to keep both Low-side switches closed to form an electric brake when the bot is in Neutral to make sure it does not roll down a hill or move without being commanded. Alternatively, if all switches are left open in Neutral (coasting), there will be no resistance to the motor generating electricity—so if it is on a hill, it will roll.

Acceptable H-bridge states

Figure 3.11. Acceptable H-bridge states

Shoot-through H-bridge states—bad!

Figure 3.12. Shoot-through H-bridge states—bad!

Implementation

To create an H-bridge circuit, we simply need four switches—two of the switches must control the path of the current from the positive supply to each motor terminal, and the other two must control the path of the current from the negative supply to each motor terminal. These switches are labeled as S1, S2, S3, and S4 in the illustrations. We can use any type of switch that we want in the H-bridge, depending on our application. Relay switches work fine for single speed (On/Off) operation, whereas bipolar transistors or mosfets are more appropriate for full-speed control using PWM.

If you are making a smaller H-bridge with BJT transistors, you should include protection diodes from the drain to source of each transistor to protect them from Back EMF. Mosfets have built-in "body diodes" that are capable of handling the same voltages and amperage as the mosfet itself, so these are usually safe to interface directly to the Arduino.

There are four different homemade approaches to building an H-bridge circuit that we discuss, each with their own benefits and drawbacks. We start with the most simple implementation and progress to the most complex.

Method 1: Simple Switches

We can make a full H-bridge using (2) three-way (SPDT) switches from the hardware store, a DC motor, and a 9v battery. This simple bridge has built-in short-circuit protection so it cannot be commanded into a shoot-through state. It can, however, be placed into any acceptable H-bridge state: forward, reverse, electric brake (positive), electric brake (negative), or neutral. Each switch in the circuit has three positions, On/Off/On, and switches the center contact between the two outer contacts (or in this case, the positive and negative battery wires).

Here you can see a basic H-bridge circuit using two SPDT switches, a DC motor, and a 9v battery. Notice how the top terminals of each switch share a common positive supply wire, while the bottom terminals share a common negative supply wire. The center terminals of each switch are used to route the power signals to the motor terminals.

Figure 3.13. Here you can see a basic H-bridge circuit using two SPDT switches, a DC motor, and a 9v battery. Notice how the top terminals of each switch share a common positive supply wire, while the bottom terminals share a common negative supply wire. The center terminals of each switch are used to route the power signals to the motor terminals.

This method shows the simplicity of a basic H-bridge circuit, but does not provide speed control (it is either on or off). Although this might be a rugged circuit, its use is limited, so it is usually only good for testing and educational purposes.

Method 2: DPDT Relay with Simple

This method is wired the same as Method 1, but we combine the two SPDT switches and use one DPDT Relay, so it can be controlled by the Arduino. Also we can use the Arduino to provide a simple PWM signal for speed control of the motor (see Figure 3-14). The simplest way to do this is to add a Logic-level N-channel mosfet (or several in parallel) to control the entire circuit's path to ground. By using a PWM signal on the Ground supply to the H-bridge (Relay), we can control the speed of the motor from 0–100%, whereas the relay switches the motor's direction. The relay acts as both the High-side and Low-side switches in the bridge, so there are actually two low-side switches in this configuration—the relay used to route the power terminals and the N-channel mosfet used to provide the PWM speed control.

This provides complete 0–100% speed control and requires as few as four parts other than the relay: (2) logic level N-channel mosfets, (1) diode (for relay coil), and (1) small prototyping PCB (or you can make your own). Depending on the mosfet, you can expect to carry about 10 amperes at 24vdc with no heatsink or fan; an n-channel logic-level mosfet can be found at Digikey.com for between $0.50–$5.00 each and with an amperage rating from 100mA–200amps. I usually select power mosfets with the highest amperage rating in my price range (anything above 75 amps), a higher voltage rating than I plan to use in my project (usually 30v–55v is good), and the lowest possible on-state resistance (check the datasheet for Rds(On)).

A relay-based PWM speed control circuit

Figure 3.14. A relay-based PWM speed control circuit

We can build this circuit with (2) FQP50N06L N-channel mosfets from Digikey. One mosfet is needed to provide PWM speed control, and the other mosfet is needed to interface the relay coil to the Arduino for direction control.

The relay mosfet can be controlled by any Arduino digital output pin, whereas the speed control mosfet should be controlled by an Arduino PWM output. Next we connect the mosfet Drain pin to the Relay as shown in Figure 3-14, and the mosfet Source pin to the main Ground supply. The prototyping PCB makes this easier to put together and you can add screw-terminals for easy wiring. The voltage and current limits of this circuit are dependent on the mosfet and relay ratings, giving this circuit potential despite using a mechanical relay switch.

Method 3: P-Channel and N-Channel Mosfets

Moving up, we have a basic solid-state H-bridge that uses P-channel mosfets for the high-side switches and n-channel mosfets for the low-side switches. This H-bridge has no internal protection against short-circuit, so you must be careful not to open both switches on the same side of the bridge because this will result in a shoot-through condition. This design can easily be implemented on a prototyping PCB as well as adding multiple mosfets in parallel to increase the current capacity. This H-bridge can be built using only two p-channel power mosfets, two n-channel power mosfets, two n-channel signal mosfets, and a few resistors (see Figure 3-15).

Notice the 10k pull-up resistors on the P-channel mosfets and the 10k pull-down resistors on the N-channel mosfets. This keeps the mosfets in the off state when not in use.

Figure 3.15. Notice the 10k pull-up resistors on the P-channel mosfets and the 10k pull-down resistors on the N-channel mosfets. This keeps the mosfets in the off state when not in use.

This method enables for a full solid-state circuit without using any mechanical switches or relays. If this circuit is operated within the voltage and current limits of the mosfets, it will easily outlast either of the previous methods. Even though this bridge is more complex than the previous two, it still has limitations; this design is not optimized for high PWM frequencies or high voltages, but costs little and is easy to build.

Method 4: N-Channel H-Bridge

Most p-channel mosfets have higher Rds(On) values, lower amperage ratings, and higher prices than their n-channel counterparts, making it difficult to design a symmetrical H-bridge.

As you might recall, to turn on an n-channel mosfet (logic-level), the Gate pin must be 5v higher than the Source pin (usually Ground). By connecting an n-channel mosfet backward, we can get it to conduct as a high-side switch. To do this, we connect the mosfet Drain pin to the Positive voltage supply and the Source pin to the motor or load. The only catch is that we must now get the Gate pin to be at least 5v above the Positive supply voltage through boot-strapping.

So how do we make a voltage that is higher than the Positive supply voltage of the batteries? A charge pump is used to collect voltage through a diode and into a capacitor each time the PWM signal is cycled. This is called a bootstrap circuit and is effectively a simple voltage doubler used to provide the mosfet Gates with an elevated voltage level. There are several H-bridge driver ICs that include all of the circuitry needed for this operation and require only an external capacitor and diode. We use this type of driver chip to enable the Arduino to control each switch in the H-bridge individually. This type of H-bridge allows for high current capacity and fast PWM switching speeds, which are useful features for a robot motor-controller.

For more information about n-channel H-bridges and circuit diagrams, check out the Open Source Motor Controller (OSMC) project. You can download complete circuits and PCB files, ask questions, or design your own variation and submit your progress to share with the group.

http://www.robotpower.com/products/osmc_info.html

H-Bridge ICs

To build your own H-bridge, but leave the designing to a professional, you might be interested in an H-bridge IC. An H-bridge IC is a complete H-bridge circuit that is contained on a tiny integrated circuit chip. These are usually fitted into a circuit with very few extra components, typically only a few resistors and a regulated power supply for the logic controls. When using an H-bridge IC, you can usually expect shoot-through protection, thermal overload protection, and high frequency capabilities. Although these H-bridge chips are far less likely to be destroyed by user error than a completely homemade design, they also have much lower power ratings than a homemade H-bridge, typically under 3amps of continuous current.

There are several H-bridge IC chips that include all four switches and a method of controlling them safely. The L293D is a Dual H-bridge IC that can handle up to 36 volts and 600 milliamp per motor. The L298N is a larger version of the L293D that can handle up to 2amps (see Figure 3-16). There are a few ICs that can control up to 25amps, but they are expensive and hard to find. There are several H-bridge ICs that work for some of the smaller projects in this book, but the larger bots require a higher powered H-bridge capable of conducting 10amps or more.

Here is the popular L298N dual 2amp H-bridge motor-controller on a homemade PCB. The other components include a 7805 5v regulator, a few EMF protection diodes, a capacitor, and some direction LEDs. This board can be used to control the speed and direction of two independent DC motors.

Figure 3.16. Here is the popular L298N dual 2amp H-bridge motor-controller on a homemade PCB. The other components include a 7805 5v regulator, a few EMF protection diodes, a capacitor, and some direction LEDs. This board can be used to control the speed and direction of two independent DC motors.

Changing PWM Frequencies

We talked about how higher PWM frequencies eventually lead to switching losses and cross-conduction, so what is a good PWM frequency to use? If you leave your Arduino alone and don't change anything, the PWM outputs will run at 1kHz (pins 5 and 6) and 500Hz (pins 11, 3, 9, and 10). This is considered a relatively low PWM frequency for motor-controllers because at this frequency, there is an audible "whine" that you can hear from the motor coils being switched.

Because most motor-controllers can easily handle a 1kHz PWM signal, you might want to leave the Arduino at its default values. If however, you want your motors to be silent during operation, you must use a PWM frequency that is above the audible human-hearing range, typically around 24,000Hz (24kHz). A problem arises because some motor-controllers are not capable of switching at such high frequency—switching losses increase as the PWM frequency increases. Because it is a difficult design task, motor-controllers that can operate at silent switching speeds (24kHz or higher) are usually more expensive and well built.

The frequency of each PWM output pin on the Arduino is controlled by one of three system timers that are built into the Arduino. Think of each system timer in the Arduino as a digital metronome, that determines how many beats will be in each second. The value of each timer can be changed using one line of code and a specific setting selected from Table 3-1.

To change the frequency of a PWM pin, select an available frequency from Table 3-1 and replace the <setting> in the following code with the appropriate setting from the chart. Then add the following line of code into the setup() function of your sketch, depending on the timer you want to change:

TCCR0B = TCCR0B & 0b11111000 | <setting>; //Timer 0 (PWM pins 5 & 6)
TCCR1B = TCCR1B & 0b11111000 | <setting>; //Timer 1 (PWM pins 9 & 10)
TCCR2B = TCCR2B & 0b11111000 | <setting>; //Timer 2 (PWM pins 3 & 11)

Table 3.1. Available PWM Frequency Settings for Each Arduino System Timer

Arduino Timer

<setting>

Divisor

Frequency (Hertz)

0 (pins 5 and 6)

0x01

1

62500

0 (pins 5 and 6)

0x02

8

7812.5

0 (pins 5 and 6)

0x03

64

976.56

0 (pins 5 and 6)

0x04

256

244.14

0 (pins 5 and 6)

0x05

1024

61.04

1 (pins 9 and 10)

0x01

1

31250

1 (pins 9 and 10)

0x02

8

3906.25

1 (pins 9 and 10)

0x03

64

488.28

1 (pins 9 and 10)

0x04

256

122.07

1 (pins 9 and 10)

0x05

1024

30.52

2 (pins 3 and 11)

0x01

1

31250

2 (pins 3 and 11)

0x02

8

3906.25

2 (pins 3 and 11)

0x03

32

976.56

2 (pins 3 and 11)

0x04

64

488.28

2 (pins 3 and 11)

0x05

128

244.14

2 (pins 3 and 11)

0x06

256

122.07

2 (pins 3 and 11)

0x07

1024

30.52

This table Table 3-1 shows the available frequencies with their corresponding settings—you might notice that some frequencies are available only on certain timers, making each PWM pin unique. For example, to change the frequency on PWM pins 9 and 10 from the default 500Hz to an ultra-sonic switching speed of 32kHz, change the setting for system timer 1 in the setup() function, as shown in the following:

void setup(){
    TCCR1B = TCCR1B & 0b11111000 | 0x01;
}

By changing timer 1 to a setting of "0x01", PWM pins 9 and 10 will now operate at 32kHz frequency anytime the analogWrite() command is used on either pin. Alternatively, you can set these same PWM pins to operate at their lowest available frequency (30Hz) by changing the <setting> to "0x05".

If you operate the PWM output at a too low of a frequency (below 100Hz), it will significantly decrease the resolution of the control—that is, a small change in the input will cause a drastic change in output and changes will appear choppy and not smooth as they do at higher frequencies. If in doubt, simply stay with the Arduino default PWM frequencies because they are sufficient for most robotics projects, even if you can hear your motors.

Note

Changing the Arduino system timer 0 affects the output of certain Arduino timing functions that rely on timer 0, such as the delay(), millis(), and micros() functions.

Back EMF

Back Electro-Motive Force (Back EMF) is the term used to describe the energy that must be disposed of when the electro-magnetic field of an inductor collapses. This collapse happens each time the motor is stopped or changes directions. If the voltage cannot escape through a rectifying diode, it can damage an unprotected transistor and possibly damage the Arduino pin that is driving it. A simple rectifier diode (1n4001) works for most relay coils and small BJT transistor-based H-bridges up to 1amp.

A protection diode should be placed between the motor terminal and the power supply. If using an H-bridge, a diode must be placed between each motor terminal and both the positive and negative power supply for a total of four diodes (see Figure 3-17). If you have an H-bridge that has no protection diodes, you can add the diodes directly onto the motor terminals as shown in Figure 3-18.

Protection diodes should be placed around the switches to protect them from motor back EMF, D1–D4 in the image.

Figure 3.17. Protection diodes should be placed around the switches to protect them from motor back EMF, D1–D4 in the image.

Notice this implementation of Back-EMF protection diodes, soldered directly onto the motor terminals—this alleviates the need for diodes built in to the motor-controller.

Figure 3.18. Notice this implementation of Back-EMF protection diodes, soldered directly onto the motor terminals—this alleviates the need for diodes built in to the motor-controller.

Current Sensing

Sometimes, the best way to protect a homemade H-bridge is to install a current-sensing device to monitor the level of amperage that is passing through the H-bridge. By reading the output of a current-sensor with the Arduino, we can send a stop command to each motor if the current level exceeds a given point. The over-current protection feature uses current sensing to disable the driver if the power reaches an unsafe level to protect it from overheating. Using this feature nearly eliminates user errors that can result in a destroyed motor-controller.

The simplest way to measure the amperage level in an H-bridge is to measure the voltage drop across a power resistor. This resistor must be placed in series with motor and the positive voltage supply, and the motor must be powered and running while you are measuring the voltage across the resistor (see Figure 3-19). Knowing the exact value of the resistor in ohms and the measured voltage across the resistor, we can use Ohm's law to calculate the amperage that is passing through the resistor, and therefore the circuit.

The only problem with this method is that the resistor creates heat in the process (wasting electricity). For this reason, it is ideal to pick the lowest value resistor possible (0.01–1 ohm) and it must have a power rating that is sufficient for the amount of current you will pass through it.

By measuring the voltage across a current-sensing resistor, we can calculate the amount of current that a motor is using.

Figure 3.19. By measuring the voltage across a current-sensing resistor, we can calculate the amount of current that a motor is using.

For example, if the voltage drop across a current sensing resistor is 0.5 volts, and the resistor value is 0.05 ohms, how much current is passed through the resistor, and what will the power rating need to be for the resistor?

First we measure the current through the resistor:

  • V = I * R

  • 0.5v = I * 0.05 ohms

  • I = 0.5v / 0.05 ohms

  • I = 10 amps

If you measure 0.5 volts across a 0.05-ohm current sensing resistor, the amount of current that is passing through the resistor is 10amps.

Now to calculate the power dissipation of the resistor:

  • W = I 2 * R

  • W = (10amps * 10amps) * 0.05 ohms

  • W = 5 watts

As you can see, the resistor must be rated for 5 watts to be able to handle 10 amperes flowing through it without failing.

There are better options available for current sensing in an H-bridge, like the hall-effect based ACS-714 current sensor that can accurately measure up to 30amps in either direction, and outputs a proportional analog output voltage that can be read using the Arduino. This sensor is mentioned in Chapter 2 as a non-autonomous sensor. It is available on a breakout board for use with an existing motor-controller or as an IC that can be soldered directly into a motor-controller design (like the ones used on the Explorer bot in Chapter 8). With this motor feedback mechanism, we can use the Arduino to monitor the motor output current and create a custom over-current protection method to keep the motor-controller from overheating.

Commercial H-Bridges (Motor-Controllers)

If you do not plan to build your own motor-controller, you will still need to decide which one to buy. It is important to select a motor-controller with a voltage limit that is at least a few volts above your desired operating voltage, because a fully charged battery is usually a few volts higher than its rating. This is important because if the maximum voltage limit is exceeded even for a few seconds, it can destroy the mosfets, which will result in a broken H-bridge. The amperage rating is a bit more forgiving, in that if it is exceeded the H-bridge will simply heat up. Remember that using a heat sink or cooling fan can increase the maximum amperage limit by removing the dangerous heat, so many commercial units have heatsinks or fans built-in to aid in heat dissipation.

A commercial H-bridge can range in price from $10–$500+, but we will assume that you are not made of money, and focus mainly on the budget motor controllers. Most units accept PWM, Serial, or R/C pulse signals and some have the capability to read several different signal types using on-board jumpers to select between modes. You can find units that handle anywhere from 1amp to 150amps of continuous current and have voltage ratings from 6VDC to 80VDC.

Small (Up to 3amps)

This size H-bridge powers small hobby motors, typically not larger than a prescription medicine bottle. There are many different H-bridges available from online retailers that can handle several amps and range in price from $10–$30 (see Table 3-2). The L293D and L298N are two common H-bridge ICs that many small commercial motor-controllers are based on. The Sparkfun Ardumoto is an Arduino compatible dual motor-controller shield that is based on a surface mount version of the L298N H-bridge IC shown in Figure 3-16, and is capable of handling up to 2amps per channel (see Figure 3-20).

The Sparkfun Ardumoto is a motor-controller shield that is built around the L298N dual H-bridge IC.

Figure 3.20. The Sparkfun Ardumoto is a motor-controller shield that is built around the L298N dual H-bridge IC.

This class of speed controllers also includes hobby Electronic Speed Controller (ESC. These H-bridges usually work only with voltages up to around 12v, because most hobby vehicles do not operate above 12v. They can, however, handle quite a bit of current, but accept only R/C servo pulse signals for control. These are available for both brushed and brushless DC motors, and are usually inexpensive and compact.

Table 3.2. This Chart Shows the Pricing of Some Small Commercial H-Bridges

Company

Model

Channels

Amperage Rating

Price

AdaFruit Industries

Motor-Shield

4

1-A

$19.50

Sparkfun.com

Ardumoto

2

2-A

$24.95

Medium (Up to 10amps)

This power range accommodates motors up to the size of a soda can. These begin to pack some real power but are usually useful for only robotics as gear-motors to provide more torque and lower speeds. There are also several different commercial H-bridges to choose from in this category, usually ranging from $30–$100 (see Table 3-3). At this power level, the motor-controller can generate a lot of heat, so it might be a good idea to use a heat-sink or fan to keep things cool and extend your operating range.

After you get above 5amps, the options for packaged ICs start to get thin—most medium-powered commercial H-bridges use an H-bridge driver IC and a set of four n-channel power mosfets.

Table 3.3. A List of Suggested Medium-Sized Commercial Motor-Controllers

Company

Model

Channels

Amperage Rating

Price

Pololu.com

24v12

1

12A continuous

$42.95

Dimension Engineering

Sabertooth 2×12

2

12A continuous

$79.99

Basic Micro

Robo Claw 2×10A

2

10A continuous

$79.95

Large (Over 10amps)

This class of H-bridge powers the largest DC motors that we use, in the range of 15amps to 150amps. This type of motor is found in electric scooters, power wheelchairs, and power tools and can be used to power larger robots weighing as much as 500 pounds! This means it can probably carry you around.

There are several options for large H-bridges ranging from around $60 to $500+ (see Table 3-4). These motor-controllers are usually full-featured and include heat-sinks or fans to keep them cool. You will want to be careful when connecting the power to these bridges because most do not usually include reverse-polarity protection and connecting the wires incorrectly is not covered under the warranty!

Table 3.4. A List of Sugd Large-Sized Commercial Motor-Controllers

Company

Model

Channels

Amperage rating

Price

[a]

Pololu.com

24v23 CS[a]

1

23A continuous

$62.95

Basic Micro

Robo Claw 2×25A

2

25A continuous

$79.95

Dimension Engineering

Sabertooth 2×25

2

25A continuous

$124.99

Dimension Engineering

Sabertooth 2×50

2

50A continuous

$249.99

RobotPower.com

OSMC (assembled)

1

160A continuous

$219.00

[a] This H-bridge has a built-in Current Sensor IC that can be read using the Arduino.

The Open Source Motor Controller (OSMC)

The OSMC is an open-source H-bridge based around the Intersil HIP4081 H-bridge driver. This chip has built-in logic to control an all N-channel mosfet H-bridge at up to 1MHz PWM frequencies (that's 1000kHz!). It cannot be commanded into a destructive state, so you can use a variety of input techniques.

The driver chip can handle input voltages from 12v to 80v and supply around 2amps of current to the mosfets. This is enough to drive the 16 mosfets used on the current OSMC design at around 16kHz PWM frequency. The use of four parallel mosfets per leg of the H-bridge brings the total current rating up to 160amps at up to 48vdc (voltage rating limited by mosfets). A single OSMC can drive only one DC motor and costs around $219 pre-assembled, but it can be used for any of the robots that we build. We provide a completely through-hole design that you can build yourself for less than half of the price as a standard OSMC, if you want to build your own.

There is a Yahoo! Group devoted to the development of this design as well as several variations that users have contributed. Because the OSMC is open-source, you can edit, modify, and altogether change the design to fit your needs. If your design works, it is always polite to share your new design with the OSMC community.

http://tech.groups.yahoo.com/group/osmc/

Because 160amps might be a bit more than most people need, you can install only as many mosfets as you need. I built two homemade OSMCs and only installed two mosfets per leg (eight total per board) on a 150lb bot, and I can run the bot continuously for several hours without the H-bridge heating up. Because the OSMC design does not use heat-sinks, it is a good idea to add a cooling fan above the mosfets if you will push much current through them.

Now that we have a better idea of what type of motors and motor-controllers we need, let's take a closer look at the power supply that move the motors—batteries.

Batteries

The type and size of battery you choose for you robot determines not only how long it will run between charges, but also how fast it will drive the motors, and how much current can be discharged at once. Batteries are rated by their output Voltage and Amp/Hour rating, which tells us how long the battery will supply power given a particular load. It is important to know that most rechargeable batteries can supply voltage levels that are around 10%–15% higher than their rated voltage when fully charged. For this reason, it is a good idea to choose a motor-controller with a voltage rating that is several volts above your project's maximum operating voltage.

You might recall that arranging the batteries with both series and parallel connections can provide multiple output voltages and higher Amp/Hour ratings. We often use these techniques to achieve a specific voltage with several smaller battery cells. Different battery compositions have varying cell voltages: NiCd and NiMh are 1.2v per cell, LiPo batteries are typically 3-7v per cell, and Lead Acid batteries are 2v per cell. We discuss only re-chargeable batteries, because they are more efficient for robotics projects.

Nickel Cadmium (NiCad)

NiCad batteries have been around for several years and offer good performance and a life cycle of several thousand charges. These batteries are also used for cordless power tools, older cordless telephones, and consumer rechargeables (see Figure 3-21). NiCad is, however, prone to a condition called "memory" that occurs when it is repeatedly charged before being allowed to fully discharge. This causes the battery life to be reduced considerably and is different than reduced battery-life due to age. If you have any of these batteries that are still good, they can be used for small- to medium-sized robots—otherwise, NiMH batteries are generally a better option for around the same price.

NiCad batteries are typically available in standard alkaline battery sizes: AA, AAA, C, D, and so on, but have a cell voltage of 1.2v instead of 1.5v like a standard alkaline battery cell.

Figure 3.21. NiCad batteries are typically available in standard alkaline battery sizes: AA, AAA, C, D, and so on, but have a cell voltage of 1.2v instead of 1.5v like a standard alkaline battery cell.

Nickel Metal Hydride (NiMH)

These rechargeable batteries are commonly used with cordless power tools, cordless telephones, cell phones, toys, and many consumer rechargeable batteries (AA, AAA, and so on) are still made using NiMH. These batteries offer high amp-hour ratings for their size, often in the range of 1000mAh to 4500mAh, and can typically be found in 1.2v cells, which can be arranged in a series to produce whatever voltage you need (see Figure 3-22). They can be re-charged many times but are prone to decreased output as they get older.

NiMh batteries are also available in standard.

Figure 3.22. NiMh batteries are also available in standard.

Lithium Polymer (LiPo)

Lithium Polymer batteries are one of the newer battery types used for their high power to weight ratio. With a typical cell voltage of 3-7v, these batteries are lightweight yet powerful and are able to deliver large amounts of current very quickly. LiPo batteries have recently become much more affordable, making them a viable option for many robotic projects, though proper charging and discharging is required to prevent overheating. They are typically arranged in series packs with up to six cells, totaling 22.2v (see Figure 3-23).

A few different sizes of hobby LiPo battery packs that I use for robotics projects. Shown are two 7.4v packs (2-cell), two 11.1v packs (3-cell), and one 18.5v pack (5-cell).

Figure 3.23. A few different sizes of hobby LiPo battery packs that I use for robotics projects. Shown are two 7.4v packs (2-cell), two 11.1v packs (3-cell), and one 18.5v pack (5-cell).

If a Lithium Polymer cell is discharged below 3-0 volts, it can become volatile and possibly catch fire. LiPo batteries must also be charged properly or again risk catching fire. For this reason, it is recommended that you learn more about lithium batteries before using them in a project. Although LiPpo's are lightweight and pack a lot of power, they can be dangerous if the proper precautions are not taken. Many people shy away from using these batteries in favor of a more forgiving chemistry.

Lead-Acid

This is the type of battery you can find in your car, boat, Power-wheels, solar power systems, and backup power applications. They are typically heavy and bulky, but have excellent power output and the highest amp/hour ratings that we use, usually ranging from 5AH to around 150AH. These batteries are typically available only in 6v, 8v, 12v, and 24v cells of which the 12v variety is the most common. They have internal lead plates arranged in series, each producing around 2 volts. The thickness of these plates determine the use of the battery.

There are several different types of lead-acid batteries to choose from, though we are interested only in the deep-cycle and AGM types for use on our bots.

  • Deep-cycle: This type of battery has thick lead plates that are designed to provide smaller amounts of current for longer periods of time, and they can be drained and re-charged many times. These are commonly used for powering lights, radios, pumps, and other accessories on boats, RVs, solar, and backup power systems. A typical deep-cycle battery has a rating from 20Ah to 150Ah. This type of battery works well for powering large robots for several hours between charging.

  • Starting: This type of battery has a lot of thin lead plates that can deliver massive amounts of current very quickly. This is ideal for powering automotive starters that draw larger currents in a short amount of time in order to start an engine. If this type of battery is allowed to completely drain several times (more than 5%–10% discharge), it can render it useless! These batteries are not suitable for draining and re-charging very many times, so we avoice this type for our robotics projects.

  • Wet-cell battery: This includes most automotive batteries because they have removable caps that enable you to add water or acid if needed. These batteries are by far the largest and heaviest and must be mounted upright to keep them from spilling, but are good for larger robots where extended run-time is required.

  • Gel-cell battery: This battery is similar to the wet-cell in terms of power, capacity, and size. These batteries, however, are sealed from the manufacturer to keep them from spilling—this enables them to be mounted in almost any position. A gel-cell battery is typically more expensive than a standard wet-cell battery but also has a longer life.

  • Absorbed Glass Mat (AGM): This battery is typically used for medium applications including backup lighting and some solar power setups. These batteries are sealed from the manufacturer and can be mounted in any position. They are also commonly referred to as Sealed Lead Acid or SLA batteries (see Figure 3-24). They are affordable and typically rated from 2Ah to 75Ah. These are similar in operation to deep-cycle batteries and are designed to be recharged many times. These are usually a bit heavy for small bots, but are an excellent choice for a medium- to large-size robot and have the best run-time for the price.

A few standard AGM sealed lead-acid batteries. Pictured are two 6v, 4.5AH batteries (top) and one 12v, 7AH battery (bottom).

Figure 3.24. A few standard AGM sealed lead-acid batteries. Pictured are two 6v, 4.5AH batteries (top) and one 12v, 7AH battery (bottom).

Each battery type has its own advantages. Notice in Table 3-5 that although NiCad and NiMh batteries are good choices for most projects, LiPo batteries are the lightest and lead-acid are the cheapest. Each has its own place in our projects, and we will use each type throughout this book.

Table 3.5. Battery Comparison

Type of Battery

Voltage

Volts/Cell

Cells

Price

Weight

Amp/Hours

Lithium Polymer

11.1v

3-7v

3

$32.00

14oz

5000mAh

NiCad

12v

1.2v

10

$49.99

32oz

5000mAh

NiMH

12v

1.2v

10

$49.99

32oz

5000mAh

Lead Acid (SLA)

12v

2.0v

6

$15.99

64oz (or 4lbs)

5000mAh

Charging

It is best to buy a good battery charger that has multiple charging voltages and currents. A typical adjustable automotive battery charger is selectable from 6v–12v and has several amperage levels, usually 2amps and 15amps.

As a rule of thumb, a normal charging rate is not more than 1/10th of the Amp/Hour rating. This means that a battery that is rated for 5000mAh should not be charged with a current that is more than 500mA (5000mAh / 10 = 500mA). If an automotive battery charger delivers too much current for your batteries, you might need to use a hobby-type charger that it compatible with multiple types of batteries.

I use a Dynam Supermate DC6 multi-function battery charger to charge all of my NiCad, NiMh, LiPoly, and small lead-acid batteries, because it offers both balance charging and selectable current levels for charging a variety of different battery types (see Figure 3-25). It requires a DC power source from 11V–18V, and can charge batteries up to 22.2V. Most hobby chargers also come with several different charging adapters to accommodate for the various plug types commonly found on rechargeable batteries.

A Dynam DC6 multi-battery charger. This charger is compatible with LiPo, NiMh, NiCd, and Lead-acid—as well as having an adjustable charging rate.

Figure 3.25. A Dynam DC6 multi-battery charger. This charger is compatible with LiPo, NiMh, NiCd, and Lead-acid—as well as having an adjustable charging rate.

Lithium batteries require special attention to keep them from overheating and catching fire, so it is recommended that you buy the appropriate charger for the battery pack you have chosen. Lithium batteries have no "memory" effect, so you can charge them as often as you like without completely discharging them.

Materials

As with everything else, there are several different materials you can choose from to build your robot. Each has its own place and you shouldn't count any one material out of your supply, because it might be the best solution to a future problem. My theory is that the more tools that you have available, the more solutions you have to a given problem. I consider the term "tools" to go further than just hammers and drills to include your materials, creativity, and general skill-set—welding, woodworking, plastic-molding, fiberglassing, 3-d printing, sewing, machining, PCB fabricating, or whatever moves you.

Wood

Wood is by far the easiest material to come by. You can theoretically make a robot from tree limbs if you were so inclined, or plane the limbs into planks and make a finished wood frame. Wood is generally used only for cheap prototyping and proof-of-concept project, because it is susceptible to bending and warping without proper treatment (not good for precisely mounted parts). Sheets of wood can be used to build a platform for holding electronics, because it is non-conductive and easy to drill holes in when mounting PCBs. Wood is also good for making wedges or spacers that might be too difficult to make using steel.

Metals

There are two types of metal that are of special interest to any robot builder: steel and aluminum. Both of these make strong and rigid frames that are resistant to warping and if properly painted, should last for many years. They can be either bolted together or welded and are strong enough for even the largest robots.

  • Steel: This metal can be put together using bolts (requires drilling holes) or welding (requires welder). Either way can be very strong and likely outlast all other parts on the bot. Steel is however heavy, so it is generally not good to use for smaller bots because smaller motors won't be able to carry a steel frame around. Large bots benefit from a steel frame because it is strong and can support quite a bit of weight.

  • Aluminum: This meatl has the same general uses as steel, but it is much lighter. You can build small, medium, and large bots with aluminum. Welding aluminum requires special equipment, so you might have to plan on bolting these pieces together.

If using bolts, you need to pre-drill holes the same size as the bolts you use. You should buy drill bits made for drilling through steel and use the highest speed setting on your drill. You can also drill aluminum, wood, and plastics with a steel drill bit. Metals can also be "tapped" to add screw threads to a drilled hole, which can be helpful to decrease the number of bolts needed to secure each piece together.

If you need to cut steel or aluminum, you can use an angle-grinder, reciprocating-saw (with steel blade), cutting-torch, metal miter saw, jigsaw, or hacksaw depending on your tool selection. A reciprocating saw is usually the fastest and cleanest cutting of the saws (it is my personal choice for quick cuts), whereas an angle-grinder is good for cleaning up rough edges.

Nuts and Bolts

Regardless of what material you choose to build your robot, you are going to need some nuts and bolts to hold everything together. Using a nut and bolt to secure two pieces of metal, wood, plastic, or fiberglass together can provide excellent strength in addition to being removable if needed.

A bolt is a metal rod with precision threads, and is available in almost any length and diameter that you can think of, in both metric and SAE sizes. You can find bolts with various shaped heads and thread types but they all serve the same purpose—holding two or more objects together.

A nut is the threaded metal ring that mounts to the bolt. Like bolts, nuts are also available in various shapes and sizes, and with different thread types. You will likely need a pair of pliers or a wrench to tighten a nut to a bolt, and it is advisable to use a lock-washer to prevent the nut from loosening during use.

Here you can see a variety of nuts and bolts, like the ones used throughout this book.

Figure 3.26. Here you can see a variety of nuts and bolts, like the ones used throughout this book.

Plastics

PVC is a commonly available plastic that can be cut, drilled, tapped, and even welded using a stream of hot air. We use PVC plastic to make a motor-mount in Chapter 9, and clear plexiglass (clear acrylic) sheets in multiple projects as a non-conductive mounting base and protective cover.

Chain and Sprockets

Chain is used to transmit power from a drive sprocket on the motor, to a receiver sprocket mounted on the wheel. Chain comes in several different sizes, but we use only #25 roller chain plexiglass also labeled as 1/4in pitch. This type of chain is commonly found on electric scooters. Sprockets are also labeled by their pitch, so it is important to get matching sprockets and chain or they won't fit together. You can choose a gear-ratio for the motor sprocket and wheel sprocket pair by selecting the number of teeth on each sprocket. Using a small motor sprocket and a large wheel sprocket is a good way to gear down a drive-train, allowing for reduced speed and increased torque.

Chains are usually sold with universal connecting links so you can size the chain to fit your needs. When using a chain and sprocket setup, it is important to maintain proper chain tension. Too much tension can result in a broken chain and not enough tension creates a slack in the drive transmission that can result in broken sprockets teeth. Each of the projects that use chain drive transmissions need to have adjustable motors or wheels to tension the chains plexiglass this can complicate the building process, so it is usually desirable to use motors with the wheels attached when available.

Wheels

The wheel is the final stage of the drive-train. It is what makes contact with the ground to propel the robot. As you might know, a larger wheel diameter travels farther than a shorter wheel diameter. Logically, this makes sense because each time the motor output shaft makes one complete revolution, the bot must travel the same distance as the outer circumference of the wheel. So a larger wheel travels faster than a smaller one, using the same motor RPM.

For smaller bots, you can make your own wheels from plexiglass or wood, or buy a toy car from your local thrift-store that has a salvageable set of wheels on it. Larger bots require finding wheels typically manufactured for a lawnmower, wheel-barrow, lawn-tractor, or other similarly sized vehicle that can carry the same payload. Wheels often require modification to fit onto a motor output shaft or attach a sprocket.

Summary

At this point you should be able to identify the various types of DC motors and determine what type of motor you need for your project. In this chapter you learned that standard brushed DC motors are usually identified by having two wires and are by far the most common and the easiest to drive, but have brushes that wear out after extended use. Brushless motors typically have three wires and require special circuitry to operate, but have excellent high-speed durability and reliability. Stepper motors have four, five, or six wires and also require a special drive circuit to operate, but have a specific number of steps in each rotation, making them ideal for position tracking applications. Servo motors use an encoding device to determine the location of the output shaft, making them ideal for angular position emulation. A linear actuator is a DC motor that converts rotational motion into linear movement. Any of these motors can be mated to a gear box to convert its energy from high-speed/low-torque to low-speed/high-torque.

We then discussed the various types of H-bridge motor control circuits and their allowed states. You should now understand how to command a simple H-bridge circuit into Forward, Reverse, or Electric-braking (positive or negative), and how not to command a Shoot-through condition (short-circuit). We then moved on to discuss how to change the PWM frequency for each timer on the Arduino as well as how to deal with Back-EMF and the benefits of current sensing in an H-bridge. We finished talking about H-bridges with a few suggestions for various sizes of commercial H-bridge motor-controllers.

Lastly, we talked about the various types of batteries and materials that we will use in our projects. Although NiCad and NiMh have a high-energy capacity, are commonly available, and easy to work with, they can also be expensive. Lead-acid batteries are inexpensive and provide excellent power, but can be heavy and thus are not suitable for small bots. Lithium Polymer (LiPo) batteries are extremely lightweight, provide excellent power, and have come down considerably in price since becoming available, but are sensitive to over-discharging and thus require more complex circuitry to ensure that they are not completely drained.

Enough talk, let's start building some robots! First up is a small autonomous robot that loves to follow lines... I named him Linus because I'm a Linux geek (Thanks, Mr. Linus Torvalds!) and it seemed to fit his behavior.

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

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