Makerverse Motor Driver, 2 Channel - Application Guide

Updated 19 December 2022

Introduction

The Makerverse Motor Driver has been updated to a v20 design which now features a 5V output pin instead of the VM pin. Some images and in-video descriptions in this guide may be outdated

This guide covers the use of the Makerverse 2 Channel Motor Driver to control small DC motors and bipolar stepper motors from a microcontroller. Code examples are provided for the Raspberry Pi Pico, but the concepts can be easily applied to other microcontrollers such as the Arduino family or Micro:bit.

This motor driver is capable of a sustained total output current of 1.6A (2A peak), can switch motor voltages from 3-16V, and is compatible with both 3.3V and 5V logic devices.

For some background reading on how motor drivers operate you can check out our guide covering Motor Drivers vs Motor Controllers.

To follow along it's best to have:

Contents:

makerverse-2ch-motor-driver-pins

Connections

The Makerverse 2 Channel Motor Driver is deisnged with unsoldered connection pads with standard pin spacings so you can easily customise it for your application.

Left Side

These pins suit a strip of standard 2.54mm pitch pin header. The "DIR" and "PWM" pins are digital logic inputs designed to be connected to microcontroller general purpose input-output (GPIO) pins. These are rated for 1.5V to 5V operation and can therefore compatible with all available microcontroller development boards. The "DIR" (direction) inputs control the rotation direction of the motor while "PWM" (pulse width modulation) inputs turn the motor on and off. The PWM inputs get their name from their ability to be switched rapidly on and off, allowing the motor speed to be varied without needing to vary the supply voltage.

The 5Vo pin is a regulated 5V output. On older versions, this is a VM pin which is intended as a power output for a suitable microcontroller power supply. Power can also be supplied into this pin however the recommended maximum input current is 1A.

You can use jumper wires, a breadboard, or a prototype PCB to make connections between the motor driver and a microcontroller.

Pin Description
DIR B Logic input, sets polarity of B output (ie: motor direction)
PWM B Logic input, enables (1) or disables (0) B output
DIR A Logic input, sets polarity of A output (ie: motor direction)
PWM A Logic input, enables (1) or disables (0) A output
5Vo Regulated 5V output supplied by VM
GND Negative supply voltage input (or output)

 

Right Side

These large, easy to solder, pads suit 5.0mm pitch screw terminals or soldering of wires up to 1.45mm in diameter (15 AWG). A total of six terminals are needed so you can use three 2-pin blocks or two 3-pin blocks. Be sure to snap them together before soldering!

Pin Description
B+ Channel B + output
B- Channel B - output
A- Channel A - output
A+ Channel A + output
VM Motor positive power supply input, 3-16V. Reverse polarity protected.
GND Motor negative power supply input

 

makerverse-2ch-motor-driver-headers-terminals

 

Download MicroPython Module

For this guide you will only need a single driver file to start using the Makerverse 2 Channel Motor Driver.

Once downloaded, copy Makerverse_Motor_2ch.py onto you Raspberry Pi Pico with Thonny.

A full description of all methods provided by this library can be found in the GitHub repo's README.

Driving Small DC Motors with the MicroPython Module

To keep this example simple the default pin assignments assumed by the Makerverse_Motor_2ch MicroPython Module will be used. These are as follows:

  • Raspberry Pi Pico pin GP0 to PWM A
  • Raspberry Pi Pico pin GP1 to DIR A
  • Any Raspberry Pi Pico GND pin to the motor driver's GND

To power the motor this example uses a 4xAA battery pack connected to the VM (red) and GND (black) screw terminals.

 

makerverse-2ch-motor-driver-raspberry-pi-pico-pinout

makerverse-motor-driver-2ch-dc-motor-driving

 

Once all connections have been made the following basic example can be used for testing. All it does is create a motor "object" and set it to rotate in the "forward" direction at full speed. This example also allows you to see which direction is "forward" and swap the motor's polarity if needed. This example will spin the motor until stopped; run m1.stop() at the REPL to stop it.

from Makerverse_Motor_2ch import motor

m1 = motor(pwmPin = 0, dirPin = 1)
m1.forward() # This method returns almost instantly

For more control, the following example uses the motor.drive() method to specify both a speed and duration (in milliseconds):

from Makerverse_Motor_2ch import motor

