Closed sh4jonny closed 6 years ago
Try this branch and see if it's any better: https://github.com/thinkyhead/Marlin/tree/bf2_eeprom_M913
@thinkyhead i try it now and have same error ((((
I notice when i run M122 , compared to yours, my RMS Current and Max current is much lower than yours. and probably the reason i feel the TMC2130 has very little torque ... Anybody know how to increse the RMS Current ?
Anybody know how to increse the RMS Current ?
To set the motor current for X use M906 X<mA>
.
@thinkyhead Yeah i know how to set the current, i was just wondering why my RMS current and Max current are so much lower than his values since we have alomst the same current set ..
@teemuatlut — I'm curious about the difference between the rms_current
and setCurrent
methods. I see that in tmc2208_init
it calls st.rms_current(st.getCurrent(), ...)
but in tmc2130_init
it instead calls st.setCurrent(st.getCurrent(), ...)
. Is this just a question of the two driver models having different characteristics and running modes?
When setting a new value rms_current
is the newer version of setCurrent
where just the arguments are in a different order. This was to allow the user to use rms_current(uint16_t, float)
or even just rms_current(uint16_t)
to set the current in a more simple way and not necessarily have to provide the hold_multiplier
or r_sense
values.
When reading they, or their counterparts, act a bit different. uint16_t getCurrent
returns the value user asked to use. uint16_t rms_current
reads from the driver and calculates the actual mA value.
@thinkyhead @teemuatlut can you help me? i have strange symbols in drivers output and driver error on the screen (((
What's your platform? There were a few changes to the way the extended axis codes were stored and it produced these strange symbols. This I believe was fixed already but I also saw it persist in some Due users output.
@thinkyhead @teemuatlut so look. just now i eject my sdcard! and error is gone!!! i have 2 tmc2130 on hardware SPI and SDcard. Arduino DUE and HackedRAMPS. and all works with 2 month ago branch state.
now i can 100% repeat this issue. when i insert sdcard i have drivers error. i eject it and all looks fine
SPI bus contention?
@thinkyhead yes HW SPI for drivers and SD card
Hi, I am having the same issue, I am using a MKS Gen 1.4 with a 'RepRap Discount Full Graphic Smart Controller' and using the the latest 1.1.X Dev version (also happens with 1.1.8). I installed TMC 2130 drivers using SPI and using the free pins for the CS. Everything works but the SD card, it fails to initialize and when trying to insert a card it errors out with 'Driver Error'. Is this because of using HW SPI and should use software? Any help is appreciated!
Please be very specific on how this happens.
A copy of the host log from power up to driver error would be most useful. It would be nice to see logs both with the SD card in and out when powering up. Probably best to attach them as .TXT files so as to make it easier to do side by side comparisons.
I noticed the echo:SD card ok a couple of times in the above when it shouldn't be there. The M43 one is absolutely strange.
>>> m43
SENDING:M43
echo:SD card ok
PIN: 00 RXD
Hi Bob, Thanks for the reply. I attached both logs as you requested. I hope they are helpful. If you need more info please let me know. StartUp-WithSD.txt StartUp-NoSD.txt
Just a quick update, it seems I got it working by disabling 'MONITOR_DRIVER_STATUS'. The interesting part is that the SD Card initializes successfully and works fine. For now I will leave this disabled although I don't know if there is still an issue and by disabling I am just ignoring the cause (I probably am...) Thanks!
@teemuatlut - does MONITOR_DRIVER_STATUS make use of an interrupt?
If yes that would explain why the SD card and TMC SPI transfers interfere with each other.
Another possibility is the SD card sets the SPI rate fairly high. Can the TMC chips handle 8MHz?
The TMC2130 can run the SPI at 4MHz max. Try enabling one of these: //#define SPI_SPEED SPI_HALF_SPEED // about 4MHz //#define SPI_SPEED SPI_QUARTER_SPEED // about 2 MHz
No and no.
I don't know how they behave with a higher clock like 8MHz when the CS line is not active.
I expect that the SD card sets the SPI controller to 8MHz and then later the monitor goes to check but doesn't re-init the speed.
We either need to have the monitor function re-init the speed each time it's run or limit the SD card speed. Where is the TMC SPI speed set?
https://github.com/teemuatlut/TMC2130Stepper/blob/master/src/source/TMC2130Stepper.cpp#L103
Does SD card init the mode and speed each time it tries communicating? The same way TMC2130 does there.
The SD card code only inits the SPI the first time a card is accessed. It inits it to mode 0 and 250K until the card reports it capabilities. After that it changes the speed to the configured value if the card can support it.
I see that the TMC2130 code inits it to 2M and mode 3.
Is mode 3 correct? Per TMC2130 DATASHEET (Rev. 1.09 / 2017-MAY-15) page 22 , "with the slave latching the data from SDI on the rising edge of SCK". That's mode 0. Maybe there's a newer data sheet out there. TMC2130_datasheet.pdf
If mode 0 is correct then we can add a check to limit the SD card speed to 2MHz when the TMC2130 is being used. Everyone will play nicely together.
See datasheet p23 and the blue hint box.
Usually this SPI timing is referred to as SPI MODE 3.
If I read the following correctly, SPI mode 0 and SPI mode 3 are equivalent as to when the data is clocked in. That means the 0 vs. 3 is probably a don't care and the only culprit is the speed.
I'll start PRs to limit the SD card speed.
@MikeInNs - please test my proposed fix. Replace your Conditionals_LCD.h file and see if the SD card and MONITOR_DRIVER_STATUS work together.
Conditionals_LCD bugfix-1.1.x.zip Conditionals_LCD bugfix-2.0.x.zip
@Bob-the-Kuhn, Thanks, will do! I am at work right now but I should have time this evening to test it out.
@Bob-the-Kuhn, I just tried your change but I am afraid the same issue persists. I even tried 1/2 and 1/8 SPI speed but no change. SD stops initializing, when inserting the card it errors with 'Driver Error'. If you need more info or want me to test something else just let me know. And thanks for your help!
Means there's another problem besides the speed.
I was thinking for a while that, if the TMC code was running a software SPI using the same SCK, MOSI & MISO pins as the SD card's hardware SPI, it would kill the MONITOR. But that wouldn't explain why the SD card wasn't functional.
Keep the new conditionals file and try this change to line 103 in .piolibdeps\TMC2130Stepper_ID1493\src\source\TMC2130Stepper.cpp
FROM
SPI.beginTransaction(SPISettings(16000000/8, MSBFIRST, SPI_MODE3));
TO
SPI.beginTransaction(SPISettings(16000000/8, MSBFIRST, SPI_MODE0));
If that doesn't do it then someone with the right hardware and a logic analyzer will need to troubleshoot it.
I
I don't have a functional TMC2130 to play with so I can't confirm it but ...
I downloaded a minimal config to a 2560 and, as soon as I plugged in the SD card, got a "X driver error detected:" message and the controller reset. It continued the error - reset loop as long as the SD card was inserted.
The problem was the X_CS_PIN was set to the same select pin as used by the SD card. When I changed pins_RAMPS.h so that X_CS_PIN wasn't assigned to pin 53 then the problem went away.
Try doing a M43 I to see if any of the TMC chip selects are shared with SDSS (or SS).
I was probably off in left field on that last comment.
I put a logic analyzer on my 2560 and found out that the TMC2130 is running a software SPI using different SCK & MOSI pins than the SD card.
@Bob-the-Kuhn, I will try changing the SPI mode for the TMC2130. Like yesterday, I am at work now so it will have to wait till I get back. You mentioned Software SPI, the weird thing is (well I find it weird) when I try to run the TMC’s using software SPI I end up with the same issue.
I did check with M43 my pin outs and as far as I can see nothing is conflicting, I had to change the pins for the CS lines in the Ramps.h.
Currently I have it setup as follows: SPI: MOSI, MISO and SCK connect to the hardware SPI pins on the board. X-CS: D11 (Servo Pin) Y-CS: D6 (Servo Pin) Z-CS: D5 (Servo Pin) EO-CS: D4 (Servo Pin) E1-CS (acting as Z2): D40 X-Diag1: XMin Endstop (D3) Y-Diag1: YMin Endstop (D14)
I have a TMC2130 connected to my DUE (RAMPS_FD_V1) via the softSPI. All is working as expected.
Please ZIP & post the following files: Configuration.h, Configuration_adv.h and pins_YOUR-BOARD.h
@Bob-the-Kuhn, thanks for willing to take a look a this, appreciate all the time you are putting into this. Attached are the files you requested, this is the working config, the only difference is the "MONITOR_DRIVER_STATUS" being switched off. (turning this on brings back the Driver Error)
I thought that I had a functioning TMC2130 but the chip select are not going active. I've tried both the hardware SPI and TMC software SPI. I've put the #define X_CS_PIN 38
in pins_RAMPS_FD_V1 and in Configuration_adv.h.
I've enabled the following in Configuration_adv.h:
#define HAVE_TMC2130
#if ENABLED(HAVE_TMC2130) // Choose your axes here. This is mandatory!
#define X_IS_TMC2130
...
#define X_CS_PIN 38
I there something else I need to enable?
As far as I know that should be it, maybe try another pin?
My sense from looking at the SD-related files is that the library (at the time Marlin adopted it) assumes that the SD card's SPI bus won't be shared with a device that needs different speeds and/or modes. Possibly the newer SDFat library is more savvy about this. ("Key changes: The SPI divisor has been replaced by SPISettings
in the begin()
call.")
The reason we haven't migrated is that the Marlin version includes some needed customizations (e.g., long filenames).
Since the SD code is getting a bit old, it may be worthwhile to do a minor overhaul to the SD libs, host them as proper libraries under the MarlinFirmware organization, and migrate to those as part of the 2.0.0 or 2.1.0 milestone. We should also evaluate alternative SD libraries, in case there happen to be any modern variants with cleaner interfaces and more flexibility.
I finally figured out my TMC2130 problem. I tried to use an endstop pin as the X_CS_PIN but on a RAMPS FD V1 board they are input only because of the board's design.
On the DUE for sure, the TMC2130 software only initializes the hardware SPI controller on the very first access. The result is the speed & mode are set by the last device to init the controller. In every case it's the SD card. The net result is the TMC2130 SPI accesses are changed from mode 3 to mode 0 soon after reset and run at the last speed set by the SD card code.
I did finally figure out how to limit the SD card's speed. The logic has to go into a different file. Please see if this fixes the monitor problem. Conditionals_post 2.0.x.zip
There is something strange going on with the SD card logic. It tries to access the card on startup even though the card isn't inserted and sometimes it leaves the SD select active all the time.
Something to look at tomorrow.
the TMC2130 software only initializes the hardware SPI controller on the very first access
It should init the SPI controller at the start of each communication attempt.
SPI.beginTransaction() isn't implemented on the DUE & LPC1768.
Damn. Maybe we should try to agree on a common implementation when compiling for the Due platforms.
Apparently there are some differences in the SPI class interface and implementation between AVR and SAM.
If I don't provide a SS pin for the beginTransaction
or begin
methods, it'll use the default SS pin to match settings. There are no pin arguments available for the AVR SPI.
Not sure if this will fix the issue but I'll be making the change for Due anyway.
I don't see a reason to change the TMC2130 software with the possible exception of the mode. As best I can tell the TMC2130 is happy with DUE & LPC1768 which puts the SPI into mode 0.
The mode change is a "nice to do" item as far as I'm concerned. I don't see any functional issues either way.
The Marlin software assumes the SPI users control the SPI slave select. I don't think there is such a thing as a default SPI select pin. All the pins files have one defined for the SD card on the LCD. At least on DUE the TMC2130 object is created with a chip select.
Eventually DUE & LPC1768 will support SPI.beginTransaction()
.
@Bob-the-Kuhn, I tried the Conditionals_Post.h you modified but I am afraid I am still experiencing the same issue.
@sh4jonny - please try the Conditionals_post 2.0.x.zip posted above and see if that fixes your DUE system issues. It did on mine.
@MikeInNs - I have your config in a 2560/RAMPS system & I can't duplicate your problem. I have five TMC2130s in it.
I can definitely get the kill message when I want to. Got plenty of them when learning how to setup my TMC2130 system.
I'm using a daisy chained cable. My system wouldn't run reliably until I put a 10K pull down on the very end of my cable. Before that I'd get a kill message from 2-120 seconds after reset.
Having the SD card inserted or not did not matter.
Maybe adding a pulldown will affect how your system works.
What an ugly pile of spaghetti!
Are there controllers/shields dedicated to the TMC2130 (doesn't need external cables)?
The above was using bugfix-1.1.x and PlatformIO. It compiles with Arduino 1.8.5 but it won't upload. I'm getting to hate Arduino.
@Bob-the-Kuhn, thanks so much for trouble shooting this! So yes, this means I might have a hardware issue with my board. My SPI lines are daisy chained as well, do you mind explaining where you used the pulldown resistor?
The only thing I can think off is that the MKS Gen V1.4 has pullup resistors on the endstops which I use with the Diag1 pins (X/Y) (Don't think the Ramps has these) So I can try different pins for these.
And yes, it's an ugly pile of spaghetti for sure, tried to keep the cables as short as possible and the daisy chaining helped a little. I haven't heard of any existing boards with the 2130's integrated using SPI, however a new board is going to be released that will have this, it's called 'The Revolve'
Thanks again Bob!
I haven't heard of any existing boards with the 2130's integrated using SPI
Einsy, Archim2, TRAMS (TMC5130) and probably a bunch of others that are currently in development. So while not many, there are still some and likely more to come.
I put the pull down on the MISO line on the very last connector in the daisy chain. My chain has more than five TMC2130 connectors on it so it was easy for me to cobble it up.
hi after a long time work with 2130 i update to last 2.0 branch 2.2.0 lib. and have a error. Other hardware is Arduino DUE and RAMPS4DUE. X Y with tmc2130. here is a Pronterface output:
also i have pins debug output
maybe i lost some definitions when merge configs? thank you!