Problem remapping T word

More
06 May 2021 04:58 #208072 by ZincBoy
I ran into an issue getting a simple remap of the T word to work. The reason I am remapping T is to check if the tool pocket number is between 0 and 20 and to abort if not. I have 50 tools in the tool table but only 20 are loaded in the changer.

Using the basic stdglue.py file and a remap .ngc file works fine when calling T# from MDI but I can't load a program containing a T word. On loading a .ngc file, I get the following error:
G-Code error in top_nut_op1_finish.ngc
Near line 0 of
/home/aclait/linuxcnc/nc_files/remote/top_nut_op1_finish.ngc
T12: pocket not found

T12 exists in the tool table and can be called from MDI. The problem seems to be in the stdglue.py prepare_prolog function when it searches for the pocket.

Adding a check for self.task as follows works around the issue:
        if tool:
            if not self.task:
                pocket = 1
            else:
                (status, pocket) = self.find_tool_pocket(tool)
                print "Tool:%d, Status:%d, Pocket:%d" % (int(tool), int(status), int(pocket))
                if status != INTERP_OK:
                    self.set_errormsg("T%d: pocket not found" % (tool))
                    return status

With this change, the .ngc file can be loaded and the program will run fine. Without the check, self.find_tool_pocket returns INTERP_ERROR (5) for status and -1 for the pocket.

I would like to run the check for valid pocket numbers on program load. This is to prevent a program from being loaded that has tools that are not in the changer. Can someone suggest a way this might be done?

This is on version 2.8.1 and happens in both simulation and realtime modes.

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

More
06 May 2021 11:42 - 06 May 2021 11:48 #208093 by bevins
Replied by bevins on topic Problem remapping T word
I haven't remapped T before but have done some work with M6 in python.

Put some print statements in the prepare_prolog and prepare_epilog to find out what is happening and what line is not working.

Start from terminal to see the output. That should narrow it down.
Are you setting random toolchanger?
Last edit: 06 May 2021 11:48 by bevins.

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

More
06 May 2021 11:57 - 06 May 2021 12:18 #208095 by bevins
Replied by bevins on topic Problem remapping T word
Also I know at some point there was an issue that the pocket wasnt passed with nml and just handeld tools in the array.
You can always deal with the pocket in M6 remap, as far as I remember the pocket in nonrandom will equal the tool#. so in M6 you can read the tool table and if the selected_tool's pocket_number is greater than 20 you can abort.
Last edit: 06 May 2021 12:18 by bevins.

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

More
06 May 2021 13:19 #208101 by andypugh
Replied by andypugh on topic Problem remapping T word
I think that pocket -1 might be code for "no tool is loaded" and is likely to be the return state at startup. Perhaps your remap simply needs to allow -1 as a valid pocket?

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

More
06 May 2021 13:49 #208109 by ZincBoy
Replied by ZincBoy on topic Problem remapping T word
self.find_tool_pocket(tool) returns INTERP_ERROR with the -1 pocket. It only does this when loading a .ngc file. From what I can tell, this function searches the tool table and is supposed to return the pocket of the associated tool. It should not matter what is in the spindle.

The problem is with the prepare_prolog code not getting the tool table info during file load.

I would think that the tool table would be loaded/valid when loading a .ngc file. The non-remap T code will error if a tool is not in the tool table when loading a .ngc. The default remap code will not detect this error.

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

More
06 May 2021 14:44 - 06 May 2021 14:46 #208124 by bevins
Replied by bevins on topic Problem remapping T word

self.find_tool_pocket(tool) returns INTERP_ERROR with the -1 pocket. It only does this when loading a .ngc file. From what I can tell, this function searches the tool table and is supposed to return the pocket of the associated tool. It should not matter what is in the spindle.

The problem is with the prepare_prolog code not getting the tool table info during file load.

I would think that the tool table would be loaded/valid when loading a .ngc file. The non-remap T code will error if a tool is not in the tool table when loading a .ngc. The default remap code will not detect this error.


"Note that unless you set the `[EMCIO] RANDOM_TOOLCHANGER=1` parameter,
tool and pocket number are identical, and the pocket number from the
tool table is ignored." so when L cnc starts up, it gets -1 cause Lcnc doesnt save pocket number. Thats how I unsderstand it.

I dont know if this is still valid but I remember this when I was doing remap work on my machines. To me there is no clear documentation on the whole tool/changer remap on how things actually work. I know this has been discussed many times by many people and I still have no understanding of it. I got around it by dealing with everything in the remap code my way. right or wrong, it worked.
Last edit: 06 May 2021 14:46 by bevins.

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

Time to create page: 0.134 seconds
Powered by Kunena Forum