- Posts: 3410
- Thank you received: 0
What's the easiest way to write and load a simple program?
M100
M101
This is my HAL file for the collet, I use an or2 so I can use both my physical buttons and the M100/M101 to operate the collet.
JT
Please Log in to join the conversation.
Now where did you put them? I think I found the spot, but we're still working on finding out for sure.
There is a file in the linuxcnc/config file called ngcgui_lib. It has a file in it named mfiles. In that mfiles file, there is a single file that has an icon with some gears on it. I don't know enough about how to identify that kind of file, but if it's an executable file, then it would make sense to make those bits of code in that mfiles folder. The code in that file is below:
#!/bin/sh
# Clear axis info notifications
# use in gcode subroutines and/or connect to pushbutton
# M1nn files must exist _before_ starting emc
# in the [DISPLAY]PROGRAM_PREFIX
# or in a dir specified by [RS274NGC]USER_M_PATH
# the pin for axisui.notifications-clear-info is in emc-2.4pre
# using an earlier version will print error to stdout
halcmd setp axisui.notifications-clear-info 1
sleep .100 ;# requires a sleep that does <1
halcmd setp axisui.notifications-clear-info 0
# if a M1nn command fails and its script exits with nonzero status,
# the gcode program exits. So always exit 0, and make sure
# the M1nn command prints a message in order to keep on going.
exit 0
Is that the location of the code with your setup and does the icon with gears mean an executable file? Keep in mind, I only used linux for about a year, mostly in gui and rarely in command line - and that was 18 years ago. So please forgive my ignorance.
Thanks,
Please Log in to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
-
- Posts: 4739
- Thank you received: 2
Attachment not found
Then after you save the M-code file there, you simply right click the file, select "properties" from the pop up menu, then click the "Permissions" tab in the window that pops up, and check the "allow this file to run as a program" check box and click ok.
Attachment not found
Please Log in to join the conversation.
I did have a rough idea of where I should put those files, but making them executable was giving me issues. I was literally in the middle of studying how to do that when your post came up.
Thanks again. This is great!
I'll keep you posted. Making this work is going to be feeding me. If what you offer helps, which I think it will, you're indirectly helping me get fed!
Scot
Please Log in to join the conversation.
I assume that the permissions need to be changed as your info laid out. But even in root, under the gui, there is no "program" section for me to allow it to be running as a program. If it helps, I just made a simple text file and named it M101. Then I tried to change it to a program in root, but it didn't help. Then I renamed the file with an ngc suffix, and tried again. But nothing like what is showing on your screen was there, sans the four drop down boxes.
Any light you can shed on this subject for me will be very helpful.
Thanks,
Scot
Please Log in to join the conversation.
Most Debian based you start the file manager then right click on the file, select Properties and on the Permissions tab is where you will find a checkbox for executable.
JT
Please Log in to join the conversation.
I was thinking that since this folder mfiles had that file and it was what I thought was executable, then the mfiles folder was where I should place it. I need root privileges to put it there.
That being said, looking at your example, it's in your home directory path for you as a user and it's not that deep into the nc_files folder so I'll give it a whirl and try and place it into my nc_files folder in my home/scot/linuxcnc/nc_files path and see what happens.
Thanks again. It's been so long since I used linux and like I've probably said too much, I'm going by fading memory and limited experience.
Scot
Please Log in to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
-
- Posts: 4739
- Thank you received: 2
The file should not have any suffix. (it will not work with a suffix added)
What is the first line or two in your file?
if it does not start with
#!/bin/sh
or
#!/bin/bash
Then the file browser (Thunar) won't recognize it as a shell script and won't give the option of setting it as executable.
(or the same happens if the file name has a file extension.)
Please Log in to join the conversation.
I just opened mouspad in my profile, copied the example text in the body of the file and saved it as M101. Then when I saved it, it came up with the icon with the gears on it, automatically? It didn't do that in root. Strange. I was able to move it into my home/scot/linuxcnc/nc_files folder without a hassle, too. Then I rightclicked on it and checked the permissions and bang! There was the check-box for making it run as a program.
Now all I have to do is to write the proper code to marry it to the PWM board and I'll be in business.
It was all about where I placed it. Placing it in the mfiles folder was only able to be done in root and not necessary.
I should have stuck with linux back a long time ago. But I'm getting the gist by learning the need-to-know stuff.
Thanks again. This was REALLY helpful! I'll keep you posted. It means a bunch.
Scot
Please Log in to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
-
- Posts: 4739
- Thank you received: 2
Scot wrote: Well I guess I had the wrong folder. From what I could see there is a file called M110 in linuxcnc/nc_files/ngcgui_lib/mfiles.
I was thinking that since this folder mfiles had that file and it was what I thought was executable, then the mfiles folder was where I should place it. I need root privileges to put it there.
That being said, looking at your example, it's in your home directory path for you as a user and it's not that deep into the nc_files folder so I'll give it a whirl and try and place it into my nc_files folder in my home/scot/linuxcnc/nc_files path and see what happens.
Thanks again. It's been so long since I used linux and like I've probably said too much, I'm going by fading memory and limited experience.
Scot
That M110 in linuxcnc/nc_files/ngcgui_lib/mfiles is part of an example configuration for demonstration purposes. If you load that demo config, and look at it's INI file it should have an entry in the [RS247NGC] section that points to that directory so that it can use that custom M-code.
Please Log in to join the conversation.
