0

members

Easy Basics: Project 033c L298N Dual H-bridge motor driver module, DC 6v/12v unipolar or bipolar stepper

of Lex C in UNO

Basics: Project 033c

Project name: L298N Dual H-bridge motor driver module, DC 6v/12v unipolar or bipolar stepper motor Nema 17

Attachments: sketch1, sketch2, sketch3 with potentiometer

Tags: Arduino, DC 6v/12v unipolar, bipolar stepper motor, Nema 17, L298N Dual H-bridge motor driver module

In this project, you needed these parts :

1.Aruduino Uno R3 (you can also use the other version of Arduino)

2.L298N H-Bridge motor driver module (as you see they can be a little bit different but have the same working principle) 1pc

3.Arduino IDE ( you can download it from here  )

4.Jumper cables

5. DC 6v/12v unipolar or bipolar stepper motor Nema 17 1 pc

6. External motor DC power supply  1 pc

7. External L298N IC logics power supply (optional, depending on external motor power supply) 1 pc

General

We will learn how to connect L298N H-Bridge motor driver module to Arduino board and use it with DC 6V/12V unipolar or bipolar stepper motor. This is the most complete guide about this module.

Understanding the stepper motor

What is a stepper motor?

A digital electric motor that moves one step at a time and each step is defined by a step angle. The stepper motor moves is distinct steps during its rotation. Each steps is defined by a step angle. In the example below you may notice that there are 4 distinct steps for the rotor to make a complete 360 degree rotation. As defines in step angle at 90 degrees. Since the stepper motor does move in discreet movement, we can say that a stepper motor is actually a digital motor. This characteristic makes it very suitable for digital interfaces integrates with a microcontroller. 

Stepper motors are not like simple DC motors and cannot be driven by providing just DC voltage. Driver circuit & a microcontroller are needed to control the speed & direction of a stepper.

With a stepper motor you can “step” exactly a given angle. Further the stepper motor has the advantage of having a holding torque.Steppers are able hold their position when they are not moving.

Stepper motors are available in two varieties: unipolar or bipolar.

Bipolar motors are the strongest type of stepper motor and usually have four leads. They have two sets of electromagnetic coils internally, and stepping is achieved by changing the direction of current within those coils.

Unipolar motors, identifiable by having 5, 6 or even 8 wires, also have two coils, but each one has a center tap. Unipolar motors can step without having to reverse the direction of current in the coils, making the electronics simpler. However, because the center tap is used to energize only half of each coil at a time they typically have less torque than bipolar.

Unipolar motors typically have two coils per phase, one for each direction of magnetic field.

Bipolar motors typically have one coil per phase, and current flows in both directions through this coil. Thus, the bipolar motor will be able to produce twice as much torque, since at any given time, the unipolar motor is only using half of its windings.

Unipolar stepper motors are generally of 6 wires, each coil phase has a center tap. If both of center tap (common) wires are connected together it becomes a 5 wire unipolar. To convert unipolar stepper motor to bipolar stepper motor (4 wires) just leave the center taps (2 wires) not connected.

You can read more about them here and here.

We will use stepper motors Nema 17 DC 6V and 12V.

1. Nema 17 unipolar stepper motor DC 12V specification

  • Manufacturer Part Number: 17HM15-0406D
  • Motor Type: Unipolar Stepper
  • Step Angle: 0.9 deg
  • Holding Torque: 26Ncm(36.8oz.in)
  • Rated Current/phase: 0.4A
  • Voltage: 12V
  • Phase Resistance: 30ohms
  • Inductance: 30mH ± 20%(1KHz)
  • Frame Size: 42 x 42mm
  • Body Length: 39mm
  • Shaft Diameter: Φ5mm
  • Front Shaft Length: 24mm
  • D-cut Length: 15mm
  • Rear Shaft Length: 10mm
  • Number of Leads: 6
  • Lead Length: 500mm
  • Weight: 300g

See additional information here.

2. Nema 17 unipolar stepper motor DC 6V specification

  • Manufacturer Part Number: 17HM15-0806S
  • Motor Type: Unipolar Stepper
  • Step Angle: 0.9 deg
  • Holding Torque: 26Ncm(36.8oz.in)
  • Rated Current/phase: 0.8A
  • Voltage: 6V
  • Phase Resistance: 7.5ohms
  • Inductance: 7.5mH ± 20%(1KHz)
  • Frame Size: 42 x 42mm
  • Body Length: 39mm
  • Shaft Diameter: Φ5mm
  • Shaft Length: 24mm
  • D-cut Length: 15mm
  • Number of Leads: 6
  • Lead Length: 500mm
  • Weight: 300g

See additional information here.

Understanding the L298N H-Bridge motor driver module

H-Bridge's are typically used in controlling motors speed and direction, but can be used for other projects such as driving the brightness of certain lighting projects such as high powered LED arrays. An H-Bridge is a circuit that can drive a current in either polarity and be controlled by Pulse Width Modulation (PWM).

PWM is a technique which allows us to adjust the average value of the voltage that’s going to the electronic device by turning on and off the power at a fast rate. The average voltage depends on the duty cycle, or the amount of time the signal is ON versus the amount of time the signal is OFF in a single period of time.

