From daa859cf2f2db0d2cbaeff3216f510626ed5c130 Mon Sep 17 00:00:00 2001 From: timkrins Date: Tue, 7 Jun 2011 00:51:47 +1000 Subject: [PATCH] Needs to be tested - target coordinates. --- Makefile | 2 +- config.h | 8 +++++--- gcode.c | 5 ++++- lcd.c | 2 +- lcd.h | 25 +++++++++++++++---------- main.c | 8 ++++---- planner.c | 4 ++++ planner.h | 3 --- 8 files changed, 34 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index efcc2a8..cf55414 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ DEVICE = atmega644p CLOCK = 20000000L PROGRAMMER = -cusbtiny -P usb -OBJECTS = main.o motion_control.o gcode.o wiring_serial.o serial_protocol.o stepper.o \ +OBJECTS = main.o motion_control.o gcode.o wiring_serial.o serial_protocol.o spindle_control.o stepper.o \ eeprom.o settings.o planner.o lcd.o diff --git a/config.h b/config.h index d2a279c..79a0df1 100644 --- a/config.h +++ b/config.h @@ -72,9 +72,11 @@ The Z axis: #define ZPOS_LIMIT_BIT 4 #define ZNEG_LIMIT_BIT 5 -#define SPINDLE_ENABLE_DDR DDRB -#define SPINDLE_ENABLE_PORT PORTB -#define SPINDLE_ENABLE_BIT 4 +#define SPINDLE_ENABLE_DDR DDRD +#define SPINDLE_ENABLE_PORT PORTD +#define SPINDLE_ENABLE_BIT 2 +#define SPINDLE_DIRECTION_PORT DDRD +#define SPINDLE_DIRECTION_BIT 1 #define LCD_DDR DDRA #define LCD_PORT PORTA diff --git a/gcode.c b/gcode.c index 7efd8fc..a86d5da 100644 --- a/gcode.c +++ b/gcode.c @@ -26,6 +26,7 @@ #include #include "nuts_bolts.h" #include +#include #include "settings.h" #include "motion_control.h" #include "spindle_control.h" @@ -251,7 +252,7 @@ uint8_t gc_execute_line(char *line) { } else { spindle_stop(); } - + char print1[50]; // Perform any physical actions switch (next_action) { case NEXT_ACTION_GO_HOME: mc_go_home(); break; @@ -261,10 +262,12 @@ uint8_t gc_execute_line(char *line) { case MOTION_MODE_CANCEL: break; case MOTION_MODE_SEEK: mc_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], gc.seek_rate, FALSE); + sprintf(print1, "SEK X%f.3, Y%f.3, Z%f.3",(double)target[X_AXIS],(double)target[Y_AXIS],(double)target[Z_AXIS]); break; case MOTION_MODE_LINEAR: mc_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], (gc.inverse_feed_rate_mode) ? inverse_feed_rate : gc.feed_rate, gc.inverse_feed_rate_mode); + sprintf(print1, "LNR X%f.3, Y%f.3, Z%f.3",(double)target[X_AXIS],(double)target[Y_AXIS],(double)target[Z_AXIS]); break; #ifdef __AVR_ATmega328P__ case MOTION_MODE_CW_ARC: case MOTION_MODE_CCW_ARC: diff --git a/lcd.c b/lcd.c index 3898712..1eb533f 100644 --- a/lcd.c +++ b/lcd.c @@ -102,7 +102,7 @@ void lcd_write_line(char *s) { lcd_write(*s); // write it to the LCD s++; // and go to the next character } else { - lcd_write(" "); + lcd_write(0x20); } } } diff --git a/lcd.h b/lcd.h index 0e77455..e77b5d4 100644 --- a/lcd.h +++ b/lcd.h @@ -9,18 +9,23 @@ Questions? Ask Tim K #include "config.h" -#define LCD_DATAMASK (1< #include "planner.h" #include "stepper.h" -//#include "spindle_control.h" +#include "spindle_control.h" #include "motion_control.h" #include "gcode.h" #include "serial_protocol.h" @@ -31,7 +31,7 @@ #include "settings.h" #include "wiring_serial.h" #include "config.h" -#include "lcd.c" +#include "lcd.h" #include #include @@ -46,7 +46,7 @@ char print1[50]; settings_init(); plan_init(); st_init(); - //spindle_init(); + spindle_init(); lcd_cnc_init(); gc_init(); @@ -55,7 +55,7 @@ char print1[50]; sp_process(); // ... process the serial protocol /* Not sure if this will work, but trying anyway */ - sprintf(print1, "X%f.3, Y%f.3, Z%f.3",(double)position[X_AXIS],(double)position[Y_AXIS],(double)position[Z_AXIS]); + //sprintf(print1, "X%f.3, Y%f.3, Z%f.3",(double)target[X_AXIS],(double)target[Y_AXIS],(double)target[Z_AXIS]); lcd_set_line(2); // sets the screen position, line 3 lcd_write_line(print1); } diff --git a/planner.c b/planner.c index 95b05d8..4ec9456 100644 --- a/planner.c +++ b/planner.c @@ -69,6 +69,10 @@ #else #define BLOCK_BUFFER_SIZE 5 #endif + +// The current position of the tool in absolute steps +static int32_t position[3]; + static block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instructions static volatile int block_buffer_head; // Index of the next block to be pushed static volatile int block_buffer_tail; // Index of the block to process now diff --git a/planner.h b/planner.h index d2d316e..e7dbe8e 100644 --- a/planner.h +++ b/planner.h @@ -51,10 +51,7 @@ typedef struct { uint32_t decelerate_after; // The index of the step event on which to start decelerating } block_t; - -// The current position of the tool in absolute steps -static int32_t position[3]; // Initialize the motion plan subsystem void plan_init();