Gmoccapy - trying to change M6 remap

More
13 May 2015 05:13 #58612 by nilsht
Im trying to make some changes to gmoccapy's toolchange M6 remap, making it call a python routine. See line 45 in pastebin.com/TLNF3Zns .
The call/routine works fine, but it is somehow called before line 32/33 is executed, so my routine is executed before the spindle is moved to the toolsensor-position.
Any ideas?

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

More
13 May 2015 17:18 - 13 May 2015 17:18 #58625 by andypugh
LinuxCNC queues-up moves to keep the motion smooth.
I think what is happening is that the G0 moves are being added to the queue and the interpreter is moving on to look for more motion lines.
(If your subroutine was a set of cuts you would expect it to be blended through)

You can either force a synch in the G-code (I can't remember how, but I should be able to find out) or your python code could wait until the machine is in position before popping up the message.
import linuxcnc
...
s = linuxcnc.stat()
...
s.poll()
while s.inpos() != 1 # I don't actually know what value the flag takes when in position
    #twiddle thumbs
    s.poll()
Last edit: 13 May 2015 17:18 by andypugh.

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

More
14 May 2015 00:03 #58646 by newbynobi
As mentioned allready, you must force a sinc.
Best to do this is wait for a digital io to become true after the call of the python part and set the digital io to true as last step of your python code.

Norbert

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

More
14 May 2015 03:32 #58655 by nilsht
Thank you for answers. I tried to use the routines Andy mentioned, but with no luck.
I googled around abit and found "yield INTERP_EXECUTE_FINISH", but as "Yield does not work in a Python oword procedure.", its really of no use.
As for testing for an io = true after the python call, will that not just ensure that my python-routine is finished executing before continuing?
I am a total n00b to the workings of linuxcnc, so please forgive my ignorance.

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

More
15 May 2015 18:16 #58727 by nilsht
Any more suggestions etc very welcome :unsure:
Beeing new to linuxcnc AND Python is a bad combo :P

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

More
15 May 2015 18:49 - 15 May 2015 18:50 #58730 by newbynobi
It is easy, please use in your G-Code G61

Digital IO

In your Python code you can set the pin to true with
import hal
self.halcomp = hal.component("<your_component>")
self.halcomp.ready()

import hal_glib
myhalpin = hal_glib.GPin(self.halcomp.newpin("<my_Halpin>", hal.HAL_BIT, hal.HAL_OUT)


# Set the pin to true to get the gcode continue running
self.halcomp["<my_Halpin>"] = True

Do not forget to connect the G61 hal pin to "<your_component>"."<my_Halpin>" in your postgui hal file.

Does this help?

Norbert

P.S. without testing, out of memory ;-)
Last edit: 15 May 2015 18:50 by newbynobi.

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

More
29 May 2015 02:33 - 29 May 2015 02:34 #59165 by nilsht
I guess you mean G62?
I tried to do this using the message/okdialog in Gmoccapy, but the program execution just continues, not stopping to wait for buttonclick.
This is how I set it up:

xxx.ini:
MESSAGE_TEXT = Connect probe now please.
MESSAGE_TYPE = okdialog
MESSAGE_PINNAME = connectclip

postgui.hal:
net clipon gmoccapy.messages.connectclip <= motion.digital-out-00

And in change.ngc:
M62 P0
O450 while [#<_hal[gmoccapy.messages.connectclip-waiting]>]
O450 endwhile

which pops up dialog.
So, Im still kindof stuck :unsure:
Last edit: 29 May 2015 02:34 by nilsht.

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

More
29 May 2015 02:59 #59168 by andypugh

I guess you mean G62?


Actually, maybe M66 :-)

M66 P0 L1 will wait for a rising-edge on the HAL pin, and you can arrange for your Python routine to make that happen at the right point.

I am wondering exactly what it is that you are trying to do. Is it possible that altering hal_manualtoolchange might be easier?

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

More
29 May 2015 03:44 #59170 by nilsht
I am trying to modify change.ngc so that it after it has moved to [TOOLSENSOR] pops up an OK-dialog telling me to connect probeclip, and wait until I press OK before starting G38.2
Then a new popup to wait for me to remove same clip.
Thats really all :)

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

More
29 May 2015 04:15 #59172 by andypugh

I am trying to modify change.ngc so that it after it has moved to [TOOLSENSOR] pops up an OK-dialog telling me to connect probeclip, and wait until I press OK before starting G38.2
Then a new popup to wait for me to remove same clip.
Thats really all :)


So the G-code needs to set output 0 to tell the Python to pop-up the message, and then it needs to wait (M66) for the Python code to set input 0 say that it has done so.

I think that M66 is a queue-buster, but if not I am pretty sure that G43 is.
The following user(s) said Thank You: nilsht

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

Moderators: newbynobiHansU
Time to create page: 0.207 seconds
Powered by Kunena Forum