From f5c05d94393b79d52b9ada67fe4bdffa3c39da52 Mon Sep 17 00:00:00 2001 From: Chris Dieringer Date: Sun, 6 Nov 2011 07:57:57 -0800 Subject: osc reduction --- Sprinter/Sprinter.pde | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) (limited to 'Sprinter/Sprinter.pde') diff --git a/Sprinter/Sprinter.pde b/Sprinter/Sprinter.pde index 657efed..bc8a2ac 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 @@ -1081,11 +1086,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]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); -- cgit v1.2.1 From d196068a8ca3d47ec9f92525644b12fb70aeb29b Mon Sep 17 00:00:00 2001 From: Philip Kin Date: Wed, 16 Nov 2011 09:16:14 -0600 Subject: M30/M31 fast sd block transfer --- Sprinter/Sprinter.pde | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) (limited to 'Sprinter/Sprinter.pde') diff --git a/Sprinter/Sprinter.pde b/Sprinter/Sprinter.pde index bc8a2ac..b189744 100644 --- a/Sprinter/Sprinter.pde +++ b/Sprinter/Sprinter.pde @@ -167,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; @@ -205,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) + { + SerialMgr.cur()->println("invalid command"); + return; + } + + *pstr = '\0'; + + //check mode (currently only RAW is supported + if(strcmp(strchr_pointer+4, "RAW") != 0) + { + SerialMgr.cur()->println("Invalid transfer codec"); + return; + }else{ + SerialMgr.cur()->print("Selected codec: "); + SerialMgr.cur()->println(strchr_pointer+4); + } + + if (!file.open(&root, pstr+1, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)) + { + SerialMgr.cur()->print("open failed, File: "); + SerialMgr.cur()->print(pstr+1); + SerialMgr.cur()->print("."); + }else{ + SerialMgr.cur()->print("Writing to file: "); + SerialMgr.cur()->println(pstr+1); + } + + SerialMgr.cur()->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(!SerialMgr.cur()->available()) + { + } + if(SerialMgr.cur()->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 + SerialMgr.cur()->read(); + for(int i=0;iavailable()) + { + } + lastxferchar = SerialMgr.cur()->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); + SerialMgr.cur()->println("ok"); + }else{ + SerialMgr.cur()->print("Wrote "); + SerialMgr.cur()->print(xferbytes); + SerialMgr.cur()->println(" bytes."); + done = true; + } + } + + file.sync(); + file.close(); + } #endif @@ -750,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 + SerialMgr.cur()->print("RAW:"); + SerialMgr.cur()->println(SD_FAST_XFER_CHUNK_SIZE); + break; #endif case 42: //M42 -Change pin status via gcode if (code_seen('S')) -- cgit v1.2.1 From fa1a0e7def0c3c0049953639cc17b8a21e8da163 Mon Sep 17 00:00:00 2001 From: Philip Kin Date: Wed, 16 Nov 2011 09:17:33 -0600 Subject: M30/M31 fast sd block transfer --- Sprinter/Sprinter.pde | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'Sprinter/Sprinter.pde') diff --git a/Sprinter/Sprinter.pde b/Sprinter/Sprinter.pde index b189744..1322b30 100644 --- a/Sprinter/Sprinter.pde +++ b/Sprinter/Sprinter.pde @@ -225,7 +225,7 @@ unsigned long stepper_inactive_time = 0; if(pstr == NULL) { - SerialMgr.cur()->println("invalid command"); + Serial.println("invalid command"); return; } @@ -234,24 +234,24 @@ unsigned long stepper_inactive_time = 0; //check mode (currently only RAW is supported if(strcmp(strchr_pointer+4, "RAW") != 0) { - SerialMgr.cur()->println("Invalid transfer codec"); + Serial.println("Invalid transfer codec"); return; }else{ - SerialMgr.cur()->print("Selected codec: "); - SerialMgr.cur()->println(strchr_pointer+4); + Serial.print("Selected codec: "); + Serial.println(strchr_pointer+4); } if (!file.open(&root, pstr+1, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)) { - SerialMgr.cur()->print("open failed, File: "); - SerialMgr.cur()->print(pstr+1); - SerialMgr.cur()->print("."); + Serial.print("open failed, File: "); + Serial.print(pstr+1); + Serial.print("."); }else{ - SerialMgr.cur()->print("Writing to file: "); - SerialMgr.cur()->println(pstr+1); + Serial.print("Writing to file: "); + Serial.println(pstr+1); } - SerialMgr.cur()->println("ok"); + Serial.println("ok"); //RAW transfer codec //Host sends \0 then up to SD_FAST_XFER_CHUNK_SIZE then \0 @@ -261,10 +261,10 @@ unsigned long stepper_inactive_time = 0; //read SD_FAST_XFER_CHUNK_SIZE bytes (or until \0 is recieved) while(!done) { - while(!SerialMgr.cur()->available()) + while(!Serial.available()) { } - if(SerialMgr.cur()->peek() != 0) + if(Serial.peek() != 0) { //host has failed, this isn't a RAW chunk, it's an actual command file.sync(); @@ -272,13 +272,13 @@ unsigned long stepper_inactive_time = 0; return; } //clear the initial 0 - SerialMgr.cur()->read(); + Serial.read(); for(int i=0;iavailable()) + while(!Serial.available()) { } - lastxferchar = SerialMgr.cur()->read(); + lastxferchar = Serial.read(); //buffer the data... fastxferbuffer[i] = lastxferchar; @@ -292,11 +292,11 @@ unsigned long stepper_inactive_time = 0; { fastxferbuffer[SD_FAST_XFER_CHUNK_SIZE] = 0; file.write(fastxferbuffer); - SerialMgr.cur()->println("ok"); + Serial.println("ok"); }else{ - SerialMgr.cur()->print("Wrote "); - SerialMgr.cur()->print(xferbytes); - SerialMgr.cur()->println(" bytes."); + Serial.print("Wrote "); + Serial.print(xferbytes); + Serial.println(" bytes."); done = true; } } @@ -853,8 +853,8 @@ inline void process_commands() fast_xfer(); break; case 31: //M31 - high speed xfer capabilities - SerialMgr.cur()->print("RAW:"); - SerialMgr.cur()->println(SD_FAST_XFER_CHUNK_SIZE); + Serial.print("RAW:"); + Serial.println(SD_FAST_XFER_CHUNK_SIZE); break; #endif case 42: //M42 -Change pin status via gcode -- cgit v1.2.1 From 49c5c65dcf22941e581b89307730cc6f450fea1f Mon Sep 17 00:00:00 2001 From: Greg Dahlman Date: Tue, 6 Dec 2011 12:30:56 -0800 Subject: Fix ifdef with missing # in Sprinter.pde and add 644 non P to the Gen 7 board in pins.h --- Sprinter/Sprinter.pde | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Sprinter/Sprinter.pde') diff --git a/Sprinter/Sprinter.pde b/Sprinter/Sprinter.pde index 1322b30..c8acc67 100644 --- a/Sprinter/Sprinter.pde +++ b/Sprinter/Sprinter.pde @@ -92,7 +92,7 @@ float axis_diff[NUM_AXIS] = {0, 0, 0, 0}; long long_step_delay_ratio = STEP_DELAY_RATIO * 100; #endif ///oscillation reduction -ifdef RAPID_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; -- cgit v1.2.1 From e7fb583df933a7012f2c42d84375b99ced0202c4 Mon Sep 17 00:00:00 2001 From: blddk Date: Sun, 22 Jan 2012 15:27:27 +0100 Subject: Added option to set a delay after enabeling stepper driver, to allow the driver to enable (time needed according to datasheet) --- Sprinter/Sprinter.pde | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'Sprinter/Sprinter.pde') diff --git a/Sprinter/Sprinter.pde b/Sprinter/Sprinter.pde index c8acc67..5387923 100644 --- a/Sprinter/Sprinter.pde +++ b/Sprinter/Sprinter.pde @@ -1284,10 +1284,33 @@ inline void linear_move(unsigned long axis_steps_remaining[]) // make linear mov //Only enable axis that are moving. If the axis doesn't need to move then it can stay disabled depending on configuration. // TODO: maybe it's better to refactor into a generic enable(int axis) function, that will probably take more ram, // but will reduce code size +#ifdef DELAY_ENABLE + if(axis_steps_remaining[0]) + { + enable_x(); + delayMicroseconds(DELAY_ENABLE); + } + if(axis_steps_remaining[1]) + { + enable_y(); + delayMicroseconds(DELAY_ENABLE); + } + if(axis_steps_remaining[2]) + { + enable_z(); + delayMicroseconds(DELAY_ENABLE); + } + if(axis_steps_remaining[3]) + { + enable_e(); + delayMicroseconds(DELAY_ENABLE); + } +#else if(axis_steps_remaining[0]) enable_x(); if(axis_steps_remaining[1]) enable_y(); if(axis_steps_remaining[2]) enable_z(); if(axis_steps_remaining[3]) enable_e(); +#endif //Define variables that are needed for the Bresenham algorithm. Please note that Z is not currently included in the Bresenham algorithm. unsigned long delta[] = {axis_steps_remaining[0], axis_steps_remaining[1], axis_steps_remaining[2], axis_steps_remaining[3]}; //TODO: implement a "for" to support N axes -- cgit v1.2.1 From d8b6c5f233e905dbb5282a255dddd68deb1c3d7f Mon Sep 17 00:00:00 2001 From: blddk Date: Sun, 22 Jan 2012 15:43:51 +0100 Subject: Changed temperature table for bed, to the one for the bed, instead of for the heater. --- Sprinter/Sprinter.pde | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Sprinter/Sprinter.pde') diff --git a/Sprinter/Sprinter.pde b/Sprinter/Sprinter.pde index 5387923..e793891 100644 --- a/Sprinter/Sprinter.pde +++ b/Sprinter/Sprinter.pde @@ -971,7 +971,7 @@ inline void process_commands() break; case 190: // M190 - Wait bed for heater to reach target. #if TEMP_1_PIN > -1 - if (code_seen('S')) target_bed_raw = temp2analogh(code_value()); + if (code_seen('S')) target_bed_raw = temp2analogBed(code_value()); codenum = millis(); while(current_bed_raw < target_bed_raw) { if( (millis()-codenum) > 1000 ) //Print Temp Reading every 1 second while heating up. -- cgit v1.2.1 From 908bc5314ca92dd673509e7a60e371752692be4b Mon Sep 17 00:00:00 2001 From: blddk Date: Sun, 22 Jan 2012 21:51:56 +0100 Subject: Reported wrong temperature while heating up --- Sprinter/Sprinter.pde | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Sprinter/Sprinter.pde') diff --git a/Sprinter/Sprinter.pde b/Sprinter/Sprinter.pde index e793891..874c333 100644 --- a/Sprinter/Sprinter.pde +++ b/Sprinter/Sprinter.pde @@ -980,7 +980,7 @@ inline void process_commands() Serial.print("T:"); Serial.print( tt ); Serial.print(" B:"); - Serial.println( analog2temp(current_bed_raw) ); + Serial.println(analog2tempBed(current_bed_raw)); codenum = millis(); } manage_heater(); -- cgit v1.2.1