teemuatlut / TMCStepper

MIT License
497 stars 194 forks source link

TMC2208 connection issues after v0.3.2 #24

Open teemuatlut opened 5 years ago

teemuatlut commented 5 years ago

Documenting here for others to see.

There seems to be some connection issues with TMC2208 with at least AVR and DUE platforms. The likely commit to cause the issues is d27257900a14ee8cd8df7d5c9b01f1f60c3c4d0b. @gloomyandy Any thoughts? I'll try reverting things bit by bit and see what the offending line is but I'll have to revert at least some of your PR and make a bugfix release.

Current solution is to use v0.3.1 until the issue is fixed.

ghost commented 5 years ago

yes it's on the board, it goes from the tx pin to the rx pin on the cpu.

ghost commented 5 years ago

You might need to alter the solder serial jumper option on your stepper boards, depends how you have them set. It's caught a lot of people out, including me ;)

teemuatlut commented 5 years ago

Some of my boards of v10, meaning one pin is UART and another pin is NC. Needed to bridge those and I'll see what happens now.

gloomyandy commented 5 years ago

@doggyfan no problem...

The AVR SoftwareSerial is a little worrying, as you say I wonder if it has got worse for some reason? I'm not very familiar with the AVR but I wonder if slowing down the baud rate and allowing interrupts during both the send and receive code would be better? Would have to make sure that the interrupt on change is still disabled though!

Yes the SKR board seems to have hit the "ender 3" price point. Lots of folks seem to be getting them. The Bigtreetech facebook page is awash with folks asking the same questions over and over. I'm amazed at how many folks seem to be happy just to follow some random YouTube video on how to do this stuff, happily installing pretty much anything you tell them to install on a PC, not to mention running stuff that could burn their house down! It's a bit of an eye opener really.

@teemuatlut I've just rebased my changes on your current master, so hopefully the branch TMC2208_PR is up todate now.

One of the nice things about the SKR board is that they have pretty quickly publish a schematic for it on their Bigtreetech github account.

@teemuatlut which driver boards do you have? One slight oddity about the SKR is that it feeds the TX/RX into the pin next to the one marked PDN. On some driver boards this is marked UART I think, but on most NC. The general advice is to bridge the two pins on the driver together. But there is a nice trick that you can do the same thing by installing a jumper at 90 degrees to the normal jumper install under the driver. I think it is the two centre pins of the first two rows. It is easy to work out if you have a meter, just buzz out the header pins against the jumper pins. This probably does not make much sense sorry!

teemuatlut commented 5 years ago

0xC0:0C:00:00 with your branch v0.3.1. Now I'll have to see if my own code worked after all!

I just got the SKR because it was cheap and I'll likely have to troubleshoot with it for a lot of people. I have no intention of using it with any of my printers.

teemuatlut commented 5 years ago

@gloomyandy I had previously fetched your branch and it worked alright. Now after pulling the latest changes, I've got a good DRV_STATUS response (the hex value everyone looks at) but a failed Testing connection = All low. Most interestingly frustrating.

ghost commented 5 years ago

@teemuatlut on the SKR or AVR board ?

teemuatlut commented 5 years ago

SKR, but it seems to work now. No idea what was wrong minute ago.

gloomyandy commented 5 years ago

@teemuatlut hmm that's strange all fine on my SKR both the DRV_STATUS and the connection test. Tried about 10 M122 and all worked... Will keep an eye on it though!

teemuatlut commented 5 years ago

Seems a bit random actually. I'm getting maybe 60/40 of OK / ALL LOW.

I pushed the master branch online and that get me OK response 100% of time. For me at least. But that still works with just a delay and read while available, so I'd still like to get in the sync bits find.

gloomyandy commented 5 years ago

That is very odd. Could you try increasing replyDelay from 10 to say 20 and see if that makes any difference to your failure rate? What do you have hooked up to the SKR anything that could be generating interrupts? Also although I'm sure you know this do you have the board powered from an external supply? The TMC2208s don't seem to be very happy when running with board using USB power.

teemuatlut commented 5 years ago

The board is powered by USB but there's 12V power of course for the drivers. Increased to 30. Seemed to be a bit more reliable but still has issues.

Switched to Internal 5V line and errors increased. I sent 5x M122 in quick succession and 4 had ALL LOW error.

gloomyandy commented 5 years ago

Is that all low on just one driver or multiple drivers? How many drivers do you have configured (I have all 5, I wonder if that makes any difference?). I can do M122 after M122 with no errors at all, really strange.

teemuatlut commented 5 years ago

Just one.

https://github.com/teemuatlut/TMCStepper/compare/tmc2208_find_sync Here's my development branch for this thing and it seems to work alright. Probably due to the delay after writing as a low value on that seems to upset the board. Maybe the final answer is something in between the two.

If you want to refine your own branch, you can see that you don't need to add anything to gain access to TMC2208_SYNC or addr, as those are already passed as part of the datagram.

gloomyandy commented 5 years ago

Could you try adding a delay at say the end of _sendDatagram in my version to see if that makes it work reliably? No problem if you can't as I can test it later tonight. If that does make it work I wonder if that tells us anything about the need for a delay in the write code?

But I'd be happy to go with your version of the code if you are happy with it?

I wonder if this version works any better on the AVR with software serial for @doggyfan ?

I did think about doing that, but I wanted to keep the code not making assumptions about the data it is sending. But I guess if we are going to go that way we may want to get rid of the length parameter and just have the code expect to have a fixed format packet. But I don't suppose it matters really.

gloomyandy commented 5 years ago

Ok just tried with a single driver and with my code I get errors about 50% of the time. I added a 1mS delay at the end of _sendDatagram and sure enough back to working 100%.

I think I did mention above that changing the timing of things may have unexpected consequences!

teemuatlut commented 5 years ago

Yea I can verify that on my end. I'll start working from your code base and bring it a bit closer to what I had. Hopefully without breaking anything.

gloomyandy commented 5 years ago

I'm just doing some testing with your current code now. Seems pretty good so far.

Does that code work OK on the AVR, both hardware and software?

teemuatlut commented 5 years ago

I'll need to check again since there have been so many changes since.

teemuatlut commented 5 years ago

https://github.com/teemuatlut/TMCStepper/tree/serial_sync

Diff to master

Reverse log of gloomyandy/TMC2208_PR..HEAD Reverse is a bit easier to follow if you want to see the thought process behind every step.

gloomyandy commented 5 years ago

Hmm that looks to me as if it could end up stuck in the read 5 bytes loop forever if for some reason the TMC2208 does not send the remaining 5 bytes (or more likely the UART misses one or more). Also are the delays of 10mS really needed? I found a delay of 1mS worked fine for me?

