Explorar el Código

Seperate ENDSTOP_INVERTING for X Y and Z

Added simple endstop filter.
Corrected M114 count display.
Erik van der Zalm hace 13 años
padre
commit
c0f8c9fd72
Se han modificado 6 ficheros con 62 adiciones y 18 borrados
  1. 3
    1
      Marlin/Configuration.h
  2. 16
    9
      Marlin/Marlin.pde
  3. 7
    0
      Marlin/planner.cpp
  4. 1
    1
      Marlin/planner.h
  5. 33
    6
      Marlin/stepper.cpp
  6. 2
    1
      Marlin/stepper.h

+ 3
- 1
Marlin/Configuration.h Ver fichero

@@ -157,7 +157,9 @@
157 157
 // Endstop Settings
158 158
 #define ENDSTOPPULLUPS // Comment this out (using // at the start of the line) to disable the endstop pullup resistors
159 159
 // The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins.
160
-const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops. 
160
+const bool X_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops. 
161
+const bool Y_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops. 
162
+const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops. 
161 163
 // For optos H21LOB set to true, for Mendel-Parts newer optos TCST2103 set to false
162 164
 
163 165
 

+ 16
- 9
Marlin/Marlin.pde Ver fichero

@@ -556,12 +556,19 @@ inline void process_commands()
556 556
       relative_mode = true;
557 557
       break;
558 558
     case 92: // G92
559
-      if(!code_seen(axis_codes[E_AXIS])) 
559
+      if(!code_seen(axis_codes[E_AXIS]))
560 560
         st_synchronize();
561 561
       for(int8_t i=0; i < NUM_AXIS; i++) {
562
-        if(code_seen(axis_codes[i])) current_position[i] = code_value();  
562
+        if(code_seen(axis_codes[i])) { 
563
+           current_position[i] = code_value();  
564
+           if(i == E_AXIS) {
565
+             plan_set_e_position(current_position[E_AXIS]);
566
+           }
567
+           else {
568
+             plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
569
+           }
570
+        }
563 571
       }
564
-      plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
565 572
       break;
566 573
     }
567 574
   }
@@ -865,27 +872,27 @@ inline void process_commands()
865 872
     case 119: // M119
866 873
       #if (X_MIN_PIN > -1)
867 874
         SERIAL_PROTOCOLPGM("x_min:");
