EB - L298P Motor Driver

$9.90

  • Model: EB0300010M
  • Shipping Weight: 20gram
  • 9995 Units in Stock

Add to Cart:



Item specifics

Brand Name:Maker Studio

Product Description

Electronic Brick - L298P Dual Channel Motor Driver often be used to translate control message to drive motors. Such as stepper motor and DC motor.   

Features

  • Working Voltage: 5V
  • With Makerduino Demo Code
  • Weight:13g

 

Applications

  • Robots
  • Smart cars

 

Details

       aeProduct.getSubject()

Use with Makerduino

The following steps show how to use EB - Motor Driver and Stepper Motor with Makerduino .

 

Materials

  • Makerduino
  • Electronic Brick Shield
  • EB - Motor Driver
  • Stepper Motor
  • Batteries
  • A/B type USB cable
  • Female DuPont wires

Steps

1. Connect Electronic Brick Shield onto Makerduino to bring out all the Makerduino Pins.

aeProduct.getSubject()

 

2. Connect EB - Motor Driver to Makerduino as following:

 

aeProduct.getSubject()

 

Connection with stepper motor and matching battery:

aeProduct.getSubject()

3. Connect the Makerduino to Computer by the USB cable.

 

4. Download the Makerduino demo code EB - Motor Driver.zip. Unzip the code directly into the libraries folder.

 

5. Open Makerduino IDE, choose the right Board and Serial Port. Open the sketch EB - Motor Driver.ino and upload it to the Makerduino.

 

/*

   stepperL298N

   Copyright 2008 G. Andrew Stone

   Licensed under the Common Public License V1.0

   For the full text of this license see:

 */

 

int ledPin = 13;

 

void setup()                    // run once, when the sketch starts

{

  pinMode(ledPin, OUTPUT);      // sets the digital pin as output

  pinMode(9,OUTPUT);

  pinMode(10,OUTPUT);

  digitalWrite(9,HIGH);

  digitalWrite(10,HIGH);

}

 

void mydelay(int clk)

{

  int i;

  for (i=0;i< clk;i++);

  //delay(clk);

}

 

class StepperL298N

{

  public:

  byte pins[4];

  byte curState;

  byte* lut;

  StepperL298N(byte pin1,byte pin2,byte pin3,byte pin4);

    

  void step(boolean dir);

  void halfStep(boolean yes) { if (yes) lut = halfStepLut; else lut = fullStepLut;}

  void start() { curState = 0xa;}

  void free() { curState = 0; }

  void brake() { curState = 0; }

 

  byte fullStepLut[16];

  byte halfStepLut[16];

};

 

 

StepperL298N::StepperL298N(byte pin1,byte pin2,byte pin3,byte pin4)

{

  pins[0] = pin1; pins[1] = pin2; pins[2]=pin3; pins[3] = pin4;

  lut = fullStepLut;

  for (int i=0;i<4;i++)

    {

    pinMode(pins[i], OUTPUT);      // sets the digital pin as output

    }

 

 memset(&fullStepLut,sizeof(byte)*16,0);

 memset(&halfStepLut,sizeof(byte)*16,0);

 

 // High nibble goes one way, low the other

 fullStepLut[0] = 0;

 // 1010 -> 1001 -> 0101 -> 0110

 fullStepLut[0xa] = 0x9 | 0x60;

 fullStepLut[0x9] = 0x5 | 0xa0;

 fullStepLut[0x5] = 0x6 | 0x90;

 fullStepLut[0x6] = 0xa | 0x50;

 

 halfStepLut[0] = 0;

 // 1010 -> 1000 -> 1001 -> 0001 -> 0101 -> 0100 -> 0110 -> 0010

 halfStepLut[0xa] = 0x8 | 0x20;

 halfStepLut[0x8] = 0x9 | 0xa0;

 halfStepLut[0x9] = 0x1 | 0x80;

 halfStepLut[0x1] = 0x5 | 0x90;

 halfStepLut[0x5] = 0x4 | 0x10;

 halfStepLut[0x4] = 0x6 | 0x50;

 halfStepLut[0x6] = 0x2 | 0x40;

 halfStepLut[0x2] = 0xa | 0x60;

}

 

void StepperL298N::step(boolean dir)

{

  curState = lut[curState];

  if (dir) curState &= 0xf;

  else curState >>= 4;

  for (int i=1,j=0;i< 16;i*= 2,j++)

    {

    byte lvl = LOW;

    if (i&curState) lvl=HIGH;

    digitalWrite(pins[j],lvl);

    }

}

 

 

int serDataVal = LOW;

void loop()                     // run over and over again

{

  unsigned long int j;

 

  StepperL298N motor(3,4,5,6);

  motor.halfStep(true);

  motor.start();

 

  for (j=0;j< 1000;j++)

    {

    motor.step(1);

    digitalWrite(ledPin, j&1);   // sets the LED on

    delay(5+j/10);  // Change the delay to change the rate the motor spins

    }

  motor.halfStep(false);

  motor.start();

  for (j=0;j< 1000;j++)

    {

    motor.step(0);

    digitalWrite(ledPin, j&1);   // sets the LED on

    delay(5+j/10);

    }

}

 

6. Check the Results. After the sketch is successfully uploaded, the stepper motor will be driven by Motor driver. The gear rounds very faster at first then slow down. Until the gear arrivers the preset degree at the sketch, it rounds revers.    

 

 

 

The following steps show how to use EB - Motor Driver and DC Motor with Makerduino.

Materials

  • Makerduino
  • Electronic Brick Shield
  • EB - Motor Driver
  • DC Motor
  • Batteries
  • A/B type USB cable
  • Female DuPont wires

 

Steps

1.      Connect Electronic Brick Shield onto Makerduino to bring out all the Makerduino Pins.

aeProduct.getSubject()

 

2.      Connect EB - Motor Driver to Makerduino as following:

aeProduct.getSubject()

Connection with stepper motor and matching battery:

aeProduct.getSubject()

3.      Connect the Makerduino to Computer by the USB cable.

 

4.      Open Makerduino IDE, choose the right Board and Serial Port. Open the sketch EB_DCMotor.ino and upload it to the Makerduino.

 

 

/*

  Demo code for testing Motor Driver

 

  by Maker Studio

*/

#include "EB_MotorDriver.h"

#include "SoftwareSerial.h"

 

//M1_EN,M1_IN2,M1_IN1, M2_EN,M2_IN2,M2_IN1

EB_MotorDriver myMotorDriver(5,12,13, 6,7,8);

 

int speed = 250;

 

void setup()

{

    myMotorDriver.begin();

}

 

void loop()

{

    myMotorDriver.run(speed,speed);

    delay(2000);

    myMotorDriver.run(-speed,-speed);

    delay(2000);

    myMotorDriver.run(speed,-speed);

    delay(2000);

    myMotorDriver.run(-speed,speed);

    delay(2000);

    myMotorDriver.stop();

    delay(2000);

}

 

5.      Check the Results. After the sketch is successfully uploaded, The DC motor will be driven by Motor driver. The motor1 rounds forward, backward, forward, backward. The motor2 rounds forward, backward, backward, forward.  

   

Download information

https://drive.google.com/?usp=folder&authuser=0&usp=folder#folders/0BzxrU4QvH7jEd3ZJTVdnNUpXNVE

 

Find EB - Motor Driver Material.zip to download schematic and other material.

 

 

 

about us 02

This product was added to our catalog on Tuesday 11 February, 2014.

Your IP Address is: 54.158.208.189
Copyright © 2018 Maker Studio