(RESOLVED) Remapping M6 - I am having issues
- bevins
-
Topic Author
- Offline
- Platinum Member
-
Less
More
- Posts: 1943
- Thank you received: 336
31 Mar 2017 11:17 - 10 Apr 2017 15:00 #90634
by bevins
(RESOLVED) Remapping M6 - I am having issues was created by bevins
Hi,
We have written a remap of M6 and it is working in preview instance. Wrote it while in preview without testing self.task so it ran as soon as we loaded LCNC for easy debugging. This I thought would be ok except now I am finding the two instances don't act the same. I could never get self.execute to work ever. even a simple 5 liner remap would not move the axis's, so I reverted to mdi mode for moving. That worked and everything is ok except after adding the self.task check and exiting the remap when in preview mode everything worked up until I ran the program. Then I got errors. Apparantly cannot activate digital outs and read digital ins while in auto mode. Am I suppose to switch to manual mode during a remap and switch back to auto?
I know I have made some fundamental errors but I cannot recover from it. I would need a little guidance please.....
Had to change the py ext to txt because the forum wont allow it.
We have written a remap of M6 and it is working in preview instance. Wrote it while in preview without testing self.task so it ran as soon as we loaded LCNC for easy debugging. This I thought would be ok except now I am finding the two instances don't act the same. I could never get self.execute to work ever. even a simple 5 liner remap would not move the axis's, so I reverted to mdi mode for moving. That worked and everything is ok except after adding the self.task check and exiting the remap when in preview mode everything worked up until I ran the program. Then I got errors. Apparantly cannot activate digital outs and read digital ins while in auto mode. Am I suppose to switch to manual mode during a remap and switch back to auto?
I know I have made some fundamental errors but I cannot recover from it. I would need a little guidance please.....
Had to change the py ext to txt because the forum wont allow it.
Last edit: 10 Apr 2017 15:00 by bevins.
Please Log in or Create an account to join the conversation.
- bevins
-
Topic Author
- Offline
- Platinum Member
-
Less
More
- Posts: 1943
- Thank you received: 336
31 Mar 2017 11:26 - 04 Apr 2017 02:50 #90635
by bevins
Replied by bevins on topic Remapping M6 - I am having issues
The code before did not work. I have the remap figurd out now and will uplaod an example her of a completed toolchange remap m6 in pure python.
Last edit: 04 Apr 2017 02:50 by bevins.
Please Log in or Create an account to join the conversation.
- bevins
-
Topic Author
- Offline
- Platinum Member
-
Less
More
- Posts: 1943
- Thank you received: 336
01 Apr 2017 12:58 #90697
by bevins
Replied by bevins on topic Remapping M6 - I am having issues
Attached is the console out with DEBUG turned on max....
Please Log in or Create an account to join the conversation.
- andypugh
-
- Offline
- Moderator
-
Less
More
- Posts: 23279
- Thank you received: 4933
04 Apr 2017 12:36 #90864
by andypugh
Replied by andypugh on topic Remapping M6 - I am having issues
Is it working now, or not?
Please Log in or Create an account to join the conversation.
- bevins
-
Topic Author
- Offline
- Platinum Member
-
Less
More
- Posts: 1943
- Thank you received: 336
10 Apr 2017 14:50 - 10 Apr 2017 15:18 #91126
by bevins
I have adapted the programming to sooth the behavour of the interpreter, so it doesnt complain.
I cannot call a function from within a function, this does not work. I dont know if this is a bug or the issues relateed with
behaviour of the interpreter. If I do not call a function from within a function everything works. I have to use the INTERP_EXECUTE_FINISH or the interpreter ignores the commands and all hell breaks loose.
I yeild the INTERP_EXECUTE_FINISH in a function that was called from another function then return back to the calling function and INTERP_EXECUTE_FINISH, that is not working. But I got around it by changing the logic of the main program and all is working.
All the moves and input checking and output setting is done with self.execute("GCODE"), and it works extremely well. I added a couple functions in a spoiler so you can see.
The trick is to keep the interpreter happy. The docs make it sound like when doing a remap just tell the interpreter to yield, then end with syncing the interpreter. That does not work. When calling a function, you need to make sure before you return to the main program you sync the interpreter. That is the only way I got it to work.
You cannot return anything within the function either. It does not work. The docs supports this also.
I am continuing to test entering and exiting functions until I find the way to do it, if it is possible to do at all.
But it works extremely well.
If you stay within the realms of the interpreter, you shouldnt have no problems. The interpreter does what it is designed to do really well.
I will upload a remap all in python, I will remove all my xml and auto stufrf so ti will be easy to see,.
Replied by bevins on topic Remapping M6 - I am having issues
Is it working now, or not?
I have adapted the programming to sooth the behavour of the interpreter, so it doesnt complain.
I cannot call a function from within a function, this does not work. I dont know if this is a bug or the issues relateed with
behaviour of the interpreter. If I do not call a function from within a function everything works. I have to use the INTERP_EXECUTE_FINISH or the interpreter ignores the commands and all hell breaks loose.
I yeild the INTERP_EXECUTE_FINISH in a function that was called from another function then return back to the calling function and INTERP_EXECUTE_FINISH, that is not working. But I got around it by changing the logic of the main program and all is working.
All the moves and input checking and output setting is done with self.execute("GCODE"), and it works extremely well. I added a couple functions in a spoiler so you can see.
The trick is to keep the interpreter happy. The docs make it sound like when doing a remap just tell the interpreter to yield, then end with syncing the interpreter. That does not work. When calling a function, you need to make sure before you return to the main program you sync the interpreter. That is the only way I got it to work.
You cannot return anything within the function either. It does not work. The docs supports this also.
I am continuing to test entering and exiting functions until I find the way to do it, if it is possible to do at all.
But it works extremely well.
Warning: Spoiler!
def DropToolToPocket1(self):
self.execute("G53 G0 X15.375 Y-25.57 Z0") #Move to front of pocket 1
self.execute("M64 P2") #Drop Spindle
self.execute("M66 P9 L3 Q5") #Wait for Spindle to drop
self.execute("M65 P2") #Release drop SP relay, only needs pulse
self.execute("M64 P10") #raise Pocket 1
self.execute("M66 P17 L3 Q5") #wait for Pocket to raise
self.execute("G53 G0 Z-1.788") #Drop the Z into position
self.execute("G53 G1 F200 X11.825") #Move into pocket to release tool
self.execute("M66 P4 L3 Q5") #Wait for pocket 1 has tool
self.execute("M64 P8") #Release Spindle
self.execute("M66 P13 L3 Q5") #Wait for Spindle to release
self.execute("M64 P5") #Raise Spindle
self.execute("M66 P7 L3 Q5") #Wait for Spindle to raise
self.execute("G53 G0 Z0") #Move to Z0
self.execute("M65 P8") #Release Sp A pulse relay, only needs pulse
self.execute("M64 P9") #Lock Spindle A
self.execute("G4 P1.0") #wait to release pulse on lock spindle
self.execute("M65 P9") #release Lock Spindle A, only needs pulse
self.execute("M65 P10") #Lower Pocket 1
self.execute("G53 G0 X15.375 Y-25.57 Z0") #Move to front of pocket 1
INTERP_EXECUTE_FINISH
def PickUpToolInPocket1(self):
self.execute("G53 G0 Z0") #Move to Z0
self.execute("G53 G0 X11.825 Y-25.57 Z0") #Move to top of pocket 1
self.execute("G53 G0 Z-1.788") #Drop the Z into position
self.execute("M64 P10") #raise Pocket 1
self.execute("M66 P17 L3 Q5") #wait for Pocket to raise
self.execute("M64 P8") #Release Spindle
self.execute("M66 P13 L3 Q5") #Wait for Spindle to release
self.execute("M64 P2") #Drop Spindle
self.execute("M66 P9 L3 Q5") #Wait for Spindle to drop
self.execute("M65 P2") #Release drop SP relay, only needs pulse
self.execute("M64 P9") #Lock Spindle A
self.execute("G4 P1.0") #wait to release pulse on lock spindle
self.execute("M65 P9") #release Lock Spindle A, only needs pulse
self.execute("G53 G0 X15.375") #Move out to front of pocket 1
self.execute("M64 P5") #Raise Spindle
self.execute("M66 P7 L3 Q5") #Wait for Spindle to raise
self.execute("M65 P10") #Lower Pocket 1
self.execute("G53 G0 Z0") #Move to Z0
INTERP_EXECUTE_FINISH
If you stay within the realms of the interpreter, you shouldnt have no problems. The interpreter does what it is designed to do really well.
I will upload a remap all in python, I will remove all my xml and auto stufrf so ti will be easy to see,.
Last edit: 10 Apr 2017 15:18 by bevins.
Please Log in or Create an account to join the conversation.
- bevins
-
Topic Author
- Offline
- Platinum Member
-
Less
More
- Posts: 1943
- Thank you received: 336
10 Apr 2017 15:15 - 10 Apr 2017 15:16 #91128
by bevins
Replied by bevins on topic Remapping M6 - I am having issues
One other thing you must have to make it work is the self.task check.
You have to check self.task is in the milltask instance or the preview instance and exit if it is in preview or else it will run your remap.
I do this at the beginning of remap file.
if self.task==0:
return INTERP_OK
What happens is when LinuxCNC starts up it is using the preview instance of the interpreter, so it can load the file and display it in the GUI.
So when you do your remap, if it is in preview you exit, otherwise your using the milltask instance.
When you run the program from within the GUI, you are using the milltask instance and it runs your gcode.
I hope I explained it correctly.
You have to check self.task is in the milltask instance or the preview instance and exit if it is in preview or else it will run your remap.
I do this at the beginning of remap file.
if self.task==0:
return INTERP_OK
What happens is when LinuxCNC starts up it is using the preview instance of the interpreter, so it can load the file and display it in the GUI.
So when you do your remap, if it is in preview you exit, otherwise your using the milltask instance.
When you run the program from within the GUI, you are using the milltask instance and it runs your gcode.
I hope I explained it correctly.
Last edit: 10 Apr 2017 15:16 by bevins.
The following user(s) said Thank You: JohnnyCNC
Please Log in or Create an account to join the conversation.
- bevins
-
Topic Author
- Offline
- Platinum Member
-
Less
More
- Posts: 1943
- Thank you received: 336
11 Apr 2017 13:51 - 11 Apr 2017 15:27 #91184
by bevins
Replied by bevins on topic Remapping M6 - I am having issues
Still have some timing tweaks but it is close....
Last edit: 11 Apr 2017 15:27 by bevins.
Please Log in or Create an account to join the conversation.
Time to create page: 0.076 seconds