Browse Source

Add the socalled "Babystepping" feature.

It is a realtime control over the head position via the LCD menu system that works _while_ printing.
Using it, one can e.g. tune the z-position in realtime, while printing the first layer.
Also, lost steps can be manually added/removed, but thats not the prime feature.
Stuff is placed into the Tune->Babystep *

It is not possible to have realtime control via gcode sending due to the buffering, so I did not include a gcode yet. However, it could be added, but it movements will not be realtime then.

Historically, a very similar thing was implemented for the "Kaamermaker" project, while Joris was babysitting his offspring, hence the name.

say goodby to fuddling around with the z-axis.
bkubicek 11 years ago
parent
commit
d147a057ac
6 changed files with 226 additions and 1 deletions
  1. 11
    0
      Marlin/Configuration_adv.h
  2. 110
    0
      Marlin/stepper.cpp
  3. 6
    0
      Marlin/stepper.h
  4. 24
    1
      Marlin/temperature.cpp
  5. 5
    0
      Marlin/temperature.h
  6. 70
    0
      Marlin/ultralcd.cpp

+ 11
- 0
Marlin/Configuration_adv.h View File

@@ -270,6 +270,17 @@
270 270
 // Enable the option to stop SD printing when hitting and endstops, needs to be enabled from the LCD menu when this option is enabled.
271 271
 //#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
272 272
 
273
+// Babystepping enables the user to control the axis in tiny amounts, independently from the normal printing process
274
+// it can e.g. be used to change z-positions in the print startup phase in realtime
275
+// does not respect endstops!
276
+
277
+//#define BABYSTEPPING
278
+//#define BABYSTEP_XY  //not only z, but also XY
279
+
280
+#ifdef COREXY
281
+    #error BABYSTEPPING not implemented for COREXY yet.
282
+#endif
283
+
273 284
 // extruder advance constant (s2/mm3)
274 285
 //
275 286
 // advance (steps) = STEPS_PER_CUBIC_MM_E * EXTUDER_ADVANCE_K * cubic mm per second ^ 2

+ 110
- 0
Marlin/stepper.cpp View File

@@ -997,6 +997,116 @@ void quickStop()
997 997
   ENABLE_STEPPER_DRIVER_INTERRUPT();
998 998
 }
999 999
 
