How to make M1** execute Gcode
- my1987toyota
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 814
- Thank you received: 331
30 Jul 2022 22:28 #248699
by my1987toyota
How to make M1** execute Gcode was created by my1987toyota
So while I am recovering from my mountain bike accident
forum.linuxcnc.org/51-ot-posts/46365-wel...oing-to-leave-a-mark
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?
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?
#!/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.
31 Jul 2022 00:06 #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.
(Works for me)
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.
#! /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.
31 Jul 2022 00:10 #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...
Back to the drawing board...
The following user(s) said Thank You: my1987toyota
Please Log in or Create an account to join the conversation.
31 Jul 2022 00:57 #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:
(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.
Then add the following to the [RS274NGC] section:
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.
The following user(s) said Thank You: my1987toyota
Please Log in or Create an account to join the conversation.
- my1987toyota
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 814
- Thank you received: 331
31 Jul 2022 11:36 - 31 Jul 2022 15:59 #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.
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: 31 Jul 2022 15:59 by my1987toyota. Reason: correcting spelling
Please Log in or Create an account to join the conversation.
- my1987toyota
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 814
- Thank you received: 331
31 Jul 2022 14:58 - 31 Jul 2022 15:15 #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: 31 Jul 2022 15:15 by my1987toyota. Reason: changing wording
Please Log in or Create an account to join the conversation.
- my1987toyota
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 814
- Thank you received: 331
31 Jul 2022 15:42 #248737
by my1987toyota
Replied by my1987toyota on topic How to make M1** execute Gcode
I ran into this problem below is the crash report
Error report created by /usr/lib/tcltk/linuxcnc/show_errors.tcl:
Print file information:
RUN_IN_PLACE=no
LINUXCNC_DIR=
LINUXCNC_BIN_DIR=/usr/bin
LINUXCNC_TCL_DIR=/usr/lib/tcltk/linuxcnc
LINUXCNC_SCRIPT_DIR=
LINUXCNC_RTLIB_DIR=/usr/lib/linuxcnc/modules
LINUXCNC_CONFIG_DIR=
LINUXCNC_LANG_DIR=/usr/lib/tcltk/linuxcnc/msgs
INIVAR=inivar
HALCMD=halcmd
LINUXCNC_EMCSH=/usr/bin/wish8.6
LINUXCNC - 2.8.0
Machine configuration directory is '/home/cnc002/linuxcnc/configs/simple_pnp'
Machine configuration file is 'simple_pnp.ini'
INIFILE=/home/cnc002/linuxcnc/configs/simple_pnp/simple_pnp.ini
VERSION=1.1
PARAMETER_FILE=linuxcnc.var
TASK=milltask
HALUI=halui
DISPLAY=axis
COORDINATES=XYZC
KINEMATICS=trivkins coordinates=XYZC
Starting LinuxCNC...
Starting LinuxCNC server program: linuxcncsvr
Loading Real Time OS, RTAPI, and HAL_LIB modules
Starting LinuxCNC IO program: io
Starting HAL User Interface program: halui
Found file(REL): ./simple_pnp.hal
Found file(REL): ./custom.hal
Starting TASK program: milltask
Starting DISPLAY program: axis
emc/task/emctask.cc 411: interp_error: Parameter file name is missing
Parameter file name is missing
emc/task/emctaskmain.cc 3087: can't initialize interpreter
waiting for s.joints<0>, s.kinematics_type<0>
waiting for s.joints<0>, s.kinematics_type<0>
waiting for s.joints<0>, s.kinematics_type<0>
waiting for s.joints<0>, s.kinematics_type<0>
waiting for s.joints<0>, s.kinematics_type<0>
waiting for s.joints<0>, s.kinematics_type<0>
waiting for s.joints<0>, s.kinematics_type<0>
waiting for s.joints<0>, s.kinematics_type<0>
waiting for s.joints<0>, s.kinematics_type<0>
Shutting down and cleaning up LinuxCNC...
Running HAL shutdown script
hm2: loading Mesa HostMot2 driver version 0.15
hm2_eth: loading Mesa AnyIO HostMot2 ethernet driver version 0.2
hm2_eth: 10.10.10.10: Hardware address: 00:60:1b:10:4b:df
hm2_eth: discovered 7I76E-16
hm2/hm2_7i76e.0: Smart Serial Firmware Version 43
Board hm2_7i76e.0.7i76.0.0 Hardware Mode 0 = standard
Board hm2_7i76e.0.7i76.0.0 Software Mode 0 = io_spin
Board hm2_7i76e.0.7i76.0.0 Software Mode 1 = io_ana_spin
Board hm2_7i76e.0.7i76.0.0 Software Mode 2 = io_enc_ana_spin_fv
Board hm2_7i76e.0.7i71.0.1 Hardware Mode 0 = standard
Board hm2_7i76e.0.7i71.0.1 Software Mode 0 = output_only
Board hm2_7i76e.0.7i71.0.1 Software Mode 1 = output_fieldvoltage
hm2/hm2_7i76e.0: 51 I/O Pins used:
hm2/hm2_7i76e.0: IO Pin 000 (P1-01): StepGen #0, pin Direction (Output)
hm2/hm2_7i76e.0: IO Pin 001 (P1-14): StepGen #0, pin Step (Output)
hm2/hm2_7i76e.0: IO Pin 002 (P1-02): StepGen #1, pin Direction (Output)
hm2/hm2_7i76e.0: IO Pin 003 (P1-15): StepGen #1, pin Step (Output)
hm2/hm2_7i76e.0: IO Pin 004 (P1-03): StepGen #2, pin Direction (Output)
hm2/hm2_7i76e.0: IO Pin 005 (P1-16): StepGen #2, pin Step (Output)
hm2/hm2_7i76e.0: IO Pin 006 (P1-04): StepGen #3, pin Direction (Output)
hm2/hm2_7i76e.0: IO Pin 007 (P1-17): StepGen #3, pin Step (Output)
hm2/hm2_7i76e.0: IO Pin 008 (P1-05): StepGen #4, pin Direction (Output)
hm2/hm2_7i76e.0: IO Pin 009 (P1-06): StepGen #4, pin Step (Output)
hm2/hm2_7i76e.0: IO Pin 010 (P1-07): Smart Serial Interface #0, pin TxData0 (Output)
hm2/hm2_7i76e.0: IO Pin 011 (P1-08): Smart Serial Interface #0, pin RxData0 (Input)
hm2/hm2_7i76e.0: IO Pin 012 (P1-09): Smart Serial Interface #0, pin TxData1 (Output)
hm2/hm2_7i76e.0: IO Pin 013 (P1-10): Smart Serial Interface #0, pin RxData1 (Input)
hm2/hm2_7i76e.0: IO Pin 014 (P1-11): Encoder #0, pin Index (Input)
hm2/hm2_7i76e.0: IO Pin 015 (P1-12): Encoder #0, pin B (Input)
hm2/hm2_7i76e.0: IO Pin 016 (P1-13): Encoder #0, pin A (Input)
hm2/hm2_7i76e.0: IO Pin 017 (P2-01): IOPort
hm2/hm2_7i76e.0: IO Pin 018 (P2-14): IOPort
hm2/hm2_7i76e.0: IO Pin 019 (P2-02): IOPort
hm2/hm2_7i76e.0: IO Pin 020 (P2-15): IOPort
hm2/hm2_7i76e.0: IO Pin 021 (P2-03): IOPort
hm2/hm2_7i76e.0: IO Pin 022 (P2-16): IOPort
hm2/hm2_7i76e.0: IO Pin 023 (P2-04): IOPort
hm2/hm2_7i76e.0: IO Pin 024 (P2-17): IOPort
hm2/hm2_7i76e.0: IO Pin 025 (P2-05): IOPort
hm2/hm2_7i76e.0: IO Pin 026 (P2-06): IOPort
hm2/hm2_7i76e.0: IO Pin 027 (P2-07): IOPort
hm2/hm2_7i76e.0: IO Pin 028 (P2-08): IOPort
hm2/hm2_7i76e.0: IO Pin 029 (P2-09): IOPort
hm2/hm2_7i76e.0: IO Pin 030 (P2-10): IOPort
hm2/hm2_7i76e.0: IO Pin 031 (P2-11): IOPort
hm2/hm2_7i76e.0: IO Pin 032 (P2-12): IOPort
hm2/hm2_7i76e.0: IO Pin 033 (P2-13): IOPort
hm2/hm2_7i76e.0: IO Pin 034 (P3-01): IOPort
hm2/hm2_7i76e.0: IO Pin 035 (P3-14): IOPort
hm2/hm2_7i76e.0: IO Pin 036 (P3-02): IOPort
hm2/hm2_7i76e.0: IO Pin 037 (P3-15): IOPort
hm2/hm2_7i76e.0: IO Pin 038 (P3-03): IOPort
hm2/hm2_7i76e.0: IO Pin 039 (P3-16): IOPort
hm2/hm2_7i76e.0: IO Pin 040 (P3-04): IOPort
hm2/hm2_7i76e.0: IO Pin 041 (P3-17): IOPort
hm2/hm2_7i76e.0: IO Pin 042 (P3-05): IOPort
hm2/hm2_7i76e.0: IO Pin 043 (P3-06): IOPort
hm2/hm2_7i76e.0: IO Pin 044 (P3-07): IOPort
hm2/hm2_7i76e.0: IO Pin 045 (P3-08): IOPort
hm2/hm2_7i76e.0: IO Pin 046 (P3-09): IOPort
hm2/hm2_7i76e.0: IO Pin 047 (P3-10): IOPort
hm2/hm2_7i76e.0: IO Pin 048 (P3-11): IOPort
hm2/hm2_7i76e.0: IO Pin 049 (P3-12): IOPort
hm2/hm2_7i76e.0: IO Pin 050 (P3-13): IOPort
hm2/hm2_7i76e.0: registered
creating ladder-state
hm2_eth: HostMot2 ethernet driver unloaded
hm2: unloading
Removing HAL_LIB, RTAPI, and Real Time OS modules
Removing NML shared memory segments
Debug file information:
Note: Using POSIX realtime
initialize: module '/home/cnc002/linuxcnc/configs/simple_pnp/toplevel.py' init failed:
Traceback (most recent call last):
File "/home/cnc002/linuxcnc/configs/simple_pnp/toplevel.py", line 1, in <module>
import remap
ImportError: No module named remap
Interp ctor: cant instantiate Python plugin
initialize: module '/home/cnc002/linuxcnc/configs/simple_pnp/toplevel.py' init failed:
Traceback (most recent call last):
File "/home/cnc002/linuxcnc/configs/simple_pnp/toplevel.py", line 1, in <module>
import remap
ImportError: No module named remap
Python plugin configure() failed, status = -11
Python plugin required for python=, but not available: 50:REMAP = M201 python=M172 argspec=p
note: MAXV max: 1.000 units/sec 60.000 units/min
note: LJOG max: 1.000 units/sec 60.000 units/min
note: LJOG default: 0.250 units/sec 15.000 units/min
note: AJOG max: 180.000 units/sec 10800.000 units/min
note: AJOG default: 12.000 units/sec 720.000 units/min
A configuration error is preventing LinuxCNC from starting.
More information may be available when running from a terminal.
2649
Stopping realtime threads
Unloading hal components
Note: Using POSIX realtime
-----------------------------------------------------------------------
Info report created by linuxcnc_info:
The file: /tmp/linuxcnc_info.txt
can be posted to a forum or a web site like:
http://pastebin.com
in order to provide information about the linuxcnc
system and configuration.
Date: Sun Jul 31 11:29:04 EDT 2022
UTC Date: Sun Jul 31 15:29:04 UTC 2022
this program: /usr/bin/linuxcnc_info
uptime: 11:29:04 up 47 min, 1 user, load average: 0.18, 0.25, 0.16
lsb_release -sa: LinuxMint Linux Mint 19.3 Tricia 19.3 tricia
which linuxcnc: /usr/bin/linuxcnc
pwd: /home/cnc002/linuxcnc/configs/simple_pnp
USER: cnc002
LOGNAME: cnc002
HOME: /home/cnc002
EDITOR:
VISUAL:
LANGUAGE: en_US
TERM: dumb
COLORTERM:
DISPLAY: :0.0
DESKTOP: xfce
display size: 1360x768 pixels (359x203 millimeters)
PATH: /usr/bin:/home/cnc002/linuxcnc/configs/simple_pnp/bin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
uname items:
nodename -n: cnc002
kernel-name -s: Linux
kernel-vers -v: #1 SMP PREEMPT RT Mon Sep 14 12:23:06 AEST 2020
machine -m: x86_64
processor -p: x86_64
platform -i: x86_64
oper system -o: GNU/Linux
/proc items:
cmdline: efi=runtime BOOT_IMAGE=/boot/vmlinuz-4.19.106-rt46-lcnc root=UUID=d96b1cf0-96f3-43bb-a32d-3fa54eb2b584 ro quiet splash vt.handoff=1
model name: Intel(R) Core(TM) i5-4590T CPU @ 2.00GHz
cores: 4
cpu MHz: 1736.177
parport:
serial:
Versions:
gcc: gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
python: Python 2.7.17
git: not_in_PATH
git commit: NA
tcl: 8.6
tk: 8.6
glade: not_in_PATH
glade-gtk2: not_in_PATH
linuxcnc_var all:
LINUXCNCVERSION: 2.8.0
LINUXCNC_AUX_GLADEVCP: /usr/share/linuxcnc/aux_gladevcp
LINUXCNC_AUX_EXAMPLES: /usr/share/linuxcnc/aux_examples
REALTIME: /etc/init.d/realtime
RTS: uspace
HALLIB_DIR: /usr/share/linuxcnc/hallib
dpkg -l '*linuxcnc*':
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-===================-============-============-=====================================================================
un linuxcnc <none> <none> (no description available)
un linuxcnc-dev <none> <none> (no description available)
un linuxcnc-doc <none> <none> (no description available)
ii linuxcnc-doc-en 1:2.8.0 all motion controller for CNC machines and robots (English documentation)
un linuxcnc-sim <none> <none> (no description available)
un linuxcnc-sim-dev <none> <none> (no description available)
ii linuxcnc-uspace 1:2.8.0 amd64 motion controller for CNC machines and robots
ii linuxcnc-uspace-dev 1:2.8.0 amd64 PC based motion controller for real-time Linux
Attachments:
Please Log in or Create an account to join the conversation.
31 Jul 2022 18:43 #248743
by andypugh
Are the two .py files in the same directory as the ini file and executable?
Replied by andypugh on topic How to make M1** execute Gcode
ImportError: No module named remap
Are the two .py files in the same directory as the ini file and executable?
The following user(s) said Thank You: my1987toyota
Please Log in or Create an account to join the conversation.
- my1987toyota
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 814
- Thank you received: 331
31 Jul 2022 20:02 #248748
by my1987toyota
Replied by my1987toyota on topic How to make M1** execute Gcode
both .py files are in the same directory as the ini. file and I did mark them executable . I may have spotted the problem. the remap file has the name remap_2022_7_30.py .
Should I remove the Date portion from the name?
Should I remove the Date portion from the name?
Please Log in or Create an account to join the conversation.
- my1987toyota
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 814
- Thank you received: 331
31 Jul 2022 20:07 - 02 Aug 2022 12:37 #248749
by my1987toyota
Replied by my1987toyota on topic How to make M1** execute Gcode
short answer is yes. I have had that problem before with the MPG .hal file I wrote and posted . for some inexplicable reason the forum will include the date in some file names.
oh and yes it does work Thank you again for the help Andy.
Now I need to expand on that . Looks like I have a ton more reading on how to manipulate and bend python to my will.
Did you ever get a chance to get your PnP fired up and running?
oh and yes it does work Thank you again for the help Andy.
Now I need to expand on that . Looks like I have a ton more reading on how to manipulate and bend python to my will.
Did you ever get a chance to get your PnP fired up and running?
Last edit: 02 Aug 2022 12:37 by my1987toyota. Reason: telling andypugh thank you for the help
Please Log in or Create an account to join the conversation.
Time to create page: 0.088 seconds