Added automatic mesh bed leveling feature
This commit is contained in:
parent
657f339d95
commit
f98cf1b44b
@ -374,7 +374,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
|
||||
//If you have enabled the Bed Auto Leveling and are using the same Z Probe for Z Homing,
|
||||
//it is highly recommended you let this Z_SAFE_HOMING enabled!!!
|
||||
|
||||
#define Z_SAFE_HOMING // This feature is meant to avoid Z homing with probe outside the bed area.
|
||||
//#define Z_SAFE_HOMING // This feature is meant to avoid Z homing with probe outside the bed area.
|
||||
// When defined, it will:
|
||||
// - Allow Z homing only after X and Y homing AND stepper drivers still enabled
|
||||
// - If stepper drivers timeout, it will need X and Y homing again before Z homing
|
||||
|
@ -5,6 +5,10 @@
|
||||
#include "ConfigurationStore.h"
|
||||
#include "Configuration_prusa.h"
|
||||
|
||||
#ifdef MESH_BED_LEVELING
|
||||
#include "mesh_bed_leveling.h"
|
||||
#endif
|
||||
|
||||
void _EEPROM_writeData(int &pos, uint8_t* value, uint8_t size)
|
||||
{
|
||||
do
|
||||
|
@ -44,6 +44,10 @@
|
||||
#endif
|
||||
#endif // ENABLE_AUTO_BED_LEVELING
|
||||
|
||||
#ifdef MESH_BED_LEVELING
|
||||
#include "mesh_bed_leveling.h"
|
||||
#endif
|
||||
|
||||
#include "ultralcd.h"
|
||||
#include "Configuration_prusa.h"
|
||||
#include "planner.h"
|
||||
@ -79,6 +83,10 @@
|
||||
|
||||
#include "ultralcd.h"
|
||||
|
||||
// Macros for bit masks
|
||||
#define BIT(b) (1<<(b))
|
||||
#define TEST(n,b) (((n)&BIT(b))!=0)
|
||||
#define SET_BIT(n,b,value) (n) ^= ((-value)^(n)) & (BIT(b))
|
||||
|
||||
|
||||
// look here for descriptions of G-codes: http://linuxcnc.org/handbook/gcode/g-code.html
|
||||
@ -103,6 +111,8 @@
|
||||
// G30 - Single Z Probe, probes bed at current XY location.
|
||||
// G31 - Dock sled (Z_PROBE_SLED only)
|
||||
// G32 - Undock sled (Z_PROBE_SLED only)
|
||||
// G80 - Automatic mesh bed leveling
|
||||
// G81 - Print bed profile
|
||||
// G90 - Use Absolute Coordinates
|
||||
// G91 - Use Relative Coordinates
|
||||
// G92 - Set current position to coordinates given
|
||||
@ -597,6 +607,13 @@ void servo_init()
|
||||
}
|
||||
|
||||
static void lcd_language_menu();
|
||||
|
||||
|
||||
#ifdef MESH_BED_LEVELING
|
||||
enum MeshLevelingState { MeshReport, MeshStart, MeshNext, MeshSet };
|
||||
#endif
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
setup_killpin();
|
||||
@ -912,6 +929,10 @@ long code_value_long()
|
||||
return (strtol(&cmdbuffer[bufindr][strchr_pointer - cmdbuffer[bufindr] + 1], NULL, 10));
|
||||
}
|
||||
|
||||
int16_t code_value_short() {
|
||||
return (int16_t)(strtol(&cmdbuffer[bufindr][strchr_pointer - cmdbuffer[bufindr] + 1], NULL, 10));
|
||||
}
|
||||
|
||||
bool code_seen(char code)
|
||||
{
|
||||
strchr_pointer = strchr(cmdbuffer[bufindr], code);
|
||||
@ -1051,6 +1072,10 @@ static void axis_is_at_home(int axis) {
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
inline void set_current_to_destination() { memcpy(current_position, destination, sizeof(current_position)); }
|
||||
inline void set_destination_to_current() { memcpy(destination, current_position, sizeof(destination)); }
|
||||
|
||||
#ifdef ENABLE_AUTO_BED_LEVELING
|
||||
#ifdef AUTO_BED_LEVELING_GRID
|
||||
static void set_bed_level_equation_lsq(double *plane_equation_coefficients)
|
||||
@ -1251,6 +1276,8 @@ static void homeaxis(int axis) {
|
||||
if (axis == X_AXIS)
|
||||
axis_home_dir = x_home_dir(active_extruder);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
current_position[axis] = 0;
|
||||
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
||||
@ -1698,6 +1725,11 @@ void process_commands()
|
||||
#ifdef ENABLE_AUTO_BED_LEVELING
|
||||
plan_bed_level_matrix.set_to_identity(); //Reset the plane ("erase" all leveling data)
|
||||
#endif //ENABLE_AUTO_BED_LEVELING
|
||||
|
||||
// For mesh bed leveling deactivate the matrix temporarily
|
||||
#ifdef MESH_BED_LEVELING
|
||||
mbl.active = 0;
|
||||
#endif
|
||||
|
||||
saved_feedrate = feedrate;
|
||||
saved_feedmultiply = feedmultiply;
|
||||
@ -1847,7 +1879,24 @@ void process_commands()
|
||||
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder);
|
||||
st_synchronize();
|
||||
#endif
|
||||
#ifdef MESH_BED_LEVELING // If Mesh bed leveling, moxve X&Y to safe position for home
|
||||
destination[X_AXIS] = MESH_MIN_X - X_PROBE_OFFSET_FROM_EXTRUDER;
|
||||
destination[Y_AXIS] = MESH_MIN_Y - Y_PROBE_OFFSET_FROM_EXTRUDER;
|
||||
destination[Z_AXIS] = MESH_HOME_Z_SEARCH; // Set destination away from bed
|
||||
feedrate = homing_feedrate[Z_AXIS]/10;
|
||||
current_position[Z_AXIS] = 0;
|
||||
|
||||
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
||||
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder);
|
||||
st_synchronize();
|
||||
current_position[X_AXIS] = destination[X_AXIS];
|
||||
current_position[Y_AXIS] = destination[Y_AXIS];
|
||||
HOMEAXIS(Z);
|
||||
|
||||
|
||||
#else
|
||||
HOMEAXIS(Z);
|
||||
#endif
|
||||
}
|
||||
#else // Z Safe mode activated.
|
||||
if(home_all_axis) {
|
||||
@ -1906,6 +1955,8 @@ void process_commands()
|
||||
current_position[Z_AXIS] += zprobe_zoffset; //Add Z_Probe offset (the distance is negative)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
||||
#endif // else DELTA
|
||||
|
||||
@ -1922,7 +1973,7 @@ void process_commands()
|
||||
feedmultiply = saved_feedmultiply;
|
||||
previous_millis_cmd = millis();
|
||||
endstops_hit_on_purpose();
|
||||
|
||||
#ifndef MESH_BED_LEVELING
|
||||
if(card.sdprinting) {
|
||||
EEPROM_read_B(EEPROM_BABYSTEP_Z,&babystepLoad[2]);
|
||||
|
||||
@ -1933,6 +1984,7 @@ void process_commands()
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@ -2120,6 +2172,124 @@ void process_commands()
|
||||
break;
|
||||
#endif // Z_PROBE_SLED
|
||||
#endif // ENABLE_AUTO_BED_LEVELING
|
||||
|
||||
#ifdef MESH_BED_LEVELING
|
||||
/**
|
||||
* G80: Mesh-based Z probe, probes a grid and produces a
|
||||
* mesh to compensate for variable bed height
|
||||
*
|
||||
* The S0 report the points as below
|
||||
*
|
||||
* +----> X-axis
|
||||
* |
|
||||
* |
|
||||
* v Y-axis
|
||||
*
|
||||
*/
|
||||
case 80:
|
||||
{
|
||||
// Firstly check if we know where we are
|
||||
if ( !( axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS] ) ){
|
||||
// We don't know where we are!!! HOME!
|
||||
enquecommand_P((PSTR("G28")));
|
||||
enquecommand_P((PSTR("G80")));
|
||||
break;
|
||||
}
|
||||
|
||||
mbl.reset();
|
||||
|
||||
|
||||
// Cycle through all points and probe them
|
||||
current_position[X_AXIS] = MESH_MIN_X - X_PROBE_OFFSET_FROM_EXTRUDER;
|
||||
current_position[Y_AXIS] = MESH_MIN_Y - Y_PROBE_OFFSET_FROM_EXTRUDER;
|
||||
|
||||
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[X_AXIS]/30, active_extruder);
|
||||
|
||||
current_position[Z_AXIS] = MESH_HOME_Z_SEARCH;
|
||||
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[Z_AXIS]/60, active_extruder);
|
||||
st_synchronize();
|
||||
|
||||
int mesh_point = 0;
|
||||
|
||||
int ix = 0;
|
||||
int iy = 0;
|
||||
|
||||
int XY_AXIS_FEEDRATE = homing_feedrate[X_AXIS]/20;
|
||||
int Z_PROBE_FEEDRATE = homing_feedrate[Z_AXIS]/60;
|
||||
int Z_LIFT_FEEDRATE = homing_feedrate[Z_AXIS]/40;
|
||||
|
||||
while (!(mesh_point == ((MESH_NUM_X_POINTS * MESH_NUM_Y_POINTS)) )) {
|
||||
|
||||
// Move Z to proper distance
|
||||
current_position[Z_AXIS] = MESH_HOME_Z_SEARCH;
|
||||
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], Z_LIFT_FEEDRATE, active_extruder);
|
||||
|
||||
st_synchronize();
|
||||
|
||||
// Get cords of measuring point
|
||||
ix = mesh_point % MESH_NUM_X_POINTS;
|
||||
iy = mesh_point / MESH_NUM_X_POINTS;
|
||||
if (iy & 1) ix = (MESH_NUM_X_POINTS - 1) - ix; // Zig zag
|
||||
|
||||
current_position[X_AXIS] = mbl.get_x(ix);
|
||||
current_position[Y_AXIS] = mbl.get_y(iy);
|
||||
|
||||
current_position[X_AXIS] -= X_PROBE_OFFSET_FROM_EXTRUDER;
|
||||
current_position[Y_AXIS] -= Y_PROBE_OFFSET_FROM_EXTRUDER;
|
||||
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], XY_AXIS_FEEDRATE, active_extruder);
|
||||
|
||||
st_synchronize();
|
||||
|
||||
// Go down until endstop is hit
|
||||
while ((READ(Z_MIN_PIN)^Z_MIN_ENDSTOP_INVERTING ) == 0) {
|
||||
|
||||
current_position[Z_AXIS] -= MBL_Z_STEP;
|
||||
|
||||
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], Z_PROBE_FEEDRATE, active_extruder);
|
||||
st_synchronize();
|
||||
delay(1);
|
||||
}
|
||||
|
||||
|
||||
mbl.set_z(ix, iy, current_position[Z_AXIS]);
|
||||
|
||||
mesh_point++;
|
||||
|
||||
}
|
||||
current_position[Z_AXIS] = MESH_HOME_Z_SEARCH;
|
||||
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS],current_position[Z_AXIS] , current_position[E_AXIS], Z_LIFT_FEEDRATE, active_extruder);
|
||||
mbl.active = 1;
|
||||
current_position[X_AXIS] = X_MIN_POS+0.2;
|
||||
current_position[Y_AXIS] = Y_MIN_POS+0.2;
|
||||
current_position[Z_AXIS] = Z_MIN_POS;
|
||||
plan_buffer_line(current_position[X_AXIS], current_position[X_AXIS], current_position[Z_AXIS], current_position[E_AXIS], XY_AXIS_FEEDRATE, active_extruder);
|
||||
st_synchronize();
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case 81:
|
||||
if (mbl.active) {
|
||||
SERIAL_PROTOCOLPGM("Num X,Y: ");
|
||||
SERIAL_PROTOCOL(MESH_NUM_X_POINTS);
|
||||
SERIAL_PROTOCOLPGM(",");
|
||||
SERIAL_PROTOCOL(MESH_NUM_Y_POINTS);
|
||||
SERIAL_PROTOCOLPGM("\nZ search height: ");
|
||||
SERIAL_PROTOCOL(MESH_HOME_Z_SEARCH);
|
||||
SERIAL_PROTOCOLLNPGM("\nMeasured points:");
|
||||
for (int y = MESH_NUM_Y_POINTS-1; y >= 0; y--) {
|
||||
for (int x = 0; x < MESH_NUM_X_POINTS; x++) {
|
||||
SERIAL_PROTOCOLPGM(" ");
|
||||
SERIAL_PROTOCOL_F(mbl.z_values[y][x], 5);
|
||||
}
|
||||
SERIAL_PROTOCOLPGM("\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
SERIAL_PROTOCOLLNPGM("Mesh bed leveling not active.");
|
||||
break;
|
||||
#endif // ENABLE_MESH_BED_LEVELING
|
||||
|
||||
case 90: // G90
|
||||
relative_mode = false;
|
||||
break;
|
||||
@ -4450,6 +4620,79 @@ void calculate_delta(float cartesian[3])
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef MESH_BED_LEVELING
|
||||
|
||||
// This function is used to split lines on mesh borders so each segment is only part of one mesh area
|
||||
void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_rate, const uint8_t& extruder, uint8_t x_splits = 0xff, uint8_t y_splits = 0xff) {
|
||||
if (!mbl.active) {
|
||||
plan_buffer_line(x, y, z, e, feed_rate, extruder);
|
||||
set_current_to_destination();
|
||||
return;
|
||||
}
|
||||
int pix = mbl.select_x_index(current_position[X_AXIS]);
|
||||
int piy = mbl.select_y_index(current_position[Y_AXIS]);
|
||||
int ix = mbl.select_x_index(x);
|
||||
int iy = mbl.select_y_index(y);
|
||||
pix = min(pix, MESH_NUM_X_POINTS - 2);
|
||||
piy = min(piy, MESH_NUM_Y_POINTS - 2);
|
||||
ix = min(ix, MESH_NUM_X_POINTS - 2);
|
||||
iy = min(iy, MESH_NUM_Y_POINTS - 2);
|
||||
if (pix == ix && piy == iy) {
|
||||
// Start and end on same mesh square
|
||||
plan_buffer_line(x, y, z, e, feed_rate, extruder);
|
||||
set_current_to_destination();
|
||||
return;
|
||||
}
|
||||
float nx, ny, ne, normalized_dist;
|
||||
if (ix > pix && (x_splits) & BIT(ix)) {
|
||||
nx = mbl.get_x(ix);
|
||||
normalized_dist = (nx - current_position[X_AXIS]) / (x - current_position[X_AXIS]);
|
||||
ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
|
||||
ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
|
||||
x_splits ^= BIT(ix);
|
||||
}
|
||||
else if (ix < pix && (x_splits) & BIT(pix)) {
|
||||
nx = mbl.get_x(pix);
|
||||
normalized_dist = (nx - current_position[X_AXIS]) / (x - current_position[X_AXIS]);
|
||||
ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
|
||||
ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
|
||||
x_splits ^= BIT(pix);
|
||||
}
|
||||
else if (iy > piy && (y_splits) & BIT(iy)) {
|
||||
ny = mbl.get_y(iy);
|
||||
normalized_dist = (ny - current_position[Y_AXIS]) / (y - current_position[Y_AXIS]);
|
||||
nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
|
||||
ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
|
||||
y_splits ^= BIT(iy);
|
||||
}
|
||||
else if (iy < piy && (y_splits) & BIT(piy)) {
|
||||
ny = mbl.get_y(piy);
|
||||
normalized_dist = (ny - current_position[Y_AXIS]) / (y - current_position[Y_AXIS]);
|
||||
nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
|
||||
ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
|
||||
y_splits ^= BIT(piy);
|
||||
}
|
||||
else {
|
||||
// Already split on a border
|
||||
plan_buffer_line(x, y, z, e, feed_rate, extruder);
|
||||
set_current_to_destination();
|
||||
return;
|
||||
}
|
||||
// Do the split and look for more borders
|
||||
destination[X_AXIS] = nx;
|
||||
destination[Y_AXIS] = ny;
|
||||
destination[E_AXIS] = ne;
|
||||
mesh_plan_buffer_line(nx, ny, z, ne, feed_rate, extruder, x_splits, y_splits);
|
||||
destination[X_AXIS] = x;
|
||||
destination[Y_AXIS] = y;
|
||||
destination[E_AXIS] = e;
|
||||
mesh_plan_buffer_line(x, y, z, e, feed_rate, extruder, x_splits, y_splits);
|
||||
}
|
||||
#endif // MESH_BED_LEVELING
|
||||
|
||||
|
||||
|
||||
void prepare_move()
|
||||
{
|
||||
clamp_to_software_endstops(destination);
|
||||
@ -4565,10 +4808,18 @@ for (int s = 1; s <= steps; s++) {
|
||||
#if ! (defined DELTA || defined SCARA)
|
||||
// Do not use feedmultiply for E or Z only moves
|
||||
if( (current_position[X_AXIS] == destination [X_AXIS]) && (current_position[Y_AXIS] == destination [Y_AXIS])) {
|
||||
#ifdef MESH_BED_LEVELING
|
||||
mesh_plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
||||
#else
|
||||
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder);
|
||||
#ifdef MESH_BED_LEVELING
|
||||
mesh_plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder);
|
||||
#else
|
||||
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder);
|
||||
#endif
|
||||
}
|
||||
#endif // !(DELTA || SCARA)
|
||||
|
||||
|
16
Firmware/mesh_bed_leveling.cpp
Executable file
16
Firmware/mesh_bed_leveling.cpp
Executable file
@ -0,0 +1,16 @@
|
||||
#include "mesh_bed_leveling.h"
|
||||
|
||||
#ifdef MESH_BED_LEVELING
|
||||
|
||||
mesh_bed_leveling mbl;
|
||||
|
||||
mesh_bed_leveling::mesh_bed_leveling() { reset(); }
|
||||
|
||||
void mesh_bed_leveling::reset() {
|
||||
active = 0;
|
||||
for (int y = 0; y < MESH_NUM_Y_POINTS; y++)
|
||||
for (int x = 0; x < MESH_NUM_X_POINTS; x++)
|
||||
z_values[y][x] = 0;
|
||||
}
|
||||
|
||||
#endif // MESH_BED_LEVELING
|
57
Firmware/mesh_bed_leveling.h
Executable file
57
Firmware/mesh_bed_leveling.h
Executable file
@ -0,0 +1,57 @@
|
||||
#include "Marlin.h"
|
||||
|
||||
#ifdef MESH_BED_LEVELING
|
||||
|
||||
#define MESH_X_DIST ((MESH_MAX_X - MESH_MIN_X)/(MESH_NUM_X_POINTS - 1))
|
||||
#define MESH_Y_DIST ((MESH_MAX_Y - MESH_MIN_Y)/(MESH_NUM_Y_POINTS - 1))
|
||||
|
||||
class mesh_bed_leveling {
|
||||
public:
|
||||
uint8_t active;
|
||||
float z_values[MESH_NUM_Y_POINTS][MESH_NUM_X_POINTS];
|
||||
|
||||
mesh_bed_leveling();
|
||||
|
||||
void reset();
|
||||
|
||||
float get_x(int i) { return MESH_MIN_X + MESH_X_DIST * i; }
|
||||
float get_y(int i) { return MESH_MIN_Y + MESH_Y_DIST * i; }
|
||||
void set_z(int ix, int iy, float z) { z_values[iy][ix] = z; }
|
||||
|
||||
int select_x_index(float x) {
|
||||
int i = 1;
|
||||
while (x > get_x(i) && i < MESH_NUM_X_POINTS - 1) i++;
|
||||
return i - 1;
|
||||
}
|
||||
|
||||
int select_y_index(float y) {
|
||||
int i = 1;
|
||||
while (y > get_y(i) && i < MESH_NUM_Y_POINTS - 1) i++;
|
||||
return i - 1;
|
||||
}
|
||||
|
||||
float calc_z0(float a0, float a1, float z1, float a2, float z2) {
|
||||
float delta_z = (z2 - z1) / (a2 - a1);
|
||||
float delta_a = a0 - a1;
|
||||
return z1 + delta_a * delta_z;
|
||||
}
|
||||
|
||||
float get_z(float x0, float y0) {
|
||||
int x_index = select_x_index(x0);
|
||||
int y_index = select_y_index(y0);
|
||||
float z1 = calc_z0(x0,
|
||||
get_x(x_index), z_values[y_index][x_index],
|
||||
get_x(x_index + 1), z_values[y_index][x_index + 1]);
|
||||
float z2 = calc_z0(x0,
|
||||
get_x(x_index), z_values[y_index + 1][x_index],
|
||||
get_x(x_index + 1), z_values[y_index + 1][x_index + 1]);
|
||||
float z0 = calc_z0(y0,
|
||||
get_y(y_index), z1,
|
||||
get_y(y_index + 1), z2);
|
||||
return z0;
|
||||
}
|
||||
};
|
||||
|
||||
extern mesh_bed_leveling mbl;
|
||||
|
||||
#endif // MESH_BED_LEVELING
|
@ -58,6 +58,10 @@
|
||||
#include "ultralcd.h"
|
||||
#include "language.h"
|
||||
|
||||
#ifdef MESH_BED_LEVELING
|
||||
#include "mesh_bed_leveling.h"
|
||||
#endif
|
||||
|
||||
//===========================================================================
|
||||
//=============================public variables ============================
|
||||
//===========================================================================
|
||||
@ -556,7 +560,15 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
||||
long target[4];
|
||||
target[X_AXIS] = lround(x*axis_steps_per_unit[X_AXIS]);
|
||||
target[Y_AXIS] = lround(y*axis_steps_per_unit[Y_AXIS]);
|
||||
target[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]);
|
||||
#ifdef MESH_BED_LEVELING
|
||||
if (mbl.active){
|
||||
target[Z_AXIS] += lround((z+mbl.get_z(x, y))*axis_steps_per_unit[Z_AXIS]);
|
||||
}else{
|
||||
target[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]);
|
||||
}
|
||||
#else
|
||||
target[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]);
|
||||
#endif // ENABLE_MESH_BED_LEVELING
|
||||
target[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]);
|
||||
|
||||
#ifdef PREVENT_DANGEROUS_EXTRUDE
|
||||
@ -1058,10 +1070,19 @@ void plan_set_position(float x, float y, float z, const float &e)
|
||||
void plan_set_position(const float &x, const float &y, const float &z, const float &e)
|
||||
{
|
||||
#endif // ENABLE_AUTO_BED_LEVELING
|
||||
|
||||
|
||||
|
||||
position[X_AXIS] = lround(x*axis_steps_per_unit[X_AXIS]);
|
||||
position[Y_AXIS] = lround(y*axis_steps_per_unit[Y_AXIS]);
|
||||
position[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]);
|
||||
#ifdef MESH_BED_LEVELING
|
||||
if (mbl.active){
|
||||
position[Z_AXIS] += lround((z+mbl.get_z(x, y))*axis_steps_per_unit[Z_AXIS]);
|
||||
}else{
|
||||
position[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]);
|
||||
}
|
||||
#else
|
||||
position[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]);
|
||||
#endif // ENABLE_MESH_BED_LEVELING
|
||||
position[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]);
|
||||
st_set_position(position[X_AXIS], position[Y_AXIS], position[Z_AXIS], position[E_AXIS]);
|
||||
previous_nominal_speed = 0.0; // Resets planner junction speeds. Assumes start from rest.
|
||||
|
@ -1084,9 +1084,12 @@ static void lcd_settings_menu()
|
||||
|
||||
|
||||
MENU_ITEM(submenu, MSG_MOVE_AXIS, lcd_move_menu_1mm);
|
||||
|
||||
|
||||
#ifndef MESH_BED_LEVELING
|
||||
MENU_ITEM(gcode, MSG_HOMEYZ, PSTR("G28 Z"));
|
||||
|
||||
#else
|
||||
MENU_ITEM(gcode, MSG_HOMEYZ, PSTR("G80"));
|
||||
#endif
|
||||
MENU_ITEM(gcode, MSG_DISABLE_STEPPERS, PSTR("M84"));
|
||||
|
||||
|
||||
|
257
Firmware/variants/1_7dev-RAMBo13a-E3Dv6lite.h
Executable file
257
Firmware/variants/1_7dev-RAMBo13a-E3Dv6lite.h
Executable file
@ -0,0 +1,257 @@
|
||||
#ifndef CONFIGURATION_PRUSA_H
|
||||
#define CONFIGURATION_PRUSA_H
|
||||
|
||||
/*------------------------------------
|
||||
GENERAL SETTINGS
|
||||
*------------------------------------*/
|
||||
|
||||
// Printer revision
|
||||
#define FILAMENT_SIZE "1_7dev"
|
||||
#define NOZZLE_TYPE "E3Dv6lite"
|
||||
|
||||
// Printer name
|
||||
#define CUSTOM_MENDEL_NAME "Prusa i3 dev"
|
||||
|
||||
// Electronics
|
||||
#define MOTHERBOARD BOARD_RAMBO_MINI_1_3
|
||||
|
||||
|
||||
/*------------------------------------
|
||||
AXIS SETTINGS
|
||||
*------------------------------------*/
|
||||
|
||||
// Steps per unit {X,Y,Z,E}
|
||||
#define DEFAULT_AXIS_STEPS_PER_UNIT {100,100,3200/8,174.2}
|
||||
|
||||
// Endstop inverting
|
||||
const bool X_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
|
||||
const bool Y_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
|
||||
const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
|
||||
|
||||
// Home position
|
||||
#define MANUAL_X_HOME_POS 0
|
||||
#define MANUAL_Y_HOME_POS -1.2
|
||||
#define MANUAL_Z_HOME_POS 0.25
|
||||
|
||||
// Travel limits after homing
|
||||
#define X_MAX_POS 255
|
||||
#define X_MIN_POS 0
|
||||
#define Y_MAX_POS 210
|
||||
#define Y_MIN_POS -1.2
|
||||
#define Z_MAX_POS 202
|
||||
#define Z_MIN_POS 0.23
|
||||
|
||||
#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
|
||||
#define HOMING_FEEDRATE {3000, 3000, 800, 0} // set the homing speeds (mm/min)
|
||||
|
||||
#define DEFAULT_MAX_FEEDRATE {500, 500, 1800, 25} // (mm/sec)
|
||||
#define DEFAULT_MAX_ACCELERATION {9000,9000,1000,10000} // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for Skeinforge 40+, for older versions raise them a lot.
|
||||
|
||||
#define DEFAULT_ACCELERATION 3000 // X, Y, Z and E max acceleration in mm/s^2 for printing moves
|
||||
#define DEFAULT_RETRACT_ACCELERATION 3000 // X, Y, Z and E max acceleration in mm/s^2 for retracts
|
||||
|
||||
|
||||
#define MANUAL_FEEDRATE {3000, 3000, 2000, 100} // set the speeds for manual moves (mm/min)
|
||||
|
||||
|
||||
/*------------------------------------
|
||||
EXTRUDER SETTINGS
|
||||
*------------------------------------*/
|
||||
|
||||
// Mintemps
|
||||
#define HEATER_0_MINTEMP 15
|
||||
#define HEATER_1_MINTEMP 5
|
||||
#define HEATER_2_MINTEMP 5
|
||||
#define BED_MINTEMP 15
|
||||
|
||||
// Maxtemps
|
||||
#define HEATER_0_MAXTEMP 265
|
||||
#define HEATER_1_MAXTEMP 265
|
||||
#define HEATER_2_MAXTEMP 265
|
||||
#define BED_MAXTEMP 150
|
||||
|
||||
// Define PID constants for extruder
|
||||
#define DEFAULT_Kp 40.925
|
||||
#define DEFAULT_Ki 4.875
|
||||
#define DEFAULT_Kd 86.085
|
||||
|
||||
// Extrude mintemp
|
||||
#define EXTRUDE_MINTEMP 190
|
||||
|
||||
// Extruder cooling fans
|
||||
#define EXTRUDER_0_AUTO_FAN_PIN 8
|
||||
#define EXTRUDER_1_AUTO_FAN_PIN -1
|
||||
#define EXTRUDER_2_AUTO_FAN_PIN -1
|
||||
#define EXTRUDER_AUTO_FAN_TEMPERATURE 50
|
||||
#define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed
|
||||
|
||||
|
||||
|
||||
/*------------------------------------
|
||||
LOAD/UNLOAD FILAMENT SETTINGS
|
||||
*------------------------------------*/
|
||||
|
||||
// Load filament commands
|
||||
#define LOAD_FILAMENT_0 "M83"
|
||||
#define LOAD_FILAMENT_1 "G1 E70 F400"
|
||||
#define LOAD_FILAMENT_2 "G1 E40 F100"
|
||||
|
||||
// Unload filament commands
|
||||
#define UNLOAD_FILAMENT_0 "M83"
|
||||
#define UNLOAD_FILAMENT_1 "G1 E-80 F400"
|
||||
|
||||
/*------------------------------------
|
||||
CHANGE FILAMENT SETTINGS
|
||||
*------------------------------------*/
|
||||
|
||||
// Filament change configuration
|
||||
#define FILAMENTCHANGEENABLE
|
||||
#ifdef FILAMENTCHANGEENABLE
|
||||
#define FILAMENTCHANGE_XPOS 211
|
||||
#define FILAMENTCHANGE_YPOS 0
|
||||
#define FILAMENTCHANGE_ZADD 2
|
||||
#define FILAMENTCHANGE_FIRSTRETRACT -2
|
||||
#define FILAMENTCHANGE_FINALRETRACT -80
|
||||
|
||||
#define FILAMENTCHANGE_FIRSTFEED 70
|
||||
#define FILAMENTCHANGE_FINALFEED 50
|
||||
#define FILAMENTCHANGE_RECFEED 5
|
||||
|
||||
#define FILAMENTCHANGE_XYFEED 70
|
||||
#define FILAMENTCHANGE_EFEED 20
|
||||
#define FILAMENTCHANGE_RFEED 400
|
||||
#define FILAMENTCHANGE_EXFEED 2
|
||||
#define FILAMENTCHANGE_ZFEED 300
|
||||
|
||||
#endif
|
||||
|
||||
/*------------------------------------
|
||||
ADDITIONAL FEATURES SETTINGS
|
||||
*------------------------------------*/
|
||||
|
||||
// Define Prusa filament runout sensor
|
||||
//#define FILAMENT_RUNOUT_SUPPORT
|
||||
|
||||
#ifdef FILAMENT_RUNOUT_SUPPORT
|
||||
#define FILAMENT_RUNOUT_SENSOR 1
|
||||
#endif
|
||||
|
||||
/*------------------------------------
|
||||
MOTOR CURRENT SETTINGS
|
||||
*------------------------------------*/
|
||||
|
||||
// Motor Current setting for BIG RAMBo
|
||||
#define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A)
|
||||
#define DIGIPOT_MOTOR_CURRENT_LOUD {135,135,135,135,135}
|
||||
|
||||
// Motor Current settings for RAMBo mini PWM value = MotorCurrentSetting * 255 / range
|
||||
#if MOTHERBOARD == 102 || MOTHERBOARD == 302
|
||||
#define MOTOR_CURRENT_PWM_RANGE 2000
|
||||
#define DEFAULT_PWM_MOTOR_CURRENT {270, 450, 450} // {XY,Z,E}
|
||||
#define DEFAULT_PWM_MOTOR_CURRENT_LOUD {540, 450, 500} // {XY,Z,E}
|
||||
#endif
|
||||
|
||||
/*------------------------------------
|
||||
BED SETTINGS
|
||||
*------------------------------------*/
|
||||
|
||||
// Define Mesh Bed Leveling system to enable it
|
||||
#define MESH_BED_LEVELING
|
||||
#ifdef MESH_BED_LEVELING
|
||||
|
||||
#define MBL_Z_STEP 0.01
|
||||
|
||||
// Mesh definitions
|
||||
#define MESH_MIN_X 35
|
||||
#define MESH_MAX_X 238
|
||||
#define MESH_MIN_Y 7
|
||||
#define MESH_MAX_Y 203
|
||||
|
||||
#define MESH_NUM_X_POINTS 3 // Don't use more than 7 points per axis, implementation limited.
|
||||
#define MESH_NUM_Y_POINTS 3
|
||||
#define MESH_HOME_Z_CALIB 0.2
|
||||
#define MESH_HOME_Z_SEARCH 5
|
||||
|
||||
#define X_PROBE_OFFSET_FROM_EXTRUDER 23 // Z probe to nozzle X offset: -left +right
|
||||
#define Y_PROBE_OFFSET_FROM_EXTRUDER 8 // Z probe to nozzle Y offset: -front +behind
|
||||
#define Z_PROBE_OFFSET_FROM_EXTRUDER -0.4 // Z probe to nozzle Z offset: -below (always!)
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/*------------------------------------
|
||||
PREHEAT SETTINGS
|
||||
*------------------------------------*/
|
||||
|
||||
#define PLA_PREHEAT_HOTEND_TEMP 210
|
||||
#define PLA_PREHEAT_HPB_TEMP 50
|
||||
#define PLA_PREHEAT_FAN_SPEED 0
|
||||
|
||||
#define ABS_PREHEAT_HOTEND_TEMP 255
|
||||
#define ABS_PREHEAT_HPB_TEMP 100
|
||||
#define ABS_PREHEAT_FAN_SPEED 0
|
||||
|
||||
#define HIPS_PREHEAT_HOTEND_TEMP 220
|
||||
#define HIPS_PREHEAT_HPB_TEMP 100
|
||||
#define HIPS_PREHEAT_FAN_SPEED 0
|
||||
|
||||
#define PP_PREHEAT_HOTEND_TEMP 254
|
||||
#define PP_PREHEAT_HPB_TEMP 100
|
||||
#define PP_PREHEAT_FAN_SPEED 0
|
||||
|
||||
#define PET_PREHEAT_HOTEND_TEMP 240
|
||||
#define PET_PREHEAT_HPB_TEMP 90
|
||||
#define PET_PREHEAT_FAN_SPEED 0
|
||||
|
||||
#define FLEX_PREHEAT_HOTEND_TEMP 230
|
||||
#define FLEX_PREHEAT_HPB_TEMP 50
|
||||
#define FLEX_PREHEAT_FAN_SPEED 0
|
||||
|
||||
|
||||
/*------------------------------------
|
||||
THERMISTORS SETTINGS
|
||||
*------------------------------------*/
|
||||
|
||||
//
|
||||
//--NORMAL IS 4.7kohm PULLUP!-- 1kohm pullup can be used on hotend sensor, using correct resistor and table
|
||||
//
|
||||
//// Temperature sensor settings:
|
||||
// -2 is thermocouple with MAX6675 (only for sensor 0)
|
||||
// -1 is thermocouple with AD595
|
||||
// 0 is not used
|
||||
// 1 is 100k thermistor - best choice for EPCOS 100k (4.7k pullup)
|
||||
// 2 is 200k thermistor - ATC Semitec 204GT-2 (4.7k pullup)
|
||||
// 3 is Mendel-parts thermistor (4.7k pullup)
|
||||
// 4 is 10k thermistor !! do not use it for a hotend. It gives bad resolution at high temp. !!
|
||||
// 5 is 100K thermistor - ATC Semitec 104GT-2 (Used in ParCan & J-Head) (4.7k pullup)
|
||||
// 6 is 100k EPCOS - Not as accurate as table 1 (created using a fluke thermocouple) (4.7k pullup)
|
||||
// 7 is 100k Honeywell thermistor 135-104LAG-J01 (4.7k pullup)
|
||||
// 71 is 100k Honeywell thermistor 135-104LAF-J01 (4.7k pullup)
|
||||
// 8 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup)
|
||||
// 9 is 100k GE Sensing AL03006-58.2K-97-G1 (4.7k pullup)
|
||||
// 10 is 100k RS thermistor 198-961 (4.7k pullup)
|
||||
// 11 is 100k beta 3950 1% thermistor (4.7k pullup)
|
||||
// 12 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed)
|
||||
// 13 is 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE"
|
||||
// 20 is the PT100 circuit found in the Ultimainboard V2.x
|
||||
// 60 is 100k Maker's Tool Works Kapton Bed Thermistor beta=3950
|
||||
//
|
||||
// 1k ohm pullup tables - This is not normal, you would have to have changed out your 4.7k for 1k
|
||||
// (but gives greater accuracy and more stable PID)
|
||||
// 51 is 100k thermistor - EPCOS (1k pullup)
|
||||
// 52 is 200k thermistor - ATC Semitec 204GT-2 (1k pullup)
|
||||
// 55 is 100k thermistor - ATC Semitec 104GT-2 (Used in ParCan & J-Head) (1k pullup)
|
||||
//
|
||||
// 1047 is Pt1000 with 4k7 pullup
|
||||
// 1010 is Pt1000 with 1k pullup (non standard)
|
||||
// 147 is Pt100 with 4k7 pullup
|
||||
// 110 is Pt100 with 1k pullup (non standard)
|
||||
|
||||
#define TEMP_SENSOR_0 5
|
||||
#define TEMP_SENSOR_1 0
|
||||
#define TEMP_SENSOR_2 0
|
||||
#define TEMP_SENSOR_BED 1
|
||||
|
||||
|
||||
#endif //__CONFIGURATION_PRUSA_H
|
Loading…
Reference in New Issue
Block a user