Difference: Motors (2 vs. 3)

Revision 32020-06-25 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

Motors

Introduction

Line: 44 to 44
 
Gnd brown Gnd
Power red 3.3V
Signal orange any GPIO pin, default: D0, on ESP32: GPIO 26
Added:
>
>

I wrote and integrated into the MicroPython binary a simple servo driver which makes it extremely simple to control the servo motor:

 
Changed:
<
<
I wrote and integrated into the MicroPython binary a simple servo driver which makes it extremely simply to control the servo motor:

from servo import Servo
servo = Servo()
servo.angle(90)  
>
>
from servo import Servo 
servo = Servo() 
servo.angle(90)  
  will move the servo to 90 degrees.
Added:
>
>

Stepping Motor

In order to learn about how stepping motors work please refer to the 2017 course on embedded systems lecture 9: UCC_Course/Lecture9:SteppingMotors. We will use a 27BJY-48 stepper motor with its associated ULN-2803 driver module. http://robocraft.ru/files/datasheet/28BYJ-48.pdf is the data sheet of the motor and https://www.sparkfun.com/datasheets/IC/uln2803a.pdf is the datasheet of the ULN-2803 Darlington Transistor array.

The stepping Motor class included in the MicroPython binary uses the following default connections

Pin on the driver module pin on the ESP32
5-12V 5V
Gnd Gnd
In1 D1: GPIO 22
In2 D2: GPIO 21
In3 D3: GPIO 17
In4 D4: GPIO 16
A stepper object is created with:

from stepper import steppingMotor 
stepper = steppingMotor() # the parameters p1,p2,p3,p4 are optional and allow to connect the stepping motor to different GPIO lines  

The steppingMotor class uses different modes for stepping:

  • SINGLE_PHASE_FORWARD (default)
  • SINGLE_PHASE_BACKWARD
  • DOUBLE_PHASE_FORWARD
  • DOUBLE_PHASE_BACKWARD
  • HALF_STEP-FORWARD
  • HALF_STEP_BACKWARD
You can set the mode with the method stepMode():

stepper.stepMode(stepper.DOUBLE_PHASE_FORWARD)

You can change the movement speed with the method waitAfterSteps() which defines how long to wait after each step in ms. Valid values are 2..1000. Again the method returns the value currently in use if called without a parameter.

The method clrAll() set all coils (IN1..IN4) to zero.

Finally the method move(noOfSteps) moves the stepping motor noOfSteps in the mode and with the speed currently selected.

  -- Uli Raich - 2020-06-25
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback