repetier / Repetier-Firmware

Firmware for Arduino based RepRap 3D printer.
812 stars 734 forks source link

Priority low but good to know: Arc G2/3 GCode inconsistency #850

Open Nibbels opened 5 years ago

Nibbels commented 5 years ago

https://github.com/repetier/Repetier-Firmware/blob/76ef4223d71d00bdb6ba02f1e1e810d9069754c1/src/ArduinoAVR/Repetier/Commands.cpp#L1010

Hello,

I changed my axis to floats and therefore I had to change and then test arc drawing too. While learning how to draw arcs and tempering with different Gcodes I stumbled upon some exception inconsistency comparing radius with center-offset-gcode type.

As I understood it, when creating an arc gcode, we can choose how we set our arcs center. Else we specify this a) center offset which is defined by command->I and command->J. Or we define a b) radius using command->R.

When using a center offset the radius is being calculated. When using a radius the center offset is being calculated.

Problems exist when our start-coordinates and end coordinates do not match the radius or center constraint so that a round circle cannot reach the end coordinates by drawing an arc. In case of such a wrong Gcode here an error is printed (which would cause some usb hosts to stop the execution): https://github.com/repetier/Repetier-Firmware/blob/76ef4223d71d00bdb6ba02f1e1e810d9069754c1/src/ArduinoAVR/Repetier/Commands.cpp#L971 (This happens if R is smaller than half the distance from start coordinate to end coordinate as example.)

Example: From X0 Y0 the half circle G3 X0 Y50 R15 has an impossible radius and the printer will print an error message. (G3 X0 Y50 R25 would work.)

That is no problem. But the other way around: If I have a offset for the center the radius is calculated. This code does not check if the offset is correct. So in case the Gcode is written by hand - wrong - there is no such exception as with the radius definition. -> Radius is calculated wrongly, the arc is drawn and then the endpoint is reached by driving a straight line.

Example: Start coordinate: 0 / 0 End coordinate: 0 / 50 Gcode Ok: I = 0 J = 25 Gcode Fail: I = 0 J != 25

We should check if the offset is inbetween startpoint and endpoint. Then the only distance allowed is the half way inbetween start and endpoint. Otherwise throw the same error.

Well I know that this is a bug but it wouldnt have a really a huge impact. Because a CAM software would not produce such an Gcode - probably.

;) Greetings

Nibbels commented 5 years ago

Well the more I think: I guess the calculated radius should always be the same

from start coordinates to center coordinates. AND from center coordinates to end coordinates?

Otherwise the circle will not reach the end constraint. I guess that leaves me with the problem that calculations are not always 100% perfect, derived from rounded coordinates and I have to think of an allowed error.