MarlinFirmware / Marlin

Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
https://marlinfw.org
GNU General Public License v3.0
16.34k stars 19.26k forks source link

[FR] Support for Trinamic TMC2660 #8138

Closed alexxy closed 4 years ago

alexxy commented 7 years ago

Hi all!

I have a Azteeg X5 GT board with TMC2660 (Bigfoot BSD2660), and seems like Marlin has support for some types of TMC drivers. How to enable TMC2660?

Spawn32 commented 7 years ago

Did you get the TMC2660's working ? I am designing a new controller board that uses them, so would be nice to know :)

alexxy commented 7 years ago

Currently no. Seems like we need new lib to get them working =)

Spawn32 commented 7 years ago

To bad, have a look at the bottom of https://github.com/MarlinFirmware/Marlin/pull/8063#issuecomment-340261846 to see what i am working on :)

teemuatlut commented 7 years ago

Yea the drivers need a new library for Marlin to be able to communicate with them. I could expand my TMC2130 or TMC2208 libraries to support them but I don't have the drivers to test. Nor really a board that would support the layout.

alexxy commented 7 years ago

@teemuatlut if you extend you're lib i'd be glad to test =) Currently i have working Marlin on Azteeg X5 GT (standart drivers work, but i have 2660 ones) #8139

Spawn32 commented 7 years ago

And i can test when i get my board ready, probably be about 2 weeks... Have a bootloader sorted, but will need a HAL and TMC2660 drivers :/

alexxy commented 7 years ago

@Spawn32 stm32 based board? I actualy have an idea to create stm32 board with 6-8 steppers =)

Spawn32 commented 7 years ago

STM32F7 and 6x TMC2660 :)

alexxy commented 7 years ago

Its a monster that can even run linux

teemuatlut commented 7 years ago

I'm not too keen on developing for something I don't actually have. While it may take me from a couple of days to a week to get the library running, it'll be months or years of supporting it. Old and new features that need testing, bug fixes, interacting with users and helping them solve problems. I don't really want to put myself in a position where my best is only a guess. I'll try contacting Panucatt and see if they'd be interested in providing samples so that I may bring Marlin/Arduino support for their drivers.

alexxy commented 7 years ago

Actualy seems like duet3d board uses same drivers and very similar setup

Spawn32 commented 7 years ago

Yes, the Duet3d uses the TMC2660's... DuetWifi_Schematic_v1.02.pdf

Roxy-3D commented 7 years ago

I'll try contacting Panucatt and see if they'd be interested in providing samples so that I may bring Marlin/Arduino support for their drivers.

@teemuatlut Roy has been very helpful trying to get an official 32-bit branch of Marlin going. When we were discussing how to seed the Marlin developers with 32-bit boards, it kind of felt like his preference was to use the Azteeg X5 GT 32bit Motion Controller as the reference platform. (It may be I'm just imagining that. But that is what I think.)

With the Azteeg X5 GT 32bit Motion Controller you can plug in the Bigfoot BSD2660 sub modules.

It says they are "Based on TMC2660. SPI setup and configuration including current limit and microstepping. 3A 30V. For 3D printing and CNC applications. Super quiet and smooth. 1/256 microstepping. "

Part of the reason I was pushing for the Re-ARM as the reference platform is because it would keep costs down. But we are now at the point where just one developer having an Azteeg X5 GT can make good progress. If you contact Roy, please include a link to this post so he knows I'm supportive. I should get around to sending him an updated status report also.

alexxy commented 7 years ago

Yeah, Azteeg X5 GT is interesting board. I already done pinout for marlin #8139 . Only thing missing is 2660 steppers.

teemuatlut commented 7 years ago

Quick update. I got a response from Roy at Panucatt and he was happy to provide me with the drivers, so now I'll need to create a new driver library to support the TMC2660. It'll likely be ready (as can be) before my drivers get here but you can test them before I can.

@Roxy-3D Roy asked me about the progress with LPC HAL and I gave him a brief summary but also said that you'd be contacting soon with a more in depth update about it. Hope you don't mind =)

Roxy-3D commented 7 years ago

