Explorar el Código

software_endstops: use *_MIN_POS and *_MAX_POS for arcs

If [XYZ]_HOME_POS and [XYZ]_MIN_POS aren't 0, these corrections are
wrong.  Use the same logic as in Marlin.pde:prepare_move: ie, clamp to
[XYZ]_{MIN,MAX}_POS.

While we're here, put this cut-and-paste code in a function
clamp_to_software_endstops.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Ian Jackson hace 13 años
padre
commit
faccb35850
Se han modificado 3 ficheros con 15 adiciones y 18 borrados
  1. 1
    0
      Marlin/Marlin.h
  2. 13
    7
      Marlin/Marlin.pde
  3. 1
    11
      Marlin/motion_control.cpp

+ 1
- 0
Marlin/Marlin.h Ver fichero

169
 
169
 
170
 void enquecommand(const char *cmd); //put an ascii command at the end of the current buffer.
170
 void enquecommand(const char *cmd); //put an ascii command at the end of the current buffer.
171
 void prepare_arc_move(char isclockwise);
171
 void prepare_arc_move(char isclockwise);
172
+void clamp_to_software_endstops(float target[3]);
172
 
173
 
173
 #ifdef FAST_PWM_FAN
174
 #ifdef FAST_PWM_FAN
174
 void setPwmFrequency(uint8_t pin, int val);
175
 void setPwmFrequency(uint8_t pin, int val);

+ 13
- 7
Marlin/Marlin.pde Ver fichero

1541
    }
1541
    }
1542
 }
1542
 }
1543
 
1543
 
1544
-void prepare_move()
1544
+void clamp_to_software_endstops(float target[3])
1545
 {
1545
 {
1546
   if (min_software_endstops) {
1546
   if (min_software_endstops) {
1547
-    if (destination[X_AXIS] < X_MIN_POS) destination[X_AXIS] = X_MIN_POS;
1548
-    if (destination[Y_AXIS] < Y_MIN_POS) destination[Y_AXIS] = Y_MIN_POS;
1549
-    if (destination[Z_AXIS] < Z_MIN_POS) destination[Z_AXIS] = Z_MIN_POS;
1547
+    if (target[X_AXIS] < X_MIN_POS) target[X_AXIS] = X_MIN_POS;
1548
+    if (target[Y_AXIS] < Y_MIN_POS) target[Y_AXIS] = Y_MIN_POS;
1549
+    if (target[Z_AXIS] < Z_MIN_POS) target[Z_AXIS] = Z_MIN_POS;
1550
   }
1550
   }
1551
 
1551
 
1552
   if (max_software_endstops) {
1552
   if (max_software_endstops) {
1553
-    if (destination[X_AXIS] > X_MAX_POS) destination[X_AXIS] = X_MAX_POS;
1554
-    if (destination[Y_AXIS] > Y_MAX_POS) destination[Y_AXIS] = Y_MAX_POS;
1555
-    if (destination[Z_AXIS] > Z_MAX_POS) destination[Z_AXIS] = Z_MAX_POS;
1553
+    if (target[X_AXIS] > X_MAX_POS) target[X_AXIS] = X_MAX_POS;
1554
+    if (target[Y_AXIS] > Y_MAX_POS) target[Y_AXIS] = Y_MAX_POS;
1555
+    if (target[Z_AXIS] > Z_MAX_POS) target[Z_AXIS] = Z_MAX_POS;
1556
   }
1556
   }
1557
+}
1558
+
1559
+void prepare_move()
1560
+{
1561
+  clamp_to_software_endstops(destination);
1562
+
1557
   previous_millis_cmd = millis();  
1563
   previous_millis_cmd = millis();  
1558
   plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder);
1564
   plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder);
1559
   for(int8_t i=0; i < NUM_AXIS; i++) {
1565
   for(int8_t i=0; i < NUM_AXIS; i++) {

+ 1
- 11
Marlin/motion_control.cpp Ver fichero

125
     arc_target[axis_linear] += linear_per_segment;
125
     arc_target[axis_linear] += linear_per_segment;
126
     arc_target[E_AXIS] += extruder_per_segment;
126
     arc_target[E_AXIS] += extruder_per_segment;
127
 
127
 
128
-    if (min_software_endstops) {
129
-      if (arc_target[X_AXIS] < X_HOME_POS) arc_target[X_AXIS] = X_HOME_POS;
130
-      if (arc_target[Y_AXIS] < Y_HOME_POS) arc_target[Y_AXIS] = Y_HOME_POS;
131
-      if (arc_target[Z_AXIS] < Z_HOME_POS) arc_target[Z_AXIS] = Z_HOME_POS;
132
-    }
133
-
134
-    if (max_software_endstops) {
135
-      if (arc_target[X_AXIS] > X_MAX_LENGTH) arc_target[X_AXIS] = X_MAX_LENGTH;
136
-      if (arc_target[Y_AXIS] > Y_MAX_LENGTH) arc_target[Y_AXIS] = Y_MAX_LENGTH;
137
-      if (arc_target[Z_AXIS] > Z_MAX_LENGTH) arc_target[Z_AXIS] = Z_MAX_LENGTH;
138
-    }
128
+    clamp_to_software_endstops(arc_target);
139
     plan_buffer_line(arc_target[X_AXIS], arc_target[Y_AXIS], arc_target[Z_AXIS], arc_target[E_AXIS], feed_rate, extruder);
129
     plan_buffer_line(arc_target[X_AXIS], arc_target[Y_AXIS], arc_target[Z_AXIS], arc_target[E_AXIS], feed_rate, extruder);
140
     
130
     
141
   }
131
   }

Loading…
Cancelar
Guardar