Browse Source

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

Bernhard Kubicek 12 years ago
parent
commit
1e5e141ac9
4 changed files with 60 additions and 63 deletions
  1. 19
    23
      Marlin/Configuration.h
  2. 1
    2
      Marlin/Marlin.pde
  3. 37
    35
      Marlin/stepper.cpp
  4. 3
    3
      Marlin/watchdog.pde

+ 19
- 23
Marlin/Configuration.h View File

@@ -11,7 +11,7 @@
11 11
 
12 12
 // Frequency limit
13 13
 // See nophead's blog for more info
14
-// Not working OK
14
+// Not working O
15 15
 //#define XY_FREQUENCY_LIMIT  15
16 16
 
17 17
 // Minimum planner junction speed. Sets the default minimum speed the planner plans for at the end
@@ -45,9 +45,9 @@
45 45
 // 5 is ParCan supplied 104GT-2 100K
46 46
 // 6 is EPCOS 100k
47 47
 // 7 is 100k Honeywell thermistor 135-104LAG-J01
48
-#define THERMISTORHEATER_0 3
49
-#define THERMISTORHEATER_1 3
50
-#define THERMISTORBED 3
48
+//#define THERMISTORHEATER_0 3
49
+//#define THERMISTORHEATER_1 3
50
+//#define THERMISTORBED 3
51 51
 
52 52
 //#define HEATER_0_USES_THERMISTOR
53 53
 //#define HEATER_1_USES_THERMISTOR
@@ -119,9 +119,15 @@
119 119
 //    #define  DEFAULT_Ki (2*Kp/PID_SWING_AT_CRITIAL*PID_dT)  
120 120
 //    #define  DEFAULT_Kd (PID_SWING_AT_CRITIAL/8./PID_dT)  
121 121
 
122
+// Ultitmaker
122 123
     #define  DEFAULT_Kp  22.2
123 124
     #define  DEFAULT_Ki (1.25*PID_dT)  
124 125
     #define  DEFAULT_Kd (99/PID_dT)  
126
+
127
+// Mendel Parts V9 on 12V    
128
+//    #define  DEFAULT_Kp  63.0
129
+//    #define  DEFAULT_Ki (2.25*PID_dT)  
130
+//    #define  DEFAULT_Kd (440/PID_dT)  
125 131
   #endif
126 132
    
127 133
   #ifdef PID_PI
@@ -140,13 +146,6 @@
140 146
 #endif // PIDTEMP
141 147
 
142 148
 
143
-
144
-
145
-
146
-
147
-
148
-
149
-
150 149
 //===========================================================================
151 150
 //=============================Mechanical Settings===========================
152 151
 //===========================================================================
@@ -177,10 +176,10 @@ const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the
177 176
 //#define INVERT_Z_DIR false    // for Mendel set to false, for Orca set to true
178 177
 //#define INVERT_E_DIR true   // for direct drive extruder v9 set to true, for geared extruder set to false
179 178
 
180
-#define INVERT_X_DIR true    // for Mendel set to false, for Orca set to true
181
-#define INVERT_Y_DIR false   // for Mendel set to true, for Orca set to false
182
-#define INVERT_Z_DIR true    // for Mendel set to false, for Orca set to true
183
-#define INVERT_E_DIR false   // for direct drive extruder v9 set to true, for geared extruder set to false
179
+#define INVERT_X_DIR true     // for Mendel set to false, for Orca set to true
180
+#define INVERT_Y_DIR false    // for Mendel set to true, for Orca set to false
181
+#define INVERT_Z_DIR true     // for Mendel set to false, for Orca set to true
182
+#define INVERT_E_DIR false    // for direct drive extruder v9 set to true, for geared extruder set to false
184 183
 
185 184
 //// ENDSTOP SETTINGS:
186 185
 // 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
243 242
 // The watchdog waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature
244 243
 // this enables the watchdog interrupt.
245 244
 //#define USE_WATCHDOG
246
-#ifdef USE_WATCHDOG
245
+//#ifdef USE_WATCHDOG
247 246
   // you cannot reboot on a mega2560 due to a bug in he bootloader. Hence, you have to reset manually, and this is done hereby:
248
-  #define RESET_MANUAL
249
-  #define WATCHDOG_TIMEOUT 4  //seconds
250
-#endif
251
-
252
-
247
+//#define RESET_MANUAL
248
+//#define WATCHDOG_TIMEOUT 4  //seconds
249
+//#endif
253 250
 
254 251
 // extruder advance constant (s2/mm3)
255 252
 //
@@ -307,8 +304,7 @@ const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the
307 304
 #define AUTOTEMP_FACTOR 1000.  //current target temperature= min+largest buffered espeeds)*FACTOR
308 305
 
309 306
 
310
-
311
-const int dropsegments=0; //everything with less than this number of steps  will be ignored as move and joined with the next movement
307
+const int dropsegments=5; //everything with less than this number of steps will be ignored as move and joined with the next movement
312 308
 
313 309
 //===========================================================================
314 310
 //=============================Buffers           ============================

+ 1
- 2
Marlin/Marlin.pde View File

@@ -240,10 +240,9 @@ void setup()
240 240
     axis_steps_per_sqr_second[i] = max_acceleration_units_per_sq_second[i] * axis_steps_per_unit[i];
241 241
   }
242 242
 
243
-  
243
+  tp_init();    // Initialize temperature loop 
244 244
   plan_init();  // Initialize planner;
245 245
   st_init();    // Initialize stepper;
246
-  tp_init();    // Initialize temperature loop
247 246
   wd_init();
248 247
 }
249 248
 

+ 37
- 35
Marlin/stepper.cpp View File

@@ -56,8 +56,8 @@ static unsigned long step_events_completed; // The number of step events execute
56 56
 #ifdef ADVANCE
57 57
   static long advance_rate, advance, final_advance = 0;
58 58
   static short old_advance = 0;
59
-  static short e_steps;
60 59
 #endif
60
+static short e_steps;
61 61
 static unsigned char busy = false; // TRUE when SIG_OUTPUT_COMPARE1A is being serviced. Used to avoid retriggering that handler.
62 62
 static long acceleration_time, deceleration_time;
63 63
 //static unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate;
