buildbotics / bbctrl-firmware

Buildbotics CNC Controller Firmware
https://buildbotics.com/
Other
67 stars 24 forks source link

Offsets not handled correctly in Macros #327

Open DougCoffland opened 2 years ago

DougCoffland commented 2 years ago

This problem started with V1.0.2

If an offset is set up in a macro, it causes invalid Over/Under displays. This happens when the following conditions exist.

Here is an example of a macro program that causes this problem.

%
G21
G90
G53 G0 X85
G92 X0
%

If I run the exact same from the play button on the Control/Auto program it does not cause 'Under' to be displayed.

Also, if I set the lower soft limit to be -85 or less, it does not display 'Under'

If I eliminate the 'G92 X0' line, it does not display 'Under'.

jcoffland commented 2 years ago

The "fix" I made previously to make your G53test.nc work was incorrect. That caused this problem. I will revert the fix.

The problem with G53test.nc is that, at the time of simulation there is no way to know what the offsets might be in the future. Therefore, a move in absolute coordinates cannot be computed correctly. For example, if you are at 0 and tell the machine to move to 0 with G53, i.e. with in absolute coordinates, then if there is no offset, no move would occur but if there is an offset the move would be to some other position and the current and next move would change. There's just no way to tell at simulation time what a G53 move will do. So you have to resimulate any time the offsets change, which we are not doing.

Even worse, you could move in absolute coordinates and then set a coordinate system based on the new position. In this case, many moves might be altered. The same goes for any coordinate systems set before the program is run.