diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2bec327..1b2d85e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 }} @@ -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 }} diff --git a/CHANGELOG.md b/CHANGELOG.md index a915a2c..8e59cf2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 456469e..d19ae1d 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/setup.cfg b/setup.cfg index 5858874..28db196 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 diff --git a/src/TMC_2209/TMC_2209_StepperDriver.py b/src/TMC_2209/TMC_2209_StepperDriver.py index 3f29248..0d0798e 100644 --- a/src/TMC_2209/TMC_2209_StepperDriver.py +++ b/src/TMC_2209/TMC_2209_StepperDriver.py @@ -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 diff --git a/src/TMC_2209/_TMC_2209_test.py b/src/TMC_2209/_TMC_2209_test.py index 8c89105..400cd8e 100644 --- a/src/TMC_2209/_TMC_2209_test.py +++ b/src/TMC_2209/_TMC_2209_test.py @@ -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) @@ -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