Using the TinyShield Motor x4 Board Tutorial

by TinyCircuits Staff February 19, 2016

Using the TinyShield Motor x4 Board Tutorial

Overview

The TinyShield Motor x4 Board lets a 4 DC brushed motors be driven from your project. You can also use this to drive other loads, like a stepper motor, solenoids or relays.

Warning: Be sure that your power supply is sufficient to operate these motors as well as your logic – batteries are the best. If you are running both the motors and the logic off of one power supply, we recommend avoid using a switching power supply as the transients caused can potentially damage items connected to the logic side.


External Connections

Pin Label Function Description
VM Motor Voltage Input This supplies the voltage to the motor and can range from 1.8 to 11 Volts.

 

High Current Connection

GND Ground Connection This is the Ground return for the motors. It is also connected to the ground for the TinyDuino logic.

 

High Current Connection

Motor1 Motor 1 Connection These are the Motor 1 output driver connections, connect these two pins to the two sides of the motor winding. The pin with the square pad is the O1 output and the other is the O2 output.

 

High Current Connection

Motor2 Motor 2 Connection These are the Motor 2 output driver connections, connect these two pins to the two sides of the motor winding. The pin with the square pad is the O1 output and the other is the O2 output.

 

High Current Connection

Motor3 Motor 3 Connection These are the Motor 3 output driver connections, connect these two pins to the two sides of the motor winding. The pin with the square pad is the O1 output and the other is the O2 output.

 

High Current Connection

Motor4 Motor 4 Connection These are the Motor 4 output driver connections, connect these two pins to the two sides of the motor winding. The pin with the square pad is the O1 output and the other is the O2 output.

 

High Current Connection


TinyShield Signals

TinyShield Signal Function Description
A3 Sleep Input This signal can put the motor controller into a low-power “Sleep Mode”.

 

A logic-low “0″ will put the motor controller into sleep mode, a logic-high “1″ will put the motor controller into normal operating mode. If sleep mode is not needed, set A3 to HIGH to allow normal operation.

2 Motor1 Dir This signal controls the Motor 1 Output 2 driver. A logic-low “0″ will set Output 2 to low, a logic-high “1″ will set Output 2 to high.

 

For motor speed control, we recommend using this as the direction speed control signal, and 3 as the motor speed control signal.

3 Motor1 PWM This signal controls the Motor 1 Output 1 driver. A logic-low “0″ will set Output 1 to low, a logic-high “1″ will set Output 1 to high.

 

For motor speed control, we recommend using this as the motor speed control signal (Using a PWM signal), and 2 as the motor direction signal.

4 Motor2 Dir This signal controls the Motor 2 Output 2 driver. A logic-low “0″ will set Output 2 to low, a logic-high “1″ will set Output 2 to high.

 

For motor speed control, we recommend using this as the direction speed control signal, and 5 as the motor speed control signal.

5 Motor2 PWM This signal controls the Motor 2 Output 1 driver. A logic-low “0″ will set Output 1 to low, a logic-high “1″ will set Output 1 to high.

 

For motor speed control, we recommend using this as the motor speed control signal (Using a PWM signal), and 4 as the motor direction signal.

7 Motor3 Dir This signal controls the Motor 3 Output 2 driver. A logic-low “0″ will set Output 2 to low, a logic-high “1″ will set Output 2 to high.

 

For motor speed control, we recommend using this as the direction speed control signal, and 6 as the motor speed control signal.

6 Motor3 PWM This signal controls the Motor 3 Output 1 driver. A logic-low “0″ will set Output 1 to low, a logic-high “1″ will set Output 1 to high.

 

For motor speed control, we recommend using this as the motor speed control signal (Using a PWM signal), and 7 as the motor direction signal.

8 Motor4 Dir This signal controls the Motor 4 Output 2 driver. A logic-low “0″ will set Output 2 to low, a logic-high “1″ will set Output 2 to high.

 

For motor speed control, we recommend using this as the direction speed control signal, and 9 as the motor speed control signal.

9 Motor4 PWM This signal controls the Motor 4 Output 1 driver. A logic-low “0″ will set Output 1 to low, a logic-high “1″ will set Output 1 to high.

 

For motor speed control, we recommend using this as the motor speed control signal (Using a PWM signal), and 8 as the motor direction signal.

 


Example 1: Motor Control with Speed and Direction Control

In this example, we use the TinyDuino processor board to control the motor direction and speed for a single motor (Motor 1).

For our battery to power the motor, we’ll be using three AAA alkaline batteries (which will give us an operating voltage range of 3 – 4.5 Volts). The batteries will supply the voltage to both the motor power supply (VM) and the logic power supply (VCC).

In this set up, the TinyDuino processor will be able to control the motor speed on digital pin #3 by using the Arduino analogWrite() command. This will send a PWM signal to the IN1 signal on the motor controller for the speed control. Direction is controlled by digital pin #2 on the Arduino and is connected to IN2 on the motor controller.

Build the Circuit:

Step 1:  Connect up the TinyDuino, USB TinyShield and Motor TinyShield

Step 2:  Connect up the TinyDuino and USB TinyShield

Step 3:  Add a wire between the GND pin on the Motor x4 TinyShield and the negative terminal on the battery holder.

Step 4:  Add a wire between the VM pin on the Motor x4 TinyShield and the positive terminal on the battery holder.

Step 5:  Add a wire between the positive connection on the battery holder and the ‘+’ hole on the TinyDuino processor Board. This will connect the VM and VCC power supplies together.

Step 6:  Add two wires from the MOTOR1 terminals to two sides of the motor.

Step 7:  Upload the sketch into the TinyDuino.

Step 8:  Unplug the USB cable

Step 9:  Put the batteries into the holder.

Run the Circuit:

This example shown below will cause the motor to ramp up speed, then ramp down speed, and change direction.

NOTE: When in the forward direction, the slowest speed is set with an analogWrite value of 0 and a max speed with a value of 255, when in the reverse direction, the slowest speed is set with an analogWrite value of 255 and the max speed with a value of 0.  

 

 

int motorDirPin = 2;      // Motor direction connected to digital pin 2
int motorSpeedPin = 3;    // Motor speed connected to digital pin 3
int motorSleepPin = A3;      // Motor sleep to analog pin 3

void setup()
{
  pinMode(motorDirPin, OUTPUT);       // sets the pin as output
  pinMode(motorSpeedPin, OUTPUT);     // sets the pin as output
  pinMode(motorSleepPin , OUTPUT);     // sets the pin as output

  digitalWrite(motorDirPin, LOW);     // sets the default dir to be forward
  digitalWrite(motorSpeedPin, LOW);   // sets the default speed to be off
  digitalWrite(motorSleepPin , HIGH);   // sets the sleep mode to be off
}

void loop()
{
  // Set the motor direction to forward
  digitalWrite(motorDirPin, LOW);     

  // Ramp the motor speed up
  analogWrite(motorSpeedPin, 0);    // Min speed forward (motor off)
  delay(50);  
  analogWrite(motorSpeedPin, 63);   
  delay(50);  
  analogWrite(motorSpeedPin, 127);   
  delay(50); 
  analogWrite(motorSpeedPin, 191);   
  delay(50); 
  analogWrite(motorSpeedPin, 255);   // Max speed forward
  delay(50); 

  // Ramp the motor speed down
  analogWrite(motorSpeedPin, 191);   
  delay(50);  
  analogWrite(motorSpeedPin, 127);   
  delay(50);  
  analogWrite(motorSpeedPin, 63);   
  delay(50); 
  analogWrite(motorSpeedPin, 0);     // Min speed forward (motor off)
  delay(50); 


  // Set the motor direction to reverse
  digitalWrite(motorDirPin, HIGH);   

  // Ramp the motor speed up
  analogWrite(motorSpeedPin, 255);    // Min speed reverse (motor off)
  delay(50); 
  analogWrite(motorSpeedPin, 191);   
  delay(50);  
  analogWrite(motorSpeedPin, 127);   
  delay(50);  
  analogWrite(motorSpeedPin, 63);   
  delay(50); 
  analogWrite(motorSpeedPin, 0);      // Max speed reverse
  delay(50); 

  // Ramp the motor speed down
  analogWrite(motorSpeedPin, 63);   
  delay(50);  
  analogWrite(motorSpeedPin, 127);   
  delay(50); 
  analogWrite(motorSpeedPin, 191);   
  delay(50); 
  analogWrite(motorSpeedPin, 255);    // Min speed reverse (motor off)
  delay(50); 
}


TinyCircuits Staff
TinyCircuits Staff

Author



Also in Learn

Tiny Arcade Assembly Instructions
Tiny Arcade Assembly Instructions

by TinyCircuits Staff September 18, 2016

Learn how to assemble your Tiny Arcade. You can read the step by step guide, or there's a video tutorial...

View full article →

Tiny Arcade Menu Update
Tiny Arcade Menu Update

by TinyCircuits Staff May 18, 2016

Update your Tiny Arcade software to the latest version from your computer.

View full article →

TinyScreen+ Windows 7/8 Driver Installation
TinyScreen+ Windows 7/8 Driver Installation

by TinyCircuits Staff May 18, 2016

Install the required drivers to use TinyScreen+ with Windows 7 and Windows 8.

View full article →