Browse Source

Merge pull request #209 from ijackson/for-upstream

M206 fixes, and ancillary improvements
ErikZalm 12 years ago
parent
commit
22aae62ccd
8 changed files with 140 additions and 70 deletions
  1. 5
    0
      .gitignore
  2. 0
    2
      Marlin/.gitignore
  3. 11
    1
      Marlin/EEPROMwrite.h
  4. 30
    21
      Marlin/Makefile
  5. 8
    1
      Marlin/Marlin.h
  6. 84
    34
      Marlin/Marlin.pde
  7. 1
    11
      Marlin/motion_control.cpp
  8. 1
    0
      README.md

+ 5
- 0
.gitignore View File

1
+*.o
2
+applet/
3
+*~
4
+*.orig
5
+*.rej

+ 0
- 2
Marlin/.gitignore View File

1
-*.o
2
-applet/

+ 11
- 1
Marlin/EEPROMwrite.h View File

38
 // the default values are used whenever there is a change to the data, to prevent
38
 // the default values are used whenever there is a change to the data, to prevent
39
 // wrong data being written to the variables.
39
 // wrong data being written to the variables.
40
 // ALSO:  always make sure the variables in the Store and retrieve sections are in the same order.
40
 // ALSO:  always make sure the variables in the Store and retrieve sections are in the same order.
41
-#define EEPROM_VERSION "V05"  
41
+#define EEPROM_VERSION "V06"
42
 
42
 
43
 inline void EEPROM_StoreSettings() 
43
 inline void EEPROM_StoreSettings() 
44
 {
44
 {
57
   EEPROM_writeAnything(i,max_xy_jerk);
57
   EEPROM_writeAnything(i,max_xy_jerk);
58
   EEPROM_writeAnything(i,max_z_jerk);
58
   EEPROM_writeAnything(i,max_z_jerk);
59
   EEPROM_writeAnything(i,max_e_jerk);
59
   EEPROM_writeAnything(i,max_e_jerk);
60
+  EEPROM_writeAnything(i,add_homeing);
60
   #ifdef PIDTEMP
61
   #ifdef PIDTEMP
61
     EEPROM_writeAnything(i,Kp);
62
     EEPROM_writeAnything(i,Kp);
62
     EEPROM_writeAnything(i,Ki);
63
     EEPROM_writeAnything(i,Ki);
119
       SERIAL_ECHOPAIR(" Z" ,max_z_jerk);
120
       SERIAL_ECHOPAIR(" Z" ,max_z_jerk);
120
       SERIAL_ECHOPAIR(" E" ,max_e_jerk);
121
       SERIAL_ECHOPAIR(" E" ,max_e_jerk);
121
       SERIAL_ECHOLN(""); 
122
       SERIAL_ECHOLN(""); 
123
+    SERIAL_ECHO_START;
124
+      SERIAL_ECHOLNPGM("Home offset (mm):");
125
+      SERIAL_ECHO_START;
126
+      SERIAL_ECHOPAIR("  M206 X",add_homeing[0] );
127
+      SERIAL_ECHOPAIR(" Y" ,add_homeing[1] );
128
+      SERIAL_ECHOPAIR(" Z" ,add_homeing[2] );
129
+      SERIAL_ECHOLN("");
122
     #ifdef PIDTEMP
130
     #ifdef PIDTEMP
123
       SERIAL_ECHO_START;
131
       SERIAL_ECHO_START;
124
       SERIAL_ECHOLNPGM("PID settings:");
132
       SERIAL_ECHOLNPGM("PID settings:");
153
       EEPROM_readAnything(i,max_xy_jerk);
161
       EEPROM_readAnything(i,max_xy_jerk);
154
       EEPROM_readAnything(i,max_z_jerk);
162
       EEPROM_readAnything(i,max_z_jerk);
155
       EEPROM_readAnything(i,max_e_jerk);
163
       EEPROM_readAnything(i,max_e_jerk);
164
+      EEPROM_readAnything(i,add_homeing);
156
       #ifndef PIDTEMP
165
       #ifndef PIDTEMP
157
         float Kp,Ki,Kd;
166
         float Kp,Ki,Kd;
158
       #endif
167
       #endif
183
       max_xy_jerk=DEFAULT_XYJERK;
192
       max_xy_jerk=DEFAULT_XYJERK;
184
       max_z_jerk=DEFAULT_ZJERK;
193
       max_z_jerk=DEFAULT_ZJERK;
185
       max_e_jerk=DEFAULT_EJERK;
194
       max_e_jerk=DEFAULT_EJERK;
195
+      add_homeing[0] = add_homeing[1] = add_homeing[2] = 0;
186
       SERIAL_ECHO_START;
196
       SERIAL_ECHO_START;
187
       SERIAL_ECHOLN("Using Default settings:");
197
       SERIAL_ECHOLN("Using Default settings:");
188
     }
198
     }

