Remap, Lost as anything

More
16 May 2021 10:32 #209062 by Willheg
Hello all,

I'm trying to do a pure python M6 remap for my machine.

What I'm trying to achieve is as follows:

1) Receive tool change /M6 command
2) Record current machine position (able to do)
3) Move to Tool change location
4) Pop up a custom message window I have created and wait until the user accepts the tool change (uses gtk.main() to run the window)
5) set the software for the new tool that has been installed
6) Move to Tool Setter location, probe length of tool and then set this new height as I only have 1 collet holder attached to my spindle
7) Return to previous location and continue cutting

I have been playing for nearly 3 weeks now with code that I thought would work but every time I get something close, I put a new line or two of code in to do something else and it all goes pair shaped and I break it.

I have tried searching for something similar on good old google but nothing is sticking out to me and reference material seams to bee hard to come by.

So I have come to my wits end and am now asking for anyone if they are willing to help or point me in the right direction, I have had fun so far trying to work this out, but it has now got the better of me, to the point I feel I want to give up on the whole project.

Any help or pointers would be great, Thanks all

William

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

More
16 May 2021 10:55 - 16 May 2021 10:57 #209065 by bevins
Replied by bevins on topic Remap, Lost as anything
Post your ini file......

And what is not doing? I did remapping with python and there is some intricacies you need to know.

1. Check for mill task at the beginning of your remap.
2. Deal with your selected_pocket in your remap when you sync.
3. Dont run three python scripts in sequence, the interpreter has issues with this.
4. Incorporate standard glue in your remap.
5. do the G43 in the gcode not the remap. (Ive had issues with this also) Others will say different. But in gcode it always works.

This is the only way I could get an all python remap to work.
Its not documented but rather scattered in the forums old and new.

Here is a rather large remap of M6 in python only. I have made some changes but have not updated github.
M6 remap in python

Note: I have a xml class that I keep parameters and stuff I only have to change in one place. But I found it is not needed and complicates the remap, so I have it on my list to remove but have not done it yet so it may look a bit complex.

from my experiences......
Last edit: 16 May 2021 10:57 by bevins.

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

More
16 May 2021 15:01 #209099 by andypugh
Replied by andypugh on topic Remap, Lost as anything

So I have come to my wits end and am now asking for anyone if they are willing to help or point me in the right direction,


I am sure that many are willing to help, but we need a bit more to go on. What, specifically, is not working at the moment?

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

More
18 May 2021 11:22 #209338 by Willheg
Replied by Willheg on topic Remap, Lost as anything
bevins, thanks for the link, I will take a look over the next few days to see if I can get my head around it.

1. Check for mill task at the beginning of your remap. Worked this one out already and have the code for that
2. Deal with your selected_pocket in your remap when you sync. Unsure of this one if i do this at the right place but have tried cutting and pasting to no real success
3. Dont run three python scripts in sequence, the interpreter has issues with this. Have read about this somewhere so only run the one python file i.e. REMAP=M6 modalgroup=10 python=tool_probe_m6
4. Incorporate standard glue in your remap. Unsure on this one as well
5. do the G43 in the gcode not the remap. (Ive had issues with this also) Others will say different. But in gcode it always works. Will get there with this one at some point, but was hoping to not have to edit post processors or gcode files hence trying to remap the m6 code to do what I'm hoping

andypugh, thats where it gets hard, one minute it will not execute the self.execute("xxx") commands, so i put a "yield INTERP_EXECUTE_FINISH" line in just after some of the execute commands, then it will do to the "yield INTERP_EXECUTE_FINISH" line, show my window then ignore the rest of the execute commands.

Then if i change the position of the "yield INTERP_EXECUTE_FINISH" it does not execute any of the self.execute("xxx") codes again, so then I go round in circles and all.

Very frustrating but I'm sure I'll get there somehow, I also found a bit of code if the github stdglue that is ment to be python only but it could not get it to run, it was called tool_probe_m6, so unsure if anything will even work now.

It is getting to the point where as much as I would not like to put all my files out there that I might just have to to see if anyone can work out where I'm going wrong or if what I'm trying to do can be done.

I have created a second "sim" configuration to just play around with the remap at this stage, but hope to put it back into my other config later on with a gladeVCP panel I have coded.

At this stage i am just running a "sim" config on a computer in my house as it is getting cold where I am.

Running linuxcnc 2.7.15 to if that make a difference or anything.

Thanks

William

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

