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.28k stars 19.24k forks source link

TMC2130 axes not moving #10320

Closed HWiese1980 closed 5 years ago

HWiese1980 commented 6 years ago

I've just upgraded my printer with two TMC2130 and a new Marlin firmware. Current branch is bugfix-1.1.x because I read of some bugs regarding SPI communication with the drivers.

SPI seems to be working. I can M906 set/get, I can M122 debug. The following output is generated by M122. I don't know what all the values mean but maybe you can use it to diagnose my problem which is that the motors simply don't move. Even after a G28 X0 Y0 they remain powerless and I can easily move them by hand.

Here's M122 output before I initiate G28:

X   Y
Enabled     false   false
Set current 900 900
RMS current 1602    1602
MAX current 2259    2259
Run current 28/31   28/31
Hold current    14/31   14/31
CS actual       0/31    0/31
PWM scale   0   0
vsense      0=.325  0=.325
stealthChop false   false
msteps      256 256
tstep       1048575 1048575
pwm
threshold       0   0
[mm/s]      -   -
OT prewarn  false   false
OT prewarn has
been triggered  false   false
off time        0   0
blank time  16  16
hysteresis
-end        -3  -3
-start      1   1
Stallguard thrs 0   0
DRVSTATUS   X   Y
stallguard
sg_result       0   0
fsactive
stst        X   X
olb
ola
s2gb
s2ga
otpw
ot
Driver registers:   X = 0x80:00:00:00
Y = 0x80:00:00:00   

And here is M122 output after G28 X0 (only X axis for testing; Y behaves equally) is initiated:

echo:busy: processing
N19 M105 *63
X:0.00 Y:0.00 Z:4.00 E:0.00 Count X:0 Y:0 Z:1600
ok
N20 M122 *48
X   Y
Enabled     false   false
Set current 900 900
RMS current 1602    1602
MAX current 2259    2259
Run current 28/31   28/31
Hold current    14/31   14/31
CS actual       0/31    0/31
PWM scale   0   0
vsense      0=.325  0=.325
stealthChop false   false
msteps      256 256
tstep       1048575 1048575
pwm
threshold       0   0
[mm/s]      -   -
OT prewarn  false   false
OT prewarn has
been triggered  false   false
off time        0   0
blank time  16  16
hysteresis
-end        -3  -3
-start      1   1
Stallguard thrs 0   0
DRVSTATUS   X   Y
stallguard
sg_result       0   0
fsactive
stst        X   X
olb     X
ola     X
s2gb
s2ga
otpw
ot
Driver registers:   X = 0xE0:00:00:00
Y = 0x80:00:00:00

And here's what I've changed in the configuration so far (only the changes and their neighborhood):

Configuration.h

<------- 141 equal lines skipped ------->
#define EXTRUDERS 1

// Generally expected filament diameter (1.75, 2.85, 3.0, ...). Used for Volumetric, Filament Width Sensor, etc.
#define DEFAULT_NOMINAL_FILAMENT_DIA 2.85