@@ -156,7 +156,7 @@ asm volatile ( \
156 156
 #define DISABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 &= ~(1<<OCIE1A)
157 157
 
158 158
 
159
-void endstops_triggered(const unsigned long &stepstaken)  
159
+inline void endstops_triggered(const unsigned long &stepstaken)  
160 160
 {
161 161
   //this will only work if there is no bufferig
162 162
   //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)
296 296
       counter_z = counter_x;
297 297
       counter_e = counter_x;
298 298
       step_events_completed = 0;
299
-      #ifdef ADVANCE
299
+ //     #ifdef ADVANCE
300 300
       e_steps = 0;
301
-      #endif
301
+//      #endif
302 302
     } 
303 303
     else {
304 304
 //      DISABLE_STEPPER_DRIVER_INTERRUPT();
@@ -309,29 +309,6 @@ ISR(TIMER1_COMPA_vect)
309 309
     // Set directions TO DO This should be done once during init of trapezoid. Endstops -> interrupt
310 310
     out_bits = current_block->direction_bits;
311 311
 
312
-    #ifdef ADVANCE
313
-        // Calculate E early.
314
-        counter_e += current_block->steps_e;
315
-        if (counter_e > 0) {
316
-          counter_e -= current_block->step_event_count;
317
-          if ((out_bits & (1<<E_AXIS)) != 0) { // - direction
318
-            CRITICAL_SECTION_START;
319
-            e_steps--;
320
-            CRITICAL_SECTION_END;
321
-          }
322
-          else {
323
-            CRITICAL_SECTION_START;
324
-            e_steps++;
325
-            CRITICAL_SECTION_END;
326
-          }
327
-        }    
328
-        // Do E steps + advance steps
329
-        CRITICAL_SECTION_START;
330
-        e_steps += ((advance >> 16) - old_advance);
331
-        CRITICAL_SECTION_END;
332
-        old_advance = advance >> 16;  
333
-    #endif //ADVANCE
334
-
335 312
     // Set direction en check limit switches
336 313
     if ((out_bits & (1<<X_AXIS)) != 0) {   // -direction
337 314
       WRITE(X_DIR_PIN, INVERT_X_DIR);
@@ -339,10 +316,10 @@ ISR(TIMER1_COMPA_vect)
339 316
         count_direction[X_AXIS]=-1;
340 317
       #endif
341 318
       #if X_MIN_PIN > -1
342
-            if(READ(X_MIN_PIN) != ENDSTOPS_INVERTING) {
343
- //             endstops_triggered(step_events_completed);
344
-              step_events_completed = current_block->step_event_count;
345
-            }
319
+        if(READ(X_MIN_PIN) != ENDSTOPS_INVERTING) {
320
+ //         endstops_triggered(step_events_completed);
321
+          step_events_completed = current_block->step_event_count;
322
+        }
346 323
       #endif
347 324
     }
348 325
     else { // +direction 
@@ -355,7 +332,7 @@ ISR(TIMER1_COMPA_vect)
355 332
  //         endstops_triggered(step_events_completed);
356 333
           step_events_completed = current_block->step_event_count;
357 334
         }
358
-        #endif
335
+      #endif
359 336
     }
360 337
 
361 338
     if ((out_bits & (1<<Y_AXIS)) != 0) {   // -direction
@@ -365,7 +342,7 @@ ISR(TIMER1_COMPA_vect)
365 342
       #endif
366 343
       #if Y_MIN_PIN > -1
367 344
         if(READ(Y_MIN_PIN) != ENDSTOPS_INVERTING) {
368
- //         endstops_triggered(step_events_completed);
345
+//          endstops_triggered(step_events_completed);
369 346
           step_events_completed = current_block->step_event_count;
370 347
         }
371 348
       #endif
@@ -390,7 +367,7 @@ ISR(TIMER1_COMPA_vect)
390 367
       #endif
391 368
       #if Z_MIN_PIN > -1
392 369
         if(READ(Z_MIN_PIN) != ENDSTOPS_INVERTING) {
393
-          endstops_triggered(step_events_completed);
370
+ //         endstops_triggered(step_events_completed);
394 371
           step_events_completed = current_block->step_event_count;
395 372
         }
396 373
       #endif
@@ -416,6 +393,30 @@ ISR(TIMER1_COMPA_vect)
416 393
     #endif //!ADVANCE
417 394
 
418 395
     for(int8_t i=0; i < step_loops; i++) { // Take multiple steps per interrupt (For high speed moves) 
396
+    /*
397
+      counter_e += current_block->steps_e;
398
+      if (counter_e > 0) {
399
+        counter_e -= current_block->step_event_count;
400
+        if ((out_bits & (1<<E_AXIS)) != 0) { // - direction
401
+          CRITICAL_SECTION_START;
402
+          e_steps--;
403
+          CRITICAL_SECTION_END;
404
+        }
405
+        else {
406
+          CRITICAL_SECTION_START;
407
+          e_steps++;
408
+          CRITICAL_SECTION_END;
409
+        }
410
+      }    
411
+      */
412
+      /*
413
+      // Do E steps + advance steps
414
+      CRITICAL_SECTION_START;
415
+      e_steps += ((advance >> 16) - old_advance);
416
+      CRITICAL_SECTION_END;
417
+      old_advance = advance >> 16;  
418
+      */
419
+        
419 420
       counter_x += current_block->steps_x;
420 421
       if (counter_x > 0) {
421 422
         WRITE(X_STEP_PIN, HIGH);
@@ -649,7 +650,8 @@ void st_init()
649 650
   TCCR1B = (TCCR1B & ~(0x07<<CS10)) | (2<<CS10); // 2MHz timer
650 651
 
651 652
   OCR1A = 0x4000;
652
-  DISABLE_STEPPER_DRIVER_INTERRUPT();  
653
+  TCNT1 = 0;
654
+  ENABLE_STEPPER_DRIVER_INTERRUPT();  
653 655
 
654 656
   #ifdef ADVANCE
655 657
     e_steps = 0;

+ 3
- 3
Marlin/watchdog.pde View File

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

Loading…
Cancel
Save