More
18 May 2021 12:50 - 18 May 2021 12:51 #209344 by bevins
Replied by bevins on topic Remap, Lost as anything
Well..... yeah this is an issue with remapping. The interpreter is ignoring commands and it has to do with quebusters.

I worked on 2.7 with mine but upgraded tyo 2.8 back then. The only thing I was able to get working was self.execute. I dont know what your code looks like but nested functions seem to be an issue also if I remember correctly. I had a hared time with this also. It is not documented very much, not alot of pure python examples that deals with quebusters. I would suggest just working on toolchange get that working then incorporate the probing.

I know during that time they were working on remapping and stdglue. But put some print statements in stdglue and make sure they are executing because you will propbably find out they are not.
Last edit: 18 May 2021 12:51 by bevins.

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

More
19 May 2021 01:40 #209433 by cmorley
Replied by cmorley on topic Remap, Lost as anything
Here is a sample I was working on in standard glue (in master)
Sounds similar to what you want to do. I did not complete this to cover all eventualities - hope to get back to it.
It may require master to work but may give you some ideas too
# REMAP=M6 modalgroup=10 python=tool_probe_m6
#
# auto tool probe on m6
# move to tool change position for toolchange
# wait for acknoledge of tool change
# move to tool setter probe position
# probe tool on tool setter
# move back to tool change position
# set offsets
# based on Versaprobe remap
#
# param 5000 holds the work piece height
# param 4999 should be set to 1 if the 
# machine is based in imperial
#
# required INI settings
# (Abs coordinates/ machine based units)
#
#[CHANGE_POSITION]
#X = 5
#Y = 0
#Z = 0

#[TOOLSENSOR]
#X = 5.00
#Y = -1
#Z = -1
#PROBEHEIGHT = 2.3
#MAXPROBE =  -3
#SEARCH_VEL = 20
#PROBE_VEL = 5

def tool_probe_m6(self, **words):

    # only run this if we are really moving the machine
    # skip this if running task for the screen
    if not self.task:
        yield INTERP_OK

    IMPERIAL_BASED = not(bool(self.params['_metric_machine']))

    try:
        # we need to be in machine based units
        # if we aren't - switch
        # remember so we can switch back later
        switchUnitsFlag = False
        if bool(self.params["_imperial"]) != IMPERIAL_BASED:
            print ("not right Units: {}".format(bool(self.params["_imperial"])))
            if IMPERIAL_BASED:
                print ("switched Units to imperial")
                self.execute("G20")
            else:
                print ("switched Units to metric")
                self.execute("G21")
            switchUnitsFlag = True

        self.params["tool_in_spindle"] = self.current_tool
        self.params["selected_tool"] = self.selected_tool
        self.params["current_pocket"] = self.current_pocket
        self.params["selected_pocket"] = self.selected_pocket

        # cancel tool offset
        self.execute("G49")

        # change tool where ever we are
        # user sets toolchange position prior to toolchange
        # we will return here after

        try:
            self.selected_pocket =  int(self.params["selected_pocket"])
            emccanon.CHANGE_TOOL(self.selected_pocket)
            self.current_pocket = self.selected_pocket
            self.selected_pocket = -1
            self.selected_tool = -1
            # cause a sync()
            self.set_tool_parameters()
            self.toolchange_flag = True
        except InterpreterException as e:
            self.set_errormsg("tool_probe_m6 remap error: %s" % (e))
            yield INTERP_ERROR

        yield INTERP_EXECUTE_FINISH

        # record current position; probably should record every axis
        self.params[4990] = emccanon.GET_EXTERNAL_POSITION_X()
        self.params[4998] = emccanon.GET_EXTERNAL_POSITION_Y()
        self.params[4997] = emccanon.GET_EXTERNAL_POSITION_Z()

        try:
            # move to tool probe position (from INI)
            self.execute("G90")
            self.execute("G53 G0 X[#<_ini[TOOLSENSOR]X>] Y[#<_ini[TOOLSENSOR]Y>]")
            self.execute("G53 G0 Z[#<_ini[TOOLSENSOR]Z>]")

            # set incremental mode
            self.execute("G91")

            # course probe
            self.execute("F [#<_ini[TOOLSENSOR]SEARCH_VEL>]")
            self.execute("G38.2 Z [#<_ini[TOOLSENSOR]MAXPROBE>]")

            # Wait for results
            yield INTERP_EXECUTE_FINISH

            # FIXME if there is an error it never comes back
            # which leaves linuxcnc in g91 state
            if self.params[5070] == 0 or self.return_value > 0.0:
                self.execute("G90")
                self.set_errormsg("tool_probe_m6 remap error:")
                yield INTERP_ERROR

            # rapid up off trigger point to do it again
            if bool(self.params["_imperial"]):
                f = 0.25
            else:
                f = 4.0
            self.execute("G0 Z{}".format(f))

            self.execute("F [#<_ini[TOOLSENSOR]PROBE_VEL>]")
            self.execute("G38.2 Z-0.5")
            yield INTERP_EXECUTE_FINISH

            # FIXME if there is an error it never comes back
            # which leaves linuxcnc in g91 state
            if self.params[5070] == 0 or self.return_value > 0.0:
                self.execute("G90")
                self.set_errormsg("tool_probe_m6 remap error:")
                yield INTERP_ERROR

            # set back absolute state
            self.execute("G90")

            # return to recorded tool change positon
            self.execute("G53 G0 Z[#4997]")
            yield INTERP_EXECUTE_FINISH
            self.execute("G53 G0 X[#4999] Y[#4998]")

            # adjust tool offset from calculations
            proberesult = self.params[5063]
            probeheight = self.params["_ini[TOOLSENSOR]PROBEHEIGHT"] 
            workheight = self.params[5000]

            adj = proberesult - probeheight + workheight
            self.execute("G10 L1 P#<selected_tool> Z{}".format(adj))

            # apply tool offset
            self.execute("G43")

            # if we switched units for tool change - switch back
            if switchUnitsFlag:
                if IMPERIAL_BASED:
                    self.execute("G21")
                    print ("switched Units back to metric")
                else:
                    self.execute("G20")
                    print ("switched Units back to imperial")
 
        except InterpreterException as e:
            msg = "%d: '%s' - %s" % (e.line_number,e.line_text, e.error_message)
            print (msg)
            yield INTERP_ERROR

    except Exception as e:
        print (e)
        self.set_errormsg("tool_probe_m6 remap error: %s" % (e))
        yield INTERP_ERROR
