Tool in spindle memory

More
7 years 7 months ago #129938 by andypugh
Replied by andypugh on topic Tool in spindle memory
True, if a remap is involved the it can trivially save the current tool to a static user variable, an be aware that a tool change is not needed (for example) on the next restart.

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

More
7 years 7 months ago #129949 by cmorley
Replied by cmorley on topic Tool in spindle memory
I think we should add an in pin to IO control for 'current-tool-number'.
Let the tool changer (or hal manual toolchange or any custom program) take care of tool memory.

I also think we should switch to IO control 2 as IIRC it handles tool change errors too.

As you said then a remap could manipulate the extra pins too.

Chris M

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

More
7 years 7 months ago #129975 by pl7i92
Replied by pl7i92 on topic Tool in spindle memory
what version of linuxcnc are you using and what OS
so it might get into bugtracker if not written to the parameter

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

More
7 years 7 months ago #130015 by cmorley
Replied by cmorley on topic Tool in spindle memory
So I looked into adding a HAL pin for external tool number initialization.
( a first step towards having the toolchanger actually be the tool memory -though maybe that is not needed)

It was fairly simple to hack on a pin that automatically reloads (internally) the tool based on the HAL pin.

What is holding me up is that you would want that pin to be only checked once just after loading the iocontrol component.
There is even a function for initialization that could be used: EMC_TOOL_INIT_TYPE
but it seems to never be called.

I have no idea how linuxcnc starts/initializes, so I don;t know where to add a NML command to call EMC_TOOL_INIT_TYPE.....

Chris M

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

More
7 years 7 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 or Create an account to join the conversation.

More
7 years 7 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 or Create an account to join the conversation.

Time to create page: 0.437 seconds
Powered by Kunena Forum