Browse Source

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

Bernhard Kubicek 13 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
 
11
 
12
 // Frequency limit
12
 // Frequency limit
13
 // See nophead's blog for more info
13
 // See nophead's blog for more info
14
-// Not working OK
14
+// Not working O
15
 //#define XY_FREQUENCY_LIMIT  15
15
 //#define XY_FREQUENCY_LIMIT  15
16
 
16
 
17
 // Minimum planner junction speed. Sets the default minimum speed the planner plans for at the end
17
 // Minimum planner junction speed. Sets the default minimum speed the planner plans for at the end
45
 // 5 is ParCan supplied 104GT-2 100K
45
 // 5 is ParCan supplied 104GT-2 100K
46
 // 6 is EPCOS 100k
46
 // 6 is EPCOS 100k
47
 // 7 is 100k Honeywell thermistor 135-104LAG-J01
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
 //#define HEATER_0_USES_THERMISTOR
52
 //#define HEATER_0_USES_THERMISTOR
53
 //#define HEATER_1_USES_THERMISTOR
53
 //#define HEATER_1_USES_THERMISTOR
119
 //    #define  DEFAULT_Ki (2*Kp/PID_SWING_AT_CRITIAL*PID_dT)  
119
 //    #define  DEFAULT_Ki (2*Kp/PID_SWING_AT_CRITIAL*PID_dT)  
120
 //    #define  DEFAULT_Kd (PID_SWING_AT_CRITIAL/8./PID_dT)  
120
 //    #define  DEFAULT_Kd (PID_SWING_AT_CRITIAL/8./PID_dT)  
121
 
121
 
122
+// Ultitmaker
122
     #define  DEFAULT_Kp  22.2
123
     #define  DEFAULT_Kp  22.2
123
     #define  DEFAULT_Ki (1.25*PID_dT)  
124
     #define  DEFAULT_Ki (1.25*PID_dT)  
124
     #define  DEFAULT_Kd (99/PID_dT)  
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
   #endif
131
   #endif
126
    
132
    
127
   #ifdef PID_PI
133
   #ifdef PID_PI
140
 #endif // PIDTEMP
146
 #endif // PIDTEMP
141
 
147
 
142
 
148
 
143
-
144
-
145
-
146
-
147
-
148
-
149
-
150
 //===========================================================================
149
 //===========================================================================
151
 //=============================Mechanical Settings===========================
150
 //=============================Mechanical Settings===========================
152
 //===========================================================================
151
 //===========================================================================
177
 //#define INVERT_Z_DIR false    // for Mendel set to false, for Orca set to true
176
 //#define INVERT_Z_DIR false    // for Mendel set to false, for Orca set to true
178
 //#define INVERT_E_DIR true   // for direct drive extruder v9 set to true, for geared extruder set to false
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
 //// ENDSTOP SETTINGS:
184
 //// ENDSTOP SETTINGS:
186
 // Sets direction of endstops when homing; 1=MAX, -1=MIN
185
 // Sets direction of endstops when homing; 1=MAX, -1=MIN
243
 // The watchdog waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature
242
 // The watchdog waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature
244
 // this enables the watchdog interrupt.
243
 // this enables the watchdog interrupt.
245
 //#define USE_WATCHDOG
244
 //#define USE_WATCHDOG
246
-#ifdef USE_WATCHDOG
245
+//#ifdef USE_WATCHDOG
247
   // you cannot reboot on a mega2560 due to a bug in he bootloader. Hence, you have to reset manually, and this is done hereby:
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
 // extruder advance constant (s2/mm3)
251
 // extruder advance constant (s2/mm3)
255
 //
252
 //
307
 #define AUTOTEMP_FACTOR 1000.  //current target temperature= min+largest buffered espeeds)*FACTOR
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
 //=============================Buffers           ============================
310
 //=============================Buffers           ============================

+ 1
- 2
Marlin/Marlin.pde View File

240
     axis_steps_per_sqr_second[i] = max_acceleration_units_per_sq_second[i] * axis_steps_per_unit[i];
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
   plan_init();  // Initialize planner;
244
   plan_init();  // Initialize planner;
245
   st_init();    // Initialize stepper;
245
   st_init();    // Initialize stepper;
246
-  tp_init();    // Initialize temperature loop
247
   wd_init();
246
   wd_init();
248
 }
247
 }
249
 
248
 

+ 37
- 35
Marlin/stepper.cpp View File

56
 #ifdef ADVANCE
56
 #ifdef ADVANCE
57
   static long advance_rate, advance, final_advance = 0;
57
   static long advance_rate, advance, final_advance = 0;
58
   static short old_advance = 0;
58
   static short old_advance = 0;
59
-  static short e_steps;
60
 #endif
59
 #endif
60
+static short e_steps;
61
 static unsigned char busy = false; // TRUE when SIG_OUTPUT_COMPARE1A is being serviced. Used to avoid retriggering that handler.
61
 static unsigned char busy = false; // TRUE when SIG_OUTPUT_COMPARE1A is being serviced. Used to avoid retriggering that handler.
62
 static long acceleration_time, deceleration_time;
62
 static long acceleration_time, deceleration_time;
63
 //static unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate;
63
 //static unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate;
