Skip to content

Commit

Permalink
Merge pull request #67 from Chr157i4n/dev
Browse files Browse the repository at this point in the history
version 0.5
  • Loading branch information
Chr157i4n authored May 26, 2024
2 parents 3c87827 + f1a9bf6 commit 734c93e
Show file tree
Hide file tree
Showing 19 changed files with 345 additions and 72 deletions.
18 changes: 18 additions & 0 deletions .github/ISSUE_TEMPLATE/new_board_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: New Board Request
about: Create a Request if you want a new board supported
title: ''
labels: ''
assignees: ''

---

**Info about your board**

- the name and a link to you board
- a library that can be used to control the gpios of your board
- a info to the serial port of your board

**Board Identification**
A method to recognize the new board programmatically. ideally with the output of
`cat /proc/device-tree/model`
3 changes: 2 additions & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install pylint
pip install gpiozero
pip install RPi.GPIO
pip install Mock.GPIO
pip install mock
pip install pyserial
- name: Analysing the code with pylint
run: |
pylint $(git ls-files '*.py') --disable=C0103 --extension-pkg-whitelist=RPi
pylint $(git ls-files '*.py') --disable=C0103 --disable=W0511 --extension-pkg-whitelist=RPi
1 change: 1 addition & 0 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install gpiozero
pip install RPi.GPIO
pip install Mock.GPIO
pip install pyserial
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## version 0.5

- decoupled gpio access from gpio library
- added support for Raspberry Pi5 (gpiozero)
- added support for Luckfox Pico (python-periphery)

## version 0.4.5