1000
+#ifdef BABYSTEPPING
1001
+
1002
+
1003
+void babystep(const uint8_t axis,const bool direction)
1004
+{
1005
+  //MUST ONLY BE CALLED BY A ISR, it depends on that no other ISR interrupts this
1006
+    //store initial pin states
1007
+  switch(axis)
1008
+  {
1009
+  case X_AXIS:
1010
+  {
1011
+    enable_x();   
1012
+    uint8_t old_x_dir_pin= READ(X_DIR_PIN);  //if dualzstepper, both point to same direction.
1013
+   
1014
+    //setup new step
1015
+    WRITE(X_DIR_PIN,(INVERT_X_DIR)^direction);
1016
+    #ifdef DUAL_X_CARRIAGE
1017
+      WRITE(X2_DIR_PIN,(INVERT_X_DIR)^direction);
1018
+    #endif
1019
+    
1020
+    //perform step 
1021
+    WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); 
1022
+    #ifdef DUAL_X_CARRIAGE
1023
+      WRITE(X2_STEP_PIN, !INVERT_X_STEP_PIN);
1024
+    #endif
1025
+    {
1026
+    float x=1./float(axis+1)/float(axis+2); //wait a tiny bit
1027
+    }
1028
+    WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
1029
+    #ifdef DUAL_X_CARRIAGE
1030
+      WRITE(X2_STEP_PIN, INVERT_X_STEP_PIN);
1031
+    #endif
1032
+
1033
+    //get old pin state back.
1034
+    WRITE(X_DIR_PIN,old_x_dir_pin);
1035
+    #ifdef DUAL_X_CARRIAGE
1036
+      WRITE(X2_DIR_PIN,old_x_dir_pin);
1037
+    #endif
1038
+
1039
+  }
1040
+  break;
1041
+  case Y_AXIS:
1042
+  {
1043
+    enable_y();   
1044
+    uint8_t old_y_dir_pin= READ(Y_DIR_PIN);  //if dualzstepper, both point to same direction.
1045
+   
1046
+    //setup new step
1047
+    WRITE(Y_DIR_PIN,(INVERT_Y_DIR)^direction);
1048
+    #ifdef DUAL_Y_CARRIAGE
1049
+      WRITE(Y2_DIR_PIN,(INVERT_Y_DIR)^direction);
1050
+    #endif
1051
+    
1052
+    //perform step 
1053
+    WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); 
1054
+    #ifdef DUAL_Y_CARRIAGE
1055
+      WRITE(Y2_STEP_PIN, !INVERT_Y_STEP_PIN);
1056
+    #endif
1057
+    {
1058
+    float x=1./float(axis+1)/float(axis+2); //wait a tiny bit
1059
+    }
1060
+    WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
1061
+    #ifdef DUAL_Y_CARRIAGE
1062
+      WRITE(Y2_STEP_PIN, INVERT_Y_STEP_PIN);
1063
+    #endif
1064
+
1065
+    //get old pin state back.
1066
+    WRITE(Y_DIR_PIN,old_y_dir_pin);
1067
+    #ifdef DUAL_Y_CARRIAGE
1068
+      WRITE(Y2_DIR_PIN,old_y_dir_pin);
1069
+    #endif
1070
+
1071
+  }
1072
+  break; 
1073
+  case Z_AXIS:
1074
+  {
1075
+    enable_z();
1076
+    uint8_t old_z_dir_pin= READ(Z_DIR_PIN);  //if dualzstepper, both point to same direction.
1077
+    //setup new step
1078
+    WRITE(Z_DIR_PIN,(INVERT_Z_DIR)^direction);
1079
+    #ifdef Z_DUAL_STEPPER_DRIVERS
1080
+      WRITE(Z2_DIR_PIN,(INVERT_Z_DIR)^direction);
1081
+    #endif
1082
+    //perform step 
1083
+    WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); 
1084
+    #ifdef Z_DUAL_STEPPER_DRIVERS
1085
+      WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN);
1086
+    #endif
1087
+    //wait a tiny bit
1088
+    {
1089
+    float x=1./float(axis+1); //absolutely useless
1090
+    }
1091
+    WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN);
1092
+    #ifdef Z_DUAL_STEPPER_DRIVERS
1093
+      WRITE(Z2_STEP_PIN, INVERT_Z_STEP_PIN);
1094
+    #endif
1095
+
1096
+    //get old pin state back.
1097
+    WRITE(Z_DIR_PIN,old_z_dir_pin);
1098
+    #ifdef Z_DUAL_STEPPER_DRIVERS
1099
+      WRITE(Z2_DIR_PIN,old_z_dir_pin);
1100
+    #endif
1101
+
1102
+  }
1103
+  break;
1104
+ 
1105
+  default:    break;
1106
+  }
1107
+}
1108
+#endif //BABYSTEPPING
1109
+
1000 1110
 void digitalPotWrite(int address, int value) // From Arduino DigitalPotControl example
1001 1111
 {
1002 1112
   #if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1

+ 6
- 0
Marlin/stepper.h View File

@@ -92,4 +92,10 @@ void digipot_current(uint8_t driver, int current);
92 92
 void microstep_init();
93 93
 void microstep_readings();
94 94
 
95
+#ifdef BABYSTEPPING
96
+  void babystep(const uint8_t axis,const bool direction); // perform a short step with a single stepper motor, outside of any convention
97
+#endif
98
+     
99
+
100
+
95 101
 #endif

+ 24
- 1
Marlin/temperature.cpp View File

@@ -66,6 +66,10 @@ float current_temperature_bed = 0.0;
66 66
   unsigned char fanSpeedSoftPwm;
67 67
 #endif
68 68
   
69
+#ifdef BABYSTEPPING
70
+  volatile int babystepsTodo[3]={0,0,0};
71
+#endif
72
+  
69 73
 //===========================================================================
70 74
 //=============================private variables============================
71 75
 //===========================================================================
@@ -1252,7 +1256,26 @@ ISR(TIMER0_COMPB_vect)
1252 1256
        bed_max_temp_error();
1253 1257
     }
1254 1258
 #endif
