Sensorless Dual Endstops and Stall Detection - Trinamics

Has anyone considered using the Trinamic drivers to do sensorless dual endstops? For those who aren’t aware, some of the stepper drivers produced by Trinamic can sense the feedback from the force being exerted on a stepper (like running into something).

Sensorless Endstops?

In 3D printing, this is usually used to allow the printer to do it's homing without mechanical endstops (it can detect when it bumps into the frame). I'm wondering about the feasibility of doing this with the Lowrider/MPCNC. First, the accuracy of the stall detection is good to 1 stop at best and 4 at worst. Assuming the worst case scenario of 4 stops, that's 1/50mm at our current 200 steps/mm X/Y settings, or less than one thou. This is actually quite a bit worse than mechanical endstops, but I suspect still way smaller than a laundry list of other factors that could affect accuracy. Of note: The additional cost of the drivers is more than just adding physical endstops, but would be simpler to set up (I think).

Stall Detection?

Currently, Marlin only uses the stall feedback for sensorless homing, but one interesting safety consideration is the detection of stalls. If the router got "hung up" on something due to being too deep, hitting a clamp, etc. then the router could theoretically detect the event and shut down the operation, potentially preventing a fire. This wouldn't be trivial. The loads present in a CNC are way higher than something like a 3D printer. I suspect they're pretty dynamic too. DOC, speed, etc. would all change the range of force which would be considered "normal". I do wonder, however, if you could measure the feedback for the first X inches of cut, use it to set a baseline, and then use that baseline in concert with an acceptable buffer amount and perhaps a bit of hysteresis to detect problems. This definitely depends on just how dynamic the cutting forces are though, which is something I'm currently ignorant to. You could absolutely start passively measuring feedback throughout normal usage, though, and find out how feasible this is. If your spindle is relay controlled then you could pretty easily turn it off. If not then you could just raise it to ZMax.

The recently released TMC2209 can handle the full current of our steppers, as can the older TMC5160. I snagged 5 of them as well as an SKR Pro board which should let me do dual endstops, laser cutting/etching, and digitally controlled air assist. I won’t have it for 4-6 weeks though so I’ll probably do my initial build with my spare SKR 1.3 and DRV8825s. I’m a programmer by trade and maintain some Trinamic Marlin firmware for the Ender 3 so I think I can handle the code side.


I like the idea of it. Sounds straightforward. Would really like to see it in action and costs.


When doing sensorless endstops, it reduces the sensitivity only while homing on the affected driver, so you’ll need to make sure that works with X2 and Y2. Marlin hasn’t been great in the past at being right when you combine corner cases like that, but sensorless homing and dual endstops have been out long enough, maybe it will work.

You’ll also need more IO. Each driver needs a CS pin if using 2130s. IDK how the uart ones deconflict.

As for the stall detection sensitivity, you don’t really care what the threshold is. If it skips, you’re done. If it doesn’t, then chive on. Doesn’t the prusa 3 have this concept? If it was just a snagged cable, you could continue. If your CAM was wrong, you’d need to be pretty clever to recover and you might as well start again, even if you’re cutting some air.

Good point about the edge case. If it isn’t implemented I’ll write a PR for it.

The boards I mentioned have the IO and even implement the connections via a jumper on the board itself rather than needing to modify the driver pins or add jumper wires. The TMC2209s further expand this with slave addressing in UART allowing multiple to be used per port.

You’re probably right about the threshold. I didn’t really consider that a skipped step will probably register under any sensitivity. That makes that much simpler. Seems like it might be something handy to have enabled should you really screw something up.

Maybe take a look at the prusa fork for marlin. They use the einsy Rambo board and sensorless homing

I should probably get in on this chat :slight_smile:


I have a SKR 1.3 with TMC2130’s and dual endstops on Y and Z and sensorless homing on all axis. I havent tried stall detection yet though.

