Current Tool-number permanent?

More
23 Jun 2016 10:28 - 23 Jun 2016 10:32 #76480 by terkaa
Hi,

How can I make current tool number permanent? So even after power down LinuxCNC knows that ie. tool number 5 is on spindle? Tool change is written as HAL component.

Tero
Last edit: 23 Jun 2016 10:32 by terkaa.

Please Log in or Create an account to join the conversation.

More
23 Jun 2016 12:01 #76486 by andypugh
A partial solution is to configure as a random toolchanger.
One of the things that RANDOM_TOOLCHANGER does is put the tool in the spindle in pocket 0. This is written to the tool-table, and so the tool is still in the spindle at re-start.
(I think this is the case, experiment with a sim config to be sure)
It seems, however, that your toolchanger is _not_ random, the tool removed from the spindle is put back in its home slot.

I don't know if it is better documented anywhere, linuxcnc.org/docs/2.7/html/config/ini-co....html#_emcio_section

I did try to make the whole system rather better a few years ago, but the work was abandoned about the time of the Machinekit split.
(read here for the system that might-have-been: wiki.linuxcnc.org/cgi-bin/wiki.pl?ToolDatabase

The obvious solution would be to write the tool-in-spindle to disc from inside your sequencer component, but that is unfortunately not possible because the realtime system does not have access to the filesystem.

One way that should be quite reliable might be to have a userspace hal component (probably written in Python) that writes the tool-in-spindle to a disk file every time it see the tool change and a start-up G-code that reads a tool-number from that component and does a G61 and G43.

This is quite a common requirement and it is rather annoying that the system doesn't have it properly built-in.

Please Log in or Create an account to join the conversation.

More
23 Jun 2016 20:03 #76514 by terkaa
Ok,

I had to learn some Python. I just wrote handler.py for atc_panel (to show steps/status of ATC) I also wrote saving spindle tool number to file on disk there... forum.linuxcnc.org/forum/48-gladevcp/311...g-with-hal-pin#76513 it is quick and hasty but seems to work. I have to finish it tomorrow.

Tero

Please Log in or Create an account to join the conversation.

More
24 Jun 2016 16:46 #76583 by terkaa
Ok,

Ended up doing this:

[HALUI]

MDI_COMMAND = M61 Q#4999
MDI_COMMAND = #4999=#5400

net machine-enabled halui.mdi-command-00
net tool-change-loop halui.mdi-command-01

This seems to handle it too. Or is there any problem with this approach?

Tero

Please Log in or Create an account to join the conversation.

More
24 Jun 2016 17:22 #76585 by andypugh

This seems to handle it too. Or is there any problem with this approach?


Have you checked that the MDI_COMMAND gets called when the Tool-change is inside a G-code program?
(I have a feeling it might not be)

If not, then there is an (actually slightly neater) option that ought to work. You can re-map M6 to save the parameter and then do the M6.

linuxcnc.org/docs/2.7/html/remap/remap.h...g_the_m6_replacement

I don't think you need the python prologs, just
REMAP = modalgroup=6 M6 ngc=change

Then a file called change.ngc that contains
#4999=#5400
M6

Please Log in or Create an account to join the conversation.

More
24 Jun 2016 19:21 #76592 by terkaa
Hi,

This is giving me :

emc/rs274ngc/interp_remap.cc:575: REMAP BUG=REMAP=M6 100:REMAP = REMAP=M6 modalgroup=6 ngc=toolchange

And does not seem to work....

You are correct using halui.mdi-command-01 works with manual and MDI but not with Auto mode...

Tero

Please Log in or Create an account to join the conversation.

More
24 Jun 2016 19:30 #76595 by andypugh

emc/rs274ngc/interp_remap.cc:575: REMAP BUG=REMAP=M6 100:REMAP = REMAP=M6 modalgroup=6 ngc=toolchange


Can you paste the whole error message? Looking at the code around that spot (github.com/LinuxCNC/linuxcnc/blob/master...interp_remap.cc#L572) there should be a second error message.


The docs on remap seem to say that what was proposed will work:
linuxcnc.org/docs/2.7/html/remap/remap.h...s_including_tt_m6_tt

Please Log in or Create an account to join the conversation.

More
24 Jun 2016 20:07 #76598 by terkaa
Hmmm... I get only:

8199 emc/rs274ngc/interp_remap.cc:575: REMAP BUG=REMAP=M6 100:REMAP = REMAP=M6 modalgroup=6 ngc=toolchange
8199 emc/rs274ngc/interp_remap.cc:575: REMAP BUG=REMAP=M6 100:REMAP = REMAP=M6 modalgroup=6 ngc=toolchange

and this (this comes at tool change):

8202 emc/rs274ngc/interp_remap.cc:575: REMAP BUG=REMAP=M6 100:REMAP = REMAP=M6 modalgroup=6 ngc=toolchange

Tero

Please Log in or Create an account to join the conversation.

More
24 Jun 2016 21:52 #76608 by andypugh

Hmmm... I get only:

8199 emc/rs274ngc/interp_remap.cc:575: REMAP BUG=REMAP=M6 100:REMAP = REMAP=M6 modalgroup=6 ngc=toolchange
8199 emc/rs274ngc/interp_remap.cc:575: REMAP BUG=REMAP=M6 100:REMAP = REMAP=M6 modalgroup=6 ngc=toolchange


I have just experimented a bit, and it does seem like you need an O<change> SUB and O<change> ENDSUB in the change.ngc file.

Maybe also an M2, not sure.

Please Log in or Create an account to join the conversation.

More
25 Jun 2016 06:47 #76634 by terkaa
Hi,

That does not seem to work either... I tried also python way:

with open('cinci.var', 'r') as file:
# read a list of lines into data
data = file.readlines()
print data[0]
data[0] = '4999 %s.000000\n' % (widget.get_label())
print data[0]
file.close()
with open('cinci.var', 'w') as file:
file.writelines(data)

But it does not work because cinci.var file is already opened by LinuxCNC so writing is not possible. Is there an example of Python writing variables?

Tero

Please Log in or Create an account to join the conversation.

Time to create page: 0.100 seconds
Powered by Kunena Forum