I gave him a brief summary but also said that you'd be contacting soon with a more in depth update about it. Hope you don't mind =)

Not a problem! I'll try to do that in the next day or two...

Spawn32 commented 7 years ago

@Roxy-3D @teemuatlut and the rest of you:

Nice, is just a incredible job you guy's do here. thank you :)

Spawn32 commented 7 years ago

@teemuatlut Any news on TMC2660 ? 😃

teemuatlut commented 7 years ago

I think the hardware is on its' way so I could theoretically start with the library. I just have a bunch of other stuff too that I should be doing.

alexxy commented 6 years ago

Hi! Any news about this drivers?

alexborro commented 6 years ago

Someone using this driver could tell if the lack of StealthChop mode makes any difference. I mean, do you miss it?

Em 5 de dez de 2017 11:55, "Alexey Shvetsov" notifications@github.com escreveu:

Hi! Any news about this drivers?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/MarlinFirmware/Marlin/issues/8138#issuecomment-349310592, or mute the thread https://github.com/notifications/unsubscribe-auth/AE-ZE6dbimmv_UZDmS862LuLgkl0Yo6pks5s9UtDgaJpZM4QKH3t .

teemuatlut commented 6 years ago

@alexxy I've started working on a universal TMC driver library that would support 5 driver models. This is quite a big task and requires a completely new architecture inside the library to do it in a way that makes sense. That said, I did take a look at the TMC2660 communication information and it seems to differ a bit from the other drivers. Makes me think that they're a slightly older driver design.

Edit: Steppers are turning now so I've established basic communications.

alexxy commented 6 years ago

@cool are there some branch to test?

Spawn32 commented 6 years ago

Good work @teemuatlut looking forward to testing it :)

teemuatlut commented 6 years ago

@alexxy No not yet. I'll first try to get the library examples to work on TMC2660 as well as 2130, 2208, 2224 and 5130. The final Marlin integration on a basic level is actually quite simple and shouldn't take much time.

alexxy commented 6 years ago

@teemuatlut hows youre universal tmc lib going?

teemuatlut commented 6 years ago

TMC5130 and TMC2130 compile the Simple example. I've been busy with other tasks for a while now but the new library is on the agenda over the christmas holidays because I can't do much CAD work on the laptop. I've pretty much decided that TMC2660 has to be an entity on its' own because of a drastically different register structure. TMC2208 needs some fundamental changes to work properly.

alfredanil commented 6 years ago

@teemuatlut TMC 5130 has an integrated velocity ramp generator, do you plan to implement the ramp generator function as well? apart from standard trapezoidal ramp it also has a six point ramp function, which seems pretty cool. To test TMC2660 there is a readily available shield for Uno called TOS100 for Arduino and it can be purchased from Watterott Electronic for about 25 Euro. TMC2660 was also used in T-Bone cape for beagle bone (project available on GitHub) tried and tested lib available for all functions.

teemuatlut commented 6 years ago

I do have full support for Trinamic's TRAMS board in the works but it's been pushed back ever since the summer. But IIRC it did do movements and homing and other basic functions. Regarding the TMC2660, I have the bigfoot drivers from Panucatt and I've also got an Azteeg X5 GT to go along with them so testing is not a problem. I've already been able to communicate them and set the TOFF to have some movement. Mostly it's a matter of writing the methods in a more user friendly way.

teemuatlut commented 6 years ago

Some progress. Obviously not finished but you should be able to get the driver moving with toff(4); cs(10);.

Also see the Simple.ino example that's currently configured for TMC2660.

alexxy commented 6 years ago

@teemuatlut cool. Seems basic movement works for me

alexxy commented 6 years ago

Hi!

Seems like STM32F7 HAL added driver for TMC2660. Was this planned as generic driver for such type of TMC drivers?

jsondag commented 6 years ago

I'm currently running an azteeg xt GT with the TMC 2660 big foot drivers. Running smoothie currently. Would like to try marlin 2. Does anyone have this working well, and is there any documentation on how to get it going. I'm struggling to find any.

thinkyhead commented 6 years ago

@jsondag — There's no real documentation at this time. Basically, use these options in Configuration_adv.h (bugfix branch)…

/**
 * Enable this section if you have TMC26X motor drivers.
 * You will need to import the TMC26XStepper library into the Arduino IDE for this
 * (https://github.com/trinamic/TMC26XStepper.git)
 */
//#define HAVE_TMC26X
#if ENABLED(HAVE_TMC26X)  // Choose your axes here. This is mandatory!
  . . .
#endif // HAVE_TMC26X
jsondag commented 6 years ago

Thanks. Is there anywhere about how to compile for the azteeg? I saw something about using platformio but wasn’t quite sure how to go about that.

thinkyhead commented 6 years ago

Which Azteeg? I'm assuming you mean the Azteeg X5 GT.

Easiest way to get PlatformIO:

Then you can use the Tasks menu to build… image

image

…or upload… image

Use the PlaformIO Home button image to show the PlatformIO Home tab if you need to install additional board support.

alexxy commented 6 years ago

Ghm.. Does 2660 drivers works with TMC26XStepper? it seems like different driver.

Spawn32 commented 6 years ago

@alexxy Yes TMC26XStepper works for the 2660, in my F7 hal i have a slightly modified version, mostly since i use the STM32Generic and it needs the newer version of the I2C, doesn't like the Marlin version :)

Right now i dont have a working stepper anymore on my F7 Borg board, Timers in Marlin has been very modified the last month's and its broken, don even now where to begin, LOL

But, it will get sorted, and i will update the HW rev on the board ( a few blunders) an make a new batch + ad it to gihub :)

really hope @teemuatlut finds time to make a lib for the 2660 soon :)

alexxy commented 6 years ago

Ghm... Current TMC26XStepper doesnt compile on LPC (however i'll try to fix it) Seems like i have problem with SPI.h on LPC (missing definitions for

arm-none-eabi-g++ -o .pioenvs/LPC1768/libf3e/TMC26XStepper/TMC26XStepper.o -c -fno-rtti -fno-exceptions -std=gnu++11 -Os -ffunction-sections -fdata-sections -mthumb -nostdlib -mcpu=cortex-m3 -Os -mcpu=cortex-m3 -mthumb -ffreestanding -fsigned-char -fno-move-loop-invariants -fno-strict-aliasing --specs=nano.specs --specs=nosys.specs -MMD -MP -fmax-errors=5 -g -ggdb -DF_CPU=100000000L -DPLATFORMIO=30501 -DTARGET_LPC1768 -DU8G_HAL_LINKS -IMarlin/src/HAL/HAL_LPC1768/include -IMarlin/src/HAL/HAL_LPC1768/u8g -I.piolibdeps/TMC26XStepper -Iframeworks/CMSIS/LPC1768/include -Iframeworks/CMSIS/LPC1768/lib -Iframeworks/CMSIS -I.piolibdeps/TMC2130Stepper_ID1493/src -I.piolibdeps/U8glib-HAL_ID1932/src .piolibdeps/TMC26XStepper/TMC26XStepper.cpp
.piolibdeps/TMC26XStepper/TMC26XStepper.cpp: In member function 'void TMC26XStepper::start()':
.piolibdeps/TMC26XStepper/TMC26XStepper.cpp:175:9: error: 'class SPIClass' has no member named 'setBitOrder'
SPI.setBitOrder(MSBFIRST);
^~~~~~~~~~~
.piolibdeps/TMC26XStepper/TMC26XStepper.cpp:176:6: error: 'class SPIClass' has no member named 'setClockDivider'
SPI.setClockDivider(SPI_CLOCK_DIV8);
^~~~~~~~~~~~~~~
.piolibdeps/TMC26XStepper/TMC26XStepper.cpp:176:22: error: 'SPI_CLOCK_DIV8' was not declared in this scope
SPI.setClockDivider(SPI_CLOCK_DIV8);
^~~~~~~~~~~~~~
.piolibdeps/TMC26XStepper/TMC26XStepper.cpp:176:22: note: suggested alternative: '_CLOCK_T_'
SPI.setClockDivider(SPI_CLOCK_DIV8);
^~~~~~~~~~~~~~
_CLOCK_T_
.piolibdeps/TMC26XStepper/TMC26XStepper.cpp: In member function 'char TMC26XStepper::move()':
.piolibdeps/TMC26XStepper/TMC26XStepper.cpp:245:28: error: 'micros' was not declared in this scope
unsigned long time = micros();
^~~~~~
.piolibdeps/TMC26XStepper/TMC26XStepper.cpp:245:28: note: suggested alternative: 'millis'
unsigned long time = micros();
^~~~~~
millis
.piolibdeps/TMC26XStepper/TMC26XStepper.cpp: In member function 'void TMC26XStepper::send262(long unsigned int)':
.piolibdeps/TMC26XStepper/TMC26XStepper.cpp:952:30: error: 'SPCR' was not declared in this scope
unsigned char oldMode =  SPCR & SPI_MODE_MASK;
^~~~
.piolibdeps/TMC26XStepper/TMC26XStepper.cpp:952:30: note: suggested alternative: 'SPI'
unsigned char oldMode =  SPCR & SPI_MODE_MASK;
^~~~
SPI
compilation terminated due to -fmax-errors=5.
*** [.pioenvs/LPC1768/libf3e/TMC26XStepper/TMC26XStepper.o] Error 1
thinkyhead commented 6 years ago

@alexxy — If you discover that changes to the library are needed, check to see if the original author will apply the changes to their library on GitHub so everyone can benefit. If they're unresponsive, then send us the updated library and we'll just host it under the MarlinFirmware organization or let @teemuatlut host it with his other TMCxxxxStepper libraries.

teemuatlut commented 6 years ago

https://github.com/teemuatlut/Marlin/tree/bf2_tmc2660 https://github.com/teemuatlut/TMCStepper/blob/master/src/TMCStepper.h#L475

This is what I've been working on for the past week.

alexxy commented 6 years ago

Cool =)

