Skip to content

A python 3 library to connect various motor systems to a Raspberry pi single board computer

License

Notifications You must be signed in to change notification settings

gavinlyonsrepo/RpiMotorLib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

97 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Website Rss Donate

RpiMotorLib

ScreenShot dcmotor ScreenShot Nema ScreenShot L298N ScreenShot A4988

Table of contents

Overview

  • Name: RpiMotorLib
  • Title: Raspberry pi motor library.
  • Description:

A python 3 library to drive motor controllers and servos with a Raspberry pi.

These components supported are some of the most widely used by maker community. There are three categories in library. Stepper motors, DC Motors and Servos. The end user can import this library into their projects and then control the components with short snippets of code. The library is modular so user can just import/use the section they need.

  • Project URL: URL LINK

  • Tested on Toolchains:

    1. RPI 3 model B. Raspbian 10 Buster, 32 bit. Python 3.7.3.
    2. RPI 3 model B. Raspbian 12 Bookworm, 64 bit. Python 3.11.2.

Installation

Latest version 3.2 (10-2022)

From PyPi with pip or pipx

The Python Package Index (PyPI) is a repository of software for the Python programming language. The program is present in python package index, Pypi. Install using pip or pipx to the location or environment of your choice. Package name = rpimotorlib Link.

NB see notes section for more on pipx.

From Github

Manually install from github The package is also archived on github and can be manually download and installed via python and setup.py. Not recommended.

curl -sL https://github.com/gavinlyonsrepo/RpiMotorLib/archive/3.2.tar.gz | tar xz
cd RpiMotorLib-3.2
python3 setup.py build 
python3 setup.py install --user

Hardware

Supported Components:

Stepper motors

Motor tested Motor controller Help File URL link
Unipolar 28BYJ-48 ULN2003 driver module URL
Bipolar Nema TB6612FNG Dual Driver Carrier URL
Bipolar Nema L298N H-Bridge controller module URL
Bipolar Nema A4988 Stepper Driver Carrier URL
Bipolar Nema DRV8825 Stepper Driver Carrier URL
Bipolar Nema A3967 Stepper Driver aka "easy driver v4.4" URL
Bipolar (untested on hw) LV8729 Stepper Driver Carrier URL
Bipolar (untested) DV8833 Motor controller module TODO
Bipolar (untested) L9110S Motor controller module TODO

DC motors

Motor Motor controller Help File URL link
DC Brushed Motor L298N Motor controller module. URL
DC Brushed Motor L9110S Motor controller module. URL
DC Brushed Motor DV8833 Motor controller module. URL
DC Brushed Motor TB6612FNG Dual Motor Driver Carrier URL
DC Brushed Motor Transistor control URL

Servos

There are two different options for controlling the servo. When using Rpi_GPIO option you may notice twitching at certain delays and stepsizes. This is the result of the implementation of the RPIO PWM software timing. If the application requires precise control the user can pick the pigpio library which uses hardware based timing. The disadvantage being they must install a dependency(pigpio) and start its daemon.

Servo Link
Servo software timing RPi.GPIO module PWM
Servo hardware timing pigpio library module PWM

Software

  1. Separate help files are in documentation folder to learn how to use library. Click on the relevant URL link in tables in hardware section.
  2. Test files used during development are in test folder of repository.
  3. There is a "Software matrix" showing which classes are used to drive which components. This is in the Software_Matrix.md file in documentation folder.

File System

RpiMotorLib files are listed below:

File Path Description
RPiMotorLib/RpiMotorLib.py stepper motor python library file
RPiMotorLib/rpiservolib.py servo python library RPi.GPIO PWM file
RPiMotorLib/rpi_pservo_lib.py servo python library pigpio PWM file
RPiMotorLib/rpi_dc_lib.py DC python motor library file
documentation/*.md 15 markdown library documentation files
test/*Test.py 14 python tes