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.3k stars 19.25k forks source link

[BUG] TMC Driver Settings Ignored #14051

Closed thisiskeithb closed 5 years ago

thisiskeithb commented 5 years ago

Description

TMC driver settings are using values not set by me which causes the steppers to not move at all. Homing halts the printer since there is no axis movement.

Expected behavior: Use TMC values set in Marlin configs

Actual behavior: Using random values for TMC drivers like 256 microstepping and really high hybrid thresholds.

Additional Information

After porting my settings from the 7ccbcf2 commit to the 1dad6e7 commit from earlier today (both are attached below), my TMC5160 drivers no longer work as intended on a BigTreeTech SKR 1.3.

Running M122 after flashing the 1dad6e7 commit from today returns very odd values:

Send: M122
                X       Y       Z       E
Enabled         false   false   false   false
Set current     635     950     530     890
RMS current     631     942     518     876
MAX current     890     1328    730     1235
Run current     31/31   31/31   31/31   31/31
Hold current    15/31   15/31   15/31   15/31
Global scaler   53/256  79/256  44/256  74/256
CS actual       8/31    8/31    8/31    8/31
PWM scale       8       8       8       8
stealthChop     false   false   false   false
msteps          256     256     256     256
tstep           max     max     max     max
pwm
threshold       49      49      39      31
[mm/s]          3227.04 3227.04 810.90  491.64
OT prewarn      false   false   false   false
OT prewarn has
been triggered  false   false   false   false
off time        0       0       0       0
blank time      36      36      36      36
hysteresis
-end            -1      -1      -1      -1
-start          6       6       6       6
Stallguard thrs 1       -2      0       0
DRVSTATUS       X       Y       Z       E
stallguard
sg_result       0       0       0       0
fsactive
stst            X       X       X       X
olb                             X
ola                             X
s2gb
s2ga
otpw
ot
Driver registers:
                X       0x80:08:00:00
                Y       0x80:08:00:00
                Z       0xE0:08:00:00
                E       0x80:08:00:00

Testing X connection... OK
Testing Y connection... OK
Testing Z connection... OK
Testing E connection... OK
ok

Running M122 on the 7ccbcf2 commit from 5/16/19 returns the correct values:

Send: M122
                X       Y       Z       E
Enabled         false   false   false   false
Set current     635     950     530     890
RMS current     631     942     518     876
MAX current     890     1328    730     1235
Run current     31/31   31/31   31/31   31/31
Hold current    15/31   15/31   15/31   15/31
Global scaler   53/256  79/256  44/256  74/256
CS actual       15/31   15/31   15/31   15/31
PWM scale       0       0       0       0
stealthChop     true    true    true    false
msteps          16      16      16      16
tstep           max     max     max     max
pwm
threshold       49      49      39      31
[mm/s]          201.69  201.69  50.68   30.73
OT prewarn      false   false   false   false
OT prewarn has
been triggered  false   false   false   false
off time        4       4       4       4
blank time      24      24      24      24
hysteresis
-end            2       2       2       2
-start          1       1       1       1
Stallguard thrs 1       -2      0       0
DRVSTATUS       X       Y       Z       E
stallguard
sg_result       0       0       0       0
fsactive
stst            X       X       X       X
olb
ola
s2gb
s2ga
otpw
ot
Driver registers:
                X       0x80:0F:40:00
                Y       0x80:0F:40:00
                Z       0x80:0F:40:00
                E       0x80:0F:00:00

Testing X connection... OK
Testing Y connection... OK
Testing Z connection... OK
Testing E connection... OK
ok

I always run M502 and M500 after flashing since it's part of my post-flash script in OctoPrint, but just for good measure, I issued the commands manually and nothing changes.

Config files: Ender-3 - SKR 1.3 - Marlin-bugfix-2.0.x - 1dad6e7 - 5.18-19.zip

Ender-3 - SKR 1.3 - Marlin-bugfix-2.0.x - 7ccbcf2 - 5-16-2019.zip

