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: 18610

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

Marcelo Rodrigues replied to GarageLab's discussion Serious claims against BeagleBone's manufacturer CircuitCo
"Ed, No, they didn't deliver yet.  :( Good luck for us all."
23 hours ago
Profile IconWesenachin Asfaw and Muhammad Basil joined GarageLab (arduino, electronics, robotics, hacking)
23 hours ago
Marcelo Rodrigues replied to FiniousFingers's discussion New to group
"Hey man! A good point to start is reading basic tutorials on Arduino coding and wiring. Then, you…"
23 hours ago
FiniousFingers posted a discussion

New to group

Couple quick things,I am just starting to learn, or wanting to learn, how to use the Arduino UNO…See More
yesterday
Profile IconDan Urbauer, Bjorn and Jiaming Zhao joined GarageLab (arduino, electronics, robotics, hacking)
Wednesday
FiniousFingers is now a member of GarageLab (arduino, electronics, robotics, hacking)
Monday
Erva updated their profile
Mar 16
Erva and Mrs. Priscilla Bonneval are now friends
Mar 16
Profile IconSamantha Dorr, Lee Robinson and Celso Eiju Ito joined GarageLab (arduino, electronics, robotics, hacking)
Mar 16
Edward Evans updated their profile
Mar 15
Edward Evans replied to GarageLab's discussion Serious claims against BeagleBone's manufacturer CircuitCo
"Hi Marcelo, I am curious if you have had any resolution on this?  We may be in the same boat…"
Mar 15
Celso Eiju Ito left a comment for Mrs. Priscilla Bonneval
"I just accept your invitation. Thank You for contact me. Sincerelly,   'Eiju"
Mar 15
Mohasin Ahamed Chinnapattan commented on Mauro Assis's blog post How to hack a remote control (and a flying shark) I
"You mentioned collector is set to ground but emitter is set to ground in your diagram "
Mar 14
Profile Iconbadrkhan mijbas khalifa, Bethany Cruz, Mrs. Priscilla Bonneval and 1 more joined GarageLab (arduino, electronics, robotics, hacking)
Mar 13
Edward Evans is now a member of GarageLab (arduino, electronics, robotics, hacking)
Mar 9
Profile IconAllan Zilkowsky, Shubham Dewangan, FAUSTO PEREIRA ROMANO and 4 more joined GarageLab (arduino, electronics, robotics, hacking)
Mar 1
Dave Lewing is now a member of GarageLab (arduino, electronics, robotics, hacking)
Feb 27
Profile Iconjames essien and Chow HP joined GarageLab (arduino, electronics, robotics, hacking)
Feb 17
Profile IconPerry Duvall, Irayya Mathad and wiley milam joined GarageLab (arduino, electronics, robotics, hacking)
Feb 16
Profile IconAlan Powell and Chuck Nolan joined GarageLab (arduino, electronics, robotics, hacking)
Feb 9

© 2017   Created by Marcelo Rodrigues.   Powered by

Badges  |  Report an Issue  |  Terms of Service