Merge branch 'Marlin_v1' of https://github.com/ErikZalm/Marlin into Marlin_v1

This commit is contained in:
Bernhard Kubicek 2011-11-18 22:22:23 +01:00
commit 1e5e141ac9
4 changed files with 60 additions and 63 deletions

View file

@ -11,7 +11,7 @@
// Frequency limit // Frequency limit
// See nophead's blog for more info // See nophead's blog for more info
// Not working OK // Not working O
//#define XY_FREQUENCY_LIMIT 15 //#define XY_FREQUENCY_LIMIT 15
// Minimum planner junction speed. Sets the default minimum speed the planner plans for at the end // Minimum planner junction speed. Sets the default minimum speed the planner plans for at the end
@ -45,9 +45,9 @@
// 5 is ParCan supplied 104GT-2 100K // 5 is ParCan supplied 104GT-2 100K
// 6 is EPCOS 100k // 6 is EPCOS 100k
// 7 is 100k Honeywell thermistor 135-104LAG-J01 // 7 is 100k Honeywell thermistor 135-104LAG-J01
#define THERMISTORHEATER_0 3 //#define THERMISTORHEATER_0 3
#define THERMISTORHEATER_1 3 //#define THERMISTORHEATER_1 3
#define THERMISTORBED 3 //#define THERMISTORBED 3
//#define HEATER_0_USES_THERMISTOR //#define HEATER_0_USES_THERMISTOR
//#define HEATER_1_USES_THERMISTOR //#define HEATER_1_USES_THERMISTOR
@ -119,9 +119,15 @@
// #define DEFAULT_Ki (2*Kp/PID_SWING_AT_CRITIAL*PID_dT) // #define DEFAULT_Ki (2*Kp/PID_SWING_AT_CRITIAL*PID_dT)
// #define DEFAULT_Kd (PID_SWING_AT_CRITIAL/8./PID_dT) // #define DEFAULT_Kd (PID_SWING_AT_CRITIAL/8./PID_dT)
// Ultitmaker
#define DEFAULT_Kp 22.2 #define DEFAULT_Kp 22.2
#define DEFAULT_Ki (1.25*PID_dT) #define DEFAULT_Ki (1.25*PID_dT)
#define DEFAULT_Kd (99/PID_dT) #define DEFAULT_Kd (99/PID_dT)
// Mendel Parts V9 on 12V
// #define DEFAULT_Kp 63.0
// #define DEFAULT_Ki (2.25*PID_dT)
// #define DEFAULT_Kd (440/PID_dT)
#endif #endif
#ifdef PID_PI #ifdef PID_PI
@ -140,13 +146,6 @@
#endif // PIDTEMP #endif // PIDTEMP
//=========================================================================== //===========================================================================
//=============================Mechanical Settings=========================== //=============================Mechanical Settings===========================
//=========================================================================== //===========================================================================
@ -177,10 +176,10 @@ const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the
//#define INVERT_Z_DIR false // for Mendel set to false, for Orca set to true //#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 //#define INVERT_E_DIR true // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_X_DIR true // 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_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_Z_DIR true // for Mendel set to false, for Orca set to true
#define INVERT_E_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false #define INVERT_E_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false
//// ENDSTOP SETTINGS: //// ENDSTOP SETTINGS:
// Sets direction of endstops when homing; 1=MAX, -1=MIN // Sets direction of endstops when homing; 1=MAX, -1=MIN
@ -243,13 +242,11 @@ const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the
// The watchdog waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature // The watchdog waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature
// this enables the watchdog interrupt. // this enables the watchdog interrupt.
//#define USE_WATCHDOG //#define USE_WATCHDOG
#ifdef USE_WATCHDOG //#ifdef USE_WATCHDOG
// you cannot reboot on a mega2560 due to a bug in he bootloader. Hence, you have to reset manually, and this is done hereby: // you cannot reboot on a mega2560 due to a bug in he bootloader. Hence, you have to reset manually, and this is done hereby:
#define RESET_MANUAL //#define RESET_MANUAL
#define WATCHDOG_TIMEOUT 4 //seconds //#define WATCHDOG_TIMEOUT 4 //seconds
#endif //#endif
// extruder advance constant (s2/mm3) // extruder advance constant (s2/mm3)
// //
@ -307,8 +304,7 @@ const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the
#define AUTOTEMP_FACTOR 1000. //current target temperature= min+largest buffered espeeds)*FACTOR #define AUTOTEMP_FACTOR 1000. //current target temperature= min+largest buffered espeeds)*FACTOR
const int dropsegments=5; //everything with less than this number of steps will be ignored as move and joined with the next movement
const int dropsegments=0; //everything with less than this number of steps will be ignored as move and joined with the next movement
//=========================================================================== //===========================================================================
//=============================Buffers ============================ //=============================Buffers ============================