I ran a couple of prints with your previous code (this one https://github.com/teemuatlut/TMCStepper/tree/tmc2208_find_sync) on my SKR with no problems. In some ways I prefer this version. It preserved the timing of the code that has been out there for some time, but hopefully fixes the issues we have been seeing.

teemuatlut commented 5 years ago

The delay of 10ms is conservative at this stage and I haven't tweaked it at all yet. The previous code didn't have the abort timing in effect; the code is commented out. There's also a bug in the sync bitmask. 0xFFFFF is just 20b when we should be looking for 3 bytes / 24b. EDIT: Though it likely didn't matter as the first nibble would be 0, from 0x05.

I'll add the same timeout abort code to the second loop aswell.

gloomyandy commented 5 years ago

The previous code doesn't really need the abort timing though. It has the fixed delay at the start after which all of the data should be sat in the read buffer. Which is pretty much what the old code used to do. However it does need to add a test on the reply from the read if it is ever < 0 then abort with no data found. So something like....

    while (serPtr.available() > 0) serPtr.read(); // Flush
    for(int i=0; i<=len; i++) serPtr.write(datagram[i]);
        // Wait for response to be sent and read into UART buffer
    delay(replyDelay);

    const uint32_t sync_target = (((uint32_t)datagram[0] & 0x0F)<<16) | 0xFF00 | datagram[2];
    uint32_t sync = 0;

    do { // Find SYNC nibble and the rest of the pattern
        int16_t res = serPtr.read();
                // end of data with no sync? Abort
                if (res < 0) return 0;
        sync <<= 8;
        sync |= res & 0xFF;
        sync &= 0xFFFFFF;

    } while ((sync) != sync_target);

    uint64_t out = sync;

    // Read data bytes and CRC
    for(uint8_t i = 0; i<5; i++) {
        int16_t res = serPtr.read();
                // not enough data after sync? Abort.
                if (res < 0) return 0;
        out <<= 8;
        out |= res&0xFF;
    }
    return out;

I thought your use of the short mask was deliberate! The first byte of the datagram does not have to be just TMC2208_SYNC it can have data in the low nibble (and perhaps it should to make the sent data different to the expected receive data?). In the above code I have masked out that nibble when setting the target. Note I've not tested the code above!

teemuatlut commented 5 years ago

I tried returning with negative response bytes but it broke the implementation.

I've pushed the most recent commits and I've also reverted back into my mistake of 20b bitmask as it actually makes sense after all. The current code seems really stable and reliable so if it works with AVR, I'll merge it into the next release. I'm definitely not going to spend another day on this =)

gloomyandy commented 5 years ago

I tried returning with negative response bytes but it broke the implementation.

That's a little worrying, was that with the fixed length initial delay, rather than doing the timeout stuff? The two sort of go together. I wonder if in this case the initial delay (replyDelay) is sometimes just not long enough? At 5mS it is certainly pretty marginal for the LPC176x software serial code.

As to the mask it would really be better to mask the bits when you initialize sync_target and use the full 24bit mask later. In a response the first byte should always be TMC2208_SYNC anything else is an error.

I see you have moved the "extra" delay out into the read routine (which I guess match the one in the write). I suspect that using replyDelay may be a little excessive, but who knows!

Let me know when you are happy with the code and I'll grab a copy and give it a try.

teemuatlut commented 5 years ago

I think it's close to ready now. I increased replyDelay back to 5 as it made the AVR SW UART happier.

I see your point on bitmask.

https://github.com/teemuatlut/TMCStepper/tree/serial_sync

gloomyandy commented 5 years ago

OK, will give it a try....

viper93458 commented 5 years ago

Hello, not that you want to hear from someone without the ability to help with the development side, but I did want to report that I have non-working TMC2208's on AVR for a while and never reported a bug in the Marlin forums as I had no way to really determine where the problem is. I have (2) AVR machines that have the communications issue. I am only reporting this because when this thread started, it was mentioned that no one was reporting it in the Marling forums. :)

Fortunately for me, I just use my printers for fun and I have been way too busy lately to worry about them not working. To that end I just lurk around the forums and watch all the conversations.

Thanks and keep up the good work! I hope to see a permanent fix soon.

-William

teemuatlut commented 5 years ago

I'd rather hear about it than for something to go unnoticed. But the default answer for communication issues is to check the wiring and configuration. A fundamental issue on the library level would very likely cause many more people to speak up. The good/bad thing about the TMC2208 drivers in particular is that they "work" even if you don't have UART communication working to and from the driver.

If you want, you can try the serial_sync branch, but I'm planning to make a new release today that includes the changes. Other than that it's back to Marlin troubleshooting bullet points. But I know the new code works and there should be no reason for it to not work for others as well.

gloomyandy commented 5 years ago

Just to confirm I've been running the serial_sync branch for the last day or so and have happily completed several prints from the SD card and via Octoprint. My version of Marlin is modified to enable MONITOR_DRIVER_STATUS when using software serial so it will have been generating a fair number of read/writes. I've added additional logging to check for CRC errors etc. and have seen none at all.

Oh should have said all of that on an SKR V1.3 board with five active TMC2208s.

ghost commented 5 years ago

