Recently, I was working through a complex g-code program to find and fix some bugs in G-Wizard Editor. Trying to understand what the heck somebody else’s program is doing and whether or not my own g-code simulator was properly simulating the program often leads to helpful ideas for tools that make G-Code programming easier for everyone. For example, it got me to add the ability to make the simulator run until it hits the next macro command that would cause a branch to some location other than the next line of g-code. This is a really handy way to buzz through programs going from one subprogram to the next, and it corresponds to similar commands in debuggers and simulators for other computer languages.
This time around, I had a program that had lots of subprograms all madly calling around to make a bunch of holes and then thread mill them with NPT threads using helical interpretation. The subprograms were quite clever in how they used the “L” word to repeat the helix 4 times for 90 degree moves to complete each turn, and then 9 more times to get 9 threads milled. But man, there sure were a lot of different little subprograms all calling each other, sometimes with “L” repeats and sometimes not. I was getting lost and found myself wishing for another tool that’s commonly available for other computer languages besides g-code. That tool is called a “stack trace”. It basically shows “who called who”. Here is the newly implemented stack trace for GWE:
Stack trace is underlined in red…
It’s a simple little tool. The list of numbers are the line numbers of the different callers. So we can see the following:
- At line 35, the first subprogram was called.
- Within that subprogram, at line 176, another subprogram was called.
- Within that subprogram, at line 183, a third subprogram was called, and this one has a repeat factor of “4”.
This particular g-code part program nested down 4 levels and at one point had two different repeat counts going. I told you it was complicated. This little display made it tremendously easier to keep track of what was going on. The “L” numbers count down as each repeat cycle is executed as well.
If you like to write these sorts of macro subprograms in your g-code, check out the new tool. It’s in GWE version 0.310. Registration for the Beta Test is free.