If you’ve read up on controlling LED’s with your microcontroller you probably have already run into PWM as it’s also a good method of controlling the brightness of an LED. With PWM the DC motor is sent a series of pulses. Each pulse is of the full voltage that the motor can handle so a 6-volt motor will be sent 6 volt pulses while a 12-volt motor will be sent 12 volt pulses. The width of the pulses are varied to control the motor speed, pulses with a narrow width will cause the motor to spin quite slowly. Increasing the pulse width will increase the speed of the motor, as illustrated below.

In order to stop the motor completely you just stop pulsing it, essentially sending it zero volts. To run it at full speed you send it the full voltage, again without pulsing it.

The Arduino has a function called “analogWrite” which is used to drive any of its PWM-capable outputs (the Arduino Uno has 6 digital outputs (pins 3,5,6,9,10,11) that are also capable of PWM).DC motors will last much longer and be more reliable if controlled through PWM.

Let's check how to reverse DC motor direction by changing polarity and how to change their speed using pulse width modulation with using a very common circuit configuration called an “H-Bridge”.

An H-Bridge circuit contains four switching elements, transistors or MOSFETs, with the motor at the center forming an H-like configuration. Using transistors also allows you to control the motor speed with PWM, as described above.By activating two particular switches at the same time we can change the direction of the current flow, thus change the rotation direction of the motor.

In the first diagram we can see four switches which are all in the open or “off” position. In the center of the circuit is a DC motor. If you look at the circuit as it is drawn here you can distinctly see a letter “H”, with the motor attached in the center or “bridge” section – thus the term “H-Bridge”.

If we close (i.e. turn on) two of the switches you can see how the voltage is applied to the motor, causing it to turn clockwise.

Now we’ll open those switches and close the other two. As you can see this causes the polarity of the voltage applied to the motor to be reversed, resulting in our motor spinning counterclockwise.

This is pretty simple but effective. In fact if all you need to do is design a circuit to drive the motor full-speed in either direction you could actually build this as shown here, using a 4PDT (4 Pole Double-Throw) center-off switch. But of course we want to control the motor using an Arduino, so an electronic circuit where the switches are replaced by transistors is what we need.

L298N H-Bridge

While you can use discrete transistors to build an H-Bridge there are a number of advantages in using an integrated circuit. A number of H-Bridge motor driver IC’s are available and all of them work in pretty much the same fashion. One of the most popular is the L298N.

The L298N is a member of a family of IC’s that all have the designation “L298”. The difference between the family members is in the amount of current they can handle. 

The L298N actually contains two complete H-Bridge circuits, so it is capable of driving a pair of DC motors. This makes it ideal for robotic projects, as most robots have either two or four powered wheels. The L298N can also be used to drive a single stepper motor, however we won’t cover that configuration in this article.

L298N schematics:

L298N Dual H-bridge motor driver module can control up to 2 DC motors or one bipolar stepper motor.

L298N logic table:

L=Low, H=High, X=Don’t care, Z=High impedance, Vin=Input voltage, Vdrop=Voltage drop

Note: There is a voltage drop between the input voltage and the L298N' motor outputs, you can expect a 1V to 3V drop depend on the input voltage and current draw.

Specifications:

  • Double H bridge Drive Chip: L298N
  • Logical voltage: 5V DC
  • Drive voltage: 5V-35V DC
  • Logical current: 0-36mA 
  • Drive peak current: up to 2A MAX single bridge (one DC motor)
  • Max power: 25W
  • Dimensions: 43 x 43 x 26mm
  • Weight: 26g

See more info about L298N IC here and here.

Signals and connections of stepper motor Nema 17

1.Unipolar stepper motor (can be bipolar too). Used in project

2.Bipolar stepper motor (Same maker but different wire colors)

Signals and connections of L298N H-Bridge motor driver module

L298N integrated circuit pinouts:

You’ll find a few different versions of L298N boards but they all operate in the same fashion. The board contains an L298N mounted on a heatsink, a 5 volt voltage regulator to “optionally" provide power for logic circuits, supporting diodes and capacitors and connectors as follows:

  • Logic inputs for each H-Bridge circuit
  • Power supply inputs for the motor power supply
  • An optional 5 Volt power input for the logic circuits.
  • Outputs for each DC motor

L298N H-Bridge motor driver module jumpers:

CSA – This is the “current sensing” function for Motor A. If the jumper is in this function is ignored. Most of the time you’ll leave this jumper in place.

CSB – The “current sensing” function for Motor B. If the jumper is in this function is ignored. Most of the time you’ll leave this jumper in place.

UR1 – Input 1 pull-up resistor. You will usually leave this in place, which enables a 10k pull-up resistor for the input.

UR2 – Input 2 pull-up resistor.

UR3 – Input 3 pull-up resistor.

UR4 – Input 4 pull-up resistor.

5v-EN – This is the only jumper that you need to really pay attention to. When this jumper is in place it enables the boards internal 78M05 5V voltage regulator chip, supplying logic power from the motor power supply. When this jumper is enabled you will NOT need to supply 5 V to the 5 V input terminal. When the jumper is removed you will need to supply 5 V to the 5 V input terminal.

