Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TMC2209 #13

Closed
simon-jouet opened this issue Mar 28, 2020 · 11 comments
Closed

TMC2209 #13

simon-jouet opened this issue Mar 28, 2020 · 11 comments

Comments

@simon-jouet
Copy link
Owner

@felixstorm @vivian-ng

(Decided to post here instead of the main repo because I assume that's an issue only for ESP32 users.)

Hey guys, hopefully you get a notification from those mentions :), with what has been happening I finally took some time this weekend top bump my Marlin version and trying to do some minor updates to my printer.

I got TMC2209 a while back (fystec v2.1) and i'm running into some issues with the configuration, so I was hoping one of you had a try. Setting up a single TMC2209 works perfectly fine, the stepping works okay and doing a M122 returns the status of the driver as expected.

The problem is when I start enabling more that one TMC2209 for the same UART, if I enable both X and Y, give X the slave address 0 and y the slave address 1 then the stepping stops working. The driver is enabled (the stepper is on hold), M122 returns the status of all the drivers but stepping just doesn't do anything.

If I comment out the driver type from tmc2209 for either X or Y (so only a driver is tmc2209) then the one configured for tmc2209 is working perfectly, just can't have more than one TMC2209 at a time.

Do you have any clue what could be going on before I start digging too deep into this?

Here is the diff of my branch if that helps
esp32.txt

@vivian-ng
Copy link

@simon-jouet I did my initial test on TMC2209 using X and Y too with no issues... anyway, right now, I am using TMC2209 on X, Y, Z, and E0.

Configuration.h set as:

#define X_DRIVER_TYPE  TMC2209
#define Y_DRIVER_TYPE  TMC2209
#define Z_DRIVER_TYPE  TMC2209
#define E0_DRIVER_TYPE TMC2209

Configuration_adv.h set as:

  #define  X_SLAVE_ADDRESS 0
  #define  Y_SLAVE_ADDRESS 1
  #define  Z_SLAVE_ADDRESS 2
  #define E0_SLAVE_ADDRESS 3

  #define X_HARDWARE_SERIAL Serial1
  #define Y_HARDWARE_SERIAL Serial1
  #define Z_HARDWARE_SERIAL Serial1
  #define E0_HARDWARE_SERIAL Serial1
  #define HARDWARE_SERIAL1_RX 21
  #define HARDWARE_SERIAL1_TX 22
  //#define MONITOR_DRIVER_STATUS
  #define TMC_DEBUG

Can I check which version of Marlin are you using? I think pins 25 and 26 are being used for I2S on your original pins_esp32.h so I don't know if your configuration to use these pins for TX and RX could be an issue.

My last compile was on March 24, using bugfix-2.0.x pulled on March 23. No issues with moving X, Y, and Z axes, will test out a print later if necessary.

@simon-jouet
Copy link
Owner Author

simon-jouet commented Mar 29, 2020

Thanks @vivian-ng, good to know that it's working well. I will try it again today now that i've got time to think it over and know that it should work :)

I'm using latest bugfix 2.0.x branch from yesterday (commit 2f7e5cf)

Regarding the pins you're right but the I2S version of my controller uses different pins, just that the config on marlin was never updated for the i2s version of my board, considering stepping and status work when only one driver is selected I don't think it's the issue.

EDIT: Still not working for me, not sure what i'm missing... I've tried the latest and the first and last commit on the 23/03 and I get exactly the same behaviour. With only one TMC2209 driver it works perfectly (even with the different addresses), with 2+ TMC2209 drivers it just doesn't work. The driver status is reported properly but not stepping is happening.

		X	Y	Z	E
Address		0	1	2	3
Enabled		true	true	true	true
Set current	800	850	800	800
RMS current	795	826	795	795
MAX current	1121	1165	1121	1121
Run current	25/31	26/31	25/31	25/31
Hold current	12/31	13/31	12/31	12/31
CS actual	12/31	13/31	12/31	12/31
PWM scale	35	27	34	40
vsense		1=.18	1=.18	1=.18	1=.18
stealthChop	true	true	true	true
msteps		16	16	16	16
tstep		max	max	max	max
PWM thresh.				
[mm/s]					
OT prewarn	false	false	false	false
off time	3	3	3	3
blank time	24	24	24	24
hysteresis
 -end		-1	-1	-1	-1
 -start		1	1	1	1
Stallguard thrs	0	0	0	0
DRVSTATUS	X	Y	Z	E
sg_result	0	0	0	0
stst					
olb					
ola					
s2gb					
s2ga					
otpw					
ot					
157C					
150C					
143C					
120C					
s2vsa					
s2vsb					
Driver registers:
		X	0xC0:0C:00:00
		Y	0xC0:0D:00:00
		Z	0xC0:0C:00:00
		E	0xC0:0C:00:00
Testing X connection... OK
Testing Y connection... OK
Testing Z connection... OK
Testing E connection... OK

@vivian-ng If you don't mind could you give me a bit more info on the following so I can hopefully get it working?

  • Do a git diff on your marlin branch so I can see all the changes you have? In case i've missed something
  • Send the commit you're using just in case it's that (which i kind of doubt)
  • Send a M122 before and after stepping. Surprisingly for me when using a single motor (when it works) the status changes between init and stepping, while with multiple drivers it doesn't
  • Any particular wiring for the TX/RX? I'm just connecting all of it to the TX and RX and considering the status is working fine I'm not expecting this to be the issue. Do you pull MS1 and MS2 to GND to make them LOW or you just pull them to VIO to put them high? (again considering the address is working fine with one driver I don't think that would be the issue)
  • Maybe a revealing issue - when I issue M84 (Motors off) the motors remain enabled. If I only enable one TMC2209 in configuration_adv then motor off is working as expected :(
  • Which TMC2209 drivers are you using and any specific version (i'm using fysetc v2.1)

Thanks very much! Bit frustrating to go back to this after a while and get stuck with issues like this

@felixstorm
Copy link

@simon-jouet Yes, your mention did reach me and nice to hear that you are still using the ESP32 with Marlin. My board has now been in use for almost a year without ever wanting to go back 😉
Unfortunately I only use TMC2208 drivers in standalone mode (not even connected via SPI), so there's probably not much I can help you with 😞

@simon-jouet
Copy link
Owner Author

@felixstorm Yeah still using my ESP32 board, I just had (and have) little time to play with my printer in the last 6 months or so. It was quite a step up when I tried to update my Marlin version this weekend :). Using Luc's webui is a significant improvement (I might play with the javascript/html at some point).

Thanks for the details regarding your setup, I've been tempted to just put my 2209 in standalone mode, but I'm in no rush to get that plugged in (still using drv8825 on the printer at the moment). And considering it's working for @vivian-ng it's probably because i'm doing something wrong, although with even more debugging yesterday I didn't find what the issue is...

Thanks both for the reply, I hope everyone is keeping well with what has been happening

@vivian-ng
Copy link

@simon-jouet Try taking a look at this blog post, it talks about the wiring for using TMC2209s on a single UART through slave addresses. The part about the hardware serial #defines are outdated, though.

@simon-jouet
Copy link
Owner Author

Thanks @vivian-ng I will look through this in more details maybe tonight, but from the looks of it just now the wiring looks to be okay (I used different tmc2209 drivers) but nothing is obviously wrong... :(

@simon-jouet
Copy link
Owner Author

simon-jouet commented Mar 30, 2020

@vivian-ng still no success, what's in the blog is pretty much exactly what I do. I use fysetc 2.1 drivers that have the UART config a bit different but the UART bit looks to be working so I don't think that's the issue.

I've basically got the following and it doesn't work, if I comment out X_DRIVER_TYPE or Y_DRIVER_TYPE (to only have a single TMC2209) then it works fine.

#define X_DRIVER_TYPE TMC2209
#define Y_DRIVER_TYPE TMC2209

#define  X_SLAVE_ADDRESS 0
#define  Y_SLAVE_ADDRESS 1

#define MONITOR_DRIVER_STATUS
#define TMC_DEBUG

#define X_HARDWARE_SERIAL Serial1
#define Y_HARDWARE_SERIAL Serial1

#define HARDWARE_SERIAL1_RX                   25
#define HARDWARE_SERIAL1_TX                   26

I just had a look with the logic analyzer and I can see that when only one TMC2209 is present then the steps are sent properly, however with 2 TMC2209 the steps are not sent. Now I have to figure out why they are not sent... need to figure out first if it's a hardware or software issue...

EDIT: If I manually short the STEP pin to high then it does step, so yeah the issue is somewhere in the stepper/scheduler when 2 TMC2209 are enabled (or something wrong with the I2S stream but it works fine with just one driver)

@vivian-ng
Copy link

@simon-jouet Try printing with other drivers, if they work, then I think we can assume the I2S stepper stream is working fine, and it is more likely something else (firmware or hardware) that is causing the problem. If you have changed the pins since the last time, it may be a good idea to double check that all the pins are correctly assigned in the pins file with respect to the actual hardware. I made that mistake before when I redid my board but forgot to update the pins file...

@simon-jouet
Copy link
Owner Author

simon-jouet commented Mar 31, 2020

@vivian-ng I started working on this last night, it works fine with other drivers and it works fine with TMC2209 too (but just when one is used). If i use more than one tmc2209 (regardless of the axis) it stops working, if I try every axis independently it works...

I've started debugging a bit, my guess is that something is wrong initializing the stepper stream for some reason. I haven't had much time last night but I will try to look at that this week

EDIT: Okay so the issue is that with more than one TMC2209 my slave data for I2S (on GPIO 17) isn't driven properly. With just one TMC it's fine. I guess something is trying to use port 17 when it shouldn't

image

@simon-jouet
Copy link
Owner Author

Okay I've figured it out, it's a bug in the code, not exactly sure what's the exact cause of the issue but I've moved i2s_init() from HAL_init() to the end of HAL_init_board() and it's working.

My guess the cause is that Serial2 is somehow initialised with multiple drivers therefore the GPIO17 is redefined from being a I2S pin to be a UART pin and the stepping fails.

Looking at the code I can see that the BOARD_INIT() is done after the TMC Serial bit, so I would guess that's why. Going to look a bit more, to see if I can open a proper MR on Marlin instead of just moving code around

@simon-jouet
Copy link
Owner Author

Thanks guys :), I've opened a MR to "fix" that

MarlinFirmware#17351

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants