How to control unipolar/bipolar stepper/stepping motors such as 28BYJ48 using motor drivers such as L293D
Ask QuestionAsked 1 year, 11 months agoActive 5 months agoViewed 805 times31
So I’m having issues with controlling the motor with this ic.
I have got it to work when it was unipolar with the uln2003.
I slit the red wire so there are only 4,two windings. Measured ohms across coils.
Pin 1 ic – 5v pos
Pin2 ic – gpio 27
Pin3 ic – yellow motor wire
Pin 4 ic – ground
Pin 5 ic – ground
Pin 6 ic – Blue motor wire
Pin 7 ic – gpio 22
Pin 8 ic – 5v pos
Pin 9 ic – 3v3 pi
Pin 10 ic – gpio 9
Pin 11 ic – pink motor wire
Pin 12 ic – ground
Pin 13 ic – ground
Pin 14 ic – orange motor wire
Pin 15 ic – gpio 10
Pin 16 ic – 5v pos
When I run:
import RPi. GPIO as GPIO
import time
GPIO. setmode(GPIO. BCM)
ControlPins = [27,22,10,9]
for pin in ControlPins:
GPIO. setup(pin, GPIO. OUT)
GPIO. output(pin, 0)
seq = [[1,0,0,0],[1,1,0,0],[0,1,0,0],[0,1,1,0],[0,0,1,0],[0,0,1,1],[0,0,0,1],[1,0,0,1]]
def rotate90(direction):
if direction == 'CW':
for i in range (128):
for halfstep in range(4):
GPIO. ouput(ControlPins[pin], seq[halfstep] [pin])
rotate90('CW')
GPIO.cleanup()
The data sheets do not have a truth table(seq) as far as I can see. They also say to use diodes and caps(I’m assuming that’s for efficiency).
The 28byj is making sounds, but isn’t rotating. I think this is because of my truth table. What should it be?
Sorry for the messy question. I’m on my phone.dc-motorShareEditFollowCloseFlagedited 4 mins agotlfong013,62133 gold badges77 silver badges2222 bronze badgesasked Apr 27 ’19 at 3:52Alex White16155 bronze badges
- Yes, you connection data is messy. I can only count to 7, but you have 16! Can you draw me a picture? – tlfong01 Apr 27 ’19 at 4:26
- Of course she is making sounds – she is complaining that you have made all the connections. You suspect your truth table, but can you show me your truth table? – tlfong01 Apr 27 ’19 at 4:32
- Will draw one up now. – Alex White Apr 27 ’19 at 4:37
- No hurry, I am going out to eat. See you later. – tlfong01 Apr 27 ’19 at 5:04
- imgur.com/gallery/UyG3ii4 – Alex White Apr 27 ’19 at 5:15
- Sorry that took ages… My internet is awful. – Alex White Apr 27 ’19 at 5:16
- Let us continue this discussion in chat. – tlfong01 Apr 27 ’19 at 6:40
1 Answer
Question
Stepper 28byj48 unipolar OK with uln2003
Slit the red wire so there are only two windings
Measured ohms across coils. Pin 1 ic – 5v pos … (OMG, 16 connection pairs!!!)
Answer
I did the same thing a long while ago. I vaguely remember I performed the following operation converting the stepper from unipolar to bipolar.
- Open the casing
- Cut away the red wire, so that the two windings do not electrically connected to each other.

Now I am googling something to read, and jot down some pictures, …

Now the schematic for L293D driving a bipolar stepping motor.

I have found a L293D module in my junk box.

Now I have shrinked and merged 4 big pictures into one big picture for my small eyes to look at.

The problem is we don’t know the colour code of the wiring scheme. For example, what colour is for 1a, 1b, 2a, 3b etc. If we could not find the colour code, we may need to use the multimeter and a 6 battery to find by trial and error manually.

Anyway, now I have removed the casing of the 5 wire unipolar motor. Next step is find out which trace to cut to separate the two coils sticking together at the red wire, to make it a 4 wire, two non connecting coils, red wire don’t care bipolar motor.

Now I am also thinking of testing my old stepper and compare how more powerful is, comparing to the small guy. The old guy costed me US$2 (a couple of years ago). The wires were badly torn, but I know there is no contact brushes to wear, so found it good and quite. A new one costed US$25. I thought it was very good money for a hobbyist to play with and learn something. As a newbie, I needed to google hard before I know how to use a battery, a multimeter, and a 1 pole, 12 throw to figure out which wire goes with which other wire, …


A stronger stepping motor to replace 28BYJ48, should be strong enough to turn Rubik cube

/ to continue, …
References
(1) 28BYJ-48 – 5V Stepper Motor
(2) Stepping Motor Fundamentals – Microchip
(3) Control of Stepping Motors A Tutorial – DW Jones Uni Iowa, 1995
(4) L293x Quadruple Half-H Drivers Datasheet – TI
(5) MINI L293D DC/stepping motor controller board – ¥9.50
(6) L293D DC motor control card dual h-bridge Module – US$ 1.43
(7) Stepping Motor Tutorial (Unipolar/Bipolar, Half Step/ Full Step, ULN2003/L293D)
(8) Stepping Motor Tutorial Using L298N Driver
(10) What could be the reasons for a stepper motor stuttering with an A4988 driver? – EESE 2021apr05
(11) My experiments with stepper motor – ScientistNobee, 2015mar12
Appendices
Appendix A – Why we need a dual bridge motor driver (L293D or L298N)?
We need to use two H-bridge circuits (dual H-bridge) to drive both coils of a bipolar stepper motor.
How does a H-bridge circuit work?
The field effect transistors (FET) Q1 to Q4 act like switches. The diodes D1 to D4 act like freewheeling diodes to channel back-electromagnetic force (back-EMF) of the motor coils. When the ‘switches’ Q1 and Q4 are closed (and Q2 and Q3 are open) a conducting path is created and current will flow from +9Vdc to Q1 to the coil to Q4 to GND. By opening Q1 and Q4 switches and closing Q2 and Q3 switches, a different conducting path is generated from +9Vdc to Q2 to the coil to Q3 to GND. If you pay close attention you will notice the current flowing through the coil in the opposite direction, allowing reverse operation of the motor.
Note however the switches Q1 and Q2 should never be closed at the same time, as this would cause a short circuit. The same applies to the switches Q3 and Q4. This is why we cannot simply use Arduino [or Rpi] HIGH and LOW outputs to reverse the polarity; a H-bridge circuit is essential.
ShareEditDeleteFlagedited 3 mins agoanswered Apr 27 ’19 at 4:25tlfong013,62133 gold badges77 silver badges2222 bronze badges
- Comments are not for extended discussion; this conversation has been moved to chat. Alex, you should be able to use this one. If not leave a msg here
@goldilocks
. – goldilocks♦ Apr 27 ’19 at 13:34 - I know you modified the 28byj48 uniplor stepping motor to bipolar, by tearing it down and disconnecting the common read wire. I did the same thing but found that changing from unipolar to bipolar does not make the motor much more powerful. You also changed the power sequence from half step to full step etc, hopping to increase torque. I also did the same thing, but not much improvement. I forgot to added that to increase torque, 28BYJ48 is very limited. I just found a more powerful stepping motor in may junk box, together with a “micro stepping driver”. This combination is more powerful. – tlfong01 May 22 ’19 at 5:40
- I forgot if you wish to rotate the Rubik cube using 4 stepping motors. 28BYJ24 is not powerful enough. I later used another more powerful one and found it OK to turn the Rubik cube. Perhaps I can show it later. – tlfong01 May 22 ’19 at 5:42
Categories: Uncategorized