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

Topic attachments
I Attachment History Action Size Date Who Comment
PNGpng dcMotorProp.png r1 manage 51.4 K 2020-06-25 - 08:42 UliRaich  
PNGpng motorShieldBack.png r1 manage 192.2 K 2020-06-25 - 08:43 UliRaich  
PNGpng motorShieldFront.png r1 manage 170.7 K 2020-06-25 - 08:43 UliRaich  
Edit | Attach | Watch | Print version | History: r12 | r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r1 - 2020-06-25 - UliRaich
 
  • Edit
  • Attach
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