+ 30
- 21
Marlin/Makefile View File

170
 ALL_CXXFLAGS = -mmcu=$(MCU) $(CXXFLAGS)
170
 ALL_CXXFLAGS = -mmcu=$(MCU) $(CXXFLAGS)
171
 ALL_ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp $(ASFLAGS)
171
 ALL_ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp $(ASFLAGS)
172
 
172
 
173
+# set V=1 (eg, "make V=1") to print the full commands etc.
174
+ifneq ($V,1)
175
+ Pecho=@echo
176
+ P=@
177
+else
178
+ Pecho=@:
179
+ P=
180
+endif
173
 
181
 
174
 # Default target.
182
 # Default target.
175
 all: sizeafter
183
 all: sizeafter
178
 
186
 
179
 # Creates the object directory
187
 # Creates the object directory
180
 applet: 
188
 applet: 
181
-	@mkdir -p applet
189
+	$P mkdir -p applet
182
 
190
 
183
 # the .cpp for Marlin depends on the .pde
191
 # the .cpp for Marlin depends on the .pde
184
 #applet/$(TARGET).cpp: $(TARGET).pde
192
 #applet/$(TARGET).cpp: $(TARGET).pde
189
 # Here is the "preprocessing".
197
 # Here is the "preprocessing".
190
 # It creates a .cpp file based with the same name as the .pde file.
198
 # It creates a .cpp file based with the same name as the .pde file.
191
 # On top of the new .cpp file comes the WProgram.h header.
199
 # On top of the new .cpp file comes the WProgram.h header.
192
-	@echo "  WR    $@"
193
-	@echo '#include "WProgram.h"' > $@
194
-	@echo '#include "$<"' >>$@
195
-	@echo '#include "$(ARDUINO)/main.cpp"' >> $@
200
+	$(Pecho) "  WR    $@"
201
+	$P echo '#include "WProgram.h"' > $@
202
+	$P echo '#include "$<"' >>$@
203
+	$P echo '#include "$(ARDUINO)/main.cpp"' >> $@
196
 
204
 
197
 elf: applet/$(TARGET).elf
205
 elf: applet/$(TARGET).elf
198
 hex: applet/$(TARGET).hex
206
 hex: applet/$(TARGET).hex
213
 
221
 
214
 	# Display size of file.
222
 	# Display size of file.
215
 HEXSIZE = $(SIZE) --target=$(FORMAT) applet/$(TARGET).hex
223
 HEXSIZE = $(SIZE) --target=$(FORMAT) applet/$(TARGET).hex
216
-ELFSIZE = $(SIZE)  applet/$(TARGET).elf
224
+ELFSIZE = $(SIZE) --mcu=$(MCU) -C applet/$(TARGET).elf; \
225
+          $(SIZE)  applet/$(TARGET).elf
217
 sizebefore:
226
 sizebefore:
218
-	@if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
227
+	$P if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
219
 
228
 
220
 sizeafter: build
229
 sizeafter: build
221
-	@if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
230
+	$P if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
222
 
231
 
223
 
232
 
224
 # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
233
 # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
241
 .PRECIOUS: .o
250
 .PRECIOUS: .o
242
 
251
 
243
 .elf.hex:
252
 .elf.hex:
