chiark / gitweb /
M206: always use homing ("homeing") offsets
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 1 Aug 2012 20:12:14 +0000 (21:12 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 1 Aug 2012 20:25:57 +0000 (21:25 +0100)
Previously the parameters set in M206 would only be used if a G82
command was sent with specific axis home values.  This limits its
usefulness.

Really, we should have a way to adjust the XYZ homing of a machine in
the eeprom.  So as the first stage of this, make M206 affect every
home command.  The values set using M206 are now added to the
configuration variables [XYZ]_HOME_POS.

This is achieved by replacing all uses of [XYZ]_HOME_POS in the code
by [XYZ]_HOME_POS_A which is a macro which includes the adjustment.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Marlin/Marlin.h
Marlin/Marlin.pde
Marlin/motion_control.cpp
README.md

index 4123634442cfede7b3c26de9e6cc6deb4b37d357..7645830fdfae863c27be199af391445855ca282b 100644 (file)
@@ -157,6 +157,10 @@ void manage_inactivity(byte debug);
 enum AxisEnum {X_AXIS=0, Y_AXIS=1, Z_AXIS=2, E_AXIS=3};
 
 
+#define X_HOME_POS_A (X_HOME_POS + add_homeing[X_AXIS])
+#define Y_HOME_POS_A (Y_HOME_POS + add_homeing[Y_AXIS])
+#define Z_HOME_POS_A (Z_HOME_POS + add_homeing[Z_AXIS])
+
 void FlushSerialRequestResend();
 void ClearToSend();
 
index 73f1f4126b84350000c24ca825ab69a5f7696912..dd40cdf76dc0d1fac55048ee5b6a2c9e80000db3 100644 (file)
@@ -562,7 +562,7 @@ bool code_seen(char code)
     plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); \
     st_synchronize();\
     \
-    current_position[LETTER##_AXIS] = LETTER##_HOME_POS;\
+    current_position[LETTER##_AXIS] = LETTER##_HOME_POS_A;\
     destination[LETTER##_AXIS] = current_position[LETTER##_AXIS];\
     feedrate = 0.0;\
     endstops_hit_on_purpose();\
@@ -676,8 +676,8 @@ void process_commands()
         plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
         st_synchronize();
     
-        current_position[X_AXIS] = X_HOME_POS;
-        current_position[Y_AXIS] = Y_HOME_POS;
+        current_position[X_AXIS] = X_HOME_POS_A;
+        current_position[Y_AXIS] = Y_HOME_POS_A;
         plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
         destination[X_AXIS] = current_position[X_AXIS];
         destination[Y_AXIS] = current_position[Y_AXIS];
index f11d8c8b8e5ec6b24e7cf512d6f6a8b8a96c6f04..6bcea4137293ddef6e022a02282bfccead466232 100644 (file)
@@ -126,9 +126,9 @@ void mc_arc(float *position, float *target, float *offset, uint8_t axis_0, uint8
     arc_target[E_AXIS] += extruder_per_segment;
 
     if (min_software_endstops) {
-      if (arc_target[X_AXIS] < X_HOME_POS) arc_target[X_AXIS] = X_HOME_POS;
-      if (arc_target[Y_AXIS] < Y_HOME_POS) arc_target[Y_AXIS] = Y_HOME_POS;
-      if (arc_target[Z_AXIS] < Z_HOME_POS) arc_target[Z_AXIS] = Z_HOME_POS;
+      if (arc_target[X_AXIS] < X_HOME_POS_A) arc_target[X_AXIS] = X_HOME_POS_A;
+      if (arc_target[Y_AXIS] < Y_HOME_POS_A) arc_target[Y_AXIS] = Y_HOME_POS_A;
+      if (arc_target[Z_AXIS] < Z_HOME_POS_A) arc_target[Z_AXIS] = Z_HOME_POS_A;
     }
 
     if (max_software_endstops) {
index 86dd93de952da7086db17b215378dd78dd3a6422..fb2c18968c4f8ad5a298331c5b19fbfd451dcd21 100644 (file)
--- a/README.md
+++ b/README.md
@@ -152,6 +152,7 @@ Movement variables:
 *   M202 - Set max acceleration in units/s^2 for travel moves (M202 X1000 Y1000) Unused in Marlin!!\r
 *   M203 - Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in mm/sec\r
 *   M204 - Set default acceleration: S normal moves T filament only moves (M204 S3000 T7000) im mm/sec^2  also sets minimum segment time in ms (B20000) to prevent buffer underruns and M20 minimum feedrate\r
+*   M206 - set home offsets.  This sets the X,Y,Z coordinates of the endstops (and is added to the {X,Y,Z}_HOME_POS configuration options (and is also added to the coordinates, if any, provided to G82, as with earlier firmware)\r
 *   M220 - set build speed mulitplying S:factor in percent ; aka "realtime tuneing in the gcode". So you can slow down if you have islands in one height-range, and speed up otherwise.\r
 *   M221 - set the extrude multiplying S:factor in percent\r
 *   M400 - Finish all buffered moves.\r