Interfacing LinuxCNC to a Touch-Probe and Tool-Setter

jcdammeyer

John
Premium Member
About a year and a half ago my tool setter arrived so I decided to add it along with my touch probe to the PSNG Touch Screen.
Last time I did anything with it was last January. Although I thought I'd done a good enough job documenting things it turns out I didn't. Can't remember how to use it and I'm sure I did have it working correctly.

Anyway. This thread is going to be my rambling on how I got the tool setter and touch probe working the way I want on LinuxCNC.
 

Attachments

  • Screenshot1280x1024.png
    Screenshot1280x1024.png
    243.7 KB · Views: 5
  • MillMockupValues.pdf
    249.9 KB · Views: 1

DavidR8

Scrap maker
Administrator
Moderator
Premium Member
I have a tool setter but have never taken the time to sort it out with UCCNC.
 
Last edited:

jcdammeyer

John
Premium Member
About a year and a half ago my tool setter arrived so I decided to add it along with my touch probe to the PSNG Touch Screen.
Last time I did anything with it was last January. Although I thought I'd done a good enough job documenting things it turns out I didn't. Can't remember how to use it and I'm sure I did have it working correctly.

Anyway. This thread is going to be my rambling on how I got the tool setter and touch probe working the way I want on LinuxCNC.
So let's get started. Here's my Touch Probe.
1687838042328.png
It's connected to an input on the PC like this:
1687838141417.png
When the probe tip is deflected or pressed inwards the contact opens. If the connecting wire comes off it opens for safety.

I also bought one of these from AliExpress. It's connected effectively in series with the Touch probe so I only use one input on the PC.
ToolHeightSetter-1.jpg

Move down with a tool or the spindle and press the top for sensing. I won't go into the electrical details past that. However in LinuxCNC there are far more 'details' As I start to write up a complete description and guide I'll post it as a pdf. As I make changes I'll post new versions of the PDF.
 

jcdammeyer

John
Premium Member
So. One of the issues with understanding all this stuff is that a CNC router or Mill with a movable head is way easier than a Knee Milling machine simply because as the head moves towards the table the distances get smaller so if we drill a 1" deep hole we go down 1"
With a knee mill if the knee is what moves (not the quill) then when we drill 1" hole we go up 1". My quill is always locked at fully up and only used for manual operations.

With my mill the home switch is with the knee all the way down. That's so when it heads to home we never have to worry about running into anything on the way home. And that home position is the machine co-ordinate 0.000. But we have no idea where the quill is. That we have to measure. But we don't know how long our touch probe is so how to measure the length of the tool sticking out of the spindle.

If we refer back to my original PDF drawing it's clear I have been able to measure this. It's not as hard as it might appear.

I started with the HOME command. Then moved the table up until a couple of stacked 1-2-3 blocks just slid under the spindle with a tad bit of friction. The readout from the LinuxCNC DRO (a negative number) minus the 4" of the 1-2-3 blocks gives the total knee travel; in my case 12.718".

Now that we have that value we can use the spindle to touch the tool setter and the PC DRO Z value plus a bit of math will tell us the exact position the switch closes which is 3.663".

MeasureToolSetter.jpg

Similarly now that we know the distance from the spindle to the table we can install the probe and touch the table. Again simple math will tell me that the probe switch closes at 4.784".

These 3 values: Total distance, Probe Length, Setter Height let me measure each TTS held tool or a drill bit placed into the Jacobs chuck.
 

jcdammeyer

John
Premium Member
So say I have a 5/16" end mill held in the TTS holder. From Tormach you can buy the expensive micrometer and surface plate with a hole for the shank of the TTS holder. Then use the indicator to measure the length and enter that into the LinuxCNC tool table. The way Tormach does it now is the electronic indicator is connected to the PC and when you measure the tool in their setup it automatically enters it into the tool table for you. Not sure if it's the actual length or some offset.

The value I want to see in the tool table is the length of the tool plus holder. Not a negative number or some sort of offset which is what the software for the probe appears to be generating. Very confusing.

In LinuxCNC the G-Code to cause a tool change is from the AlibreCAM code:
( TOOL 3 - FlatMill5-16 - DESC: 0.3125 DIA, 4 FLUTE, HSS MAT )
T3 M06 G43

The T3 says use tool #3. The M06 starts the tool change process which might just be a dialog to tell you to change the tool or could be a sequence that moves the table down and moves what is on it out of the way so you can insert a new tool and then click on OK. Or all the way to the automatic tool changer doing it for me.