244
-	@echo "  COPY  $@"
245
-	@$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
253
+	$(Pecho) "  COPY  $@"
254
+	$P $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
246
 
255
 
247
 .elf.eep:
256
 .elf.eep:
248
 	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
257
 	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
258
 
267
 
259
 	# Link: create ELF output file from library.
268
 	# Link: create ELF output file from library.
260
 applet/$(TARGET).elf: applet/$(TARGET).cpp applet/core.a Configuration.h
269
 applet/$(TARGET).elf: applet/$(TARGET).cpp applet/core.a Configuration.h
261
-	@echo "  CXX   $@"
262
-	@$(CC) $(ALL_CXXFLAGS) -Wl,--gc-sections -o $@ applet/$(TARGET).cpp -L. applet/core.a $(LDFLAGS)
270
+	$(Pecho) "  CXX   $@"
271
+	$P $(CC) $(ALL_CXXFLAGS) -Wl,--gc-sections -o $@ applet/$(TARGET).cpp -L. applet/core.a $(LDFLAGS)
263
 
272
 
264
 applet/core.a: $(OBJ)
273
 applet/core.a: $(OBJ)
265
-	@for i in $(OBJ); do echo "  AR    $$i"; $(AR) rcs applet/core.a $$i; done
274
+	$P for i in $(OBJ); do echo "  AR    $$i"; $(AR) rcs applet/core.a $$i; done
266
 
275
 
267
 applet/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE)
276
 applet/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE)
268
-	@echo "  CC    $@"
269
-	@$(CC) -MMD -c $(ALL_CFLAGS) $< -o $@
277
+	$(Pecho) "  CC    $@"
278
+	$P $(CC) -MMD -c $(ALL_CFLAGS) $< -o $@
270
 
279
 
271
 applet/%.o: %.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
280
 applet/%.o: %.cpp Configuration.h Configuration_adv.h $(MAKEFILE)