1255
-  }  
1259
+  }
1260
+  
1261
+#ifdef BABYSTEPPING
1262
+  for(uint8_t axis=0;axis<3;axis++)
1263
+  {
1264
+    int curTodo=babystepsTodo[axis]; //get rid of volatile for performance
1265
+   
1266
+    if(curTodo>0)
1267
+    {
1268
+      babystep(axis,/*fwd*/true);
1269
+      babystepsTodo[axis]--; //less to do next time
1270
+    }
1271
+    else
1272
+    if(curTodo<0)
1273
+    {
1274
+      babystep(axis,/*fwd*/false);
1275
+      babystepsTodo[axis]++; //less to do next time
1276
+    }
1277
+  }
1278
+#endif //BABYSTEPPING
1256 1279
 }
1257 1280
 
1258 1281
 #ifdef PIDTEMP

+ 5
- 0
Marlin/temperature.h View File

@@ -53,6 +53,11 @@ extern float current_temperature_bed;
53 53
   extern float bedKp,bedKi,bedKd;
54 54
 #endif
55 55
   
56
+  
57
+#ifdef BABYSTEPPING
58
+  extern volatile int babystepsTodo[3];
59
+#endif
60
+  
56 61
 //high level conversion routines, for use outside of temperature.cpp
57 62
 //inline so that there is no performance decrease.
58 63
 //deg=degreeCelsius

+ 70
- 0
Marlin/ultralcd.cpp View File

@@ -322,6 +322,68 @@ static void lcd_cooldown()
322 322
     lcd_return_to_status();
323 323
 }
324 324
 
325
+#ifdef BABYSTEPPING
326
+static void lcd_babystep_x()
327
+{
328
+    if (encoderPosition != 0)
329
+    {
330
+        babystepsTodo[X_AXIS]+=(int)encoderPosition;
331
+        encoderPosition=0;
332
+        lcdDrawUpdate = 1;
333
+    }
334
+    if (lcdDrawUpdate)
335
+    {
336
+        lcd_implementation_drawedit(PSTR("Babystepping X"),"");
337
+    }
338
+    if (LCD_CLICKED)
339
+    {
340
+        lcd_quick_feedback();
341
+        currentMenu = lcd_tune_menu;
342
+        encoderPosition = 0;
343
+    }
344
+}
345
+
346
+static void lcd_babystep_y()
347
+{
348
+    if (encoderPosition != 0)
349
+    {
350
+        babystepsTodo[Y_AXIS]+=(int)encoderPosition;
351
+        encoderPosition=0;
352
+        lcdDrawUpdate = 1;
353
+    }
354
+    if (lcdDrawUpdate)
355
+    {
356
+        lcd_implementation_drawedit(PSTR("Babystepping Y"),"");
357
+    }
358
+    if (LCD_CLICKED)
359
+    {
360
+        lcd_quick_feedback();
361
+        currentMenu = lcd_tune_menu;
362
+        encoderPosition = 0;
363
+    }
364
+}
365
+
366
+static void lcd_babystep_z()
367
+{
368
+    if (encoderPosition != 0)
369
+    {
370
+        babystepsTodo[Z_AXIS]+=(int)encoderPosition;
371
+        encoderPosition=0;
372
+        lcdDrawUpdate = 1;
373
+    }
374
+    if (lcdDrawUpdate)
375
+    {
376
+        lcd_implementation_drawedit(PSTR("Babystepping Z"),"");
377
+    }
378
+    if (LCD_CLICKED)
379
+    {
380
+        lcd_quick_feedback();
381
+        currentMenu = lcd_tune_menu;
382
+        encoderPosition = 0;
383
+    }
384
+}
385
+#endif //BABYSTEPPING
386
+
325 387
 static void lcd_tune_menu()
326 388
 {
327 389
     START_MENU();
@@ -339,6 +401,14 @@ static void lcd_tune_menu()
339 401
 #endif
340 402
     MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255);
341 403
     MENU_ITEM_EDIT(int3, MSG_FLOW, &extrudemultiply, 10, 999);
404
+    
405
+#ifdef BABYSTEPPING
406
+    #ifdef BABYSTEP_XY
407
+      MENU_ITEM(submenu, "Babystep X", lcd_babystep_x);
408
+      MENU_ITEM(submenu, "Babystep Y", lcd_babystep_y);
409
+    #endif //BABYSTEP_XY
410
+    MENU_ITEM(submenu, "Babystep Z", lcd_babystep_z);
411
+#endif
342 412
 #ifdef FILAMENTCHANGEENABLE
343 413
      MENU_ITEM(gcode, MSG_FILAMENTCHANGE, PSTR("M600"));
344 414
 #endif

Loading…
Cancel
Save