Finally the G43 says use the value in the tool table for tool #3 to change the Z axis position value (shown in the DRO) so that the tip of the tool is at the same zero position as a different tool with a different length.

To cancel this tool offset the G49 removes it from the equation by effectively setting it to zero.

The current code in the PSNG menu overides the standard M06 command and moves the table so the quill is over the tool setter. Then puts up a dialog asking me to install the tool. So I remove the old one and install the new one (T3) and click OK. It then moves to the Tool Setter position which may be different from the tool load position for clearance reasons. Then it moves the knee up slowly until the tool switches the tool setter. At which point the calculated tool+holder length is entered into the tool table and the G43 adds it into the Z position.

Needless to say this is annoying for every tool change but needed if you have one jacobs chuck and need three different drill sizes.
 

Susquatch

Ultra Member
Administrator
Moderator
Premium Member
Needless to say this is annoying for every tool change but needed if you have one jacobs chuck and need three different drill sizes.

I read all that and then realize how lucky I am to be so happy milling and turning manually. Especially since I almost never make anything more than once.

I setup a tool height gauge too. But I only use it to zero Z. Paper also works if you know the current and target dimension and the thickness of the paper.
 

jcdammeyer

John
Premium Member
I read all that and then realize how lucky I am to be so happy milling and turning manually. Especially since I almost never make anything more than once.

I setup a tool height gauge too. But I only use it to zero Z. Paper also works if you know the current and target dimension and the thickness of the paper.
You're 100% right when there's a one off and the drawing is a sketch on the back of an envelope. The tool height setter is new to me and in the past I've also used the slip of paper and the knee was powered by an old ELS and stepper motor. Max 25 IPM but handy for raising and lowering the knee rather than cranking.

The quill has the scale on it. And this Shumatech DRO-350 (I have a spare kit not yet assembled) saved the day when it showed that the X axis was losing position due to a faulty Brushed DC Servo motor. So as yet I've not removed the DRO.
DRO_SwitchBox.jpg

And a DRO like this has made doing things like bolt circles a piece of cake. Just move XY until they read 0. Then drill and press next and move XY till they read 0. Rinse and repeat.
I even have a couple of DRO 550's from Shumatech that I never installed. They can interface to just about any scale rather than just the caliper based ones. Also Project #42.

However, what it cannot do, and the G-Code manually or with CAD/CAM generated G-Code is complex shapes or curves or angles. Granted one can mount what you need on a rotary table. And then just turn and index. So this project didn't need CNC although it would have worked out better if the stupid operator had used the 3mm bit instead of the 4mm one. But that mistake could have happened with manual mode too since it was only after the second slot showed a tooth that was too narrow. And at that point it was too late.
EncoderDisk-s.jpg

And since my mill can pivot the table I could even mill angles under single axis power feed. So you are correct. Most everything can be done without the CNC. But there have been a few projects where I have used the CNC paths to do what would have been impossible without the CNC. And of course it didn't really happen because I don't have any pictures...
 
Last edited:

Susquatch

Ultra Member
Administrator
Moderator
Premium Member
But there have been a few projects where I have used the CNC paths to do what would have been impossible without the CNC. And of course it didn't really happen because I don't have any pictures...

Oh, I hope I don't come across like I think CNC is crap! I do NOT. It has its place. It's just not for me. I fully appreciate that complex shapes are VERY DIFFICULT (if not impossible) on a manual machine. Even something as simple as milling letters into a plate would bring me to screeching STOP! I even find simple angles difficult without a fixture.

No need for pictures. I believe you!
 

jcdammeyer

John
Premium Member
I think I just figured out why my tool setting wasn't working right. When we talk about G-Code being confusing I'm right up there with the rest of them.
I had written on my document to do:
G49 ; which removes any tool offsets.
G91 ; relative motion rather than absolute
G38.3 Z-3 F2.5 ; probe vertically for 3 inches downward and stop when the tool setter switches on. Store Z value into #5063.

The clue, when I read the fine print, is that the value of Z stored is not in machine co-ordinates but in the current co-ordinate system. Which is logical but not immediately apparent. So if I'm in the P1 or G54 co-ordinate system and G54.Z has a non-zero value then there is nothing to reference the tool setter height to. So the lengths come out strange.

