Run a G-Code created with debug_on

Hi all,
just a tip to debug the generated G-Code and fix post-processor steps.

BobCAD/CAM post-processor engine can enter in debug mode setting:

26. Set debug comments for post-editing
	debug_on

At this point before every g-code generated line, the post adds a description line of xx. block which generates the following code:

...
..
.
T1 M06
G54
G90 X-64. Y27. S10000 M03
*************2 - 14. Tool length compensation*************
G43 H1 Z42. M08
*************40. Start of operation*************
*************27. First Rapid Move Z*************
Z22.
*************50. Line rapid move Z - Z retract*************
Z20.
*************51. Line feed move Z*************
G01 Z15. F800.
*************55. Line feed move XYZ*************
X64. F3500.
*************64. Arc move XY*************
.
..
...

This is a wonderful way to understand the flow of post-processor BUT the info data format is incompatible with common CNC comments format so you can’t use the output to debug in CNC or in an external CNC owned simulator (this is my case).

But there is a fast tip using the VBScript engine of the post-processor.
At first, I enable the check each output line with scripting, so before putting out a line the post-processor executes the block 2102. Read each Line on Output.

540. Check each output line with scripting? y

Then in block 2102 is simple to convert a debug info to comment for CNC, in this case, I use the comment start with ; char (comment is between ; to end line) but some CNC can use standard ( comment ) way:

2102. Read each Line on Output.

    ' check if is a debug line and add comment header
    Line = MILL_GetOutputLineToNcFile()
	If Mid(Line, 1, 1) = "*" Then
		Line = "; *** [" + Replace(Line, "*************"," ") + "] ***"
		MILL_SetOutputLineToNcFile(Line)
	End If

The resulting GCode can be now debugged with info and is ready to be executed in an external simulator or directly on CNC:

2 Likes

Great Tip,

I don’t think most users will want debug comments in their code for readability and memory savings…but in a development environment it’s a treat!

Alex

Hi @shineworld,
good job :ok_hand:

@BC-Team: wouldn’t be that hard to implement output of debug info with a semicolon in advance…

Bye, Harald