Version 1.3.24T / 21.09.2013
- M105 show same format as Marlin work better with new Pronterface - Optimize TEMP_RESIDENCY function at Command M109
This commit is contained in:
parent
f84de85ec9
commit
308cce734a
3 changed files with 89 additions and 19 deletions
|
|
@ -311,7 +311,7 @@ const int dropsegments=5; //everything with less than this number of steps will
|
||||||
#define LED_PWM_FOR_BRIGHTNESS(brightness) ((64*brightness-1384)/(300-brightness))
|
#define LED_PWM_FOR_BRIGHTNESS(brightness) ((64*brightness-1384)/(300-brightness))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Change this value (range 30-255) to limit the current to the nozzle
|
// Change this value (range 30 - 255) to limit the current to the nozzle
|
||||||
#define HEATER_CURRENT 255
|
#define HEATER_CURRENT 255
|
||||||
|
|
||||||
// How often should the heater check for new temp readings, in milliseconds
|
// How often should the heater check for new temp readings, in milliseconds
|
||||||
|
|
@ -341,8 +341,9 @@ const int dropsegments=5; //everything with less than this number of steps will
|
||||||
//#define WATCHPERIOD 5000 //5 seconds
|
//#define WATCHPERIOD 5000 //5 seconds
|
||||||
|
|
||||||
// Actual temperature must be close to target for this long before M109 returns success
|
// Actual temperature must be close to target for this long before M109 returns success
|
||||||
//#define TEMP_RESIDENCY_TIME 20 // (seconds)
|
#define TEMP_RESIDENCY_TIME 10 // (seconds)
|
||||||
//#define TEMP_HYSTERESIS 5 // (C°) range of +/- temperatures considered "close" to the target one
|
#define TEMP_HYSTERESIS 3 // (C°) range of +/- temperatures considered "close" to the target one
|
||||||
|
#define TEMP_WINDOW 1 // (degC) Window around target to start the recidency timer x degC early.
|
||||||
|
|
||||||
//// The minimal temperature defines the temperature below which the heater will not be enabled
|
//// The minimal temperature defines the temperature below which the heater will not be enabled
|
||||||
#define MINTEMP 5
|
#define MINTEMP 5
|
||||||
|
|
@ -352,6 +353,7 @@ const int dropsegments=5; //everything with less than this number of steps will
|
||||||
// This feature exists to protect your hotend from overheating accidentally, but *NOT* from thermistor short/failure!
|
// 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.
|
// You should use MINTEMP for thermistor short/failure protection.
|
||||||
#define MAXTEMP 275
|
#define MAXTEMP 275
|
||||||
|
#define MAXTEMP_BED 140
|
||||||
|
|
||||||
// Select one of these only to define how the nozzle temp is read.
|
// Select one of these only to define how the nozzle temp is read.
|
||||||
#define HEATER_USES_THERMISTOR
|
#define HEATER_USES_THERMISTOR
|
||||||
|
|
|
||||||
|
|
@ -149,6 +149,10 @@
|
||||||
- Analog pins was added with the wrong pin number, needs to be offset +55 to protect against using the pin as a digital
|
- Analog pins was added with the wrong pin number, needs to be offset +55 to protect against using the pin as a digital
|
||||||
- Min step delay in microseconds (EXTEND_STEP_PULSE_USEC)
|
- Min step delay in microseconds (EXTEND_STEP_PULSE_USEC)
|
||||||
|
|
||||||
|
Version 1.3.24T / 21.09.2013
|
||||||
|
- M105 show same format as Marlin work better with new Pronterface
|
||||||
|
- Optimize TEMP_RESIDENCY function
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
|
|
@ -255,7 +259,7 @@ void __cxa_pure_virtual(){};
|
||||||
// M603 - Show Free Ram
|
// M603 - Show Free Ram
|
||||||
|
|
||||||
|
|
||||||
#define _VERSION_TEXT "1.3.23T / 28.11.2012"
|
#define _VERSION_TEXT "1.3.24T / 21.09.2013"
|
||||||
|
|
||||||
//Stepper Movement Variables
|
//Stepper Movement Variables
|
||||||
char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
|
char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
|
||||||
|
|
@ -1508,6 +1512,18 @@ FORCE_INLINE void process_commands()
|
||||||
#if (TEMP_0_PIN > -1) || defined (HEATER_USES_MAX6675) || defined HEATER_USES_AD595
|
#if (TEMP_0_PIN > -1) || defined (HEATER_USES_MAX6675) || defined HEATER_USES_AD595
|
||||||
showString(PSTR("ok T:"));
|
showString(PSTR("ok T:"));
|
||||||
Serial.print(hotendtC);
|
Serial.print(hotendtC);
|
||||||
|
showString(PSTR(" /"));
|
||||||
|
Serial.print(analog2temp(target_raw));
|
||||||
|
|
||||||
|
#if TEMP_1_PIN > -1 || defined BED_USES_AD595
|
||||||
|
showString(PSTR(" B:"));
|
||||||
|
Serial.print(bedtempC);
|
||||||
|
showString(PSTR(" /"));
|
||||||
|
Serial.print(analog2temp(target_bed_raw));
|
||||||
|
#else
|
||||||
|
Serial.print(PSTR(" B:0 /0"));
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PIDTEMP
|
#ifdef PIDTEMP
|
||||||
showString(PSTR(" @:"));
|
showString(PSTR(" @:"));
|
||||||
Serial.print(heater_duty);
|
Serial.print(heater_duty);
|
||||||
|
|
@ -1523,23 +1539,40 @@ FORCE_INLINE void process_commands()
|
||||||
showString(PSTR(",AU:"));
|
showString(PSTR(",AU:"));
|
||||||
Serial.print(autotemp_setpoint);
|
Serial.print(autotemp_setpoint);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
#if TEMP_1_PIN > -1 || defined BED_USES_AD595
|
|
||||||
showString(PSTR(" B:"));
|
|
||||||
Serial.println(bedtempC);
|
|
||||||
#else
|
#else
|
||||||
Serial.println();
|
showString(PSTR(" @:0"));
|
||||||
|
#if (HEATER_0_PIN > -1)
|
||||||
|
if(READ(HEATER_0_PIN))
|
||||||
|
Serial.println(255);
|
||||||
|
else
|
||||||
|
Serial.println(0);
|
||||||
|
#else
|
||||||
|
Serial.println(0);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
showString(PSTR(" B@:"));
|
||||||
|
#if (HEATER_1_PIN > -1)
|
||||||
|
if(READ(HEATER_1_PIN))
|
||||||
|
Serial.println(255);
|
||||||
|
else
|
||||||
|
Serial.println(0);
|
||||||
|
#else
|
||||||
|
Serial.println(0);
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#error No temperature source available
|
#error No temperature source available
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
//break;
|
//break;
|
||||||
case 109: { // M109 - Wait for extruder heater to reach target.
|
case 109: // M109 - Wait for extruder heater to reach target.
|
||||||
#ifdef CHAIN_OF_COMMAND
|
{
|
||||||
|
#ifdef CHAIN_OF_COMMAND
|
||||||
st_synchronize(); // wait for all movements to finish
|
st_synchronize(); // wait for all movements to finish
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (code_seen('S')) target_raw = temp2analogh(target_temp = code_value());
|
if (code_seen('S')) target_raw = temp2analogh(target_temp = code_value());
|
||||||
|
|
||||||
#ifdef WATCHPERIOD
|
#ifdef WATCHPERIOD
|
||||||
if(target_raw>current_raw)
|
if(target_raw>current_raw)
|
||||||
{
|
{
|
||||||
|
|
@ -1561,27 +1594,51 @@ FORCE_INLINE void process_commands()
|
||||||
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 ? (current_raw < target_raw) : (current_raw > target_raw))
|
while((residencyStart == -1) ||
|
||||||
|| (residencyStart > -1 && (millis() - residencyStart) < TEMP_RESIDENCY_TIME*1000) ) {
|
(residencyStart >= 0 && (((unsigned int) (millis() - residencyStart)) < (TEMP_RESIDENCY_TIME * 1000UL))) ) {
|
||||||
#else
|
#else
|
||||||
while ( target_direction ? (current_raw < target_raw) : (current_raw > target_raw) ) {
|
while ( target_direction ? (current_raw < target_raw) : (current_raw > target_raw) ) {
|
||||||
#endif
|
#endif //TEMP_RESIDENCY_TIME
|
||||||
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
|
||||||
|
if( (millis() - codenum) > 1000UL )
|
||||||
{
|
{
|
||||||
showString(PSTR("T:"));
|
showString(PSTR("T:"));
|
||||||
|
#ifndef TEMP_RESIDENCY_TIME
|
||||||
Serial.println( analog2temp(current_raw) );
|
Serial.println( analog2temp(current_raw) );
|
||||||
|
#else
|
||||||
|
Serial.print( analog2temp(current_raw) );
|
||||||
|
showString(PSTR(" E:0"));
|
||||||
|
showString(PSTR(" W:"));
|
||||||
|
if(residencyStart > -1)
|
||||||
|
{
|
||||||
|
codenum = ((TEMP_RESIDENCY_TIME * 1000UL) - (millis() - residencyStart)) / 1000UL;
|
||||||
|
Serial.print( codenum );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Serial.print("?");
|
||||||
|
}
|
||||||
|
|
||||||
|
showString(PSTR(" D:"));
|
||||||
|
Serial.println( analog2temp(current_raw) - analog2temp(target_raw) );
|
||||||
|
#endif
|
||||||
codenum = millis();
|
codenum = millis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Call Heatercontrol
|
||||||
manage_heater();
|
manage_heater();
|
||||||
|
|
||||||
#if (MINIMUM_FAN_START_SPEED > 0)
|
#if (MINIMUM_FAN_START_SPEED > 0)
|
||||||
manage_fan_start_speed();
|
manage_fan_start_speed();
|
||||||
#endif
|
#endif
|
||||||
#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 && current_raw >= target_raw)
|
|
||||||
|| (residencyStart == -1 && !target_direction && current_raw <= target_raw)
|
if ((residencyStart == -1 && target_direction && (analog2temp(current_raw) >= (analog2temp(target_raw)-TEMP_WINDOW))) ||
|
||||||
|| (residencyStart > -1 && labs(analog2temp(current_raw) - analog2temp(target_raw)) > TEMP_HYSTERESIS) ) {
|
(residencyStart == -1 && !target_direction && (analog2temp(current_raw) <= (analog2temp(target_raw)+TEMP_WINDOW))) ||
|
||||||
|
(residencyStart > -1 && labs(analog2temp(current_raw) - analog2temp(target_raw)) > TEMP_HYSTERESIS) )
|
||||||
|
{
|
||||||
residencyStart = millis();
|
residencyStart = millis();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,10 @@ unsigned long previous_millis_heater, previous_millis_bed_heater, previous_milli
|
||||||
int maxttemp = temp2analogh(MAXTEMP);
|
int maxttemp = temp2analogh(MAXTEMP);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef MAXTEMP_BED
|
||||||
|
int maxttemp_bed = temp2analogBed(MAXTEMP_BED);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define HEAT_INTERVAL 250
|
#define HEAT_INTERVAL 250
|
||||||
|
|
@ -305,6 +309,9 @@ ISR(TIMER2_OVF_vect)
|
||||||
// Some information see:
|
// Some information see:
|
||||||
// http://brettbeauregard.com/blog/2012/01/arduino-pid-autotune-library/
|
// http://brettbeauregard.com/blog/2012/01/arduino-pid-autotune-library/
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
|
//HEATER_CURRENT --> 255
|
||||||
|
|
||||||
#ifdef PID_AUTOTUNE
|
#ifdef PID_AUTOTUNE
|
||||||
void PID_autotune(int PIDAT_test_temp)
|
void PID_autotune(int PIDAT_test_temp)
|
||||||
{
|
{
|
||||||
|
|
@ -742,7 +749,11 @@ void PID_autotune(int PIDAT_test_temp)
|
||||||
|
|
||||||
|
|
||||||
#ifdef MINTEMP
|
#ifdef MINTEMP
|
||||||
|
#ifdef MAXTEMP_BED
|
||||||
|
if(current_bed_raw >= target_bed_raw || current_bed_raw < minttemp || current_bed_raw > maxttemp_bed)
|
||||||
|
#else
|
||||||
if(current_bed_raw >= target_bed_raw || current_bed_raw < minttemp)
|
if(current_bed_raw >= target_bed_raw || current_bed_raw < minttemp)
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
if(current_bed_raw >= target_bed_raw)
|
if(current_bed_raw >= target_bed_raw)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue