Warning! I have not extensively tested this code. Do not leave your machine unattended while it is running. Let me know if you find any bugs. I take no responsibility for any damage that occurs from using this code.
I've modified the Contraptor firmware to include XZ and YZ arcs. The way I implemented this was by creating dummy indices I_Axis, J_Axis, & K_axis. I-J is the plane that the arc resides in and K is always normal to it. So for XY arcs I = X, J = Y, & K = Z. For XZ, I = X, J = Z, & K = Y. Since the code originally only acted on the XY plane, I made it act on the new generic I-J plane. The way I set it up, the code will behave identically to the original unless you provide it with the g-codes G18 or G19. G18 = XZ plan. G19 = YZ plane. Although I did add a small fix to the way feedrates were handled after a change in the unit system. The original code would not change the units for the feedrate properly if an arc move immediately followed the unit change command.
The syntax for arc moves goes like this:
G90 G20 G17 G1 X0.0 Y0.0 Z0.0 G3 X0.5 Y-0.5 I0.5 J0.0 G18 G1 X0.0 Y0.0 Z0.0 G3 X0.5 Z-0.5 I0.5 K0.0 G19 G1 X0.0 Y0.0 Z0.0 G3 Y0.5 Z-0.5 J0.5 K0.0
That should draw the same quarter circle in all three planes. If you wanted to draw a helix, you can use the following command:
G90 G20 G18 G1 X0.0 Y0.0 Z0.0 G3 X0.5 Z-0.5 I0.5 K0.0 Y1.0
G17 = XY plane, G18 = XZ plane, G19 = YZ plane.
Other bonuses in this code include:
-arthurwolf microstepping fix (I haven't tested this but he seems to know what he is doing)
-Albanetc's arc fix
-Added M2, M3, M5 and M30 codes for starting and stopping your cutting head. Use TOOL_HEAD_PIN in _init to select which pin that will act on. Set it to -1 if you don't want to use it.
-Added manual controls:
- -START_PAUSE pin is an analog pin connected to a pull down resistor and a high side switch. When switched to high, it exits all of the running code, and enters a while loop that allows you to jog the stage. The jogging isn't taken to account by the main program. So absolute positioning is not maintained. I used an analog pin for START_PAUSE, so that I can add other functions later.
- -TOOL_HEAD_SW_PIN will turn on the cutting head when the code is paused. If it is left high when you enter the paused loop, it must be toggled low and then high again to turn on the cutting head (safety feature).
- -HOLD_PIN will enable and disable all of the steppers. If it is left high when you enter the paused loop, it must be toggled low and then high again to turn on the steppers (safety feature).
- -MAX_MIN_PIN is an analog pin which all of the limit switches are connected to. A resistor ladder is used to differentiate between the limit switches. This is necessary when manually jogging if you want to back off of a limit switch. This also frees up more pins.
- -_LEFT_RIGHT are analog pins connected to pots to move the axis. 2.5V = no movement. 0V = fastest left. 5V = fastest right. All directions can be moved at once. I used an old gaming controller and wired the existing pots to my arduino.
You can enable and disable the manual controls code by using MANUAL_ATTACH inside reprap_new_firmware_arc.pde. If you don't want the manual controls, set #define MANUAL_ATTACH 0 and the firmware should behave like the original.
Here is the firmware: http://www.mediafire.com/?6756ivkwz7kk8ih
(Small update: fixed an issue that caused the manual controls to not work.)