L298N H-Bridge motor driver module pins:

Motor A (or OUTA, OUTB) (or OUT1, OUT2) - DC motor A output (+ , -) or Stepper motor (+, -)

Motor B (or OUTC, OUTD) (or OUT3, OUT4) - DC motor B output(+ , -)

VMS (or VCC) (or VDD) - Motors external power supply from 5V to 35 V

GND - common ground

+5V - DC 5V output or input for the logic circuits

ENA (or EN1) - DC motor A enable jumper. Connect to PWM output for DC motor A speed control (Leave this in place when using a stepper motor).

ENB (or EN2) - DC motor B enable jumper. Connect to PWM output for DC motor B speed control (Leave this in place when using a stepper motor).

IN1 (or N1) (or INA) – Input 1 for DC motor A

IN2 (or N2) (or INB) – Input 2 for DC motor A

IN3 (or N3) (or INC) – Input 3 for DC motor B

IN4 (or N4) (or IND) – Input 4 for DC motor B

The L298N Dual H-bridge motor driver module has an onboard (internal) 5V regulator which is either enabled or disabled using a 5V regulator jumper. If the exernal motor supply voltage is up to 12V we can enable the onboard (internal) 5V regulator and the +5V pin can be used as output, for example for powering your Arduino board. But if the external motor power voltage is greater than 12V we must disconnect the 5V jumper because those voltages will cause damage to the onboard (internal) 5V regulator. In this case the +5V pin will be used as input as we need connect it to a 5V power supply in order the L298N IC to work properly.


Please note that L298N IC makes a voltage drop of about 2V. So for example, if we use a 12V power supply, the voltage at motors terminals will be about 10V, which means that we won’t be able to get the maximum speed out of our 12V DC motor.

Wiring

The following picture shows the needed connections with the Arduino Uno:

1. Unipolar stepper motor DC 6V. Make sure that jumpers on ENB and +5V, ENB and +5V removed from the motor driver board and 5V_EN (5V) regulator jumper set on the motor driver board.

2. Bipolar stepper motor DC 6V. We use unipolar stepper motor with 4 wires connection. It can be different colors of the stepper motor wires - for example instead of RED will be BLACK, YELLOW -> GREEN, BLUE -> RED, GREEN -> BLUE. Check your motor specification first before doing wiring. Make sure that jumpers on ENB and +5V, ENB and +5V removed from the motor driver board and 5V_EN (5V) regulator jumper set on the motor driver board.

3. Unipolar stepper motor DC 12V. Make sure that jumpers on ENB and +5V, ENB and +5V,  5V_EN (5V) regulator jumper removed from the motor driver board.

4. Bipolar stepper motor DC 12V. We use unipolar stepper motor with 4 wires connection. It can be different colors of the stepper motor wires - for example instead of RED will be BLACK, YELLOW -> GREEN, BLUE -> RED, GREEN -> BLUE. Make sure that jumpers on ENB and +5V, ENB and +5V,  5V_EN (5V) regulator jumper removed from the motor driver board.

5. Sketch 3 with potentiometer. See how potentiometer connected to Arduino Uno below.

6.Alternative stepper motor connection

Step by Step instruction

  1. Do wiring.
  2. If you do use the internal voltage regulator you’ll have to supply the motor power supply with at least 7.5 V. External motor power supply needs to be a bit higher voltage than the actual motor requirements. This is due to the internal voltage drop in the transistors that form the H-Bridge circuit. The combined voltage drop is 1.4 V, so if you are using 6 V motors you’ll need to give the board 7.4 V, if you have 12 V motors then your motor supply voltage will need to be 13.4 V.
  3. Connect your external motor power supply – the positive (red wire) to pin +12V on the motor driver module and negative (black wire) to pin GND close to pin +12V. If your external motor power supply is more then 12V remove the 5V regulator jumper on the motor driver module.Don’t forget to connect Arduino board GND to pin GND on the motor driver module as well to complete the circuit.
  4. Connect your external L298N logic power supply – the positive (red wire) to pin +5V on the motor driver module and negative (black wire) to pin GND close to pin +5V.  Don’t forget to connect Arduino board GND to pin GND on the motor driver module as well to complete the circuit.
  5. Open Arduino IDE.
  6. Plug your Adruino Uno board into your PC and select the correct board and com port
  7. Open up serial monitor and set your baud to 9600 baud
  8. Verify and upload the the calibration sketch to your Adruino Uno

Summary

We have learnt how to connect L298N H-Bridge motor driver module to Arduino board and use it with DC 6V/12V unipolar or bipolar stepper motor. 

Libraries:

  • Stepper library included in Arduino IDE.

Sketch:

  • See attachments on the begining of this project description.


Other projects of Lex C
Easy Basics: Project 057a ACR122U NFC Reader of Lex C, Not selected 17-01-2018

« Go back to category
Is this project fake? Report it!   
Recommend to a friend
Published at 27-09-2017
Viewed: 1695 times