Przeglądaj źródła

Fix Babystepping loop (again)

Scott Lahteine 5 lat temu
rodzic
commit
5e197df89a

+ 4
- 4
Marlin/src/feature/babystep.cpp Wyświetl plik

35
 
35
 
36
 Babystep babystep;
36
 Babystep babystep;
37
 
37
 
38
-volatile int16_t Babystep::steps[BS_TODO_AXIS(Z_AXIS) + 1];
38
+volatile int16_t Babystep::steps[BS_AXIS_IND(Z_AXIS) + 1];
39
 #if ENABLED(BABYSTEP_DISPLAY_TOTAL)
39
 #if ENABLED(BABYSTEP_DISPLAY_TOTAL)
40
   int16_t Babystep::axis_total[BS_TOTAL_AXIS(Z_AXIS) + 1];
40
   int16_t Babystep::axis_total[BS_TOTAL_AXIS(Z_AXIS) + 1];
41
 #endif
41
 #endif
42
 int16_t Babystep::accum;
42
 int16_t Babystep::accum;
43
 
43
 
44
 void Babystep::step_axis(const AxisEnum axis) {
44
 void Babystep::step_axis(const AxisEnum axis) {
45
-  const int16_t curTodo = steps[BS_TODO_AXIS(axis)]; // get rid of volatile for performance
45
+  const int16_t curTodo = steps[BS_AXIS_IND(axis)]; // get rid of volatile for performance
46
   if (curTodo) {
46
   if (curTodo) {
47
     stepper.do_babystep((AxisEnum)axis, curTodo > 0);
47
     stepper.do_babystep((AxisEnum)axis, curTodo > 0);
48
-    if (curTodo > 0) steps[BS_TODO_AXIS(axis)]--; else steps[BS_TODO_AXIS(axis)]++;
48
+    if (curTodo > 0) steps[BS_AXIS_IND(axis)]--; else steps[BS_AXIS_IND(axis)]++;
49
   }
49
   }
50
 }
50
 }
51
 
51
 
112
     #else
112
     #else
113
       BSA_ENABLE(Z_AXIS);
113
       BSA_ENABLE(Z_AXIS);
114
     #endif
114
     #endif
115
-    steps[BS_TODO_AXIS(axis)] += distance;
115
+    steps[BS_AXIS_IND(axis)] += distance;
116
   #endif
116
   #endif
117
   #if ENABLED(BABYSTEP_ALWAYS_AVAILABLE)
117
   #if ENABLED(BABYSTEP_ALWAYS_AVAILABLE)
118
     gcode.reset_stepper_timeout();
118
     gcode.reset_stepper_timeout();

+ 7
- 5
Marlin/src/feature/babystep.h Wyświetl plik

32
 #endif
32
 #endif
33
 
33
 
34
 #if IS_CORE || EITHER(BABYSTEP_XY, I2C_POSITION_ENCODERS)
34
 #if IS_CORE || EITHER(BABYSTEP_XY, I2C_POSITION_ENCODERS)
35
-  #define BS_TODO_AXIS(A) A
35
+  #define BS_AXIS_IND(A) A
36
+  #define BS_AXIS(I) AxisEnum(I)
36
 #else
37
 #else
37
-  #define BS_TODO_AXIS(A) 0
38
+  #define BS_AXIS_IND(A) 0
39
+  #define BS_AXIS(I) Z_AXIS
38
 #endif
40
 #endif
39
 
41
 
40
 #if ENABLED(BABYSTEP_DISPLAY_TOTAL)
42
 #if ENABLED(BABYSTEP_DISPLAY_TOTAL)
47
 
49
 
