configurations and adjustments to protocol

This commit is contained in:
Simen Svale Skogsrud 2009-02-15 12:56:07 +01:00
parent 356517c6f2
commit 2bd984a734
7 changed files with 21 additions and 17 deletions

View File

@ -23,9 +23,9 @@
#define VERSION "0.0" #define VERSION "0.0"
#define X_STEPS_PER_MM 10.0 #define X_STEPS_PER_MM 1.0
#define Y_STEPS_PER_MM 10.0 #define Y_STEPS_PER_MM 1.0
#define Z_STEPS_PER_MM 10.0 #define Z_STEPS_PER_MM 1.0
#define INCHES_PER_MM 25.4 #define INCHES_PER_MM 25.4
#define X_STEPS_PER_INCH X_STEPS_PER_MM*INCHES_PER_MM #define X_STEPS_PER_INCH X_STEPS_PER_MM*INCHES_PER_MM

View File

@ -23,7 +23,7 @@
/* Intentionally not supported: /* Intentionally not supported:
- Canned cycles - Canned cycles
- Tool radius compensatino - Tool radius compensation
- A,B,C-axes - A,B,C-axes
- Multiple coordinate systems - Multiple coordinate systems
- Evaluation of expressions - Evaluation of expressions
@ -35,7 +35,7 @@
/* /*
Omitted for the time being: 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 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 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 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)); memset(&gc, 0, sizeof(gc));
gc.feed_rate = DEFAULT_FEEDRATE; gc.feed_rate = DEFAULT_FEEDRATE;
select_plane(X_AXIS, Y_AXIS, Z_AXIS); select_plane(X_AXIS, Y_AXIS, Z_AXIS);
gc.absolute_mode = true;
} }
inline float to_millimeters(double value) { inline float to_millimeters(double value) {
@ -180,7 +181,7 @@ uint8_t gc_execute_line(char *line) {
case 'M': case 'M':
switch(int_value) { switch(int_value) {
case 0: case 1: gc.program_flow = PROGRAM_FLOW_PAUSED; break; 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 3: gc.spindle_direction = 1; break;
case 4: gc.spindle_direction = -1; break; case 4: gc.spindle_direction = -1; break;
case 5: gc.spindle_direction = 0; break; case 5: gc.spindle_direction = 0; break;

View File

@ -65,7 +65,7 @@ void mc_dwell(uint32_t milliseconds)
// Calculate the microseconds between steps that we should wait in order to travel the // 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 // 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; int32_t pace;
if (invert) { if (invert) {
pace = round(ONE_MINUTE_OF_MICROSECONDS/feed_rate/steps); 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 // Ask old Phytagoras to estimate how many mm our next move is going to take us
double millimeters_of_travel = double millimeters_of_travel =
sqrt(pow(X_STEPS_PER_MM*step_count[X_AXIS],2) + sqrt(square(X_STEPS_PER_MM*step_count[X_AXIS]) +
pow(Y_STEPS_PER_MM*step_count[Y_AXIS],2) + square(Y_STEPS_PER_MM*step_count[Y_AXIS]) +
pow(Z_STEPS_PER_MM*step_count[Z_AXIS],2)); square(Z_STEPS_PER_MM*step_count[Z_AXIS]));
// And set the step pace // 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 ----------------------------------------------------------------------------------------------- // Execution -----------------------------------------------------------------------------------------------
@ -247,10 +247,10 @@ void mc_arc(double theta, double angular_travel, double radius, double linear_tr
// Calculate feed rate ------------------------------------------------------------------------------------- // Calculate feed rate -------------------------------------------------------------------------------------
// We then calculate the millimeters of helical travel // 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. // 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. // 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 ----------------------------------------------------------------------------------------------- // Execution -----------------------------------------------------------------------------------------------

View File

@ -14,7 +14,7 @@ Status:
* Runs on atmega168/arduino. * Runs on atmega168/arduino.
* GCode interpreter complete * GCode interpreter complete
* Linear interpolation machine control 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 * 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' g-code while the steppers are still steppin'
* Basic serial protocol complete * Basic serial protocol complete

View File

@ -32,7 +32,7 @@ char line[BLOCK_BUFFER_SIZE];
uint8_t line_counter; uint8_t line_counter;
void prompt() { void prompt() {
printString(PROMPT); printString("\r\n@");
line_counter = 0; line_counter = 0;
} }
@ -74,7 +74,7 @@ void sp_init()
printString("\r\nGrbl "); printString("\r\nGrbl ");
printString(VERSION); printString(VERSION);
printByte('\r'); printString("\r\n");
prompt(); prompt();
} }
@ -85,9 +85,12 @@ void sp_process()
{ {
if((c < 32)) { // Line is complete. Then execute! if((c < 32)) { // Line is complete. Then execute!
line[line_counter] = 0; line[line_counter] = 0;
// printByte('"');
// printString(line);
// printByte('"');
gc_execute_line(line); gc_execute_line(line);
line_counter = 0; line_counter = 0;
print_result(); //print_result();
prompt(); prompt();
} else if (c == ' ' || c == '\t') { // Throw away whitepace } else if (c == ' ' || c == '\t') { // Throw away whitepace
} else if (c >= 'a' && c <= 'z') { // Upcase lowercase } else if (c >= 'a' && c <= 'z') { // Upcase lowercase