Difference: Motors (1 vs. 12)

Revision 122022-09-23 - UliRaich

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

Motors

Introduction

Line: 59 to 58
 
Pin on the driver module pin on the ESP32
5-12V 5V
Gnd Gnd
Changed:
<
<
In1 D1: GPIO 26
In2 D2: GPIO 18
In3 D3: GPIO 19
In4 D4: GPIO 23
>
>
In1 D0: GPIO 26
In2 D5: GPIO 18
In3 D6: GPIO 19
In4 D7: GPIO 23
 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 lines  

Revision 112022-09-01 - UliRaich

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

Motors

Introduction

Line: 58 to 59
 
Pin on the driver module pin on the ESP32
5-12V 5V
Gnd Gnd
Changed:
<
<
In1 D1: GPIO 22
In2 D2: GPIO 21
In3 D3: GPIO 17
In4 D4: GPIO 16
>
>
In1 D1: GPIO 26
In2 D2: GPIO 18
In3 D3: GPIO 19
In4 D4: GPIO 23
 A stepper object is created with:

Deleted:
<
<
 
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  

Revision 102022-08-25 - UliRaich

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

Motors

Introduction

Line: 52 to 52
 will move the servo to 90 degrees.

Stepping Motor

Changed:
<
<
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.
>
>
In 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
Pin on the driver module pin on the ESP32

Revision 92022-03-07 - UliRaich

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

Motors

Introduction

Line: 42 to 42
 The servo motor is connected to the WeMos D1 as follows
Cable from Servo Motor Cable color Pin on ESP32
Gnd brown Gnd
Changed:
<
<
Power red 3.3V
>
>
Power red 5V
 
Signal orange any GPIO pin, default: D0, on ESP32: GPIO 26

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)  

Revision 82022-03-05 - UliRaich

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

Motors

Introduction

Line: 99 to 99
 
META FILEATTACHMENT attachment="motorShieldFront.png" attr="" comment="" date="1593074633" name="motorShieldFront.png" path="motorShieldFront.png" size="174779" user="UliRaich" version="1"
META FILEATTACHMENT attachment="servo.png" attr="" comment="" date="1593086112" name="servo.png" path="servo.png" size="146400" user="UliRaich" version="1"
META FILEATTACHMENT attachment="exercise_7.odt" attr="" comment="" date="1596963558" name="exercise_7.odt" path="exercise_7.odt" size="383197" user="UliRaich" version="1"
Added:
>
>
META FILEATTACHMENT attachment="stepping.png" attr="" comment="" date="1646509224" name="stepping.png" path="stepping.png" size="156004" user="UliRaich" version="1"

Revision 72022-02-23 - UliRaich

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

Motors

Introduction

Line: 9 to 9
 
  • Stepping motors: Move in steps and therefore allow to move forward or backward to a precise position of any distance.

The DC motor

Changed:
<
<
The DC motor we use need ~ 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 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!
  dcMotorProp.png

Revision 62021-06-30 - UliRaich

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

Motors

Introduction

Line: 20 to 20
 As shown in the photo on the right 2 solder bridges must be installed to
  • tie the reset pin to the reset signal of the system
  • to allow access to motor standby through an I2C command
Changed:
<
<
The motor control shield is accessed as an I2C device on address 0x30. I2C access is managed by an STM32F030 micro controller, which unfortunately is delivered with buggy firmware. When trying, I saw the device on the I2C bus immediately after reset but when trying a second time it disappeared from the bus.
>
>
The motor control shield is accessed as an I2C device on address 0x30. I2C access is managed by an STM32F030 micro controller, which unfortunately is delivered with buggy firmware. When trying, I saw the device on the I2C bus immediately after reset but when trying a second time it had disappeared from the bus.
  Fortunately for us other people have noticed this before and Piotr Bugalski has written replacement firmware which works reliably. Have a look at https://hackaday.io/project/18439-motor-shield-reprogramming to find out how this is done.

Revision 52021-01-29 - UliRaich

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

Motors

Introduction

Changed:
<
<
We have 3 different types of motors in out kit:
>
>
We have 3 different types of motors in our kit:
 
  • DC motor: Used for continuous movement in either forward or backward direction and at different speeds
  • Servo motor: Allows to move to a precise angle. Used e.g. for steering the direction of a robot car, RC controlled model air planes or ships. Allowed angles are usually 0..180 degrees
  • Stepping motors: Move in steps and therefore allow to move forward or backward to a precise position of any distance.

Revision 42020-08-09 - UliRaich

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

Motors

Introduction

Line: 74 to 74
 
  • DOUBLE_PHASE_BACKWARD
  • HALF_STEP-FORWARD
  • HALF_STEP_BACKWARD
Changed:
<
<
You can set the mode with the method stepMode():
>
>
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.

Line: 84 to 83
  Finally the method move(noOfSteps) moves the stepping motor noOfSteps in the mode and with the speed currently selected.
Added:
>
>
The exercise sheet in odt format:

https://iotworkshop.africa/pub/IoT_Course_English/Motors/exercise_7.odt

 -- Uli Raich - 2020-06-25

Comments

Line: 94 to 97
 
