Tutorial: How to use the Monster Moto Shield

Hi Guys,

In this tutorial we will show you how to use the Monster Motor Shield to control a DC Motor 12V that is connected to a wheel where we will control the direction and speed of rotation.

List of Materials:

1x Arduino Uno

1x Monster Motor Shield

1x Resistor 110R

1x LED

1x DC Motor  12V

1x DC Font 12V

1x Wheel Off Road

Some Jumpers

1. Operation

1.1) PWM

PWM means Pulse Width Modulation. 

With this technique it is possible to control the speed of the motors, keeping the torque even at low speeds. This guarantees soft starts even when it has a larger charge upon the motors. Those are the aspects that point PWM as ideal to control robotic applications.

The speed control of our motor will be controlled by a PWM that can be defined with a value between 0 and 255, where 0 indicates that the motor is stopped and 255 indicates that the motor is in full speed.

1.2) Hardware Monster Motor Shield

 

PinA2 - Analog Pino 2: Current sensor for Motor 0 via Hardware >> //cspin[0]

PinA3 - Analog Pino 3: Current sensor for para Motor 1 via Hardware >> //cspin[1]

OBS: For value definitions of limit current  (CS_THRESHOLD) in your project, check the manufacture's Datasheet

PinD7 (D7) - Digital Pin 7: Pin to control the clockwise direction of Motor 0 (A1) >>        // inApin[0]

PinD8 (D8)Digital Pin 8: Pin to control the counterclockwise direction of Motor 0 (B1) >> // inBpin[0]

 

PinD4 (D4)Digital Pin 4: Pin to control the clockwise direction of Motor 1 (A2) >>        // inApin[1]

PinD9 (D9)Digital Pin 9: Pin to control the counterclockwise direction of Motor 1 (B2) >> // inBpin[1]

  

PinD5 (D5) - Digital Pin 5: Pin for PWM Motor 0     // pwmpin[0]

PinD6 (D6) - Digital Pin 6: Pin for PWM Motor 1     // pwmpin[1]

- Tables of Truth:

 

1.3) Monster Shield Example

The Serial Monitor will be used to follow the speedup in PWM of the motor and the lock if it happens 

The LED and the resistance between the pins 13 and GND are used in the example to indicate that the motor is locked.

The definition  "#define CS_THRESHOLD on the fifth line of the program works as a protection for the circuit, where you define a maximum current value before the program shut the motor down. Because, if by any means, the motor locks, the current will raise and this definition prevents the damage of any components.

OBS: The value set in this command is not given in A (Ampere), the value is a sampling that the circuit do via hardware, as shown below:

 

OBS: To define the current used in this command, check the  Datasheet

The function of our control is "motorGo(motor, direction, pwm);" where:

Motor: Is the output of the motor that we will use: "0" (A1:B1) and/or "1" (A2:B2)

Direction: "CW" to clockwise direction of rotation and "CCW"  to counterclockwise direction of rotation

PWM: Value between "0" and "255" to control the speed of the motor

Example: "motorGo(0, CW, 255);"

At example, motor 1 will spin in a clockwise direction at full speed.

 

2. Assembly


Scheme of Assembly:

2.1) Connect your Monster Motor Shield to the Arduino

2.2) Connect the LED with the resistance between the pin 13 and GND that will be use in example to indicate that the motor is locked.

2.3) Connect the motor on the pins A1:B1 of the Shield

2.4) Connect the 12V font on the pins + and - of the Monster Moto Shield

2.5) Assembled circuit

3. O Sketch

#define BRAKEVCC 0
#define CW 1
#define CCW 2
#define BRAKEGND 3
#define CS_THRESHOLD 15   // Definition of safety current (Check: "1.3 Monster Shield Example").

 

int inApin[2] = {7, 4}; // INA: Clockwise Direction Motor0 and Motor1 (Check:"1.2 Hardware Monster Motor Shield").
int inBpin[2] = {8, 9}; // INB: Counterlockwise Direction Motor0 and Motor1 (Check: "1.2 Hardware Monster Motor Shield").
int pwmpin[2] = {5, 6};            // PWM's input
int cspin[2] = {2, 3};              // Current's sensor input

int statpin = 13;
int i=0;;
void setup()                         
{
Serial.begin(9600);              // Initiates the serial to do the monitoring 
pinMode(statpin, OUTPUT);
for (int i=0; i<2; i++)
    {
    pinMode(inApin[i], OUTPUT);
    pinMode(inBpin[i], OUTPUT);
    pinMode(pwmpin[i], OUTPUT);
    }
for (int i=0; i<2; i++)
    {
    digitalWrite(inApin[i], LOW);
    digitalWrite(inBpin[i], LOW);
    }
}

