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

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

Profile IconJiangbin ZHENG and Riszter István joined GarageLab (arduino, electronics, robotics, hacking)
yesterday
Profile Iconkaan and guner guvenc joined GarageLab (arduino, electronics, robotics, hacking)
Monday
Devang Rameshbhai Zalavadiya is now a member of GarageLab (arduino, electronics, robotics, hacking)
May 18
Profile Iconraj kumar, Raffaello Palandri and Jigga Boo joined GarageLab (arduino, electronics, robotics, hacking)
May 7
Profile IconGabriele D'Angelo, dale wolver, Ibrahim Aykut and 2 more joined GarageLab (arduino, electronics, robotics, hacking)
May 5
Profile IconJaschaSaurus Rex and Christian Mock joined GarageLab (arduino, electronics, robotics, hacking)
May 1
Igor Golov is now a member of GarageLab (arduino, electronics, robotics, hacking)
Apr 27
Marco is now a member of GarageLab (arduino, electronics, robotics, hacking)
Apr 24
Muhammad Ali commented on Marcelo Rodrigues's blog post Arduino generated VGA (color) signal - Complete!
"Thanks for the advice. I will persist with the code till I get it done. thanks once again."
Apr 18
Marcelo Rodrigues commented on Marcelo Rodrigues's blog post Arduino generated VGA (color) signal - Complete!
""The output waveforms on oscilloscope for Hsync and Vsync and for that matter RGB pins are not…"
Apr 17
Muhammad Ali commented on Marcelo Rodrigues's blog post Arduino generated VGA (color) signal - Complete!
"Hi  Marcelo I am trying to make this code work with Attiny 44a operating @ 20 MHz. I have…"
Apr 17
Profile IconReal NOiseux, Muhammad Ali, bob v and 1 more joined GarageLab (arduino, electronics, robotics, hacking)
Apr 17
baiqian is now a member of GarageLab (arduino, electronics, robotics, hacking)
Apr 10
Profile IconDavide and Almas Amandossov joined GarageLab (arduino, electronics, robotics, hacking)
Apr 6
Profile Iconvamoalrenga and John Ferrell joined GarageLab (arduino, electronics, robotics, hacking)
Apr 3
Marcelo Rodrigues replied to FiniousFingers's discussion New to group
"Yes, please share your progress here. Thanks and good"
Mar 27
FiniousFingers replied to FiniousFingers's discussion New to group
"Thanks, good to know someone is out there. I will be…"
Mar 27
Edward Evans replied to GarageLab's discussion Serious claims against BeagleBone's manufacturer CircuitCo
"Have you moved forward with any action?  I would be interested in discussing your…"
Mar 27
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."
Mar 23
Profile IconWesenachin Asfaw and Muhammad Basil joined GarageLab (arduino, electronics, robotics, hacking)
Mar 23

© 2017   Created by Marcelo Rodrigues.   Powered by

Badges  |  Report an Issue  |  Terms of Service