# PSoC Lab 06: DC Motor Speed Control

## Objective

• Learn how to interface DC motor with microcontroller
• Learn how to contrtol motor speed and direction

## Background Information

Engineers use electric motors for a variety of applications requiring movement (robots, automation equipment, disk drives, etc.). A motor is only useful if we can control it. Sometimes we want to control the motor’s position (robot arms, 3d printer), sometimes its speed (cruise control), and sometimes its torque (human-interface robots, heavy machinery). In this lab, we will investigate controlling the voltage across a motor, which will control the speed of the motor. The steady-state speed of the motor is proportional to the voltage across its terminals, unless acted upon by an outside force.

# DC Motor Driver

DC motors are the most common and least expensive of all small motors. It can produce a continuous rotational speed that can be easily controlled. Small DC motors ideal for use in applications were speed control is required such as in small toys, models, robots and other such electronics circuits.

Since motors require more current than the microcontroller pin can typically provide, the motor can not directly power through the microcontroller. It must be connected to some type of a switch (such as transistors, MOSFET, Rlay etc.), which can be controlled by a small current, then amplify and generate a larger current to drive the motor. This entire process is called motor driver.

#### What is a Motor Driver?

A motor driver is basically a current amplifier which takes a low-current signal from the microcontroller and then turn it into a proportionally higher current signal which can control and drive a motor.

#### Motor Driver for Single Direction

Turning a motor ON and OFF requires only one switch to control a signal motor in a single direction. In most cases, a transistor can act as a switch and perform this task to drive the motor in a single direction.

Uses Transistor as Switch
Uses MOSFET as Switch
Uses Relay

#### H-Brigde

If the motor need to reverse its direction, the simple way is to reverse it polarity. This can be implemented by using four switches that are arranged to alter polarity on a motor thus changing the direction of rotation. Most common and clever design is a H-bridge circuit where switches are arranged in a shape that resembles the English alphabet "H". A typical H-bridge is shown below:

The H-bridge circuit pnsists of four switches A, B, C and D. Turning these switches ON and OFF can drive a motor in different ways.

1. Turning on switches A and D makes the motor rotate clockwise
The left lead of the motor will be connected to the power supply, while the right lead is connected to ground. Current starts flowing through the motor which energizes the motor in (let's assume) the forward direction and the motor shaft starts spinning.
1. Turning on switches B and C makes the motor rotate counter clockwise
The reverse will happen, the motor gets energized in the reverse direction, and the shaft will start spinning backwards.
1. Turning on Switches A and B will stop the motor (Brakes)
1. Turning off all the switches gives the motor a free wheel drive
1. Never ever close both A and C (or B and D) at the same time. If you did that, you just have created a really low-resistance path between power and GND, effectively short-circuiting your power supply. This condition is called ‘shoot-through’ and is an almost guaranteed way to quickly destroy your bridge, or something else in your circuit.

#### Uses L293D to Connect the Motor

The L293 and L293D are quadruple high-current half-H drivers.

• The L293 is designed to provide bidirectional drive currents of up to 1 A at voltages from 4.5 V to 36 V.
• The L293D is designed to provide bidirectional drive currents of up to 600-mA at voltages from 4.5 V to 36 V.

Both devices are designed to drive inductive loads such as relays, solenoids, DC and bipolar stepping motors, as well as other high-current/high-voltage loads in positive-supply applications.

All inputs are TTL compatible. Each output is a complete totem-pole drive circuit, with a Darlington transistor sink and a pseudo-Darlington source. Drivers are enabled in pairs, with drivers 1 and 2 enabled by 1,2EN and drivers 3 and 4 enabled by 3,4EN. When an enable input is high, the associated drivers are enabled, and their outputs are active and in phase with their inputs. When the enable input is low, those drivers are disabled, and their outputs are off and in the high-impedance state. With the proper data inputs, each pair of drivers forms a full-H (or bridge) reversible drive suitable for solenoid or motor applications.

## Required Components List

 5V DC Motor x 1 L293D x 1 Braedboard x 1 Power Supply Module x 1 Push switch x 1

## Procedure

Procedure can have as many steps as needed per experiment. A checkbox for instructor's initials, stamp, etc. should be provided next to each step, in order to easily track individual student's progress.

Lab Experiments

Experiment 1:

## Questions

Around five questions should be based on Required Reading Material. Two more challenging questions will require students to perform additional research for extra credit points

## Exercises

Program Implementation will require code submission.