Difference between revisions of "Stepper Motor and ULN2003"
Jump to navigation
Jump to search
m |
|||
(13 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | + | = IMPORTANT = | |
+ | '''In many computers the current is not enough to drive the servo!!!''' | ||
+ | '''If it does not work, keeps disconnecting, or rebooting the ESP the power is not sufficent and you need an extra power supply.''' | ||
+ | |||
+ | See [[SG90 Servo#Power Issues]] and the video on the [[SG90 Servo]] page for details how to do this. | ||
= Description = | = Description = | ||
Line 10: | Line 14: | ||
* http://www.jangeox.be/2013/10/stepper-motor-28byj-48_25.html | * http://www.jangeox.be/2013/10/stepper-motor-28byj-48_25.html | ||
* https://cookierobotics.com/042/ | * https://cookierobotics.com/042/ | ||
+ | * see https://github.com/zhcong/ULN2003-for-ESP32 | ||
− | [[File:Stepper03.JPG| | + | [[File:Stepper.JPG|x300px]] |
+ | [[File:Stepper03.JPG|x300px]] | ||
ULN2003 driver module. | ULN2003 driver module. | ||
Line 19: | Line 25: | ||
= How to connect it electrically = | = How to connect it electrically = | ||
− | [[File:Stepper-c.JPG| | + | [[File:Stepper-c.JPG|x250px]] |
+ | [[File:Elko-stepper.JPG|x250px]] | ||
+ | |||
+ | We recommend to add the capacitor to keep the power supply more stable. This issue is similar to the power issue with the servo [[SG90 Servo]]. | ||
[[File:Stepper-cables01.JPG|x200px]] | [[File:Stepper-cables01.JPG|x200px]] | ||
Line 36: | Line 45: | ||
from machine import Pin | from machine import Pin | ||
+ | # for the ESP8266 | ||
+ | # In1 = Pin(2,Pin.OUT) # IN1-> GPIO2 | ||
+ | # In2 = Pin(0,Pin.OUT) # IN1-> GPIO0 | ||
+ | # In3 = Pin(4,Pin.OUT) # IN1-> GPIO4 | ||
+ | # In4 = Pin(5,Pin.OUT) # IN1-> GPIO5 | ||
+ | |||
+ | # for ESP32 | ||
In1 = Pin(32,Pin.OUT) | In1 = Pin(32,Pin.OUT) | ||
In2 = Pin(33,Pin.OUT) | In2 = Pin(33,Pin.OUT) | ||
Line 50: | Line 66: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | = Related Tutorial Videos = | ||
+ | <youtube>EIwjeek5hnM</youtube> | ||
+ | <!-- <youtube>PEKjvD1uQe4</youtube> --> | ||
− | + | [[Category:Actuators]] | |
− | |||
− | |||
− |
Latest revision as of 09:32, 14 June 2024
Contents
IMPORTANT[edit]
In many computers the current is not enough to drive the servo!!!
If it does not work, keeps disconnecting, or rebooting the ESP the power is not sufficent and you need an extra power supply.
See SG90 Servo#Power Issues and the video on the SG90 Servo page for details how to do this.
Description[edit]
A stepper motor is a motor where the turning can be controlled in steps.
Our motor has about 508 steps for 360° (the motor itself has 64 steps but there is a gear train on top)
more details:
- http://www.jangeox.be/2013/10/stepper-motor-28byj-48_25.html
- https://cookierobotics.com/042/
- see https://github.com/zhcong/ULN2003-for-ESP32
ULN2003 driver module.
How to connect it electrically[edit]
We recommend to add the capacitor to keep the power supply more stable. This issue is similar to the power issue with the servo SG90 Servo.
Required Module and Files[edit]
- We use Stepper.py
- this is downloaded from https://github.com/zhcong/ULN2003-for-ESP32
- the original file is at https://github.com/zhcong/ULN2003-for-ESP32/blob/master/Stepper.py
- this is based on: https://github.com/IDWizard/uln2003 by (c) IDWizard 2017,MIT License.
How to control it in MicroPython[edit]
1 import Stepper
2 from machine import Pin
3
4 # for the ESP8266
5 # In1 = Pin(2,Pin.OUT) # IN1-> GPIO2
6 # In2 = Pin(0,Pin.OUT) # IN1-> GPIO0
7 # In3 = Pin(4,Pin.OUT) # IN1-> GPIO4
8 # In4 = Pin(5,Pin.OUT) # IN1-> GPIO5
9
10 # for ESP32
11 In1 = Pin(32,Pin.OUT)
12 In2 = Pin(33,Pin.OUT)
13 In3 = Pin(25,Pin.OUT)
14 In4 = Pin(26,Pin.OUT)
15
16 s1 = Stepper.create(In1,In2,In3,In4, delay=10)
17
18 s1.step(509,-1)
19
20 s1 = Stepper.create(In1,In2,In3,In4, delay=1)
21
22 s1.step(509)
Related Tutorial Videos[edit]