Anyone figured out how to get Trinamic's TMC5160 drivers working with LinuxCNC?

More
26 Dec 2023 09:02 - 26 Dec 2023 09:07 #289071 by rajhlinux
Finally some big beefy TMC5160 driver boards out, supports 60 DC Volts and 6 Amps, could be used for CNC metal milling:

www.amazon.com/BIGTREETECH-TMC5160T-Step...81-b373-0e5c1a776d5d

biqu.equipment/products/bigtreetech-tmc5...riant=40447047860322

I really want to use them on the PM-25mv bench mill converted to CNC due to it's "stealthchop" and alike features, would be used for the X and Y-axis closed-loop stepper motors, I think Z-axis should be ok which doesn't have heavy spindle motor.

Anyone figured out how to get the TMC5160 working with LinuxCNC?
I plan on getting a MESA card...

Any advice would be helpful.

Thanks.

Attachments:
Last edit: 26 Dec 2023 09:07 by rajhlinux.

Please Log in or Create an account to join the conversation.

  • tommylight
  • tommylight's Avatar
  • Away
  • Moderator
  • Moderator
More
26 Dec 2023 09:21 #289075 by tommylight
Nothing to figure out there, 5160T plus works with step/dir so can be used even with parallel port.
The other types/models use SPI, no idea if those can be used with RPI, but should also be usable with a 3D printer board and Remora:
forum.linuxcnc.org/18-computer/42276-rem...ller-via-spi?start=0

Please Log in or Create an account to join the conversation.

More
26 Dec 2023 19:54 #289108 by cakeslob
SPI control mode, where you can use an encoder, no one is currently using this to control the steppers, and thus getting closed loop. i havent seen this mode supported anywhere really, except TMC sdk stuff.

Step/dir control mode - there is a user with the milo project using that driver, he is using the cfg jumpers to set the micro steps and step/dir for steps. connects like a normal driver.

step/dir mode with SPI cfg - used step/dir to control and SPI to configure the driver, this is what most 3d printer stuff uses. I havent seen this supported by linuxcnc before, with remora or otherwise
The following user(s) said Thank You: tommylight

Please Log in or Create an account to join the conversation.

More
18 Feb 2024 03:14 - 18 Feb 2024 03:37 #293664 by pl.studentoflife
I'm using those drivers currently. They are quite a beasty. It is possible to use them in standalone mode, but  i would advice against it if your motor is relatively low current (below 5A). I burnt one motor this way as setup of IRUN (with CFG pins) is half range up to full power - this is probably linear scale so 5 -10 A.

Best option is to have additional SPI capable device (arduino, rasperry pi, even 8081 probably would do) just to configure the driver(s).
Connect DIR/Step (and maybe DIAGs) to parallel/mesa card. 

Quite important to supply all 3 power inputs (took me some time to get figure this out)
- main board HV (0-60) 
- stepstick adapter VIO for logic (5V)
- stepstick adapter VM/ 24V (it can be lower - i'm  using 19.5V/4A now). As mentioned this input is exposed as VM on stepstick adapter - it should be used to  supply colling FAN but is also used to supply TMC internal voltage regulator and then some internal circuitry !!! 
As a observation it looks like this input require some power too like few amps (my 24V/1.6A died when suppling 3 drivers- was good with one).
 
Next step is just to tune parameters and you are set.

 
Last edit: 18 Feb 2024 03:37 by pl.studentoflife.
The following user(s) said Thank You: tommylight

Please Log in or Create an account to join the conversation.

  • tommylight
  • tommylight's Avatar
  • Away
  • Moderator
  • Moderator
More
18 Feb 2024 13:46 #293682 by tommylight
Some more info, just in case:
These heat a lot when enabled, use coolers, big ones, preferably with fans.
Stealthchop and (insert name here, can not recall right now) make motors run quietly but also introduce a bit of positioning error, infos are on manuals. Can also cause huge vibrations at higher speeds.
Been over a year since i dealt with 2208 and 2209, so a bit fuzzy on the details.

Please Log in or Create an account to join the conversation.

More
27 Jun 2024 14:33 #303902 by chrisfischer
I'm looking to see if anyone has used the trinamic drivers for stall guard to detect skipped steps during the cut but also to do sensorless homing. I'm surprised I don't see anyone mention this.

Please Log in or Create an account to join the conversation.

More
08 Sep 2024 13:36 - 08 Sep 2024 13:38 #309653 by BICHLER
Attachments:
Last edit: 08 Sep 2024 13:38 by BICHLER.

Please Log in or Create an account to join the conversation.

More
23 Dec 2024 21:17 #317231 by 3404gerber
Hi all,

[Introduction, skip this if you're in a hurry]

I have some experience with the TMC5160 and FluidNC, but I had issues trying to run them at higher velocities, at around 200mm/sec and with 1000mm/s² acceleration. The axis were noisy during ramp up/down; I have the feeling that it is related to the grbl step generation, as they run way smoother with the internal ramp generator. It is probably related to the fact that the velocity is updated at ~20khz in the TMC, and "only" at 100Hz by default in FluidNC.

I also tried, with my very limited coding knowledge, to run them in full SPI mode with FluidNC. It was let's say "sort of moving", but I didn't find a way to make it reliable. One of the problem I encountered was that the internal clock has quite a big tolerance (+-3%) and it became hard to synchronize the axis as they weren't always exactly where they were suppose to be. Coding of some kind of feedback to compensate was too challenging for me.

Then I looked for other solution and I came across Linuxcnc and decided to give it a try.

[End of the introduction]

I started a couple of days ago, and I'm learning and progressing slowly. My configuration is a PI400, connected directly to the TMC via SPI. Just one for now, but the plan is to "daisy-chain" as much as needed, remembering that more drives means more cable, meaning slower SPI speed and longer read/write time. To get an idea, 5 drives serial connected would need 2x5x40bits for reading (reading needs 2 cycle) and 2x5x40bits for writing (1 for direction, 1 for speed), so @2MHz SPI speed that would be at least 0.4ms just for the communication. I have no experience with LCNC and don't know if the servo thread can still be configured at 1ms with this. I guess I'll find out later.

For the code, as I already wrote, I'm more a copy/paster than a coder. And it works perfectly in this case, as nearly all I need have been done before. :) I use following projects as reference:

-Remora-spi: uses LCNC data to send velocity command to a slave device over SPI. Sounds like a perfect match!
-TMC libraries: there is the Trinamic-library written in C and the TMCStepper library in cpp which is more complete. I'm picking information in the second to adjust the first one.
-FluidNC: the source code is a good example about how and what to configure in the drives, with also a good basis for the daisy-chain code. I already spent hours on this, that's why I'm using it, but you can also take a 3D printer firmware, as most of them support TMC drives.

So far I'm just able to move 1 axis back and forth, without any feedback; just a joint vel-cmd sent to the drive. It works as expected, meaning with a position error of 1 or 2%. Next step will be to close the loop with a position PID (position feedback is the step count in the TMC drive). Then I'll have to test with 2 drives, add error management, determine the variable that will be in the INI file and finally clean up the mess code. It will probably take me months to have something usable, but as far as I can see, this topic is not the most active on the forum, so I don't have much pressure! :)

Here are a few question that maybe someone can help me to answer:
  1. The Remora component includes a PID-Loop, but there is also a PID component in LCNC; which option makes more sense: integrate one in the comp or use the standard one?
  2. The TMC have a poor on-board reference clock with accuracy of +-3% according to datasheet. Would it be a good idea to calculate the speed based on two readings and thread time and make a velocity correction with the data? I have the feeling that without it the position loop will unnecessary oscillate all the time, as the commanded velocity is always off. I'd see something like a "permanent" correction of the internal clock; by permanent I think about something like an auto adjusting FF0 variable that initialize at 1 when LCNC is started and the corrects itself if the velocity error is bigger than, let's say 0.1% or so.
  3. In full SPI mode, the Step/Dir inputs become REFL/REFR. I didn't make any search so far, but can someone tell me how hard it would be to use the TMC capability to latch a position on REFL/REFR input to home an axis? I guess it will require a custom Home comp? And could this new comp call a function in my TMC5160 comp, for example a read_Xlatch() that would write the latched position in a HAL variable? Everything is so new to me and there is so much to learn...
Thanks in advance!

Please Log in or Create an account to join the conversation.

More
25 Dec 2024 09:02 #317330 by stefan63
STEP/DIR is the way to go and maybe the Makerbase TMC5160 board is preferable since you can set your parameters with jumpers.
 
Attachments:

Please Log in or Create an account to join the conversation.

More
01 Feb 2025 15:46 - 06 Feb 2025 17:38 #320329 by 3404gerber
I did some tests and ended up with a working comp. All it does is sending the registers to the drivers and then taking a velocity command as input and giving a position feedback as output. For now the settings are set by defining registers values as parameters, which isn't the easiest way to do it. It would probably not be too difficult to code a GUI to change the registers values according to more "readable" parameters. The comp also uses the bcm2835 library, which isn't compatible with RPI5 as far as I know. I'd like to change the code to directly write to spidev one day.

Here is a short video showing 3 motors moving: Link to youtube video
Edit: added a second video with physical axis attached to the drivers: Link to youtube video

The 4 drivers are connected in daisy chained mode and communicate with the Pi at 3.125MHz. All the read, write and PID stuff is done in the servo thread set at 1ms. Just using 4 pins for SPI and 1 as enable, there are plenty left for the other functions.

But there is more to explore; the TMC5160 has an encoder input and rather than reading the internal step counter, one could read the encoder counter as position feedback. There are also reference inputs that can be used directly on the board, and the possibility to do sensorless homing. A 50$ RPi, a couple of 15$ stepper driver and some cheap 3.3V->24V level shifter; could become a interesting poor man's closed-loop-stepper CNC controller.
Last edit: 06 Feb 2025 17:38 by 3404gerber.

Please Log in or Create an account to join the conversation.

Moderators: PCWjmelson
Time to create page: 0.110 seconds
Powered by Kunena Forum