Suppose you’ve got a 4th axis that incorporates a disc brake or other mechanism to lock the axis during machining:
One of Steve Simpson’s 4th Axis units set up with an air-activated disc brake…
Cutting on a 4th axis can apply considerable torque if you get too far off-axis and so a brake makes the whole thing a lot more rigid.
Further, let’s suppose you’ve configured some custom m-codes to lock and unlock the axis. It’s be nice to have some automatic way of adding those codes to existing g-code programs whenever the A-axis moves.
For example, you want to be able to change this:
M201 (Unlock the axis)
M202 (Lock the axis)
G-Wizard Editor has a special command that makes it easy to do this kind of thing. The command is called “Monitor”, because it was originally designed to make it easy to add monitoring code to programs for Machine Data Collection (MDC). MDC is not the subject of this post, but just to explain, it is a process whereby the CNC machine sends data back to a central gathering point that collects statistics about what’s happening on the Shop Floor. For example, you might want to monitor all tool changes, when a g-code program starts and stops, and that sort of thing. From that information you’d know how long particular tooling has been used or how much time the CNC machine spends sitting idle versus running part programs.
The Monitor command is part of a general class of G-Wizard Editor commands called “Revisions”. Think of an Editor revising a document. That’s what Revisions do–they revise g-code. What the Monitor Revision does is to search for particular words and then add a specific string either before or after the word. Getting back to our example, here’s how you’d set up the monitor command to make the change described:
Adding unlock (M201) and lock (M202) commands around use of the A-axis for a 4th axis…
As you can see, it’s pretty easy to set up the Monitor Revision. Referring to the screen shot, Monitor searches for any use of the “A” word, and the first line adds “M201 (Unlock 4th)” on a new line before the line containing the A-word. The second line adds “M202 (Lock 4th)” on a new line after use of the A-word.
“Why not just use Search and Replace?” you may wonder.
The answer is that the Monitor Revision is aware of g-code syntax, and so it’s quite a bit more robust. G-code doesn’t know the difference between “G01A90”, “g1a90”, “G01 A90”, “G01<newline>A90”, and all sorts of other combinations. A complex regular expression search could unravel it for the most part, but having a special command that is aware of the g-code syntax is faster and more reliable for this sort of thing. Imagine making a mistake with search and replace that suddenly changed the line breaks on a lot of lines. Given g-codes modal nature that would be a nasty one if you didn’t catch it soon enough to Undo!
Like what you read on CNCCookbook?
Join 100,000+ CNC'ers! Get our latest blog posts delivered straight to your email inbox once a week for free. Plus, we’ll give you access to some great CNC reference materials including:
- Our Big List of over 200 CNC Tips and Techniques
- Our Free GCode Programming Basics Course
- And more!
Just enter your name and email address below:
100% Privacy: We will never Spam you!