48
 class Babystep {
50
 class Babystep {
49
 public:
51
 public:
50
-  static volatile int16_t steps[BS_TODO_AXIS(Z_AXIS) + 1];
52
+  static volatile int16_t steps[BS_AXIS_IND(Z_AXIS) + 1];
51
   static int16_t accum;                                     // Total babysteps in current edit
53
   static int16_t accum;                                     // Total babysteps in current edit
52
 
54
 
53
   #if ENABLED(BABYSTEP_DISPLAY_TOTAL)
55
   #if ENABLED(BABYSTEP_DISPLAY_TOTAL)
65
   static void add_mm(const AxisEnum axis, const float &mm);
67
   static void add_mm(const AxisEnum axis, const float &mm);
66
 
68
 
67
   static inline bool has_steps() {
69
   static inline bool has_steps() {
68
-    return steps[BS_TODO_AXIS(X_AXIS)] || steps[BS_TODO_AXIS(Y_AXIS)] || steps[BS_TODO_AXIS(Z_AXIS)];
70
+    return steps[BS_AXIS_IND(X_AXIS)] || steps[BS_AXIS_IND(Y_AXIS)] || steps[BS_AXIS_IND(Z_AXIS)];
69
   }
71
   }
70
 
72
 
71
   //
73
   //
73
   // apply accumulated babysteps to the axes.
75
   // apply accumulated babysteps to the axes.
74
   //
76
   //
75
   static inline void task() {
77
   static inline void task() {
76
-    LOOP_LE_N(axis, BS_TODO_AXIS(Z_AXIS)) step_axis((AxisEnum)axis);
78
+    LOOP_LE_N(i, BS_AXIS_IND(Z_AXIS)) step_axis(BS_AXIS(i));
77
   }
79
   }
78
 
80
 
79
 private:
81
 private:

+ 1
- 1
Marlin/src/feature/tmc_util.cpp Wyświetl plik

1097
 
1097
 
1098
   bool tmc_enable_stallguard(TMC2209Stepper &st) {
1098
   bool tmc_enable_stallguard(TMC2209Stepper &st) {
1099
     const bool stealthchop_was_enabled = !st.en_spreadCycle();
1099
     const bool stealthchop_was_enabled = !st.en_spreadCycle();
1100
-    
1100
+
1101
     st.TCOOLTHRS(0xFFFFF);
1101
     st.TCOOLTHRS(0xFFFFF);
1102
     st.en_spreadCycle(false);
1102
     st.en_spreadCycle(false);
1103
     return stealthchop_was_enabled;
1103
     return stealthchop_was_enabled;

+ 1
- 1
Marlin/src/gcode/motion/M290.cpp Wyświetl plik

131
         #else
131
         #else
132
           PSTR("Babystep Z")
132
           PSTR("Babystep Z")
133
         #endif
133
         #endif
134
-        , babystep.axis_total[BS_TODO_AXIS(Z_AXIS)]
134
+        , babystep.axis_total[BS_AXIS_IND(Z_AXIS)]
135
       );
135
       );
136
     }
136
     }
137
     #endif
137
     #endif

+ 8
- 8
Marlin/src/lcd/extensible_ui/ui_api.cpp Wyświetl plik

785
     #if HAS_BED_PROBE
785
     #if HAS_BED_PROBE
786
       return probe.offset.z;
786
       return probe.offset.z;
787
     #elif ENABLED(BABYSTEP_DISPLAY_TOTAL)
787
     #elif ENABLED(BABYSTEP_DISPLAY_TOTAL)
788
-      return (planner.steps_to_mm[Z_AXIS] * babystep.axis_total[BS_TODO_AXIS(Z_AXIS)]);
788
+      return (planner.steps_to_mm[Z_AXIS] * babystep.axis_total[BS_AXIS_IND(Z_AXIS)]);
789
     #else
789
     #else
790
       return 0.0;
790
       return 0.0;
791
     #endif
791
     #endif
898
     float getPIDValues_Kp(const extruder_t tool) {
898
     float getPIDValues_Kp(const extruder_t tool) {
899
       return PID_PARAM(Kp, tool);
899
       return PID_PARAM(Kp, tool);
900
     }
900
     }
901
-    
901
+
902
     float getPIDValues_Ki(const extruder_t tool) {
902
     float getPIDValues_Ki(const extruder_t tool) {
903
       return unscalePID_i(PID_PARAM(Ki, tool));
903
       return unscalePID_i(PID_PARAM(Ki, tool));
904
     }
904
     }
905
-    
905
+
906
     float getPIDValues_Kd(const extruder_t tool) {
906
     float getPIDValues_Kd(const extruder_t tool) {
907
       return unscalePID_d(PID_PARAM(Kd, tool));
907
       return unscalePID_d(PID_PARAM(Kd, tool));
908
     }
908
     }
918
       thermalManager.PID_autotune(temp, (heater_ind_t)tool, 8, true);