The following user(s) said Thank You: Clive S

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

More
19 May 2021 11:00 - 19 May 2021 11:02 #209480 by Willheg
Replied by Willheg on topic Remap, Lost as anything
Thanks for the info bevins, I will relook this over again soon as it is late tonight where I am now while checking for replys.

cmorley, thanks for that one, this is the one I fould in a stdglue.py on the github page somewhere, I have tried it but had no luck, will have to play some more maybe and see where I can get to.

All else failing, sometime next week I think it will be time to submit where I'm at even thought I think I'm a long way off to see if it can be made to work how I'd like.
Last edit: 19 May 2021 11:02 by Willheg.

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

More
01 Jun 2021 13:18 #210888 by Willheg
Replied by Willheg on topic Remap, Lost as anything
Hello again everyone,

Well I'm back after some more playing and have got the remap to a somewhat working state.

My issues now is after I issue the tool change command in the python script and the request the move to the tool touch off position, there is somehow a xtra move being added in before this which sends the tool back to where ever the program was started, then goes to the tool touch off position.

Seams like a lot of wasted movement

I have tried TOOL_CHANGE_AT_G30 = 0, commented out TOOL_CHANGE_POSITION line, and added TOOL_CHANGE_QUILL_UP = 0, all with no result.

Can anyone shed any light on what might be going on? I have also made a dumber down version of what I'm doing using the manual tool change feature on a sim config, so if needs be I could work out how to shear this so people can take a look if needs be to see what is wrong or anything. Once this all works like I'm after I will test on my machine I have to see if it all works right then if I'm happy will release my code for others to have a look at and try at there descretion if they like.

Would just like to thank everyone so far and also to everyone else that has released code that I have looked over to get where I am.

William.

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

More
01 Jun 2021 13:22 #210889 by andypugh
Replied by andypugh on topic Remap, Lost as anything
Is it possible that the extra move is coming from the CAM system? Fusion 360 always puts a G53 G0 Z0 before every tool change.

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

More
01 Jun 2021 13:39 #210893 by Willheg
Replied by Willheg on topic Remap, Lost as anything
I hand wrote a gcode file so no xtra moves in there that I'm aware of, it seems to happen after every tool change commanded, and from memory it's the same in mdi mode. Will check this out again in a couple of days time to see if that's the case.

Maybe I'm missing something in the remap code to stop this, I am trying to do it all in python but getting to the point where I may just give up and use the change.ngc sub routine as I've tried everything I can think of.

Anyway it's super late where I am, thanks for the help so far and all replays are welcome. Will check back in again really soon.

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

Time to create page: 0.081 seconds
Powered by Kunena Forum