Hello Guest it is April 18, 2024, 03:05:46 PM

Author Topic: VB Script triggered by Gcode?  (Read 2958 times)

0 Members and 1 Guest are viewing this topic.

VB Script triggered by Gcode?
« on: January 25, 2016, 05:51:40 PM »
Looking around in here and a lot of posts have to do with automatic tool changing...I do not have this but it got me thinking...can you make a script run when the Gcode gives certain commands, like M6 (tool change)? May be old hat to you guys, but it would be cool on my Ox style CNC router to move to the front of the machine (couple of user DRO positions), and wait for me to change the tool, press a button, move to the next location in the cut, touch off the Z axis, then take off. That would be way cool! I was just looking at my Gcode and I do not see a command to turn of the spindle when the M6 command comes up, but Mach3 turns it off so there must be some "hook" to know that a tool change needs to occur...if there are previous posts that explain this point them out and I will read them...

Thanks
Leslie
Re: VB Script triggered by Gcode?
« Reply #1 on: January 25, 2016, 05:55:17 PM »
I just was thinking and poking around and found the m6 macro, I assume this is where I would put any extra code as I stated above, correct? How does Mach know to run the M6, is it programmed into the Mach3 code? Or, can others be created to look for a vertain GCode command and run a script?

Leslie
Re: VB Script triggered by Gcode?
« Reply #2 on: January 25, 2016, 06:03:25 PM »
Hmmmm...was going to add a simple Code "G0 X0" to the end of M6Start.m1s, and I am not able to save it (even without Mach3 running)

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: VB Script triggered by Gcode?
« Reply #3 on: January 25, 2016, 06:37:48 PM »
You would use teh macro editor to add to teh M6. Now that said you also need to make sure you have Tool changing turned on. It is on teh Gencofig page top left hand side. 

Offline ger21

*
  • *
  •  6,295 6,295
    • View Profile
    • The CNC Woodworker
Re: VB Script triggered by Gcode?
« Reply #4 on: January 25, 2016, 07:26:52 PM »
It's good practice for the g-code to have an M5 to turn off the spindle before an M6, but Mach3 can be configured to do it. You want to set Mach3 to Stop Spindle, Wait for Cycle Start.
What happens when Mach3 sees an M6 in the g-code, is that the M6Start macro is run first, then Mach3 stops for you to change the tool. After you click Cycle Start, Mach3 then runs the M6End macro.

In my 2010 Screenset, the M6 Start moves the spindle to the toolchange position. The M6End zero's the tool to a fixed plate, and then returns the spindle back to where it was before the tool change. The fixed plate location is stored during an auto zero prior to running the g-code.
Gerry

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

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