Likely when I first created the help sheet drawing I had homed and also cleared the G54 XYZ values so everything worked. Since then my working home position hasn't been the limit switches but a point midway in the X and Y axis and about half way up (-6" or so). And that was a while ago so I likely never realized I'd been using no offsets for G54.

So what has to happen is the current co-ordinate has to be zero'd before measuring the tool length.
What looks like it will work is:
G10 L2 P#5220 Z0 ; set the current co-ordinate system Z offset to 0.

Once the tools have been measured then the touch probe can be used on whatever to correctly set the G5n.Z value. Now the Tx M06 G43 end up with the correct offset and the tip of the tool is at zero no matter what the tool length.

OK. Enough rambling. Now to check out the routines that came with the screen and see if they have the same error since they never appear to measure the tool correctly.
 

jcdammeyer

John
Premium Member
Alright! I think I've figured it out. First the comments in the code refer to moving the head up out of the way. That's fine for a CNC router or for a mill that moves the spindle assembly up on a track or ways. Not for a knee mill that moves the knee down out of the way of the spindle.

I'm still confused by the process used by the original author but that's partly because his software measures every tool every single time which I don't want.

There's another user, named Alkabal who posted two G-Code files and instructions on how to modify some of the LinuxCNC files so an M06 would call his routines while leaving all the other probe routines alone. It's even smart enough to determine if the tool has been measured or if it's a dynamic tool like a drill bit in a chuck or in an R8 collet instead of TTS. That's more like what I wanted originally.

Next step is try that code and modify my write-up on how to use all this.

What I have also discovered is I need to be really fastidious on measuring backlash and verifying that the head is perpendicular to the table. The 1-2-3 blocks, when placed to just slide under the quill on the left side run into it on the right side and are a squish fit from the front. That suggests the head isn't quite square to the table.

And backlash on the knee results in different readings from a few months ago. My Table to quill distance is different by about 0.035 this time. Not sure why. More on this saga as it unfolds.
 

jcdammeyer

John
Premium Member
Man the instructions in that Alkabal document and the code do not match very well. LinuxCNC wouldn't run.
# Alkabal Version
REMAP=M6 modalgroup=6 ngc=m6remap.ngc
# Original Version
# REMAP=M6 modalgroup=6 prolog=change_prolog ngc=psng_manual_change epilog=change_epilog

That's because his document said ngc=m6remap.ngc and the error message was Joint 0 waiting... WHAT????
Turns out remove the .ngc and then the G-Code loaded.
Sigh...

His code also Didn't move to the tool change location when it encountered the T3 M6 G43. I guess his viewpoint was that he'd move it manually or just do it wherever the spindle was. Or maybe his G-Code generation program created that move first.

So I added the motion commands after his G90 G0
(This is a different tool.)
G90 G0 (Absolute distance mode Rapid move)
G53 Z#<_ini[CHANGE_POSITION]Z> (Move Z to safe height above tool setter to start probe)
G53 X#<_ini[CHANGE_POSITION]X> Y#<_ini[CHANGE_POSITION]Y> (Move to tool setter position)
M6 T#<_selected_tool>
G43 (Enables tool length compensation.)

There's a whole bunch of code used to save current coordinate system so it can muck with values to change the tool or measure a tool if the length of the tool is set to 0 in the tool table. After adding one other variable not mentioned in the document it actually worked.

If the tool had a length then go to change position, ask user to insert tool, click OK on dialog and then it would continue with G-Code. Of course did muck up the G54 Z offset so tool length was kind of useless.

If the tool didn't have a length now it moved to the tool setter position and went down and measured the tool but didn't change the tool table value. Left it at zero as expected for say a drill chuck that might get 3 different drill bits. But it still screwed up the G54 Z offset so where the tool tip really was ended up being wrong.

Finally, also totally missed out is Tool #0 which is by convention no tool and no tool compensation. Goes to the tool change position, tells you to remove the tool after which it's supposed to do a G49 instead of a G43 and instead heads down to the tool setter.

ESTOP button handy here.

So this code is going to require some more work. But I have to stop for the evening. Maybe tomorrow.

Baby steps...
 

jcdammeyer

John
Premium Member
This thread explains why I needed a new probe:

Replacement probe arrived today.
Along with a hand written post it note saying this was a gift.

Since i made my own box to parallel the Probe and the Tool Setter I now have to figure out how to connect this new, much nicer box compared to my point to point wired, 3D printed box. Project #42 I think.
 
Top