Patag commented 5 years ago

Maybe you could try M502 (EEPROM reset) and M500 (save current settings).

thisiskeithb commented 5 years ago

@Patag: As I said above:

I always run M502 and M500 after flashing since it's part of my post-flash script in OctoPrint, but just for good measure, I issued the commands manually and nothing changes.

thinkyhead commented 5 years ago

We'll have to trace where TMC drivers are initialized at startup and see if any obvious errors jump out. I don't have a Trinamic setup at this time, but I may be able to run the code on a bare board and follow the bouncing bits.

thisiskeithb commented 5 years ago

This looks to be an issue with the latest TMC Stepper library (@teemuatlut). I specified v0.3.2 in platformio.ini and recompiled the 1dad6e7 commit and now I'm back in business:

Send: M122
        X   Y   Z   E
Enabled     false   false   false   false
Set current 635 950 530 890
RMS current 631 942 518 876
MAX current 890 1328    730 1235
Run current 31/31   31/31   31/31   31/31
Hold current    15/31   15/31   15/31   15/31
Global scaler   53/256  79/256  44/256  74/256
CS actual       15/31   15/31   15/31   15/31
PWM scale   0   0   27  0
stealthChop true    true    true    false
msteps      16  16  16  16
tstep       max max max max
pwm
threshold       49  49  39  31
[mm/s]      201.69  201.69  50.68   30.73
OT prewarn  false   false   false   false
OT prewarn has
been triggered  false   false   false   false
off time        4   4   4   4
blank time  24  24  24  24
hysteresis
-end        2   2   2   2
-start      1   1   1   1
Stallguard thrs 1   -2  0   0
DRVSTATUS   X   Y   Z   E
stallguard
sg_result       0   0   0   0
fsactive
stst        X   X   X   X
olb
ola
s2gb
s2ga
otpw
ot
Driver registers:
        X   0x80:0F:40:00
        Y   0x80:0F:40:00
        Z   0x80:0F:40:00
        E   0x80:0F:00:00

Testing X connection... OK
Testing Y connection... OK
Testing Z connection... OK
Testing E connection... OK
ok
jmdearras commented 5 years ago

@thisiskeithb how do you specify a particular version in platformio?

thisiskeithb commented 5 years ago

@jmdearras: Look for TMCStepper@<1.0.0 under the LPC1768 environment section and change it to TMCStepper=https://github.com/teemuatlut/TMCStepper/archive/v0.3.2.zip

teemuatlut commented 5 years ago

I was able to confirm your issue going when from TMCStepper v0.3.2 to v0.3.3.

kAdonis commented 5 years ago

I tested which commit started breaking things for me, last working commit of the TMCStepper library is teemuatlut/TMCStepper@d33aba2

teemuatlut commented 5 years ago

That doesn't make changes to the code. The problem is with SW SPI trying to follow MODE3 but it isn't quite there yet.

thisiskeithb commented 5 years ago

@teemuatlut: Reverting SW SPI MODE3 changes in v0.3.4 resolved my issues, thank you!

~I had to specify that particular version in platformio.ini (maybe due to some propagation with CDNs?), but hopefully PIO will start grabbing the latest copy for everyone soon.~

Edit: I had to close & restart Atom as well as clean the libraries a few times before v0.3.4 was pulled down.

Edit edit: Atom stinks. Use VSCode.

VanLaser commented 5 years ago

I know this is closed, but (since I probably don't understand it exactly), would this affect anyone anymore? I.e. can I just update my fork with latest Marlin bugfix-2.0.x/TMCStepper and re-apply my configs over it, or do I have to do something extra (e.g. remove any local, already downloaded TMCStepper library folder)? Thanks.

teemuatlut commented 5 years ago

Rebase your fork and apply settings. You can remove the .pioenvs and .piolibdeps folders for good measure if you're using PIO. Then just make sure you're compiling the latest library version.

VanLaser commented 5 years ago

Thanks for the prompt answer!

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.