[an error occurred while processing this directive]

PWM Speed Controller for Small DC Motors

with Reverse with Digital Interface for Microcontrollers

by Bryan A. Thompson

Last Updated 11/29/2008

Description

This is a reversible speed controller for small DC motors.  It uses PWM generated by the microcontroller to regulate the speed of the DC motor - this requires one digital output pin from the microcontroller.  The IRF1404 FET is rated up to 202A with proper heatsink.  I chose not to use an H-bridge to minimize switching losses and FETs, and because superfast polarity switching is not necessary.  The circuit includes a DPDT relay controlled by a second digital output from the microcontroller.  

Current limiting resistor for FET gates

We expect the control inputs for the PWM FET and relay coil FET to be +5V.  At t=0 the capacitor looks like a short circuit.  The BASIC Stamp can safely source 20mA per pin.  Therefore the resistor needs to be 5V/20mA = 250 Ohms.  We chose a 270 Ohm resistor to limit the current to something that can be safely supplied by the Stamp and that can be purchased. 

+5V Voltage Regulator

A 7805 three terminal regulator IC and filter caps were used to generate the 5V supply required for the relay.  I considered a resistor in series with the relay coil and decided against it to allow the supply voltage to change to support motors with multiple voltages.

FET switch for relay coil

The relay required at least 70% and at most 130% of the rated voltage of +5V to switch the coil on safely.  It was not possible to meet that requirement with a BJT, so a FET was used. 

FET Protection

I included a 15.1V Zener diode across the Gate and Source terminals to protect against static electricity and reverse control inputs.  Diode D1 is provided to protect Q2 when the relay coil is turned off.  Diode D4 is provided to protect Q2 from possible back EMF generated by the load connected to the motor controller outputs.

Reverse Voltage Protection

I included a 1N4001 diode in parallel with the input supply to protect the motor controller in case the power supply is connected in reverse.  This diode is only capable of conducting 1A in the reverse direction, so if the power supply can supply more than 1A the diode will be destroyed.  Use a 1A fuse to eliminate this possibility. 

Control Inputs

The motor controller is designed to provide no output unless a control signal is applied.  In case the motor controller becomes disconnected from the microcontroller or the microcontroller fails, the motor controller will remove power from the load. 

BASIC Stamp Output P0 is assigned to the PWM FET Q2.  When this control is off, the output of the motor controller is off (minus a few nA leakage current through the FET).  A TTL Logic High (+5V) is required to turn this on.  Resistor R4 is provided to drain the energy stored in Cgs when the input is turned off or disconnected.  It may be increased to more rapidly turn off the FET, but shouldn’t be less than about 2K, as it forms a voltage divider (together with the gate current limiting R3) and the FET requires about 4V to turn on the FET.

BASIC Stamp output P1 is assigned to the reversing relay FET Q1.  When this control input is off, the voltage to the load is normal (not reversed).  A TTL Logic High (+5V) is required to turn this on and provide reverse voltage to the load.  Resistor R2 is provided to drain the energy stored in Cgs when the input is turned off or disconnected.  It may be increased to more rapidly turn off the FET, but shouldn’t be less than about 2K, as it forms a voltage divider (together with the gate current limiting R1) and the FET requires about 4V to turn on the FET.

Power Supply

The BASIC Stamp requires 5V-15V to operate safely. 

The Motor Controller requires Vcc (the 9V battery clip) to be 7.5-20V to provide the +5V output required for the relay coil.  The max safe operating voltage for the FETs is when the supply voltage is below 40V. 

The relay contacts are rated for 8A and the PWM FET is good for 160+ amps if the PWM FET is connected to an appropriate heatsink.  The motor current should be less than about 2A unless the PWM FET is connected to a better heatsink and the wiring that composes the output stage is upgraded.   

The control inputs to the motor controller require a voltage of 4-15V to turn the FET on.  Anything more than 15.1 and the gate protection Zeners will start conducting and short the control input to ground.

 

Figure 1 - Schematic

 

Download complete project with documentation and sample code for Basic Stamp II microcontroller (ZIP File)

[an error occurred while processing this directive]