918
       thermalManager.PID_autotune(temp, (heater_ind_t)tool, 8, true);
919
     }
919
     }
920
   #endif
920
   #endif
921
-  
921
+
922
   #if ENABLED(PIDTEMPBED)
922
   #if ENABLED(PIDTEMPBED)
923
     float getBedPIDValues_Kp() {
923
     float getBedPIDValues_Kp() {
924
       return thermalManager.temp_bed.pid.Kp;
924
       return thermalManager.temp_bed.pid.Kp;
925
     }
925
     }
926
-    
926
+
927
     float getBedPIDValues_Ki() {
927
     float getBedPIDValues_Ki() {
928
       return unscalePID_i(thermalManager.temp_bed.pid.Ki);
928
       return unscalePID_i(thermalManager.temp_bed.pid.Ki);
929
     }
929
     }
930
-    
930
+
931
     float getBedPIDValues_Kd() {
931
     float getBedPIDValues_Kd() {
932
       return unscalePID_d(thermalManager.temp_bed.pid.Kd);
932
       return unscalePID_d(thermalManager.temp_bed.pid.Kd);
933
     }
933
     }
934
-    
934
+
935
     void setBedPIDValues(const float p, const float i, const float d) {
935
     void setBedPIDValues(const float p, const float i, const float d) {
936
       thermalManager.temp_bed.pid.Kp = p;
936
       thermalManager.temp_bed.pid.Kp = p;
937
       thermalManager.temp_bed.pid.Ki = scalePID_i(i);
937
       thermalManager.temp_bed.pid.Ki = scalePID_i(i);
938
       thermalManager.temp_bed.pid.Kd = scalePID_d(d);
938
       thermalManager.temp_bed.pid.Kd = scalePID_d(d);
939
       thermalManager.updatePID();
939
       thermalManager.updatePID();
940
     }
940
     }
941
-    
941
+
942
     void startBedPIDTune(const float temp) {
942
     void startBedPIDTune(const float temp) {
943
       thermalManager.PID_autotune(temp, H_BED, 4, true);
943
       thermalManager.PID_autotune(temp, H_BED, 4, true);
944
     }
944
     }

+ 1
- 1
Marlin/src/lcd/extensible_ui/ui_api.h Wyświetl plik

256
     void setPIDValues(const float, const float, const float, extruder_t);
256
     void setPIDValues(const float, const float, const float, extruder_t);
257
     void startPIDTune(const float, extruder_t);
257
     void startPIDTune(const float, extruder_t);
258
   #endif
258
   #endif
259
-  
259
+
260
   #if ENABLED(PIDTEMPBED)
260
   #if ENABLED(PIDTEMPBED)
261
     float getBedPIDValues_Kp();
261
     float getBedPIDValues_Kp();
262
     float getBedPIDValues_Ki();
262
     float getBedPIDValues_Ki();

+ 19
- 9
Marlin/src/module/stepper.cpp Wyświetl plik

81
 
81
 
82
 Stepper stepper; // Singleton
82
 Stepper stepper; // Singleton
83
 
83
 
84
+#define BABYSTEPPING_EXTRA_DIR_WAIT
85
+
84
 #if HAS_MOTOR_CURRENT_PWM
86
 #if HAS_MOTOR_CURRENT_PWM
85
   bool Stepper::initialized; // = false
87
   bool Stepper::initialized; // = false
86
 #endif
88
 #endif
1367
     #endif
1369
     #endif
1368
 
1370
 
1369
     #if ENABLED(INTEGRATED_BABYSTEPPING)
1371
     #if ENABLED(INTEGRATED_BABYSTEPPING)
1370
-      const bool do_babystep = (nextBabystepISR == 0);              // 0 = Do Babystepping (XY)Z pulses
1371
-      if (do_babystep) nextBabystepISR = babystepping_isr();
1372
+      const bool is_babystep = (nextBabystepISR == 0);              // 0 = Do Babystepping (XY)Z pulses
1373
+      if (is_babystep) nextBabystepISR = babystepping_isr();
1372
     #endif
1374
     #endif
1373
 
1375
 
1374
     // ^== Time critical. NOTHING besides pulse generation should be above here!!!
1376
     // ^== Time critical. NOTHING besides pulse generation should be above here!!!