// For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE
<------- 152 equal lines skipped ------->
 *
 * :{ '0': "Not used", '1':"100k / 4.7k - EPCOS", '2':"200k / 4.7k - ATC Semitec 204GT-2", '3':"Mendel-parts / 4.7k", '4':"10k !! do not use for a hotend. Bad resolution at high temp. !!", '5':"100K / 4.7k - ATC Semitec 104GT-2 (Used in ParCan & J-Head)", '6':"100k / 4.7k EPCOS - Not as accurate as Table 1", '7':"100k / 4.7k Honeywell 135-104LAG-J01", '8':"100k / 4.7k 0603 SMD Vishay NTCS0603E3104FXT", '9':"100k / 4.7k GE Sensing AL03006-58.2K-97-G1", '10':"100k / 4.7k RS 198-961", '11':"100k / 4.7k beta 3950 1%", '12':"100k / 4.7k 0603 SMD Vishay NTCS0603E3104FXT (calibrated for Makibox hot bed)", '13':"100k Hisens 3950  1% up to 300°C for hotend 'Simple ONE ' & hotend 'All In ONE'", '20':"PT100 (Ultimainboard V2.x)", '51':"100k / 1k - EPCOS", '52':"200k / 1k - ATC Semitec 204GT-2", '55':"100k / 1k - ATC Semitec 104GT-2 (Used in ParCan & J-Head)", '60':"100k Maker's Tool Works Kapton Bed Thermistor beta=3950", '66':"Dyze Design 4.7M High Temperature thermistor", '70':"the 100K thermistor found in the bq Hephestos 2", '71':"100k / 4.7k Honeywell 135-104LAF-J01", '147':"Pt100 / 4.7k", '1047':"Pt1000 / 4.7k", '110':"Pt100 / 1k (non-standard)", '1010':"Pt1000 / 1k (non standard)", '-3':"Thermocouple + MAX31855 (only for sensor 0)", '-2':"Thermocouple + MAX6675 (only for sensor 0)", '-1':"Thermocouple + AD595",'998':"Dummy 1", '999':"Dummy 2" }
 */
#define TEMP_SENSOR_0 5
#define TEMP_SENSOR_1 0
#define TEMP_SENSOR_2 0
#define TEMP_SENSOR_3 0
#define TEMP_SENSOR_4 0
#define TEMP_SENSOR_BED 5

// Dummy thermistor constant temperature readings, for use with 998 and 999
#define DUMMY_THERMISTOR_998_VALUE 25
<------- 230 equal lines skipped ------->
 * Override with M92
 *                                      X, Y, Z, E0 [, E1[, E2[, E3[, E4]]]]
 */
#define DEFAULT_AXIS_STEPS_PER_UNIT   { 80, 80, 400, 445 }

/**
 * Default Max Feed Rate (mm/s)
 * Override with M203
 *                                      X, Y, Z, E0 [, E1[, E2[, E3[, E4]]]]
 */
#define DEFAULT_MAX_FEEDRATE          { 300, 300, 20, 25 }

/**
 * Default Max Acceleration (change/s) change = mm/s
<------- 83 equal lines skipped ------->
 * A Fix-Mounted Probe either doesn't deploy or needs manual deployment.
 *   (e.g., an inductive probe or a nozzle-based probe-switch.)
 */
#define FIX_MOUNTED_PROBE

/**
 * Z Servo Probe, such as an endstop switch on a rotating arm.
<------- 16 equal lines skipped ------->
 * These options are most useful for the BLTouch probe, but may also improve
 * readings with inductive probes and piezo sensors.
 */
#define PROBING_HEATERS_OFF       // Turn heaters off when probing
//#define PROBING_FANS_OFF          // Turn fans off when probing
//#define DELAY_BEFORE_PROBING 200  // (ms) To prevent vibrations from triggering piezo sensors

<------- 27 equal lines skipped ------->
 *      O-- FRONT --+
 *    (0,0)
 */
#define X_PROBE_OFFSET_FROM_EXTRUDER 45  // X offset: -left  +right  [of the nozzle]
#define Y_PROBE_OFFSET_FROM_EXTRUDER 15  // Y offset: -front +behind [the nozzle]
#define Z_PROBE_OFFSET_FROM_EXTRUDER -0.7   // Z offset: -below +above  [the nozzle]

// Certain types of probes need to stay away from edges
#define MIN_PROBE_EDGE 10
<------- 35 equal lines skipped ------->
#define Z_PROBE_OFFSET_RANGE_MAX 20

// Enable the M48 repeatability test to test probe accuracy
#define Z_MIN_PROBE_REPEATABILITY_TEST

// For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
// :{ 0:'Low', 1:'High' }
<------- 40 equal lines skipped ------->

//#define UNKNOWN_Z_NO_RAISE // Don't raise Z (lower the bed) if Z is "unknown." For beds that fall when Z is powered off.