868
-        SERIAL_PROTOCOL(((READ(X_MIN_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
875
+        SERIAL_PROTOCOL(((READ(X_MIN_PIN)^X_ENDSTOPS_INVERTING)?"H ":"L "));
869 876
       #endif
870 877
       #if (X_MAX_PIN > -1)
871 878
         SERIAL_PROTOCOLPGM("x_max:");
872
-        SERIAL_PROTOCOL(((READ(X_MAX_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
879
+        SERIAL_PROTOCOL(((READ(X_MAX_PIN)^X_ENDSTOPS_INVERTING)?"H ":"L "));
873 880
       #endif
874 881
       #if (Y_MIN_PIN > -1)
875 882
         SERIAL_PROTOCOLPGM("y_min:");
876
-        SERIAL_PROTOCOL(((READ(Y_MIN_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
883
+        SERIAL_PROTOCOL(((READ(Y_MIN_PIN)^Y_ENDSTOPS_INVERTING)?"H ":"L "));
877 884
       #endif
878 885
       #if (Y_MAX_PIN > -1)
879 886
         SERIAL_PROTOCOLPGM("y_max:");
880
-        SERIAL_PROTOCOL(((READ(Y_MAX_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
887
+        SERIAL_PROTOCOL(((READ(Y_MAX_PIN)^Y_ENDSTOPS_INVERTING)?"H ":"L "));
881 888
       #endif
882 889
       #if (Z_MIN_PIN > -1)
883 890
         SERIAL_PROTOCOLPGM("z_min:");
884
-        SERIAL_PROTOCOL(((READ(Z_MIN_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
891
+        SERIAL_PROTOCOL(((READ(Z_MIN_PIN)^Z_ENDSTOPS_INVERTING)?"H ":"L "));
885 892
       #endif
886 893
       #if (Z_MAX_PIN > -1)
887 894
         SERIAL_PROTOCOLPGM("z_max:");
888
-        SERIAL_PROTOCOL(((READ(Z_MAX_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
895
+        SERIAL_PROTOCOL(((READ(Z_MAX_PIN)^Z_ENDSTOPS_INVERTING)?"H ":"L "));
889 896
       #endif
890 897
       SERIAL_PROTOCOLLN("");
891 898
       break;

+ 7
- 0
Marlin/planner.cpp Ver fichero

@@ -762,7 +762,14 @@ void plan_set_position(const float &x, const float &y, const float &z, const flo
762 762
   previous_speed[3] = 0.0;
763 763
 }
764 764
 
765
+void plan_set_e_position(const float &e)
766
+{
767
+  position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]);  
768
+  st_set_e_position(position[E_AXIS]);
769
+}
770
+
765 771
 uint8_t movesplanned()
766 772
 {
767 773
  return (block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1);
768 774
 }
775
+

+ 1
- 1
Marlin/planner.h Ver fichero

@@ -70,7 +70,7 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
70 70
 
71 71
 // Set position. Used for G92 instructions.
72 72
 void plan_set_position(const float &x, const float &y, const float &z, const float &e);
73
-
73
+void plan_set_e_position(const float &e);
74 74
 
75 75
 // Called when the current block is no longer needed. Discards the block and makes the memory
76 76
 // availible for new blocks.

+ 33
- 6
Marlin/stepper.cpp Ver fichero

@@ -70,6 +70,13 @@ static volatile bool endstop_x_hit=false;
70 70
 static volatile bool endstop_y_hit=false;
71 71
 static volatile bool endstop_z_hit=false;
72 72
 
73
+static bool old_x_min_endstop=false;
74
+static bool old_x_max_endstop=false;
75
+static bool old_y_min_endstop=false;
76
+static bool old_y_max_endstop=false;
77
+static bool old_z_min_endstop=false;
78
+static bool old_z_max_endstop=false;
79
+
73 80
 volatile long count_position[NUM_AXIS] = { 0, 0, 0, 0};
74 81
 volatile char count_direction[NUM_AXIS] = { 1, 1, 1, 1};
75 82
 
@@ -260,6 +267,7 @@ ISR(TIMER1_COMPA_vect)
260 267
     SERIAL_ERROR_START
261 268
     SERIAL_ERROR(*(unsigned short *)OCR1A);
262 269
     SERIAL_ERRORLNPGM(" ISR overtaking itself.");
270
+    OCR1A = 0x30000;
263 271
     return; 
264 272
   } // The busy-flag is used to avoid reentering this interrupt
265 273
 
@@ -295,22 +303,26 @@ ISR(TIMER1_COMPA_vect)
295 303
       WRITE(X_DIR_PIN, INVERT_X_DIR);
296 304
       count_direction[X_AXIS]=-1;
297 305
       #if X_MIN_PIN > -1
298
-        if((READ(X_MIN_PIN) != ENDSTOPS_INVERTING) && (current_block->steps_x > 0)) {
306
+        bool x_min_endstop=(READ(X_MIN_PIN) != X_ENDSTOPS_INVERTING);
307
+        if(x_min_endstop && old_x_min_endstop && (current_block->steps_x > 0)) {
299 308
           endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
300 309
           endstop_x_hit=true;
301 310
           step_events_completed = current_block->step_event_count;
302 311
         }
312
+        old_x_min_endstop = x_min_endstop;
303 313
       #endif
304 314
     }
305 315
     else { // +direction 
306 316
       WRITE(X_DIR_PIN,!INVERT_X_DIR);
307 317
       count_direction[X_AXIS]=1;
308 318
       #if X_MAX_PIN > -1
309
-        if((READ(X_MAX_PIN) != ENDSTOPS_INVERTING) && (current_block->steps_x > 0)){
319
+        bool x_max_endstop=(READ(X_MAX_PIN) != X_ENDSTOPS_INVERTING);
320
+        if(x_max_endstop && old_x_max_endstop && (current_block->steps_x > 0)){
310 321
           endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
311 322
           endstop_x_hit=true;
312 323
           step_events_completed = current_block->step_event_count;
313 324
         }
325
+        old_x_max_endstop = x_max_endstop;
314 326
       #endif
315 327
     }
316 328
 
@@ -318,22 +330,26 @@ ISR(TIMER1_COMPA_vect)
318 330
       WRITE(Y_DIR_PIN,INVERT_Y_DIR);
319 331
       count_direction[Y_AXIS]=-1;
320 332
       #if Y_MIN_PIN > -1
321
-        if((READ(Y_MIN_PIN) != ENDSTOPS_INVERTING) && (current_block->steps_y > 0)) {
333
+        bool y_min_endstop=(READ(Y_MIN_PIN) != Y_ENDSTOPS_INVERTING);
334
+        if(y_min_endstop && old_y_min_endstop && (current_block->steps_y > 0)) {
322 335
           endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
323 336
           endstop_y_hit=true;
324 337
           step_events_completed = current_block->step_event_count;
325 338
         }
339
+        old_y_min_endstop = y_min_endstop;
326 340
       #endif
327 341
     }
328 342
     else { // +direction
329 343
     WRITE(Y_DIR_PIN,!INVERT_Y_DIR);
330 344
       count_direction[Y_AXIS]=1;
331 345
       #if Y_MAX_PIN > -1
332
-      if((READ(Y_MAX_PIN) != ENDSTOPS_INVERTING) && (current_block->steps_y > 0)){
346
+        bool y_max_endstop=(READ(Y_MAX_PIN) != Y_ENDSTOPS_INVERTING);
347
+        if(y_max_endstop && old_y_max_endstop && (current_block->steps_y > 0)){
333 348
           endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
334 349
           endstop_y_hit=true;
335 350
           step_events_completed = current_block->step_event_count;
336 351
         }
352
+        old_y_max_endstop = y_max_endstop;
337 353
       #endif
338 354
     }
339 355
 
@@ -341,22 +357,26 @@ ISR(TIMER1_COMPA_vect)
341 357
       WRITE(Z_DIR_PIN,INVERT_Z_DIR);
342 358
       count_direction[Z_AXIS]=-1;
343 359
       #if Z_MIN_PIN > -1
344
-        if((READ(Z_MIN_PIN) != ENDSTOPS_INVERTING) && (current_block->steps_z > 0)) {
360
+        bool z_min_endstop=(READ(Z_MIN_PIN) != Z_ENDSTOPS_INVERTING);
361
+        if(z_min_endstop && old_z_min_endstop && (current_block->steps_z > 0)) {
345 362
           endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
346 363
           endstop_z_hit=true;
347 364
           step_events_completed = current_block->step_event_count;
348 365
         }
366
+        old_z_min_endstop = z_min_endstop;
349 367
       #endif
350 368
     }
351 369
     else { // +direction
352 370
       WRITE(Z_DIR_PIN,!INVERT_Z_DIR);
353 371
         count_direction[Z_AXIS]=1;
354 372
       #if Z_MAX_PIN > -1
355
-        if((READ(Z_MAX_PIN) != ENDSTOPS_INVERTING)  && (current_block->steps_z > 0)){
373
+        bool z_max_endstop=(READ(Z_MAX_PIN) != Z_ENDSTOPS_INVERTING);
374
+        if(z_max_endstop && old_z_max_endstop && (current_block->steps_z > 0)) {
356 375
           endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
357 376
           endstop_z_hit=true;
358 377
           step_events_completed = current_block->step_event_count;
359 378
         }
379
+        old_z_max_endstop = z_max_endstop;
360 380
       #endif
361 381
     }
362 382
 
@@ -654,6 +674,13 @@ void st_set_position(const long &x, const long &y, const long &z, const long &e)
654 674
   CRITICAL_SECTION_END;
655 675
 }
656 676
 
677
+void st_set_e_position(const long &e)
678
+{
679
+  CRITICAL_SECTION_START;
680
+  count_position[E_AXIS] = e;
681
+  CRITICAL_SECTION_END;
682
+}
683
+
657 684
 long st_get_position(char axis)
658 685
 {
659 686
   long count_pos;

+ 2
- 1
Marlin/stepper.h Ver fichero

@@ -31,6 +31,7 @@ void st_synchronize();
31 31
 
32 32
 // Set current position in steps
33 33
 void st_set_position(const long &x, const long &y, const long &z, const long &e);
34
+void st_set_e_position(const long &e);
34 35
 
35 36
 // Get current position in steps
36 37
 long st_get_position(char axis);
@@ -48,4 +49,4 @@ void endstops_hit_on_purpose(); //avoid creation of the message, i.e. after home
48 49
 extern block_t *current_block;  // A pointer to the block currently being traced
49 50
 
50 51
 
51
-#endif
52
+#endif

Loading…
Cancelar
Guardar