Hi Guys,
I'm in the final steps of retrofitting my Chiron CNC with a basket tool changer.
I the baby running except the emergency stop (wich kicks in before the spindle brake. But this shouldn't be a to big issue cause I have already some ideas how to tackle this) and the tool change. To run this this safely I have to move the Spindle up. And I also want to be able to use tools other than the one in the tool changer. For the old Sinumerik I implemented this in the post processor of my CAM and I could also do it for linuxcnc. But I would prefer It to be "hard coded" into the machine.
So I started to write a script an remapped it to m6. But This is not working well, cause the I can't properly read the hal pins in ngc. They are updated to slow, so the variable #<_hal[iocontrol.0.tool-prep-number]> is not reliable.
The actual Mcodes work well cause they are in bash and there I can read the hal pins correctly. But the logic where to move an what Mcodes to trigger is in ngc. So is there another way to read hal pins in ngc? or a way to move the machine from bash (I use 2.7 linuxcnc)?
Here are the codes I use:
Code:
o<sub_progs/toolchange> sub
M108 P#<_hal[iocontrol.0.tool-number]> Q#<_hal[iocontrol.0.tool-prep-number]>
G4 P1
M108 P#<_hal[iocontrol.0.tool-number]> Q#<_hal[iocontrol.0.tool-prep-number]>
G4 P1
M108 P#<_hal[iocontrol.0.tool-number]> Q#<_hal[iocontrol.0.tool-prep-number]>
G4 P1
M108 P#<_hal[iocontrol.0.tool-number]> Q#<_hal[iocontrol.0.tool-prep-number]>
G4 P1
M108 P#<_hal[iocontrol.0.tool-number]> Q#<_hal[iocontrol.0.tool-prep-number]> (Debugging)
o500 if [#<_hal[iocontrol.0.tool-number]> NE #<_hal[iocontrol.0.tool-prep-number]>]
o501 if [#<_hal[iocontrol.0.tool-number]> EQ 0]
M110 (unlock tool)
M112 (lower basket)
(load new tool)
o<sub_progs/loadtool> call
o501 elseif [#<_hal[iocontrol.0.tool-number]> GT 0]
(remove tool)
o<sub_progs/removetool> call
o501 endif
M108 P1 Q1
o502 if [#<_hal[iocontrol.0.tool-prep-number]> EQ 0]
M113 (raise basket)
M111(lock tool)
M6 G43
o502 elseif [#<_hal[iocontrol.0.tool-prep-number]> GT 0]
(load next tool)
o<sub_progs/loadtool> call
o502 endif
o500 endif
o<sub_progs/toolchange> endsub
Code:
o<sub_progs/removetool> sub
M108 P#<_hal[iocontrol.0.tool-number]> Q#<_hal[iocontrol.0.tool-prep-number]>
o502 if[ #<_hal[iocontrol.0.tool-number]> LE 12] (tool in basket)
M108 P20 Q1
G0 G53 Z0
M110 (unlock tool)
M112 (lower basket)
M116 (raise tool arms)
o502 elseif [#<_hal[iocontrol.0.tool-number]> GT 12] (tool not in basket )
M108 P20 Q3
G53 G0 Z0
G53 G0 X0 Y0 (go to door)
M125 (remove tool)
o502 endif
o<sub_progs/removetool> endsub
Code:
o<sub_progs/loadtool> sub
M108 P#<_hal[iocontrol.0.tool-number]> Q#<_hal[iocontrol.0.tool-prep-number]>
o504 if [#<_hal[iocontrol.0.tool-prep-number]> LE 12] (next tool in basket)
M108 P10 Q1
G0 G53 Z0
M112 (lower basket)
M118 (lower tool)
M114
S150 M3 (Spindel move slowly)
M113 (Raise basket)
M115
M111 (lock tool)
M5 (Spindel Sto)
M6 G43
o504 elseif [#<_hal[iocontrol.0.tool-prep-number]> GT 12] (next tool not in Basket)
M108 P10 Q3
M113 (Raise basket)
G53 G0 Z0
G53 G0 X0 Y0 (Go to door)
M126
M6 G43
o504 endif
M108 P10 Q4
o<sub_progs/loadtool> endsub
Thaks Patrick