Browse Source

first-commit

pull/1/head
Erik van der Zalm 14 years ago
parent
commit
26bf57e22c
  1. 43
      Marlin/Configuration.h
  2. 69
      Marlin/Marlin.pde
  3. 56
      README

43
Marlin/Configuration.h

@ -13,26 +13,6 @@
// 3 is mendel-parts thermistor // 3 is mendel-parts thermistor
#define THERMISTORHEATER 3 #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 //// Calibration variables
// X, Y, Z, E steps per unit - Metric Prusa Mendel with V9 extruder: // X, Y, Z, E steps per unit - Metric Prusa Mendel with V9 extruder:
@ -94,10 +74,10 @@ bool axis_relative_modes[] = {false, false, false, false};
//// Acceleration settings //// 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. // 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 retract_acceleration = 7000; // Normal acceleration mm/s^2
float max_jerk = 20*60; 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 // 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
@ -130,4 +110,23 @@ double Kd = 80/PID_dT;
#endif // PIDTEMP #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 #endif

69
Marlin/Marlin.pde

@ -18,10 +18,12 @@
/* /*
This firmware is a mashup between Sprinter and grbl. This firmware is a mashup between Sprinter and grbl.
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/kliment/Sprinter)
(https://github.com/simen/grbl/tree) (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
This firmware is optimized for gen6 electronics. This firmware is optimized for gen6 electronics.
*/ */
@ -35,12 +37,12 @@ char version_string[] = "0.9.0";
#ifdef SDSUPPORT #ifdef SDSUPPORT
#include "SdFat.h" #include "SdFat.h"
#endif #endif //SDSUPPORT
#ifndef CRITICAL_SECTION_START #ifndef CRITICAL_SECTION_START
#define CRITICAL_SECTION_START unsigned char _sreg = SREG; cli() #define CRITICAL_SECTION_START unsigned char _sreg = SREG; cli()
#define CRITICAL_SECTION_END SREG = _sreg #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 // look here for descriptions of gcodes: http://linuxcnc.org/handbook/gcode/g-code.html
// http://objects.reprap.org/wiki/Mendel_User_Manual:_RepRapGCodes // http://objects.reprap.org/wiki/Mendel_User_Manual:_RepRapGCodes
@ -138,18 +140,18 @@ unsigned char temp_meas_ready = false;
double pid_input; double pid_input;
double pid_output; double pid_output;
bool pid_reset; bool pid_reset;
#endif #endif //PIDTEMP
#ifdef WATCHPERIOD #ifdef WATCHPERIOD
int watch_raw = -1000; int watch_raw = -1000;
unsigned long watchmillis = 0; unsigned long watchmillis = 0;
#endif #endif //WATCHPERIOD
#ifdef MINTEMP #ifdef MINTEMP
int minttemp = temp2analogh(MINTEMP); int minttemp = temp2analogh(MINTEMP);
#endif #endif //MINTEMP
#ifdef MAXTEMP #ifdef MAXTEMP
int maxttemp = temp2analogh(MAXTEMP); int maxttemp = temp2analogh(MAXTEMP);
#endif #endif //MAXTEMP
//Inactivity shutdown variables //Inactivity shutdown variables
unsigned long previous_millis_cmd = 0; unsigned long previous_millis_cmd = 0;
@ -183,7 +185,7 @@ void initsd(){
Serial.println("openRoot failed"); Serial.println("openRoot failed");
else else
sdactive = true; sdactive = true;
#endif #endif //SDSS
} }
inline void write_command(char *buf){ inline void write_command(char *buf){
@ -205,7 +207,7 @@ inline void write_command(char *buf){
Serial.println("error writing to file"); Serial.println("error writing to file");
} }
} }
#endif #endif //SDSUPPORT
void setup() void setup()
@ -278,7 +280,7 @@ void setup()
SET_INPUT(Z_MAX_PIN); SET_INPUT(Z_MAX_PIN);
WRITE(Z_MAX_PIN,HIGH); WRITE(Z_MAX_PIN,HIGH);
#endif #endif
#else #else //ENDSTOPPULLUPS
#if X_MIN_PIN > -1 #if X_MIN_PIN > -1
SET_INPUT(X_MIN_PIN); SET_INPUT(X_MIN_PIN);
#endif #endif
@ -297,7 +299,7 @@ void setup()
#if Z_MAX_PIN > -1 #if Z_MAX_PIN > -1
SET_INPUT(Z_MAX_PIN); SET_INPUT(Z_MAX_PIN);
#endif #endif
#endif #endif //ENDSTOPPULLUPS
#if (HEATER_0_PIN > -1) #if (HEATER_0_PIN > -1)
SET_OUTPUT(HEATER_0_PIN); SET_OUTPUT(HEATER_0_PIN);
@ -333,10 +335,10 @@ void setup()
#if SDPOWER > -1 #if SDPOWER > -1
SET_OUTPUT(SDPOWER); SET_OUTPUT(SDPOWER);
WRITE(SDPOWER,HIGH); WRITE(SDPOWER,HIGH);
#endif #endif //SDPOWER
initsd(); initsd();
#endif #endif //SDSUPPORT
plan_init(); // Initialize planner; plan_init(); // Initialize planner;
st_init(); // Initialize stepper; st_init(); // Initialize stepper;
tp_init(); // Initialize temperature loop tp_init(); // Initialize temperature loop
@ -367,7 +369,7 @@ void loop()
} }
#else #else
process_commands(); process_commands();
#endif #endif //SDSUPPORT
buflen = (buflen-1); buflen = (buflen-1);
bufindr = (bufindr + 1)%BUFSIZE; bufindr = (bufindr + 1)%BUFSIZE;
} }
@ -446,7 +448,7 @@ inline void get_command()
#ifdef SDSUPPORT #ifdef SDSUPPORT
if(savetosd) if(savetosd)
break; break;
#endif #endif //SDSUPPORT
Serial.println("ok"); Serial.println("ok");
break; break;
default: default:
@ -497,7 +499,7 @@ inline void get_command()
if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char; if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char;
} }
} }
#endif #endif //SDSUPPORT
} }
@ -751,7 +753,7 @@ inline void process_commands()
//processed in write to file routine above //processed in write to file routine above
//savetosd = false; //savetosd = false;
break; break;
#endif #endif //SDSUPPORT
case 104: // M104 case 104: // M104
#ifdef PID_OPENLOOP #ifdef PID_OPENLOOP
if (code_seen('S')) PidTemp_Output = code_value() * (PID_MAX/100.0); if (code_seen('S')) PidTemp_Output = code_value() * (PID_MAX/100.0);
@ -790,7 +792,7 @@ inline void process_commands()
else{ else{
watchmillis = 0; watchmillis = 0;
} }
#endif #endif //WATCHERPERIOD
codenum = millis(); codenum = millis();
while(current_raw < target_raw) { while(current_raw < target_raw) {
if( (millis() - codenum) > 1000 ) //Print Temp Reading every 1 second while heating up. if( (millis() - codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
@ -922,7 +924,7 @@ void ClearToSend()
#ifdef SDSUPPORT #ifdef SDSUPPORT
if(fromsd[bufindr]) if(fromsd[bufindr])
return; return;
#endif #endif //SDSUPPORT
Serial.println("ok"); Serial.println("ok");
} }
@ -958,7 +960,7 @@ CRITICAL_SECTION_START;
CRITICAL_SECTION_END; CRITICAL_SECTION_END;
#ifdef PIDTEMP #ifdef PIDTEMP
pid_input = analog2temp(current_raw);//ACT pid_input = analog2temp(current_raw);
#ifndef PID_OPENLOOP #ifndef PID_OPENLOOP
pid_error = pid_setpoint - pid_input; pid_error = pid_setpoint - pid_input;
@ -1000,7 +1002,7 @@ CRITICAL_SECTION_END;
Serial.println(); Serial.println();
#endif //PID_DEBUG #endif //PID_DEBUG
OCR2B = pid_output; OCR2B = pid_output;
#endif #endif //PIDTEMP
} }
@ -1051,7 +1053,7 @@ inline void kill()
target_raw=0; target_raw=0;
#ifdef PIDTEMP #ifdef PIDTEMP
pid_setpoint = 0.0; pid_setpoint = 0.0;
#endif PIDTEMP #endif //PIDTEMP
OCR2B = 0; OCR2B = 0;
WRITE(HEATER_0_PIN,LOW); WRITE(HEATER_0_PIN,LOW);
@ -1465,7 +1467,7 @@ void plan_buffer_line(float x, float y, float z, float e, float feed_rate) {
float speed_factor = 1; float speed_factor = 1;
float tmp_speed_factor; float tmp_speed_factor;
if(abs(block->speed_x) > max_feedrate[X_AXIS]) { 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]){ if(abs(block->speed_y) > max_feedrate[Y_AXIS]){
tmp_speed_factor = max_feedrate[Y_AXIS] / abs(block->speed_y); tmp_speed_factor = max_feedrate[Y_AXIS] / abs(block->speed_y);
@ -1473,11 +1475,11 @@ void plan_buffer_line(float x, float y, float z, float e, float feed_rate) {
} }
if(abs(block->speed_z) > max_feedrate[Z_AXIS]){ if(abs(block->speed_z) > max_feedrate[Z_AXIS]){
tmp_speed_factor = max_feedrate[Z_AXIS] / abs(block->speed_z); 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]){ if(abs(block->speed_e) > max_feedrate[E_AXIS]){
tmp_speed_factor = max_feedrate[E_AXIS] / abs(block->speed_e); 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; multiplier = multiplier * speed_factor;
block->speed_z = delta_z_mm * multiplier; block->speed_z = delta_z_mm * multiplier;
@ -1910,8 +1912,6 @@ ISR(TIMER0_COMPA_vect)
// Critical section needed because Timer 1 interrupt has higher priority. // 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. // The pin set functions are placed on trategic position to comply with the stepper driver timing.
WRITE(E_STEP_PIN, LOW); WRITE(E_STEP_PIN, LOW);
// e_steps is changed in timer 1 interrupt
CRITICAL_SECTION_START;
// Set E direction (Depends on E direction + advance) // Set E direction (Depends on E direction + advance)
if (e_steps < 0) { if (e_steps < 0) {
WRITE(E_DIR_PIN,INVERT_E_DIR); WRITE(E_DIR_PIN,INVERT_E_DIR);
@ -1923,7 +1923,6 @@ ISR(TIMER0_COMPA_vect)
e_steps--; e_steps--;
WRITE(E_STEP_PIN, HIGH); WRITE(E_STEP_PIN, HIGH);
} }
CRITICAL_SECTION_END;
old_OCR0A += 25; // 10kHz interrupt old_OCR0A += 25; // 10kHz interrupt
OCR0A = old_OCR0A; OCR0A = old_OCR0A;
} }
@ -1974,7 +1973,7 @@ void tp_init()
TCCR2A = 0x23; //OC2A disable; FastPWM noninverting; FastPWM mode 7 TCCR2A = 0x23; //OC2A disable; FastPWM noninverting; FastPWM mode 7
#else #else
TCCR2A = 0x03; //OC2A disable; FastPWM noninverting; FastPWM mode 7 TCCR2A = 0x03; //OC2A disable; FastPWM noninverting; FastPWM mode 7
#endif #endif //PIDTEMP
OCR2A = 156; //Period is ~10ms OCR2A = 156; //Period is ~10ms
OCR2B = 0; //Duty Cycle for heater pin is 0 (startup) OCR2B = 0; //Duty Cycle for heater pin is 0 (startup)
TIMSK2 = 0x01; //Enable overflow interrupt TIMSK2 = 0x01; //Enable overflow interrupt
@ -2009,9 +2008,9 @@ ISR(TIMER2_OVF_vect)
OCR2B = 0; OCR2B = 0;
#else #else
WRITE(HEATER_0_PIN,LOW); WRITE(HEATER_0_PIN,LOW);
#endif #endif //PIDTEMP
} }
#endif #endif //MAXTEMP
#ifdef MINTEMP #ifdef MINTEMP
if(current_raw <= minttemp) { if(current_raw <= minttemp) {
target_raw = 0; target_raw = 0;
@ -2019,9 +2018,9 @@ ISR(TIMER2_OVF_vect)
OCR2B = 0; OCR2B = 0;
#else #else
WRITE(HEATER_0_PIN,LOW); WRITE(HEATER_0_PIN,LOW);
#endif #endif //PIDTEMP
} }
#endif #endif //MAXTEMP
#ifndef PIDTEMP #ifndef PIDTEMP
if(current_raw >= target_raw) if(current_raw >= target_raw)
{ {
@ -2031,7 +2030,7 @@ ISR(TIMER2_OVF_vect)
{ {
WRITE(HEATER_0_PIN,HIGH); WRITE(HEATER_0_PIN,HIGH);
} }
#endif #endif //PIDTEMP
} }
} }

56
README

@ -0,0 +1,56 @@
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.
Loading…
Cancel
Save