File sstep_motion.c¶
FileList > src > sstep_motion.c
Go to the source code of this file
#include "sstep_internal.h"
Public Functions¶
| Type | Name |
|---|---|
| uint32_t | sstep_isqrt64 (uint64_t x) Integer square root: floor(sqrt(x)). |
| uint8_t | sstep_motion_step (struct sstep_motion * mo) One slow loop period of the motion generator: trapezoidal velocity profile with one-period look-ahead braking for moves, exact stop on the target. |
Public Static Functions¶
| Type | Name |
|---|---|
| int32_t | abs_i32 (int32_t v) |v|; velocities are limited to |v| < 2^30, so -v cannot overflow. |
| int64_t | abs_i64 (int64_t v) |v|; positions differences are far below 2^63. |
| int32_t | clamp_i32 (int32_t v, int32_t lo, int32_t hi) v limited to lo . |
| int64_t | half_floor (int64_t v) floor(v / 2) without shifting a signed value. |
| int32_t | target_velocity (const struct sstep_motion * mo) Velocity the profile aims at in this period. |
Public Functions Documentation¶
function sstep_isqrt64¶
Integer square root: floor(sqrt(x)).
Parameters:
xValue.
Returns:
floor(sqrt(x)).
function sstep_motion_step¶
One slow loop period of the motion generator: trapezoidal velocity profile with one-period look-ahead braking for moves, exact stop on the target.
Parameters:
moMotion state; pos and vel are updated.
Returns:
SSTEP_MOTION_DONE when a move reached its target in this period, else 0.
Public Static Functions Documentation¶
function abs_i32¶
|v|; velocities are limited to |v| < 2^30, so -v cannot overflow.
function abs_i64¶
|v|; positions differences are far below 2^63.
function clamp_i32¶
v limited to lo .
. hi.
function half_floor¶
floor(v / 2) without shifting a signed value.
function target_velocity¶
Velocity the profile aims at in this period.
A move aims at the largest v_new for which the distance of this period, (v + v_new) / 2, plus the braking distance from v_new, v_new^2 / (2 dec), fits into the distance left: v_new = (-dec + sqrt(dec^2 + 8 dec |rem| - 4 dec |v|)) / 2. No overshoot; the velocity changes by at most acc or dec per period, except in the last period of a move, where the remaining v <= 2 dec (a few microsteps per second) drops to zero on the target.
The documentation for this class was generated from the following file src/sstep_motion.c