// 3 is mendel-parts thermistor
#define THERMISTORHEATER 3
-// extruder advance constant (s2/mm3)
-//
-// advance (steps) = STEPS_PER_CUBIC_MM_E * EXTUDER_ADVANCE_K * cubic mm per second ^ 2
-//
-// hooke's law says: force = k * distance
-// bernoulli's priniciple says: v ^ 2 / 2 + g . h + pressure / density = constant
-// so: v ^ 2 is proportional to number of steps we advance the extruder
-//#define ADVANCE
-
-#ifdef ADVANCE
-#define EXTRUDER_ADVANCE_K 0.02
-
-#define D_FILAMENT 1.7
-#define STEPS_MM_E 65
-//#define D_FILAMENT 2.85
-//#define STEPS_MM_E 367.35
-#define EXTRUTION_AREA (0.25 * D_FILAMENT * D_FILAMENT * 3.14159)
-#define STEPS_PER_CUBIC_MM_E (axis_steps_per_unit[E_AXIS]/ EXTRUTION_AREA)
-
-#endif // ADVANCE
//// Calibration variables
// X, Y, Z, E steps per unit - Metric Prusa Mendel with V9 extruder:
//// Acceleration settings
// X, Y, Z, E maximum start speed for accelerated moves. E default values are good for skeinforge 40+, for older versions raise them a lot.
-float acceleration = 3000; // Normal acceleration mm/s^2
+float acceleration = 2000; // Normal acceleration mm/s^2
float retract_acceleration = 7000; // Normal acceleration mm/s^2
float max_jerk = 20*60;
-long max_acceleration_units_per_sq_second[] = {7000,7000,20,10000}; // X, Y, Z and E max acceleration in mm/s^2 for printing moves or retracts
+long max_acceleration_units_per_sq_second[] = {7000,7000,100,10000}; // X, Y, Z and E max acceleration in mm/s^2 for printing moves or retracts
// Not used long max_travel_acceleration_units_per_sq_second[] = {500,500,50,500}; // X, Y, Z max acceleration in mm/s^2 for travel moves
#endif // PIDTEMP
+// extruder advance constant (s2/mm3)
+//
+// advance (steps) = STEPS_PER_CUBIC_MM_E * EXTUDER_ADVANCE_K * cubic mm per second ^ 2
+//
+// hooke's law says: force = k * distance
+// bernoulli's priniciple says: v ^ 2 / 2 + g . h + pressure / density = constant
+// so: v ^ 2 is proportional to number of steps we advance the extruder
+//#define ADVANCE
+
+#ifdef ADVANCE
+#define EXTRUDER_ADVANCE_K 0.02
+
+#define D_FILAMENT 1.7
+#define STEPS_MM_E 65
+#define EXTRUTION_AREA (0.25 * D_FILAMENT * D_FILAMENT * 3.14159)
+#define STEPS_PER_CUBIC_MM_E (axis_steps_per_unit[E_AXIS]/ EXTRUTION_AREA)
+
+#endif // ADVANCE
+
#endif
/*
This firmware is a mashup between Sprinter and grbl.
+ (https://github.com/kliment/Sprinter)
+ (https://github.com/simen/grbl/tree)
+
It has preliminary support for Matthew Roberts advance algorithm
http://reprap.org/pipermail/reprap-dev/2011-May/003323.html
- (https://github.com/kliment/Sprinter)
- (https://github.com/simen/grbl/tree)
+
This firmware is optimized for gen6 electronics.
*/
#ifdef SDSUPPORT
#include "SdFat.h"
-#endif
+#endif //SDSUPPORT
#ifndef CRITICAL_SECTION_START
#define CRITICAL_SECTION_START unsigned char _sreg = SREG; cli()
#define CRITICAL_SECTION_END SREG = _sreg
-#endif
+#endif //CRITICAL_SECTION_START
// look here for descriptions of gcodes: http://linuxcnc.org/handbook/gcode/g-code.html
// http://objects.reprap.org/wiki/Mendel_User_Manual:_RepRapGCodes
double pid_input;
double pid_output;
bool pid_reset;
-#endif
+#endif //PIDTEMP
#ifdef WATCHPERIOD
int watch_raw = -1000;
unsigned long watchmillis = 0;
-#endif
+#endif //WATCHPERIOD
#ifdef MINTEMP
int minttemp = temp2analogh(MINTEMP);
-#endif
+#endif //MINTEMP
#ifdef MAXTEMP
int maxttemp = temp2analogh(MAXTEMP);
-#endif
+#endif //MAXTEMP
//Inactivity shutdown variables
unsigned long previous_millis_cmd = 0;
Serial.println("openRoot failed");
else
sdactive = true;
-#endif
+#endif //SDSS
}
inline void write_command(char *buf){
Serial.println("error writing to file");
}
}
-#endif
+#endif //SDSUPPORT
void setup()
SET_INPUT(Z_MAX_PIN);
WRITE(Z_MAX_PIN,HIGH);
#endif
-#else
+#else //ENDSTOPPULLUPS
#if X_MIN_PIN > -1
SET_INPUT(X_MIN_PIN);
#endif
#if Z_MAX_PIN > -1
SET_INPUT(Z_MAX_PIN);
#endif
-#endif
+#endif //ENDSTOPPULLUPS
#if (HEATER_0_PIN > -1)
SET_OUTPUT(HEATER_0_PIN);
#if SDPOWER > -1
SET_OUTPUT(SDPOWER);
WRITE(SDPOWER,HIGH);
-#endif
+#endif //SDPOWER
initsd();
-#endif
+#endif //SDSUPPORT
plan_init(); // Initialize planner;
st_init(); // Initialize stepper;
tp_init(); // Initialize temperature loop
}
#else
process_commands();
-#endif
+#endif //SDSUPPORT
buflen = (buflen-1);
bufindr = (bufindr + 1)%BUFSIZE;
}
#ifdef SDSUPPORT
if(savetosd)
break;
-#endif
+#endif //SDSUPPORT
Serial.println("ok");
break;
default:
if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char;
}
}
-#endif
+#endif //SDSUPPORT
}
//processed in write to file routine above
//savetosd = false;
break;
-#endif
+#endif //SDSUPPORT
case 104: // M104
#ifdef PID_OPENLOOP
if (code_seen('S')) PidTemp_Output = code_value() * (PID_MAX/100.0);
else{
watchmillis = 0;
}
-#endif
+#endif //WATCHERPERIOD
codenum = millis();
while(current_raw < target_raw) {
if( (millis() - codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
#ifdef SDSUPPORT
if(fromsd[bufindr])
return;
-#endif
+#endif //SDSUPPORT
Serial.println("ok");
}
CRITICAL_SECTION_END;
#ifdef PIDTEMP
- pid_input = analog2temp(current_raw);//ACT
+ pid_input = analog2temp(current_raw);
#ifndef PID_OPENLOOP
pid_error = pid_setpoint - pid_input;
Serial.println();
#endif //PID_DEBUG
OCR2B = pid_output;
-#endif
+#endif //PIDTEMP
}
target_raw=0;
#ifdef PIDTEMP
pid_setpoint = 0.0;
-#endif PIDTEMP
+#endif //PIDTEMP
OCR2B = 0;
WRITE(HEATER_0_PIN,LOW);
float speed_factor = 1;
float tmp_speed_factor;
if(abs(block->speed_x) > max_feedrate[X_AXIS]) {
- speed_factor = max_feedrate[Y_AXIS] / abs(block->speed_x);
+ speed_factor = max_feedrate[X_AXIS] / abs(block->speed_x);
}
if(abs(block->speed_y) > max_feedrate[Y_AXIS]){
tmp_speed_factor = max_feedrate[Y_AXIS] / abs(block->speed_y);
}
if(abs(block->speed_z) > max_feedrate[Z_AXIS]){
tmp_speed_factor = max_feedrate[Z_AXIS] / abs(block->speed_z);
- if(tmp_speed_factor < speed_factor) speed_factor = tmp_speed_factor;
+ if(speed_factor > tmp_speed_factor) speed_factor = tmp_speed_factor;
}
if(abs(block->speed_e) > max_feedrate[E_AXIS]){
tmp_speed_factor = max_feedrate[E_AXIS] / abs(block->speed_e);
- if(tmp_speed_factor < speed_factor) speed_factor = tmp_speed_factor;
+ if(speed_factor > tmp_speed_factor) speed_factor = tmp_speed_factor;
}
multiplier = multiplier * speed_factor;
block->speed_z = delta_z_mm * multiplier;
// Critical section needed because Timer 1 interrupt has higher priority.
// The pin set functions are placed on trategic position to comply with the stepper driver timing.
WRITE(E_STEP_PIN, LOW);
- // e_steps is changed in timer 1 interrupt
- CRITICAL_SECTION_START;
// Set E direction (Depends on E direction + advance)
if (e_steps < 0) {
WRITE(E_DIR_PIN,INVERT_E_DIR);
e_steps--;
WRITE(E_STEP_PIN, HIGH);
}
- CRITICAL_SECTION_END;
old_OCR0A += 25; // 10kHz interrupt
OCR0A = old_OCR0A;
}
TCCR2A = 0x23; //OC2A disable; FastPWM noninverting; FastPWM mode 7
#else
TCCR2A = 0x03; //OC2A disable; FastPWM noninverting; FastPWM mode 7
-#endif
+#endif //PIDTEMP
OCR2A = 156; //Period is ~10ms
OCR2B = 0; //Duty Cycle for heater pin is 0 (startup)
TIMSK2 = 0x01; //Enable overflow interrupt
OCR2B = 0;
#else
WRITE(HEATER_0_PIN,LOW);
-#endif
+#endif //PIDTEMP
}
-#endif
+#endif //MAXTEMP
#ifdef MINTEMP
if(current_raw <= minttemp) {
target_raw = 0;
OCR2B = 0;
#else
WRITE(HEATER_0_PIN,LOW);
-#endif
+#endif //PIDTEMP
}
-#endif
+#endif //MAXTEMP
#ifndef PIDTEMP
if(current_raw >= target_raw)
{
{
WRITE(HEATER_0_PIN,HIGH);
}
-#endif
+#endif //PIDTEMP
}
}
+This firmware is a mashup between Sprinter, grbl and many original parts.
+ (https://github.com/kliment/Sprinter)
+ (https://github.com/simen/grbl/tree)
+
+Features:
+ - Interrupt based movement with real linear acceleration
+ - High steprate
+ - Look ahead (Keep the speed high when possible. High cornering speed)
+ - Interrupt based temperature protection
+ - preliminary support for Matthew Roberts advance algorithm
+ For more info see: http://reprap.org/pipermail/reprap-dev/2011-May/003323.html
+
+This firmware is optimized for gen6 electronics.
+
+The default baudrate is 250000.
+This gives less communication errors then regular baudrates.
+
+========================================================================================
+
+Configuring and compilation
+
+
+Install the arduino software version 0018
+ http://www.arduino.cc/en/Main/Software
+
+Install the sanguino software, version 0018
+ http://sanguino.cc/useit
+
+Install pronterface
+ https://github.com/kliment/Printrun
+
+Copy the Marlin firmware
+ https:/github.com/ErikZalm/Marlin
+ (Use the download button)
+
+Start the arduino IDE.
+Select Tools -> Board -> Sanguino
+Select the correct serial port in Tools ->Serial Port
+Open Marlin.pde
+
+Change the printer specific setting in Configuration.h to the correct values.
+
+The following values are the most important:
+ - float axis_steps_per_unit[].... // Set the correct steps / mm in the corresponding field
+ - const bool ENDSTOPS_INVERTING = false; // Change if only positive moves are executed
+ - #define INVERT_x_DIR true // Change if the motor direction is wrong
+
+Click the Upload button
+If all goes well the firmware is uploading
+
+Start pronterface
+
+Select the correct Serial Port. Type 250000 in the baudrate field.
+Press the Connect button.
+
+