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.19k stars 19.22k forks source link

[FR] Support for Trinamic TMC2660 #8138

Closed alexxy closed 4 years ago

alexxy commented 6 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?

teemuatlut commented 6 years ago

No. Use 0.1 for Panucatt BSD2660.

Driver R_sense Max current
Watterott TMC2130 0.11 1.77A
Watterott TMC2208 0.11 1.77A
Panucatt BSD2660 0.100 2.19A
UltiMachine Einsy 0.22 0.96A
UltiMachine Archim2 0.22 0.96A
alexxy commented 6 years ago

Ok. Lets try again =) (will wait untill stepper cool down)

teemuatlut commented 6 years ago

I pushed a fix for the TMC2660 current equation. But I'm not sure if it fixes your overheating issue. I would need to see the actual bit pattern for the register to verify it's being properly configured.

teemuatlut commented 6 years ago

Where are you using the drivers? I'll add a M122 R option to see the raw patterns for the drivers

alexxy commented 6 years ago

They are plugged into Azteeg X5 GT. How can I help you?

Second board installed on large CoreXY (400x400x400 build volume)

alexxy commented 6 years ago

Testing you're new equation. Seems not heating much @800mA rms current

teemuatlut commented 6 years ago

Update and upload your bf2_tmc2660 branch and post your M122 R output. Remember to turn on TMC_DEBUG.

alexxy commented 6 years ago
SENDING:M122 R
Raw registers: 
stepperX.sgcsconf=      13stepperY.sgcsconf=      13stepperZ.sgcsconf=      13stepperE0.sgcsconf=      13ok
teemuatlut commented 6 years ago

Forgot to add the new line characters -_- Still some tuning needed for the equation. 800mA should give a CS value of DEC 20 or HEX 14 (R_SENSE = 0.1). Pushing more updates...

alexxy commented 6 years ago

doesnt build

Compiling .pioenvs/LPC1768/src/src/gcode/feature/trinamic/M906.o
Marlin/src/gcode/feature/trinamic/M122.cpp:47:40: error: macro "SERIAL_ECHO_F" requires 2 arguments, but only 1 given
SERIAL_ECHO_F(stepperX.SGCSCONF());
^
Marlin/src/gcode/feature/trinamic/M122.cpp:53:40: error: macro "SERIAL_ECHO_F" requires 2 arguments, but only 1 given
SERIAL_ECHO_F(stepperY.SGCSCONF());
^
Marlin/src/gcode/feature/trinamic/M122.cpp:59:40: error: macro "SERIAL_ECHO_F" requires 2 arguments, but only 1 given
SERIAL_ECHO_F(stepperZ.SGCSCONF());
^
Marlin/src/gcode/feature/trinamic/M122.cpp:65:41: error: macro "SERIAL_ECHO_F" requires 2 arguments, but only 1 given
SERIAL_ECHO_F(stepperE0.SGCSCONF());
^
Compiling .pioenvs/LPC1768/src/src/gcode/feature/trinamic/M911-M915.o
Compiling .pioenvs/LPC1768/src/src/gcode/gcode.o
Marlin/src/gcode/feature/trinamic/M122.cpp: In static member function 'static void GcodeSuite::M122()':
Marlin/src/gcode/feature/trinamic/M122.cpp:47:7: error: 'SERIAL_ECHO_F' was not declared in this scope
SERIAL_ECHO_F(stepperX.SGCSCONF());
^~~~~~~~~~~~~
*** [.pioenvs/LPC1768/src/src/gcode/feature/trinamic/M122.o] Error 1
teemuatlut commented 6 years ago

Change them to SERIAL_ECHO, or comment out SERIAL_PORT_2.

alexxy commented 6 years ago

Ok. Some output (i changed current)

T:25> M122 R
SENDING:M122 R
Raw registers: 
stepperX.sgcsconf=0x      13=19
stepperY.sgcsconf=0x       E=14
stepperZ.sgcsconf=0x      10=16
stepperE0.sgcsconf=0x      13=19
stepperE1.sgcsconf=0x      13=19ok
T:25> M501  
SENDING:M501
V54 stored settings retrieved (673 bytes; crc 31784)
  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 Y600    
  M906 Z700    
  M906 T0 E800 
  M906 T1 E800 
T:25> 
T:25> M906 Y900
SENDING:M906 Y900
T:25> M500
SENDING:M500
Settings Stored (673 bytes; crc 18577)
T:25> 
T:25> 
T:25> M122 R   
SENDING:M122 R
Raw registers: 
stepperX.sgcsconf=0x      13=19
stepperY.sgcsconf=0x      15=21
stepperZ.sgcsconf=0x      10=16
stepperE0.sgcsconf=0x      13=19
stepperE1.sgcsconf=0x      13=19ok
T:25> 
T:25> 
T:25> 
T:25> 
T:25> M501
SENDING:M501
V54 stored settings retrieved (673 bytes; crc 18577)
  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 Y900    
  M906 Z700    
  M906 T0 E800 
  M906 T1 E800 

