How to make M1** execute Gcode

More
4 years 3 months ago #248699 by my1987toyota
How to make M1** execute Gcode was created by my1987toyota
So while I am recovering from my mountain bike accident [url] forum.linuxcnc.org/51-ot-posts/46365-wel...oing-to-leave-a-mark [/url]
I decided to work on the pick and place project again . Right now I am trying to figure out how to use M172 with a P number to facilitate
moving the placing head to a specific feeder location instead of manually adding that location in my G-codes.. I am still very lost as far as
bash scripting or programming in general. I have been trying to remedy that but sometimes I think it's hopeless. The code below is what I
have so far and obviously it doesn't work. Any idea's?
Code:
#!/bin/bash P=${1%.*} case $P in         1)          linuxcnc.command()          self.execute(G0 X1.0 Y1.0);;          2)          linuxcnc.command()          self.execute(G0 X2.0 Y2.0);; esac exit 0

Please Log in or Create an account to join the conversation.

More
4 years 3 months ago #248704 by andypugh
Replied by andypugh on topic How to make M1** execute Gcode
I don't know much bash, but I think that you are mixing bash and Python.

Does it _have_ to be M172? If you could use one of the remappable codes (M200-M999 or an unused one in the < M100) then you can use the canonical motion commands and have the motion added to the queue, so that it is blended etc.
Code:
#! /usr/bin/env python3 import linuxcnc import sys P = int(float(sys.argv[1])) if P < 0:     print("error, a P parameter must be passed")      c = linuxcnc.command() if P == 1:     c.mdi("G0 X10") if P == 2:     c.mdi("G0 X20")

(Works for me) 
 
The following user(s) said Thank You: my1987toyota

Please Log in or Create an account to join the conversation.

More
4 years 3 months ago #248705 by andypugh
Replied by andypugh on topic How to make M1** execute Gcode
But... I tried this inside a programme and it does _not_ work as MDI is not possible in Auto mode.

Back to the drawing board...
The following user(s) said Thank You: my1987toyota

Please Log in or Create an account to join the conversation.

More
4 years 3 months ago #248707 by andypugh
Replied by andypugh on topic How to make M1** execute Gcode
Drop the attached files in the same folder as your config and make them executable (probably necessary, though I am not 100% sure)

Then add the following to the [RS274NGC] section:
Code:
REMAP = M201 python=M172 argspec=P [PYTHON] TOPLEVEL=toplevel.py PATH_PREPEND = ./

(ie, add a [PYTHON] section after the [RS274_NGC] section.)

This will currently give you a new "M201" command that takes a P parameter and moves the axes.

It doesn't seem to be possible to map it to M172, though.

 
Attachments:
The following user(s) said Thank You: my1987toyota

Please Log in or Create an account to join the conversation.

More
4 years 3 months ago - 4 years 3 months ago #248720 by my1987toyota
Replied by my1987toyota on topic How to make M1** execute Gcode
Thank you andypugh I will give that a try. The only reason I specified M172 was because that was the M code I was using. I used M1** codes with a
P number for firing the feeder advancers. I don't know enough to determin when a pure bin/bash command should be used or a bin/python instead.

 
Last edit: 4 years 3 months ago by my1987toyota. Reason: correcting spelling

Please Log in or Create an account to join the conversation.

More
4 years 3 months ago - 4 years 3 months ago #248734 by my1987toyota
Replied by my1987toyota on topic How to make M1** execute Gcode
Hi andy the code I need to add to the [RS274NGC] section: that's the ini. file [RS274NGC] section: correct? Or is it a file elsewhere in the system?
Last edit: 4 years 3 months ago by my1987toyota. Reason: changing wording

Please Log in or Create an account to join the conversation.

Time to create page: 0.379 seconds
Powered by Kunena Forum