Simulate M998 with a LinuxCNC Macro
Thomas
Please Log in or Create an account to join the conversation.
I thought Tormac used Linuxcnc, their owner is very active in it.
No need for 'macros', you can specify the tool change position.
You can even specify tool change with spindle on.
www.linuxcnc.org/docs/html/config/ini_co...ml#sub:EMCIO-Section
regards
Please Log in or Create an account to join the conversation.
I appreciate the note but that doesn't get what I need. I have hundreds of Mach3 programs that have multiple "M998" commands in them whenever I paused the program and went to the load position. I could replace these with "G54 G00Z-.4" just as easily as anything else but I want a new M198 that accomplished the same thing. Additionally my plan was to integrate a spindle off and coolant off as well as a spindle retract to give me a shortcut for future programs. Besides the G-Code, I want to be able to type M198 in the MDI as I do M998 now in Mach3. I also want a custom button to call M198 that says go to load change position. Basically I want to know how to send G Codes inside a macro and have the machine respond to them.
As far as changing tools with the spindle on, I use a quick change tooling system but without the automatic tool changer or drawbar so unless I had the Flash loosen and tighten the drawbar, I will be stopping and locking the spindle during tool changes for the foreseeable future.
Please Log in or Create an account to join the conversation.
I appreciate the note but that doesn't get what I need. I have hundreds of Mach3 programs that have multiple "M998" commands in them whenever I paused the program and went to the load position. I could replace these with "G54 G00Z-.4" just as easily as anything else but I want a new M198 that accomplished the same thing. Additionally my plan was to integrate a spindle off and coolant off as well as a spindle retract to give me a shortcut for future programs. Besides the G-Code, I want to be able to type M198 in the MDI as I do M998 now in Mach3. I also want a custom button to call M198 that says go to load change position. Basically I want to know how to send G Codes inside a macro and have the machine respond to them.
OK
First you need to be familiar with the generalities of user M codes
www.linuxcnc.org/docs/devel/html/gcode/m...tml#sec:M100-to-M199
They are not macros and don't use a cutdown version of some visual basic c**p, they are system commands and as such can do anything from invoke bash, start a compiled binary , run a python script etc.
The MDI commands you want are here
www.linuxcnc.org/docs/devel/html/gui/halui.html
Create an entry in your ini file under the [HALUI] header
MDI_COMMAND = G53 G01 Z-4
Then create a file called M198, make it executable (chmod 755 M198) and put in the folder pointed to by the entry PROGRAM_PREFIX = in your ini file
# !/bin/bash
halcmd setp halui.mdi-command-00 1
exit 0
You can thereafter either invoke M198 from the MDI line or in a file, or you can link the halui.mdi-command-00 pin to the output of a pyVCP push button to do the same
regards
EDIT:
If this is a command you will be repeating, you will also need to reset the halui.mdi-command-00 pin in the M198 script.
Otherwise the pin will remain at 1 and then not respond the next time you use it, the command is only activated on a change from 0 to 1
Easiest way is to set to 0 first then set to 1
# !/bin/bash
halcmd setp halui.mdi-command-00 0;
sleep 1;
halcmd setp halui.mdi-command-00 1
exit 0
The commas tell bash to wait for completion before the next line and the sleep 1 forces a pause to ensure the pin is changed to 0 before it is changed to 1 again
Please Log in or Create an account to join the conversation.
They are not macros and don't use a cutdown version of some visual basic c**p, they are system commands and as such can do anything from invoke bash, start a compiled binary , run a python script etc.
Mach3 macros do have the significant advantage of being able to run G-code, though.
Having a macro set a HAL pin to suggest to LinuxCNC that it should run some code doesn't seem like the most intuitive way to do things, but that does seem to be the system we have.
I also have a feeling that MDI_COMMANDS are only acted on if the machine is not in auto mode.
If you use Master or 2.6 (both available from the Buildbot) then you can create your own G and M-codes, including M998
www.linuxcnc.org/docs/devel/html/remap/structure.html
All you would need to do is insert a remap command in the INI file:
[RS274NGC]REMAP = M998 ngc=M998 modalgroup=5
o<m998> sub
G53 G0 Z0
o<m998> endsub
m2
I just tried it, and it worked
Please Log in or Create an account to join the conversation.
I also have a feeling that MDI_COMMANDS are only acted on if the machine is not in auto mode.
You are right, I had overlooked that.
I am all for people being able to do things how they wish, but feel that this whole concept is flawed.
To my mind if you switch to a new controller you should embrace the new features it offers.
Perpetuating a bodge that was necessary in mach, because it had no proper way to set toolchange position, in the name of familiarity, seems the wrong move.
The 'existing code already using it' argument, could be nullified in seconds using sed or similar, to comment out or alter those lines in bulk.
From what I have seen of the Tormach tool change system, it should provide very good repeatable tool changes, so why wouldn't you want to use its full potential, set up the tool table properly and use industry standard toolchanges, in a pre-defined position?
Just my opinion, you will have seen that if nothing else Linuxcnc is very flexible and there are always several ways to skin the cat
regards
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
- Posts: 5007
- Thank you received: 1441
linuxcnc.org/index.php/english/forum/10-...-script?limitstart=0
Please Log in or Create an account to join the conversation.