diff --git a/Makefile b/Makefile
index cc53371..3dd6068 100644
--- a/Makefile
+++ b/Makefile
@@ -39,7 +39,7 @@ AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE) -B 10
COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE) -I.
# symbolic targets:
-all: main.hex
+all: grbl.hex
.c.o:
$(COMPILE) -c $< -o $@
@@ -55,7 +55,7 @@ all: main.hex
$(COMPILE) -S $< -o $@
flash: all
- $(AVRDUDE) -U flash:w:main.hex:i
+ $(AVRDUDE) -U flash:w:grbl.hex:i
fuse:
$(AVRDUDE) $(FUSES)
@@ -65,19 +65,19 @@ install: flash fuse
# if you use a bootloader, change the command below appropriately:
load: all
- bootloadHID main.hex
+ bootloadHID grbl.hex
clean:
- rm -f main.hex main.elf $(OBJECTS)
+ rm -f grbl.hex main.elf $(OBJECTS)
# file targets:
main.elf: $(OBJECTS)
$(COMPILE) -o main.elf $(OBJECTS) -lm
-main.hex: main.elf
- rm -f main.hex
- avr-objcopy -j .text -j .data -O ihex main.elf main.hex
- avr-size main.hex *.o
+grbl.hex: main.elf
+ rm -f grbl.hex
+ avr-objcopy -j .text -j .data -O ihex main.elf grbl.hex
+ avr-size grbl.hex *.o
# If you have an EEPROM section, you must also create a hex file for the
# EEPROM and add it to the "flash" target.
diff --git a/gcode.c b/gcode.c
index f8d1ba2..62e0a06 100644
--- a/gcode.c
+++ b/gcode.c
@@ -30,12 +30,12 @@
- Variables
- Multiple home locations
- Probing
- - Spindle direction
- Override control
*/
/*
Omitted for the time being:
+ - Spindle direction
group 0 = {G10, G28, G30, G53, G92, G92.1, G92.2, G92.3} (Non modal G-codes)
group 5 = {G93, G94} feed rate mode
@@ -126,7 +126,7 @@ uint8_t gc_execute_line(char *line) {
double unit_converted_value;
double inverse_feed_rate;
- uint8_t absolute_mode = 0; /* 0 = relative motion, 1 = absolute motion {G90, G91} */
+ uint8_t absolute_mode; /* 0 = relative motion, 1 = absolute motion {G90, G91} */
uint8_t next_action = NEXT_ACTION_DEFAULT; /* One of the NEXT_ACTION_-constants */
double target[3], offset[3];
diff --git a/motion_control.c b/motion_control.c
index 447ee57..8ec2322 100644
--- a/motion_control.c
+++ b/motion_control.c
@@ -18,7 +18,13 @@
along with Grbl. If not, see .
*/
-/* This code was inspired by the Arduino GCode_Interpreter by Mike Ellery. */
+/* The structure of this module was inspired by the Arduino GCode_Interpreter by Mike Ellery. The arc
+ interpolator written from the information provided in the Wikipedia article 'Midpoint circle algorithm'
+ and the lecture 'Circle Drawing Algorithms' by Leonard McMillan.
+
+ http://en.wikipedia.org/wiki/Midpoint_circle_algorithm
+ http://www.cs.unc.edu/~mcmillan/comp136/Lecture7/circle.html
+*/
#include
#include "config.h"
diff --git a/readme.txt b/readme.txt
index 2b13899..2753c52 100644
--- a/readme.txt
+++ b/readme.txt
@@ -2,7 +2,9 @@ Grbl - An embedded rs274/ngc (g-code) interpreter, CNC controller, readout and e
Inspired by the Arduino GCode Interpreter by Mike Ellery
Status:
-* Linear interpolation machine control complete (No arcs yet)
+* Linear interpolation machine control complete (Arc support in embryonic state)
+* Buffered, non blocking, asynchronous stepping so the rest of the system is free to generate new steps and parse
+ g-code while the steppers are still steppin'
* GCode interpreter complete
* Basic serial protocol complete
* As of yet completely untested in a real environemnt. Still waiting for my micRo kit from Lumenlab.com
@@ -18,7 +20,7 @@ Goals:
Limitations:
* Limited GCode-support. Focus on the kind of GCode produced by CAM tools. Leave human GCoders frustrated.
-* No rotation axes, only x,y and z.
+* No rotation axes, only x, y and z.
diff --git a/serial_protocol.c b/serial_protocol.c
index b704686..2a6894e 100644
--- a/serial_protocol.c
+++ b/serial_protocol.c
@@ -40,15 +40,14 @@ void print_result() {
int inches_mode;
uint8_t status_code;
uint32_t line_number;
+ int i; // loop variable
gc_get_status(position, &status_code, &inches_mode, &line_number);
- printByte('[');
- printInteger(trunc(position[X_AXIS]*100));
- printByte(',');
- printInteger(trunc(position[Y_AXIS]*100));
- printByte(',');
- printInteger(trunc(position[Z_AXIS]*100));
+ printString("[ ");
+ for(i=X_AXIS; i<=Z_AXIS; i++) {
+ printInteger(trunc(position[i]*100));
+ printByte(' ');
+ }
printByte(']');
- printByte(' ');
printByte('@');
printInteger(line_number);
printByte(':');
diff --git a/stepper.c b/stepper.c
index 21fe403..d17fd24 100644
--- a/stepper.c
+++ b/stepper.c
@@ -18,6 +18,9 @@
along with Grbl. If not, see .
*/
+/* The timer calculations of this module informed by the 'RepRap cartesian firmware' by Zack Smith
+ and Philipp Tiefenbacher. The circle buffer implementation by the wiring_serial library by David A. Mellis */
+
#include "stepper.h"
#include "config.h"
#include "nuts_bolts.h"
@@ -30,7 +33,7 @@ volatile uint8_t step_buffer[STEP_BUFFER_SIZE]; // A buffer for step instruction
volatile int step_buffer_head = 0;
volatile int step_buffer_tail = 0;
-uint8_t state = STEPPER_STATE_STOPPED;
+uint8_t stepper_mode = STEPPER_MODE_STOPPED;
// This timer interrupt is executed at the pace set with set_pace. It pops one instruction from
// the step_buffer, executes it. Then it starts timer2 in order to reset the motor port after
@@ -77,7 +80,7 @@ void st_init()
// Configure Timer 2
TCCR2A = 0; // Normal operation
- TCCT2B = 1<
#include
-#define STEPPER_STATE_STOPPED 0
-#define STEPPER_STATE_RUNNING 1
-#define STEPPER_STATE_LIMIT_OVERRUN 2
-#define STEPPER_STATE_HOMING 3
+#define STEPPER_MODE_STOPPED 0
+#define STEPPER_MODE_RUNNING 1
+#define STEPPER_MODE_LIMIT_OVERRUN 2
+#define STEPPER_MODE_HOMING 3
// Initialize and start the stepper motor subsystem
void st_init();
diff --git a/todo.txt b/todo.txt
index e2aace7..a30e13d 100644
--- a/todo.txt
+++ b/todo.txt
@@ -1,3 +1,6 @@
+* Implement homing cycle in stepper.c
+* Implement limit switch support in stepper.c (use port-triggered interrupts?)
+* How to implement st_set_pace? Consider synchronizing when pace is changed
* Eliminate need for circle_x and circle_y in step_arc_along…
* Use timer interrupts to drive steppers
* Tool table
diff --git a/wiring_serial.c b/wiring_serial.c
index 9392a09..c7a4397 100644
--- a/wiring_serial.c
+++ b/wiring_serial.c
@@ -128,21 +128,21 @@ SIGNAL(SIG_UART_RECV)
}
}
-void printMode(int mode)
-{
- // do nothing, we only support serial printing, not lcd.
-}
+// void printMode(int mode)
+// {
+// // do nothing, we only support serial printing, not lcd.
+// }
void printByte(unsigned char c)
{
serialWrite(c);
}
-void printNewline()
-{
- printByte('\n');
-}
-
+// void printNewline()
+// {
+// printByte('\n');
+// }
+//
void printString(const char *s)
{
while (*s)
@@ -180,20 +180,20 @@ void printInteger(long n)
printIntegerInBase(n, 10);
}
-void printHex(unsigned long n)
-{
- printIntegerInBase(n, 16);
-}
-
-void printOctal(unsigned long n)
-{
- printIntegerInBase(n, 8);
-}
-
-void printBinary(unsigned long n)
-{
- printIntegerInBase(n, 2);
-}
+// void printHex(unsigned long n)
+// {
+// printIntegerInBase(n, 16);
+// }
+//
+// void printOctal(unsigned long n)
+// {
+// printIntegerInBase(n, 8);
+// }
+//
+// void printBinary(unsigned long n)
+// {
+// printIntegerInBase(n, 2);
+// }
/* Including print() adds approximately 1500 bytes to the binary size,
* so we replace it with the smaller and less-confusing printString(),