M6 Tx Remap with O-Code
- markkram
- Offline
- New Member
Less
More
- Posts: 9
- Thank you received: 2
07 Dec 2022 08:12 - 07 Dec 2022 08:18 #258793
by markkram
M6 Tx Remap with O-Code was created by markkram
Hello,
I'm currently trying to program my fixed-position toolchanger with a remap of the M6 Tx command. I have 3 o-codes for better readability. The first one checks which state the machine is in and acts accordingly. The second and third ones store the coordinates for the different slots of the current and called tool (I didn't find a more elegant way to do this, maybe someone has a suggestion there) and store or catch the tool. The file "toolchange" seems to work fine, but when it gets to the o-code "wkz_holen" (german for getting the tool) it gets caught up in a loop:
It first goes to o500 in "toolchange", moves to X20 Y300 Z300, then proceeds to o501 and since the current tool is T0, calls "wkz_holen". There it executes the lines to get the called tool and jumps back to the position X20 Y300 Z300 in the file "toolchange" and begins the same cycle. Can someone explain why it does that? I don't work with return or while so I can't see, why it jumps back instead of proceeding forward.
The code I used:
toolchange:
[/code]
I'm currently trying to program my fixed-position toolchanger with a remap of the M6 Tx command. I have 3 o-codes for better readability. The first one checks which state the machine is in and acts accordingly. The second and third ones store the coordinates for the different slots of the current and called tool (I didn't find a more elegant way to do this, maybe someone has a suggestion there) and store or catch the tool. The file "toolchange" seems to work fine, but when it gets to the o-code "wkz_holen" (german for getting the tool) it gets caught up in a loop:
It first goes to o500 in "toolchange", moves to X20 Y300 Z300, then proceeds to o501 and since the current tool is T0, calls "wkz_holen". There it executes the lines to get the called tool and jumps back to the position X20 Y300 Z300 in the file "toolchange" and begins the same cycle. Can someone explain why it does that? I don't work with return or while so I can't see, why it jumps back instead of proceeding forward.
The code I used:
Warning: Spoiler!
toolchange:
o<sub_progs/toolchange> sub
M61 Q#4999 (Werkzeug aus Speicher setzen)
o500 if[#<_current_tool> EQ #<_selected_tool>]
(DEBUG,Tool bereits in Spindel)
o500 elseif [#<_current_tool> NE #<_selected_tool>]
G0 G53 X20 Y300 Z300 (Spindelpositionierung und Orientierung)
o501 if[#<_current_tool> EQ 0] (aktuelles WZ ist T0)
o<sub_progs/wkz_holen> call
M6 G43
#4999=#5400 (WZ dauerhaft merken)
o501 elseif [#<_current_tool> GT 0] (aktuelles WZ nicht T0)
o502 if [#<_selected_tool> EQ 0] (gewähltes WZ T0)
o<sub_progs/wkz_wegbringen> call
M6 G43
#4999=#5400 (WZ dauerhaft merken)
o502 elseif [#<_selected_tool> NE 0] (gewähltes WZ nicht T0)
o<sub_progs/wkz_wegbringen> call
o<sub_progs/wkz_holen> call
M6 G43
#4999=#5400 (WZ dauerhaft merken)
o502 endif
o501 endif
o500 endif
o<sub_progs/toolchange> endsub
m2
wkz_holen:
[code]o<sub_progs/wkz_holen> sub
o100 if[#<_selected_tool> EQ 1]
G53 X150 Y20 Z300
G53 Z290
M111 (WKZ spannen)
G53 Z300
o100 elseif [#<_selected_tool> EQ 2]
G53 X150 Y40 Z300
G53 Z290
M111 (WKZ spannen)
G53 Z300
o100 elseif [#<_selected_tool> EQ 3]
G53 X150 Y60 Z300
G53 Z290
M111 (WKZ spannen)
G53 Z300
o100 elseif [#<_selected_tool> EQ 4]
G53 X150 Y80 Z300
G53 Z290
M111 (WKZ spannen)
G53 Z300
o100 elseif [#<_selected_tool> EQ 5]
G53 X150 Y100 Z300
G53 Z290
M111 (WKZ spannen)
G53 Z300
o100 else
o100 endif
o<sub_progs/wkz_holen> endsub
m2
[/spoiler]
Last edit: 07 Dec 2022 08:18 by markkram.
Please Log in or Create an account to join the conversation.
- MaHa
- Offline
- Platinum Member
Less
More
- Posts: 398
- Thank you received: 159
07 Dec 2022 15:33 #258814
by MaHa
Replied by MaHa on topic M6 Tx Remap with O-Code
After toolchange it is still in the o501 conditional, checking for selected tool, which is -1 after toolchange.
Please Log in or Create an account to join the conversation.
- markkram
- Offline
- New Member
Less
More
- Posts: 9
- Thank you received: 2
07 Dec 2022 18:58 #258825
by markkram
Replied by markkram on topic M6 Tx Remap with O-Code
so the parameter #<_selected_tool> switches to -1 after the toolchange? How do I get out of the loop of doom then?
Please Log in or Create an account to join the conversation.
- MaHa
- Offline
- Platinum Member
Less
More
- Posts: 398
- Thank you received: 159
07 Dec 2022 22:00 #258838
by MaHa
Replied by MaHa on topic M6 Tx Remap with O-Code
You can try if that helps, insert o-return after 'o100 endif' to leave the toolchange sub.
o100 endif
o500 return
o<sub_progs/wkz_holen> endsub
Please Log in or Create an account to join the conversation.
- markkram
- Offline
- New Member
Less
More
- Posts: 9
- Thank you received: 2
08 Dec 2022 19:01 #258908
by markkram
Replied by markkram on topic M6 Tx Remap with O-Code
The error was caused by something different I think. The command M6 G43 in the o501 subroutine executed the whole toolchange.ngc again due to the remap, because M6 now calls the toolchange.ngc
I changed this line to G43 alone and added a M61 command. The final and working code is below if anybody wants to use it.
toolchange.ngcwkz_holen.ngc (get the tool)wkz_wegbringen.ngc (store the tool)
I changed this line to G43 alone and added a M61 command. The final and working code is below if anybody wants to use it.
Warning: Spoiler!
toolchange.ngc
o<sub_progs/toolchange> sub
M61 Q#4999 (set the tool nr. from storage)
G43
o500 if[#<_current_tool> EQ #<_selected_tool>]
(DEBUG,Tool already in spindle)
o500 elseif [#<_current_tool> NE #<_selected_tool>]
G0 G53 X20 Y300 Z300
o501 if[#<_current_tool> EQ 0] (no tool in spindle)
o<sub_progs/wkz_holen> call
M61 Q#<_selected_tool> (set new tool nr.)
G43 (set new tool offsets)
#4999=#5400 (store tool nr. of current tool)
o501 elseif [#<_current_tool> GT 0] (current tool not T0)
o502 if [#<_selected_tool> EQ 0] (called tool T0)
o<sub_progs/wkz_wegbringen> call
M61 Q#<_selected_tool> (set new tool nr.)
G43
#4999=#5400
o502 elseif [#<_selected_tool> NE 0] (called tool not T0)
o<sub_progs/wkz_wegbringen> call
o<sub_progs/wkz_holen> call
M61 Q#<_selected_tool>
G43
#4999=#5400
o502 endif
o501 endif
o500 endif
o<sub_progs/toolchange> endsub
m2
o<sub_progs/wkz_holen> sub
o100 if[#<_selected_tool> EQ 1]
G53 X150 Y20 Z300 (coordinates of the first tool)
G53 Z290
M111 (M-code to close the collet )
G53 Z300
o100 elseif [#<_selected_tool> EQ 2]
G53 X150 Y40 Z300
G53 Z290
M111 (M-code to close the collet )
G53 Z300
o100 elseif [#<_selected_tool> EQ 3]
G53 X150 Y60 Z300
G53 Z290
M111 (M-code to close the collet )
G53 Z300
o100 elseif [#<_selected_tool> EQ 4]
G53 X150 Y80 Z300
G53 Z290
M111 (M-code to close the collet )
G53 Z300
o100 elseif [#<_selected_tool> EQ 5]
G53 X150 Y100 Z300
G53 Z290
M111 (M-code to close the collet )
G53 Z300
o100 else
(DEBUG, Tool not in storage. Please change manually)
o100 endif
o<sub_progs/wkz_holen> endsub
m2
o<sub_progs/wkz_wegbringen> sub
o100 if[#<_current_tool> EQ 1]
G53 X150 Y20 Z300
G53 Z290
M110 (M-code to open the collet )
G53 Z300
o100 elseif [#<_current_tool> EQ 2]
G53 X150 Y40 Z300
G53 Z290
M110 (M-code to open the collet )
G53 Z300
o100 elseif [#<_current_tool> EQ 3]
G53 X150 Y60 Z300
G53 Z290
M110 (M-code to open the collet )
G53 Z300
o100 elseif [#<_current_tool> EQ 4]
G53 X150 Y80 Z300
G53 Z290
M110 (M-code to open the collet )
G53 Z300
o100 elseif [#<_current_tool> EQ 5]
G53 X150 Y100 Z300
G53 Z290
M110 (M-code to open the collet )
G53 Z300
o100 else
(DEBUG, No place in toolchanger. Please remove the tool manually)
o100 endif
o<sub_progs/wkz_wegbringen> endsub
m2
Please Log in or Create an account to join the conversation.
Time to create page: 0.082 seconds