G3 puzzle or bug
-
I have an interesting puzzle whereby I can print circles with G3 as long as the circles are not exactly 8.8mm diameter. The 8.8mm circles fail with the message "Error: G2/G3: bad combination of parameter values", but if I make the circles 8.8001mm or 8.799mm they work properly.
I have not found another 'magical' diameter that fails, but I'm a bit concerned that there might still be a bug in the G3 arc firmware code.
Here is a two layer circle file that fails: test13 8.8.gcode
And here is one that works: test13 8.8001.gcode -
@MJLew Sorry, I uploaded two files that fail (the second is a misnamed copy of the first, I think). Here is a two layer circle that works: test12 8.8001.gcode
-
Thanks for your interesting example! It appears to be caused by the combination of the arc being exactly 180 degrees and floating point rounding error. The firmware is calculating this quantity, which is required to be non-negative:
R^2 - (dX^2 + dY^2)/4
In your example this is:
(4.4)^2 - ((55.6-64.4)^2 + (50.0-50.0)^2)/4
which of course should be exactly zero. However, the values 55.6, 64.4 and 4.4 can't be represented exactly in IEEE floating int format, so when 64.4 is subtracted from 55.6 the result is slightly larger than minus twice the radius.
I think the way I can fix this is to detect when the two terms being subtracted in the overall computation are very close leading to a slightly negative amount, and in such cases increase the radius just enough (one LSB is probably enough) to make the overall difference zero.
I propose to include this fix in RRF 3.3.
-
I have now included this fix in the RRF 3.3 source code. I also changed the error message to "G2/G3: radius is too small to reach endpoint". If you would like an unofficial build to try, let me know which Duet you are using.
-
Ah, I would never hav worked that out. It seems like I should simply make three segments in the circles. I'll give that a go tomorrow.
Thanks for fixing it.
-
@MJLew said in G3 puzzle or bug:
Ah, I would never hav worked that out. It seems like I should simply make three segments in the circles. I'll give that a go tomorrow.
Either that, or increase the radius by a tiny amount.
BTW there is a standard CNC way of doing an entire circle using one G2/G3 command, which recent versions of RRF support.