So does TMC2660 are usable with Marlin?

alexxy commented 6 years ago

@teemuatlut with some minor changes seems works on Azteeg X5 GT. But steppers are quite hot...

Spawn32 commented 6 years ago

Looking forward to test this as soon as i can get my timers fixed again, lol :)

Thank you @teemuatlut !!

alexxy commented 6 years ago

Seems like current control doesnt work, as well as TMC_DEBUG and MONITOR_DRIVER_STATUS

teemuatlut commented 6 years ago

I made a complete rewrite last week with no access to the hardware. I haven't tested anything. The additional features likely definitely don't work yet.

teemuatlut commented 6 years ago

But steppers are quite hot

It's possible the current calculation formula needs some attention. Or the SPI command was wrong. Or...

Did you remember to change the sense resistor value?

alexxy commented 6 years ago

No. I didnt change it.

alexxy commented 6 years ago

Smoothie uses that value

motor_driver_control.beta.sense_resistor     100              # set the sense resistor used

So does Marlin use same units?

alexxy commented 6 years ago

I changed value of sense resistor to 100, stepper still quickly became very hot....

m501
SENDING:M501
V54 stored settings retrieved (673 bytes; crc 974)
  G21    ; Units in mm
  M149 C ; Units in Celsius
  M200 D3.000000
  M200 T1 D3.000000
  M200 D0      
  M92 X80.000000 Y80.000000 Z4000.000000 E500.000000
  M203 X300.000000 Y300.000000 Z5.000000 E25.000000
  M201 X3000 Y3000 Z100 E10000
  M204 P3000.000000 R3000.000000 T3000.000000
  M205 S0.000000 T0.000000 B20000 X10.000000 Y10.000000 Z0.300000 E5.000000
  M206 X0.000000 Y0.000000 Z0.000000
  M218 T1 X0.000000 Y0.000000
  M145 S0 H180 B70 F0
  M145 S1 H240 B110 F0
  M301 E0 P22.200001 I1.080000 D114.000000
  M301 E1 P22.200001 I1.080000 D114.000000
  M304 P10.000000 I0.023000 D305.399994
  M250 C140    
  M906 X800    
  M906 Y800    
  M906 Z800    
  M906 T0 E800 
  M906 T1 E800