- Posts: 58
- Thank you received: 0
Will the remapped code be executed first when the G code file is loaded?
4 years 11 months ago #224854
by chen1234
When I tested the G code, I found that writing the remapping code in the G code file, the remapping code will be executed first when the file is loaded, and I did not click to execute it.I don't understand how this is caused, hope someone can help me.Thank you in advance, here is my configuration and G code:
Attachment not found
Attachment not found
Please Log in to join the conversation.
4 years 11 months ago #224924
by andypugh
Replied by andypugh on topic Will the remapped code be executed first when the G code file is loaded?
The code is run-through in simulation mode when the file is loaded to generate the graphical preview.
You can choose to exclude some code from execution if this causes a problem:
See #<_task>
linuxcnc.org/docs/2.8/html/gcode/overvie...ub:system-parameters
You can choose to exclude some code from execution if this causes a problem:
See #<_task>
linuxcnc.org/docs/2.8/html/gcode/overvie...ub:system-parameters
Please Log in to join the conversation.
4 years 11 months ago #224963
by chen1234
Replied by chen1234 on topic Will the remapped code be executed first when the G code file is loaded?
Thank you for your answer, I solved the problem that it will be executed when the file is loaded. But I encountered a new problem: I used python to remap a G code: G02.1, its function is to assign the value of the parameter to another executable program. But after I load the G code file, it will be executed immediately when I click Start, and it is not executed in the order of the G code file. What should I do to make the remapped code execute in the order in the file? Thanks in advance, here is my code:The code is run-through in simulation mode when the file is loaded to generate the graphical preview.
You can choose to exclude some code from execution if this causes a problem:
See #<_task>
linuxcnc.org/docs/2.8/html/gcode/overvie...ub:system-parameters
Attachment not found
Please Log in to join the conversation.
4 years 11 months ago #225264
by andypugh
Replied by andypugh on topic Will the remapped code be executed first when the G code file is loaded?
I wonder if the Python storage class being used is not necessarily an ordered list?
Please Log in to join the conversation.
4 years 11 months ago #225320
by chen1234
Replied by chen1234 on topic Will the remapped code be executed first when the G code file is loaded?
I solved the order problem because the remapping code cannot be executed in order, I added yield INTERP_EXECUTE_FINISH. Now it can be executed in the order I wrote, but a new problem has arisen. I can’t get this remapping code to execute the function completely. It will execute the next line of G Code. The function of my remapping code is to pass parameters to the executable program .cpp. The executable program controls the movement of the galvanometer, but cannot make the galvanometer work complete before executing the next line of g code. That is, my galvanometer motion may not be completed yet, and cnc went to execute the next line of G code.Some people say that I need to return to INTERP_EXECUTE_FINISH, but I feel very confused when using it and cannot return it normally. I hope someone can help me. Thanks in advance, here is my code:
Attachment not found
Attachment not found
Please Log in to join the conversation.
4 years 10 months ago #228888
by 93xshang
Replied by 93xshang on topic Will the remapped code be executed first when the G code file is loaded?
Not sure if you've figured this out, but the issue you are having is because you can't have both
and
in the same remapped function. Remove the return lines from your functions and see if it will work. For more information checkout #9.4.5 in
linuxcnc.org/docs/2.6/html/remap/structu...ntions_ngc_to_python
Code:
return
Code:
yield
Please Log in to join the conversation.
1 year 6 months ago #326216
by DavidK
Replied by DavidK on topic Will the remapped code be executed first when the G code file is loaded?
Hi,
I have the same problem. Could you please tell me where I have to set the #<_task> paramter to skip the remapped code.
Thank you very much
I have the same problem. Could you please tell me where I have to set the #<_task> paramter to skip the remapped code.
Thank you very much
Please Log in to join the conversation.
1 year 6 months ago #326217
by Aciera
Replied by Aciera on topic Will the remapped code be executed first when the G code file is loaded?
You don't 'set' the #<_task> parameter, you use an 'if' statement in your code to check the value of the #<_task> parameter.
Examples:
In ngc code:
In a python remap:
Examples:
In ngc code:
Code:
o100 if [#<_task> EQ 1]
;everything in here is only executed during actual gcode execution
o100 endif
In a python remap:
Code:
if self.task == 0: # ignore the preview interpreter
yield INTERP_EXECUTE_FINISH
return INTERP_OK
Please Log in to join the conversation.
Time to create page: 0.117 seconds