272
-	@echo "  CXX   $@"
273
-	@$(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@
281
+	$(Pecho) "  CXX   $@"
282
+	$P $(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@
274
 
283
 
275
 
284
 
276
 # Target: clean project.
285
 # Target: clean project.
277
 clean:
286
 clean:
278
-	@echo "  RM    applet/*"
279
-	@$(REMOVE) applet/$(TARGET).hex applet/$(TARGET).eep applet/$(TARGET).cof applet/$(TARGET).elf \
287
+	$(Pecho) "  RM    applet/*"
288
+	$P $(REMOVE) applet/$(TARGET).hex applet/$(TARGET).eep applet/$(TARGET).cof applet/$(TARGET).elf \
280
 		applet/$(TARGET).map applet/$(TARGET).sym applet/$(TARGET).lss applet/$(TARGET).cpp applet/core.a \
289
 		applet/$(TARGET).map applet/$(TARGET).sym applet/$(TARGET).lss applet/$(TARGET).cpp applet/core.a \
281
 		$(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
290
 		$(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
282
-	@echo "  RMDIR applet/"
283
-	@rm -rf applet
291
+	$(Pecho) "  RMDIR applet/"
292
+	$P rm -rf applet
284
 
293
 
285
 
294
 
286
 .PHONY:	all build elf hex eep lss sym program coff extcoff clean depend applet_files sizebefore sizeafter
295
 .PHONY:	all build elf hex eep lss sym program coff extcoff clean depend applet_files sizebefore sizeafter

+ 8
- 1
Marlin/Marlin.h View File

84
 #define SERIAL_ECHOLN(x) SERIAL_PROTOCOLLN(x)
84
 #define SERIAL_ECHOLN(x) SERIAL_PROTOCOLLN(x)
85
 #define SERIAL_ECHOLNPGM(x) SERIAL_PROTOCOLLNPGM(x)
85
 #define SERIAL_ECHOLNPGM(x) SERIAL_PROTOCOLLNPGM(x)
86
 
86
 
87
-#define SERIAL_ECHOPAIR(name,value) {SERIAL_ECHOPGM(name);SERIAL_ECHO(value);}
87
+#define SERIAL_ECHOPAIR(name,value) (serial_echopair_P(PSTR(name),(value)))
88
+
89
+void serial_echopair_P(const char *s_P, float v);
90
+void serial_echopair_P(const char *s_P, double v);
91
+void serial_echopair_P(const char *s_P, unsigned long v);
88
 
92
 
89
 
93
 
90
 //things to write to serial from Programmemory. saves 400 to 2k of RAM.
94
 //things to write to serial from Programmemory. saves 400 to 2k of RAM.
169
 
173
 
170
 void enquecommand(const char *cmd); //put an ascii command at the end of the current buffer.
174
 void enquecommand(const char *cmd); //put an ascii command at the end of the current buffer.
171
 void prepare_arc_move(char isclockwise);
175
 void prepare_arc_move(char isclockwise);
176
+void clamp_to_software_endstops(float target[3]);
172
 
177
 
173
 #ifdef FAST_PWM_FAN
178
 #ifdef FAST_PWM_FAN
174
 void setPwmFrequency(uint8_t pin, int val);
179
 void setPwmFrequency(uint8_t pin, int val);
183
 extern bool axis_relative_modes[];
188
 extern bool axis_relative_modes[];
184
 extern float current_position[NUM_AXIS] ;
189
 extern float current_position[NUM_AXIS] ;
185
 extern float add_homeing[3];
190
 extern float add_homeing[3];
191
+extern float min_pos[3];
192
+extern float max_pos[3];
186
 extern unsigned char FanSpeed;
193
 extern unsigned char FanSpeed;
187
 
194
 
188
 // Handling multiple extruders pins
195
 // Handling multiple extruders pins

+ 84
- 34
Marlin/Marlin.pde View File

1
+/* -*- c++ -*- */
2
+
1
 /*
3
 /*
2
     Reprap firmware based on Sprinter and grbl.
4
     Reprap firmware based on Sprinter and grbl.
3
  Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
5
  Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
141
 volatile int extrudemultiply=100; //100->1 200->2
143
 volatile int extrudemultiply=100; //100->1 200->2
142
 float current_position[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0 };
144
 float current_position[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0 };
143
 float add_homeing[3]={0,0,0};
145
 float add_homeing[3]={0,0,0};
146
+float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS };
147
+float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
144
 uint8_t active_extruder = 0;
148
 uint8_t active_extruder = 0;
145
 unsigned char FanSpeed=0;
149
 unsigned char FanSpeed=0;
146
 
150
 
199
 
203
 
200
 void get_arc_coordinates();
204
 void get_arc_coordinates();
201
 
205
 
206
+void serial_echopair_P(const char *s_P, float v)
207
+    { serialprintPGM(s_P); SERIAL_ECHO(v); }
208
+void serial_echopair_P(const char *s_P, double v)
209
+    { serialprintPGM(s_P); SERIAL_ECHO(v); }
210
+void serial_echopair_P(const char *s_P, unsigned long v)
211
+    { serialprintPGM(s_P); SERIAL_ECHO(v); }
212
+
202
 extern "C"{
213
 extern "C"{
203
   extern unsigned int __bss_end;
214
   extern unsigned int __bss_end;
204
   extern unsigned int __heap_start;
215
   extern unsigned int __heap_start;
541
   return (strchr_pointer != NULL);  //Return True if a character was found
552
   return (strchr_pointer != NULL);  //Return True if a character was found
542
 }
553
 }
543
 
554
 
544
-#define HOMEAXIS(LETTER) \
545
-  if ((LETTER##_MIN_PIN > -1 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > -1 && LETTER##_HOME_DIR==1))\
546
-    { \
547
-    current_position[LETTER##_AXIS] = 0; \
548
-    plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); \
549
-    destination[LETTER##_AXIS] = 1.5 * LETTER##_MAX_LENGTH * LETTER##_HOME_DIR; \
550
-    feedrate = homing_feedrate[LETTER##_AXIS]; \
551
-    plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); \
552
-    st_synchronize();\
553
-    \
554
-    current_position[LETTER##_AXIS] = 0;\
555
-    plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);\
556
-    destination[LETTER##_AXIS] = -LETTER##_HOME_RETRACT_MM * LETTER##_HOME_DIR;\
557
-    plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); \
558
-    st_synchronize();\
559
-    \
560
-    destination[LETTER##_AXIS] = 2*LETTER##_HOME_RETRACT_MM * LETTER##_HOME_DIR;\
561
-    feedrate = homing_feedrate[LETTER##_AXIS]/2 ;  \
562
-    plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); \
563
-    st_synchronize();\
564
-    \
565
-    current_position[LETTER##_AXIS] = LETTER##_HOME_POS;\
566
-    destination[LETTER##_AXIS] = current_position[LETTER##_AXIS];\
567
-    feedrate = 0.0;\
568
-    endstops_hit_on_purpose();\
555
+#define DEFINE_PGM_READ_ANY(type, reader)		\
556
+    static inline type pgm_read_any(const type *p)	\
557
+	{ return pgm_read_##reader##_near(p); }
558
+
559
+DEFINE_PGM_READ_ANY(float,       float);
560
+DEFINE_PGM_READ_ANY(signed char, byte);
561
+
562
+#define XYZ_CONSTS_FROM_CONFIG(type, array, CONFIG)	\
563
+static const PROGMEM type array##_P[3] =		\
564
+    { X_##CONFIG, Y_##CONFIG, Z_##CONFIG };		\
565
+static inline type array(int axis)			\
566
+    { return pgm_read_any(&array##_P[axis]); }
567
+
568
+XYZ_CONSTS_FROM_CONFIG(float, base_min_pos,    MIN_POS);
569
+XYZ_CONSTS_FROM_CONFIG(float, base_max_pos,    MAX_POS);
570
+XYZ_CONSTS_FROM_CONFIG(float, base_home_pos,   HOME_POS);
571
+XYZ_CONSTS_FROM_CONFIG(float, max_length,      MAX_LENGTH);
572
+XYZ_CONSTS_FROM_CONFIG(float, home_retract_mm, HOME_RETRACT_MM);
573
+XYZ_CONSTS_FROM_CONFIG(signed char, home_dir,  HOME_DIR);
574
+
575
+static void axis_is_at_home(int axis) {
576
+  current_position[axis] = base_home_pos(axis) + add_homeing[axis];
577
+  min_pos[axis] =          base_min_pos(axis) + add_homeing[axis];
578
+  max_pos[axis] =          base_max_pos(axis) + add_homeing[axis];
579
+}
580
+
581
+static void homeaxis(int axis) {
582
+#define HOMEAXIS_DO(LETTER) \
583
+  ((LETTER##_MIN_PIN > -1 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > -1 && LETTER##_HOME_DIR==1))
584
+
585
+  if (axis==X_AXIS ? HOMEAXIS_DO(X) :
586
+      axis==Y_AXIS ? HOMEAXIS_DO(Y) :
587
+      axis==Z_AXIS ? HOMEAXIS_DO(Z) :
588
+      0) {
589
+    current_position[axis] = 0;
590
+    plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
591
+    destination[axis] = 1.5 * max_length(axis) * home_dir(axis);
592
+    feedrate = homing_feedrate[axis];
593
+    plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
594
+    st_synchronize();
595
+   
596
+    current_position[axis] = 0;
597
+    plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
598
+    destination[axis] = -home_retract_mm(axis) * home_dir(axis);
599
+    plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
600
+    st_synchronize();
601
+   
602
+    destination[axis] = 2*home_retract_mm(axis) * home_dir(axis);
603
+    feedrate = homing_feedrate[axis]/2 ; 
604
+    plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
605
+    st_synchronize();
606
+   
607
+    axis_is_at_home(axis);					
608
+    destination[axis] = current_position[axis];
609
+    feedrate = 0.0;
610
+    endstops_hit_on_purpose();
569
   }
611
   }
612
+}
613
+#define HOMEAXIS(LETTER) homeaxis(LETTER##_AXIS)
570
 
614
 
571
 void process_commands()
615
 void process_commands()
572
 {
616
 {
676
         plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
720
         plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
677
         st_synchronize();
721
         st_synchronize();
678
     
722
     
679
-        current_position[X_AXIS] = X_HOME_POS;
680
-        current_position[Y_AXIS] = Y_HOME_POS;
723
+        axis_is_at_home(X_AXIS);
724
+        axis_is_at_home(Y_AXIS);
681
         plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
725
         plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
682
         destination[X_AXIS] = current_position[X_AXIS];
726
         destination[X_AXIS] = current_position[X_AXIS];
683
         destination[Y_AXIS] = current_position[Y_AXIS];
727
         destination[Y_AXIS] = current_position[Y_AXIS];
1539
    }
1583
    }
1540
 }
1584
 }
1541
 
1585
 
1542
-void prepare_move()
1586
+void clamp_to_software_endstops(float target[3])
1543
 {
1587
 {
1544
   if (min_software_endstops) {
1588
   if (min_software_endstops) {
1545
-    if (destination[X_AXIS] < X_MIN_POS) destination[X_AXIS] = X_MIN_POS;
1546
-    if (destination[Y_AXIS] < Y_MIN_POS) destination[Y_AXIS] = Y_MIN_POS;
1547
-    if (destination[Z_AXIS] < Z_MIN_POS) destination[Z_AXIS] = Z_MIN_POS;
1589
+    if (target[X_AXIS] < min_pos[X_AXIS]) target[X_AXIS] = min_pos[X_AXIS];
1590
+    if (target[Y_AXIS] < min_pos[Y_AXIS]) target[Y_AXIS] = min_pos[Y_AXIS];
1591
+    if (target[Z_AXIS] < min_pos[Z_AXIS]) target[Z_AXIS] = min_pos[Z_AXIS];
1548
   }
1592
   }
1549
 
1593
 
1550
   if (max_software_endstops) {
1594
   if (max_software_endstops) {
1551
-    if (destination[X_AXIS] > X_MAX_POS) destination[X_AXIS] = X_MAX_POS;
1552
-    if (destination[Y_AXIS] > Y_MAX_POS) destination[Y_AXIS] = Y_MAX_POS;
1553
-    if (destination[Z_AXIS] > Z_MAX_POS) destination[Z_AXIS] = Z_MAX_POS;
1595
+    if (target[X_AXIS] > max_pos[X_AXIS]) target[X_AXIS] = max_pos[X_AXIS];
1596
+    if (target[Y_AXIS] > max_pos[Y_AXIS]) target[Y_AXIS] = max_pos[Y_AXIS];
1597
+    if (target[Z_AXIS] > max_pos[Z_AXIS]) target[Z_AXIS] = max_pos[Z_AXIS];
1554
   }
1598
   }
1599
+}
1600
+
1601
+void prepare_move()
1602
+{
1603
+  clamp_to_software_endstops(destination);
1604
+
1555
   previous_millis_cmd = millis();  
1605
   previous_millis_cmd = millis();  
1556
   plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder);
1606
   plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder);
1557
   for(int8_t i=0; i < NUM_AXIS; i++) {
1607
   for(int8_t i=0; i < NUM_AXIS; i++) {

+ 1
- 11
Marlin/motion_control.cpp View File

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
   }

+ 1
- 0
README.md View File

152
 *   M202 - Set max acceleration in units/s^2 for travel moves (M202 X1000 Y1000) Unused in Marlin!!
152
 *   M202 - Set max acceleration in units/s^2 for travel moves (M202 X1000 Y1000) Unused in Marlin!!
153
 *   M203 - Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in mm/sec
153
 *   M203 - Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in mm/sec
154
 *   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
154
 *   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
155
+*   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)
155
 *   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.
156
 *   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.
156
 *   M221 - set the extrude multiplying S:factor in percent
157
 *   M221 - set the extrude multiplying S:factor in percent
157
 *   M400 - Finish all buffered moves.
158
 *   M400 - Finish all buffered moves.

Loading…
Cancel
Save