summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Sprinter/Configuration.h12
-rw-r--r--Sprinter/Sprinter.pde150
-rw-r--r--Sprinter/fastio.h48
-rw-r--r--Sprinter/pins.h50
4 files changed, 257 insertions, 3 deletions
diff --git a/Sprinter/Configuration.h b/Sprinter/Configuration.h
index df52a08..be42e0b 100644
--- a/Sprinter/Configuration.h
+++ b/Sprinter/Configuration.h
@@ -50,9 +50,13 @@ const bool Z_ENDSTOP_INVERT = false;
// Comment out (using // at the start of the line) to disable SD support:
#define SDSUPPORT
-
//// ADVANCED SETTINGS - to tweak parameters
+#ifdef SDSUPPORT
+ //Fast transfer chunk size (> 1024 is unstable, change at your own risk).
+ #define SD_FAST_XFER_CHUNK_SIZE 1024
+#endif
+
#include "thermistortables.h"
// For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
@@ -99,6 +103,12 @@ bool axis_relative_modes[] = {false, false, false, false};
// If you enable this, make sure STEP_DELAY_MICROS is disabled. (except for Gen6: both need to be enabled.)
//#define STEP_DELAY_RATIO 0.25
+///Oscillation reduction. Forces x,y,or z axis to be stationary for ## ms before allowing axis to switch direcitons. Alternative method to prevent skipping steps. Uncomment the line below to activate.
+//#define RAPID_OSCILLATION_REDUCTION
+#ifdef RAPID_OSCILLATION_REDUCTION
+long min_time_before_dir_change = 30; //milliseconds
+#endif
+
// Comment this to disable ramp acceleration
#define RAMP_ACCELERATION
diff --git a/Sprinter/Sprinter.pde b/Sprinter/Sprinter.pde
index 657efed..1322b30 100644
--- a/Sprinter/Sprinter.pde
+++ b/Sprinter/Sprinter.pde
@@ -91,7 +91,12 @@ float axis_diff[NUM_AXIS] = {0, 0, 0, 0};
#ifdef STEP_DELAY_RATIO
long long_step_delay_ratio = STEP_DELAY_RATIO * 100;
#endif
-
+///oscillation reduction
+ifdef RAPID_OSCILLATION_REDUCTION
+ float cumm_wait_time_in_dir[NUM_AXIS]={0.0,0.0,0.0,0.0};
+ bool prev_move_direction[NUM_AXIS]={1,1,1,1};
+ float osc_wait_remainder = 0.0;
+#endif
// comm variables
#define MAX_CMD_SIZE 96
@@ -162,6 +167,9 @@ unsigned long stepper_inactive_time = 0;
bool sdactive = false;
bool savetosd = false;
int16_t n;
+ char fastxferbuffer[SD_FAST_XFER_CHUNK_SIZE + 1];
+ int lastxferchar;
+ long xferbytes;
void initsd(){
sdactive = false;
@@ -200,6 +208,102 @@ unsigned long stepper_inactive_time = 0;
Serial.println("error writing to file");
}
}
+
+ void fast_xfer()
+ {
+ char *pstr;
+ boolean done = false;
+
+ //force heater pins low
+ if(HEATER_0_PIN > -1) WRITE(HEATER_0_PIN,LOW);
+ if(HEATER_1_PIN > -1) WRITE(HEATER_1_PIN,LOW);
+
+ lastxferchar = 1;
+ xferbytes = 0;
+
+ pstr = strstr(strchr_pointer+4, " ");
+
+ if(pstr == NULL)
+ {
+ Serial.println("invalid command");
+ return;
+ }
+
+ *pstr = '\0';
+
+ //check mode (currently only RAW is supported
+ if(strcmp(strchr_pointer+4, "RAW") != 0)
+ {
+ Serial.println("Invalid transfer codec");
+ return;
+ }else{
+ Serial.print("Selected codec: ");
+ Serial.println(strchr_pointer+4);
+ }
+
+ if (!file.open(&root, pstr+1, O_CREAT | O_APPEND | O_WRITE | O_TRUNC))
+ {
+ Serial.print("open failed, File: ");
+ Serial.print(pstr+1);
+ Serial.print(".");
+ }else{
+ Serial.print("Writing to file: ");
+ Serial.println(pstr+1);
+ }
+
+ Serial.println("ok");
+
+ //RAW transfer codec
+ //Host sends \0 then up to SD_FAST_XFER_CHUNK_SIZE then \0
+ //when host is done, it sends \0\0.
+ //if a non \0 character is recieved at the beginning, host has failed somehow, kill the transfer.
+
+ //read SD_FAST_XFER_CHUNK_SIZE bytes (or until \0 is recieved)
+ while(!done)
+ {
+ while(!Serial.available())
+ {
+ }
+ if(Serial.peek() != 0)
+ {
+ //host has failed, this isn't a RAW chunk, it's an actual command
+ file.sync();
+ file.close();
+ return;
+ }
+ //clear the initial 0
+ Serial.read();
+ for(int i=0;i<SD_FAST_XFER_CHUNK_SIZE+1;i++)
+ {
+ while(!Serial.available())
+ {
+ }
+ lastxferchar = Serial.read();
+ //buffer the data...
+ fastxferbuffer[i] = lastxferchar;
+
+ xferbytes++;
+
+ if(lastxferchar == 0)
+ break;
+ }
+
+ if(fastxferbuffer[0] != 0)
+ {
+ fastxferbuffer[SD_FAST_XFER_CHUNK_SIZE] = 0;
+ file.write(fastxferbuffer);
+ Serial.println("ok");
+ }else{
+ Serial.print("Wrote ");
+ Serial.print(xferbytes);
+ Serial.println(" bytes.");
+ done = true;
+ }
+ }
+
+ file.sync();
+ file.close();
+ }
#endif
@@ -745,6 +849,13 @@ inline void process_commands()
//processed in write to file routine above
//savetosd = false;
break;
+ case 30: //M30 - fast SD transfer
+ fast_xfer();
+ break;
+ case 31: //M31 - high speed xfer capabilities
+ Serial.print("RAW:");
+ Serial.println(SD_FAST_XFER_CHUNK_SIZE);
+ break;
#endif
case 42: //M42 -Change pin status via gcode
if (code_seen('S'))
@@ -1081,11 +1192,46 @@ void prepare_move()
time_for_move = time_for_move / max_feedrate[i] * (abs(axis_diff[i]) / (time_for_move / 60000000.0));
}
}
+
+#ifdef RAPID_OSCILLATION_REDUCTION //VERBOSE commenting for peer review. tested on multiple prints--works!
+ for(int i=0; i < NUM_AXIS-1; i++) { //do for each axis, except for extruder (refer to the -1 value)
+ if(prev_move_direction[i] != move_direction[i]){ //check if we've changed direcitons
+ osc_wait_remainder=min_time_before_dir_change; //if we changed directions, then shit the bed! We better make sure to wait & chill out time before jerkin' over in the opposite direction!
+ if(cumm_wait_time_in_dir[i]<min_time_before_dir_change){ //if so, check if we've sat @ the current position long enough for this axis
+ if((min_time_before_dir_change-cumm_wait_time_in_dir[i])>osc_wait_remainder){ //if not, dont overwrite the remaining wait time if we already have to wait LONGER for a different axis
+ osc_wait_remainder=min_time_before_dir_change-cumm_wait_time_in_dir[i];
+ }
+ }
+ cumm_wait_time_in_dir[i] = 0.0; //we've changed directions! now that we've either set a wait period, or we had already waited long enough after a direction change, let's reset our wait variable for this axis
+ }
+ else{ //we haven't changed directions! so, lets make sure to increase our wait time for the time we have not been moving back on the same axis
+ if(cumm_wait_time_in_dir[i]==0.0){
+ cumm_wait_time_in_dir[i] = 0.001; //if the cumm wait variable = 0.0, that means we've just completed our first move after a dir change. we really haven't waited at all. so, let's increment the wait value insignifcant value so that we may proceed, but not hit this line again.
+ }
+ else{
+ //Serial.print("It is will take [ESTIMATED] this many seconds to perform this move:"); Serial.println(time_for_move/1000000);
+ cumm_wait_time_in_dir[i] = cumm_wait_time_in_dir[i] + time_for_move/1000; //increment the time we've waited in this axis
+ }
+ }
+ }
+
+ //update prev_moves for next move. again, excluded extruder
+ for(int i=0; i < NUM_AXIS-1; i++) {
+ prev_move_direction[i]=move_direction[i];
+ }
+
+ //now WAIT if you are oscillating back & forth too fast in any given axis
+ if(osc_wait_remainder>0.0){
+ delay(osc_wait_remainder);
+ osc_wait_remainder=0.0;
+ }
+#endif
+
//Calculate the full speed stepper interval for each axis
for(int i=0; i < NUM_AXIS; i++) {
if(move_steps_to_take[i]) axis_interval[i] = time_for_move / move_steps_to_take[i] * 100;
}
-
+
#ifdef DEBUG_PREPARE_MOVE
log_float("_PREPARE_MOVE - Move distance on the XY plane", xy_d);
log_float("_PREPARE_MOVE - Move distance on the XYZ space", d);
diff --git a/Sprinter/fastio.h b/Sprinter/fastio.h
index 6b5572a..5f1f5d1 100644
--- a/Sprinter/fastio.h
+++ b/Sprinter/fastio.h
@@ -625,6 +625,54 @@ pins
#define DIO31_DDR DDRA
#define DIO31_PWM NULL
+#define DIO33_PIN PINA7
+#define DIO33_RPORT PINA
+#define DIO33_WPORT PORTA
+#define DIO33_DDR DDRA
+#define DIO33_PWM NULL
+
+#define DIO34_PIN PINA6
+#define DIO34_RPORT PINA
+#define DIO34_WPORT PORTA
+#define DIO34_DDR DDRA
+#define DIO34_PWM NULL
+
+#define DIO35_PIN PINA5
+#define DIO35_RPORT PINA
+#define DIO35_WPORT PORTA
+#define DIO35_DDR DDRA
+#define DIO35_PWM NULL
+
+#define DIO36_PIN PINA4
+#define DIO36_RPORT PINA
+#define DIO36_WPORT PORTA
+#define DIO36_DDR DDRA
+#define DIO36_PWM NULL
+
+#define DIO37_PIN PINA3
+#define DIO37_RPORT PINA
+#define DIO37_WPORT PORTA
+#define DIO37_DDR DDRA
+#define DIO37_PWM NULL
+
+#define DIO38_PIN PINA2
+#define DIO38_RPORT PINA
+#define DIO38_WPORT PORTA
+#define DIO38_DDR DDRA
+#define DIO38_PWM NULL
+
+#define DIO39_PIN PINA1
+#define DIO39_RPORT PINA
+#define DIO39_WPORT PORTA
+#define DIO39_DDR DDRA
+#define DIO39_PWM NULL
+
+#define DIO40_PIN PINA0
+#define DIO40_RPORT PINA
+#define DIO40_WPORT PORTA
+#define DIO40_DDR DDRA
+#define DIO40_PWM NULL
+
#define AIO0_PIN PINA0
#define AIO0_RPORT PINA
#define AIO0_WPORT PORTA
diff --git a/Sprinter/pins.h b/Sprinter/pins.h
index fbe6a6e..ed0420f 100644
--- a/Sprinter/pins.h
+++ b/Sprinter/pins.h
@@ -688,6 +688,56 @@
#endif
/****************************************************************************************
+* Gen7 pin assignment
+*
+****************************************************************************************/
+#if MOTHERBOARD == 7
+#define KNOWN_BOARD 1
+
+#if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega1284P__)
+ #error Oops! Make sure you have 'Sanguino' selected from the 'Tools -> Boards' menu.
+#endif
+
+//x axis pins
+ #define X_STEP_PIN 15
+ #define X_DIR_PIN 18
+ #define X_ENABLE_PIN 33
+ #define X_MIN_PIN 8
+ #define X_MAX_PIN 7
+
+ //y axis pins
+ #define Y_STEP_PIN 29
+ #define Y_DIR_PIN 28
+ #define Y_ENABLE_PIN 33
+ #define Y_MIN_PIN 3
+ #define Y_MAX_PIN 6
+
+ //z axis pins
+ #define Z_STEP_PIN 35
+ #define Z_DIR_PIN 34
+ #define Z_ENABLE_PIN 33
+ #define Z_MIN_PIN 2
+ #define Z_MAX_PIN 1
+
+ //extruder pins
+ #define E_STEP_PIN 37
+ #define E_DIR_PIN 36
+ #define E_ENABLE_PIN 33
+ #define TEMP_0_PIN 39 // Extruder
+ #define HEATER_0_PIN 5 // Extruder
+ #define HEATER_1_PIN 4 // Bed
+
+
+ #define SDPOWER -1
+ #define SDSS -1
+ #define LED_PIN -1
+ #define TEMP_1_PIN 38 //Bed
+ #define FAN_PIN -1
+ #define PS_ON_PIN 21
+
+#endif
+
+/****************************************************************************************
* Teensylu 0.7 pin assingments (ATMEGA90USB)
* Requires the Teensyduino software with Teensy2.0++ selected in arduino IDE!
****************************************************************************************/