Prusa MINI Firmware overview
planner.cpp File Reference
#include "planner.h"
#include "stepper.h"
#include "motion.h"
#include "temperature.h"
#include "../lcd/ultralcd.h"
#include "../core/language.h"
#include "../gcode/parser.h"
#include "../Marlin.h"
#include "../feature/bedlevel/bedlevel.h"
#include "../feature/spindle_laser.h"

Macros

#define BLOCK_DELAY_FOR_1ST_MOVE   100
 
#define MINIMAL_STEP_RATE   120
 
#define LIMIT_ACCEL_LONG(AXIS, INDX)
 
#define LIMIT_ACCEL_FLOAT(AXIS, INDX)
 
#define ACCEL_IDX   0
 
#define CACHED_SQRT(N, V)   const float N = SQRT(V)
 
#define AXIS_CONDITION   true
 

Functions

void limit_and_warn (float &val, const uint8_t axis, PGM_P const setting_name, const xyze_float_t &max_limit)
 

Variables

Planner planner
 
constexpr xy_pos_t level_fulcrum
 

Macro Definition Documentation

◆ BLOCK_DELAY_FOR_1ST_MOVE

#define BLOCK_DELAY_FOR_1ST_MOVE   100

Marlin 3D Printer Firmware Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]

Based on Sprinter and grbl. Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. planner.cpp

Buffer movement commands and manage the acceleration profile plan

Derived from Grbl Copyright (c) 2009-2011 Simen Svale Skogsrud

The ring buffer implementation gleaned from the wiring_serial library by David A. Mellis.

Reasoning behind the mathematics in this module (in the key of 'Mathematica'):

s == speed, a == acceleration, t == time, d == distance

Basic definitions: Speed[s_, a_, t_] := s + (a*t) Travel[s_, a_, t_] := Integrate[Speed[s, a, t], t]

Distance to reach a specific speed with a constant acceleration: Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, d, t] d -> (m^2 - s^2)/(2 a) --> estimate_acceleration_distance()

Speed after a given distance of travel with constant acceleration: Solve[{Speed[s, a, t] == m, Travel[s, a, t] == d}, m, t] m -> Sqrt[2 a d + s^2]

DestinationSpeed[s_, a_, d_] := Sqrt[2 a d + s^2]

When to start braking (di) to reach a specified destination speed (s2) after accelerating from initial speed s1 without ever stopping at a plateau: Solve[{DestinationSpeed[s1, a, di] == DestinationSpeed[s2, a, d - di]}, di] di -> (2 a d - s1^2 + s2^2)/(4 a) --> intersection_distance()

IntersectionDistance[s1_, s2_, a_, d_] := (2 a d - s1^2 + s2^2)/(4 a)


The fast inverse function needed for Bézier interpolation for AVR was designed, written and tested by Eduardo José Tagle on April/2018

◆ MINIMAL_STEP_RATE

#define MINIMAL_STEP_RATE   120

◆ LIMIT_ACCEL_LONG

#define LIMIT_ACCEL_LONG (   AXIS,
  INDX 
)
Value:
do{ \
if (block->steps[AXIS] && max_acceleration_steps_per_s2[AXIS+INDX] < accel) { \
const uint32_t comp = max_acceleration_steps_per_s2[AXIS+INDX] * block->step_event_count; \
if (accel * block->steps[AXIS] > comp) accel = comp / block->steps[AXIS]; \
} \
}while(0)

◆ LIMIT_ACCEL_FLOAT

#define LIMIT_ACCEL_FLOAT (   AXIS,
  INDX 
)
Value:
do{ \
if (block->steps[AXIS] && max_acceleration_steps_per_s2[AXIS+INDX] < accel) { \
const float comp = (float)max_acceleration_steps_per_s2[AXIS+INDX] * (float)block->step_event_count; \
if ((float)accel * (float)block->steps[AXIS] > comp) accel = comp / (float)block->steps[AXIS]; \
} \
}while(0)

◆ ACCEL_IDX

#define ACCEL_IDX   0

◆ CACHED_SQRT

#define CACHED_SQRT (   N,
 
)    const float N = SQRT(V)

◆ AXIS_CONDITION

#define AXIS_CONDITION   true

Function Documentation

◆ limit_and_warn()

void limit_and_warn ( float &  val,
const uint8_t  axis,
PGM_P const  setting_name,
const xyze_float_t max_limit 
)
2812  {
2813  const uint8_t lim_axis = axis > E_AXIS ? E_AXIS : axis;
2814  const float before = val;
2815  LIMIT(val, 1, max_limit[lim_axis]);
2816  if (before != val) {
2817  SERIAL_CHAR(axis_codes[lim_axis]);
2818  SERIAL_ECHOPGM(" Max ");
2819  serialprintPGM(setting_name);
2820  SERIAL_ECHOLNPAIR(" limited to ", val);
2821  }
2822 }
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ planner

Planner planner

◆ level_fulcrum

constexpr xy_pos_t level_fulcrum
constexpr
Initial value:
SERIAL_CHAR
#define SERIAL_CHAR(x)
Definition: serial.h:69
LIMIT
#define LIMIT(v, n1, n2)
Definition: macros.h:139
X_HOME_POS
#define X_HOME_POS
Definition: Conditionals_post.h:156
Y_HOME_POS
#define Y_HOME_POS
Definition: Conditionals_post.h:172
SERIAL_ECHOPGM
#define SERIAL_ECHOPGM(S)
Definition: serial.h:173
SERIAL_ECHOLNPAIR
#define SERIAL_ECHOLNPAIR(V...)
Definition: serial.h:144
uint8_t
const uint8_t[]
Definition: 404_html.c:3
E_AXIS
Definition: types.h:40
serialprintPGM
void serialprintPGM(PGM_P str)
Definition: serial.cpp:35
axis_codes
const xyze_char_t axis_codes
Definition: types.h:486