Hello Guest it is December 21, 2024, 08:57:38 AM

Author Topic: VB Script from g-code problem  (Read 15143 times)

0 Members and 1 Guest are viewing this topic.

VB Script from g-code problem
« 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

Offline ger21

*
  • *
  •  6,295 6,295
    • The CNC Woodworker
Re: VB Script from g-code problem
« Reply #1 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.
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: VB Script from g-code problem
« Reply #2 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.

Offline ger21

*
  • *
  •  6,295 6,295
    • The CNC Woodworker
Re: VB Script from g-code problem
« Reply #3 on: September 20, 2012, 09:59:59 PM »
First you said Mach3 ignored it, now you say there's an error?
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: VB Script from g-code problem
« Reply #4 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"

Offline ger21

*
  • *
  •  6,295 6,295
    • The CNC Woodworker
Re: VB Script from g-code problem
« Reply #5 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)
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
Re: VB Script from g-code problem
« Reply #6 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
Re: VB Script from g-code problem
« Reply #7 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.

Offline Hood

*
  •  25,835 25,835
  • Carnoustie, Scotland
Re: VB Script from g-code problem
« Reply #8 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
Re: VB Script from g-code problem
« Reply #9 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.