1376
     if (!nextMainISR) nextMainISR = block_phase_isr();  // Manage acc/deceleration, get next block
1378
     if (!nextMainISR) nextMainISR = block_phase_isr();  // Manage acc/deceleration, get next block
1377
 
1379
 
1378
     #if ENABLED(INTEGRATED_BABYSTEPPING)
1380
     #if ENABLED(INTEGRATED_BABYSTEPPING)
1379
-      if (do_babystep)                                  // Avoid ANY stepping too soon after baby-stepping
1381
+      if (is_babystep)                                  // Avoid ANY stepping too soon after baby-stepping
1380
         NOLESS(nextMainISR, (BABYSTEP_TICKS) / 8);      // FULL STOP for 125µs after a baby-step
1382
         NOLESS(nextMainISR, (BABYSTEP_TICKS) / 8);      // FULL STOP for 125µs after a baby-step
1381
 
1383
 
1382
       if (nextBabystepISR != BABYSTEP_NEVER)            // Avoid baby-stepping too close to axis Stepping
1384
       if (nextBabystepISR != BABYSTEP_NEVER)            // Avoid baby-stepping too close to axis Stepping
2507
     #endif
2509
     #endif
2508
   #endif
2510
   #endif
2509
 
2511
 
2512
+  #if ENABLED(BABYSTEPPING_EXTRA_DIR_WAIT)
2513
+    #define EXTRA_DIR_WAIT_BEFORE DIR_WAIT_BEFORE
2514
+    #define EXTRA_DIR_WAIT_AFTER  DIR_WAIT_AFTER
2515
+  #else
2516
+    #define EXTRA_DIR_WAIT_BEFORE()
2517
+    #define EXTRA_DIR_WAIT_AFTER()
2518
+  #endif
2519
+
2510
   #if DISABLED(DELTA)
2520
   #if DISABLED(DELTA)
2511
 
2521
 
2512
     #define BABYSTEP_AXIS(AXIS, INV, DIR) do{           \
2522
     #define BABYSTEP_AXIS(AXIS, INV, DIR) do{           \
2519
       _APPLY_STEP(AXIS, !_INVERT_STEP_PIN(AXIS), true); \
2529
       _APPLY_STEP(AXIS, !_INVERT_STEP_PIN(AXIS), true); \
2520
       _PULSE_WAIT();                                    \
2530
       _PULSE_WAIT();                                    \
2521
       _APPLY_STEP(AXIS, _INVERT_STEP_PIN(AXIS), true);  \
2531
       _APPLY_STEP(AXIS, _INVERT_STEP_PIN(AXIS), true);  \
2522
-      DIR_WAIT_BEFORE();                                \
2532
+      EXTRA_DIR_WAIT_BEFORE();                          \
2523
       _APPLY_DIR(AXIS, old_dir);                        \
2533
       _APPLY_DIR(AXIS, old_dir);                        \
2524
-      DIR_WAIT_AFTER();                                 \
2534
+      EXTRA_DIR_WAIT_AFTER();                           \
2525
     }while(0)
2535
     }while(0)
2526
 
2536
 
2527
   #elif IS_CORE
2537
   #elif IS_CORE
2539
       _PULSE_WAIT();                                            \
2549
       _PULSE_WAIT();                                            \
2540
       _APPLY_STEP(A, _INVERT_STEP_PIN(A), true);                \
2550
       _APPLY_STEP(A, _INVERT_STEP_PIN(A), true);                \
2541
       _APPLY_STEP(B, _INVERT_STEP_PIN(B), true);                \
2551
       _APPLY_STEP(B, _INVERT_STEP_PIN(B), true);                \
2542
-      DIR_WAIT_BEFORE();                                        \
2552
+      EXTRA_DIR_WAIT_BEFORE();                                  \
2543
       _APPLY_DIR(A, old_dir.a); _APPLY_DIR(B, old_dir.b);       \
2553
       _APPLY_DIR(A, old_dir.a); _APPLY_DIR(B, old_dir.b);       \
2544
-      DIR_WAIT_AFTER();                                         \
2554
+      EXTRA_DIR_WAIT_AFTER();                                   \
2545
     }while(0)
2555
     }while(0)
2546
 
2556
 
2547
   #endif
