Tags:
tag this topic
create new tag
view all tags
---+ Motor exercises ---++ Introduction We have 3 types of motors that are used for different purposes and controlled in different ways: * <p>DC motor used in continuous movement e.g. a propeller, motor to move a robot car etc.</p> * <p>Servo motor: A motor that allows to go to a precises angle used e.g. to steer the car, model airplane or</p> * Stepping motor: Move to a precise position or angle. In contrast to the servo motor the angle is not limited and can make several full turns | DC motor | Servo Motor | Stepping motor | | <img alt="dcMotorProp.png" height="278" src="%ATTACHURL%/dcMotorProp.png" title="dcMotorProp.png" width="328" /> | <img alt="servo.png" height="358" src="%ATTACHURL%/servo.png" title="servo.png" width="423" /> | <img alt="stepping.png" height="368" src="%ATTACHURL%/stepping.png" title="stepping.png" width="369" /> | Before starting with the exercises please read the TWiki page on motors: [[Motors]] ---++ Exercise 1: The DC Motor Make sure the solder jumpers are correctly inserted on the motor shield. Check with i2c_scan from the exercise on the SHT30 that you can reliably see the motor shield on address 0x30 of the !I2C bus. Run !I2C_scan several times and make sure the motor shield does not disappear from the bus. If this happens you will have to upgrade the firmware for the !STM32F030 micro-controller providing the !I2C interface to the motor shield. Read the section “Reprogramming without soldering” very carefully and follow the steps. If something is not clear, *please don’t hesitate to ask!* https://hackaday.io/project/18439-motor-shield-reprogramming Download the motor shield driver from [[https://github.com/mcauser/deshipu-micropython-d1motor/blob/master/d1motor.py%20][ https://github.com/mcauser/deshipu-micropython-d1motor/blob/master/d1motor.py ]]and make sure you understand every detail. Make a list with all methods and their parameters. Finally connect the DC motor to the shield and make the motor move at different speeds and in forward and backward direction. Attention: The motor draws ~ 350 mA, which is too much for the USB interface of the micro-controller delivering a maximum of ~ 200mA. <b>You need an external power supply! </b>The motor works on voltages between 3V and 6V. ---++ Exercise 2: The servo motor Connect the servo motor as described on the TWiki page. For the hobby servo motor the power delivered through the USB bus is sufficient. Check out the description of PWM in the !MicroPython manual: https://docs.micropython.org/en/latest/esp8266/tutorial/pwm.html. Download my simplistic servo driver from the TWiki page on motors. Write a program to move the servo motor to a given angle. ---++ Exercise 3: The stepping motor If you do not know in detail how stepping motors work, please have a look at chapter Lecture 9 of the course on embedded systems: https://afnog.iotworkshop.africa/do/view/Embedded_Systems/Lecture9:SteppingMotors Stepping motors can run in different modes: * <p>Single phase forward and backward</p> * <p>Double phase forward and backward</p> * <p>Half step forward and backward.</p> Write a stepping motor class implementing these 6 stepping modes. The class should have the methods: * <p><font face="Courier New, monospace">__init__</font><font face="Courier New, monospace">(self,p1=_PHASE1,p2=_PHASE2,p3=_PHASE3,p4=_PHASE4)</font><font face="Courier New, monospace"> :</font> creating a motor instance. You may pass the coil pins as keyword parameters</p> * <p><font face="Courier New, monospace">clrAll(self)</font> : sets all coils off</p> * <p><font face="Courier New, monospace">stepMode</font><font face="Courier New, monospace">(self,mode=None)</font>: Sets the stepping mode<br /> The available stepping modes are declared as Class variables as follows:</p> <p><font face="Courier New, monospace">SINGLE_PHASE_FORWARD = 0<br /> SINGLE_PHASE_BACKWARD = 1<br /> DOUBLE_PHASE_FORWARD = 2<br /> DOUBLE_PHASE_BACKWARD = 3<br /> HALF_STEP_FORWARD = 4<br /> HALF_STEP_BACKWARD = 5</font></p> * <p><font face="Courier New, monospace">move(self,noOfSteps): </font>Moves the motor by the number of steps given in the currently set mode.</p> Write a script stepperTest.py exercising all 6 stepping modes -- %USERSIG{UliRaich - 2022-03-05}% ---++ Comments %COMMENT%
Attachments
Attachments
Topic attachments
I
Attachment
History
Action
Size
Date
Who
Comment
png
dcMotorProp.png
r1
manage
51.4 K
2022-03-05 - 19:51
UliRaich
png
servo.png
r1
manage
143.0 K
2022-03-05 - 19:51
UliRaich
png
stepping.png
r1
manage
152.3 K
2022-03-05 - 19:51
UliRaich
E
dit
|
A
ttach
|
Watch
|
P
rint version
|
H
istory
: r1
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r1 - 2022-03-05
-
UliRaich
Home
Site map
AFNOG web
Embedded_Systems web
IoT_Course_English web
IoT_Course_French web
Main web
Sandbox web
TWiki web
IoT_Course_English Web
Create New Topic
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
P
View
Raw View
Print version
Find backlinks
History
More topic actions
Edit
Raw edit
Attach file or image
Edit topic preference settings
Set new parent
More topic actions
Account
Log In
Register User
E
dit
A
ttach
Copyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback