Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: dcattena on September 20, 2012, 09:47:47 PM

Title: VB Script from g-code problem
Post by: dcattena on September 20, 2012, 09:47:47 PM
Hi, I'm relatively new to the Mach 3 software and its features. I've been looking around trying to run some scripts from a .nc g-code file. In the script editor I have some code to activate the reset button eg: DoOEMButton(1021)
This code works fine via the script editor. I saved the file as M6.m1s and then within my g-code :

G00 X10 Y10
M6

I was expecting it to stop and the reset button trips. All the program does is continue over the M6 finish the rest of the g-code.
Could anyone tell me what I'm doing wrong with the script? It would be much appreciated.

Thanks in advance
Title: Re: VB Script from g-code problem
Post by: ger21 on September 20, 2012, 09:55:23 PM
I'm not sure that naming the file M6.m1s will work.
First, make sure you have Mach3 configured correctly. In General Config, there are 3 different options for M6.
1) Ignore them.
2) Stop Spindle, Wait for Cycle Start
3) Auto Tool Change.

If you have it set to Ignore them, then you'll see what you're seeing.

As for the file name. Mach3 uses two M6 macros, named M6Start.m1s and M6End.M1s
When you choose "Stop Spindle, Wait for Cycle Start", Mach3 will first run M6Start, then it will wait for the user, and after pressing Cycle Start, Mach3 will run the M6End macro.

If you use the ATC option, Mach3 runs the M6Start only.
Title: Re: VB Script from g-code problem
Post by: dcattena on September 20, 2012, 09:57:50 PM
Thanks for your reply. I should change my filenames. Its just a empty script file with DoOEMButton(1021) inside. Even if i save it as RESET.m1s and call RESET in the g-code it still errors out.
Title: Re: VB Script from g-code problem
Post by: ger21 on September 20, 2012, 09:59:59 PM
First you said Mach3 ignored it, now you say there's an error?
Title: Re: VB Script from g-code problem
Post by: dcattena on September 20, 2012, 10:01:33 PM
Sorry i meant when M6 was ignored which is the name of the macro i made not anyhting inbuilt. I renamed the macro to RESET.m1s and i tried calling that

eg:

G00 X0.000 Y0.000 Z10.00
G00 Z10.00
RESET

I get "unknown word starting with eLine 2"
Title: Re: VB Script from g-code problem
Post by: ger21 on September 20, 2012, 10:45:18 PM
You can't call a macro like that. It has to be an M code, like M555 (M555.m1s) or M23 (M23.m1s)
Title: Re: VB Script from g-code problem
Post by: Hood on September 21, 2012, 02:55:39 AM
M codes under 100 are for Machs internal use, although often they will work if being named under 100 they may conflict or not run correctly and you are advised not to use them for custom macros, you should use 101 and above.

Hood
Title: Re: VB Script from g-code problem
Post by: dcattena on September 23, 2012, 05:42:31 PM
Ive named the file above M100. But i still get the same effect. I run my g-code then when it gets up to M110, it will just skip over it and continue the program. Running M110 within the script editor presses the reset button like it should but when its called after a few steps in the g-code it just skips over.
Title: Re: VB Script from g-code problem
Post by: Hood on September 23, 2012, 05:47:41 PM
Put a
MsgBox ("Its being called")

after your code and see if it pops up the message box.
If not then I am thinking you have saved the macro to the wrong folder.
Hood
Title: Re: VB Script from g-code problem
Post by: dcattena on September 23, 2012, 05:50:04 PM
Wierd....mach3 doesnt understand the MsgBox command it just says unknown word starting with sLine 3. Which is the msg box command line.
Title: Re: VB Script from g-code problem
Post by: dcattena on September 23, 2012, 05:50:50 PM
Sorry in my code. Ill do that now sorry its very early
Title: Re: VB Script from g-code problem
Post by: dcattena on September 23, 2012, 05:52:21 PM
It runs now and still no msgbox. Ive saved the macro under C:\Mach3\macros\MachStdMill\Mill which is the current screenset im using
Title: Re: VB Script from g-code problem
Post by: Hood on September 23, 2012, 05:54:45 PM
It will depend what the profile is called, If that is the profile name you see in Mach then that is the correct location.
Not sure what you are meaning though, are you saying its doing as you want now?
Hood
Title: Re: VB Script from g-code problem
Post by: dcattena on September 23, 2012, 05:55:36 PM
Ok ive moved it to a few folders now. What it does now is it just pauses on the M-code call and sits there. No message box nothing
Title: Re: VB Script from g-code problem
Post by: ger21 on September 23, 2012, 05:58:37 PM
Try it without the (),

Msgbox "Its being called"
Title: Re: VB Script from g-code problem
Post by: Hood on September 23, 2012, 06:00:01 PM
Ok just noticed its the reset, maybe it will not throw the message box if its after a reset, not sure, try with the message box before.
To see which folder you are needing to put it in right click  the shortcut you use to launch Mach abd look at its  properties and see what its target is.

Hood
Title: Re: VB Script from g-code problem
Post by: dcattena on September 23, 2012, 06:01:38 PM
Does the m-code file go right into the root directory or does it go into one of the macro folders? ive got it in a few places already.
Title: Re: VB Script from g-code problem
Post by: Hood on September 23, 2012, 06:02:37 PM
Ok just tried and it works fine here so I think it may either be the wrong folder or could well be something to do with MSM as its not a standard screenset so it may be screwing with it.
Hood
Title: Re: VB Script from g-code problem
Post by: dcattena on September 23, 2012, 06:03:53 PM
Ill try load a basic mach screen set and ill save the macro into the macros, macros/mach3mill
Title: Re: VB Script from g-code problem
Post by: Hood on September 23, 2012, 06:04:00 PM
It goes into the macro folder of the profile you are using so if for example the profile you are using is dcattena the location would be
C:\Mach3\Macros\dcattena

Hood
Title: Re: VB Script from g-code problem
Post by: dcattena on September 23, 2012, 06:08:20 PM
Still does nothing. If it seems to work fine on yours and its just as simple as writing M110 in the g-code i might re-install mach 3 just to get it all fresh
Title: Re: VB Script from g-code problem
Post by: Hood on September 23, 2012, 06:09:44 PM
I just tried from MDI line but will try from code as well as I cant see that being a problem.
Hood
Title: Re: VB Script from g-code problem
Post by: Hood on September 23, 2012, 06:11:58 PM
Yes works fine from code as well.
Hood
Title: Re: VB Script from g-code problem
Post by: dcattena on September 23, 2012, 06:15:41 PM
Everything works now i just did a huge refresh install. I maybe had some broken files here and there. Thanks for all your help
Title: Re: VB Script from g-code problem
Post by: Hood on September 23, 2012, 06:16:24 PM
No probs :)
Hood