The trouble is, most people are going to stay firmly fixed in the 8-bit world, which means using a (a currently) troublesome software serial driver for them :(

A spare timer (to create timed ints) on the AVR (or hanging off a used one) would be a very useful to fix the AVR software serial driver.

teemuatlut commented 5 years ago

I tested the branch with AVR SW UART as well.

gloomyandy commented 5 years ago

@doggyfan Have you had chance to test this latest branch (with extra logging)? I'm curious as to how bad it is and how it compares with the previous state.

gloomyandy commented 5 years ago

When I say previous I mean whatever the one was that was a "working" version on that platform.

ghost commented 5 years ago

You're determined to keep me in 8-bit mode aren't you @gloomyandy lol

I'll check in the next hour or, just resting my poorly back at mo.

ghost commented 5 years ago

Right den. This is boot-up on the AVR. I've added a retry loop (up to 9 times if need be) as the AVR is trouble some.

AVR boot-up ``` 00: start echo:Marlin bugfix-2.0.x echo: Last Updated: 2018-01-20 | Author: (doggyfan, AVR) echo:Compiled: May 17 2019 echo: Free Memory: 1613 PlannerBufferBytes: 1456 01: echo:Hardcoded Default Settings Loaded echo: G21 ; Units in mm (mm) echo: M149 C ; Units in Celsius echo:Filament settings: Disabled echo: M200 D1.75 echo: M200 D0 echo:Steps per unit: echo: M92 X50.00 Y50.00 Z400.00 E84.88 echo:Maximum feedrates (units/s): echo: M203 X225.00 Y225.00 Z22.00 E400.00 echo:Maximum Acceleration (units/s2): echo: M201 X1800.00 Y1800.00 Z176.00 E3200.00 echo:Acceleration (units/s2): P R T echo: M204 P1800.00 R3200.00 T1800.00 echo:Advanced: B S T X Y Z E echo: M205 B20000.00 S0.00 T0.00 X10.00 Y10.00 Z1.00 E5.00 echo:Home offset: echo: M206 X0.00 Y0.00 Z0.00 echo:Filament Runout Sensor: echo: M412 S1 echo:Mesh Bed Leveling: echo: M420 S0 Z0.00 echo:Material heatup parameters: echo: M145 S0 H180 B70 F0 echo: M145 S1 H240 B110 F0 echo:PID settings: echo: M301 P16.25 I2.67 D24.68 echo: M304 P57.48 I1.36 D608.58 echo:User thermistors: M305 P0 R4700.0 T100000.0 B3950.0 C0.000000000 ; HOTEND 0 M305 P1 R4700.0 T100000.0 B3950.0 C0.000000000 ; BED echo:Power-Loss Recovery: echo: M413 S1 echo:Stepper driver current: echo: M906 X1000 echo:Hybrid Threshold: echo: M913 TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_16_00_82_84_D2 Retry-1 CRC-ERROR 05_FF_6C_16_00_82_84_D2 TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_16_00_82_84_D5 Retry-2 CRC-OK 05_FF_6C_16_00_82_84_D5 X76 echo:Driver stepping mode: echo: TMC_TX 05_00_00_48 TMC_RX 1ms 8 05_FF_00_00_00_00_C0_8D Retry-1 CRC-OK 05_FF_00_00_00_00_C0_8D M569 S1 X echo:Filament load/unload lengths: echo: M603 L0.00 U100.00 echo:Filament runout sensor: echo: M412 S1 TMC_TX 05_00_6C_CA TMC_RX 0ms 8 05_FF_6C_8B_00_81_84_D4 Retry-1 CRC-ERROR 05_FF_6C_8B_00_81_84_D4 TMC_TX 05_00_6C_CA TMC_RX 0ms 8 05_FF_6C_13_00_81_82_DA Retry-2 CRC-ERROR 05_FF_6C_13_00_81_82_DA TMC_TX 05_00_6C_CA TMC_RX 30ms 0 TIMED OUT Retry-3 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6C_CA TMC_RX 0ms 8 05_FF_6C_16_00_81_82_D2 Retry-4 CRC-ERROR 05_FF_6C_16_00_81_82_D2 TMC_TX 05_00_6C_CA TMC_RX 30ms 0 TIMED OUT Retry-5 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6C_CA TMC_RX 0ms 8 05_FF_6C_16_00_81_86_D6 Retry-6 CRC-ERROR 05_FF_6C_16_00_81_86_D6 TMC_TX 05_00_6C_CA TMC_RX 30ms 0 TIMED OUT Retry-7 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6C_CA TMC_RX 30ms 0 TIMED OUT Retry-8 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6C_CA TMC_RX 0ms 8 05_FF_6C_16_00_81_86_D6 Retry-9 CRC-ERROR 05_FF_6C_16_00_81_86_D6 echo:SD card ok Testing X connection... TMC_TX 05_00_6F_84 TMC_RX 0ms 8 05_FF_6F_C0_11_00_00_A6 Retry-1 CRC-OK 05_FF_6F_C0_11_00_00_A6 OK echo:SD card ok ```
ghost commented 5 years ago

hmmmm. With the latest and not so greatest Marlin I get this from an M112. No idea why and totally no feedback as to why from the AVR board (user should ALWAYS be told why it's killed itself). It's OK on the SKR 1.3 board though.

On the AVR LCD it just says ..

KILLED
PRINTER HALTED
Please reset
03:43: M112
ok
Error:Printer halted. kill() called!
teemuatlut commented 5 years ago

M112 is emergency stop

ghost commented 5 years ago

oops !

ghost commented 5 years ago

AVR M122 lol ..

M122 output ``` 08:57: M122 X Enabled TMC_TX 05_00_06_6F TMC_RX 1ms 8 05_FF_06_20_00_A0_50_FC Retry-1 CRC-ERROR 05_FF_06_20_00_A0_50_FC TMC_TX 05_00_06_6F TMC_RX 1ms 8 05_FF_06_20_00_03_40_1A Retry-2 CRC-ERROR 05_FF_06_20_00_03_40_1A TMC_TX 05_00_06_6F TMC_RX 0ms 8 05_FF_06_20_00_03_41_1D Retry-3 CRC-ERROR 05_FF_06_20_00_03_41_1D TMC_TX 05_00_06_6F TMC_RX 1ms 8 05_FF_06_20_00_01_41_1D Retry-4 CRC-ERROR 05_FF_06_20_00_01_41_1D TMC_TX 05_00_06_6F TMC_RX 0ms 8 05_FF_06_20_00_03_41_1A Retry-5 CRC-OK 05_FF_06_20_00_03_41_1A false Set current 1000 RMS current TMC_TX 05_00_6C_CA TMC_RX 30ms 0 TIMED OUT Retry-1 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6C_CA TMC_RX 30ms 0 TIMED OUT Retry-2 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6C_CA TMC_RX 0ms 8 05_FF_6C_16_00_81_82_F5 Retry-3 CRC-ERROR 05_FF_6C_16_00_81_82_F5 TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_16_00_82_84_D5 Retry-4 CRC-OK 05_FF_6C_16_00_82_84_D5 994 MAX current TMC_TX 05_00_6C_CA TMC_RX 30ms 0 TIMED OUT Retry-1 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6C_CA TMC_RX 0ms 8 05_FF_6C_16_00_82_84_D5 Retry-2 CRC-OK 05_FF_6C_16_00_82_84_D5 1402 Run current 17/31 Hold current 8/31 CS actual TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5F Retry-1 CRC-ERROR 05_FF_6F_C0_08_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5F Retry-2 CRC-ERROR 05_FF_6F_C0_08_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 0ms 8 05_FF_6F_C0_08_00_00_5F Retry-3 CRC-ERROR 05_FF_6F_C0_08_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_04_00_00_5F Retry-4 CRC-ERROR 05_FF_6F_C0_04_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5E Retry-5 CRC-OK 05_FF_6F_C0_08_00_00_5E 8/31 PWM scale TMC_TX 05_00_71_EB TMC_RX 0ms 8 05_FF_71_00_00_00_0A_F3 Retry-1 CRC-ERROR 05_FF_71_00_00_00_0A_F3 TMC_TX 05_00_71_EB TMC_RX 1ms 8 05_FF_71_00_00_00_0D_F7 Retry-2 CRC-ERROR 05_FF_71_00_00_00_0D_F7 TMC_TX 05_00_71_EB TMC_RX 1ms 8 05_FF_71_00_00_00_0A_F6 Retry-3 CRC-OK 05_FF_71_00_00_00_0A_F6 10 vsense TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_1B_00_C1_84_D5 Retry-1 CRC-ERROR 05_FF_6C_1B_00_C1_84_D5 TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_16_00_81_82_D5 Retry-2 CRC-ERROR 05_FF_6C_16_00_81_82_D5 TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_16_00_81_82_D2 Retry-3 CRC-ERROR 05_FF_6C_16_00_81_82_D2 TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_16_00_82_84_D5 Retry-4 CRC-OK 05_FF_6C_16_00_82_84_D5 0=.325 stealthChop TMC_TX 05_00_6F_84 TMC_RX 30ms 0 TIMED OUT Retry-1 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6F_84 TMC_RX 0ms 8 05_FF_6F_C0_04_00_00_5E Retry-2 CRC-ERROR 05_FF_6F_C0_04_00_00_5E TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_04_00_00_5E Retry-3 CRC-ERROR 05_FF_6F_C0_04_00_00_5E TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5E Retry-4 CRC-OK 05_FF_6F_C0_08_00_00_5E true msteps TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_1B_00_82_84_D4 Retry-1 CRC-ERROR 05_FF_6C_1B_00_82_84_D4 TMC_TX 05_00_6C_CA TMC_RX 30ms 0 TIMED OUT Retry-2 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6C_CA TMC_RX 30ms 0 TIMED OUT Retry-3 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6C_CA TMC_RX 30ms 0 TIMED OUT Retry-4 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6C_CA TMC_RX 0ms 8 05_FF_6C_16_00_82_84_D5 Retry-5 CRC-OK 05_FF_6C_16_00_82_84_D5 4 tstep TMC_TX 05_00_12_B7 TMC_RX 30ms 5 TIMED OUT Retry-1 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_12_B7 TMC_RX 0ms 8 05_FF_12_00_0F_FF_FF_1D Retry-2 CRC-OK 05_FF_12_00_0F_FF_FF_1D max pwm threshold 52 [mm/s] TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_16_00_82_82_D4 Retry-1 CRC-ERROR 05_FF_6C_16_00_82_82_D4 TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_1B_00_81_82_F5 Retry-2 CRC-ERROR 05_FF_6C_1B_00_81_82_F5 TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_16_00_82_84_D5 Retry-3 CRC-OK 05_FF_6C_16_00_82_84_D5 76.02 OT prewarn TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_84_00_00_5F Retry-1 CRC-ERROR 05_FF_6F_C0_84_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_04_00_00_5F Retry-2 CRC-ERROR 05_FF_6F_C0_04_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5F Retry-3 CRC-ERROR 05_FF_6F_C0_08_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 30ms 0 TIMED OUT Retry-4 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6F_84 TMC_RX 0ms 8 05_FF_6F_C0_04_00_00_5F Retry-5 CRC-ERROR 05_FF_6F_C0_04_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5E Retry-6 CRC-OK 05_FF_6F_C0_08_00_00_5E false off time TMC_TX 05_00_6C_CA TMC_RX 30ms 0 TIMED OUT Retry-1 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6C_CA TMC_RX 0ms 8 05_FF_6C_16_00_82_84_D5 Retry-2 CRC-OK 05_FF_6C_16_00_82_84_D5 4 blank time TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_13_00_81_82_D2 Retry-1 CRC-ERROR 05_FF_6C_13_00_81_82_D2 TMC_TX 05_00_6C_CA TMC_RX 0ms 8 05_FF_6C_16_00_82_84_D5 Retry-2 CRC-OK 05_FF_6C_16_00_82_84_D5 24 hysteresis -end TMC_TX 05_00_6C_CA TMC_RX 30ms 0 TIMED OUT Retry-1 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6C_CA TMC_RX 0ms 8 05_FF_6C_16_00_82_84_F5 Retry-2 CRC-ERROR 05_FF_6C_16_00_82_84_F5 TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_16_00_81_86_D2 Retry-3 CRC-ERROR 05_FF_6C_16_00_81_86_D2 TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_13_00_81_84_D5 Retry-4 CRC-ERROR 05_FF_6C_13_00_81_84_D5 TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_16_00_82_82_D2 Retry-5 CRC-ERROR 05_FF_6C_16_00_82_82_D2 TMC_TX 05_00_6C_CA TMC_RX 30ms 0 TIMED OUT Retry-6 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6C_CA TMC_RX 0ms 8 05_FF_6C_16_00_82_84_D5 Retry-7 CRC-OK 05_FF_6C_16_00_82_84_D5 2 -start TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_1B_80_82_82_D5 Retry-1 CRC-ERROR 05_FF_6C_1B_80_82_82_D5 TMC_TX 05_00_6C_CA TMC_RX 30ms 0 TIMED OUT Retry-2 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6C_CA TMC_RX 30ms 0 TIMED OUT 08:58: Retry-3 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6C_CA TMC_RX 30ms 0 TIMED OUT Retry-4 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6C_CA TMC_RX 30ms 0 TIMED OUT Retry-5 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6C_CA TMC_RX 30ms 0 TIMED OUT Retry-6 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6C_CA TMC_RX 0ms 8 05_FF_6C_16_00_81_82_F5 Retry-7 CRC-ERROR 05_FF_6C_16_00_81_82_F5 TMC_TX 05_00_6C_CA TMC_RX 30ms 0 TIMED OUT Retry-8 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6C_CA TMC_RX 0ms 8 05_FF_6C_16_00_81_82_DA Retry-9 CRC-ERROR 05_FF_6C_16_00_81_82_DA 1 Stallguard thrs DRVSTATUS X stst TMC_TX 05_00_6F_84 TMC_RX 0ms 8 05_FF_6F_C0_08_00_00_5E Retry-1 CRC-OK 05_FF_6F_C0_08_00_00_5E X olb TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5F Retry-1 CRC-ERROR 05_FF_6F_C0_08_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_04_00_00_5F Retry-2 CRC-ERROR 05_FF_6F_C0_04_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5E Retry-3 CRC-OK 05_FF_6F_C0_08_00_00_5E ola TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_84_00_00_5E Retry-1 CRC-ERROR 05_FF_6F_C0_84_00_00_5E TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_04_00_00_4F Retry-2 CRC-ERROR 05_FF_6F_C0_04_00_00_4F TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5E Retry-3 CRC-OK 05_FF_6F_C0_08_00_00_5E s2gb TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_0C_00_00_5F Retry-1 CRC-ERROR 05_FF_6F_C0_0C_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 0ms 8 05_FF_6F_C0_08_00_00_5F Retry-2 CRC-ERROR 05_FF_6F_C0_08_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 30ms 0 TIMED OUT Retry-3 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6F_84 TMC_RX 0ms 8 05_FF_6F_C0_08_00_00_5E Retry-4 CRC-OK 05_FF_6F_C0_08_00_00_5E s2ga TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_04_00_00_5E Retry-1 CRC-ERROR 05_FF_6F_C0_04_00_00_5E TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_84_00_00_5F Retry-2 CRC-ERROR 05_FF_6F_C0_84_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_0C_00_00_5F Retry-3 CRC-ERROR 05_FF_6F_C0_0C_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5E Retry-4 CRC-OK 05_FF_6F_C0_08_00_00_5E otpw TMC_TX 05_00_6F_84 TMC_RX 30ms 0 TIMED OUT Retry-1 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6F_84 TMC_RX 0ms 8 05_FF_6F_C0_04_00_00_5F Retry-2 CRC-ERROR 05_FF_6F_C0_04_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5E Retry-3 CRC-OK 05_FF_6F_C0_08_00_00_5E ot TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_0C_00_00_5F Retry-1 CRC-ERROR 05_FF_6F_C0_0C_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 0ms 8 05_FF_6F_C0_04_00_00_5F Retry-2 CRC-ERROR 05_FF_6F_C0_04_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 0ms 8 05_FF_6F_C0_04_00_00_5E Retry-3 CRC-ERROR 05_FF_6F_C0_04_00_00_5E TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5E Retry-4 CRC-OK 05_FF_6F_C0_08_00_00_5E 157C TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_4F Retry-1 CRC-ERROR 05_FF_6F_C0_08_00_00_4F TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_0C_00_00_5E Retry-2 CRC-ERROR 05_FF_6F_C0_0C_00_00_5E TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5E Retry-3 CRC-OK 05_FF_6F_C0_08_00_00_5E 150C TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_84_00_00_5E Retry-1 CRC-ERROR 05_FF_6F_C0_84_00_00_5E TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5F Retry-2 CRC-ERROR 05_FF_6F_C0_08_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5F Retry-3 CRC-ERROR 05_FF_6F_C0_08_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 30ms 0 TIMED OUT Retry-4 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6F_84 TMC_RX 30ms 0 TIMED OUT Retry-5 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6F_84 TMC_RX 0ms 8 05_FF_6F_C0_08_00_00_5E Retry-6 CRC-OK 05_FF_6F_C0_08_00_00_5E 143C TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_84_00_00_5E Retry-1 CRC-ERROR 05_FF_6F_C0_84_00_00_5E TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_0C_00_00_5F Retry-2 CRC-ERROR 05_FF_6F_C0_0C_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5E Retry-3 CRC-OK 05_FF_6F_C0_08_00_00_5E 120C TMC_TX 05_00_6F_84 TMC_RX 30ms 0 TIMED OUT Retry-1 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6F_84 TMC_RX 0ms 8 05_FF_6F_C0_08_00_00_5E Retry-2 CRC-OK 05_FF_6F_C0_08_00_00_5E s2vsa s2vsb Driver registers: TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5E Retry-1 CRC-OK 05_FF_6F_C0_08_00_00_5E X 0xC0:08:00:00 Testing X connection... TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5F Retry-1 CRC-ERROR 05_FF_6F_C0_08_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_04_00_00_5E Retry-2 CRC-ERROR 05_FF_6F_C0_04_00_00_5E TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5E Retry-3 CRC-OK 05_FF_6F_C0_08_00_00_5E OK ok ```
ghost commented 5 years ago

a fair few retries to overcome the software serial problem.

But the serial sync'ing certainly works no problem at all. It's always best to use it, that's what TMC has put the sync byte(s) in for.

32-bit (SKR board) is perfect though, never an error in sight. Now if only we could get everyone to go 32-bit.

ghost commented 5 years ago

Another AVR M122 ..

M122 output ``` X Enabled TMC_TX 05_00_06_6F TMC_RX 1ms 8 05_FF_06_20_00_03_41_1D Retry-1 CRC-ERROR 05_FF_06_20_00_03_41_1D TMC_TX 05_00_06_6F TMC_RX 1ms 8 05_FF_06_20_00_03_40_1B Retry-2 CRC-ERROR 05_FF_06_20_00_03_40_1B TMC_TX 05_00_06_6F TMC_RX 30ms 8 00_03_C1_1A TIMED OUT Retry-3 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_06_6F TMC_RX 30ms 7 00_05_FF_06_20_00_A0_69 TIMED OUT Retry-4 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_06_6F TMC_RX 1ms 8 05_FF_06_20_00_03_50_E1 Retry-5 CRC-ERROR 05_FF_06_20_00_03_50_E1 TMC_TX 05_00_06_6F TMC_RX 1ms 8 05_FF_06_20_00_03_40_1A Retry-6 CRC-ERROR 05_FF_06_20_00_03_40_1A TMC_TX 05_00_06_6F TMC_RX 0ms 8 05_FF_06_20_00_01_41_1B Retry-7 CRC-ERROR 05_FF_06_20_00_01_41_1B TMC_TX 05_00_06_6F TMC_RX 0ms 8 05_FF_06_20_00_01_41_1B Retry-8 CRC-ERROR 05_FF_06_20_00_01_41_1B TMC_TX 05_00_06_6F TMC_RX 30ms 8 00_03_41_1A TIMED OUT Retry-9 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_16_00_82_84_D5 Retry-1 CRC-OK 05_FF_6C_16_00_82_84_D5 true Set current 1000 RMS current TMC_TX 05_00_6C_CA TMC_RX 30ms 8 00_82_84_D5 TIMED OUT Retry-1 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_16_00_82_84_D5 Retry-2 CRC-OK 05_FF_6C_16_00_82_84_D5 994 MAX current TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_13_00_82_84_D5 Retry-1 CRC-ERROR 05_FF_6C_13_00_82_84_D5 TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_16_00_81_82_D2 Retry-2 CRC-ERROR 05_FF_6C_16_00_81_82_D2 TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_1B_00_81_82_F5 Retry-3 CRC-ERROR 05_FF_6C_1B_00_81_82_F5 TMC_TX 05_00_6C_CA TMC_RX 0ms 8 05_FF_6C_16_00_82_84_D5 Retry-4 CRC-OK 05_FF_6C_16_00_82_84_D5 1402 Run current 17/31 Hold current 8/31 CS actual TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_0C_00_00_1D Retry-1 CRC-OK 05_FF_6F_C0_0C_00_00_1D 12/31 PWM scale TMC_TX 05_00_71_EB TMC_RX 1ms 8 05_FF_71_00_00_00_0F_17 Retry-1 CRC-ERROR 05_FF_71_00_00_00_0F_17 TMC_TX 05_00_71_EB TMC_RX 1ms 8 05_FF_71_00_00_00_0E_16 Retry-2 CRC-OK 05_FF_71_00_00_00_0E_16 14 vsense TMC_TX 05_00_6C_CA TMC_RX 0ms 8 05_FF_6C_16_00_82_84_D5 Retry-1 CRC-OK 05_FF_6C_16_00_82_84_D5 0=.325 stealthChop TMC_TX 05_00_6F_84 TMC_RX 30ms 7 00_05_FF_6F_C0_21_00_D1 TIMED OUT Retry-1 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_0B_00_00_D3 Retry-2 CRC-OK 05_FF_6F_C0_0B_00_00_D3 true msteps TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_0B_00_81_84_D5 Retry-1 CRC-ERROR 05_FF_6C_0B_00_81_84_D5 TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_16_00_82_82_F5 Retry-2 CRC-ERROR 05_FF_6C_16_00_82_82_F5 TMC_TX 05_00_6C_CA TMC_RX 0ms 8 05_FF_6C_16_00_81_82_D2 Retry-3 CRC-ERROR 05_FF_6C_16_00_81_82_D2 TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_16_00_81_82_D2 Retry-4 CRC-ERROR 05_FF_6C_16_00_81_82_D2 TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_16_00_81_82_F5 Retry-5 CRC-ERROR 05_FF_6C_16_00_81_82_F5 TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_16_00_82_84_D5 Retry-6 CRC-OK 05_FF_6C_16_00_82_84_D5 4 tstep TMC_TX 05_00_12_B7 TMC_RX 30ms 6 00_00_05_FF_12_00_E8_C7 TIMED OUT Retry-1 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_12_B7 TMC_RX 30ms 6 00_00_05_FF_12_00_0F_C7 TIMED OUT Retry-2 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_12_B7 TMC_RX 30ms 7 00_05_FF_12_00_0F_FF_1E TIMED OUT Retry-3 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_12_B7 TMC_RX 30ms 7 00_05_FF_12_00_0F_FF_1D TIMED OUT Retry-4 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_12_B7 TMC_RX 1ms 8 05_FF_12_00_0F_FF_FF_1D Retry-5 CRC-OK 05_FF_12_00_0F_FF_FF_1D max pwm threshold 52 [mm/s] TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_16_00_81_86_D6 Retry-1 CRC-ERROR 05_FF_6C_16_00_81_86_D6 TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_16_00_81_84_D5 Retry-2 CRC-ERROR 05_FF_6C_16_00_81_84_D5 TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_16_00_82_84_D5 Retry-3 CRC-OK 05_FF_6C_16_00_82_84_D5 76.02 OT prewarn TMC_TX 05_00_6F_84 TMC_RX 30ms 6 00_80_00_DC TIMED OUT Retry-1 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6F_84 TMC_RX 30ms 7 00_00_00_D8 TIMED OUT Retry-2 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_05_00_00_DC Retry-3 CRC-ERROR 05_FF_6F_C0_05_00_00_DC TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_0A_00_00_DC Retry-4 CRC-ERROR 05_FF_6F_C0_0A_00_00_DC TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_09_00_00_D8 Retry-5 CRC-ERROR 05_FF_6F_C0_09_00_00_D8 TMC_TX 05_00_6F_84 TMC_RX 30ms 6 00_00_00_D8 TIMED OUT Retry-6 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_0A_00_00_D8 Retry-7 CRC-OK 05_FF_6F_C0_0A_00_00_D8 false off time TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_16_00_82_82_D4 Retry-1 CRC-ERROR 05_FF_6C_16_00_82_82_D4 TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_16_00_81_82_DA Retry-2 CRC-ERROR 05_FF_6C_16_00_81_82_DA TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_16_00_81_82_D2 Retry-3 CRC-ERROR 05_FF_6C_16_00_81_82_D2 TMC_TX 05_00_6C_CA TMC_RX 0ms 8 05_FF_6C_13_00_81_86_D6 Retry-4 CRC-ERROR 05_FF_6C_13_00_81_86_D6 TMC_TX 05_00_6C_CA TMC_RX 30ms 8 00_82_84_D5 TIMED OUT Retry-5 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_16_00_82_84_D5 Retry-6 CRC-OK 05_FF_6C_16_00_82_84_D5 4 blank time TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_16_00_82_84_F5 Retry-1 CRC-ERROR 05_FF_6C_16_00_82_84_F5 TMC_TX 05_00_6C_CA TMC_RX 0ms 8 05_FF_6C_16_00_82_84_F5 Retry-2 CRC-ERROR 05_FF_6C_16_00_82_84_F5 TMC_TX 05_00_6C_CA 35:29: TMC_RX 30ms 8 00_83_84_F5 TIMED OUT Retry-3 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_16_00_82_84_D2 Retry-4 CRC-ERROR 05_FF_6C_16_00_82_84_D2 TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_13_00_82_84_D5 Retry-5 CRC-ERROR 05_FF_6C_13_00_82_84_D5 TMC_TX 05_00_6C_CA TMC_RX 0ms 8 05_FF_6C_16_00_82_82_D2 Retry-6 CRC-ERROR 05_FF_6C_16_00_82_82_D2 TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_16_00_81_82_D5 Retry-7 CRC-ERROR 05_FF_6C_16_00_81_82_D5 TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_1B_00_82_84_D6 Retry-8 CRC-ERROR 05_FF_6C_1B_00_82_84_D6 TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_13_00_82_84_D5 Retry-9 CRC-ERROR 05_FF_6C_13_00_82_84_D5 16 hysteresis -end TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_1B_00_81_82_D2 Retry-1 CRC-ERROR 05_FF_6C_1B_00_81_82_D2 TMC_TX 05_00_6C_CA TMC_RX 30ms 8 00_82_84_D5 TIMED OUT Retry-2 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_16_00_82_84_D5 Retry-3 CRC-OK 05_FF_6C_16_00_82_84_D5 2 -start TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_16_00_82_82_F5 Retry-1 CRC-ERROR 05_FF_6C_16_00_82_82_F5 TMC_TX 05_00_6C_CA TMC_RX 30ms 7 00_82_84_D5 TIMED OUT Retry-2 CRC-OK 00_00_00_00_00_00_00_00 TMC_TX 05_00_6C_CA TMC_RX 1ms 8 05_FF_6C_16_00_82_84_D5 Retry-3 CRC-OK 05_FF_6C_16_00_82_84_D5 1 Stallguard thrs DRVSTATUS X stst TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5E Retry-1 CRC-OK 05_FF_6F_C0_08_00_00_5E X olb TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_0C_00_00_5E Retry-1 CRC-ERROR 05_FF_6F_C0_0C_00_00_5E TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5F Retry-2 CRC-ERROR 05_FF_6F_C0_08_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5E Retry-3 CRC-OK 05_FF_6F_C0_08_00_00_5E ola TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_04_00_00_5F Retry-1 CRC-ERROR 05_FF_6F_C0_04_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_04_00_00_5E Retry-2 CRC-ERROR 05_FF_6F_C0_04_00_00_5E TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_04_00_00_5F Retry-3 CRC-ERROR 05_FF_6F_C0_04_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_0C_00_00_5F Retry-4 CRC-ERROR 05_FF_6F_C0_0C_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 0ms 8 05_FF_6F_C0_0C_00_00_5E Retry-5 CRC-ERROR 05_FF_6F_C0_0C_00_00_5E TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5E Retry-6 CRC-OK 05_FF_6F_C0_08_00_00_5E s2gb TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5F Retry-1 CRC-ERROR 05_FF_6F_C0_08_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_04_00_00_5F Retry-2 CRC-ERROR 05_FF_6F_C0_04_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 0ms 8 05_FF_6F_C0_04_00_00_4F Retry-3 CRC-ERROR 05_FF_6F_C0_04_00_00_4F TMC_TX 05_00_6F_84 TMC_RX 0ms 8 05_FF_6F_C0_08_00_00_5E Retry-4 CRC-OK 05_FF_6F_C0_08_00_00_5E s2ga TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5F Retry-1 CRC-ERROR 05_FF_6F_C0_08_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_04_00_00_5F Retry-2 CRC-ERROR 05_FF_6F_C0_04_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 0ms 8 05_FF_6F_C0_0C_00_00_5F Retry-3 CRC-ERROR 05_FF_6F_C0_0C_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 0ms 8 05_FF_6F_C0_08_00_00_5E Retry-4 CRC-OK 05_FF_6F_C0_08_00_00_5E otpw TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5F Retry-1 CRC-ERROR 05_FF_6F_C0_08_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_04_00_00_5F Retry-2 CRC-ERROR 05_FF_6F_C0_04_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 0ms 8 05_FF_6F_C0_0C_00_00_5F Retry-3 CRC-ERROR 05_FF_6F_C0_0C_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 0ms 8 05_FF_6F_C0_08_00_00_5E Retry-4 CRC-OK 05_FF_6F_C0_08_00_00_5E ot TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5F Retry-1 CRC-ERROR 05_FF_6F_C0_08_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_04_00_00_5E Retry-2 CRC-ERROR 05_FF_6F_C0_04_00_00_5E TMC_TX 05_00_6F_84 TMC_RX 0ms 8 05_FF_6F_C0_04_00_00_5F Retry-3 CRC-ERROR 05_FF_6F_C0_04_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_04_00_00_5F Retry-4 CRC-ERROR 05_FF_6F_C0_04_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5E Retry-5 CRC-OK 05_FF_6F_C0_08_00_00_5E 157C TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_04_00_00_5F Retry-1 CRC-ERROR 05_FF_6F_C0_04_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_0C_00_00_5F Retry-2 CRC-ERROR 05_FF_6F_C0_0C_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 0ms 8 05_FF_6F_C0_08_00_00_5E Retry-3 CRC-OK 05_FF_6F_C0_08_00_00_5E 150C TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5E Retry-1 CRC-OK 05_FF_6F_C0_08_00_00_5E 143C TMC_TX 05_00_6F_84 TMC_RX 0ms 8 05_FF_6F_C0_08_00_00_5E Retry-1 CRC-OK 05_FF_6F_C0_08_00_00_5E 120C TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5E Retry-1 CRC-OK 05_FF_6F_C0_08_00_00_5E s2vsa s2vsb Driver registers: TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5E Retry-1 CRC-OK 05_FF_6F_C0_08_00_00_5E X 0xC0:08:00:00 Testing X connection... TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_04_00_00_5E Retry-1 CRC-ERROR 05_FF_6F_C0_04_00_00_5E TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_04_00_00_6F Retry-2 CRC-ERROR 05_FF_6F_C0_04_00_00_6F TMC_TX 05_00_6F_84 TMC_RX 1ms 8 05_FF_6F_C0_08_00_00_5F Retry-3 CRC-ERROR 05_FF_6F_C0_08_00_00_5F TMC_TX 05_00_6F_84 TMC_RX 0ms 8 05_FF_6F_C0_08_00_00_5E Retry-4 CRC-OK 05_FF_6F_C0_08_00_00_5E OK ok ```
teemuatlut commented 5 years ago

What code where you using for testing? If the code was as bad your log would suggest, I should been seeing a whole lot more failed connection tests.

ghost commented 5 years ago

Your serial_sync code and the current Marlin code.

ghost commented 5 years ago

Your current serial sync with added debug code ..

serial sync code ```cpp #include "TMCStepper.h" #include "TMC_MACROS.h" #define _DEBUG 1 // '0' = no debug, '1' = debug #if _DEBUG #include "/Projects/3D Printer/Marlin 2/mine/Marlin/src/core/serial.h" #include "/Projects/3D Printer/Marlin 2/mine/Marlin/src/libs/hex_print_routines.h" #endif ... uint8_t TMC2208Stepper::calcCRC(uint8_t datagram[], uint8_t len) { uint8_t crc = 0; for (uint8_t i = 0; i < len; i++) { uint8_t currentByte = datagram[i]; for (uint8_t j = 0; j < 8; j++) { if ((crc >> 7) ^ (currentByte & 0x01)) { crc = (crc << 1) ^ 0x07; } else { crc = (crc << 1); } crc &= 0xff; currentByte = currentByte >> 1; } } return crc; } void TMC2208Stepper::write(uint8_t addr, uint32_t regVal) { uint8_t len = 7; addr |= TMC_WRITE; uint8_t datagram[] = {TMC2208_SYNC|0xf0, TMC2208_SLAVE_ADDR, addr, (uint8_t)(regVal>>24), (uint8_t)(regVal>>16), (uint8_t)(regVal>>8), (uint8_t)(regVal>>0), 0x00}; datagram[len] = calcCRC(datagram, len); #if SW_CAPABLE_PLATFORM if (SWSerial != NULL) { for(int i=0; i<=len; i++){ bytesWritten += SWSerial->write(datagram[i]); } } else #endif { for(int i=0; i<=len; i++){ bytesWritten += HWSerial->write(datagram[i]); } } delay(replyDelay); } template uint64_t _sendDatagram(SERIAL_TYPE &serPtr, uint8_t datagram[], const uint8_t len, uint16_t timeout) { #if _DEBUG uint16_t timeout_ms = timeout; uint8_t bytes_rx = 0; SERIAL_EOL(); SERIAL_ECHOPGM("TMC_TX "); SERIAL_ECHOPAIR(" ", hex_byte(datagram[0])); for (uint8_t i = 1; i <= len; i++) SERIAL_ECHOPAIR("_", hex_byte(datagram[i])); SERIAL_EOL(); #endif while (serPtr.available() > 0) serPtr.read(); // Flush for(int i=0; i<=len; i++) serPtr.write(datagram[i]); // scan for the rx frame and read it uint32_t ms = millis(); uint32_t sync_target = ((uint32_t)datagram[0]<<16) | 0xFF00 | datagram[2]; uint32_t sync = 0; do { uint32_t ms2 = millis(); if (ms2 != ms) { // 1ms tick ms = ms2; timeout--; } if (!timeout) { #if _DEBUG SERIAL_ECHOPGM("TMC_RX"); SERIAL_ECHOPAIR(" ", timeout_ms - timeout, "ms"); SERIAL_ECHOPAIR(" ", bytes_rx); SERIAL_ECHOPAIR(" ", hex_byte((uint8_t)(sync >> 24))); SERIAL_ECHOPAIR("_", hex_byte((uint8_t)(sync >> 16))); SERIAL_ECHOPAIR("_", hex_byte((uint8_t)(sync >> 8))); SERIAL_ECHOPAIR("_", hex_byte((uint8_t)(sync >> 0))); SERIAL_ECHOPGM(" TIMED OUT"); SERIAL_EOL(); #endif return 0; } int16_t res = serPtr.read(); if (res < 0) continue; sync <<= 8; sync |= res & 0xFF; sync &= 0xFFFFFF; #if _DEBUG bytes_rx++; #endif } while (sync != sync_target); uint64_t out = sync; for(uint8_t i=0; i<5;) { uint32_t ms2 = millis(); if (ms2 != ms) { // 1ms tick ms = ms2; timeout--; } if (!timeout) { #if _DEBUG SERIAL_ECHOPGM("TMC_RX"); SERIAL_ECHOPAIR(" ", timeout_ms - timeout, "ms"); SERIAL_ECHOPAIR(" ", bytes_rx); SERIAL_ECHOPAIR(" ", hex_byte((uint8_t)(out >> 56))); SERIAL_ECHOPAIR("_", hex_byte((uint8_t)(out >> 48))); SERIAL_ECHOPAIR("_", hex_byte((uint8_t)(out >> 40))); SERIAL_ECHOPAIR("_", hex_byte((uint8_t)(out >> 32))); SERIAL_ECHOPAIR("_", hex_byte((uint8_t)(out >> 24))); SERIAL_ECHOPAIR("_", hex_byte((uint8_t)(out >> 16))); SERIAL_ECHOPAIR("_", hex_byte((uint8_t)(out >> 8))); SERIAL_ECHOPAIR("_", hex_byte((uint8_t)(out >> 0))); SERIAL_ECHOPGM(" TIMED OUT"); SERIAL_EOL(); #endif return 0; } int16_t res = serPtr.read(); if (res < 0) continue; out <<= 8; out |= res & 0xFF; #if _DEBUG bytes_rx++; #endif i++; } #if _DEBUG SERIAL_ECHOPGM("TMC_RX"); SERIAL_ECHOPAIR(" ", timeout_ms - timeout, "ms"); SERIAL_ECHOPAIR(" ", bytes_rx); SERIAL_ECHOPAIR(" ", hex_byte((uint8_t)(out >> 56))); SERIAL_ECHOPAIR("_", hex_byte((uint8_t)(out >> 48))); SERIAL_ECHOPAIR("_", hex_byte((uint8_t)(out >> 40))); SERIAL_ECHOPAIR("_", hex_byte((uint8_t)(out >> 32))); SERIAL_ECHOPAIR("_", hex_byte((uint8_t)(out >> 24))); SERIAL_ECHOPAIR("_", hex_byte((uint8_t)(out >> 16))); SERIAL_ECHOPAIR("_", hex_byte((uint8_t)(out >> 8))); SERIAL_ECHOPAIR("_", hex_byte((uint8_t)(out >> 0))); SERIAL_EOL(); #endif while (serPtr.available() > 0) serPtr.read(); // Flush return out; } uint32_t TMC2208Stepper::read(uint8_t addr) { constexpr uint8_t len = 3; addr |= TMC_READ; uint8_t datagram[] = {TMC2208_SYNC, TMC2208_SLAVE_ADDR, addr, 0x00}; datagram[len] = calcCRC(datagram, len); uint64_t out = 0x00000000UL; for (uint8_t retry = 1; retry <= 9; retry++) { #if SW_CAPABLE_PLATFORM if (SWSerial != NULL) { SWSerial->listen(); out = _sendDatagram(*SWSerial, datagram, len, abort_window); SWSerial->stopListening(); } else #endif { out = _sendDatagram(*HWSerial, datagram, len, abort_window); } delay(replyDelay); uint8_t out_datagram[] = {(uint8_t)(out>>56), (uint8_t)(out>>48), (uint8_t)(out>>40), (uint8_t)(out>>32), (uint8_t)(out>>24), (uint8_t)(out>>16), (uint8_t)(out>>8), (uint8_t)(out>>0)}; CRCerror = (calcCRC(out_datagram, 7) == (uint8_t)(out&0xFF)) ? false : true; // debug #if _DEBUG SERIAL_ECHOPAIR("Retry-", retry); if (CRCerror) SERIAL_ECHOPGM(" CRC-ERROR "); else SERIAL_ECHOPGM(" CRC-OK "); SERIAL_ECHOPAIR(" ", hex_byte((uint8_t)(out >> 56))); SERIAL_ECHOPAIR("_", hex_byte((uint8_t)(out >> 48))); SERIAL_ECHOPAIR("_", hex_byte((uint8_t)(out >> 40))); SERIAL_ECHOPAIR("_", hex_byte((uint8_t)(out >> 32))); SERIAL_ECHOPAIR("_", hex_byte((uint8_t)(out >> 24))); SERIAL_ECHOPAIR("_", hex_byte((uint8_t)(out >> 16))); SERIAL_ECHOPAIR("_", hex_byte((uint8_t)(out >> 8))); SERIAL_ECHOPAIR("_", hex_byte((uint8_t)(out >> 0))); SERIAL_EOL(); #endif // probably better to return nothing rather than random bad data. if (CRCerror) out = 0; if (out != 0 && !CRCerror) break; } return out>>8; } ```
ghost commented 5 years ago

I want to swap over to TMC5160's and use SPI to do constant stepper monitoring all the time but they are somewhat costly at the moment. But TMC2208's on the 32-bit do it for me at the moment.

teemuatlut commented 5 years ago

Here's mine with no modifications done. There are a few failed attempts but it's not as bad as was in your log. You can also see that even with the failed reads, there's still a successful test connection, which essentially calls DRV_STATUS again and compares it to invalid values.

After this I again called M122 thirty times and all had successful reads on both the hex value as well as test connection.

M122 output ``` >>> M122 SENDING:M122 X Enabled false Set current 800 RMS current 795 MAX current 1121 Run current 25/31 Hold current 12/31 CS actual 12/31 PWM scale 14 vsense 1=.18 stealthChop true msteps 16 tstep max pwm threshold 0 [mm/s] - OT prewarn false off time 3 blank time 24 hysteresis -end -1 -start 1 Stallguard thrs DRVSTATUS X stst olb ola s2gb s2ga otpw ot 157C 150C 143C 120C s2vsa s2vsb Driver registers: X 0xC0:0C:00:00 Testing X connection... OK >>> M122 SENDING:M122 X Enabled true Set current 800 RMS current 795 MAX current 1121 Run current 25/31 Hold current 12/31 CS actual 12/31 PWM scale 14 vsense 1=.18 stealthChop true msteps 16 tstep max pwm threshold 0 [mm/s] - OT prewarn false off time 3 blank time 24 hysteresis -end -1 -start 1 Stallguard thrs DRVSTATUS X stst X olb ola s2gb s2ga otpw ot 157C 150C 143C 120C s2vsa s2vsb Driver registers: X 0x00:00:00:00 Bad response! Testing X connection... OK >>> M122 SENDING:M122 X Enabled false Set current 800 RMS current 795 MAX current 1121 Run current 25/31 Hold current 12/31 CS actual 12/31 PWM scale 14 vsense 1=.18 stealthChop true msteps 16 tstep max pwm threshold 0 [mm/s] - OT prewarn false off time 3 blank time 24 hysteresis -end -1 -start 1 Stallguard thrs DRVSTATUS X stst X olb ola s2gb s2ga otpw ot 157C 150C 143C 120C s2vsa s2vsb Driver registers: X 0x00:00:00:00 Bad response! Testing X connection... OK >>> M122 SENDING:M122 X Enabled false Set current 800 RMS current 795 MAX current 1121 Run current 25/31 Hold current 12/31 CS actual 12/31 PWM scale 14 vsense 1=.18 stealthChop true msteps 16 tstep max pwm threshold 0 [mm/s] - OT prewarn false off time 0 blank time 24 hysteresis -end -1 -start 1 Stallguard thrs DRVSTATUS X stst olb ola s2gb s2ga otpw ot 157C 150C 143C 120C s2vsa s2vsb Driver registers: X 0xC0:0C:00:00 Testing X connection... OK >>> M122 SENDING:M122 X Enabled false Set current 800 RMS current 795 MAX current 1121 Run current 25/31 Hold current 12/31 CS actual 12/31 PWM scale 14 vsense 1=.18 stealthChop true msteps 16 tstep max pwm threshold 0 [mm/s] - OT prewarn false off time 3 blank time 24 hysteresis -end -1 -start 1 Stallguard thrs DRVSTATUS X stst X olb ola s2gb s2ga otpw ot 157C 150C 143C 120C s2vsa s2vsb Driver registers: X 0xC0:0C:00:00 Testing X connection... OK >>> M122 SENDING:M122 X Enabled false Set current 800 RMS current 795 MAX current 1121 Run current 25/31 Hold current 12/31 CS actual 12/31 PWM scale 14 vsense 1=.18 stealthChop true msteps 16 tstep max pwm threshold 0 [mm/s] - OT prewarn false off time 0 blank time 24 hysteresis -end -1 -start 1 Stallguard thrs DRVSTATUS X stst X olb ola s2gb s2ga otpw ot 157C 150C 143C 120C s2vsa s2vsb Driver registers: X 0xC0:0C:00:00 Testing X connection... OK >>> M122 SENDING:M122 X Enabled false Set current 800 RMS current 795 MAX current 1121 Run current 25/31 Hold current 12/31 CS actual 12/31 PWM scale 14 vsense 1=.18 stealthChop true msteps 16 tstep max pwm threshold 0 [mm/s] - OT prewarn false off time 3 blank time 24 hysteresis -end -1 -start 1 Stallguard thrs DRVSTATUS X stst X olb ola s2gb s2ga otpw ot 157C 150C 143C 120C s2vsa s2vsb Driver registers: X 0xC0:0C:00:00 Testing X connection... OK >>> M122 SENDING:M122 X Enabled false Set current 800 RMS current 795 MAX current 1121 Run current 25/31 Hold current 12/31 CS actual 12/31 PWM scale 14 vsense 1=.18 stealthChop true msteps 16 tstep max pwm threshold 0 [mm/s] - OT prewarn false off time 3 blank time 24 hysteresis -end -1 -start 1 Stallguard thrs DRVSTATUS X stst X olb ola s2gb s2ga otpw ot 157C 150C 143C 120C s2vsa s2vsb Driver registers: X 0xC0:0C:00:00 Testing X connection... OK >>> M122 SENDING:M122 X Enabled false Set current 800 RMS current 795 MAX current 2025 Run current 25/31 Hold current 12/31 CS actual 12/31 PWM scale 14 vsense 1=.18 stealthChop true msteps 16 tstep max pwm threshold 0 [mm/s] - OT prewarn false off time 3 blank time 24 hysteresis -end -1 -start 1 Stallguard thrs DRVSTATUS X stst X olb ola s2gb s2ga otpw ot 157C 150C 143C 120C s2vsa s2vsb Driver registers: X 0xC0:0C:00:00 Testing X connection... OK >>> M122 SENDING:M122 X Enabled false Set current 800 RMS current 795 MAX current 1121 Run current 25/31 Hold current 12/31 CS actual 12/31 PWM scale 14 vsense 1=.18 stealthChop true msteps 16 tstep max pwm threshold 0 [mm/s] - OT prewarn false off time 3 blank time 24 hysteresis -end -1 -start 1 Stallguard thrs DRVSTATUS X stst X olb ola s2gb s2ga otpw ot 157C 150C 143C 120C s2vsa s2vsb Driver registers: X 0xC0:0C:00:00 Testing X connection... OK >>> M122 SENDING:M122 X Enabled true Set current 800 RMS current 795 MAX current 1121 Run current 25/31 Hold current 12/31 CS actual 0/31 PWM scale 14 vsense 1=.18 stealthChop true msteps 16 tstep max pwm threshold 0 [mm/s] - OT prewarn false off time 3 blank time 24 hysteresis -end -1 -start 1 Stallguard thrs DRVSTATUS X stst X olb ola s2gb s2ga otpw ot 157C 150C 143C 120C s2vsa s2vsb Driver registers: X 0xC0:0C:00:00 Testing X connection... OK ```
ghost commented 5 years ago

It might depend on the configuration of Marlin as a whole (how resource stretched the ISR's are maybe), I don't know, I can only report back with what I get.

teemuatlut commented 5 years ago

https://github.com/teemuatlut/TMCStepper/releases/tag/v0.3.3

ghost commented 5 years ago

How do you make your text colapsable like that on these github messages ? (your last M122 output)

I'll that in future as it saves the reader having to scroll through all the text.