Interesting that setting current to 600mA gives E in M122 R

teemuatlut commented 6 years ago

0xE = 14. The values are still not quite correct. They're really close though so I'm thinking there might be some rounding errors that I need to deal with.

alexxy commented 6 years ago

Ohh, so values are in Hex...

teemuatlut commented 6 years ago

On AVR:

>>> M906
SENDING:M906
X driver current: 800
Y driver current: 600
Z driver current: 700
E0 driver current: 800
>>> M122R
SENDING:M122R
Raw registers:
stepperX.sgcsconf=0x14=20
stepperY.sgcsconf=0xF=15
stepperZ.sgcsconf=0x12=18
stepperE0.sgcsconf=0x14=20

Everything is as should be. Perhaps LPC does things its own way. Again...

alexxy commented 6 years ago
T:25> m906
SENDING:M906
X driver current: 800
Y driver current: 600
Z driver current: 700
E0 driver current: 800
E1 driver current: 800
T:25> M122R
SENDING:M122R
Raw registers: 
stepperX.sgcsconf=0x      14=20
stepperY.sgcsconf=0x       F=15
stepperZ.sgcsconf=0x      12=18
stepperE0.sgcsconf=0x      14=20
stepperE1.sgcsconf=0x      14=20
alexxy commented 6 years ago

I removed .libdeps and rebuild, so seems something wasnt fetched PS also M911/M921 reports nothing

alexxy commented 6 years ago

My configs configs.zip

alexxy commented 6 years ago

@teemuatlut created PR for your branch with Azteeg X5 GT pin definitions

alexxy commented 6 years ago

@teemuatlut today i tested Marlin on Azteeg X5 GT with 2660 drivers on real printer. So far so good. It works. I can print.

Only issue is that i cannot turn off motors by M84.

teemuatlut commented 6 years ago

The driver/enable commands need to work through SPI. I've committed the changes already but haven't pushed yet.

alexxy commented 6 years ago

@teemuatlut if you push it i can test =) PS i also fixed pin definitions for E0 and E1

teemuatlut commented 6 years ago

Pushed updates to library and Marlin branch. Enable/disable should work now.

alexxy commented 6 years ago

@teemuatlut to make code actualy compile you also need this https://github.com/teemuatlut/Marlin/pull/22

alexxy commented 6 years ago

And M84 seems doesnt work...

alexxy commented 6 years ago

@teemuatlut you're latest marlin branch dont compile

Marlin/src/HAL/HAL_LPC1768/HAL_spi.cpp: In member function 'void SPIClass::beginTransaction(SPISettings)':
Marlin/src/HAL/HAL_LPC1768/HAL_spi.cpp:246:3: error: 'SSP_Cmd' was not declared in this scope
SSP_Cmd(LPC_SSP0, DISABLE); // Disable SSP0 before changing rate
^~~~~~~
*** [.pioenvs/LPC1768/src/src/HAL/HAL_LPC1768/HAL_spi.o] Error 1
teemuatlut commented 6 years ago

It does compile for me. Try deleting the .piolenvs and .piolibdeps folders. If that doesn't work, try redownloading the repo or do a fetch into hard reset for your local clone.

EDIT: Try disabling SDSUPPORT

alexxy commented 6 years ago

I removed .pio* and did hardreset. I used configs for printer. configs.zip

alexxy commented 6 years ago

Seems like related to commit 4dc81651684ce3ff3ffb7763e037314b0b619ce7

teemuatlut commented 6 years ago

It's because if you have SDSUPPORT and LCD in use, then LPC will use software SPI which does not include the necessary header.

alexxy commented 6 years ago

Arent sdsupport needed for eeprom emulation?

p3p commented 6 years ago

@alexxy The LPC176x platform transparently redirects the EEPROM if its enabled to the always present onboard sdcard, This happens behind the HAL so "Marlin" doesn't actually know about it. The sdsupport config option is just for Marlins normal controller based sdcards.

I think teemuatlut has fixed the issue of using a hardware spi command in software spi mode, so that should be resolved.

alexxy commented 6 years ago

@p3p Yes. It builds now =)

alexxy commented 6 years ago

@thinkyhead to early. TMC2660 still have no support in any of release barcnhes. So reopen it

mamama1 commented 6 years ago

Hi there,

I've read the whole thread. Great work! So I assume TMC2660 support is being worked on for the 2.x branch and 1.1.x won't get that support anymore, right? Will TMC2660 support also work on AVR?

How can we support your great work? I'm planning something with TMC2660 and AVR but I don't have any hardware yet, so I can't send you anything to test (yet).

teemuatlut commented 6 years ago

The 1.1.x branch is in a feature freeze and I don't want to add anything that might break things just before the final release on that branch. All my future development will target the v2 branches. Yes, I do primarily test on AVR and I've confirmed it to be working. I'm not sure what kind of support you're talking about. I'm not opposed to having platforms to play with and I do have quite a few already.

