I have been testing OrangeCats manual tool change routine and ran into issues I didn't understand - primarily this:
"Linear move on line 128 would exceed joint 2's positive limit"
This error popped up after a new tool was inserted and the height probing complete. But not in a consistent way, and that puzzled me.
I therefore modified the subroutine by inserting some (print, ..) statements. See the attached file.
I then did this:
1) Start LinuxCnc from the terminal, so I can watch the output from the print statements
2) Home the machine (now at (0,0,0))
3) From MDI run: M600 and then M0 T6 (I leave the tool in)
The first probing sequence is executed and the spindle returns to its original position (0,0,0). The print output is:
First tool change
G38.2 Z[-128.000000 - -10.000000] F[400.000000]
Trip point _ToolZRef = -24.113033
4) I load the .ngc file with the cnc project I want to run
5) Manually move the spindle to the workpiece and touch off all axes. The print output is:
First tool change
G38.2 Z[-128.000000 - -10.000000] F[400.000000]
Trip point _ToolZRef = -32.790000
First tool change
G38.2 Z[-128.000000 - -10.000000] F[400.000000]
Trip point _ToolZRef = -32.790000
First tool change
G38.2 Z[-128.000000 - -10.000000] F[400.000000]
Trip point _ToolZRef = -32.790000
First tool change
G38.2 Z[-128.000000 - -10.000000] F[400.000000]
Trip point _ToolZRef = -32.124133
6) Press Run to start the program. Linuxcnc prompts me to change to the first tool. Since the correct tool is in the spindle, I leave it in.
The probing sequence starts. The print output is:
ToolDiamMM = 4.000000
G38.2 Z[-128.000000 - -10.000000] F[400.000000]
Old tool length = ######
New tool length = -23.671500
G53 G1 F[500.000000] Z[0.000000 - -24.113033 + -23.671500]
USRMOT: ERROR: invalid command
Linear move on line 128 would exceed joint 2's positive limit
The problem is clearly that the last G53 command wants to move the spindle above Z0 (valid range is -130 to 0).
Even though it is the same tool in both probing sequences, the small difference (actually rather large??) between two readings may result in the addition of a positive number. This combined with the fact that variable #5183 apparently always is zero (also if I move the z-axis down after homing and before step 3 above).
My two questions:
1) Why is #5183 always zero?
2) Why is the tool-change.ngc subroutine executed when the touch-off button is pressed? (The "First tool change" output is seen multiple times and "_ToolZRef = -32.790000" is printed
at each touch-off button press, even though the z-axis doesn't move. Don't understand where this value comes from?
What am I missing here?