2557
   #endif
2620
           Z_STEP_WRITE(INVERT_Z_STEP_PIN);
2630
           Z_STEP_WRITE(INVERT_Z_STEP_PIN);
2621
 
2631
 
2622
           // Restore direction bits
2632
           // Restore direction bits
2623
-          DIR_WAIT_BEFORE();
2633
+          EXTRA_DIR_WAIT_BEFORE();
2624
 
2634
 
2625
           X_DIR_WRITE(old_dir.x);
2635
           X_DIR_WRITE(old_dir.x);
2626
           Y_DIR_WRITE(old_dir.y);
2636
           Y_DIR_WRITE(old_dir.y);
2627
           Z_DIR_WRITE(old_dir.z);
2637
           Z_DIR_WRITE(old_dir.z);
2628
 
2638
 
2629
-          DIR_WAIT_AFTER();
2639
+          EXTRA_DIR_WAIT_AFTER();
2630
 
2640
 
2631
         #endif
2641
         #endif
2632
 
2642
 

+ 7
- 7
Marlin/src/pins/mega/pins_PICA.h Wyświetl plik

36
 /*
36
 /*
37
 // Note that these are the "pins" that correspond to the analog inputs on the arduino mega.
37
 // Note that these are the "pins" that correspond to the analog inputs on the arduino mega.
38
 // These are not the same as the physical pin numbers
38
 // These are not the same as the physical pin numbers
39
-  AD0 = 54;   AD1 = 55;   AD2 = 56;   AD3 = 57;   
40
-  AD4 = 58;   AD5 = 59;   AD6 = 60;   AD7 = 61;   
39
+  AD0 = 54;   AD1 = 55;   AD2 = 56;   AD3 = 57;
40
+  AD4 = 58;   AD5 = 59;   AD6 = 60;   AD7 = 61;
41
   AD8 = 62;   AD9 = 63;   AD10 = 64;  AD11 = 65;
41
   AD8 = 62;   AD9 = 63;   AD10 = 64;  AD11 = 65;
42
   AD12 = 66;  AD13 = 67;  AD14 = 68;  AD15 = 69;
42
   AD12 = 66;  AD13 = 67;  AD14 = 68;  AD15 = 69;
43
 */
43
 */
61
 //
61
 //
62
 #define X_STEP_PIN         55
62
 #define X_STEP_PIN         55
63
 #define X_DIR_PIN          54
63
 #define X_DIR_PIN          54
64
-#define X_ENABLE_PIN       60     
64
+#define X_ENABLE_PIN       60
65
 
65
 
66
 #define Y_STEP_PIN         57
66
 #define Y_STEP_PIN         57
67
 #define Y_DIR_PIN          56
67
 #define Y_DIR_PIN          56
71
 #define Z_DIR_PIN          58
71
 #define Z_DIR_PIN          58
72
 #define Z_ENABLE_PIN       62
72
 #define Z_ENABLE_PIN       62
73
 
73
 
74
-#define E0_STEP_PIN        67 
74
+#define E0_STEP_PIN        67
75
 #define E0_DIR_PIN         24
75
 #define E0_DIR_PIN         24
76
 #define E0_ENABLE_PIN      26
76
 #define E0_ENABLE_PIN      26
77
 
77
 
103
 #endif
103
 #endif
104
 
104
 
105
 #define SDPOWER_PIN        -1
105
 #define SDPOWER_PIN        -1
106
-#define LED_PIN            -1 
106
+#define LED_PIN            -1
107
 #define PS_ON_PIN          -1
107
 #define PS_ON_PIN          -1
108
 #define KILL_PIN           -1
108
 #define KILL_PIN           -1
109
-      
109
+
110
 #define SSR_PIN             6
110
 #define SSR_PIN             6
111
 
111
 
112
 // SPI for Max6675 or Max31855 Thermocouple
112
 // SPI for Max6675 or Max31855 Thermocouple
119
 //
119
 //
120
 // SD Support
120
 // SD Support
121
 //
121
 //
122
-#define SD_DETECT_PIN      49 
122
+#define SD_DETECT_PIN      49
123
 #define SDSS               53
123
 #define SDSS               53
124
 
124
 
125
 //
125
 //

Ładowanie…
Anuluj
Zapisz