User Defined M codes
24 Nov 2018 19:08 - 24 Nov 2018 19:24 #121303
by PCW
It means you cannot run halcmd unless PathPilot is running
Also if "admin halshow" works that's a convenient way to poke around at hal pins/parameters
Replied by PCW on topic User Defined M codes
Not sure what that means while running PP.
It means you cannot run halcmd unless PathPilot is running
Also if "admin halshow" works that's a convenient way to poke around at hal pins/parameters
Last edit: 24 Nov 2018 19:24 by PCW.
Please Log in or Create an account to join the conversation.
25 Nov 2018 14:17 #121320
by rds626
Replied by rds626 on topic User Defined M codes
So I restored my HD from a previous backup & “halcmd” now works within my M101 file when called from the PP MDI using M101.
I still don't know how I screwed that up. Anyway I back up all my computers to a FreeNAS server I have running using CloneZilla – really convenient.
Creating a M101 file containing:Results in:And then:Results in:So I think I'm getting closer. Any suggestions appreciated.
Quote: "Also if "admin halshow" works that's a convenient way to poke around at hal pins/parameters"
Does not work - complains about missing file "halshow.tcl"
I still don't know how I screwed that up. Anyway I back up all my computers to a FreeNAS server I have running using CloneZilla – really convenient.
Creating a M101 file containing:
#!/bin/bash
#halcmd show all
halcmd setp hm2_7i92.0.gpio.017.out true
exit 0
issuing MDI command: M101
<commandline>:0: parameter or pin 'hm2_7i92.0.gpio.017.out' not found
#!/bin/bash
#halcmd show all
halcmd setp hm2_7i92.0.gpio.001.out true
exit 0
issuing MDI command: M101
<commandline>:0: pin 'hm2_7i92.0.gpio.001.out' is connected to a signal
Quote: "Also if "admin halshow" works that's a convenient way to poke around at hal pins/parameters"
Does not work - complains about missing file "halshow.tcl"
Please Log in or Create an account to join the conversation.
25 Nov 2018 14:29 #121321
by PCW
Replied by PCW on topic User Defined M codes
The fact that you cannot set gpio 0017 means that its been claimed by a special function. The fix for this is to edit your hal file to change the number or PWM or stepgen instances so there are none enabled on P1
Please Log in or Create an account to join the conversation.
25 Nov 2018 16:58 #121324
by rds626
Replied by rds626 on topic User Defined M codes
OK, I finally wiggled gpio 018 with my user defined M code.
I don't know why Tormach programmed the unused connector with special functions that used gpio 017, but gpio 018 was free.
So with this file "~/tmc/configs/tormach_mill/nc_subs/M101" containing:Note: this file must be set executable.
I can enter M101 in the PP MDI box & watch pin 7i92-P1-2 (IDC ) go high.
OK, so I finally get it now.
So now I've got 17 GPIO pins that I can control with M1xx user-defined macros
Thanks for the feedback ...
I don't know why Tormach programmed the unused connector with special functions that used gpio 017, but gpio 018 was free.
So with this file "~/tmc/configs/tormach_mill/nc_subs/M101" containing:
#!/bin/bash
halcmd setp hm2_7i92.0.gpio.018.is_output true
halcmd setp hm2_7i92.0.gpio.018.out true
exit 0
I can enter M101 in the PP MDI box & watch pin 7i92-P1-2 (IDC ) go high.
OK, so I finally get it now.
So now I've got 17 GPIO pins that I can control with M1xx user-defined macros
Thanks for the feedback ...
Please Log in or Create an account to join the conversation.
25 Nov 2018 17:23 #121325
by PCW
Replied by PCW on topic User Defined M codes
Its standard for hostmot2 configs to have extra hardware
The hal file is where this should be addressed, _not_ the firmware
The hal file is where this should be addressed, _not_ the firmware
Please Log in or Create an account to join the conversation.
01 Dec 2018 00:50 #121663
by smgvbest
Replied by smgvbest on topic User Defined M codes
Just a thought that you could also look at remap.py and write the function in python to work with the pins directly.
in the ini you have something like this
REMAP= M64 modalgroup=5 argspec=P py=digital_io_output_on_immediate_M64
then in remap.py
def digital_io_output_on_immediate_M64 (self,**words):
emccanon.SET_AUX_OUTPUT_BIT(int(words))
return INTERP_OK
thats the tormach one as an example
a little digging and you could use the remapping tormach provides
in the ini you have something like this
REMAP= M64 modalgroup=5 argspec=P py=digital_io_output_on_immediate_M64
then in remap.py
def digital_io_output_on_immediate_M64 (self,**words):
emccanon.SET_AUX_OUTPUT_BIT(int(words))
return INTERP_OK
thats the tormach one as an example
a little digging and you could use the remapping tormach provides
Please Log in or Create an account to join the conversation.
- snowgoer540
- Offline
- Moderator
Less
More
- Posts: 2386
- Thank you received: 779
25 Sep 2023 00:44 #281570
by snowgoer540
I know I am digging up an old post, but I ran into this same problem this evening and thought I would share the solution I came up with.
This has to do with how Tormach sets up their environment variables/pathing.
halcmd and mesaflash are both treated differently in that mesaflash will run from any directory (with ~/tmc/bin/mesaflash (you may have to use sudo to actually do the flashing), but halcmd needs to be run from the folder it is located in (using either ./halcmd, or ~/tmc/bin/halcmd works, as long as you are in ~/tmc/bin).
To do this via python, you can either use os.chdir() to change the working directory, or you could specify cwd= when using subprocess.Popen().
An example that works (using your command/pin from before):
Replied by snowgoer540 on topic User Defined M codes
For reasons I don't understand I'm unable to run any of the linuxcnc utilities in "~/tmc/bin" such as "halcmd" and or "mesaflash". Simply typing the command returns "command not found" even though it's listed in the directory & is executable. If I type "./haclcmd" then I get "./halcmd: error while loading shared libraries: liblinuxcncini.so.0: cannot open shared object file: No such file or directory" which I don't understand. Is halcmd a program or some kind of script?
I know I am digging up an old post, but I ran into this same problem this evening and thought I would share the solution I came up with.
This has to do with how Tormach sets up their environment variables/pathing.
halcmd and mesaflash are both treated differently in that mesaflash will run from any directory (with ~/tmc/bin/mesaflash (you may have to use sudo to actually do the flashing), but halcmd needs to be run from the folder it is located in (using either ./halcmd, or ~/tmc/bin/halcmd works, as long as you are in ~/tmc/bin).
To do this via python, you can either use os.chdir() to change the working directory, or you could specify cwd= when using subprocess.Popen().
An example that works (using your command/pin from before):
import os
from subprocess import call as CALL
home = os.getenv('HOME')
scriptFolder = os.path.join(home, 'tmc/bin')
halcmd = os.path.join(scriptFolder, 'halcmd')
os.chdir(scriptFolder)
CALL([halcmd, 'setp', 'hm2_7i92.0.gpio.018.out', 'true'])
The following user(s) said Thank You: Aciera
Please Log in or Create an account to join the conversation.
Moderators: cncbasher
Time to create page: 0.122 seconds