From 2bd984a734fef0e63a4c37f58b7863d5f8558647 Mon Sep 17 00:00:00 2001 From: Simen Svale Skogsrud Date: Sun, 15 Feb 2009 12:56:07 +0100 Subject: [PATCH] configurations and adjustments to protocol --- config.h | 6 +++--- gcode.c | 7 ++++--- motion_control.c | 14 +++++++------- readme.txt | 2 +- {scripts => script}/console | 0 {scripts => script}/proxy | 0 serial_protocol.c | 9 ++++++--- 7 files changed, 21 insertions(+), 17 deletions(-) rename {scripts => script}/console (100%) rename {scripts => script}/proxy (100%) diff --git a/config.h b/config.h index 6af95df..fba66db 100644 --- a/config.h +++ b/config.h @@ -23,9 +23,9 @@ #define VERSION "0.0" -#define X_STEPS_PER_MM 10.0 -#define Y_STEPS_PER_MM 10.0 -#define Z_STEPS_PER_MM 10.0 +#define X_STEPS_PER_MM 1.0 +#define Y_STEPS_PER_MM 1.0 +#define Z_STEPS_PER_MM 1.0 #define INCHES_PER_MM 25.4 #define X_STEPS_PER_INCH X_STEPS_PER_MM*INCHES_PER_MM diff --git a/gcode.c b/gcode.c index e2cee54..3223fd7 100644 --- a/gcode.c +++ b/gcode.c @@ -23,7 +23,7 @@ /* Intentionally not supported: - Canned cycles - - Tool radius compensatino + - Tool radius compensation - A,B,C-axes - Multiple coordinate systems - Evaluation of expressions @@ -35,7 +35,7 @@ /* Omitted for the time being: - group 0 = {G10, G28, G30, G53, G92, G92.1, G92.2, G92.3} (Non modal G-codes) + group 0 = {G10, G28, G30, G92, G92.1, G92.2, G92.3} (Non modal G-codes) group 8 = {M7, M8, M9} coolant (special case: M7 and M8 may be active at the same time) group 9 = {M48, M49} enable/disable feed and speed override switches group 12 = {G54, G55, G56, G57, G58, G59, G59.1, G59.2, G59.3} coordinate system selection @@ -114,6 +114,7 @@ void gc_init() { memset(&gc, 0, sizeof(gc)); gc.feed_rate = DEFAULT_FEEDRATE; select_plane(X_AXIS, Y_AXIS, Z_AXIS); + gc.absolute_mode = true; } inline float to_millimeters(double value) { @@ -180,7 +181,7 @@ uint8_t gc_execute_line(char *line) { case 'M': switch(int_value) { case 0: case 1: gc.program_flow = PROGRAM_FLOW_PAUSED; break; - case 2: gc.program_flow = PROGRAM_FLOW_COMPLETED; break; + case 2: case 30: case 60: gc.program_flow = PROGRAM_FLOW_COMPLETED; break; case 3: gc.spindle_direction = 1; break; case 4: gc.spindle_direction = -1; break; case 5: gc.spindle_direction = 0; break; diff --git a/motion_control.c b/motion_control.c index 8817022..70fe298 100644 --- a/motion_control.c +++ b/motion_control.c @@ -65,7 +65,7 @@ void mc_dwell(uint32_t milliseconds) // Calculate the microseconds between steps that we should wait in order to travel the // designated amount of millimeters in the amount of steps we are going to generate -void set_step_pace(double feed_rate, double millimeters_of_travel, uint32_t steps, int invert) { +void compute_and_set_step_pace(double feed_rate, double millimeters_of_travel, uint32_t steps, int invert) { int32_t pace; if (invert) { pace = round(ONE_MINUTE_OF_MICROSECONDS/feed_rate/steps); @@ -113,11 +113,11 @@ void mc_line(double x, double y, double z, float feed_rate, int invert_feed_rate // Ask old Phytagoras to estimate how many mm our next move is going to take us double millimeters_of_travel = - sqrt(pow(X_STEPS_PER_MM*step_count[X_AXIS],2) + - pow(Y_STEPS_PER_MM*step_count[Y_AXIS],2) + - pow(Z_STEPS_PER_MM*step_count[Z_AXIS],2)); + sqrt(square(X_STEPS_PER_MM*step_count[X_AXIS]) + + square(Y_STEPS_PER_MM*step_count[Y_AXIS]) + + square(Z_STEPS_PER_MM*step_count[Z_AXIS])); // And set the step pace - set_step_pace(feed_rate, millimeters_of_travel, maximum_steps, invert_feed_rate); + compute_and_set_step_pace(feed_rate, millimeters_of_travel, maximum_steps, invert_feed_rate); // Execution ----------------------------------------------------------------------------------------------- @@ -247,10 +247,10 @@ void mc_arc(double theta, double angular_travel, double radius, double linear_tr // Calculate feed rate ------------------------------------------------------------------------------------- // We then calculate the millimeters of helical travel - double millimeters_of_travel = sqrt(pow(angular_travel*radius,2)+pow(abs(linear_travel),2)); + double millimeters_of_travel = hypot(angular_travel*radius, abs(linear_travel)); // Then we calculate the microseconds between each step as if we will trace the full circle. // It doesn't matter what fraction of the circle we are actually going to trace. The pace is the same. - set_step_pace(feed_rate, millimeters_of_travel, maximum_steps, invert_feed_rate); + compute_and_set_step_pace(feed_rate, millimeters_of_travel, maximum_steps, invert_feed_rate); // Execution ----------------------------------------------------------------------------------------------- diff --git a/readme.txt b/readme.txt index cee843b..a6dd47a 100644 --- a/readme.txt +++ b/readme.txt @@ -14,7 +14,7 @@ Status: * Runs on atmega168/arduino. * GCode interpreter complete * Linear interpolation machine control complete -* Arcs complete (no helices yet) +* Arcs and helical interpolation complete * 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' * Basic serial protocol complete diff --git a/scripts/console b/script/console similarity index 100% rename from scripts/console rename to script/console diff --git a/scripts/proxy b/script/proxy similarity index 100% rename from scripts/proxy rename to script/proxy diff --git a/serial_protocol.c b/serial_protocol.c index e5be1d5..90d6a0f 100644 --- a/serial_protocol.c +++ b/serial_protocol.c @@ -32,7 +32,7 @@ char line[BLOCK_BUFFER_SIZE]; uint8_t line_counter; void prompt() { - printString(PROMPT); + printString("\r\n@"); line_counter = 0; } @@ -74,7 +74,7 @@ void sp_init() printString("\r\nGrbl "); printString(VERSION); - printByte('\r'); + printString("\r\n"); prompt(); } @@ -85,9 +85,12 @@ void sp_process() { if((c < 32)) { // Line is complete. Then execute! line[line_counter] = 0; + // printByte('"'); + // printString(line); + // printByte('"'); gc_execute_line(line); line_counter = 0; - print_result(); + //print_result(); prompt(); } else if (c == ' ' || c == '\t') { // Throw away whitepace } else if (c >= 'a' && c <= 'z') { // Upcase lowercase