Skip to content

Commit

Permalink
Merged multiple extruder support.
Browse files Browse the repository at this point in the history
Soft PWM. (Sanguinololu can also have PID temperature control)
Interrupt save WRITE for addresses > 0x0FF
  • Loading branch information
ErikZalm committed Dec 12, 2011
1 parent 3664ed6 commit e017228
Show file tree
Hide file tree
Showing 11 changed files with 5,525 additions and 5,413 deletions.
95 changes: 49 additions & 46 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@


// This determines the communication speed of the printer
//#define BAUDRATE 250000
#define BAUDRATE 115200
#define BAUDRATE 250000
//#define BAUDRATE 115200
//#define BAUDRATE 230400

#define EXTRUDERS 2
#define EXTRUDERS 1

// Frequency limit
// See nophead's blog for more info
Expand All @@ -32,7 +32,7 @@
// Sanguinololu 1.2 and above = 62
// Ultimaker = 7,
// Teensylu = 8
#define MOTHERBOARD 33
#define MOTHERBOARD 7

//===========================================================================
//=============================Thermal Settings ============================
Expand All @@ -46,16 +46,21 @@
// 5 is ParCan supplied 104GT-2 100K
// 6 is EPCOS 100k
// 7 is 100k Honeywell thermistor 135-104LAG-J01
#define THERMISTORHEATER_0 1
#define THERMISTORHEATER_1 1
#define HEATER_0_USES_THERMISTOR
#define HEATER_1_USES_THERMISTOR
//#define HEATER_0_USES_AD595

//#define THERMISTORHEATER_0 3
//#define THERMISTORHEATER_1 1
//#define THERMISTORHEATER_2 1

//#define HEATER_0_USES_THERMISTOR
//#define HEATER_1_USES_THERMISTOR
//#define HEATER_2_USES_THERMISTOR
#define HEATER_0_USES_AD595
//#define HEATER_1_USES_AD595
//#define HEATER_2_USES_AD595

// Select one of these only to define how the bed temp is read.
#define THERMISTORBED 1
#define BED_USES_THERMISTOR
//#define THERMISTORBED 1
//#define BED_USES_THERMISTOR
//#define BED_USES_AD595

#define BED_CHECK_INTERVAL 5000 //ms
Expand All @@ -73,15 +78,17 @@
//// The minimal temperature defines the temperature below which the heater will not be enabled
#define HEATER_0_MINTEMP 5
//#define HEATER_1_MINTEMP 5
#define BED_MINTEMP 5
//#define HEATER_2_MINTEMP 5
//#define BED_MINTEMP 5


// When temperature exceeds max temp, your heater will be switched off.
// This feature exists to protect your hotend from overheating accidentally, but *NOT* from thermistor short/failure!
// You should use MINTEMP for thermistor short/failure protection.
#define HEATER_0_MAXTEMP 275
//#define HEATER_1_MAXTEMP 275
#define BED_MAXTEMP 150
//#define HEATER_2_MAXTEMP 275
//#define BED_MAXTEMP 150


// Wait for Cooldown
Expand All @@ -92,21 +99,17 @@

// Heating is finished if a temperature close to this degree shift is reached
#define HEATING_EARLY_FINISH_DEG_OFFSET 1 //Degree

// PID settings:
// Uncomment the following line to enable PID support.

#define PIDTEMP
#define PID_MAX 255 // limits current to nozzle; 255=full current
#ifdef PIDTEMP
#if MOTHERBOARD == 62
#error Sanguinololu does not support PID, sorry. Please disable it.
#endif
//#define PID_DEBUG // Sends debug data to the serial port.
//#define PID_OPENLOOP 1 // Puts PID in open loop. M104 sets the output power in %

#define PID_MAX 255 // limits current to nozzle; 255=full current
#define PID_INTEGRAL_DRIVE_MAX 255 //limit for the integral term
#define K1 0.95 //smoothing factor withing the PID
#define PID_dT 0.1 //sampling period of the PID
#define PID_dT 0.128 //sampling period of the PID

//To develop some PID settings for your machine, you can initiall follow
// the Ziegler-Nichols method.
Expand All @@ -130,14 +133,14 @@
// #define DEFAULT_Kd (PID_SWING_AT_CRITIAL/8./PID_dT)

// Ultitmaker
// #define DEFAULT_Kp 22.2
// #define DEFAULT_Ki (1.25*PID_dT)
// #define DEFAULT_Kd (99/PID_dT)
#define DEFAULT_Kp 22.2
#define DEFAULT_Ki (1.25*PID_dT)
#define DEFAULT_Kd (99/PID_dT)

// Makergear
#define DEFAULT_Kp 7.0
#define DEFAULT_Ki 0.1
#define DEFAULT_Kd 12
// #define DEFAULT_Kp 7.0
// #define DEFAULT_Ki 0.1
// #define DEFAULT_Kd 12

// Mendel Parts V9 on 12V
// #define DEFAULT_Kp 63.0
Expand Down Expand Up @@ -170,12 +173,12 @@
#define ENDSTOPPULLUPS // Comment this out (using // at the start of the line) to disable the endstop pullup resistors

// The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins.
const bool X_ENDSTOPS_INVERTING = false; // set to true to invert the logic of the endstops.
const bool Y_ENDSTOPS_INVERTING = false; // set to true to invert the logic of the endstops.
const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of the endstops.
const bool X_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
const bool Y_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
// For optos H21LOB set to true, for Mendel-Parts newer optos TCST2103 set to false

//#define ENDSTOPS_ONLY_FOR_HOMING // If defined the endstops will only be used for homing
#define ENDSTOPS_ONLY_FOR_HOMING // If defined the endstops will only be used for homing

// For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
#define X_ENABLE_ON 0
Expand All @@ -186,7 +189,7 @@ const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of t
// Disables axis when it's not being used.
#define DISABLE_X false
#define DISABLE_Y false
#define DISABLE_Z true
#define DISABLE_Z false
#define DISABLE_E false // For all extruders

// Inverting axis direction
Expand All @@ -195,11 +198,11 @@ const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of t
//#define INVERT_Z_DIR false // for Mendel set to false, for Orca set to true
//#define INVERT_E*_DIR true // for direct drive extruder v9 set to true, for geared extruder set to false, used for all extruders

#define INVERT_X_DIR false // for Mendel set to false, for Orca set to true
#define INVERT_X_DIR true // for Mendel set to false, for Orca set to true
#define INVERT_Y_DIR false // for Mendel set to true, for Orca set to false
#define INVERT_Z_DIR true // for Mendel set to false, for Orca set to true
#define INVERT_E0_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_E1_DIR true // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_E1_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_E2_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false

//// ENDSTOP SETTINGS:
Expand All @@ -208,15 +211,15 @@ const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of t
#define Y_HOME_DIR -1
#define Z_HOME_DIR -1

#define min_software_endstops false //If true, axis won't move to coordinates less than zero.
#define max_software_endstops false //If true, axis won't move to coordinates greater than the defined lengths below.
#define X_MAX_LENGTH 210
#define Y_MAX_LENGTH 210
#define Z_MAX_LENGTH 210
#define min_software_endstops true //If true, axis won't move to coordinates less than zero.
#define max_software_endstops true //If true, axis won't move to coordinates greater than the defined lengths below.
#define X_MAX_LENGTH 205
#define Y_MAX_LENGTH 205
#define Z_MAX_LENGTH 200

//// MOVEMENT SETTINGS
#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
#define HOMING_FEEDRATE {30*60, 30*60, 2*60, 0} // set the homing speeds (mm/min)
#define HOMING_FEEDRATE {50*60, 50*60, 4*60, 0} // set the homing speeds (mm/min)

//homing hits the endstop, then retracts by this distance, before it tries to slowly bump again:
#define X_HOME_RETRACT_MM 5
Expand All @@ -230,9 +233,9 @@ const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of t