m1 = motor(pwmPin = 0, dirPin = 1)
m1.drive(speed = 80, duration_ms = 1000)

For a more interesting example, we can have the motor slowly vary its speed from full forward to full reverse. Note that this example also demonstrates the "dead band" of speed values which are too slow to overcome static friction in the motor and gearbox. The example above also demonstrates how the speed variable works: negative values indicate reverse rotation and positive values indicate forwards.

from Makerverse_Motor_2ch import motor
import time m1 = motor()
for speed in range(-100,100,10): print(speed) m1.speed(speed) time.sleep_ms(300)

m1.stop()

 

Driving Bipolar Stepper Motors with the MicroPython Module

The Makerverse_Motor_2ch MicroPython Module contains the bipolarStepper() class to aid in driving stepper motors.

For this example a bipolar stepper motor is connected with one coil connected to the A+ and A- pins while the other coil connects to the B+ and B-. Note that if the stepper motor spins in the wrong direction swapping only one coil's polarity will reverse the motor's direction.

When creating the stepper motor object the required RPM and steps per rotation should both be specified for complete control. If the motor you're using only has the "degrees per step" data the steps per rotation is equal to 360 divided by the degrees per step.

Be sure to check out the complete library documentation on the GitHub README.

The default connections from the Raspberry Pi Pico to the motor driver are as follows:

  • GP0 to PWMA
  • GP1 to DIR A
  • GP2 to PWM B
  • GP3 to DIR B
  • GND to GND

The basic demonstration below creates a stepper motor object, rotates it 50 steps forward (at the default speed of 10 RPM), 180 degrees backward, then returns to the starting "home" position:

from Makerverse_Motor_2ch import bipolarStepper

stepper = bipolarStepper(pwmPinA = 0, dirPinA = 1, pwmPinB = 2, dirPinB = 3, RPM = 10, stepsPerRotation = 200)

stepper.rotate(50)
stepper.rotate(angle=-180)
stepper.returnHome()

 

makerverse-2ch-motor-driver-bipolar-stepper-wiring-connections

If you are looking to drive a stepper motor from Arduino, you can check out our gide on Controlling Stepper Motors with the Arduino. The Makerverse 2 Channel Motor Driver is compatible with the Arduino Stepper library by configuring it for "IN1/IN2" mode. See PWM vs IN1/IN2 Mode for more information.

Driving Small DC Motors - Low Level Logic Control

By default, the input logic for each output channel is as follows:

PWM x DIR x Mode
0 0 Stop
0 1 Stop
1 0 Reverse
1 1 Forward

In other words: you can set a direction with the DIR pin then control the speed with the PWM pin. Note that the definitions of "forward" and "reverse" might be backwards as it depends on how the motor is physically wired and mounted. One simple way to change the motor direction is to swap the + and - wires.

The following Raspberry Pi Pico example shows how to set a direction and PWM duty cycle. It configures a PWM output at 1kHz, 50% duty cycle, moves forward for 1 second, then backwards for 1 second, before turning the motor off. It uses pin 1 for the DIR signal and pin 0 for PWM.

Note that the pwmB.duty_u16() function accepts a duty cycle between 0 (always off) and 65535 (always on)

from machine import PWM, Pin
import time

dirA = Pin(1, Pin.OUT) # Direction signal on GP1

pwmA = PWM(Pin(0))
pwmA.freq(1000) # 1kHz PWM frequency
pwmA.duty_u16(32768) # 50% duty cycle

dirA.on()
time.sleep_ms(1000)
dirA.off()
time.sleep_ms(1000)

pwmA.duty_u16(0) # Turn motor off

Driving two motors follows the same pattern, except typically unique PWM and DIR pins are used so that each motor can be driven independently.

Current Limiting

In most applications the motor and power supply can be chosen so that the motor's rated voltage is closely matched with the chosen power supply.

The current limiting feature is provided as an extra layer of protection for both the motor and power supply. The motor driver will automatically pulse width modulate the output if the current exceeds the set point. Without the current limit potentiometer installed a stalled DC motor can be supplied with up to about 3A before the driver chip's internal protection disables the outputs. The current limiting can also be used to, say, drive a 6V stepper motor from a 12V supply.

To use current limiting a 10k potentiometer can be soldered on the provided pads. The 7 holes allow for mounting of a wide variety of potentiometers from cheap trimpots to 20-turn precision units.

