-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gmoccapy - Patch for Combination M61 + G4 #2489 - Version 2 #2841
Conversation
This patch ensures that the automatic command G43 is not executed immediately, but when the LCNC is in IDLE mode.
The idea as described sounds fine, but I think we need Norbert (@gmoccapy ) to look at the code to be sure it will work without unintended side-effects. |
I agree with Andy. |
I would like to add some more information about what this patch is good for. Currently, Gmoccapy behaves randomly when we want to change the tool with G43 active. Sometimes only a tool change is implemented. Sometimes a tool change is performed and the tool table window is closed. I made two examples. In both cases I have G43 active and in both cases I change the tool from tool1 to tool10. |
@gmoccapy Can we at least add this Pull Request to the master branch? The master branch is still in development and could be tested. |
Please do not add this, I do only know one case where the actual way does not work. I do hope to have time to go on developing the GUI in about one year |
@gmoccapy Replace MDI commands:
By changing the parameters: There would be no need to deal with problematic MDI mode switching. Would it be acceptable to you if one of the experienced programmers did it? I understand that you don't want push PR from an amateur like me. That I'm an amateur is a fact, it's not sarcasm. |
can somebody explain what the actual problem is? |
It all started here: It is race condition. linuxcnc/src/emc/usr_intf/gmoccapy/gmoccapy.py Line 3489 in d9fd333
In _update_toolinfo is "automatic G43": linuxcnc/src/emc/usr_intf/gmoccapy/gmoccapy.py Lines 3538 to 3542 in d9fd333
Sometimes "mdihistory widget" wins and G4 is executed. I use
At this moment I dont recommend merge this patch Version 2, because patch Version 4 is better. |
Sorry but I still don't understand. What does M61 have to do with G4? Can you tell what the problem is, in other words, where does gmoccapy something unexpected? What is it that is unexpected and what should happen instead? |
Look here: #2489 You will probably never use M61 + G4 commands in the real world. This combination is only used to simulate bugs. Expected:
Real:
The problem is that this bug is dependent on the PC configuration. Some users are unable to simulate this bug. What happens to you when you enter: linuxcnc/src/emc/usr_intf/gmoccapy/gmoccapy.py Line 3489 in d9fd333
If you test only: |
There is definitely something fishy going on, I can trigger it only in gmoccapy, not in axis. I will investigate what the interpreter / tasl / mot is doing, there can't be a difference between different GUIs IMO. I don't really believe the Dwell is not executed, the problem is probably somewhere else. One last thing: how does "G43" play into this? I guess that G43 is not executed in the case the dwell is "skipped"? |
It looks like the interpreter returns/is returned to "idle" without waiting (or without waiting the full time). IMO we should find out how and why that happens and fix that (if possible) and not patch around it for some cases like G43 after tool change. |
@rmu75 As far as I do know, you are not seeing this behaviour in AXIS, as AXIS has no auto G43 If G43 is set once in gmoccapy the GUI will maintain that G-Code active, even after setting a new tool. I did not find a way to simulate the described problem, mostly caused to a lake of time. Norbert |
I think the interpreter is waiting for NOTHING. The problem is not just waiting for G-code commands to be executed. If you want to fix it overall, you also need to solve the waiting for mode switching. For example:
For example, I did the preparation for stacking HALUI commands here: |
There is something else going on, i tried "M61 Q1 G4 P10" etc..., and the G4 dwell sometimes doesn't happen -- the interp returns to idle "immediately" (it should stay in "waiting for delay"). or is returned. which is to be determined. It probably really is a race condition but for me it is not obvious where / what is involved and if gmoccapy has really anything to do with it. I'm going to the bottom of that (I think I have seen such behaviour on one of my machines) but it will need some time, don't hold your breath. |
I misspoke somewhat, interp should stay in "reading" and execState should stay in "waiting for delay", but sometimes interp returns to idle and execstate to done without the dwell. Maybe some intermediate steps are involved that I'm currently missing. |
Ok, now I understand better:
So what happens is
So indeed issuing G43 should wait until interp is idle. Issuing G43 should probably happen in the M6 remap anyways. |
I wonder how this can work at all in case of a remapped M6 -- I guess the tool number is changed only upon successful completion of the remapped procedure. What remains is gmoccapy can and will cancel macros or multiple commands called from MDI that change the tool / tool number, subject to timing / race condition. |
gmoccapy doesn't miss a state changes, it reacts too fast, it sends a mode change to the interp that is still occupied with executing the tool change. This mode change cancels / interferes with whatever the interp was doing. |
Thinking about it a bit more, that "auto-G43" can't be implemented correctly in gmoccapy (or any GUI really). Just suppose you are executing something like "M61 Q4 F5 G1 Z-10". In this case, after M61 Q4 sets tool number, at some point in the G1 move gmoccapy executes G43, cancelling the move. So this "G43" needs to be sandwiched in between M61 and G1 which is not possible from within the GUI. So this auto-G43 could be implemented either in the M6 remap (not sure if that's possible for M61) or something has to be done in the interpreter. |
"auto-G43" can't be implemented correctly in any GUI at THIS TIME. In theory, it would be possible, but tools for determining priorities would have to be created.
It is a great pity that there is no warning in any log that some G-code commands are arborted. At THIS TIME, it's really easiest to delete "auto-G43" in Gmoccapy and use remap.
M61 is possible:
? The solution I'm using now: System solution design:
|
The GUI isn't the right place to define machine behaviour anyways. Machine should behave identically independent of selected GUI IMHO. AFAIK the "T" command only prepares the tool change and could be used ahead of time to e.g. turn the carousel while still doing some machining. Also M61 uses Q. So I would remap M6 and M61 and put G43 there. I'm not sure what you mean with priority of commands, but "preempting" executing commands with other stuff or manipulating queued commands is not possible / a bad idea IMO. So I suppose your solution of deactivating "auto-G43" and implementing that in the M6 / M61 remap is the only way to get consistent behaviour. The gmoccapy auto-G43 only works in simple cases and is potentially dangerous. |
It is a very dangerous. In my configuration auto-G43 has already set wrong corrections a few times. Bad corrections mean a 99% crash machine. That's why I spend so much time on this problem. |
Another way is: BUT it is not working now: |
I would like to ask Robert Schöftner if he would be willing to look into why RETAIN_G43=1 does not work. It would probably be easier than using the M6 remap. |
I did try RETAIN_G43 it and indeed it doesn't seem to work. Unfortunately the code that is involved linuxcnc/src/emc/rs274ngc/interp_convert.cc Line 3955 in d8a09ef
|
What do you mean? May I ask for an explanation? |
Here are some comments: |
there is no test case in tests/ dir that tests RETAIN_G43. |
I readed definition of RETAIN_G43 again:
I think the RETAIN_G43 function is for *.ngc file read only. After the *.ngc program ends, it is deactivated. Therefore, RETAIN_G43 cannot be tested in MDI or MANUAL code. In conclusion, I would say that RETAIN_G43 != auto_G43 in Gmoccapy |
I feel that it would be reasonable to expect RETAIN_G43 to work in MDI too. (and also feel that the GUI has no business at all in affecting this behaviour) |
To andy: I think that it works correctly. MDI command is something like 1 program for RETAIN_G43. After execute MDI commad, G49 is activated. |
Hmm, OK. But then I don't see the point in RETAIN_G43. I have always assumed that RETAIN_G43 was meant to be AUTOMATIC_G43. But clearly not. |
I think RETAIN_G43 only makes sense for manually typing G-code. The post-processor automatically places G43 everywhere. The post-processor can't forget it. A person can forget it. |
rmu75:
I would like to ask @gmoccapy to comment on rmu75's post. I would like to remove automatic_g43 from Master branche. |
You are right, if you mention that the GUI is not the correct place to define machine behavior but also industrial machines behave different depending on the GUI / better said Haidenhain, Siemens, Haas etc. The Problem is not in automatic programs, as the post processor (being a human very often) is responsible for the G43 handling. So I would like to mention, why I have introduced the actual behavior. I and some other users are using the machine in semi automatic way. I set my work piece with a 3D zero point setter, after I use MDI commands to mill just one side or a bore etc. If you drill a hole, you use first a center drill, then a drill and last a deburring tool. I have all that tools measured in ma tool table, I just change the tool by hand and I do not have to care about G43. If you do remove the "auto G43" from gmoccapy we should add at the same time a tool change remap Sim with manual and auto change with auto G43. That must contain also a M61 handling of the G43 settings. I was until now not able to reproduce the race condition on my machines, so IMHO it is a very very random problem. But is up to you what to do, as I will only be able to work on gmoccapy in about one year, as I have rebuild a house and need to finish my new workshop to stand up my two new machines. (old workshop is getting to expensive). Norbert |
Thank you for your comment. I'm closing this PR and starting to work on removing automatic_G43 + M6 M61 remap + its integration into the sim. |
This patch ensures that the automatic command G43 is not executed immediately, but when the LCNC is in IDLE mode.