Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
marlin-anet-a8
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jonas Leder
marlin-anet-a8
Commits
542efda7
Unverified
Commit
542efda7
authored
Dec 7, 2017
by
Scott Lahteine
Committed by
GitHub
Dec 7, 2017
Browse files
Options
Downloads
Plain Diff
Merge pull request #8698 from thinkyhead/bf2_replace_jerk_code
[2.0.x] Improved Core-compatible jerk code
parents
438c21ad
3cd76599
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Marlin/src/module/planner.cpp
+11
-28
11 additions, 28 deletions
Marlin/src/module/planner.cpp
with
11 additions
and
28 deletions
Marlin/src/module/planner.cpp
+
11
−
28
View file @
542efda7
...
@@ -1090,10 +1090,13 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE], float fr_mm_s, const
...
@@ -1090,10 +1090,13 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE], float fr_mm_s, const
}
}
#endif
#endif
// Calculate and limit speed in mm/sec for each axis
// Calculate and limit speed in mm/sec for each axis
, calculate minimum acceleration ratio
float
current_speed
[
NUM_AXIS
],
speed_factor
=
1.0
;
// factor <1 decreases speed
float
current_speed
[
NUM_AXIS
],
speed_factor
=
1.0
;
// factor <1 decreases speed
float
max_stepper_speed
=
0
,
min_axis_accel_ratio
=
1
;
// ratio < 1 means acceleration ramp needed
LOOP_XYZE
(
i
)
{
LOOP_XYZE
(
i
)
{
const
float
cs
=
FABS
((
current_speed
[
i
]
=
delta_mm
[
i
]
*
inverse_secs
));
const
float
cs
=
FABS
((
current_speed
[
i
]
=
delta_mm
[
i
]
*
inverse_secs
));
NOMORE
(
min_axis_accel_ratio
,
max_jerk
[
i
]
/
cs
);
NOLESS
(
max_stepper_speed
,
cs
);
#if ENABLED(DISTINCT_E_FACTORS)
#if ENABLED(DISTINCT_E_FACTORS)
if
(
i
==
E_AXIS
)
i
+=
extruder
;
if
(
i
==
E_AXIS
)
i
+=
extruder
;
#endif
#endif
...
@@ -1138,6 +1141,9 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE], float fr_mm_s, const
...
@@ -1138,6 +1141,9 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE], float fr_mm_s, const
}
}
#endif // XY_FREQUENCY_LIMIT
#endif // XY_FREQUENCY_LIMIT
block
->
nominal_speed
=
max_stepper_speed
;
// (mm/sec) Always > 0
block
->
nominal_rate
=
CEIL
(
block
->
step_event_count
*
inverse_secs
);
// (step/sec) Always > 0
// Correct the speed
// Correct the speed
if
(
speed_factor
<
1.0
)
{
if
(
speed_factor
<
1.0
)
{
LOOP_XYZE
(
i
)
current_speed
[
i
]
*=
speed_factor
;
LOOP_XYZE
(
i
)
current_speed
[
i
]
*=
speed_factor
;
...
@@ -1145,6 +1151,9 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE], float fr_mm_s, const
...
@@ -1145,6 +1151,9 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE], float fr_mm_s, const
block
->
nominal_rate
*=
speed_factor
;
block
->
nominal_rate
*=
speed_factor
;
}
}
float
safe_speed
=
block
->
nominal_speed
*
min_axis_accel_ratio
;
static
float
previous_safe_speed
;
// Compute and limit the acceleration rate for the trapezoid generator.
// Compute and limit the acceleration rate for the trapezoid generator.
const
float
steps_per_mm
=
block
->
step_event_count
*
inverse_millimeters
;
const
float
steps_per_mm
=
block
->
step_event_count
*
inverse_millimeters
;
uint32_t
accel
;
uint32_t
accel
;
...
@@ -1246,32 +1255,6 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE], float fr_mm_s, const
...
@@ -1246,32 +1255,6 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE], float fr_mm_s, const
}
}
#endif
#endif
/**
* Adapted from Průša MKS firmware
* https://github.com/prusa3d/Prusa-Firmware
*
* Start with a safe speed (from which the machine may halt to stop immediately).
*/
// Exit speed limited by a jerk to full halt of a previous last segment
static
float
previous_safe_speed
;
float
safe_speed
=
block
->
nominal_speed
;
uint8_t
limited
=
0
;
LOOP_XYZE
(
i
)
{
const
float
jerk
=
FABS
(
current_speed
[
i
]),
maxj
=
max_jerk
[
i
];
if
(
jerk
>
maxj
)
{
if
(
limited
)
{
const
float
mjerk
=
maxj
*
block
->
nominal_speed
;
if
(
jerk
*
safe_speed
>
mjerk
)
safe_speed
=
mjerk
/
jerk
;
}
else
{
++
limited
;
safe_speed
=
maxj
;
}
}
}
if
(
moves_queued
&&
!
UNEAR_ZERO
(
previous_nominal_speed
))
{
if
(
moves_queued
&&
!
UNEAR_ZERO
(
previous_nominal_speed
))
{
// Estimate a maximum velocity allowed at a joint of two successive segments.
// Estimate a maximum velocity allowed at a joint of two successive segments.
// If this maximum velocity allowed is lower than the minimum of the entry / exit safe velocities,
// If this maximum velocity allowed is lower than the minimum of the entry / exit safe velocities,
...
@@ -1283,7 +1266,7 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE], float fr_mm_s, const
...
@@ -1283,7 +1266,7 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE], float fr_mm_s, const
// Factor to multiply the previous / current nominal velocities to get componentwise limited velocities.
// Factor to multiply the previous / current nominal velocities to get componentwise limited velocities.
float
v_factor
=
1
;
float
v_factor
=
1
;
limited
=
0
;
uint8_t
limited
=
0
;
// Now limit the jerk in all axes.
// Now limit the jerk in all axes.
const
float
smaller_speed_factor
=
vmax_junction
/
previous_nominal_speed
;
const
float
smaller_speed_factor
=
vmax_junction
/
previous_nominal_speed
;
...
...
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment