- Posts: 12170
- Thank you received: 4153
How to make M1** execute Gcode
- rodw
- Offline
- Platinum Member
-
Less
More
4 years 2 months ago - 4 years 2 months ago #248927
by rodw
Replied by rodw on topic How to make M1** execute Gcode
I have not played with it at all but Python 3.10 which is shipped with Debian Bookworm where Linuxcnc can be installed using:
sudo apt install linuxcnc-uspace
Now includes a case statement:
Ref:
towardsdatascience.com/switch-case-state...-python-d0caf7b2bfd3
Its enought to make me want to adopt Bookworm as my new best friend.
sudo apt install linuxcnc-uspace
Now includes a case statement:
Code:
http_code = "418"
match http_code:
case "200":
print("OK")
do_something_good()
case "404":
print("Not Found")
do_something_bad()
case "418":
print("I'm a teapot")
make_coffee()
case _:
print("Code not found")
Its enought to make me want to adopt Bookworm as my new best friend.
Last edit: 4 years 2 months ago by rodw.
The following user(s) said Thank You: my1987toyota
Please Log in or Create an account to join the conversation.
- tjtr33
- Offline
- Elite Member
-
Less
More
- Posts: 170
- Thank you received: 54
4 years 2 months ago - 4 years 2 months ago #249004
by tjtr33
Replied by tjtr33 on topic How to make M1** execute Gcode
Hi,
I dont knopw if this will help
but I use M1xx to move
Theres a comp i use
and it changes modes from auto to Pause
and the motion destination is set by a seperate Mcode
My effort is for EDM
Yours is PickAnPlace
But the use of MoveWhilePaused is similar
Mine uses a single axis but can be modified
Yours would like have motion with some waypoints
that is, move UPtoClearHeight then XYtoPartWanted then DownToGrabPart then XYtoOverDest then DownToPartDestHeight
All this could be done using machine coordinates
This idea does NOT use Gcode, just destination positions
This code does NOT use PID Accell/Decell
This idea ends at same position where it began
That allows the mode reversal back to Auto without any jerk.
I attach the comp code and the hal wiring as png's
hth tomp
edit 07aug2022
in python script use
import sys, subprocess
then build your command string
like cmdstr = "halcmd setp testEtab.0.mypin"
and add the value to be set
like cmdstr = cmdstr + str(myval)
then have the system exec the cmdstr
like
subprocess.call(cmdstr, shell=True)
loop that recipe thru all the pins to be set
hth tomp
watch in action
subprocess.call(strg5, shell=True)
...
I dont knopw if this will help
but I use M1xx to move
Theres a comp i use
and it changes modes from auto to Pause
and the motion destination is set by a seperate Mcode
My effort is for EDM
Yours is PickAnPlace
But the use of MoveWhilePaused is similar
Mine uses a single axis but can be modified
Yours would like have motion with some waypoints
that is, move UPtoClearHeight then XYtoPartWanted then DownToGrabPart then XYtoOverDest then DownToPartDestHeight
All this could be done using machine coordinates
This idea does NOT use Gcode, just destination positions
This code does NOT use PID Accell/Decell
This idea ends at same position where it began
That allows the mode reversal back to Auto without any jerk.
I attach the comp code and the hal wiring as png's
hth tomp
edit 07aug2022
in python script use
import sys, subprocess
then build your command string
like cmdstr = "halcmd setp testEtab.0.mypin"
and add the value to be set
like cmdstr = cmdstr + str(myval)
then have the system exec the cmdstr
like
subprocess.call(cmdstr, shell=True)
loop that recipe thru all the pins to be set
hth tomp
watch in action
subprocess.call(strg5, shell=True)
...
Last edit: 4 years 2 months ago by tjtr33. Reason: example code & video link added
The following user(s) said Thank You: my1987toyota
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
-
Less
More
- Posts: 4793
- Thank you received: 1480
4 years 2 months ago #249043
by Todd Zuercher
Replied by Todd Zuercher on topic How to make M1** execute Gcode
Another option might be to an O-sub program call instead of an M1xx code.
The following user(s) said Thank You: my1987toyota
Please Log in or Create an account to join the conversation.
- my1987toyota
- Offline
- Platinum Member
-
Less
More
- Posts: 1004
- Thank you received: 449
4 years 2 months ago #249567
by my1987toyota
Replied by my1987toyota on topic How to make M1** execute Gcode
So far my end result became switching to a M201 code using python see the link if you want to see how it works.
[url] forum.linuxcnc.org/pnp/46568-using-m201-...nd-using-it-s-values [/url]
[url] forum.linuxcnc.org/pnp/46568-using-m201-...nd-using-it-s-values [/url]
Please Log in or Create an account to join the conversation.
Time to create page: 0.151 seconds