#define Z_HOMING_HEIGHT 4  // (in mm) Minimal z height before homing (G28) for Z clearance above the bed, clamps, ...
                             // Be sure you have this distance over your Z_MAX_POS in case.

// Direction of endstops when homing; 1=MAX, -1=MIN
<------- 98 equal lines skipped ------->
//#define AUTO_BED_LEVELING_3POINT
//#define AUTO_BED_LEVELING_LINEAR
//#define AUTO_BED_LEVELING_BILINEAR
#define AUTO_BED_LEVELING_UBL
//#define MESH_BED_LEVELING

/**
 * Normally G28 leaves leveling disabled on completion. Enable
 * this option to have G28 restore the prior leveling state.
 */
#define RESTORE_LEVELING_AFTER_G28

/**
 * Enable detailed logging of G28, G29, M48, etc.
<------- 146 equal lines skipped ------->
// - Move the Z probe (or nozzle) to a defined XY point before Z Homing when homing all axes (G28).
// - Prevent Z homing when the Z probe is outside bed area.
//
#define Z_SAFE_HOMING

#if ENABLED(Z_SAFE_HOMING)
  #define Z_SAFE_HOMING_X_POINT ((X_BED_SIZE) / 2)    // X point for Z homing when homing all axes (G28).
<------- 75 equal lines skipped ------->
// M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).
// M502 - reverts to the default "factory settings".  You still need to store them in EEPROM afterwards if you want to.
//
#define EEPROM_SETTINGS // Enable for M500 and M501 commands
//#define DISABLE_M503    // Saves ~2700 bytes of PROGMEM. Disable for release!
#define EEPROM_CHITCHAT   // Give feedback on EEPROM commands. Disable to save PROGMEM.

<------- 541 equal lines skipped ------->
// @section extras

// Increase the FAN PWM frequency. Removes the PWM noise but increases heating in the FET/Arduino
#define FAST_PWM_FAN

// Use software PWM to drive the fan, as for the heaters. This uses a very low frequency
// which is not as annoying as with the hardware PWM. On the other hand, if this frequency
<------- 120 equal lines skipped ------->

Configuration_adv.h

<------- 308 equal lines skipped ------->
  #endif
#endif

#define Z_DUAL_STEPPER_DRIVERS
#if ENABLED(Z_DUAL_STEPPER_DRIVERS)
  //#define Z_DUAL_ENDSTOPS
  #if ENABLED(Z_DUAL_ENDSTOPS)
<------- 698 equal lines skipped ------->
 * in your `pins_MYBOARD.h` file. (e.g., RAMPS 1.4 uses AUX3 pins `X_CS_PIN 53`, `Y_CS_PIN 49`, etc.).
 * You may also use software SPI if you wish to use general purpose IO pins.
 */
#define HAVE_TMC2130
#if ENABLED(HAVE_TMC2130)  // Choose your axes here. This is mandatory!
  #define X_IS_TMC2130
  //#define X2_IS_TMC2130
  #define Y_IS_TMC2130
  //#define Y2_IS_TMC2130
  //#define Z_IS_TMC2130
  //#define Z2_IS_TMC2130
<------- 95 equal lines skipped ------->
   * M912 - Clear stepper driver overtemperature pre-warn condition flag.
   * M122 S0/1 - Report driver parameters (Requires TMC_DEBUG)
   */
  #define MONITOR_DRIVER_STATUS

  #if ENABLED(MONITOR_DRIVER_STATUS)
    #define CURRENT_STEP_DOWN     50  // [mA]