META FILEATTACHMENT attachment="motorShieldBack.png" attr="" comment="" date="1593074633" name="motorShieldBack.png" path="motorShieldBack.png" size="196861" user="UliRaich" version="1"
META FILEATTACHMENT attachment="motorShieldFront.png" attr="" comment="" date="1593074633" name="motorShieldFront.png" path="motorShieldFront.png" size="174779" user="UliRaich" version="1"
META FILEATTACHMENT attachment="servo.png" attr="" comment="" date="1593086112" name="servo.png" path="servo.png" size="146400" user="UliRaich" version="1"
Added:
>
>
META FILEATTACHMENT attachment="exercise_7.odt" attr="" comment="" date="1596963558" name="exercise_7.odt" path="exercise_7.odt" size="383197" user="UliRaich" version="1"

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

Revision 22020-06-25 - UliRaich

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

Motors

Introduction

Line: 33 to 33
 
  • brake: stop the motor
  • sleep: put the motor into standby mode to save power
Added:
>
>

The Servo Motor

The 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.

servo.png

The servo motor is connected to the WeMos D1 as follows

Cable from Servo Motor Cable color Pin on ESP32
Gnd brown Gnd
Power red 3.3V
Signal orange any GPIO pin, default: D0, on ESP32: GPIO 26

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)  

will move the servo to 90 degrees.

 -- Uli Raich - 2020-06-25

Comments

Line: 42 to 60
 
META FILEATTACHMENT attachment="dcMotorProp.png" attr="" comment="" date="1593074555" name="dcMotorProp.png" path="dcMotorProp.png" size="52606" user="UliRaich" version="1"
META FILEATTACHMENT attachment="motorShieldBack.png" attr="" comment="" date="1593074633" name="motorShieldBack.png" path="motorShieldBack.png" size="196861" user="UliRaich" version="1"
META FILEATTACHMENT attachment="motorShieldFront.png" attr="" comment="" date="1593074633" name="motorShieldFront.png" path="motorShieldFront.png" size="174779" user="UliRaich" version="1"
Added:
>
>
META FILEATTACHMENT attachment="servo.png" attr="" comment="" date="1593086112" name="servo.png" path="servo.png" size="146400" user="UliRaich" version="1"

Revision 12020-06-25 - UliRaich

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

Motors

Introduction

We have 3 different types of motors in out kit:

  • DC motor: Used for continuous movement in either forward or backward direction and at different speeds
  • Servo motor: Allows to move to a precise angle. Used e.g. for steering the direction of a robot car, RC controlled model air planes or ships. Allowed angles are usually 0..180 degrees
  • Stepping motors: Move in steps and therefore allow to move forward or backward to a precise position of any distance.

The DC motor

The DC motor we use need ~ 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!

dcMotorProp.png

The motor is controlled by a motor control shield:

Motor Control Shield
Front view
Motor Controller Shield
Back side
motorShieldFront.png motorShieldBack.png
As shown in the photo on the right 2 solder bridges must be installed to
  • tie the reset pin to the reset signal of the system
  • to allow access to motor standby through an I2C command
The motor control shield is accessed as an I2C device on address 0x30. I2C access is managed by an STM32F030 micro controller, which unfortunately is delivered with buggy firmware. When trying, I saw the device on the I2C bus immediately after reset but when trying a second time it disappeared from the bus.

Fortunately for us other people have noticed this before and Piotr Bugalski has written replacement firmware which works reliably. Have a look at https://hackaday.io/project/18439-motor-shield-reprogramming to find out how this is done.

A MicroPython driver for exactly this motor controller can be found on https://bitbucket.org/thesheep/micropython-d1motor/src/default. I integrated this driver into the MicroPython binary. It provides a class Motor with the following methods:

  • A Motor instance must be created with the parameters
    • index: 0 or 1 which corresponds to either motor 1 or motor 1 (2 DC motors can be controlled be the shield)
    • ic2: an I2C object, which must be created before (we did this in the exercise on the SHT30)
  • frequency(freq): if freq == None this method returns the PWM frequency used to control motor speed otherwise its sets the frequency
  • speed(motor_speed): if motor_speed == None: returns the current speed,otherwise it sets the speed.
    motor_speed values can be 1..10000 to move clockwise or -1..-10000 to move counterclockwise.
    I found that for values below 1500 the current is too low to make the motor move
  • brake: stop the motor
  • sleep: put the motor into standby mode to save power

-- Uli Raich - 2020-06-25

Comments

<--/commentPlugin-->

META FILEATTACHMENT attachment="dcMotorProp.png" attr="" comment="" date="1593074555" name="dcMotorProp.png" path="dcMotorProp.png" size="52606" user="UliRaich" version="1"
META FILEATTACHMENT attachment="motorShieldBack.png" attr="" comment="" date="1593074633" name="motorShieldBack.png" path="motorShieldBack.png" size="196861" user="UliRaich" version="1"
META FILEATTACHMENT attachment="motorShieldFront.png" attr="" comment="" date="1593074633" name="motorShieldFront.png" path="motorShieldFront.png" size="174779" user="UliRaich" version="1"
 
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