Line: 1 to 1 | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
MotorsIntroductionWe have 3 different types of motors in our kit:
The DC motorThe DC motor we use needs ~ 350 mA of power and can therefore not be run when the ESP32 power is coming from the USB connector, delivering a maximum ~200mA. We will need an external power supply! The motor is controlled by a motor control shield:
The Servo MotorThe servo motor we use is of type SG90. It is a cheap hobbyist servo which can be run directly off the ESP32 power supply even it that board is powered through an USB connector. For connections and technical details pleas consult the SG90 data sheet. The servo motor is connected to the WeMos D1 as follows
I wrote and integrated into the MicroPython binary a simple servo driver which makes it extremely simple to control the servo motor: | |||||||||||||||||||
Deleted: | |||||||||||||||||||
< < | |||||||||||||||||||
from servo import Servo servo = Servo() servo.angle(90)will move the servo to 90 degrees. Stepping MotorIn order to learn about how stepping motors work please refer to the 2017 course on embedded systems lecture 9: Embedded_Systems/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
| |||||||||||||||||||
Changed: | |||||||||||||||||||
< < |
| ||||||||||||||||||
> > |
| ||||||||||||||||||
A stepper object is created with: | |||||||||||||||||||
Added: | |||||||||||||||||||
> > | |||||||||||||||||||
from stepper import steppingMotor stepper = steppingMotor() # the parameters p1,p2,p3,p4 are optional and allow to connect the stepping motor to different GPIO linesThe steppingMotor class uses different modes for stepping:
| |||||||||||||||||||
Deleted: | |||||||||||||||||||
< < | |||||||||||||||||||
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. The exercise sheet in odt format: https://afnog.iotworkshop.africa/pub/IoT_Course_English/Motors/exercise_7.odt -- Uli Raich - 2020-06-25 Comments
|