trying to get autotemp to work.

This commit is contained in:
Bernhard Kubicek 2011-11-19 15:37:10 +01:00
parent f0154de5b3
commit 8a08b8e07e
3 changed files with 30 additions and 8 deletions

View file

@ -695,7 +695,17 @@ inline void process_commands()
case 109: case 109:
{// M109 - Wait for extruder heater to reach target. {// M109 - Wait for extruder heater to reach target.
LCD_MESSAGEPGM("Heating..."); LCD_MESSAGEPGM("Heating...");
autotemp_enabled=false;
if (code_seen('S')) setTargetHotend0(code_value()); if (code_seen('S')) setTargetHotend0(code_value());
#ifdef AUTOTEMP
if (code_seen('S')) autotemp_min=code_value();
if (code_seen('T')) autotemp_max=code_value();
if (code_seen('F'))
{
autotemp_factor=code_value();
autotemp_enabled=true;
}
#endif
setWatch(); setWatch();
codenum = millis(); codenum = millis();

View file

@ -87,7 +87,10 @@ static float previous_speed[4]; // Speed of previous path line segment
static float previous_nominal_speed; // Nominal speed of previous path line segment static float previous_nominal_speed; // Nominal speed of previous path line segment
#ifdef AUTOTEMP #ifdef AUTOTEMP
float high_e_speed=0; float autotemp_max=250;
float autotemp_min=210;
float autotemp_factor=1;
bool autotemp_enabled=false;
#endif #endif
@ -379,26 +382,29 @@ block_t *plan_get_current_block() {
#ifdef AUTOTEMP #ifdef AUTOTEMP
void getHighESpeed() void getHighESpeed()
{ {
if(degTargetHotend0()+2<AUTOTEMP_MIN) //probably temperature set to zero. if(!autotemp_enabled)
return;
if(degTargetHotend0()+2<autotemp_min) //probably temperature set to zero.
return; //do nothing return; //do nothing
float high=0; float high=0;
char block_index = block_buffer_tail; char block_index = block_buffer_tail;
while(block_index != block_buffer_head) { while(block_index != block_buffer_head) {
float se=block_buffer[block_index].speed_e; float se=block_buffer[block_index].steps_e/float(block_buffer[block_index].step_event_count)*block_buffer[block_index].nominal_rate;
//se; units steps/sec;
if(se>high) if(se>high)
{ {
high=se; high=se;
} }
block_index = (block_index+1) & (BLOCK_BUFFER_SIZE - 1); block_index = (block_index+1) & (BLOCK_BUFFER_SIZE - 1);
} }
high_e_speed=high*axis_steps_per_unit[E_AXIS]/(1000000.0); //so it is independent of the esteps/mm. before
float g=AUTOTEMP_MIN+high_e_speed*AUTOTEMP_FACTOR; float g=autotemp_min+high*autotemp_factor;
float t=constrain(AUTOTEMP_MIN,g,AUTOTEMP_MAX); float t=constrain(autotemp_min,g,autotemp_max);
setTargetHotend0(t); setTargetHotend0(t);
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOPAIR("highe",high_e_speed); SERIAL_ECHOPAIR("highe",high);
SERIAL_ECHOPAIR(" t",t); SERIAL_ECHOPAIR(" t",t);
SERIAL_ECHOLN(""); SERIAL_ECHOLN("");
} }

View file

@ -92,7 +92,13 @@ extern float max_xy_jerk; //speed than can be stopped at once, if i understand c
extern float max_z_jerk; 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];
#ifdef AUTOTEMP #ifdef AUTOTEMP
extern float high_e_speed; extern bool autotemp_enabled;
extern float autotemp_max;
extern float autotemp_min;
extern float autotemp_factor;
#endif #endif
#endif #endif