Home / reprap_new_firmware_arc
Name Modified Size InfoDownloads / Week
Parent folder
ThermistorTable.h 2010-12-13 800 Bytes
reprap_new_firmware_arc.pde 2010-12-13 2.2 kB
stepper_control.pde 2010-12-13 34.7 kB
process_string.pde 2010-12-13 20.0 kB
reprap_new_firmware.h 2010-12-13 1.1 kB
extruder.pde 2010-12-13 4.2 kB
optimal_routines.pde 2010-12-13 7.3 kB
_init.pde 2010-12-13 4.9 kB
Totals: 8 Items   75.2 kB 0
********************************************************************************
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 been building a CNC Mill, and I wanted it to be Arduino controlled so that I can tailor it to my needs. I took a version of the RepRap firmware created by Chris Meighan and used by Contraptor that has arcs and acceleration, and I expanded it so that it can draw arcs in all three planes. 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.

You can find the original firmware here: http://contraptor.svn.sourceforge.net/viewvc/contraptor/trunk/firmware/

********************************************************************************

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): http://www.contraptor.org/forum/t-275140/reprap-new-firmware-1-16-microstepping-trouble#post-897494

-Albanetc's arc fix: http://www.contraptor.org/forum/t-192541/mini-cnc-case-study#post-749373

-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:

   1. -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.

   2. -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).

   3. -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).

   4. -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.

   5. -_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.
Source: ReadMe.txt, updated 2010-12-14