First parts 2nd extruder
This commit is contained in:
parent
a0dc66f7bf
commit
aad4b75b94
@ -8,6 +8,7 @@
|
|||||||
//#define BAUDRATE 115200
|
//#define BAUDRATE 115200
|
||||||
//#define BAUDRATE 230400
|
//#define BAUDRATE 230400
|
||||||
|
|
||||||
|
#define EXTRUDERS 1
|
||||||
|
|
||||||
// Frequency limit
|
// Frequency limit
|
||||||
// See nophead's blog for more info
|
// See nophead's blog for more info
|
||||||
|
@ -174,7 +174,7 @@ static unsigned long stepper_inactive_time = 0;
|
|||||||
static unsigned long starttime=0;
|
static unsigned long starttime=0;
|
||||||
static unsigned long stoptime=0;
|
static unsigned long stoptime=0;
|
||||||
|
|
||||||
|
static uint8_t tmp_extruder;
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//=============================ROUTINES=============================
|
//=============================ROUTINES=============================
|
||||||
@ -641,7 +641,6 @@ inline void process_commands()
|
|||||||
//processed in write to file routine above
|
//processed in write to file routine above
|
||||||
//card,saving = false;
|
//card,saving = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#endif //SDSUPPORT
|
#endif //SDSUPPORT
|
||||||
|
|
||||||
case 30: //M30 take time since the start of the SD print or an M109 command
|
case 30: //M30 take time since the start of the SD print or an M109 command
|
||||||
@ -684,19 +683,36 @@ inline void process_commands()
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 104: // M104
|
case 104: // M104
|
||||||
if (code_seen('S')) setTargetHotend0(code_value());
|
tmp_extruder = active_extruder;
|
||||||
|
if(code_seen('T')) {
|
||||||
|
tmp_extruder = code_value();
|
||||||
|
if(tmp_extruder >= EXTRUDERS) {
|
||||||
|
SERIAL_ECHO_START;
|
||||||
|
SERIAL_ECHO("M104 Invalid extruder ");
|
||||||
|
SERIAL_ECHOLN(tmp_extruder);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (code_seen('S')) setTargetHotend(code_value(), tmp_extruder);
|
||||||
setWatch();
|
setWatch();
|
||||||
break;
|
break;
|
||||||
case 140: // M140 set bed temp
|
case 140: // M140 set bed temp
|
||||||
if (code_seen('S')) setTargetBed(code_value());
|
if (code_seen('S')) setTargetBed(code_value());
|
||||||
break;
|
break;
|
||||||
case 105 : // M105
|
case 105 : // M105
|
||||||
//SERIAL_ECHOLN(freeMemory());
|
tmp_extruder = active_extruder;
|
||||||
//test watchdog:
|
if(code_seen('T')) {
|
||||||
//delay(20000);
|
tmp_extruder = code_value();
|
||||||
#if (TEMP_0_PIN > -1) || defined (HEATER_USES_AD595)
|
if(tmp_extruder >= EXTRUDERS) {
|
||||||
|
SERIAL_ECHO_START;
|
||||||
|
SERIAL_ECHO("M105 Invalid extruder ");
|
||||||
|
SERIAL_ECHOLN(tmp_extruder);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#if (TEMP_0_PIN > -1) || (TEMP_2_PIN > -1)
|
||||||
SERIAL_PROTOCOLPGM("ok T:");
|
SERIAL_PROTOCOLPGM("ok T:");
|
||||||
SERIAL_PROTOCOL( degHotend0());
|
SERIAL_PROTOCOL( degHotend(tmp_extruder));
|
||||||
#if TEMP_1_PIN > -1
|
#if TEMP_1_PIN > -1
|
||||||
SERIAL_PROTOCOLPGM(" B:");
|
SERIAL_PROTOCOLPGM(" B:");
|
||||||
SERIAL_PROTOCOL(degBed());
|
SERIAL_PROTOCOL(degBed());
|
||||||
@ -715,41 +731,51 @@ inline void process_commands()
|
|||||||
break;
|
break;
|
||||||
case 109:
|
case 109:
|
||||||
{// M109 - Wait for extruder heater to reach target.
|
{// M109 - Wait for extruder heater to reach target.
|
||||||
LCD_MESSAGEPGM("Heating...");
|
tmp_extruder = active_extruder;
|
||||||
#ifdef AUTOTEMP
|
if(code_seen('T')) {
|
||||||
autotemp_enabled=false;
|
tmp_extruder = code_value();
|
||||||
#endif
|
if(tmp_extruder >= EXTRUDERS) {
|
||||||
if (code_seen('S')) setTargetHotend0(code_value());
|
SERIAL_ECHO_START;
|
||||||
#ifdef AUTOTEMP
|
SERIAL_ECHO("M109 Invalid extruder ");
|
||||||
if (code_seen('S')) autotemp_min=code_value();
|
SERIAL_ECHOLN(tmp_extruder);
|
||||||
if (code_seen('T')) autotemp_max=code_value();
|
break;
|
||||||
if (code_seen('F'))
|
}
|
||||||
{
|
}
|
||||||
autotemp_factor=code_value();
|
LCD_MESSAGEPGM("Heating...");
|
||||||
autotemp_enabled=true;
|
#ifdef AUTOTEMP
|
||||||
}
|
autotemp_enabled=false;
|
||||||
#endif
|
#endif
|
||||||
|
if (code_seen('S')) setTargetHotend(code_value(), tmp_extruder);
|
||||||
setWatch();
|
#ifdef AUTOTEMP
|
||||||
codenum = millis();
|
if (code_seen('S')) autotemp_min=code_value();
|
||||||
|
if (code_seen('G')) autotemp_max=code_value();
|
||||||
|
if (code_seen('F'))
|
||||||
|
{
|
||||||
|
autotemp_factor=code_value();
|
||||||
|
autotemp_enabled=true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
setWatch();
|
||||||
|
codenum = millis();
|
||||||
|
|
||||||
/* See if we are heating up or cooling down */
|
/* See if we are heating up or cooling down */
|
||||||
bool target_direction = isHeatingHotend0(); // true if heating, false if cooling
|
bool target_direction = isHeatingHotend(tmp_extruder); // true if heating, false if cooling
|
||||||
|
|
||||||
#ifdef TEMP_RESIDENCY_TIME
|
#ifdef TEMP_RESIDENCY_TIME
|
||||||
long residencyStart;
|
long residencyStart;
|
||||||
residencyStart = -1;
|
residencyStart = -1;
|
||||||
/* continue to loop until we have reached the target temp
|
/* continue to loop until we have reached the target temp
|
||||||
_and_ until TEMP_RESIDENCY_TIME hasn't passed since we reached it */
|
_and_ until TEMP_RESIDENCY_TIME hasn't passed since we reached it */
|
||||||
while((target_direction ? (isHeatingHotend0()) : (isCoolingHotend0())) ||
|
while((target_direction ? (isHeatingHotend(tmp_extruder)) : (isCoolingHotend(tmp_extruder))) ||
|
||||||
(residencyStart > -1 && (millis() - residencyStart) < TEMP_RESIDENCY_TIME*1000) ) {
|
(residencyStart > -1 && (millis() - residencyStart) < TEMP_RESIDENCY_TIME*1000) ) {
|
||||||
#else
|
#else
|
||||||
while ( target_direction ? (isHeatingHotend0()) : (isCoolingHotend0()&&(CooldownNoWait==false)) ) {
|
while ( target_direction ? (isHeatingHotend(tmp_extruder)) : (isCoolingHotend(tmp_extruder)&&(CooldownNoWait==false)) ) {
|
||||||
#endif //TEMP_RESIDENCY_TIME
|
#endif //TEMP_RESIDENCY_TIME
|
||||||
if( (millis() - codenum) > 1000 )
|
if( (millis() - codenum) > 1000 )
|
||||||
{ //Print Temp Reading every 1 second while heating up/cooling down
|
{ //Print Temp Reading every 1 second while heating up/cooling down
|
||||||
SERIAL_PROTOCOLPGM("T:");
|
SERIAL_PROTOCOLPGM("T:");
|
||||||
SERIAL_PROTOCOLLN( degHotend0() );
|
SERIAL_PROTOCOLLN( degHotend(tmp_extruder) );
|
||||||
codenum = millis();
|
codenum = millis();
|
||||||
}
|
}
|
||||||
manage_heater();
|
manage_heater();
|
||||||
@ -757,9 +783,9 @@ inline void process_commands()
|
|||||||
#ifdef TEMP_RESIDENCY_TIME
|
#ifdef TEMP_RESIDENCY_TIME
|
||||||
/* start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time
|
/* start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time
|
||||||
or when current temp falls outside the hysteresis after target temp was reached */
|
or when current temp falls outside the hysteresis after target temp was reached */
|
||||||
if ((residencyStart == -1 && target_direction && !isHeatingHotend0()) ||
|
if ((residencyStart == -1 && target_direction && !isHeatingHotend(tmp_extruder)) ||
|
||||||
(residencyStart == -1 && !target_direction && !isCoolingHotend0()) ||
|
(residencyStart == -1 && !target_direction && !isCoolingHotend(tmp_extruder)) ||
|
||||||
(residencyStart > -1 && labs(degHotend0() - degTargetHotend0()) > TEMP_HYSTERESIS) )
|
(residencyStart > -1 && labs(degHotend(tmp_extruder) - degTargetHotend(tmp_extruder)) > TEMP_HYSTERESIS) )
|
||||||
{
|
{
|
||||||
residencyStart = millis();
|
residencyStart = millis();
|
||||||
}
|
}
|
||||||
@ -943,8 +969,6 @@ inline void process_commands()
|
|||||||
#ifdef PIDTEMP
|
#ifdef PIDTEMP
|
||||||
case 301: // M301
|
case 301: // M301
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if(code_seen('P')) Kp = code_value();
|
if(code_seen('P')) Kp = code_value();
|
||||||
if(code_seen('I')) Ki = code_value()*PID_dT;
|
if(code_seen('I')) Ki = code_value()*PID_dT;
|
||||||
if(code_seen('D')) Kd = code_value()/PID_dT;
|
if(code_seen('D')) Kd = code_value()/PID_dT;
|
||||||
@ -989,6 +1013,18 @@ inline void process_commands()
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(code_seen('T')) {
|
||||||
|
tmp_extruder = code_value();
|
||||||
|
if(tmp_extruder >= EXTRUDERS) {
|
||||||
|
SERIAL_ECHO_START;
|
||||||
|
SERIAL_ECHO("T");
|
||||||
|
SERIAL_ECHO(tmp_extruder);
|
||||||
|
SERIAL_ECHOLN("Invalid extruder");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
active_extruder = tmp_extruder;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SERIAL_ECHO_START;
|
SERIAL_ECHO_START;
|
||||||
|
@ -81,6 +81,8 @@ float max_z_jerk;
|
|||||||
float mintravelfeedrate;
|
float mintravelfeedrate;
|
||||||
unsigned long axis_steps_per_sqr_second[NUM_AXIS];
|
unsigned long axis_steps_per_sqr_second[NUM_AXIS];
|
||||||
|
|
||||||
|
uint8_t active_extruder = 0;
|
||||||
|
|
||||||
// The current position of the tool in absolute steps
|
// The current position of the tool in absolute steps
|
||||||
long position[4]; //rescaled from extern when axis_steps_per_unit are changed by gcode
|
long position[4]; //rescaled from extern when axis_steps_per_unit are changed by gcode
|
||||||
static float previous_speed[4]; // Speed of previous path line segment
|
static float previous_speed[4]; // Speed of previous path line segment
|
||||||
|
@ -94,6 +94,7 @@ extern float max_z_jerk;
|
|||||||
extern float mintravelfeedrate;
|
extern float mintravelfeedrate;
|
||||||
extern unsigned long axis_steps_per_sqr_second[NUM_AXIS];
|
extern unsigned long axis_steps_per_sqr_second[NUM_AXIS];
|
||||||
|
|
||||||
|
extern uint8_t active_extruder;
|
||||||
|
|
||||||
#ifdef AUTOTEMP
|
#ifdef AUTOTEMP
|
||||||
extern bool autotemp_enabled;
|
extern bool autotemp_enabled;
|
||||||
|
@ -62,9 +62,18 @@ extern float Kp,Ki,Kd,Kc;
|
|||||||
inline float degHotend0(){ return analog2temp(current_raw[TEMPSENSOR_HOTEND_0]);};
|
inline float degHotend0(){ return analog2temp(current_raw[TEMPSENSOR_HOTEND_0]);};
|
||||||
inline float degHotend1(){ return analog2temp(current_raw[TEMPSENSOR_HOTEND_1]);};
|
inline float degHotend1(){ return analog2temp(current_raw[TEMPSENSOR_HOTEND_1]);};
|
||||||
inline float degBed() { return analog2tempBed(current_raw[TEMPSENSOR_BED]);};
|
inline float degBed() { return analog2tempBed(current_raw[TEMPSENSOR_BED]);};
|
||||||
|
inline float degHotend(uint8_t extruder){
|
||||||
|
if(extruder == 0) return analog2temp(current_raw[TEMPSENSOR_HOTEND_0]);
|
||||||
|
if(extruder == 1) return analog2temp(current_raw[TEMPSENSOR_HOTEND_1]);
|
||||||
|
};
|
||||||
|
|
||||||
inline float degTargetHotend0() { return analog2temp(target_raw[TEMPSENSOR_HOTEND_0]);};
|
inline float degTargetHotend0() { return analog2temp(target_raw[TEMPSENSOR_HOTEND_0]);};
|
||||||
inline float degTargetHotend1() { return analog2temp(target_raw[TEMPSENSOR_HOTEND_1]);};
|
inline float degTargetHotend1() { return analog2temp(target_raw[TEMPSENSOR_HOTEND_1]);};
|
||||||
|
inline float degTargetHotend(uint8_t extruder){
|
||||||
|
if(extruder == 0) return analog2temp(target_raw[TEMPSENSOR_HOTEND_0]);
|
||||||
|
if(extruder == 1) return analog2temp(target_raw[TEMPSENSOR_HOTEND_1]);
|
||||||
|
};
|
||||||
|
|
||||||
inline float degTargetBed() { return analog2tempBed(target_raw[TEMPSENSOR_BED]);};
|
inline float degTargetBed() { return analog2tempBed(target_raw[TEMPSENSOR_BED]);};
|
||||||
|
|
||||||
inline void setTargetHotend0(const float &celsius)
|
inline void setTargetHotend0(const float &celsius)
|
||||||
@ -75,14 +84,26 @@ inline void setTargetHotend0(const float &celsius)
|
|||||||
#endif //PIDTEMP
|
#endif //PIDTEMP
|
||||||
};
|
};
|
||||||
inline void setTargetHotend1(const float &celsius) { target_raw[TEMPSENSOR_HOTEND_1]=temp2analog(celsius);};
|
inline void setTargetHotend1(const float &celsius) { target_raw[TEMPSENSOR_HOTEND_1]=temp2analog(celsius);};
|
||||||
|
inline float setTargetHotend(const float &celcius, uint8_t extruder){
|
||||||
|
if(extruder == 0) setTargetHotend0(celcius);
|
||||||
|
if(extruder == 1) setTargetHotend1(celcius);
|
||||||
|
};
|
||||||
inline void setTargetBed(const float &celsius) { target_raw[TEMPSENSOR_BED ]=temp2analogBed(celsius);};
|
inline void setTargetBed(const float &celsius) { target_raw[TEMPSENSOR_BED ]=temp2analogBed(celsius);};
|
||||||
|
|
||||||
inline bool isHeatingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] > current_raw[TEMPSENSOR_HOTEND_0];};
|
inline bool isHeatingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] > current_raw[TEMPSENSOR_HOTEND_0];};
|
||||||
inline bool isHeatingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] > current_raw[TEMPSENSOR_HOTEND_1];};
|
inline bool isHeatingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] > current_raw[TEMPSENSOR_HOTEND_1];};
|
||||||
|
inline float isHeatingHotend(uint8_t extruder){
|
||||||
|
if(extruder == 0) return target_raw[TEMPSENSOR_HOTEND_0] > current_raw[TEMPSENSOR_HOTEND_0];
|
||||||
|
if(extruder == 1) return target_raw[TEMPSENSOR_HOTEND_1] > current_raw[TEMPSENSOR_HOTEND_1];
|
||||||
|
};
|
||||||
inline bool isHeatingBed() {return target_raw[TEMPSENSOR_BED] > current_raw[TEMPSENSOR_BED];};
|
inline bool isHeatingBed() {return target_raw[TEMPSENSOR_BED] > current_raw[TEMPSENSOR_BED];};
|
||||||
|
|
||||||
inline bool isCoolingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] < current_raw[TEMPSENSOR_HOTEND_0];};
|
inline bool isCoolingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] < current_raw[TEMPSENSOR_HOTEND_0];};
|
||||||
inline bool isCoolingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] < current_raw[TEMPSENSOR_HOTEND_1];};
|
inline bool isCoolingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] < current_raw[TEMPSENSOR_HOTEND_1];};
|
||||||
|
inline float isCoolingHotend(uint8_t extruder){
|
||||||
|
if(extruder == 0) return target_raw[TEMPSENSOR_HOTEND_0] < current_raw[TEMPSENSOR_HOTEND_0];
|
||||||
|
if(extruder == 1) return target_raw[TEMPSENSOR_HOTEND_1] < current_raw[TEMPSENSOR_HOTEND_1];
|
||||||
|
};
|
||||||
inline bool isCoolingBed() {return target_raw[TEMPSENSOR_BED] < current_raw[TEMPSENSOR_BED];};
|
inline bool isCoolingBed() {return target_raw[TEMPSENSOR_BED] < current_raw[TEMPSENSOR_BED];};
|
||||||
|
|
||||||
void disable_heater();
|
void disable_heater();
|
||||||
|
Loading…
Reference in New Issue
Block a user