The message below the line presents an interesting puzzle, but the solution turns out to be simple. While running the code shown, the interpreter was simultaneously looking ahead through the main program and down into the subroutine next to be called. That's where it found the attempted division by zero. With the diplomatic discretion for which it is famous, the interpreter did not choose to reveal where it had found the problem.
-----------------------------------------------------------------------------------------
I have a gCode program that causes PathPilot to generate a false 'Attempt to divide by zero' message. To document the problem, I went through my code and logged the divisor of every division, even where the divisor was a constant. Some of the resulting code looks like this:
Code:
#1 = [2 * #<HPasses>]
(debug, A = #5423, T.P = #<_TP>, divisor(2 * HPasses) = #1)
#<CutProg> = [#<_TierProg> / [2 * #<HPasses>]] ; .. 2 cuts per loop
#<HPass> = 0 ; ..
o 10351 repeat [#<HPasses>] ; loops cycle outward
#<HPass> = [#<HPass> + 1] ; ..
#<_TP> = [#<_ReportTier> + #<HPass>/10000] ; added for debugging
#<WOffset> = [#<HPass> * #<WOC>] ; ..
(debug, A = #5423, T.P = #<_TP>, divisor(2) = 2)
#<ToeUnder> = [#<WOffset> + #<_ToolRadius> - #<_SlotWidth> / 2]
o 10355 if [#<_Finishing> OR [#<ToeUnder> GT 0]] ; cut into side
#<XOffset> = [#<WOffset> * #<_sin>]
#<YOffset> = [#<WOffset> * #<_cos>]
#<XSE> = [#<_XClearStart> + #<XOffset>]
#<YSE> = [#<_YClearStart> - #<YOffset>]
#<XNE> = [#<_XClearEnd> + #<XOffset>]
#<YNE> = [#<_YClearEnd> - #<YOffset>]
#<XNW> = [#<_XClearEnd> - #<XOffset>]
#<YNW> = [#<_YClearEnd> + #<YOffset>]
#<XSW> = [#<_XClearStart> - #<XOffset>]
#<YSW> = [#<_YClearStart> + #<YOffset>]
G00 X [#<XSE>] Y [#<YSE>] ; to SE
G01 X [#<XNE>] Y [#<YNE>] A [#<_OldA> + #<CutProg>] ; to NE
G00 X [#<XNW>] Y [#<YNW>] ; to NW
G01 X [#<XSW>] Y [#<YSW>] A [#<_OldA> + 2 * #<CutProg>] ; to SW
G00 X [#<_XClearStart>] Y [#<_YClearStart>] ; to Clear
#<_OldA> = [#<_OldA> + 2 * #<CutProg>]
o 10355 else ; don't bother cutting air
#<_OldA> = [#<_OldA> + 2 * #<CutProg>] ; easy progress
G00 A [#<_OldA>] ; ..
o 10355 endif ; on to next loop
o 10351 endrepeat ; ..
About 3 minutes into the operation of the program, PathPilot's Status output from this code includes (color added)
Code:
A = 18.973602, T.P = 10.001000, divisor(2) = 2
Attempt to divide by zero
A = 18.823018, T.P = 10.000900, divisor(2) = 2
A = 18.672434, T.P = 10.000800, divisor(2) = 2
A = 18.521850, T.P = 10.000700, divisor(2) = 2
A = 18.371266, T.P = 10.000600, divisor(2) = 2
A = 18.220682, T.P = 10.000500, divisor(2) = 2
A = 18.070098, T.P = 10.000400, divisor(2) = 2
A = 17.919513, T.P = 10.000300, divisor(2) = 2
A = 17.768929, T.P = 10.000200, divisor(2) = 2
A = 17.618345, T.P = 10.000100, divisor(2) = 2
A = 17.618345, T.P = 10.000000, divisor(2 * HPasses) = 26.000000
The code quoted above is inside a subroutine, so execution goes ahead despite PathPilot's mistaken detection of an error, but then the run aborts as soon as this subroutine returns.
Has anyone else seen this problem before? I don't see how it could be tracked down without going through the code of PP's gCode interpreter.
Similar Threads: