浏览代码

Advance experiments. Not working yet.

Erik van der Zalm 13 年前
父节点
当前提交
e7dca8614b
共有 4 个文件被更改,包括 61 次插入65 次删除
  1. 20
    25
      Marlin/Configuration.h
  2. 1
    2
      Marlin/Marlin.pde
  3. 37
    35
      Marlin/stepper.cpp
  4. 3
    3
      Marlin/watchdog.pde

+ 20
- 25
Marlin/Configuration.h 查看文件

@@ -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
@@ -31,7 +31,7 @@
31 31
 // Sanguinololu 1.2 and above = 62
32 32
 // Ultimaker = 7,
33 33
 // Teensylu = 8
34
-#define MOTHERBOARD 7
34
+#define MOTHERBOARD 5
35 35
 
36 36
 //===========================================================================
37 37
 //=============================Thermal Settings  ============================
@@ -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
@@ -120,9 +120,15 @@
120 120
 //    #define  DEFAULT_Ki (2*Kp/PID_SWING_AT_CRITIAL*PID_dT)  
121 121
 //    #define  DEFAULT_Kd (PID_SWING_AT_CRITIAL/8./PID_dT)  
122 122
 
123
+// Ultitmaker
123 124
     #define  DEFAULT_Kp  22.2
124 125
     #define  DEFAULT_Ki (1.25*PID_dT)  
125 126
     #define  DEFAULT_Kd (99/PID_dT)  
127
+
128
+// Mendel Parts V9 on 12V    
129
+//    #define  DEFAULT_Kp  63.0
130
+//    #define  DEFAULT_Ki (2.25*PID_dT)  
131
+//    #define  DEFAULT_Kd (440/PID_dT)  
126 132
   #endif
127 133
    
128 134
   #ifdef PID_PI
@@ -141,13 +147,6 @@
141 147
 #endif // PIDTEMP
142 148
 
143 149
 
144
-
145
-
146
-
147
-
148
-
149
-
150
-
151 150
 //===========================================================================
152 151
 //=============================Mechanical Settings===========================
153 152
 //===========================================================================
@@ -178,10 +177,10 @@ const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the
178 177
 //#define INVERT_Z_DIR false    // for Mendel set to false, for Orca set to true
179 178
 //#define INVERT_E_DIR true   // for direct drive extruder v9 set to true, for geared extruder set to false
180 179
 
181
-#define INVERT_X_DIR true    // for Mendel set to false, for Orca set to true
182
-#define INVERT_Y_DIR false   // for Mendel set to true, for Orca set to false
183
-#define INVERT_Z_DIR true    // for Mendel set to false, for Orca set to true
184
-#define INVERT_E_DIR false   // for direct drive extruder v9 set to true, for geared extruder set to false
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
185 184
 
186 185
 //// ENDSTOP SETTINGS:
187 186
 // Sets direction of endstops when homing; 1=MAX, -1=MIN
@@ -243,13 +242,10 @@ const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the
243 242
 
244 243
 // The watchdog waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature
245 244
 // this enables the watchdog interrupt.
246
-#define USE_WATCHDOG
245
+//#define 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
-
251
-
252
-
247
+//#define RESET_MANUAL
248
+//#define WATCHDOG_TIMEOUT 4  //seconds
253 249
 
254 250
 // extruder advance constant (s2/mm3)
255 251
 //
@@ -275,7 +271,7 @@ const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the
275 271
 //#define ULTRA_LCD  //general lcd support, also 16x2
276 272
 //#define SDSUPPORT // Enable SD Card Support in Hardware Console
277 273
 
278
-#define ULTIPANEL
274
+//#define ULTIPANEL
279 275
 #ifdef ULTIPANEL
280 276
 //  #define NEWPANEL  //enable this if you have a click-encoder panel
281 277
   #define SDSUPPORT
@@ -307,8 +303,7 @@ const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the
307 303
 #define AUTOTEMP_FACTOR 1000.  //current target temperature= min+largest buffered espeeds)*FACTOR
308 304
 
309 305
 
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
306
+const int dropsegments=5; //everything with less than this number of steps will be ignored as move and joined with the next movement
312 307
 
313 308
 //===========================================================================
314 309
 //=============================Buffers           ============================

+ 1
- 2
Marlin/Marlin.pde 查看文件

@@ -232,10 +232,9 @@ void setup()
232 232
     axis_steps_per_sqr_second[i] = max_acceleration_units_per_sq_second[i] * axis_steps_per_unit[i];
233 233
   }
234 234
 
235
-  
235
+  tp_init();    // Initialize temperature loop 
236 236
   plan_init();  // Initialize planner;
237 237
   st_init();    // Initialize stepper;
238
-  tp_init();    // Initialize temperature loop
239 238
 }
240 239
 
241 240
 

+ 37
- 35
Marlin/stepper.cpp 查看文件

@@ -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 查看文件

@@ -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
 //===========================================================================

正在加载...
取消
保存