<------- 45 equal lines skipped ------->
   * Enable M122 debugging command for TMC stepper drivers.
   * M122 S0/1 will enable continous reporting.
   */
  #define TMC_DEBUG

  /**
   * M915 Z Axis Calibration
<------- 443 equal lines skipped ------->

pins_RAMPS.h

(because I usually have an LCD, which isn't currently connected, I reconfigured the CS pins - correctly, I've double checked these settings)

<------- 91 equal lines skipped ------->
#define X_DIR_PIN          55
#define X_ENABLE_PIN       38
#ifndef X_CS_PIN
#define X_CS_PIN           44
#endif

#define Y_STEP_PIN         60
#define Y_DIR_PIN          61
#define Y_ENABLE_PIN       56
#ifndef Y_CS_PIN
#define Y_CS_PIN           64
#endif

#define Z_STEP_PIN         46
<------- 469 equal lines skipped ------->

Aside from any help regarding this problem I'd like to know what the values and especially the driver registers exactly mean. They are probably documented in the datasheet of the TMC2130 but I couldn't figure out yet where they come from, like, which of the TMC's registers are meant by "Driver registers".

Thanks a lot, folks!

Cheers

teemuatlut commented 6 years ago

The driver register in question in DRV_STATUS which contains a lot of the current information about the driver, such as standstill flag or over temperature or motor load value.

You seem to have a problem where either the driver didn't get configured correctly or the reading failed for everything but the register retrieve. I'll try a vanilla branch tomorrow and test that nothing is broken.

HWiese1980 commented 6 years ago

Hey @teemuatlut, have you had a chance to take a look into this? I've double checked my wiring and I'm pretty certain everything's correct. All bridges of the drivers are open, motors connected. They still wouldn't move. I have no idea why it isn't working.

teemuatlut commented 6 years ago

I checked the functionality with a single Y stepper and it seems to be working as intended. I'd recommend you first try to get the Simple example sketch in the library working. Since it's not software (or at least that's what it looks like) you need to start ruling out components. Use simple jumper wires for the SPI. Change the driver, Arduino, RAMPS, motor one at a time to see if one is failing. Basically simplify your setup as much as possible and build from there once something starts working.

HWiese1980 commented 6 years ago

I've tried the minimum example. The TMC2130 both do not work. If I replace them with the old TMC2100 and disable everything related to the TMC2130 in the code (so left with only toggling pins) those work. So it's neither the software nor the RAMPS/Arduino. Seems to either have to do with configuration or both TMC2130 are dead - which I certainly don't hope and also wouldn't be able to say why. They are brand new and I'm sure I've soldered/wired everything correctly.

Bob-the-Kuhn commented 6 years ago

No power to the steppers with the TMC2130s but all is well when using different drivers.

As I understand it the TMC2130s load a default config on power up. You should be able to just remove the old driver and drop in the 2130 and see stepper movement. Even if the default 2130 current setting is too low to move the stepper they should still have power to them.

I suspect that the ENABLE pins on the 2130s are not connected. Try re-soldering them. The enable pin is the single pin near the SPI pins.

tmc2130 9-16 cropped low res tmc2130 1-8 cropped low res

HWiese1980 commented 6 years ago

I've found other people who had been experiencing the same issues. The solution is that somehow motor voltage has to be up before VCC of the driver. My individual problem was that my printer was configured to switch on/off VM on demand. That apparently doesn't work with the TMC2130 (should be mentioned in the FAQ somewhere). After rewiring my power supply so that VM is always on, the motors now move.

Now on to the next problem: stallGuard/sensorless homing doesn't work. Even with the minimal example. The DIAG1 pin is always at 0V/GND, no matter how much load I give to the motor (even when it eventually stalls).

I suppose though that it's better to open a different thread for this new issue...

thinkyhead commented 6 years ago

motor voltage has to be up before VCC of the driver

@teemuatlut I remember we were talking about this w/r/t the configuration being accepted. Perhaps we can do something to ensure power is available before attempting to apply settings. Otherwise, a warning message would be the second best choice.

thinkyhead commented 6 years ago

The DIAG1 pin is always at 0V/GND, no matter how much load I give to the motor

In the TMC2130 example sketch? I know we just recently made a change to the initialization of that pin in Marlin, and maybe this is related.

teemuatlut commented 6 years ago

It's fine to apply the settings even before there is power. The library will cache the write commands and we can then use push() to sync the settings into the driver. The issue likely is that he's using AUTO_POWER_CONTROL which may not take into account this requirement.

thinkyhead commented 6 years ago

I feel like we did some additions for AUTO_POWER_CONTROL at some point. Am I tripping?

teemuatlut commented 6 years ago

If it uses Power::power_on() then it should push the configs to the drivers. It's not a feature I personally use so I don't know how well it works.

thinkyhead commented 6 years ago

Ah, right. It does use power_on and that does call restore_stepper_drivers after a 100ms delay.

HWiese1980 commented 6 years ago

VM before VCC

I'm deeply ashamed to admit that I'm not using AUTO_POWER_CONTROL to control the PSU but an ordinary pin (D6) which I switch on through gcode. I don't know why, but when I first tried to use AUTO_POWER_CONTROL it wouldn't work either and I decided to go with this makeshift solution. And nothing lasts longer than a makeshift.

I'll probably try to use AUTO_POWER_CONTROL in the future if it helps to deal with the VM before VCC problem.

DIAG1

In the example sketch, yes. (@thinkyhead )

thinkyhead commented 6 years ago

You should be able to leave the pin as-is and use AUTO_POWER_CONTROL by adding #define PS_ON_PIN 6 to your Configuration.h.

StaurusN commented 6 years ago

There is a tmc2130 driver on the x and y axes. But it does not move. please help. (mks gene v1.4 and tmc2130) error code 0x00000000

thinkyhead commented 6 years ago

@StaurusN —

For best results getting help with configuration and troubleshooting, please use the following resources:

After seeking help from the community, if the consensus points to to a bug in Marlin, then you should post a bug report.

Hilpas commented 6 years ago

I have a similar problem using bugfix-2.0.x and TMCStepper v0.2.2 on an Arduino Due+Smart Ramps. Got SW SPI Working at least i am able to Debug the drivers and set current for example. But for some reason i cant get them to move. Is the problem that the TMCStepper library isnt compatible with the Arduino Due? Any chances for it to work?

unbenannt

Evg33 commented 5 years ago

For reinit tmc2130spi after psu return power to tmc you can Insert in top of startup g-code:

;poweron
M80
;M502 - factory reset to enable-steppers
M502
;M501 - Restore Settings to enable steppers
M501

or another way:

M80
M906 ... (from M501)
M569 ... (from M501 if exist)
M913 ... (from M501 if exist)
M914 ... (from M501 if exist)

it solved the problem in my case.

2DEV: For tmc2130spi requires modification code in restore_stepper_drivers. (called from power.cpp and M80_M81.cpp)

boelle commented 5 years ago

@HWiese1980

still having an issue when using latest bugfix 2.0?

Evg33 commented 5 years ago

@HWiese1980 still having an issue when using latest bugfix 2.0? Not working :( Need reinit TMC2130 via SPI or M502.

11,787 commits. branch is 3405 commits ahead, 1816 commits behind 1.1.x.

HWiese1980 commented 5 years ago

@boelle I'm sorry, I must admit I've switched to Klipper and TMC2208 in the meantime. Might be that I return to Marlin one day, but I'm pretty satisfied with how it works at the moment.

boelle commented 5 years ago

maybe we can close this one and open new issue if you get back to marlin?

unless others have this problem and can contribute to finding out what is wrong

HWiese1980 commented 5 years ago

Not sure. I'm okay with it if I'm the only one.

Ofr3d commented 5 years ago

I was back reading trying to find a solution to my tmc2130 on a mks Gen L. The motors were working on the stock board (tronxy x5s), now after flashing bugfix 2 the motors buzz but won't turn, I was adjusting the current and added the tmc library in platformio, I'm a little lost with all what been said here

teemuatlut commented 5 years ago

See the TMC troubleshooting steps at the Marlin website http://marlinfw.org/docs/hardware/tmc_drivers.html#troubleshooting

github-actions[bot] commented 4 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.