The provided test point allows a voltmeter to be used to measure the current limit. With the negative test lead connected to ground (eg: the screw head on the nearby GND terminal) and the positive lead on the test point labeled "1.1 A/V >" the trimpot can be adjusted for the desired value. The motor does not need to be connected when taking this measurement so you can minimise the risk of damaging it.

Note that the current limiting is not a high precision feature. The output current will depend somewhat on the motor's inductance, supply voltage, etc.

The image below shows the suggested method for measuring the current limit set point.

makerverse-2ch-motor-driver-current-limit-set

makerverse-2ch-motor-driver-current-limit-measurement

PWM vs IN1/IN2 Mode

Out of the box the Makerverse 2 Channel Motor Driver is configured for "PWM" (or "Phase") mode. Some motor driver software libraries (eg: the Arduino Stepper library) require motor drivers to accept "IN1/IN2" (or simply "IN") mode where the input pins essentially directly drive the internal H-bridge of the motor driver.

To configure the Makerverse 2 Channel Motor Driver for "IN1/IN2" mode simply connect the solder bridge on the rear of the PCB.

With this done, the input pin's logic changes as follows:

PWM x (IN1) DIR x (IN2) Mode
0 0 Stop
0 1 Reverse
1 0 Forward
1 1 Brake (motor terminals shorted out)

In "stop" mode the motor's current can flow through the internal H-bridge's EMF protection diodes, providing moderate braking power which diminishes as the motor slows down. In "brake" mode the low two H-bridge MOSFETs are explicitly turned on, providing a stronger braking force all the way to 0 RPM. 

makerverse-2ch-motor-driver-in-mode-solder-bridge

If you wish to use the Arduino Stepper library with this module the following code can be used as a starting point:

#include <Stepper.h>

const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution for your motor

// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);

int stepCount = 0;         // number of steps the motor has taken

void setup() {
  // initialize the serial port:
  Serial.begin(9600);
}

void loop() {
  // step one step:
  myStepper.step(1);
  Serial.print("steps:");
  Serial.println(stepCount);
  stepCount++;
  delay(100);
}

It is written to work with the following pin assignment:

Arduino Pin Motor Driver Pin
8 DIR B
9 DIR A
10 PWM B
11 PWM A

Protection Modes

The TC78H660 chip used on the Makerverse 2 Channel Motor Driver asserts an auto-shutdown protection mode under three circumstances:

  • The internal chip temperature exceeds 120°C (approx 100°C on the PCB)
  • The output current exceeds 3A (lower when VM is under 5V; approx 1.5A at 3V)
  • The VM pin voltage drops below 2.1V

When an auto-shutdown event occurs the output motor drive transistors are turned off.

In order to reset the motor driver a power-cycle is required. The supply voltage must drop to 0V and, after a couple of seconds, be reconnected.

If an auto-shutdown event occurs it is typically due to an operating problem which requires fixing. Is the motor too big? Is there an accidental short circuit? etc.

The auto-shutdown feature is a "last ditch" effort to avoid damage to the motor driver chip, it should not be relied upon to protect the device. We have, for example, been able to intentionally destroy one device by repeatedly over-heating the module with a constant 2A load!

Drive Capabilities In Detail

Typically the output drive current will be limited by the heat dissipation of the module. When testing sustained current output the driver chip would measure at about 100°C when delivering close to 2A, with the thermal protection kicking in very easily.

As such, we recommend the following maximum operating conditions:

At or above 5V:

Maximum sustained output current (sum of both channels): 1.6A

Maximum peak output current (<1 second burst, sum of both channels): 2A

At 3V:

Maximum sustained output current (sum of both channels): 1.5A

Maximum peak output current (<1 second burst, sum of both channels): 1.5A

Below 5V the motor driver chip's output current limit is triggered at lower currents. There is also more heat dissipation as the internal H-bridge MOSFETs have a higher on resistance with lower gate drive voltages.

The input PWM frequency of the motor driver is rated from DC to 400kHz however 500Hz to 1kHz is recommended for small DC motors.

Resources:

Have a question? Ask the Author of this guide today!

Please enter minimum 20 characters

Your comment will be posted (automatically) on our Support Forum which is publicly accessible. Don't enter private information, such as your phone number.

Expect a quick reply during business hours, many of us check-in over the weekend as well.

Comments


Loading...
Feedback

Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.