L298N Dual H-Bridge Driver Module (HCROBO0068)

Stepper and DC type motor drivers
Post Reply
admin
Site Admin
Posts: 866
Joined: Sun Aug 05, 2012 4:02 pm

L298N Dual H-Bridge Driver Module (HCROBO0068)

Post by admin » Mon Jun 04, 2018 1:00 pm

Image




The L298N motor drive module (HCROBO0068) contains a dual channel full H-bridge driver. This driver allows up two DC motors to be independently controlled in both forward and reverse directions via a microcontroller such as an Arduino. Alternatively, the module is capable of driving a single 4 input stepper motor. It includes an optional on-board 5V regulator for powering its internal logic circuit so only one supply voltage is required (Vm = 6 to 12V). Screw terminals allow for easy connection of the motor(s) and the power supply.

Image Image



Specification:

Product code: HCROBO0068
Motor input voltage (Vm): 5 – 24V
Combined motor drive current (max): 2A for 2 minutes / 1A continuous
5V output current (J1 fitted): 100mA
Dimensions: (LxWxH): 43mm x 43mm x 27.5mm



Notes:

When J1 is fitted the input of the on-board 5V regulator is connected to Vm and the 5V terminal becomes an output. If J1 is removed a separate 5V supply connected to the 5V terminal is required to power the digital circuit.

Actual voltage across motor terminals = Vm - ~2.35V

(!) When using the 5V terminal as an output (J1 fitted) DO NOT draw more than 100mA from this terminal.
(!) For Vm voltages > 12V jumper J1 must be removed and a separate 5V supply connected the 5V terminal.

Failure to observe the above conditions will result in permanent damage to the on-board regulator resulting in the motor supply voltage Vm being applied to the 5V terminal.




Image




Example Arduino Sketch:

Code: Select all

/* FILE:    HCROBO0068_DC_Motor_Example
   DATE:    04/06/18
   VERSION: 0.1
   AUTHOR:  Andrew Davies


This example sketch uses the HCMotor library to individually control two DC motors 
connected to the two motor output terminals of the HCROBO0068 L298N motor driver.

The HCMOTOR library can be downloaded from the software section of our support forum 
here: http://forum.hobbycomponents.com/viewtopic.php?f=58&t=1870

The HCROBO0068 dual H-Bridge motor driver can be purchased from our website here:
[LINK TBA]
 
Connect your Arduino as follows:

Arduino..............HCROBO0068
D5...................IN1
D4...................IN2
D3...................IN3
D2...................IN4
GND..................GND terminal

Connect motor 1 to terminals OUT1 & OUT2
Connect motor 2 to terminals OUT3 & OUT4
Connect motor power supply (Vm) to terminals +12V and GND. (Note Vm voltage should 
match the rated voltage of your motors)


You may copy, alter and reuse this code in any way you like, but please leave
reference to HobbyComponents.com in your comments if you redistribute this code.
This software may not be used directly for the purpose of selling products that
directly compete with Hobby Components Ltd's own range of products.

THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, WHETHER
EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR LACK OF NEGLIGENCE.
HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR ANY DAMAGES,
INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY
REASON WHATSOEVER.
*/


/* Include the library */
#include "HCMotor.h"

#define MOTOR1 0
#define MOTOR2 1

/* Digital pins used to drive the motors */
#define IN1 5
#define IN2 4
#define IN3 3
#define IN4 2

/* Create an instance of the library */
HCMotor HCMotor;


void setup() 
{

  /* Initialise the library */
  HCMotor.Init();

  /* Tell the library which pins control which motor and type of driver */
  HCMotor.attach(MOTOR1, DCMOTOR_H_BRIDGE, IN1, IN2);
  HCMotor.attach(MOTOR2, DCMOTOR_H_BRIDGE, IN3, IN4);

  /* Set the duty cycle of the PWM signal in 100uS increments. 
     Here 100 x 100uS = 1mS duty cycle. */
  HCMotor.DutyCycle(MOTOR1, 100);
  HCMotor.DutyCycle(MOTOR2, 100);

}

void loop() 
{
  /* Set the direction of the motors */
  HCMotor.Direction(MOTOR1, FORWARD);
  HCMotor.Direction(MOTOR2, REVERSE);

  /* Slowly ramp up the speed of the motors from 0 to 100 percent */
  for(byte SpeedPercent = 0; SpeedPercent <= 100; SpeedPercent++)
  {
    HCMotor.OnTime(MOTOR1, SpeedPercent);
    HCMotor.OnTime(MOTOR2, SpeedPercent);
    delay(100);
  }

  /* Slowly ramp down the speed of the motors from 0 to 100 percent */
  for(byte SpeedPercent = 0; SpeedPercent <= 100; SpeedPercent++)
  {
    HCMotor.OnTime(MOTOR1, 100 - SpeedPercent);
    HCMotor.OnTime(MOTOR2, 100 - SpeedPercent);
    delay(100);
  }



  /* Reverse the direction of the motors */
  HCMotor.Direction(MOTOR1, REVERSE);
  HCMotor.Direction(MOTOR2, FORWARD);

  /* Slowly ramp up the speed of the motors from 0 to 100 percent */
  for(byte SpeedPercent = 0; SpeedPercent <= 100; SpeedPercent++)
  {
    HCMotor.OnTime(MOTOR1, SpeedPercent);
    HCMotor.OnTime(MOTOR2, SpeedPercent);
    delay(100);
  }

  /* Slowly ramp down the speed of the motors from 0 to 100 percent */
  for(byte SpeedPercent = 0; SpeedPercent <= 100; SpeedPercent++)
  {
    HCMotor.OnTime(MOTOR1, 100 - SpeedPercent);
    HCMotor.OnTime(MOTOR2, 100 - SpeedPercent);
    delay(100);
  }

}




Image

The HCAM2315 Arduino compatible library can be downlaoded from the software section of this forum here:

http://forum.hobbycomponents.com/viewto ... =58&t=1870


Schematic:
L298N_Dual_H-Bridge_Driver_HCROBO0068_Schematic.png



Disclaimer: Libraries, example code, and diagrams are provided as an additional free service by Hobby Components and are not sold as part of this product. We do not provide any guarantees or warranties as to their accuracy or fitness for purpose.

Descriptions and diagrams on this page are copyright Hobby Components Ltd and may not be reproduced without permission.
You do not have the required permissions to view the files attached to this post.

Post Reply

Return to “Motor drivers”