- enhancement of logging module
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,24 @@ pip3 install TMC-2209-Raspberry-Pi
sudo raspi-config
```

### Board Support

The following table shows the supported boards and which libraries for GPIO access is beeing used for that board.

Library | Installation Parameter | Boards
-- | -- | --
RPi.GPIO | RASPBERRY_PI | Pi4, Pi3 etc.
gpiozero | RASPBERRY_PI5 | Pi5
Jetson.GPIO | NVIDIA_JETSON | Nvidia Jetson
pheriphery | LUCKFOX_PICO | Luckfox Pico

Those libraries are needed for this library to work. You can either install the correct library yourself.
You can also install the needed GPIO library by specifing the Installation Parameter while installing this library:

```shell
pip3 install TMC-2209-Raspberry-Pi[RASPBERRY_PI]
```

## Wiring

Pin TMC2209 | connect to | Function
Expand Down
8 changes: 6 additions & 2 deletions demo/debug_script_01_uart_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
import time
try:
from src.TMC_2209.TMC_2209_StepperDriver import *
from src.TMC_2209._TMC_2209_GPIO_board import Board
except ModuleNotFoundError:
from TMC_2209.TMC_2209_StepperDriver import *
from TMC_2209._TMC_2209_GPIO_board import Board


print("---")
Expand All @@ -25,9 +27,11 @@
# initiate the TMC_2209 class
# use your pins for pin_en, pin_step, pin_dir here
#-----------------------------------------------------------------------
if BOARD == "RASPBERRY_PI":
if BOARD == Board.RASPBERRY_PI:
tmc = TMC_2209(21, 16, 20, skip_uart_init=True)
elif BOARD == "NVIDIA_JETSON":
elif BOARD == Board.RASPBERRY_PI5:
tmc = TMC_2209(21, 16, 20, serialport="/dev/ttyAMA0", skip_uart_init=True)
elif BOARD == Board.NVIDIA_JETSON:
tmc = TMC_2209(13, 6, 5, serialport="/dev/ttyTHS1", skip_uart_init=True)
else:
# just in case
Expand Down
8 changes: 6 additions & 2 deletions demo/demo_script_01_uart_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
import time
try:
from src.TMC_2209.TMC_2209_StepperDriver import *
from src.TMC_2209._TMC_2209_GPIO_board import Board
except ModuleNotFoundError:
from TMC_2209.TMC_2209_StepperDriver import *
from TMC_2209._TMC_2209_GPIO_board import Board


print("---")
Expand All @@ -25,9 +27,11 @@
# initiate the TMC_2209 class
# use your pins for pin_en, pin_step, pin_dir here
#-----------------------------------------------------------------------
if BOARD == "RASPBERRY_PI":
if BOARD == Board.RASPBERRY_PI:
tmc = TMC_2209(21, 16, 20)
elif BOARD == "NVIDIA_JETSON":
elif BOARD == Board.RASPBERRY_PI5:
tmc = TMC_2209(21, 16, 20, serialport="/dev/ttyAMA0")
elif BOARD == Board.NVIDIA_JETSON:
tmc = TMC_2209(13, 6, 5, serialport="/dev/ttyTHS1")
else:
# just in case
Expand Down
8 changes: 6 additions & 2 deletions demo/demo_script_02_pin_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
import time
try:
from src.TMC_2209.TMC_2209_StepperDriver import *
from src.TMC_2209._TMC_2209_GPIO_board import Board
except ModuleNotFoundError:
from TMC_2209.TMC_2209_StepperDriver import *
from TMC_2209._TMC_2209_GPIO_board import Board


print("---")
Expand All @@ -25,9 +27,11 @@
# initiate the TMC_2209 class
# use your pins for pin_en, pin_step, pin_dir here
#-----------------------------------------------------------------------
if BOARD == "RASPBERRY_PI":
if BOARD == Board.RASPBERRY_PI:
tmc = TMC_2209(21, 16, 20)
elif BOARD == "NVIDIA_JETSON":
elif BOARD == Board.RASPBERRY_PI5:
tmc = TMC_2209(21, 16, 20, serialport="/dev/ttyAMA0")
elif BOARD == Board.NVIDIA_JETSON:
tmc = TMC_2209(13, 6, 5, serialport="/dev/ttyTHS1")
else:
# just in case
Expand Down
8 changes: 6 additions & 2 deletions demo/demo_script_03_basic_movement.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
import time
try:
from src.TMC_2209.TMC_2209_StepperDriver import *
from src.TMC_2209._TMC_2209_GPIO_board import Board
except ModuleNotFoundError:
from TMC_2209.TMC_2209_StepperDriver import *
from TMC_2209._TMC_2209_GPIO_board import Board


print("---")
Expand All @@ -25,9 +27,11 @@
# initiate the TMC_2209 class
# use your pins for pin_en, pin_step, pin_dir here
#-----------------------------------------------------------------------
if BOARD == "RASPBERRY_PI":
if BOARD == Board.RASPBERRY_PI:
tmc = TMC_2209(21, 16, 20, loglevel=Loglevel.DEBUG)
elif BOARD == "NVIDIA_JETSON":
elif BOARD == Board.RASPBERRY_PI5:
tmc = TMC_2209(21, 16, 20, serialport="/dev/ttyAMA0", loglevel=Loglevel.DEBUG)
elif BOARD == Board.NVIDIA_JETSON:
tmc = TMC_2209(13, 6, 5, serialport="/dev/ttyTHS1", loglevel=Loglevel.DEBUG)
else:
# just in case
Expand Down
14 changes: 9 additions & 5 deletions demo/demo_script_04_stallguard.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
import time
try:
from src.TMC_2209.TMC_2209_StepperDriver import *
from src.TMC_2209._TMC_2209_GPIO_board import Board
except ModuleNotFoundError:
from TMC_2209.TMC_2209_StepperDriver import *
from TMC_2209._TMC_2209_GPIO_board import Board


print("---")
Expand All @@ -25,13 +27,15 @@
# initiate the TMC_2209 class
# use your pins for pin_en, pin_step, pin_dir here
#-----------------------------------------------------------------------
if BOARD == "NVIDIA_JETSON":
if BOARD == Board.NVIDIA_JETSON:
raise NotImplementedError('''
Not implemented. Needs refinement.\nNvidia Jetson has nuances with the parameter pull_up_down for pin_stallguard:
https://github.com/NVIDIA/jetson-gpio/issues/5''')

if BOARD == "RASPBERRY_PI":
Not implemented. Needs refinement.\n
Nvidia Jetson has nuances with the parameter pull_up_down for pin_stallguard:
https://github.com/NVIDIA/jetson-gpio/issues/5''')
if BOARD == Board.RASPBERRY_PI:
tmc = TMC_2209(21, 16, 20)
elif BOARD == Board.RASPBERRY_PI5:
tmc = TMC_2209(21, 16, 20, serialport="/dev/ttyAMA0")
else:
# just in case
tmc = TMC_2209(21, 16, 20)
Expand Down
8 changes: 6 additions & 2 deletions demo/demo_script_05_vactual.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
import time
try:
from src.TMC_2209.TMC_2209_StepperDriver import *
from src.TMC_2209._TMC_2209_GPIO_board import Board
except ModuleNotFoundError:
from TMC_2209.TMC_2209_StepperDriver import *
from TMC_2209._TMC_2209_GPIO_board import Board


print("---")
Expand All @@ -25,9 +27,11 @@
# initiate the TMC_2209 class
# use your pin for pin_en here
#-----------------------------------------------------------------------
if BOARD == "RASPBERRY_PI":
if BOARD == Board.RASPBERRY_PI:
tmc = TMC_2209(21, 16, 20)
elif BOARD == "NVIDIA_JETSON":
elif BOARD == Board.RASPBERRY_PI5:
tmc = TMC_2209(21, 16, 20, serialport="/dev/ttyAMA0")
elif BOARD == Board.NVIDIA_JETSON:
tmc = TMC_2209(13, 6, 5, serialport="/dev/ttyTHS1")
else:
# just in case
Expand Down
10 changes: 8 additions & 2 deletions demo/demo_script_06_multiple_drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
#pylint: disable=unused-import
#pylint: disable=duplicate-code
#pylint: disable=broad-exception-raised
#pylint: disable=no-else-raise
"""
test file for testing multiple drivers via one UART connection
"""

import time
try:
from src.TMC_2209.TMC_2209_StepperDriver import *
from src.TMC_2209._TMC_2209_GPIO_board import Board
except ModuleNotFoundError:
from TMC_2209.TMC_2209_StepperDriver import *
from TMC_2209._TMC_2209_GPIO_board import Board


print("---")
Expand All @@ -27,10 +30,13 @@
# use your pins for pin_en, pin_step, pin_dir here
#-----------------------------------------------------------------------
# Multiple driver not tested
if BOARD == "RASPBERRY_PI":
if BOARD == Board.RASPBERRY_PI:
tmc1 = TMC_2209(21, 16, 20, driver_address=0)
tmc2 = TMC_2209(26, 13, 19, driver_address=1)
elif BOARD == "NVIDIA_JETSON":
elif BOARD == Board.RASPBERRY_PI5:
tmc1 = TMC_2209(21, 16, 20, serialport="/dev/ttyAMA0", driver_address=0)
tmc2 = TMC_2209(26, 13, 19, serialport="/dev/ttyAMA0", driver_address=1)
elif BOARD == Board.NVIDIA_JETSON:
# tmc1 = TMC_2209(13, 6, 5, serialport="/dev/ttyTHS1", driver_address=0)
raise Exception("Not tested for Nvidia Jetson, use with caution")
else:
Expand Down
8 changes: 6 additions & 2 deletions demo/demo_script_07_threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
import time
try:
from src.TMC_2209.TMC_2209_StepperDriver import *
from src.TMC_2209._TMC_2209_GPIO_board import Board
except ModuleNotFoundError:
from TMC_2209.TMC_2209_StepperDriver import *
from TMC_2209._TMC_2209_GPIO_board import Board

print("---")
print("SCRIPT START")
Expand All @@ -23,9 +25,11 @@
# initiate the TMC_2209 class
# use your pins for pin_en, pin_step, pin_dir here
#-----------------------------------------------------------------------
if BOARD == "RASPBERRY_PI":
if BOARD == Board.RASPBERRY_PI:
tmc1 = TMC_2209(21, 16, 20)
elif BOARD == "NVIDIA_JETSON":
elif BOARD == Board.RASPBERRY_PI5:
tmc1 = TMC_2209(21, 16, 20, serialport="/dev/ttyAMA0")
elif BOARD == Board.NVIDIA_JETSON:
tmc1 = TMC_2209(13, 6, 5, serialport="/dev/ttyTHS1")
else:
# just in case
Expand Down
9 changes: 7 additions & 2 deletions demo/demo_script_08_log_to_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
import logging
try:
from src.TMC_2209.TMC_2209_StepperDriver import *
from src.TMC_2209._TMC_2209_GPIO_board import Board
except ModuleNotFoundError:
from TMC_2209.TMC_2209_StepperDriver import *
from TMC_2209._TMC_2209_GPIO_board import Board



Expand All @@ -36,10 +38,13 @@
# initiate the TMC_2209 class
# use your pins for pin_en, pin_step, pin_dir here
#-----------------------------------------------------------------------
if BOARD == "RASPBERRY_PI":
if BOARD == Board.RASPBERRY_PI:
tmc = TMC_2209(21, 16, 20, skip_uart_init=True,
loglevel=loglevel, log_handlers=[logging_handler], log_formatter=logformatter)
elif BOARD == "NVIDIA_JETSON":
elif BOARD == Board.RASPBERRY_PI5:
tmc = TMC_2209(21, 16, 20, serialport="/dev/ttyAMA0", skip_uart_init=True,
loglevel=loglevel, log_handlers=[logging_handler], log_formatter=logformatter)
elif BOARD == Board.NVIDIA_JETSON:
tmc = TMC_2209(13, 6, 5, serialport="/dev/ttyTHS1", skip_uart_init=True,
loglevel=loglevel, log_handlers=[logging_handler], log_formatter=logformatter)
else:
Expand Down
15 changes: 12 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = TMC_2209_Raspberry_Pi
version = 0.4.5
version = 0.5
author = Christian Köhlke
author_email = christian@koehlke.de
description = this is a Python libary to drive a stepper motor with a Trinamic TMC2209 stepper driver and a Raspberry Pi
Expand All @@ -24,8 +24,17 @@ package_dir =
packages = find:
python_requires = >=3.7
install_requires =
RPi.GPIO
pyserial

[options.packages.find]
where = src
where = src

[options.extras_require]
RASPBERRY_PI =
RPi.GPIO
RASPBERRY_PI5 =
gpiozero
NVIDIA_JETSON =
Jetson.GPIO
LUCKFOX_PICO =
python-periphery
Loading

0 comments on commit 734c93e

Please sign in to comment.