Introduction: Bipolar Stepper Library

About: 55+ years in electronics, computers, and teaching ... now retired.

This instructable demonstrates my TinyStepper library for controlling bipolar stepping motors.

The library is a bipolar version of the unipolar "TinyStepper_28BYJ_48" library found at https://github.com/Stan-Reifel/TinyStepper_28BYJ_48

The reason for creating this library is that the stepping patterns for unipolar and bipolar motors are different.

In my library the stepping mode can be changed between "full-step", "wave", and half-step" by editing lines 380~382 in the TinyStepper.cpp" library file. The default mode is full-stepping”. [1]

The Documentation for both libraries is the same and may be found at https://github.com/Stan-Reifel/TinyStepper_28BYJ_48.

Both libraries feature ramp up/down motor acceleration in steps/second/second using the LeibRamp Algorithm found at https://github.com/nephen/Leib-Ramp-on-Arduino-Due

Each of the library examples intended for a 2048 step/revolution unipolar motor(s) have been reworked for 200 step/revolution bipolar motors.


Images

  • The cover image shows a single NEMA17 bipolar stepper connected to an Arduino UNO R3 via an L298N H-bridge module.
  • Photo 2 shows two NEMA17 bipolar steppers connected to the Arduino.
  • The video clip shows how the motors can be programmed to start and stop at the same time regardless of the number of rotations. The stepper motors are 17HS2408 6 volt steppers with coil currents of 0.6A (600mA). The H-bridge voltage has been set at 7 volts to allow for the voltage drop across the series-pass transistors.


Notes

[1]

The following article explains the various stepping modes together with each of their advantages and disadvantages:

https://www.monolithicpower.com/stepper-motors-basics-types-uses

Supplies

The following items were obtained from https://www.aliexpress.com/

  • 1 only Arduino UNO R3 with USB cable
  • 2 only NEMA17 stepper motors ... 17HS2804 (6V, 0.6A) or 17HS3430 (12V, 0.4A)
  • 2 only L298N H-Bridge driver boards
  • 1 only Arduino male-male jumper (common earth between Arduino and the L298Ns)
  • 8 only Arduino male-female (four per L298N)
  • Misc hookup wire for distributing the power

The estimated cost for these items are:

  • Arduino $8.00
  • L298N x 2 $4.00 ($2.00 each)
  • Steppers x 2 $24.00 ($12.00 each)

A power supply or car battery will also be required. 

Step 1: Theory


Bipolar Motors

Place a coil near a compass needle. Connect a battery across the coil and one end of the compass needle will point towards the coil. Reverse the battery connections and the compass needle will point the other way.

Motors which require the battery polarity to be reversed are called bipolar (two-polarity) stepping motors.


Unipolar Motors

Alternately connect your battery between the center of the coil and ground. Touch one end of the coil to ground and the compass needle will point towards the coil. Now reverse the current direction by touching the opposite end of the coil to ground ... the compass needle will point the other way

Motors which do not require the battery polarity to be reversed are called unipolar (single-polarity) stepping motors.


Resolution

Each of the above motors has a resolution of 180 degrees-per-step.

A resolution of 90 degrees-per-step can be obtained by introducing a second coil at 90 degrees to the first.

This resolution can further be improved by introducing extra windings, shaped magnetic pole-pieces, gears, and microstepping.

Each method has its advantages and disadvantages.

For more information see this article:

https://www.monolithicpower.com/stepper-motors-basics-types-uses


Key Points

The coil switching patterns for bipolar and unipolar motors are different:

  • To reverse the magnetic field in a bipolar motor winding we reverse the battery connections across the coil.
  • To reverse the magnetic field in a unipolar motor winding we connect the opposite end of the coil to ground.

Motor resolution can be increased using gears and microstepping.

Be aware that gears have a tiny amount of backlash.


Popular Motors

The NEMA range of bipolar stepping motors, such as the NEMA17 and NEMA23, have a shaft resolution of 200 steps-per-revolution or 1.8 degrees per step. These motors are suitable for applications such as 3D printers and plotters.

The 28BYJ-48 unipolar stepping motor has a shaft resolution of 2048 steps-per-revolution. This motor is popular with hobbists due to it’s small size and low current consumption. These motors are suitable for tasks that require a low shaft speed.

Step 2: Wiring Diagram

Photo 1 shows two motors connected to an Arduino UNO R3 microcontroller using L298N H-bridge controller boards.

Each additonal motor controller requires four Arduino I/O (input/output) pins.

Step 3: Library Software

Installation

  • Create a new folder called “TinyStepper” in your “...\arduino\libraries” folder
  • Copy the attached file “TinyStepper.h” into the “TinyStepper” folder.
  • Copy the attached file “TinyStepper.cpp” into the “TinyStepper” folder
  • Installation is now complete

Examples

Four example files are attached:

  • TinyStepper_absolute_moves.ino
  • TinyStepper_basic.ino
  • TinyStepper_multiple_tasks.ino
  • TinyStepper_speed_coordination.ino

To run an example:

  • Wire your motors as shown in Step 2 “Wiring Diagram”
  • Copy the contents of each file to a new Arduino sketch.
  • Save the file ... use the same name less the “.ino” file extension [1]
  • Compile and upload the file to your Arduino
  • The motor(s ) should start to move.

Notes

[1]

Use a text editor such as Notepad++ ... do not use a word processor.

Step 4: Summary

This instructable presents a new bipolar stepper library, “TinyStepper”, that features ramp up/down acceleration.

The library is a bipolar version of the unipolar "TinyStepper_28BYJ_48" library found at https://github.com/Stan-Reifel/TinyStepper_28BYJ_48

In addition three stepping modes are supported:

  • Wave
  • Full-step
  • Half-step

The default stepping mode is “full-step”.

The estimated cost of the test circuit is approximately $50.00 plus shipping.

  Click here   to view my other instructables.

Anything Goes Contest 2021

Participated in the
Anything Goes Contest 2021