156
 #define DISABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 &= ~(1<<OCIE1A)
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
   //this will only work if there is no bufferig
161
   //this will only work if there is no bufferig
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
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
       counter_z = counter_x;
296
       counter_z = counter_x;
297
       counter_e = counter_x;
297
       counter_e = counter_x;
298
       step_events_completed = 0;
298
       step_events_completed = 0;
299
-      #ifdef ADVANCE
299
+ //     #ifdef ADVANCE
300
       e_steps = 0;
300
       e_steps = 0;
301
-      #endif
301
+//      #endif
302
     } 
302
     } 
303
     else {
303
     else {
304
 //      DISABLE_STEPPER_DRIVER_INTERRUPT();
304
 //      DISABLE_STEPPER_DRIVER_INTERRUPT();
309
     // Set directions TO DO This should be done once during init of trapezoid. Endstops -> interrupt
309
     // Set directions TO DO This should be done once during init of trapezoid. Endstops -> interrupt
310
     out_bits = current_block->direction_bits;
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
     // Set direction en check limit switches
312
     // Set direction en check limit switches
336
     if ((out_bits & (1<<X_AXIS)) != 0) {   // -direction
313
     if ((out_bits & (1<<X_AXIS)) != 0) {   // -direction
337
       WRITE(X_DIR_PIN, INVERT_X_DIR);
314
       WRITE(X_DIR_PIN, INVERT_X_DIR);
339
         count_direction[X_AXIS]=-1;
316
         count_direction[X_AXIS]=-1;
340
       #endif
317
       #endif
341
       #if X_MIN_PIN > -1
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
       #endif
323
       #endif
347
     }
324
     }
348
     else { // +direction 
325
     else { // +direction 
355
  //         endstops_triggered(step_events_completed);
332
  //         endstops_triggered(step_events_completed);
356
           step_events_completed = current_block->step_event_count;
333
           step_events_completed = current_block->step_event_count;
357
         }
334
         }
358
-        #endif
335
+      #endif
359
     }
336
     }
360
 
337
 
361
     if ((out_bits & (1<<Y_AXIS)) != 0) {   // -direction
338
     if ((out_bits & (1<<Y_AXIS)) != 0) {   // -direction
365
       #endif
342
       #endif
366
       #if Y_MIN_PIN > -1
343
       #if Y_MIN_PIN > -1
367
         if(READ(Y_MIN_PIN) != ENDSTOPS_INVERTING) {
344
         if(READ(Y_MIN_PIN) != ENDSTOPS_INVERTING) {
368
- //         endstops_triggered(step_events_completed);
345
+//          endstops_triggered(step_events_completed);
369
           step_events_completed = current_block->step_event_count;
346
           step_events_completed = current_block->step_event_count;
370
         }
347
         }
371
       #endif
348
       #endif
390
       #endif
367
       #endif
391
       #if Z_MIN_PIN > -1
368
       #if Z_MIN_PIN > -1
392
         if(READ(Z_MIN_PIN) != ENDSTOPS_INVERTING) {
369
         if(READ(Z_MIN_PIN) != ENDSTOPS_INVERTING) {
393
-          endstops_triggered(step_events_completed);
370
+ //         endstops_triggered(step_events_completed);
394
           step_events_completed = current_block->step_event_count;
371
           step_events_completed = current_block->step_event_count;
395
         }
372
         }
396
       #endif
373
       #endif
416
     #endif //!ADVANCE
393
     #endif //!ADVANCE
417
 
394
 
418
     for(int8_t i=0; i < step_loops; i++) { // Take multiple steps per interrupt (For high speed moves) 
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
       counter_x += current_block->steps_x;
420
       counter_x += current_block->steps_x;
420
       if (counter_x > 0) {
421
       if (counter_x > 0) {
421
         WRITE(X_STEP_PIN, HIGH);
422
         WRITE(X_STEP_PIN, HIGH);
649
   TCCR1B = (TCCR1B & ~(0x07<<CS10)) | (2<<CS10); // 2MHz timer
650
   TCCR1B = (TCCR1B & ~(0x07<<CS10)) | (2<<CS10); // 2MHz timer
650
 
651
 
651
   OCR1A = 0x4000;
652
   OCR1A = 0x4000;
652
-  DISABLE_STEPPER_DRIVER_INTERRUPT();  
653
+  TCNT1 = 0;
654
+  ENABLE_STEPPER_DRIVER_INTERRUPT();  
653
 
655
 
654
   #ifdef ADVANCE
656
   #ifdef ADVANCE
655
     e_steps = 0;
657
     e_steps = 0;

+ 3
- 3
Marlin/watchdog.pde View File

19
 /// intialise watch dog with a 1 sec interrupt time
19
 /// intialise watch dog with a 1 sec interrupt time
20
 void wd_init() 
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
 /// reset watchdog. MUST be called every 1s after init or avr will reset.
27
 /// reset watchdog. MUST be called every 1s after init or avr will reset.
27
 void wd_reset() 
28
 void wd_reset() 
28
 {
29
 {
29
   wdt_reset();
30
   wdt_reset();
30
-  timeout_seconds=0; //reset counter for resets
31
 }
31
 }
32
 
32
 
33
 //===========================================================================
33
 //===========================================================================

Loading…
Cancel
Save