Browse Source

More explicit junction/jerk math

Scott Lahteine 4 years ago
parent
commit
b8947ac8a5
2 changed files with 4 additions and 6 deletions
  1. 3
    3
      Marlin/src/module/planner.cpp
  2. 1
    3
      Marlin/src/module/planner.h

+ 3
- 3
Marlin/src/module/planner.cpp View File

2304
         const float junction_acceleration = limit_value_by_axis_maximum(block->acceleration, junction_unit_vec),
2304
         const float junction_acceleration = limit_value_by_axis_maximum(block->acceleration, junction_unit_vec),
2305
                     sin_theta_d2 = SQRT(0.5f * (1.0f - junction_cos_theta)); // Trig half angle identity. Always positive.
2305
                     sin_theta_d2 = SQRT(0.5f * (1.0f - junction_cos_theta)); // Trig half angle identity. Always positive.
2306
 
2306
 
2307
-        vmax_junction_sqr = JUNC_SQ(junction_acceleration, sin_theta_d2);
2307
+        vmax_junction_sqr = junction_acceleration * junction_deviation_mm * sin_theta_d2 / (1.0f - sin_theta_d2);
2308
 
2308
 
2309
         if (block->millimeters < 1) {
2309
         if (block->millimeters < 1) {
2310
           const float neg = junction_cos_theta < 0 ? -1 : 1,
2310
           const float neg = junction_cos_theta < 0 ? -1 : 1,
2340
                *  for (float t = 0; t <= 1; t += 0.0003f) {
2340
                *  for (float t = 0; t <= 1; t += 0.0003f) {
2341
                *    const float e = acos(t) / approx(t);
2341
                *    const float e = acos(t) / approx(t);
2342
                *    if (isfinite(e)) {
2342
                *    if (isfinite(e)) {
2343
-               *      NOMORE(min, e);
2344
-               *      NOLESS(max, e);
2343
+               *      if (e < min) min = e;
2344
+               *      if (e > max) max = e;
2345
                *    }
2345
                *    }
2346
                *  }
2346
                *  }
2347
                *  fprintf(stderr, "%.9gf, ", (min + max) / 2);
2347
                *  fprintf(stderr, "%.9gf, ", (min + max) / 2);

+ 1
- 3
Marlin/src/module/planner.h View File

838
       static void autotemp_update();
838
       static void autotemp_update();
839
     #endif
839
     #endif
840
 
840
 
841
-    #define JUNC_SQ(N,ST) (junction_deviation_mm * (N) * (ST) / (1.0f - (ST)))
842
-
843
     #if HAS_LINEAR_E_JERK
841
     #if HAS_LINEAR_E_JERK
844
       FORCE_INLINE static void recalculate_max_e_jerk() {
842
       FORCE_INLINE static void recalculate_max_e_jerk() {
845
-        #define GET_MAX_E_JERK(N) SQRT(JUNC_SQ(N,SQRT(0.5)))
843
+        #define GET_MAX_E_JERK(N) SQRT(junction_deviation_mm * (N) * SQRT(0.5) / (1.0f - SQRT(0.5)))
846
         #if ENABLED(DISTINCT_E_FACTORS)
844
         #if ENABLED(DISTINCT_E_FACTORS)
847
           LOOP_L_N(i, EXTRUDERS)
845
           LOOP_L_N(i, EXTRUDERS)
848
             max_e_jerk[i] = GET_MAX_E_JERK(settings.max_acceleration_mm_per_s2[E_AXIS_N(i)]);
846
             max_e_jerk[i] = GET_MAX_E_JERK(settings.max_acceleration_mm_per_s2[E_AXIS_N(i)]);

Loading…
Cancel
Save