Python toolchanger, problem while loading program
07 Aug 2018 18:06 #115762
by emcPT
Python toolchanger, problem while loading program was created by emcPT
Hello,
I am working on a python tool changer project that is mostly already doing what we wanted. In fact we were already saying that it is ready as we tested several time with MDI mode.
When preparing gcode to test the tool changer in a repeat manner, we found that any gcode file during load though errors that are present on the python tool changer. It looks like the preview runs the toolchanger (that makes sense). However there are conditions that are not meet during the load of a file that are effective errors if the tool changer is really called.
To avoid this error I have tested several things including trying to get the linuxcnc.status or mode, without success, so that in python the tool changer routine is aborted if the machine is not running in AUTO or MDI.
Any ideia to overcome this problem?
I am working on a python tool changer project that is mostly already doing what we wanted. In fact we were already saying that it is ready as we tested several time with MDI mode.
When preparing gcode to test the tool changer in a repeat manner, we found that any gcode file during load though errors that are present on the python tool changer. It looks like the preview runs the toolchanger (that makes sense). However there are conditions that are not meet during the load of a file that are effective errors if the tool changer is really called.
To avoid this error I have tested several things including trying to get the linuxcnc.status or mode, without success, so that in python the tool changer routine is aborted if the machine is not running in AUTO or MDI.
Any ideia to overcome this problem?
Please Log in or Create an account to join the conversation.
07 Aug 2018 19:04 - 07 Aug 2018 19:14 #115765
by bevins
Replied by bevins on topic Python toolchanger, problem while loading program
I use this in my M6 remap to get the mode.
I used it when building and troubleshooting python remap. I pulled it from the code but the function is still there.
I used it when building and troubleshooting python remap. I pulled it from the code but the function is still there.
Warning: Spoiler!
def emc_status(actualtask):
s = linuxcnc.stat()
s.poll()
task_mode = s.task_mode
task_state = s.task_state
exec_state = s.exec_state
interp_state = s.interp_state
#actualtask = self.task
Warning: Spoiler!
sReturn = "---------------------------------------------------------\n"
sReturn += "task_mode values are :\n"
sReturn += "MODE_MANUAL : %d \n" % (linuxcnc.MODE_MANUAL)
sReturn += "MODE_AUTO : %d \n" % (linuxcnc.MODE_AUTO)
sReturn += "MODE_MDI : %d \n" % (linuxcnc.MODE_MDI)
sReturn += "task_mode = %d \n" % (task_mode)
Last edit: 07 Aug 2018 19:14 by bevins.
Please Log in or Create an account to join the conversation.
07 Aug 2018 19:11 #115766
by bevins
Replied by bevins on topic Python toolchanger, problem while loading program
Forum wont take my function. Says too many links in message, please decrease them.
So I have to split it up.
So I have to split it up.
Warning: Spoiler!
sReturn += "\n"
sReturn += "exec_state values are :\n"
sReturn += "EXEC_ERROR : %d \n" % (linuxcnc.EXEC_ERROR)
sReturn += "EXEC_DONE : %d \n" % (linuxcnc.EXEC_DONE)
sReturn += "EXEC_WAITING_FOR_MOTION : %d \n" % (linuxcnc.EXEC_WAITING_FOR_MOTION)
sReturn += "EXEC_WAITING_FOR_MOTION_QUEUE : %d \n" % (linuxcnc.EXEC_WAITING_FOR_MOTION_QUEUE)
sReturn += "EXEC_WAITING_FOR_IO : %d \n" % (linuxcnc.EXEC_WAITING_FOR_IO)
#sReturn += "EXEC_WAITING_FOR_PAUSE : %d \n" % (linuxcnc.EXEC_WAITING_FOR_PAUSE) This does not exist
The following user(s) said Thank You: emcPT
Please Log in or Create an account to join the conversation.
08 Aug 2018 11:47 #115803
by emcPT
Replied by emcPT on topic Python toolchanger, problem while loading program
Thank you.
We were not able to use your function as the return state during a MDI code or for example a touch off where the same, and during the touch off the routine trigger a error.
Or solution was to implement on the top of the python file a verification check for a digital pin that we know that is always "1". If it would be impossible to fetch the status of the pin or returned a value different than "1", it means that the python toolchanger script could not be used and returned without any toolchange.
We were not able to use your function as the return state during a MDI code or for example a touch off where the same, and during the touch off the routine trigger a error.
Or solution was to implement on the top of the python file a verification check for a digital pin that we know that is always "1". If it would be impossible to fetch the status of the pin or returned a value different than "1", it means that the python toolchanger script could not be used and returned without any toolchange.
Please Log in or Create an account to join the conversation.
08 Aug 2018 15:08 #115813
by bevins
Whats driving that pin?
Replied by bevins on topic Python toolchanger, problem while loading program
Thank you.
We were not able to use your function as the return state during a MDI code or for example a touch off where the same, and during the touch off the routine trigger a error.
Or solution was to implement on the top of the python file a verification check for a digital pin that we know that is always "1". If it would be impossible to fetch the status of the pin or returned a value different than "1", it means that the python toolchanger script could not be used and returned without any toolchange.
Whats driving that pin?
Please Log in or Create an account to join the conversation.
08 Aug 2018 18:28 #115826
by emcPT
Replied by emcPT on topic Python toolchanger, problem while loading program
The pin that we added to test?
We set it on hal to be true, always.
We set it on hal to be true, always.
Please Log in or Create an account to join the conversation.
08 Aug 2018 22:42 #115833
by cmorley
Replied by cmorley on topic Python toolchanger, problem while loading program
Is this relevant?
linuxcnc.org/docs/devel/html/remap/remap...apped-code-execution
linuxcnc.org/docs/devel/html/remap/remap...apped-code-execution
Please Log in or Create an account to join the conversation.
12 Aug 2018 14:53 #115963
by emcPT
Replied by emcPT on topic Python toolchanger, problem while loading program
Yes it is relevant. I did not tested, but it looks that is the correct way to do it.
Thank you
Thank you
Please Log in or Create an account to join the conversation.
13 Aug 2018 12:06 #115998
by bevins
Replied by bevins on topic Python toolchanger, problem while loading program
Are you checking which mode your in in your remap file?
I do it like this.... first thing to do in remap file, that will exit if in preview. If in milltask, it will run your code.
I do it like this.... first thing to do in remap file, that will exit if in preview. If in milltask, it will run your code.
if self.task==0:
return INTERP_OK
Please Log in or Create an account to join the conversation.
Time to create page: 0.100 seconds