Editing tool change command sequence in a post processor?

Here's the place for discussion related to CAM/CNC and the development of the Path module.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
moriseikiman
Posts: 8
Joined: Thu Dec 29, 2022 9:55 pm

Editing tool change command sequence in a post processor?

Post by moriseikiman »

Hi again, I am trying to figure out how to customise the sequence of commands for the tool change on a post processor and adding commands after tool change. Related to this I only found the TOOL_CHANGE line that adds the commands before tool change.That worked. But my machine needs the M6 command after the T command on a separate line. Also I need to move the machine in G53 coordinates before tool change so I would need a work offset command for the current work coordinate system in use after that.

I could add an M6 to the pre operation commands but then there's a duplicate M6 which causes an error for the first one before the T command so they would need to be removed manually. Also no idea how to get it to output different work offset commands.

The tool change code should look something like this:

G53 G0 Z0 Y-200.0
T1001
M6
G54

Almost unfamiliar with coding (procrastinated on learning to code for at least 10 years) so any insights will be appreciated!
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: Editing tool change command sequence in a post processor?

Post by GeneFC »

moriseikiman wrote: Thu Jan 19, 2023 11:14 am
You did not say which post processor you are using, but you will need to add the appropriate commands in the section that actually writes into the output file.

In linuxcnc_post.py this is the section that starts with

Code: Select all

      # Check for Tool Change:
Just add the commands you mention above. It might take a bit of tweaking depending on your Python expertise, but it is not very difficult if you follow the example of the nearby code.

Gene
moriseikiman
Posts: 8
Joined: Thu Dec 29, 2022 9:55 pm

Re: Editing tool change command sequence in a post processor?

Post by moriseikiman »

Thanks for the insight.

I am totally unfamiliar with any programming language, but I was able to do some of the changes by trial and error. Still struggling to find a way to get the next tool's number to be inserted in the code after a tool change or in the beginning of operations so that the ATC can index to the next tool while the operation is running. It takes up to 25 seconds to index if needing a tool from the opposite side of the ATC so this is essential.
Another similar thing is how to get the current used work offset number (G54-G59)

Could be something basic but I'm not really even at basic level yet.

I know now where I should put the things in the python file but just missing how to get the numbers I need.

Here is how the file is now, it has some unfinished trials going on atm though
fanuc10M_post.py
(22.86 KiB) Downloaded 25 times

It would be nice if the number for tool offsets could be separated from the tool number in the whole Path workbench by adding another parameter, as for example my machine has only 32 numbers for tool offsets but 9999 numbers for the tools. That's not doing much bad for the usability of the machine but I can't have a fixed tool number for more than 12 tools (as it's a 20 tool ATC).
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: Editing tool change command sequence in a post processor?

Post by GeneFC »

moriseikiman wrote: Sun Jan 29, 2023 9:41 pm Still struggling to find a way to get the next tool's number to be inserted in the code after a tool change or in the beginning of operations so that the ATC can index to the next tool while the operation is running.
I believe everything in the Path WB is 100% sequential. I am not aware of any capability for look-ahead.

This sounds very much like a function of the machine controller. If you can find the proper command it should be possible to insert it in the g-code output from your postprocessor.

I use a dirt-simple linuxcnc controller, so I cannot comment further on how your controller might work.

Gene
moriseikiman
Posts: 8
Joined: Thu Dec 29, 2022 9:55 pm

Re: Editing tool change command sequence in a post processor?

Post by moriseikiman »

I am now chatting with ChatGPT about this, should've done it right away I should say. That thing is crazy to put it mildly. I will tell you later if I can use it to come up with a thing that ain't necessarily pretty but does its job.
bmsaus4ax
Posts: 250
Joined: Sat Nov 14, 2020 9:16 pm
Location: Bargara, Queensland, Australia UTC+10

Re: Editing tool change command sequence in a post processor?

Post by bmsaus4ax »

moriseikiman wrote: Thu Jan 19, 2023 11:14 am Hi again, I am trying to figure out how to customise the sequence of commands for the tool change on a post processor and adding commands after tool change. Related to this I only found the TOOL_CHANGE line that adds the commands before tool change.That worked. But my machine needs the M6 command after the T command on a separate line. Also I need to move the machine in G53 coordinates before tool change so I would need a work offset command for the current work coordinate system in use after that.

I could add an M6 to the pre operation commands but then there's a duplicate M6 which causes an error for the first one before the T command so they would need to be removed manually. Also no idea how to get it to output different work offset commands.

The tool change code should look something like this:

G53 G0 Z0 Y-200.0
T1001
M6
G54

Almost unfamiliar with coding (procrastinated on learning to code for at least 10 years) so any insights will be appreciated!
Coming to this discussion late but is your user name indicative of the machine you are using?

Having previously used a Mori-Seiki H500 I believe you can approach this from the machine side leaving the post processor code as is.

The machine I used operated on Fanuc control with a Windows Embedded user interface.

In the Fanuc system you can reassign an M-Code to a macro of your own to carry out all the sequence steps with one g-code call.
I don't have access anymore but the "How" is in the Fanuc manuals (three massive yellow books with the machine)

In our case it consisted of
Retract Z, stop spindle, turn off coolant, move to tool change position, spindle orient, tool change ( the base g-code M06 inside the macro) , start spindle at low speed (50RPM [ this to over ride previous speed to protect speed limited tools such as carbide insert saws to prevent friction held inserts being ejected] )
So the program merely calls M6 and the machine controller runs the macro.
moriseikiman
Posts: 8
Joined: Thu Dec 29, 2022 9:55 pm

Re: Editing tool change command sequence in a post processor?

Post by moriseikiman »

Hi, yes I have a Mori Seiki MV Junior VMC and a Mori Seiki AL-2 lathe (which I program by hand in gcode)

Not exactly sure how it would work with a macro, it will need the next tool number from ahead in the program in order to start indexing the ATC beforehand. M6 in the beginning of next op executes the tool change.

This is a Fanuc 10M from late 80s, it may work differently as the newer ones.

ChatGPT suggested that I might use 'fileinput' to go through the file after it's done and post-postprocess it. I will play with it some more maybe tomorrow, ran out of time now.
moriseikiman
Posts: 8
Joined: Thu Dec 29, 2022 9:55 pm

Re: Editing tool change command sequence in a post processor?

Post by moriseikiman »

Haven't gotten around this yet but I just changed some of the "secret magic 9000 series parameters" from the Fanuc and now it accepts both radius and height offset under the same number as well as has 99 slots for the offset. So I can have a dedicated number for each tool now as I have less than 99 tools. Getting there.
Post Reply