|
Prusa MINI Firmware overview
|
#include "stepper.h"#include "endstops.h"#include "planner.h"#include "motion.h"#include "temperature.h"#include "../lcd/ultralcd.h"#include "../core/language.h"#include "../gcode/queue.h"#include "../sd/cardreader.h"#include "../Marlin.h"#include "../HAL/shared/Delay.h"Macros | |
| #define | DUAL_ENDSTOP_APPLY_STEP(A, V) |
| #define | DUAL_SEPARATE_APPLY_STEP(A, V) |
| #define | TRIPLE_ENDSTOP_APPLY_STEP(A, V) |
| #define | TRIPLE_SEPARATE_APPLY_STEP(A, V) |
| #define | X_APPLY_DIR(v, Q) X_DIR_WRITE(v) |
| #define | X_APPLY_STEP(v, Q) X_STEP_WRITE(v) |
| #define | Y_APPLY_DIR(v, Q) Y_DIR_WRITE(v) |
| #define | Y_APPLY_STEP(v, Q) Y_STEP_WRITE(v) |
| #define | Z_APPLY_DIR(v, Q) Z_DIR_WRITE(v) |
| #define | Z_APPLY_STEP(v, Q) Z_STEP_WRITE(v) |
| #define | SET_STEP_DIR(A) |
| #define | STEP_MULTIPLY(A, B) MultiU24X32toH16(A, B) |
| #define | _APPLY_STEP(AXIS) AXIS ##_APPLY_STEP |
| #define | _INVERT_STEP_PIN(AXIS) INVERT_## AXIS ##_STEP_PIN |
| #define | PULSE_START(AXIS) |
| #define | PULSE_STOP(AXIS) |
| #define | S_(N) current_block->steps[CORE_AXIS_##N] |
| #define | D_(N) TEST(current_block->direction_bits, CORE_AXIS_##N) |
| #define | X_CMP == |
| #define | X_MOVE_TEST ( S_(1) != S_(2) || (S_(1) > 0 && D_(1) X_CMP D_(2)) ) |
| #define | Y_CMP == |
| #define | Y_MOVE_TEST ( S_(1) != S_(2) || (S_(1) > 0 && D_(1) Y_CMP D_(2)) ) |
| #define | Z_CMP == |
| #define | Z_MOVE_TEST ( S_(1) != S_(2) || (S_(1) > 0 && D_(1) Z_CMP D_(2)) ) |
| #define | _STEP_INIT(AXIS) AXIS ##_STEP_INIT |
| #define | _WRITE_STEP(AXIS, HIGHLOW) AXIS ##_STEP_WRITE(HIGHLOW) |
| #define | _DISABLE(AXIS) disable_## AXIS() |
| #define | AXIS_INIT(AXIS, PIN) |
| #define | E_AXIS_INIT(NUM) AXIS_INIT(E## NUM, E) |
Functions | |
| HAL_STEP_TIMER_ISR () | |
Variables | |
| Stepper | stepper |
| #define DUAL_ENDSTOP_APPLY_STEP | ( | A, | |
| V | |||
| ) |
| #define DUAL_SEPARATE_APPLY_STEP | ( | A, | |
| V | |||
| ) |
| #define TRIPLE_ENDSTOP_APPLY_STEP | ( | A, | |
| V | |||
| ) |
| #define TRIPLE_SEPARATE_APPLY_STEP | ( | A, | |
| V | |||
| ) |
| #define X_APPLY_DIR | ( | v, | |
| Q | |||
| ) | X_DIR_WRITE(v) |
| #define X_APPLY_STEP | ( | v, | |
| Q | |||
| ) | X_STEP_WRITE(v) |
| #define Y_APPLY_DIR | ( | v, | |
| Q | |||
| ) | Y_DIR_WRITE(v) |
| #define Y_APPLY_STEP | ( | v, | |
| Q | |||
| ) | Y_STEP_WRITE(v) |
| #define Z_APPLY_DIR | ( | v, | |
| Q | |||
| ) | Z_DIR_WRITE(v) |
| #define Z_APPLY_STEP | ( | v, | |
| Q | |||
| ) | Z_STEP_WRITE(v) |
| #define SET_STEP_DIR | ( | A | ) |
| #define STEP_MULTIPLY | ( | A, | |
| B | |||
| ) | MultiU24X32toH16(A, B) |
| #define _APPLY_STEP | ( | AXIS | ) | AXIS ##_APPLY_STEP |
| #define _INVERT_STEP_PIN | ( | AXIS | ) | INVERT_## AXIS ##_STEP_PIN |
| #define PULSE_START | ( | AXIS | ) |
| #define PULSE_STOP | ( | AXIS | ) |
| #define S_ | ( | N | ) | current_block->steps[CORE_AXIS_##N] |
| #define D_ | ( | N | ) | TEST(current_block->direction_bits, CORE_AXIS_##N) |
| #define X_CMP == |
| #define Y_CMP == |
| #define Z_CMP == |
| #define _STEP_INIT | ( | AXIS | ) | AXIS ##_STEP_INIT |
| #define _WRITE_STEP | ( | AXIS, | |
| HIGHLOW | |||
| ) | AXIS ##_STEP_WRITE(HIGHLOW) |
| #define _DISABLE | ( | AXIS | ) | disable_## AXIS() |
| #define AXIS_INIT | ( | AXIS, | |
| PIN | |||
| ) |
| #define E_AXIS_INIT | ( | NUM | ) | AXIS_INIT(E## NUM, E) |
| HAL_STEP_TIMER_ISR | ( | ) |
Stepper Driver Interrupt
Directly pulses the stepper motors at high frequency.

| Stepper stepper |
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/. stepper.cpp - A singleton object to execute motion plans using stepper motors Marlin Firmware
Derived from Grbl Copyright (c) 2009-2011 Simen Svale Skogsrud
Grbl 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.
Grbl 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 Grbl. If not, see http://www.gnu.org/licenses/. Timer calculations informed by the 'RepRap cartesian firmware' by Zack Smith and Philipp Tiefenbacher.
__________________________ /| |\ _________________ ^ / | | \ /| |\ | / | | \ / | | \ s
/ | | | | | \ p / | | | | | \ e +--—+---------------------—+—+–+------------—+-—+ e | BLOCK 1 | BLOCK 2 | d
time ----->
The trapezoid is the shape the speed curve over time. It starts at block->initial_rate, accelerates first block->accelerate_until step_events_completed, then keeps going at constant speed until step_events_completed reaches block->decelerate_after after which it decelerates until the trapezoid generator is reset. The slope of acceleration is calculated using v = u + at where t is the accumulated timer values of the steps so far. Marlin uses the Bresenham algorithm. For a detailed explanation of theory and method see https://www.cs.helsinki.fi/group/goa/mallinnus/lines/bresenh.html Jerk controlled movements planner added Apr 2018 by Eduardo José Tagle. Equations based on Synthethos TinyG2 sources, but the fixed-point implementation is new, as we are running the ISR with a variable period. Also implemented the Bézier velocity curve evaluation in ARM assembler, to avoid impacting ISR speed.