In Lab 1, we used buffer IC’s (7417, 7414) to isolate the signals to and from the Arduino. This protected the board, and provided power for external devices without drawing it from the Arduino. An H-bridge can be thought of in much the same way. It is the interface between an electrical signal and an electrical power source. Though they share the same medium, their functions are vastly different.
The H-bridge is a common circuit used to control the speed and direction of a DC motor with low current PWM signals. The H-bridge you will be using is the LMD18200 (datasheet) and has additional functionality. It allows you to supply power to the motor (on/off), switch its direction
(CW/CCW), brake the motor, sense the amount of current being supplied to the motor, and provides a warning signal if overheated.
In this lab, we will explore two methods for controlling the DC motor with the Arduino.
Sign/Direction PWM is the most straight forward way of using the H-bridge. The amount of current that is sent to the DC motor from OUT1 and OUT2 is proportional to the duty cycle of the PWM signal. The absence of a pulse signal represents zero drive whereas a constant signal represents full drive. The DIRECTION pin determines the source of the current. A logic high means that current flows from OUT1 to OUT2 whereas a logic low is the opposite.

Simple PWM consists of a single, variable duty-cycle signal in which both direction and amplitude information is encoded. A 50% duty-cycle PWM signal represents zero drive, since the net value of voltage (integrated over one period) delivered to the load is zero. A 25% duty-cycle PWM signal represents current flow from OUT2 to OUT1 whereas a 75% duty-cycle represents current flowing from OUT1 to OUT2. To use simple PWM for driving the DC motor, wire the PWM signal from the Arduino to the DIRECTION input (pin 3) while the PWM input (pin 5) is tied to logic high. If you used a pull-up resistor on the PWM input, you can control the direction and magnitude of a DC motor with only one output from the Arduino.



Before you continue to the software tasks, make sure that your DC motor is working by supplying 5V from the benchtop power supply. The Arduino will not be able to supply enough current. Plugging the DC motor into the 5V and GND will trigger a board shutdown in order to prevent further damage.
Use a different PWM method for the two following tasks. For example, if you use the sign/direction PWM method for “Throttle Control”, you should use the simple PWM method for “Mimicking Motion”
Control the direction and speed of the provided DC motor with a potentiometer. The motor should behave like the throttle of a boat. A potentiometer twisted all the way to the right should have the motor spinning fast in one direction. As the potentiometer is twisted left, the motor should slow down and then begin spinning the other direction.
Tie the direction and speed of the motor spinning to the direction and speed of the potentiometer rotation. The faster you spin the potentiometer, the faster the motor should spin.
The map function provided by the Arduino libraries provides an easy way to scale a number within a range. It is called by map (value, fromLow, from High, toLow, toHigh). fromLow and fromHigh are the initial range of value. toLow and toHigh are the new range of values. The function returns the scaled value.
Velocity can be approximated as a change in position over a change in time. You can keep track of time in the Arduino with the millis()function. millis() returns the millisecond value of the onboard clock. It takes about 5 days for this counter to run-over and restart.
NorthWestern’s wiki for their mechatronics classes. They pages contain amazing amounts of information about DC motors, RC servos, and stepper motors. They also have links to past student projects which may serve to inspire.
Arduino’s own reference section. Everything and anything you’d want to know about the Arduino, you can find here.
For a more in depth understanding of the H-bridge used in lab, there is no better resource than our own H-bridge help manual.