Arduino Motor Control

image

 

We carry a few products that can be used to implement motor control with an Arduino (or any other controller).  A recent addition is the BM001 Single H-bridge Controller.  Pictured above is the BM001 attached to a test board “Arduino shield”  I put designed.  It allows me to easily wire our breakout modules to an Arduino.  Since the breakout modules don’t have pins I used spring-loaded test points to connect the modules to the shield.  Then jumpers are used to wire from the module connections to the Arduino pins.

The BM001 has a Freescale MC33926 H-bridge on board.  This is a good automotive H-bridge.  It is rated for 5A peak and up to 28V operation.  However, with ratings like this you need to be aware of thermal issues.  In all likelihood operation above 1A would probably cause thermal issues and require cooling.  If operating above 18V motor voltage you would want to consider protective circuitry to keep transient voltage spikes below the 28V threshold.

The Arduino code is not complex.  The MC33926 has three inputs and two outputs.  The inputs are…

EN:  Setting this pin to a logic high enables the H-bridge.
IN1:  Setting this pin high enables one half of the H-bridge.
IN2:  Setting this pin high enables the other half of the H-bridge.

To rotate a motor forward  you tie one IN2 pin low, and tie the other IN1 pin high.  If you pulse-width-modulate (PWM) the IN1 pin you can control the motor’s speed.  To reverse the motor you tie IN1 low and PWM IN2.

The outputs are…
SF:  Status flag, is pulled to ground if a fault condition occurs.  A fault can occur if the motor (or other load) draws too much current.  A fault will stop the motor and the EN pin will need to be toggled to reset it.
FB:  This is the motor current feedback output.  An analog value proportional to the motor current can be read at this pin.   Unfortunately, for small motors this value is so low as to be useless.  You could amplify the signal external to the module to make better use of it.

Code setup is straightforward.  I defined the pins and established their correct direction.

image

In the main code I just cycle the motor between forward and reverse at 50% duty-cycle for 1 second each.  The current feedback is sent to the serial monitor if you want to look at it.  I also check the status flag after each cycle to see if a fault condition exists, and if so I reset the H-bridge.

image

Here’s a cleaner photo of the BM001 module that also shows its small size.  The motor I’m using in this example is a 12V 200mA motor.  The motor is a good size for robot drive systems and has a decent balance of speed and torque.  This H-bridge module can easily drive it.

BM001 h bridge

Speak Your Mind

*