Skip to content

Commit

Permalink
Merge pull request #86 from Chr157i4n/dev
Browse files Browse the repository at this point in the history
version 0.5.6
  • Loading branch information
Chr157i4n authored Dec 19, 2024
2 parents c397cb7 + badb658 commit 9e39949
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 40 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.9", "3.12"]
python-version: ["3.7", "3.9", "3.13"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -42,7 +42,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.9", "3.12"]
python-version: ["3.7", "3.9", "3.13"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## version 0.5.6

- fixed return status instead of hardcoded True in test_uart
- refactored test_dir_step_en function
- fixed links in readme
- switched to python 3.13 in unittests

## version 0.5.5

- changed Nvidia Jetson detection
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ So if you move the motor with high speed using this library the motor will lose
Tested on a [Bigtreetech TMC2209 V1.2](https://github.com/bigtreetech/BIGTREETECH-Stepper-Motor-Driver/tree/master/TMC2209/V1.2) and [Bigtreetech TMC2209 V1.3](https://github.com/bigtreetech/BIGTREETECH-Stepper-Motor-Driver/tree/master/TMC2209/V1.3).

It has a rSense of 110 mOhm and it uses one Pin (PDN_UART) for UART RX and TX.
So the PD_UART-Pin needs to be connected to the Raspberrry Pis RX-Pin directly and to the TX-Pin with an 1kOhm resistor.
So the PDN_UART-Pin needs to be connected to the Raspberrry Pis RX-Pin directly and to the TX-Pin with an 1kOhm resistor.
You can read more about this in the datasheet from Trinamic.

Because the TMC2209 uses one shared pin for transmit and receive in the UART communication line, the Raspberry Pi also receives what it sends.
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = TMC_2209_Raspberry_Pi
version = 0.5.5
version = 0.5.6
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 Down
2 changes: 1 addition & 1 deletion src/TMC_2209/TMC_2209_StepperDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class TMC_2209:
)

from ._TMC_2209_test import (
test_dir_step_en, test_step, test_uart, test_stallguard_threshold
test_pin, test_dir_step_en, test_step, test_uart, test_stallguard_threshold
)

BOARD = BOARD
Expand Down
63 changes: 28 additions & 35 deletions src/TMC_2209/_TMC_2209_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,49 +16,42 @@



def test_dir_step_en(self):
"""tests the EN, DIR and STEP pin
def test_pin(self, pin, ioin_reg):
"""tests one pin
this sets the EN, DIR and STEP pin to HIGH, LOW and HIGH
and checks the IOIN Register of the TMC meanwhile
this function checks the connection to a pin
by toggling it and reading the IOIN register
"""
pin_dir_ok = pin_step_ok = pin_en_ok = True
pin_ok = True

TMC_gpio.gpio_output(self._pin_step, Gpio.HIGH)
TMC_gpio.gpio_output(self._pin_dir, Gpio.HIGH)
TMC_gpio.gpio_output(self._pin_step, Gpio.HIGH)
TMC_gpio.gpio_output(self._pin_en, Gpio.HIGH)
time.sleep(0.1)
ioin = self.read_ioin()
if not ioin & tmc_reg.io_dir:
pin_dir_ok = False
if not ioin & tmc_reg.io_step:
pin_step_ok = False
if not ioin & tmc_reg.io_enn:
pin_en_ok = False

TMC_gpio.gpio_output(self._pin_step, Gpio.LOW)
TMC_gpio.gpio_output(self._pin_dir, Gpio.LOW)
TMC_gpio.gpio_output(self._pin_en, Gpio.LOW)
time.sleep(0.1)

ioin = self.read_ioin()
if ioin & tmc_reg.io_dir:
pin_dir_ok = False
if ioin & tmc_reg.io_step:
pin_step_ok = False
if ioin & tmc_reg.io_enn:
pin_en_ok = False
if not ioin & ioin_reg:
pin_ok = False

TMC_gpio.gpio_output(self._pin_step, Gpio.HIGH)
TMC_gpio.gpio_output(self._pin_dir, Gpio.HIGH)
TMC_gpio.gpio_output(self._pin_en, Gpio.HIGH)
TMC_gpio.gpio_output(pin, Gpio.LOW)
time.sleep(0.1)

ioin = self.read_ioin()
if not ioin & tmc_reg.io_dir:
pin_dir_ok = False
if not ioin & tmc_reg.io_step:
pin_step_ok = False
if not ioin & tmc_reg.io_enn:
pin_en_ok = False
if ioin & ioin_reg:
pin_ok = False

return pin_ok



def test_dir_step_en(self):
"""tests the EN, DIR and STEP pin
this sets the EN, DIR and STEP pin to HIGH, LOW and HIGH
and checks the IOIN Register of the TMC meanwhile
"""
pin_dir_ok = self.test_pin(self._pin_dir, tmc_reg.io_dir)
pin_step_ok = self.test_pin(self._pin_step, tmc_reg.io_step)
pin_en_ok = self.test_pin(self._pin_en, tmc_reg.io_enn)

self.set_motor_enabled(False)

Expand Down Expand Up @@ -146,7 +139,7 @@ def test_uart(self):
self.tmc_logger.log("UART connection: not OK", Loglevel.ERROR)

self.tmc_logger.log("---")
return True
return status



Expand Down

0 comments on commit 9e39949

Please sign in to comment.