Motor Control Shield v3.0 - The missing manual

Motivation

When I bought such a motor control shield recently, it came as a kit without any instructions. I could find the circuit diagram and list of parts on the Internet after some searching, but almost nothing on assembly and how to control it. Therefore I decided to create this page to share with the community what I learned so far.

Official Documentation

http://blushingboy.net/p/motorShieldV3/

Connections

Connection strip J3 (upper left, to Arduino; from left to right)

  • 8 NC Not Connected
  • 7 GND ↔ Arduino-GND
  • 6 DIRB ↔ Arduino-13 Controls motor direction resp. activity for MOTORS 1 and 2 (LOW 1, HIGH 2)
  • 5 DIRA ↔ Arduino-12 Controls motor direction resp. activity for MOTORS 3 und 4 (LOW 3, HIGH 4)
  • 4 PWMB ↔ Arduino-11 Controls activity motor 3-4
  • 3 PWMA ↔ Arduino-10 Connects activity motor 1-2
  • 2 E2 ↔ Arduino-9 (Stepper mode: Connected to IC3 1A)
  • 1 E1 ↔ Arduino-8 (Stepper mode: Connected to IC3 4A)

Connection strip ENCODER (upper right, to Arduino)

  • 1 BB1 ↔ Arduino 7, Button 1
  • 2 BB2 ↔ Arduino 6, Button 2
  • 3 EC1 ↔ Arduino 5, Encoder 1, EC1
  • 4 EC2 ↔ Arduino 4, Encoder 2, EC2
  • 5 ↔ Arduino 3; Socket "E3" enables access to the I/O, including Interrupt 1
  • 6 ↔ Arduino 2; Interrupt line 0 for EC1, EC2, S1, S2

Connection strip STEPPER

The "official" documentation states that jumpers or bridges have to be installed here (vertically!) to control a stepper motor. This will connect E1 and E2 (Arduino 8 and 9) to IC3' inputs 1A and 4A and, via IC2, inverted to 2A and 3A.

However, normally that seems to be superfluous because DIRA and DIRB (Arduino 12 and 13) can be used instead, see instructions on stepper motor below.

Connection strip MOTORS

The output pins, numbered from top to bottom (positioned 180°, compared to the circuit diagram, it seems!), are connected to the following outputs of the driver chip:

  • 1. IC3 2Y
  • 2. IC3 1Y
  • 3. IC3 3A
  • 4. IC3 4Y

Workings of the Motor Control Shield

Motor/Device Control

The shield contains two pairs of outputs (MOTORS 1-2 and 3-4) to drive motors or other consumers. Only one of the two outputs forming a pair can be used at a time. This gives us the following options:

Control up to two consumers, e.g. DC motors, bidirectionally

Simply connect the motors to pins MOTORS 1 and 2 resp MOTORS 3 and 4.

I also managed to control a linear drive from a very old CD-ROM drive and a head drive from a hard disk drive. They are connected the same way as motors.

Take care not to overload the drivers in IC3. If the resistance of the motor coil is too low (= current will be too high) or the voltage resistance of the motor is too low (=motor will get too much voltage and take up too much power), you can connect an appropriate load resistor in series with the motor or device. This will work for experimenting, however on the long run I'd prefer using a more appropriate different driver circuit instead of wasting some of the possible power.

Controlling up to four consumers unidirectionally

Up to four DC motors or other consumers can be connected to one of the MOTORS pins with one connection and to GND with the other one. Please note that the consumers connected to MOTORS 1 and 2 resp. MOTORS 3 and 4 can be switched on only alternatively.

Of course nothing speaks against using one of the MOTORS output pairs for a bidirectional motor and the other one for unidirectional consumers.

Controlling a stepper motor.

