My manual tool change macro using 2x sensors

This is where you talk about Macros, show examples of your macro scripting and SHARE handy segments of script code as examples.

My manual tool change macro using 2x sensors

Postby fixebr » Thu Feb 10, 2022 1:03 am

Hey, everybody.
I've tweaked the macros found on the forum a bit to use two sensors.
It was pretty hard for me to figure it all out from scratch, plus there are a lot of variations on the forum, so I decided to post my version here - maybe it will help someone.
M6.txt
(4.92 KiB) Downloaded 405 times
M31.txt
(5.23 KiB) Downloaded 403 times

My tool sensor is located in the corner of the work area, it is fixed and calibrated so that its surface is parallel to the table.
3.jpg

When I set up a workpiece, I put a sensor in the spindle instead of the cutter, and use it and the probing section to set the workpiece zero in X and Y. Then I run the M31 script from the button on the main screen, and it first measures Z underneath itself, then goes to the tool sensor and measures there. I save the difference of these values as coordinate C. Then the spindle shifts to the convenient tool change position, where I remove the sensor and insert the cutter.
Then I load my g-code, and when it encounters the M6 tool change command, the manual change script is run. The script first brings the cutter to the tool change area, moves the spindle over the tool sensor when you press the button in the window that appears, and after you agree that the sensor is working, takes a measurement. The measured value is corrected by the pre-stored difference between the workpiece zero and the sensor, so that the ready coordinates are recorded and you do not need to do anything. It then returns the spindle to the last point (if you have multiple tool changes in your code, it will return it to where you left off, and the tip of the cutter will be at the same height as the tip of the last tool).
2.jpg

I bought the sensors from the Belarusian company https://vers.by/, and I like the way they work. It only cost about $240 for two wired sensors, and these sensors have many advantages - you don't risk breaking the cutter against a hard plate, you see a light on the sensors about the fact that they are working or touching. This is not an advertisement, lots of people make similar sensors, like eabrust(http://www.craftycnc.com/touch-probes/) or a bunch on aliexpress.

I also recommend installing a led #37 somewhere on the main screen so you can check the sensors if you have them without a light bulb. I had a situation once where the sensor wires shorted and the cutter punctured it...

Also sorry for the Russian comments in the code, google translate will help you understand them - I do not know English well enough to translate them correctly.
My English is bad, so you're reading machine translation results. Alas.
User avatar
fixebr
 
Posts: 40
Joined: Thu Dec 30, 2021 8:30 pm
Location: Russia, Moscow

Re: My manual tool change macro using 2x sensors

Postby torch » Sat Jan 25, 2025 7:01 pm

Thanks fixbr for sharing!

Ok its a three year thread lift (with no response?), I get that but this was the most similar setup to what I think I need/want and what I was trying to accomplish, except for that I don't have matched 3d-probe and tool length sensor working together.

I've translated the explanations in the files and adapted them to my needs (and removed a coolant start/stop) and it works great. I'm really happy I got this working as I haven't got a clue of macro programming, perhaps useful for others.

I thought it would be hard to get them to trigger simultaneously so figured I would set up a reference surface at same height as the tool lenght sensor was triggering. This seems unnecessary in my case as the limited stroke of <0.02mm before triggering makes it neglible or even possible to compensate for.

My mill is a knee mill with two manual tool change spindles (original ISO40 and one vfd, but both with equal x/y spindle centres) and an additional manually adjustable floating Z (useful for high workpieces):
Attachments
20250116_211234.jpg
M31.txt
(4.07 KiB) Downloaded 32 times
M6.txt
(3.62 KiB) Downloaded 34 times
torch
 
Posts: 9
Joined: Fri May 07, 2021 5:40 pm

Re: My manual tool change macro using 2x sensors

Postby Daywalker » Sat Jan 25, 2025 7:28 pm

fixebr wrote:Hey, everybody.

When I set up a workpiece, I put a sensor in the spindle instead of the cutter, and use it and the probing section to set the workpiece zero in X and Y. Then I run the M31 script from the button on the main screen, and it first measures Z underneath itself, then goes to the tool sensor and measures there. I save the difference of these values as coordinate C. Then the spindle shifts to the convenient tool change position, where I remove the sensor and insert the cutter.
Then I load my g-code, and when it encounters the M6 tool change command, the manual change script is run. The script first brings the cutter to the tool change area, moves the spindle over the tool sensor when you press the button in the window that appears, and after you agree that the sensor is working, takes a measurement. The measured value is corrected by the pre-stored difference between the workpiece zero and the sensor, so that the ready coordinates are recorded and you do not need to do anything. It then returns the spindle to the last point (if you have multiple tool changes in your code, it will return it to where you left off, and the tip of the cutter will be at the same height as the tip of the last tool).


Measuring the 3D probe on the tool length sensor (WZL) makes no sense. This is because the pressure forces of the springs are different and therefore the switching points are also different. The 3D probe will always trigger earlier than the WZL.

Even in the industrial sector this is not done, the 3D probe is always calibrated against a fixed point.
Regards from Germany
Udo

(UC300ETH & UB1)
[Yeah, I use a Translator ;-) ]
Daywalker
 
Posts: 36
Joined: Sun Jul 29, 2018 8:11 am


Return to Macros

Who is online

Users browsing this forum: No registered users and 2 guests