Help with UART on TCM2209 with Micropython and Pico

Hi All

Bare with me here, quite new to everything…

I am trying to learn how to drive stepper motors with MicroPython using TMC2209 v3. So far I figured out how to drive it with steps… And then started learning PWM which lead me down the UART path (to set steps), this is where I’ve hit a wall.

So at this stage I am just trying to understand how to work with UART using TMC2209. I am using Pico and MicroPython (sys.version: 3.4.0; MicroPython v1.22.1 on 2024-01-05)

Code: Select all

from machine import UART, Pin
import utime

uart = UART(0, baudrate=115200, tx=Pin(0), rx=Pin(1))

uart.write(b"?V\n")

utime.sleep(1)

print("UART Response:", uart.readline())

Response is always “None”. I’ve spent hours trying this and that and I am not having any luck. Any advice would be super appreciated.

Regarding wiring: I am using 1k resistor on GP0, both GP0 and GP1 are jumper-wired to TMC RX pin.

Thanks!

wouldn’t it be easier to just use an existing micropython library for the TCM2209? Your code example does not send a valid uart-request to the chip, so you cannot expect any response.

Yes, it would be a whole lot easier, I’m not sure there is a library for Micropython…

…and that’s why I am here.

Oh, just use google, it gives me a number of hits. No idea about the quality though and you will probably have to port it to the Pico (e.g. change pin-names and so on).

If you are interested in doing it yourself, have a look at the datasheet. It explains in details the bits and bytes you have to send via UART to receive a response.

Fantastic, thank you for your help. I didn’t realise google was an options.