Klipper3d / klipper

Klipper is a 3d-printer firmware
GNU General Public License v3.0
9.51k stars 5.32k forks source link

Feature request: TMC5160 support. #1409

Closed bdn76 closed 5 years ago

bdn76 commented 5 years ago

Feature request: TMC5160 support.

Stephan3 commented 5 years ago

@sniperlucian can you please checkout latest master from my github? Please test stallguard and sensorlesss homing. It worked for me and if you can confirm that we are done with the core functionality.

@KevinOConnor i tried that udelay in softare spi. I can use Watterotts drivers with that reliable. Unfortunately they also do without that "workarround", Spi mode 3 works reliable with CLK soldered to ground as @mattthebaker worked out here. From my point of view this is not really needed. Maybe we can do a calculation which calcs the delay needed for a certain spi speed, defined by usersetting as we do for hardware spi?

Until now my voron is doing well with these driver on klipper, I printed on unusual high speeds for more than 48hours now. Therefore i am going to pullrequest this, if no one found anything broken.

Thanks for all this effort here!

dralves commented 5 years ago

Ran a few long prints on the latest rev of tmc5160.py (though not extremely fast, 100 mm/s) with BIQU drivers, skr v1.3 (on soft SPI). looking good.

Ph0non commented 5 years ago

I'm a little bit confused by the config file provide from @Stephan3 here

[tmc5160 stepper_x]
cs_pin: ar35
#spi_software_sclk_pin: P0.4
#spi_software_mosi_pin: P4.28
#spi_software_miso_pin: P0.5
microsteps: 16
run_current: 0.8
hold_current: 0.8
sense_resistor: 0.075
stealthchop_threshold: 100
#spi_speed: 100000

If I understand this schematic right, than you use default EN, STEP and DIR for SCLK, MOSI and MISO. But what happens with the SDO, SDI, SCK and CSN pin from the TMC5160? (And is CSN identical to CS pin in the config file?)

mattthebaker commented 5 years ago

Stephan commented after that post that the config is for hardware SPI on on AVR. For hardware SPI, default pins are used.

Also, the schematic you are looking it is an SKR1.1 rather than 1.3 which isn't pre-wired for SPI.

On Sun, May 12, 2019 at 11:04 AM Ph0non notifications@github.com wrote:

I'm a little bit confused by the config file provide from @Stephan3 https://github.com/Stephan3 here https://github.com/KevinOConnor/klipper/issues/1409#issuecomment-489622877

[tmc5160 stepper_x] cs_pin: ar35

spi_software_sclk_pin: P0.4

spi_software_mosi_pin: P4.28

spi_software_miso_pin: P0.5

microsteps: 16 run_current: 0.8 hold_current: 0.8 sense_resistor: 0.075 stealthchop_threshold: 100

spi_speed: 100000

If I understand this schematic https://sc01.alicdn.com/kf/HTB1K_Y_ao_rK1Rjy0Fcq6zEvVXai/231797407/HTB1K_Y_ao_rK1Rjy0Fcq6zEvVXai.jpg_.webp right, than you use default EN, STEP and DIR for SCLK, MOSI and MISO. But what happens with the SDO, SDI, SCK and CSN pin from the TMC5160? (And is CSN identical to CS pin in the config file?)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/KevinOConnor/klipper/issues/1409#issuecomment-491616326, or mute the thread https://github.com/notifications/unsubscribe-auth/ABKHCKRMZVQ2BZF6OXDV6JDPVBL4PANCNFSM4G7D56XA .

Ph0non commented 5 years ago

Thanks, my goal is a right configured TMC5160 with Software SPI an the Radds Board and for now I'm overwhelmed by the complexity.

Stephan3 commented 5 years ago

I will pull request this week to master with config example. My printer is rock stable with 5160. Continuously printing since 4 days so I think we are done here.

sniperlucian commented 5 years ago

@Stephan3 just tested - go from me. (BTT5160 tested on SKR 1.1 with hardware SPI)

still think TMC2100 / 2130 is more quite below ~ 50 mm/sec.

300% print speed (240mm/sec) no problem. surface even better than at 100mm/sec.

Stephan3 commented 5 years ago