// default settings

//#define DEFAULT_AXIS_STEPS_PER_UNIT {78.7402,78.7402,200*8/3,760*1.1} // default steps per unit for ultimaker
//#define DEFAULT_AXIS_STEPS_PER_UNIT {40, 40, 3333.92, 67} //sells mendel with v9 extruder
#define DEFAULT_AXIS_STEPS_PER_UNIT {80.3232, 80.8900, 2284.7651, 757.2218} // SAE Prusa w/ Wade extruder
#define DEFAULT_AXIS_STEPS_PER_UNIT {78.7402,78.7402,200*8/3,760*1.1} // default steps per unit for ultimaker
//#define DEFAULT_AXIS_STEPS_PER_UNIT {40, 40, 3333.92, 360} //sells mendel with v9 extruder
//#define DEFAULT_AXIS_STEPS_PER_UNIT {80.3232, 80.8900, 2284.7651, 757.2218} // SAE Prusa w/ Wade extruder
#define DEFAULT_MAX_FEEDRATE {500, 500, 5, 45} // (mm/sec)
#define DEFAULT_MAX_ACCELERATION {9000,9000,100,10000} // 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.

Expand Down Expand Up @@ -283,10 +286,10 @@ const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of t
// 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
#define ADVANCE

#ifdef ADVANCE
#define EXTRUDER_ADVANCE_K .3
#define EXTRUDER_ADVANCE_K .0

#define D_FILAMENT 2.85
#define STEPS_MM_E 836
Expand All @@ -298,10 +301,10 @@ const bool Z_ENDSTOPS_INVERTING = false; // set to true to invert the logic of t

//LCD and SD support
//#define ULTRA_LCD //general lcd support, also 16x2
#define SDSUPPORT // Enable SD Card Support in Hardware Console
//#define SDSUPPORT // Enable SD Card Support in Hardware Console
#define SD_FINISHED_STEPPERRELEASE true //if sd support and the file is finished: disable steppers?

//#define ULTIPANEL
#define ULTIPANEL
#ifdef ULTIPANEL
//#define NEWPANEL //enable this if you have a click-encoder panel
#define SDSUPPORT
Expand Down
2 changes: 0 additions & 2 deletions Marlin/Marlin.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ const prog_char echomagic[] PROGMEM ="echo:";

#define SERIAL_ECHOPAIR(name,value) {SERIAL_ECHOPGM(name);SERIAL_ECHO(value);}

// Macro for getting current active extruder
#define ACTIVE_EXTRUDER (active_extruder)