mamama1 commented 6 years ago

Great news, I like the feature freeze thing :-) So the coming 1.1.x release will be the final 1.1.x release? Regarding the support: Dunno, beer, potato chips, .. :-D A few TB on my nextcloud, designing PCBs, doing tests...

teemuatlut commented 6 years ago

I believe that has been the plan since December but there must've been some unresolved issues that Scott wanted to address before going forward with the v1.1.9 release. We'll see how everything goes.

alexxy commented 6 years ago

Well actualy i'm printing with Azteeg X5 GT + TMC2660 drivers. So it working now. Big thanks for @teemuatlut.

However all support bits still live outside of main Marlin repo

jsondag commented 6 years ago

Any chance of helping out with a tutorial about how to get it running? I have the same board and drivers. How do you like it compared to smoothie ware?

alexxy commented 6 years ago

Smoothieware is buggy =) @jsondag you can use https://github.com/teemuatlut/Marlin/tree/bf2_tmc2660 branch. And configs from examples (i have also viki2 display)

monterman commented 6 years ago

Hi Guys, thanks for your hard work. I have my Azteeg X5 Gt with 5x TMC2660 bigfoots already on the mail coming my way!

I noticed that the processor supported by Platformio and the .ini file is the LPC1768 running at 100MhZ but the GTx5 has the LPC1769 running at 120MhZ. As shown in this is shown here: https://github.com/teemuatlut/Marlin/blob/bf2_tmc2660/platformio.ini

should there be some changes added?

Alexxy could you share your latest config files please? I'm moving from Marlin 1.1xbugfix in avr to 32bit and some things are new to me (cmake)... And I think I want to skip the smoothie experience from inception

BTW: do I need to update the boot-loader on my stock smoothie Azteeg x5 Gt?

thanks again,

Andres.

monterman commented 6 years ago

FYI, I found this awesome Guide to flash MARLIN 2.0 to ReARM board. I will try it this week on my AZTEEG X5 GT; it is super detailed!! Finally one place were all the info in located!

https://www.bountysource.com/issues/46297583-the-marlin-2-0-32-bit-thread Scroll down till you see the guide...

Andres

teemuatlut commented 6 years ago

The final version is on the Marlin homepage.

jsondag commented 6 years ago

Can you tell me if these are the right values for azteeg x5 gt with TMC2660 bigfoot drivers? is 91mOhm correct, or should I change to 100. That was the value already in there from the sample config for this board.

#define HAVE_TMC26X
#if ENABLED(HAVE_TMC26X)  // Choose your axes here. This is mandatory!
  #define X_IS_TMC26X
  //#define X2_IS_TMC26X
  #define Y_IS_TMC26X
  //#define Y2_IS_TMC26X
  #define Z_IS_TMC26X
  //#define Z2_IS_TMC26X
  #define E0_IS_TMC26X
  #define E1_IS_TMC26X
  //#define E2_IS_TMC26X
  //#define E3_IS_TMC26X
  //#define E4_IS_TMC26X

  #define X_MAX_CURRENT     2000 // in mA
  #define X_SENSE_RESISTOR    91 // in mOhms
  #define X_MICROSTEPS        16 // number of microsteps
teemuatlut commented 6 years ago

You've got the wrong section. Although that could still work, look for HAVE_TMC2660. The sense resistor values are written in the Trinamic section of Marlin docs.

jsondag commented 6 years ago

I had copied over the Configuration_adv.h from the board example. Which didn't have that section.

thinkyhead commented 6 years ago
#define HAVE_TMC2660
#if ENABLED(HAVE_TMC2660)  // Choose your axes here. This is mandatory!
  #define X_IS_TMC2660
  //#define X2_IS_TMC2660
  //#define Y_IS_TMC2660
  //#define Y2_IS_TMC2660
  //#define Z_IS_TMC2660
  //#define Z2_IS_TMC2660
  //#define E0_IS_TMC2660
  //#define E1_IS_TMC2660
  //#define E2_IS_TMC2660
  //#define E3_IS_TMC2660
  //#define E4_IS_TMC2660
#endif
jsondag commented 6 years ago

I was able to get it up and running last night. I took the main configuration.h instead of the one in the examples folder for the azteeg, and adjusted it. So far everything seems to work, my motors, and heaters all work. I can home, and bed level using the bltouch. I just need to pid tune, and play with linear advance. and bezier jerk. Thanks everyone.

jsondag commented 6 years ago

Just was doing my first test print. The printer was crazy loud, so I checked, and realized the motors are scorching hot. 65C on the x and y, and 75C on the extruder. They basically just about burn you instantly. I have 2.2A motors set to 2A, and the e3d pancake set to 1.5A, which I now realize is too much and it was 1.1A in smoothie. However the X and Y are the same as in smoothie, but they are wayyyyy hotter. The sense resistor is set to 0.1 Not sure the calculations are being done correctly.