@sniperlucian I had an decoding (brain)accident of default values listed in documentation. Can you please try the Version from here and check if your noiselevel has grown better for you? https://github.com/Stephan3/klipper/blob/tmc5160/klippy/extras/tmc5160.py

sniperlucian commented 5 years ago

k - do it tomorrow ;)

sniperlucian commented 5 years ago

@Stephan3 noise floor definitely changed. However for slow speeds the motors seems a little louder - but definitely more quite with 200% print speed (~160mm/s). However, they seem to be driven sharper/harder and trigger more certain peek resonance frequencies of my particular printer.

for reverence, I currently use: 42BYGHM810 (0.9% @ 1.2 A) Microstreps: 64 (was better than 32 with TMC2130) Interpolation: ON Stealth-shop: ON

EDIT:

Just printed the same part as yesterday and I have MUCH less ringing on the surface. Only thing that was changed is your new settings for TMC and I had reduced PA from 0.075 to 0.06. Looking further.

Stephan3 commented 5 years ago

@sniperlucian You might want to play in your config with theese values: driver_pwm_freq: 1 # try 2 here driver_tpfd: 4 # try to increase that

driver_SGT: 0 # try to play with theese. It enables coolstep too, which helps with noise https://github.com/KevinOConnor/klipper/pull/1637/commits/7bc9400d2642068663b8f24c9f7da42092754281

For theese motors the current is in my oppinion to high. Of course this is a printer specific value. On a Voron 2 I use .8 as a current. This reduces the noise too. As long als your toolhead has not a weight of 2kg, i think you can go there too. There is also an impact if you use 12v or 24v as system voltage.

-Stephan

sniperlucian commented 5 years ago

Thanks for feedback, also see my Edit above.

Also I actually have 24V allready. Modding my printer currently heavily and will going back to reduce current too. Maybe coolstep could be an option also.

IF I find the time, I am planning to put a klippy plugin together with GUI to make an on the fly tunning. Also a noise scan vs. speed would be interesting. Than, it would be possible to transform certain speed in G-Code to different frequencies, e.g. you have a resonance peek between 80-90mm/sec, which gets reduced to 70, but doesnt touch speed > 90mm/s. I allready made a plugin to calibrated my force sensitive Z-Probe, so this shouldn't be too difficult.

Just started to look in your DWC code - very interesting ...

Stephan3 commented 5 years ago

Ya if this is done here, dwc is next. The last thing missing is a client handling by cookies. But for your tuning idea. Maybe you want to take a look at TMC_SET_FIELD

As you are on .9° steppers you also might want to double driver_PWM_OFS: 30

sniperlucian commented 5 years ago

@Stephan3 after full power cycle the stepper didnt work anymore - DUMP_TMC only deliver scrambled numbers ... needed to convert back to old version....

Didnt have time yet to dig deeper.

Stephan3 commented 5 years ago

i missed toff. sorry, it should now work again.

KevinOConnor commented 5 years ago

Basic support was implemented as of PR #1637.

-Kevin

ghost commented 5 years ago

@teemuatlut

Whats the current status on the stallguard-readout via SPI? Is this implemented and how can it be activated?

I have the TMC5160 V1.2 from Bigtreetech and the stallguard feature is supposed to activate diag1 pin (second from the left in the top row). However I never get a signal from there (observed with my scope)

jakep82 commented 5 years ago

@Spacemarine2018 Did you configure the diag1 pin as well as the driver_SGT value?

https://github.com/KevinOConnor/klipper/blob/master/config/example-extras.cfg#L1529 https://github.com/KevinOConnor/klipper/blob/master/config/example-extras.cfg#L1518

ghost commented 5 years ago

@jakep82 I tried values of driver_SGT between -63 and 63, nothing changed.

What is the correct setting for the diag1 pin? It is my understanding that the physical pin on the driver-board (2nd from the left in the top row) must be connected with a wire to an endstop-input pin on the board, where ususally the physical endstop-switch is connected.

Even if I watch diag1 on the driver-board with my oscilloscope, I can not see any change, no matter which value I choose for driver_SGT

jakep82 commented 5 years ago

You need to open a new issue and post a log file.