I present a motor controller that is designed to be simple, robust, cost effective and able to handle high current. I wanted to take advantage of Pulse Width Modulation (PWM) to allow speed control but keep direction control as simple as possible.
I decided to use two Single Pole Double Throw (SPDT) relays and a single MOSFET instead of a conventional H-bridge design. The two relays are setup as an H-bridge to control direction. The MOSFET controls speed by varying the duty cycle of the PWM signal.
- Inputs for direction and PWM signal
- Input voltage = 12V
- Size: 2.5W” x 3.8L”
- MOSFET driver
- Schematic – PDF
- PCB – PDF
- Schematic – SCH
- PCB – PCB
- Mechanical Drawing – DXF
- Bill of Materials – Excel
- MBasic Firmware – *.bas
- MBasic Firmware – *.hex
- Visual Studio Test Program – C#
The schematic and PCB was developed with the freely available ExpressPCB software.
The firmware was developed with MBasic from Basic Micro. (Basic Micro no longer supports MBasic)
Reference the B.O.M above for a list of the parts necessary to complete the Hobbybotics Motor Controller.
All of the components are through-hole and easy to solder. You may need to add a heatsink to the MOSFET and Schottky Diodes.
Reference the below schematic and layout file for component locations.
Connect three pins from a microcontroller to the FWD, REV and PWM pins of the motor controller. Connect a 12V source to the M+ and M- pins (there is an extra set of power pins to allow an additional motor controller to share the same power source).
I have uploaded the MBasic firmware along with the Visual Studio application I used to develop and test the motor controller.
MBasic is no longer supported but, the basic code can be easily ported to other languages. I’ll be updating the code to PicBasic Pro in future versions.
Below is a screenshot of the test application used to vary the speed and direction of the attached motor. Commands are sent to a PIC16F877A test board I developed through the serial port. These commands are translated into speed and direction.
The “Stop” button on the test application ramps the motor speed down instead of forcing the motor to an abrupt stop. The ramp-down functionality was designed to minimize stress on the motor controller and the motor.
The circuit works by applying a high or low signal to one of the direction pins on the motor controller. This signal activates the associated channel on the optoisolator which, in turn, activates the associated relay. Current flows through the selected relay contacts and is regulated by the MOSFET to control the speed of the motor.
Hobbybotics Motor Controller V1.0 Gallery
Hobbybotics Motor Controller V1.0 (External Link)
This example shows hardware and software used to implement the design. It is recommended the viewer use sound judgment in determining and/or implementing this example for any particular application. This example may include information from 3rd parties and/or information which may require further licensing or otherwise. Additional hardware or software may be required. Hobbybotics or any affiliates does not support or warrant this information for any purpose other than a design example and takes no responsibility for any mishaps (none being implied).