void loop()                          
{

// Routine to increase the speedo of the motor

while(i<255)
    {
    motorGo(0, CW, i);   // Increase the speed of the motor, according to the value of i is increasing       
    delay(50);                         
    i++;                             
    if (analogRead(cspin[0]) > CS_THRESHOLD) // If the motor locks, it will shutdown and...  

{                                                                     // ...Resets the process of increasing the PWM
    motorOff(0);  

}
    Serial.println(i);
    digitalWrite(statpin, LOW);
    }
i=1;

//=========

//Keep the acceleration while the motor not locks

while(i!=0)
    {                                      
    motorGo(0, CW, 255);       // Keep the PWM in 255 (Max Speed) 
    if (analogRead(cspin[0]) > CS_THRESHOLD)     // If the motor locks, it will shutdown and....         

        {                                                                      // ...Resets the process of increasing the PWM
         motorOff(0); 

        }
    }

//========


}
void motorOff(int motor)     //Function to shut the motor down case it locks
{

for (int i=0; i<2; i++)
    {
    digitalWrite(inApin[i], LOW);
    digitalWrite(inBpin[i], LOW);
    }
analogWrite(pwmpin[motor], 0);
i=0;
digitalWrite(13, HIGH);
Serial.println("Motor Locked");
delay(1000);
}
void motorGo(uint8_t motor, uint8_t direct, uint8_t pwm)         //Function that controls the variables: motor(0 ou 1), direction (cw ou ccw) e pwm (entra 0 e 255);
{
if (motor <= 1)
    {
    if (direct <=4)
        {
        if (direct <=1)
            digitalWrite(inApin[motor], HIGH);
        else
            digitalWrite(inApin[motor], LOW);

        if ((direct==0)||(direct==2))
            digitalWrite(inBpin[motor], HIGH);
        else
            digitalWrite(inBpin[motor], LOW);

        analogWrite(pwmpin[motor], pwm);
        }
    }
}

So guys... this is it!

See you next tutorial! ;)

References:

http://en.wikiversity.org/wiki/Arduino/MonsterMotorShield

http://en.wikiversity.org/wiki/Arduino/MonsterMotorShield/UnoCode

http://garagelabstore.com/store/shields/monster-moto-shield.html

Views: 16847

Comment by Sergey on March 19, 2015 at 10:01am

Good day. Can you help me? I took this sketch, but it doesn't working( 

Comment by Alaa Alrashdan on October 4, 2016 at 12:21pm

Hi

I have a firgelli actuator that i run using arduino+monster moto shield. I can run it with a specific speed that i can determine. But what i need is to run it many times every time with a higher speed and control it by one arduino code, since this code is to be synchronized with other hardware.

Comment

You need to be a member of GarageLab (arduino, electronics, robotics, hacking) to add comments!

Join GarageLab (arduino, electronics, robotics, hacking)

Latest Activity

iftekhar Mobin is now a member of GarageLab (arduino, electronics, robotics, hacking)
10 hours ago
Profile IconLeicester Hibbert and Michael Young joined GarageLab (arduino, electronics, robotics, hacking)
Jan 9
Profile IconThorsten Schwarz and Dana Custer joined GarageLab (arduino, electronics, robotics, hacking)
Jan 2
Aqeel munir updated their profile
Dec 31, 2016
Todd Enger updated their profile
Dec 29, 2016
FRANK KWABENA is now a member of GarageLab (arduino, electronics, robotics, hacking)
Dec 28, 2016
Ayhan Chaplan commented on GarageLab's blog post How to use a Peltier with Arduino
"Hi! Will this setup work with a 3,8V / 2,5A Peltier element? Or do I have to reduce the resistance…"
Dec 26, 2016
Profile IconAyhan Chaplan, Erva and Donna Carter joined GarageLab (arduino, electronics, robotics, hacking)
Dec 26, 2016
Galy Huang posted a discussion

Ubuntu on Firefly-RK3399

Firefly-RK3399 with dual-core Cortex-A72 and quad-core Cortex-A53, ARM® Mali-T860 MP4 quad-core…See More
Dec 20, 2016
Chase Rangel posted a discussion

What is the simplest way to control one brushless motor forward/reverse?

  Hello everyone I don't know much about this type of stuff had only a handful of RC cars.I've been…See More
Dec 12, 2016
Profile IconErving Howe, Chase Rangel, Werner Pretorius and 1 more joined GarageLab (arduino, electronics, robotics, hacking)
Dec 12, 2016
Frank Turner is now a member of GarageLab (arduino, electronics, robotics, hacking)
Dec 9, 2016
Marcelo Rodrigues and swapnil are now friends
Dec 6, 2016
Marcelo Rodrigues replied to swapnil's discussion Tiny 85 based Thermometer
"Dear Swapnil, Since you don't have any experience with programming you should consider start…"
Dec 5, 2016
swapnil posted a discussion

Tiny 85 based Thermometer

Hi, can any one guide me how to make the tiny 85 based Thermometer which will glow the LED…See More
Dec 4, 2016
Spyros Svoronos is now a member of GarageLab (arduino, electronics, robotics, hacking)
Dec 4, 2016
K Biju is now a member of GarageLab (arduino, electronics, robotics, hacking)
Nov 29, 2016
Profile Iconswapnil and Yasser joined GarageLab (arduino, electronics, robotics, hacking)
Nov 28, 2016
udit is now a member of GarageLab (arduino, electronics, robotics, hacking)
Nov 25, 2016
Aqeel munir is now a member of GarageLab (arduino, electronics, robotics, hacking)
Nov 23, 2016

© 2017   Created by Marcelo Rodrigues.   Powered by

Badges  |  Report an Issue  |  Terms of Service