Tool in spindle memory

More
7 years 6 months ago #130061 by MaHa
Replied by MaHa on topic Tool in spindle memory
A pretty weird attempt to remember and load data of last tool used, after restart your machine. I need this, because my probing routines don't like no tool loaded. I like this automated process.
After each toolchange: o<last_tool> call
Uses the log function to create a subroutine (o714.ngc), loading the last tool by o714 call.

o<last_tool> sub
(LOGOPEN,/home/abracadabra/NcFiles/714.ngc)
(LOG,o714 sub)
(LOG,M61 Q#5400)
(LOG,o714 endsub)
(LOG,M2)
(LOGCLOSE)
o<last_tool> endsub


entry in mymachine.hal:
after the last axis is homed, mdi command to load data of last tool

# ---HALUI signals---

net y-is-homed halui.joint.1.is-homed halui.mdi-command-00


.ini file entry:

[HALUI]
MDI_COMMAND = o714 call

It is just an example, but actually working.

Please Log in to join the conversation.

More
7 years 6 months ago #130062 by andypugh
Replied by andypugh on topic Tool in spindle memory
I have determined that it is possible to add #5400 to the .var file, and the tool-in-spindle is then automatically recorded in there.

Unfortunately as soon as LinuxCNC starts that value is over-written again with a zero.

It should be possible to read the file directly, store the value and act on it.

Here is an attempt at Python script that can be loaded very early in the HAL sequence (loadusr tool_loader)

It doesn't work, it had got too late to finish it here:
Code:
#! /usr/bin/env python import sys import linuxcnc import re s = linuxcnc.stat() c = linuxcnc.command() s.poll() #inifile = linuxcnc.ini(sys.argv[1]) varfile = "sim_mm.var" #inifile.find("RS274NGC", "PARAMETER_FILE") old_tool = 0 for line in open(varfile, "r"): M = re.search("^5400\s([\.\d]*)", line) if M: old_tool = re.search("^5400\s([\.\d]*)", line).group(1) def ok_for_mdi(): s.poll() return (not s.estop) and s.enabled and s.homed and (s.interp_state == linuxcnc.INTERP_IDLE) while not ok_for_mdi: print ok_for_mdi pause(1) print "trying to set tool to %s" % old_tool c.mode(linuxcnc.MODE_MDI) c.wait_complete() c.mdi("M61 Q%s" % old_tool)

The issues are:
(1) Not finding the INI file so not being able to read the PARAMETER_FILE
(2) It doesn't wait for "ok_for_mdi" and tries to run the MDI command at an invalid time.

But other than that, it looks like it might work. It does at least try to set the correct tool number.

Please Log in to join the conversation.

More
7 years 6 months ago #130063 by cmorley
Replied by cmorley on topic Tool in spindle memory
Andy

Looks like we both hit the same problem - initialization of the tool number.
It's reset in iocontrol.cc.

Do you know what program should call a NML initialize tool IO command?
This would be a less 'hacky' fix I think.

Chris

Please Log in to join the conversation.

More
7 years 6 months ago #130067 by cmorley
Replied by cmorley on topic Tool in spindle memory
Ok I went deeper....
a NML message of EMC_TOOL_INIT _is_ sent...from taskclass.cc

but it never makes it to iocontrol.cc

maybe NML messages are marshaled somehow?

Chris M

Please Log in to join the conversation.

More
7 years 6 months ago #130072 by pl7i92
Replied by pl7i92 on topic Tool in spindle memory
you shoudt force a BUG track

But in _General
NO tool shoudt be inside the ATC over night

Please Log in to join the conversation.

More
7 years 6 months ago #130076 by cmorley
Replied by cmorley on topic Tool in spindle memory
It's really a feature request as the system works as it was designed to, at the time.

One has to be careful with general statements about what should or should not be...for instance in a lathe one does not remove the tools at night :)
Linuxcnc works with all kinds of different machines.

Chris M

Please Log in to join the conversation.

More
7 years 6 months ago #130104 by Todd Zuercher
On the router spindles I've worked with I've heard that CAT and BT taper tools should never be left in, but with HSK style tools, I've been told both to always leave in and remove over night, depending on the manufacturer's opinion.

Please Log in to join the conversation.

More
7 years 6 months ago #130123 by andypugh
Replied by andypugh on topic Tool in spindle memory
I have it working. It's not very generic at the moment though.

1) Add 5400 to the end of the .var file, this means that the tool-in-spindle is saved when LinuxCNC exits.

2) Make this Python file executable, and "loadusr" early in the HAL file sequence.
Code:
#! /usr/bin/env python import sys import linuxcnc import re import time s = linuxcnc.stat() c = linuxcnc.command() s.poll() #inifile = linuxcnc.ini(sys.argv[1]) varfile = "sim_mm.var" #inifile.find("RS274NGC", "PARAMETER_FILE") old_tool = 0 for line in open(varfile, "r"): M = re.search("^5400\s([\.\d]*)", line) if M: old_tool = re.search("^5400\s([\.\d]*)", line).group(1) def ok_for_mdi(): s.poll() return (not s.estop) and s.enabled and s.homed == (1,1,1,0,0,0,0,0,0) and s.interp_state == linuxcnc.INTERP_IDLE while not ok_for_mdi(): time.sleep(0.5) print "trying to set tool to %s" % old_tool c.mode(linuxcnc.MODE_MDI) c.wait_complete() c.mdi("M61 Q%s" % old_tool)

Note that I have not figured out how to read the .var file name from the INI, so that needs to be hard-coded. Also it only works for a 3-joint machine. Change that by editing the (1,1,1,0,0,0,0,0,0) bit of the code that is testing for all axes to be homed.

Please Log in to join the conversation.

More
7 years 6 months ago #131173 by nkp

Please Log in to join the conversation.

More
7 years 6 months ago #131174 by Todd Zuercher
It is normally saved in your machine's config dir

Please Log in to join the conversation.

Time to create page: 0.057 seconds
Powered by Kunena Forum