2017-09-24 01:09:14 +02:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
|
|
|
* Copyright (C) 2016 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/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "../gcode.h"
|
|
|
|
#include "../../Marlin.h"
|
|
|
|
#include "../../module/planner.h"
|
|
|
|
|
2017-12-20 02:44:11 +01:00
|
|
|
#if DISABLED(NO_VOLUMETRICS)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* M200: Set filament diameter and set E axis units to cubic units
|
|
|
|
*
|
|
|
|
* T<extruder> - Optional extruder number. Current extruder if omitted.
|
|
|
|
* D<linear> - Diameter of the filament. Use "D0" to switch back to linear units on the E axis.
|
|
|
|
*/
|
|
|
|
void GcodeSuite::M200() {
|
2017-09-24 01:09:14 +02:00
|
|
|
|
2018-11-15 00:33:04 +01:00
|
|
|
const int8_t target_extruder = get_target_extruder_from_command();
|
|
|
|
if (target_extruder < 0) return;
|
2017-09-24 01:09:14 +02:00
|
|
|
|
2017-12-20 02:44:11 +01:00
|
|
|
if (parser.seen('D')) {
|
|
|
|
// setting any extruder filament size disables volumetric on the assumption that
|
|
|
|
// slicers either generate in extruder values as cubic mm or as as filament feeds
|
|
|
|
// for all extruders
|
2018-07-01 22:20:28 +02:00
|
|
|
if ( (parser.volumetric_enabled = (parser.value_linear_units() != 0)) )
|
2017-12-20 02:44:11 +01:00
|
|
|
planner.set_filament_size(target_extruder, parser.value_linear_units());
|
|
|
|
}
|
|
|
|
planner.calculate_volumetric_multipliers();
|
2017-09-24 01:09:14 +02:00
|
|
|
}
|
2017-12-20 02:44:11 +01:00
|
|
|
|
|
|
|
#endif // !NO_VOLUMETRICS
|
2017-09-24 01:09:14 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* M201: Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000)
|
|
|
|
*
|
|
|
|
* With multiple extruders use T to specify which one.
|
|
|
|
*/
|
|
|
|
void GcodeSuite::M201() {
|
|
|
|
|
2018-11-15 00:33:04 +01:00
|
|
|
const int8_t target_extruder = get_target_extruder_from_command();
|
|
|
|
if (target_extruder < 0) return;
|
2017-09-24 01:09:14 +02:00
|
|
|
|
|
|
|
LOOP_XYZE(i) {
|
|
|
|
if (parser.seen(axis_codes[i])) {
|
2018-11-20 13:44:11 +01:00
|
|
|
const uint8_t a = (i == uint8_t(E_AXIS) ? E_AXIS_N(target_extruder) : i);
|
2018-10-10 16:45:20 +02:00
|
|
|
planner.settings.max_acceleration_mm_per_s2[a] = parser.value_axis_units((AxisEnum)a);
|
2017-09-24 01:09:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner)
|
|
|
|
planner.reset_acceleration_rates();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* M203: Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in units/sec
|
|
|
|
*
|
|
|
|
* With multiple extruders use T to specify which one.
|
|
|
|
*/
|
|
|
|
void GcodeSuite::M203() {
|
|
|
|
|
2018-11-15 00:33:04 +01:00
|
|
|
const int8_t target_extruder = get_target_extruder_from_command();
|
|
|
|
if (target_extruder < 0) return;
|
2017-09-24 01:09:14 +02:00
|
|
|
|
|
|
|
LOOP_XYZE(i)
|
|
|
|
if (parser.seen(axis_codes[i])) {
|
2018-11-15 00:33:04 +01:00
|
|
|
const uint8_t a = (i == E_AXIS ? E_AXIS_N(target_extruder) : i);
|
2018-10-10 16:45:20 +02:00
|
|
|
planner.settings.max_feedrate_mm_s[a] = parser.value_axis_units((AxisEnum)a);
|
2017-09-24 01:09:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* M204: Set Accelerations in units/sec^2 (M204 P1200 R3000 T3000)
|
|
|
|
*
|
|
|
|
* P = Printing moves
|
|
|
|
* R = Retract only (no X, Y, Z) moves
|
|
|
|
* T = Travel (non printing) moves
|
|
|
|
*/
|
|
|
|
void GcodeSuite::M204() {
|
2018-11-03 07:16:37 +01:00
|
|
|
if (!parser.seen("PRST")) {
|
2018-10-10 16:45:20 +02:00
|
|
|
SERIAL_ECHOPAIR("Acceleration: P", planner.settings.acceleration);
|
|
|
|
SERIAL_ECHOPAIR(" R", planner.settings.retract_acceleration);
|
|
|
|
SERIAL_ECHOLNPAIR(" T", planner.settings.travel_acceleration);
|
2017-09-24 01:09:14 +02:00
|
|
|
}
|
2018-11-03 07:16:37 +01:00
|
|
|
else {
|
2018-11-12 09:43:14 +01:00
|
|
|
//planner.synchronize();
|
2018-11-03 07:16:37 +01:00
|
|
|
// 'S' for legacy compatibility. Should NOT BE USED for new development
|
|
|
|
if (parser.seenval('S')) planner.settings.travel_acceleration = planner.settings.acceleration = parser.value_linear_units();
|
|
|
|
if (parser.seenval('P')) planner.settings.acceleration = parser.value_linear_units();
|
|
|
|
if (parser.seenval('R')) planner.settings.retract_acceleration = parser.value_linear_units();
|
|
|
|
if (parser.seenval('T')) planner.settings.travel_acceleration = parser.value_linear_units();
|
|
|
|
}
|
2017-09-24 01:09:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* M205: Set Advanced Settings
|
|
|
|
*
|
2018-06-11 01:02:54 +02:00
|
|
|
* B = Min Segment Time (µs)
|
2017-09-24 01:09:14 +02:00
|
|
|
* S = Min Feed Rate (units/s)
|
|
|
|
* T = Min Travel Feed Rate (units/s)
|
|
|
|
* X = Max X Jerk (units/sec^2)
|
|
|
|
* Y = Max Y Jerk (units/sec^2)
|
|
|
|
* Z = Max Z Jerk (units/sec^2)
|
|
|
|
* E = Max E Jerk (units/sec^2)
|
2018-06-11 01:02:54 +02:00
|
|
|
* J = Junction Deviation (mm) (Requires JUNCTION_DEVIATION)
|
2017-09-24 01:09:14 +02:00
|
|
|
*/
|
|
|
|
void GcodeSuite::M205() {
|
2018-11-03 07:16:37 +01:00
|
|
|
#if ENABLED(JUNCTION_DEVIATION)
|
|
|
|
#define J_PARAM "J"
|
|
|
|
#else
|
2018-11-06 05:36:38 +01:00
|
|
|
#define J_PARAM
|
2018-11-03 07:16:37 +01:00
|
|
|
#endif
|
|
|
|
#if HAS_CLASSIC_JERK
|
|
|
|
#define XYZE_PARAM "XYZE"
|
|
|
|
#else
|
2018-11-06 05:36:38 +01:00
|
|
|
#define XYZE_PARAM
|
2018-11-03 07:16:37 +01:00
|
|
|
#endif
|
|
|
|
if (!parser.seen("BST" J_PARAM XYZE_PARAM)) return;
|
|
|
|
|
2018-11-12 09:43:14 +01:00
|
|
|
//planner.synchronize();
|
2018-10-10 16:45:20 +02:00
|
|
|
if (parser.seen('B')) planner.settings.min_segment_time_us = parser.value_ulong();
|
|
|
|
if (parser.seen('S')) planner.settings.min_feedrate_mm_s = parser.value_linear_units();
|
|
|
|
if (parser.seen('T')) planner.settings.min_travel_feedrate_mm_s = parser.value_linear_units();
|
2018-06-11 01:02:54 +02:00
|
|
|
#if ENABLED(JUNCTION_DEVIATION)
|
2018-06-11 01:20:21 +02:00
|
|
|
if (parser.seen('J')) {
|
|
|
|
const float junc_dev = parser.value_linear_units();
|
2018-07-01 22:20:28 +02:00
|
|
|
if (WITHIN(junc_dev, 0.01f, 0.3f)) {
|
2018-06-11 01:20:21 +02:00
|
|
|
planner.junction_deviation_mm = junc_dev;
|
2018-09-17 04:24:15 +02:00
|
|
|
#if ENABLED(LIN_ADVANCE)
|
|
|
|
planner.recalculate_max_e_jerk();
|
|
|
|
#endif
|
2018-06-12 01:49:08 +02:00
|
|
|
}
|
2018-06-11 01:20:21 +02:00
|
|
|
else {
|
|
|
|
SERIAL_ERROR_START();
|
|
|
|
SERIAL_ERRORLNPGM("?J out of range (0.01 to 0.3)");
|
|
|
|
}
|
|
|
|
}
|
2018-09-17 04:24:15 +02:00
|
|
|
#endif
|
|
|
|
#if HAS_CLASSIC_JERK
|
2018-06-11 01:02:54 +02:00
|
|
|
if (parser.seen('X')) planner.max_jerk[X_AXIS] = parser.value_linear_units();
|
|
|
|
if (parser.seen('Y')) planner.max_jerk[Y_AXIS] = parser.value_linear_units();
|
|
|
|
if (parser.seen('Z')) {
|
|
|
|
planner.max_jerk[Z_AXIS] = parser.value_linear_units();
|
|
|
|
#if HAS_MESH
|
2018-07-01 22:20:28 +02:00
|
|
|
if (planner.max_jerk[Z_AXIS] <= 0.1f)
|
2018-06-11 01:02:54 +02:00
|
|
|
SERIAL_ECHOLNPGM("WARNING! Low Z Jerk may lead to unwanted pauses.");
|
|
|
|
#endif
|
|
|
|
}
|
2018-09-17 04:24:15 +02:00
|
|
|
#if DISABLED(JUNCTION_DEVIATION) || DISABLED(LIN_ADVANCE)
|
|
|
|
if (parser.seen('E')) planner.max_jerk[E_AXIS] = parser.value_linear_units();
|
|
|
|
#endif
|
2018-06-11 01:02:54 +02:00
|
|
|
#endif
|
2017-09-24 01:09:14 +02:00
|
|
|
}
|