//things to write to serial from Programmemory. saves 400 to 2k of RAM.
#define SerialprintPGM(x) serialprintPGM(MYPGM(x))
Expand Down
46 changes: 27 additions & 19 deletions Marlin/Marlin.pde
Original file line number Diff line number Diff line change
Expand Up @@ -465,16 +465,16 @@ FORCE_INLINE bool code_seen(char code)
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); \
destination[LETTER##_AXIS] = 1.5 * LETTER##_MAX_LENGTH * LETTER##_HOME_DIR; \
feedrate = homing_feedrate[LETTER##_AXIS]; \
prepare_move(); \
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); \
\
current_position[LETTER##_AXIS] = 0;\
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);\
destination[LETTER##_AXIS] = -LETTER##_HOME_RETRACT_MM * LETTER##_HOME_DIR;\
prepare_move(); \
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); \
\
destination[LETTER##_AXIS] = 2*LETTER##_HOME_RETRACT_MM * LETTER##_HOME_DIR;\
feedrate = homing_feedrate[LETTER##_AXIS]/2 ; \
prepare_move(); \
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); \
\
current_position[LETTER##_AXIS] = (LETTER##_HOME_DIR == -1) ? 0 : LETTER##_MAX_LENGTH;\
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);\
Expand Down Expand Up @@ -541,6 +541,7 @@ FORCE_INLINE void process_commands()
if( code_seen(axis_codes[0]) && code_seen(axis_codes[1]) ) //first diagonal move
{
current_position[X_AXIS] = 0; current_position[Y_AXIS] = 0;

plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
destination[X_AXIS] = 1.5 * X_MAX_LENGTH * X_HOME_DIR;
destination[Y_AXIS] = 1.5 * Y_MAX_LENGTH * Y_HOME_DIR;
Expand Down Expand Up @@ -723,7 +724,7 @@ FORCE_INLINE void process_commands()
if (code_seen('S')) setTargetBed(code_value());
break;
case 105 : // M105
tmp_extruder = ACTIVE_EXTRUDER;
tmp_extruder = active_extruder;
if(code_seen('T')) {
tmp_extruder = code_value();
if(tmp_extruder >= EXTRUDERS) {
Expand All @@ -743,6 +744,10 @@ FORCE_INLINE void process_commands()
#else
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM("No thermistors - no temp");
#endif
#ifdef PIDTEMP
SERIAL_PROTOCOLPGM(" @:");
SERIAL_PROTOCOL(getHeaterPower(tmp_extruder));
#endif
SERIAL_PROTOCOLLN("");
return;
Expand Down Expand Up @@ -788,24 +793,26 @@ FORCE_INLINE void process_commands()
while((residencyStart == -1) ||
(residencyStart > -1 && (millis() - residencyStart) < TEMP_RESIDENCY_TIME*1000) ) {
#else
while ( target_direction ? (isHeatingHotend(tmp_extruder)) : (isCoolingHotend(tmp_extruder)&&(CooldownNoWait==false)) ) {
while ( target_direction ? (isHeatingHotend(tmp_extruder)) : (isCoolingHotend(tmp_extruder)&&(CooldownNoWait==false)) ) {
#endif //TEMP_RESIDENCY_TIME
if( (millis() - codenum) > 1000 )
{ //Print Temp Reading and remaining time every 1 second while heating up/cooling down
SERIAL_PROTOCOLPGM("T:");
SERIAL_PROTOCOLLN( degHotend(tmp_extruder) );
SERIAL_PROTOCOL( degHotend(tmp_extruder) );
SERIAL_PROTOCOLPGM(" E:");
SERIAL_PROTOCOLLN( (int)tmp_extruder );
SERIAL_PROTOCOLPGM(" W:");
if(residencyStart > -1)
{
codenum = TEMP_RESIDENCY_TIME - ((millis() - residencyStart) / 1000);
SERIAL_PROTOCOLLN( codenum );
}
else
{
SERIAL_PROTOCOLLN( "?" );
}
#ifdef TEMP_RESIDENCY_TIME
SERIAL_PROTOCOLPGM(" W:");
if(residencyStart > -1)
{
codenum = TEMP_RESIDENCY_TIME - ((millis() - residencyStart) / 1000);
SERIAL_PROTOCOLLN( codenum );
}
else
{
SERIAL_PROTOCOLLN( "?" );
}
#endif
codenum = millis();
}
manage_heater();
Expand Down Expand Up @@ -834,11 +841,11 @@ FORCE_INLINE void process_commands()
{
if( (millis()-codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
{
float tt=degHotend(ACTIVE_EXTRUDER);
float tt=degHotend(active_extruder);
SERIAL_PROTOCOLPGM("T:");
SERIAL_PROTOCOL(tt);
SERIAL_PROTOCOLPGM(" E:");
SERIAL_PROTOCOLLN( (int)tmp_extruder );
SERIAL_PROTOCOLLN( (int)active_extruder );
SERIAL_PROTOCOLPGM(" B:");
SERIAL_PROTOCOLLN(degBed());
codenum = millis();
Expand Down Expand Up @@ -1191,6 +1198,7 @@ void manage_inactivity(byte debug)

void kill()
{
cli(); // Stop interrupts
disable_heater();

disable_x();
Expand All @@ -1207,4 +1215,4 @@ void kill()
while(1); // Wait for reset
}



Loading

0 comments on commit e017228

Please sign in to comment.