I tried to get a bipolar stepper motor (head drive from an old 3,5" floppy drive) working with the "official" Arduino Stepper library and the example "stepper_oneRevolution", but the motor was hardly turning, mostly only vibrating and getting quite hot. After comparing the "official" circuit diagram in the Stepper lib's docs with the Motor Control Shield's one, I understood the reason: The "official" diagram sets IC3's ENABLE lines to HIGH and controls the four IC3 outputs independently. The Motor Control Shield works differently: The control lines for IC3's 4 outputs are connected in pairs using the gates from IC2 so that always exactly one of the outputs in a pair is active, controlled by DIRA and DIRB. Then the ENABLE lines connected to PWMA/PWMB decide if outputs are to be enabled or not.

The standard stepper library can be used the following way (not recommended for more than tryout, motor is under constant power and will get hot):

  1. /*
  2.  Stepper Motor Control with Arduino Motor Control Shield V3.0.
  3.  
  4.  This program drives a bipolar stepper motor. The motor is controlled
  5.  by Arduino pins 10, 11, 12, 13.
  6.  
  7.  The motor should do five revolutions into one and five into another direction.
  8.  
  9.  Using this sketch for longer is not recommended because it will keep the motor under current
  10.  and can cause it to become quite hot.
  11.  
  12.  */
  13.  
  14. #include <Stepper.h>
  15.  
  16. int enA  = 10;  // Enable pin 1 on Motor Control Shield  
  17. int enB  = 11;  // Enable pin 2 on Motor Control Shield  
  18. int dirA = 12;  // Direction pin dirA on Motor Control Shield
  19. int dirB = 13;  // Direction pin dirB on Motor Control Shield
  20.  
  21.  
  22. const int stepsPerRevolution = 20;  // Change this to fit the number of steps per revolution
  23.                                      // for your motor
  24.  
  25. // Initialize the stepper library on pins 12 and 13:
  26. Stepper myStepper(stepsPerRevolution, dirA, dirB);            
  27.  
  28.  
  29. void setup() {
  30.   // set the speed at 60 rpm:
  31.   myStepper.setSpeed(60);
  32.  
  33.   // Enable power to the motor
  34.   pinMode(enA, OUTPUT);
  35.   digitalWrite (enA, HIGH);
  36.  
  37.   pinMode(enB, OUTPUT);
  38.   digitalWrite (enB, HIGH);  
  39. }
  40.  
  41. void loop() {
  42.   // Step five revolutions into one direction:
  43.   myStepper.step(stepsPerRevolution*5);
  44.   delay(2000);
  45.  
  46.   // Step five revolutions in the other direction:
  47.   myStepper.step(-stepsPerRevolution*5);
  48.   delay(2000);
  49. }
  50.  

Using the Arduino stepper library in 4-pin mode can be achieved the following way:

  • Install jumpers or wire bridges (vertically) on the connection strip STEPPERS, connecting E22-E2 and E12-E1 . This connects IC3's inputs 1A and 4A with the pins E1/E2 (Arduino pins 8 and 9).
  • Remove IC2
  • Bridge IC2 pins 4 and 12, connecting DIRA/Arduino 12 with IC3 2A
  • Bridge IC2 pins 6 and 9, connecting DIRB/Arduino 13 with IC3 3A
  • Set PWMA and PWMB to HIGH

Sample Code:

  1. /*
  2.  Stepper Motor Control with Arduino Motor Control Shield V3.0.
  3.  
  4.  This requires the following modification to the shield:
  5. - Remove IC2
  6. - Bridge IC2 pins 4 and 12, connecting DIRA/Arduino 12 with IC3 2A
  7. - Bridge IC2 pins 6 and 9, connecting DIRB/Arduino 13 with IC3 3A
  8.  
  9.  This program drives a bipolar stepper motor. The motor is controlled
  10.  by Arduino pins 8, 9, 12, 13. Additionally Pins 10 and 11 are required.
  11.  
  12.  The motor should do five revolutions into one and five into another direction.
  13.  
  14.  */
  15.  
  16. #include <Stepper.h>
  17.  
  18. int out1 = 8;
  19. int out2 = 9;
  20. int enA  = 10;  // Enable pin 1 on Motor Control Shield  
  21. int enB  = 11;  // Enable pin 2 on Motor Control Shield  
  22. int dirA = 12;  // Direction pin dirA on Motor Control Shield
  23. int dirB = 13;  // Direction pin dirB on Motor Control Shield
  24.  
  25.  
  26. const int stepsPerRevolution = 20;  // change this to fit the number of steps per revolution
  27.                                      // for your motor
  28.  
  29. // Initialize the stepper library on pins 8, 9, 12, 13:
  30. Stepper myStepper(stepsPerRevolution, out1, dirA, out2, dirB);            
  31.  
  32. void setup() {
  33.   // Set speed to 60 rpm:
  34.   myStepper.setSpeed(60);
  35.  
  36.   // Enable IC3 outputs.
  37.   pinMode(enA, OUTPUT);
  38.   digitalWrite (enA, HIGH);
  39.   pinMode(enB, OUTPUT);
  40.   digitalWrite (enB, HIGH);
  41. }
  42.  
  43. void loop() {
  44.   // Step five revolutions into one direction:
  45.   myStepper.step(stepsPerRevolution*5);
  46.   delay(2000);
  47.  
  48.   // Step five revolutions in the other direction:
  49.   myStepper.step(-stepsPerRevolution*5);
  50.   delay(2000);
  51. }

A unipolar stepper motor with 6 wires can be driven the same way (use an Ohmmeter to find the ends of the coils, connect one coil to MOTORS 1-2 and the other one to MOTORS 3-4, but don't connect the center wires). A unipolar stepper motor with 5 wires cannot be driven using this board.

Encoder and Button Inputs, LEDs

The encoder inputs and buttons can be used by polling (the sketch queries the status of the corresponding input lines regularly) or in interrupt mode (a special interrupt routine is called when something happens on the interrupt line 0). Interrupt mode has some oddities, see below.

Encoder Inputs

Buttons

LEDs

The LEDs next to the buttons can also be used as outputs. Sample sketch:

  1. /* Sample sketch to use the LEDs on Motor Shield v3.0 as outputs. */
  2.  
  3. int btnS1 = 7;  // Pin for button S1
  4. int btnS2 = 6;  // Pin for button S2
  5.  
  6. void setup()
  7. {
  8.   pinMode(btnS1, OUTPUT);
  9.   pinMode(btnS2, OUTPUT);
  10. }
  11.  
  12. void loop()
  13. {
  14.   digitalWrite (btnS1, LOW);
  15.   digitalWrite (btnS2, HIGH);
  16.   delay(500);
  17.   digitalWrite (btnS1, HIGH);
  18.   digitalWrite (btnS2, LOW);
  19.   delay(500);
  20. }

It might be possible to use the LEDs as output and the buttons as input "at the same time" when switching the mode of the pin between output and input mode quickly.

Inputs with interrupt

The purpose of IC1 is to be able to use the same interrupt-enabled pin for max. four devices, two encoder inputs and two button inputs. Then the interrupt service routine has to query the digital input pins for each of the devices to determine which device or which devices caused the interrupt.

The encoder inputs work with positive logic, they generate HIGH on "interruptable" pin 2 when a HIGH signal is present on EC1 or EC2.

The button inputs work the other way round, they generate HIGH on pin 2 when they are NOT both pressed. While this makes them usable as security or "dead man" switches, they cannot be used as control buttons and also block the interrupt pin for the encoders while not both pressed, unless modified.

Assembly instructions

General assembly instructions and hints

First get the schematic and other documentation from http://blushingboy.net/p/motorShieldV3/.

For assembly, you should download the package and locate the following files:

  • Circuit diagram: Motor_control_v3.0_sch.pdf
  • Board layout: Motor_control_v3.0_brd.pdf
  • List of parts: Motor_control_v3.0.lst.txt

Then follow "standard" methods for assembling an electronics board according to the schematic and parts list.

Adafruit offer a similar board and have good instructions for that, including links to pages explaining how to solder and other basics: http://www.ladyada.net/make/mshield/make.html .

The polarity of the LEDs is not stated clearly on the board print. The "flatter" side of the symbol is -. If the LED is not marked, the shorter leg is -. Note that the LEDs next to each buttons have opposite polarity!

On my Arduino UNO, there was the danger of C6 touching the USB socket on the Arduino. Therefore I used longer pins for the connection to the Arduino. Or take care that the connection wires are as flat as possible and add sufficient electrical tape, etc. below.

There is a mechanical problem with pins from "STEPPER" touching IC1. Therefore it might make sense to place bridges instead of sockets if only use with stepper motors is intended.

Build options

Depending on your requirements, some changes can be made to the kit.

Add IC sockets

I recommend using sockets for the ICs, especially for IC3, the driver. IC1 and IC2 require 14-pin sockets, IC3 a 16-pin one.

Power LED not required

If you need no power LED, do not put in R7 and PWR.

Encoders and buttons

If the encoder inputs and buttons are not required, IC1, R1, R2, S1, S2, R10 and R11 are not required and the corresponding Arduino inputs on the connection strip ENCODERS stay available for different purposes.

If only the buttons are not mounted, two more inputs are available for switches/encoders.

External power supply

The board has two different power lines, "5V" for TTL logic and "Vin" to provide power to the outputs for the motor(s). "5V is powered by the Arduino's power supply, "Vin" is connected to the Arduino's "raw" power supply.

Please note that while the Arduino is powered by USB, only very small motors or other consumers with low current requirements can be driven, otherwise the USB port might be overloaded. Otherwise an external power supply appropriate for the Arduino must be used.

The driver chip supports voltages from 4,5-36V and up to 1A. To drive the motors with a voltage different from the Arduino's "Vin", do not put in the corresponding connection pins that plug into the Arduino board, but attach the external power supply there. This will connect the GND of "Vin" and "5V".

In my kit, the capacitors C4 and C5 had a voltage rating of 20V and need to be exchanged to use higher input voltages.

Alternatives

  • See InterfacingWithHardware for other interfaces that can drive motors, etc. In my view, there seem to exist better interfaces than this one. I wouldn't buy it again, unless in need of exactly some of the properties, e.g. interrupt-driven encoder inputs.
  • For applications where relatively slow, limited movements are sufficient, I'd use RC Servos and the Servo Library instead of DC motors. Servos are cheap (starting from less than 10 €) and require only one output pin each plus power supply.
  • There exist controllers for brushless motors that are intended for radio remote controls and are controlled the same, simple way as servos.

Share