From bca8d3b4bded02af4c4b230570029d4eaa284c7d Mon Sep 17 00:00:00 2001 From: bp Date: Mon, 20 Jan 2025 15:31:42 +0100 Subject: [PATCH] Examples/TMC9660: Add GPIO demo for TMC9660-3PH-EVAL --- .../param/with_landungsbruecke/demo_gpio.py | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 examples/evalboards/TMC9660/param/with_landungsbruecke/demo_gpio.py diff --git a/examples/evalboards/TMC9660/param/with_landungsbruecke/demo_gpio.py b/examples/evalboards/TMC9660/param/with_landungsbruecke/demo_gpio.py new file mode 100644 index 0000000..3e96144 --- /dev/null +++ b/examples/evalboards/TMC9660/param/with_landungsbruecke/demo_gpio.py @@ -0,0 +1,47 @@ +################################################################################ +# Copyright © 2024 Analog Devices Inc. All Rights Reserved. +# This software is proprietary to Analog Devices, Inc. and its licensors. +################################################################################ +"""Demo on how to read and write digital IOs. + +In order for the output to work, the following configuration has to be changed in the ioconfig_tmc9660-3ph-eval.toml file: +```toml +[gpio18] +type = "output" # "input", "output", "analog" (optional) (analog only supported on GPIO 2-5) +output_value = true # false, true (optional) +``` + +On Windows the config upload and app start can be done with: + python ubltools_1.0.1/ubl_evalsystem_wrapper.py write config ubltools_1.0.1/ioconfig_tmc9660-3ph-eval.toml + python ubltools_1.0.1/ubl_evalsystem_wrapper.py start +Where needs to be replaced by the COM port of the Landungsbruecke. + +Important: first connect USB and then power the TMC9660-3PH-EVAL. + + +-----+ +-------------------+ + USB | |==| | + -------| |==| | +Connected to the machine | |==| | +running this script. |LB |==|TMC9660-3PH-EVAL | + +-----+ +-------------------+ + +""" + +from pytrinamic.connections import ConnectionManager +from pytrinamic.ic import TMC9660 +from pytrinamic.evalboards import TMC9660_3PH_eval + + +cm = ConnectionManager() + +with cm.connect() as my_interface: + + tmc9660_device = TMC9660_3PH_eval(my_interface) + + # Get the state of the digital input GPIO17 + print(f"GPIO17: {tmc9660_device.get_digital_input(17)}") + print(f"GPIO17: {tmc9660_device.get_digital_input(TMC9660.IO.GPIO17)}") + + # Set the digital output GPIO18 to True and then to False + tmc9660_device.set_digital_output(18, True) + tmc9660_device.set_digital_output(TMC9660.IO.GPIO18, False)