Simulate M998 with a LinuxCNC Macro

More
04 Jul 2014 08:29 #48423 by anidatech
My Windows 98 computer running Mach3 gave up the ghost today after many years of service on my Tormach. Thought I would try LinuxCNC and I am blown away. LinuxCNC seems to be a major upgrade over Mach3. The one problem I have is a lot of my existing Mach3 programs use M998 as a built in function that raises the Z axis to the automatic load tool change location (I use a quick change system but I don't have an automatic tool changer). LinuxCNC only goes to M199 so to speed up program conversions, I was going to write a very simple macro M198 (instead of M998) that just moves the spindle to -4 inches below home (The G code works fine "G53 G00Z-4"). I think I tried all the obvious commands in a macro - I can get the macros to run but I can't get the spindle to move inside the macro. Any help would be appreciated.
Thomas

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

More
04 Jul 2014 13:22 - 04 Jul 2014 17:40 #48424 by ArcEye
Hi

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
Last edit: 04 Jul 2014 17:40 by ArcEye.

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

More
04 Jul 2014 20:28 #48428 by anidatech
Tormach has had a LinuxCNC (EMC2) option for years but they don't provide support for Linux. However, this year they started letting you have the option to buy a LinuxCNC controller from them and those are being supported. Coincidentally, the new Tormach Lathe uses Linux as a controller (I saw a demo in January and if memory serves it is a custom Axis screen with the lathe display turned on).

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.

More
04 Jul 2014 21:49 - 04 Jul 2014 22:13 #48430 by ArcEye

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
Last edit: 04 Jul 2014 22:13 by ArcEye.

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

More
06 Jul 2014 17:51 #48464 by andypugh

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
and then create a file called m998.ngc (lower case m) in the subroutine path.
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.

More
07 Jul 2014 13:30 #48470 by ArcEye
Andy Pugh wrote:

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.

More
08 Jul 2014 09:42 #48517 by Todd Zuercher
It probably would not be that hard to set up a script (sed or python what ever your more comfortable writhing) that could modify your old code files to be what would be needed for proper Linuxcnc code on the fly, so that you would not even have to remake or adjust your old files. If you don't think your able to write such a script, Just ask for help. I was in a similar situation and got help here.
linuxcnc.org/index.php/english/forum/10-...-script?limitstart=0

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

Time to create page: 0.118 seconds
Powered by Kunena Forum