View file

@ -240,10 +240,9 @@ void setup()
axis_steps_per_sqr_second[i] = max_acceleration_units_per_sq_second[i] * axis_steps_per_unit[i]; axis_steps_per_sqr_second[i] = max_acceleration_units_per_sq_second[i] * axis_steps_per_unit[i];
} }
tp_init(); // Initialize temperature loop
plan_init(); // Initialize planner; plan_init(); // Initialize planner;
st_init(); // Initialize stepper; st_init(); // Initialize stepper;
tp_init(); // Initialize temperature loop
wd_init(); wd_init();
} }

View file

@ -56,8 +56,8 @@ static unsigned long step_events_completed; // The number of step events execute
#ifdef ADVANCE #ifdef ADVANCE
static long advance_rate, advance, final_advance = 0; static long advance_rate, advance, final_advance = 0;
static short old_advance = 0; static short old_advance = 0;
static short e_steps;
#endif #endif
static short e_steps;
static unsigned char busy = false; // TRUE when SIG_OUTPUT_COMPARE1A is being serviced. Used to avoid retriggering that handler. static unsigned char busy = false; // TRUE when SIG_OUTPUT_COMPARE1A is being serviced. Used to avoid retriggering that handler.
static long acceleration_time, deceleration_time; static long acceleration_time, deceleration_time;
//static unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate; //static unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate;
@ -156,7 +156,7 @@ asm volatile ( \
#define DISABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 &= ~(1<<OCIE1A) #define DISABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 &= ~(1<<OCIE1A)
void endstops_triggered(const unsigned long &stepstaken) inline void endstops_triggered(const unsigned long &stepstaken)
{ {
//this will only work if there is no bufferig //this will only work if there is no bufferig
//however, if you perform a move at which the endstops should be triggered, and wait for it to complete, i.e. by blocking command, it should work //however, if you perform a move at which the endstops should be triggered, and wait for it to complete, i.e. by blocking command, it should work
@ -296,9 +296,9 @@ ISR(TIMER1_COMPA_vect)
counter_z = counter_x; counter_z = counter_x;
counter_e = counter_x; counter_e = counter_x;
step_events_completed = 0; step_events_completed = 0;
#ifdef ADVANCE // #ifdef ADVANCE
e_steps = 0; e_steps = 0;
#endif // #endif
} }
else { else {
// DISABLE_STEPPER_DRIVER_INTERRUPT(); // DISABLE_STEPPER_DRIVER_INTERRUPT();
@ -309,29 +309,6 @@ ISR(TIMER1_COMPA_vect)
// Set directions TO DO This should be done once during init of trapezoid. Endstops -> interrupt // Set directions TO DO This should be done once during init of trapezoid. Endstops -> interrupt
out_bits = current_block->direction_bits; out_bits = current_block->direction_bits;
#ifdef ADVANCE
// Calculate E early.
counter_e += current_block->steps_e;
if (counter_e > 0) {
counter_e -= current_block->step_event_count;
if ((out_bits & (1<<E_AXIS)) != 0) { // - direction
CRITICAL_SECTION_START;
e_steps--;
CRITICAL_SECTION_END;
}
else {
CRITICAL_SECTION_START;
e_steps++;
CRITICAL_SECTION_END;
}
}
// Do E steps + advance steps
CRITICAL_SECTION_START;
e_steps += ((advance >> 16) - old_advance);
CRITICAL_SECTION_END;
old_advance = advance >> 16;
#endif //ADVANCE
// Set direction en check limit switches // Set direction en check limit switches
if ((out_bits & (1<<X_AXIS)) != 0) { // -direction if ((out_bits & (1<<X_AXIS)) != 0) { // -direction
WRITE(X_DIR_PIN, INVERT_X_DIR); WRITE(X_DIR_PIN, INVERT_X_DIR);
@ -339,10 +316,10 @@ ISR(TIMER1_COMPA_vect)
count_direction[X_AXIS]=-1; count_direction[X_AXIS]=-1;
#endif #endif
#if X_MIN_PIN > -1 #if X_MIN_PIN > -1
if(READ(X_MIN_PIN) != ENDSTOPS_INVERTING) { if(READ(X_MIN_PIN) != ENDSTOPS_INVERTING) {
// endstops_triggered(step_events_completed); // endstops_triggered(step_events_completed);
step_events_completed = current_block->step_event_count; step_events_completed = current_block->step_event_count;
} }
#endif #endif
} }
else { // +direction else { // +direction
@ -355,7 +332,7 @@ ISR(TIMER1_COMPA_vect)
// endstops_triggered(step_events_completed); // endstops_triggered(step_events_completed);
step_events_completed = current_block->step_event_count; step_events_completed = current_block->step_event_count;
} }
#endif #endif
} }
if ((out_bits & (1<<Y_AXIS)) != 0) { // -direction if ((out_bits & (1<<Y_AXIS)) != 0) { // -direction
@ -365,7 +342,7 @@ ISR(TIMER1_COMPA_vect)
#endif #endif
#if Y_MIN_PIN > -1 #if Y_MIN_PIN > -1
if(READ(Y_MIN_PIN) != ENDSTOPS_INVERTING) { if(READ(Y_MIN_PIN) != ENDSTOPS_INVERTING) {
// endstops_triggered(step_events_completed); // endstops_triggered(step_events_completed);
step_events_completed = current_block->step_event_count; step_events_completed = current_block->step_event_count;
} }
#endif #endif
@ -390,7 +367,7 @@ ISR(TIMER1_COMPA_vect)
#endif #endif
#if Z_MIN_PIN > -1 #if Z_MIN_PIN > -1
if(READ(Z_MIN_PIN) != ENDSTOPS_INVERTING) { if(READ(Z_MIN_PIN) != ENDSTOPS_INVERTING) {
endstops_triggered(step_events_completed); // endstops_triggered(step_events_completed);
step_events_completed = current_block->step_event_count; step_events_completed = current_block->step_event_count;
} }
#endif #endif
@ -416,6 +393,30 @@ ISR(TIMER1_COMPA_vect)
#endif //!ADVANCE #endif //!ADVANCE
for(int8_t i=0; i < step_loops; i++) { // Take multiple steps per interrupt (For high speed moves) for(int8_t i=0; i < step_loops; i++) { // Take multiple steps per interrupt (For high speed moves)
/*
counter_e += current_block->steps_e;
if (counter_e > 0) {
counter_e -= current_block->step_event_count;
if ((out_bits & (1<<E_AXIS)) != 0) { // - direction
CRITICAL_SECTION_START;
e_steps--;
CRITICAL_SECTION_END;
}
else {
CRITICAL_SECTION_START;
e_steps++;
CRITICAL_SECTION_END;
}
}
*/
/*
// Do E steps + advance steps
CRITICAL_SECTION_START;
e_steps += ((advance >> 16) - old_advance);
CRITICAL_SECTION_END;
old_advance = advance >> 16;
*/
counter_x += current_block->steps_x; counter_x += current_block->steps_x;
if (counter_x > 0) { if (counter_x > 0) {
WRITE(X_STEP_PIN, HIGH); WRITE(X_STEP_PIN, HIGH);
@ -649,7 +650,8 @@ void st_init()
TCCR1B = (TCCR1B & ~(0x07<<CS10)) | (2<<CS10); // 2MHz timer TCCR1B = (TCCR1B & ~(0x07<<CS10)) | (2<<CS10); // 2MHz timer
OCR1A = 0x4000; OCR1A = 0x4000;
DISABLE_STEPPER_DRIVER_INTERRUPT(); TCNT1 = 0;
ENABLE_STEPPER_DRIVER_INTERRUPT();
#ifdef ADVANCE #ifdef ADVANCE
e_steps = 0; e_steps = 0;

View file

@ -19,15 +19,15 @@ void(* ctrlaltdelete) (void) = 0; //does not work on my atmega2560
/// intialise watch dog with a 1 sec interrupt time /// intialise watch dog with a 1 sec interrupt time
void wd_init() void wd_init()
{ {
WDTCSR = (1<<WDCE )|(1<<WDE ); //allow changes WDTCSR |= (1<<WDCE )|(1<<WDE ); //allow changes
WDTCSR = (1<<WDIF)|(1<<WDIE)| (1<<WDCE )|(1<<WDE )| (1<<WDP2 )|(1<<WDP1)|(0<<WDP0); WDTCSR = (1<<WDCE )|(1<<WDE )|(1<<WDP3 )|(1<<WDP0); // Reset after 8 sec.
// WDTCSR = (1<<WDIF)|(1<<WDIE)| (1<<WDCE )|(1<<WDE )| (1<<WDP3) | (1<<WDP0);
} }
/// reset watchdog. MUST be called every 1s after init or avr will reset. /// reset watchdog. MUST be called every 1s after init or avr will reset.
void wd_reset() void wd_reset()
{ {
wdt_reset(); wdt_reset();
timeout_seconds=0; //reset counter for resets
} }
//=========================================================================== //===========================================================================