janelia-arduino / TMC2209

The TMC2209 is an ultra-silent motor driver IC for two phase stepper motors with both UART serial and step and direction interfaces.
Other
173 stars 26 forks source link

TMC2209 + RP2040 chip - no way to get it working #78

Open fryc88 opened 1 month ago

fryc88 commented 1 month ago

At the start i must say i'm total new with arduino ide, so i might be doing something wrong, however i'm trying to use 3d printer board for other purpose, but by all means i can't get it working. There's RP2040 chip built in, 2x TMC2209, so i would assume tmc2209 lib for arduino ide. I'm not bothered about two, i'm not even bothered about using them in full uart mode, just normal step/dir would be fine too, but that way i couldn't get it working either [https://github.com/FYSETC/FYSETC-ERB/blob/main/V1.0/hardware/Schematic.pdf](board schematics)

So from examples i've tried software serial, that wont even compile because of lack of soft serial library (?). image Any other options will give me similar results while trying to compile, all errors are related to lack of serial.

image

Could you tell me if that's related to RP2040 & you addon missing something, or am i missing something here?

peterpolidoro commented 1 month ago

I have never used one of these boards, but I am curious to see if we can get it working.

I added an example examples/UnidirectionalCommunication/TestRP2040/ and bumped this library version to 9.4.1. Please try this example and see if you can get it to run on your board.

The schematic shows that only a single RP2040 UART pin is connected to each TMC2209 so only unidirectional commands will work. Since there are no RX pins the RP2040 cannot receive any information from each TMC2209.

The UART pins are not the usual pins reserved for UART0 and UART1 so you can use SerialPIO instead of SerialUART. SoftwareSerial could work, but SerialPIO should be much faster and is preferable.

You will need to add your own code if you want to use the step and direction pins on the RP2040. My example code simply calls moveAtVelocity to test to see if it can get the motors to move. I do not know how large of motors you are using and your power supply voltage so you may need to adjust the run current.

fryc88 commented 1 month ago

Thank you for your effort. When I'll get home I'll try to flash and test it. I almost passed on this board, spent most of day yesterday and some time today and couldn't get anything to work there.

On Sun, 14 Jul 2024 at 16:23, Peter Polidoro @.***> wrote:

I have never used one of these boards, but I am curious to see if we can get it working.

I added an example examples/UnidirectionalCommunication/TestRP2040/ and bumped this library version to 9.4.1. Please try this example and see if you can get it to run on your board.

The schematic shows that only a single RP2040 UART pin is connected to each TMC2209 so only unidirectional commands will work. Since there are no RX pins the RP2040 cannot receive any information from each TMC2209.

The UART pins are not the usual pins reserved for UART0 and UART1 so you can use SerialPIO instead of SerialUART. SoftwareSerial could work, but SerialPIO should be much faster and is preferable.

You will need to add your own code if you want to use the step and direction pins on the RP2040. My example code simply calls moveAtVelocity to test to see if it can get the motors to move. I do not know how large of motors you are using and your power supply voltage so you may need to adjust the run current.

— Reply to this email directly, view it on GitHub https://github.com/janelia-arduino/TMC2209/issues/78#issuecomment-2227385661, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMB23JFTBTQHRPH7PGQ3TRTZMKJY5AVCNFSM6AAAAABK3ADM5GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMRXGM4DKNRWGE . You are receiving this because you authored the thread.Message ID: @.***>

fryc88 commented 1 month ago

Hi, I tried to compile above, but again i have serial related error: image

I can't even see any libraries for SerialPIO or SoftwareSerial, but neither of them work. Is there anything else that i need to add to Arduino IDE in order to use above?

EDIT: I actually added another boards based on RP2040 chips and tried couple of them, and one of them goes through the compilation with your example, I'll flash it and see what happens next.

Thing that I'm trying to build is respooler for 3d printer. It was built using simplified way, however I don't have necessarily components, that's why I tried to use what I had in my hands. Motor will be not-too-large nema17, for now it's all on bench power supply, so at the end I'll figure out voltage and current what I need for it. I also know in 3d printers firmwares, current on this kind of boards can be set via software. https://makerworld.com/en/models/448008?from=search#profileId-354782

fryc88 commented 1 month ago

Ok, so I've tried literally all boards from this library: https://github.com/earlephilhower/arduino-pico/tree/master

Neither of them do anything, however only this library for 2040 does go through the compilation in Arduino IDE. There are other two rp2040 libraries that I've found available, but neither of them will compile, both showing serial issue. Now I'm thinking why is that happening, I don't fully understand differences between boards, I would assume chip is chip, and as long as hardware connections are set properly then it should work, but it looks like I'm very wrong. I did ask author of that library for any suggestions, maybe he will have some ideas, as I'm pretty much clueless at this stage.

peterpolidoro commented 1 month ago

Sounds like the Arduino IDE might not be setup properly. You need to make sure you have the correct board and dependencies.

You can also try using platformio instead of the Arduino IDE. I have an example platformio file at the root of the directory. That should automatically download the dependencies for you.