With the LR2, there are a couple things to watch out for before you ruin your CNC, as it’s not designed for sensorless homing (or homing in general)

  1. sensorless Z with lead screws is generally considered to not be a thing you should try. It works, but you need to watch out! Prusa does it on Z Max so that they can drive the carriage up, and the coupler will be in compression when it hits the limit. To do that, you will need to put some clamps on your Z tubes to create a hard stop on the Z axis. OR you need to put a few spacers on your Z rods BETWEEN your coupler and stepper. I found 2 of the wheel bearing spacers to work well. Then you need to adjust your rod and coupler to take up the slack, so that when you home Z, there is no slack between the coupler and the spacers and the Z nut. I did this this way: - loosening ALL the coupler grub screws, - lower Z to home, - clamp the gantry down so it wont move - bring the lead screw UP until it makes contact with the stepper - lower the coupler as far as it will go so there is no gap beween it, the spacers and the nut - tighten the coupler to the lead screw and the motor.
  2. Now you can home Z and it works great... EXCEPT if you have just homed X, as when X is homed, you cant home Z as the x gantry hits the top bearing mounts on the Y plate! and when you do that, it will stretch the shit out of your coupler, to the point of having to replace it (ask me how i know grrr!) so, some solutions... - dont home all axis with G28 command and home manually - change the homing custom command in marlin to do G28 X, G1 X20, G28 Y Z (or whatever the right codes are) but that wont help if you press 'home all' on repetier or something. - Put a spacer onto the x rails so it homes 10-20mm away from the mount but lose some work area - home Z higher, so it clears the mount (just add a spacer or 2 to the lead screw? - modify the marlin code to move X 20mm away from the home position after homing X and before homing Z - i think there might be room to cut away part of the X plate to allow it to home all the way?
Thats what i found anyway... hope that helps? The wiring is a WHOLE LOT neater though without end stops!
1 Like

That’s really neat! I imagine that will be the way everything is done in the future.

Marlin has a firmware definition to tell it where to do the Z homing… I think it’s SAFE_HOMING or something like that


Now, that’s what I’m talking about!

I wasn’t really looking for Z homing as I just assumed that the leverage from the Z screw mixed with a very pointy bit would inevitably mean that the cutting edge sinks into the material a tiny amount before it registers, leaving a mark and potentially throwing off measurements. Gotta run power to the spindle anyway so I don’t mind having an extra wire for a touch plate there too much. The idea that it’s possible seems quite intriguing.

Soooo you’re totally gonna write the firmware for everyone and get a parts list going right? :slight_smile:

Ideally you could home to make the Z square (possibly at Zmax) and then probe to get the workspace Z=0.

Just don’t try homing z with a v bit endmill. I did that once, and it buried it up to the collet. Didn’t even slow down. This was in half inch plywood. MDF might have broken the endmill.

Sure thing. I’ll take Ryan’s firmware, merge in the latest Marlin version, then create firmware for a couple boards and post it.

1 Like

I have a Z homing setup with a pressure disc and an aluminum plate on top. Could probably do the same thing with this setup but just with a soft metal plate and maybe one of those cnc lead screw couplers that isn’t so springy. Not sure how hard the triaminic would be on the tip of the mill though.

Saw an MPCNC burn to death on the V1 Facebook page due to the Z-axis plunging into the work surface unexpectedly (power loss? bad g-code? interference?). I think that’s a great example of why stall detection is a good idea, especially with a relay controlled spindle that can be immediately powered off.


That is a good lesson in not leaving your machine alone. Stall detection won’t help if you have bad gcode, or you mount the bit at the wrong depth. These are way more dangerous than 3D printers and they need to be watched by humans.

I think we can all agree that you should keep your machine attended, but the reality is also that many machines will be left unattended for short periods of time (bathroom break, phone call) or aren’t monitored extremely closely (via a webcam, while busy on a computer in the same room, etc.). I think the majority of g-code errors would be caught, but of course, the number of errors that could occur is pretty much limitless. Errors that prevent X/Y movement, don’t turn off the spindle, or a DOC that’s large enough to light tinder but not skip a step would, of course, go unnoticed. A missed Z-axis raise, DOC that prevents movement, etc. would get caught. The idea definitely isn’t to encourage or enable leaving a machine alone.

Until you’re milling out a piece of hardwood and stall detection decides that knot you just hit is a stall and stops everything. I can’t remember if it kills motor power or just stops. If it just stops, might be alright, if it kills stepper power then it will ruin your workpiece. Even if it kills the spindle power, there will be enough enertia to drill into it a little bit, or a lot bit, depending on the mill diameter. I’ve already done the fire thing, so I’ll preach not leaving it alone until the sun goes out. Don’t take our preaching as your ideas aren’t good ideas, we’re just making sure everyone knows we don’t recommend leaving these things alone. Stall detection on the big machines are more for the safety of the machine, not the work piece or the endmill. Broken bit detection is hard to do on the big guys, probably impossible to do on these machines. Unless you do a John Saunders and try to home between operations.

Colton, did you get your firmware built? I’m just in the process of parts procurement for an MPCNC build, and ordered the SKR 1.1 Pro board with 2209 drivers. Just curious if you had a starting point for me, firmware-wise.


Unfortunately, no. I have the machine put together but am waiting on having garage space to finish the table. I would be happy to help you code it, though.

Thanks, Colton. I might take you up on that. So far, I’ve got Marlin compiled, and the TFT3.5 screen connected. I can use the screen to make jog the motors connected to the X and Y ports, which is all I’ve connected for now.

Things to do include setting up dual X and Y drivers, along with one Z driver. I’ve also got a laser on the way, so I’ll be looking through the laser posts to see if I can figure out how to use some of the extra pins for controlling the laser output. I’ve also got end stops that I can wire up and test, as well as an “auto z-level” block.

Still churning through printing the required pieces to assemble. Figure that should be done in another day or two. So fudging with the electronics gives me something tangible to work on.