AnHardt / Marlin

Reprap FW with look ahead. SDcard and LCD support. It works on Gen6, Ultimaker, RAMPS and Sanguinololu
GNU General Public License v3.0
1 stars 1 forks source link

The impossibility of safe automatic sensorless homing #92

Closed AnHardt closed 4 months ago

AnHardt commented 4 years ago

The impossibility of safe automatic sensorless homing

Save automatic sensorless homing is impossible in several ways.

A text to read on a long winter evening.

Wording:

Homing an axis is the process of determining a (carriages) position on an axis and giving that position a number. That position has to be indicated automatically by something - a sensor. In contrast to that a manual homing could be sensorless. Drive the carriage to somewhere and tell the system by a G92 axis position what axis is at what position now. At the so called sensor less homing not No but the Stallguard Sensor in a TMC stepper driver is used. From now on let's talk about "Stallguard homing" and imply 'automatic' and 'not sensorless' but a special kind of sensors.

Lets restart with

The impossibility of safe Stallguard homing

What makes Stallguard different from other sensors

If understand that right.

Stallguard:

Stallguard tries to measure a kind of 'Load-angle' - the difference between the angles of the static magnetic field of the rotating rotor and the rotating electromagnetic field of the static coils. Without load that angle is ideally zero. If the angular difference is larger than one full step the motor will lose (at least) 4 full steps if the load is not immediately decreased. If the angle exceeds two full steps a loss off at least 4 full steps is warranted. There are two registers in the TMCs. In one is the numerical representation of the 'Load-angle'. In the other is a value to compare the measured value with. Depending on, if the one value is larger/smaller then the other, a pin can be set. (The direction depends on the version of Stallguard) Under what exact circumstances the pin is reset is still unclear to me. For now I see it as a pulse of undefined length. At least the register containing the actual measured load-angle can also be read out via the drivers serial (UART or SPI) connection and could be compared to a threshold stored in the processor. Endstop-pin-less-homing can be realized by this. Saving one (ideally interrupt capable) pin per driver, but needing much more time to read out and process. Especially software UARTs will often mess up Marlins timing completely, by disabling interrupts while receiving. However. To distinguish the 'Load-angle' caused by acceleration from that of breaking from hitting something unmovable Stallguard needs some steps with a minimum constant speed to calibrate itselves. To reach that speed it needs some accelerated steps. The summed exact way for this depends on jerk-speed, acceleration and the wanted speed for this. That value can be different for all the axes. For the further, of this article, we don't need the exact number but we have to hold in mind:

Stallguard needs to move SOME_WAY before it is able to detect a stop!

(@tmc-experts: Do you want to contribute the details?)

Legal Positions:

We home an axis when we do not know where we are on that axis, else we could simply G0 or G1 to where we want. Not being homed means: we can't do absolute moves, we don't have working software-endstops, but we can (for a machine with independent axes) assume we are in a 'legal' position (somewhere in between the one and the other end of the axis). (For machines with not independent axes it's a bit more complicated. A DELTA is broken if the difference of the highest and lowest carriage exceeds a threshold) . (@delta-experts: can you contribute the details?)

A (not already broken) Machine is switched on in a 'legal' position!

Homable positions:

Normally all 'legal' positions on an axis are homable. But there are exceptions:

Could there be a 'sequence' of doing moves to solve that problem with automatic homing?

No! It was suggested to move by SOME_WAY in the opposite homing direction before homing. That will fail silently (but well audible ;-) ) if closer than SOME_WAY to the other end.

The only way out is manually checking if the position is closer than SOME_WAY to the end and moving away before homing.

But that's not very automatic any more.

The problem is about the same with lifting Z before homing X,Y to not scratch the bed with the nozzle, before Z is homed - but worse. Lifting Z before Z is homed can cause crashing into the opposite end of the z-axis. But here we can protect the system with a z-max-endstop - not so with Stallguard, because here, by definition, the moving distance is to short.

Additional difficulties with Quick- and DELTA- Homing.

Quick- and DELTA- Homing are very similar to each other. In both cases at first a group of axes is moved together until one of them reaches the limit. Then the individual axes are homed. Additional to the above constrain (all axes have to be able move at least SOME_WAY before hitting) here we have to solve additional problems. With Quick-Homing there is a problem when the start point of homing is less than SOME_WAY away from the diagonal ending at corner we are homing to. In that case the second arriving axis is less than SOME_WAY away from it's endpoint. Because the axes can (normally) be homed individually and we have already traveled most of the way to the end to be homed at, we can safely back up each axis by SOME_WAY before homing it individually. The sequence of homing the individual axes does not matter. With *DELTA-Homing we can do the same but have to care about Legal Positions. We will have trouble if the position before homing is closer than SOME_WAY to an illegal position. For example let's assume C-tower has the highest carriage, A the lowest and B somewhere in between. C and A already at the largest allowed distance. After the common move C touches the end and the distances between the carriages are the same as before. If now A begins to back-up, the distance between the carriages will become more than allowed, the machine will break. A hopefully safe strategy could be:

Good luck!

Please remember:

There can't be a save Stallguard-Homing! It needs visual control before hitting the button! Don't use it in a batch or g-code program!

Does this make sense?

AT boelle: This is neither an issue nor a pull-request. This is a try for a start of an developer talk. Please stay away.

AlexanderAmelkin commented 3 years ago

Well, belt-driven deltas will usually drop all three axes below the homing position when steppers are deactivated, just because of gravity and heavy effector/hotend. Ballscrew/leadscrew driven deltas won't probably do that (I don't have experience with them). So for belt-driven deltas we can be more or less sure that there is a space between the power-on position and the homing position. For screw-driven deltas we could add to that probability by moving the effector to a position below homing after the end of a print job.

However, if the power-on position is illegal (broken), then the probability that the delta bot will break or lose the position on the already-homed towers is quite high, so I guess you're right that fully-automatic stallguard-only homing is indeed impossible. That's why I reinstalled endstop switches onto my delta.