Commit cb6236ed authored by MagoKimbra's avatar MagoKimbra

Update

parent 4f4b9507
...@@ -174,7 +174,7 @@ ...@@ -174,7 +174,7 @@
#define TEMP_SENSOR_1 0 #define TEMP_SENSOR_1 0
#define TEMP_SENSOR_2 0 #define TEMP_SENSOR_2 0
#define TEMP_SENSOR_3 0 #define TEMP_SENSOR_3 0
#define TEMP_SENSOR_BED 1 #define TEMP_SENSOR_BED 0
// This makes temp sensor 1 a redundant sensor for sensor 0. // This makes temp sensor 1 a redundant sensor for sensor 0.
// If the temperatures difference between these sensors is to high the print will be aborted. // If the temperatures difference between these sensors is to high the print will be aborted.
...@@ -693,4 +693,5 @@ your extruder heater takes 2 minutes to hit the target on heating. ...@@ -693,4 +693,5 @@ your extruder heater takes 2 minutes to hit the target on heating.
#include "Configuration_adv.h" #include "Configuration_adv.h"
#include "thermistortables.h"
#endif //__CONFIGURATION_H #endif //__CONFIGURATION_H
...@@ -41,10 +41,10 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) { ...@@ -41,10 +41,10 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) {
// wrong data being written to the variables. // wrong data being written to the variables.
// ALSO: always make sure the variables in the Store and retrieve sections are in the same order. // ALSO: always make sure the variables in the Store and retrieve sections are in the same order.
#define EEPROM_VERSION "V13" #define EEPROM_VERSION "V16"
#ifdef EEPROM_SETTINGS #ifdef EEPROM_SETTINGS
void Config_StoreSettings() { void Config_StoreSettings() {
float dummy = 0.0f; float dummy = 0.0f;
char ver[4] = "000"; char ver[4] = "000";
int i = EEPROM_OFFSET; int i = EEPROM_OFFSET;
...@@ -56,6 +56,7 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) { ...@@ -56,6 +56,7 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) {
EEPROM_WRITE_VAR(i, max_acceleration_units_per_sq_second); EEPROM_WRITE_VAR(i, max_acceleration_units_per_sq_second);
EEPROM_WRITE_VAR(i, acceleration); EEPROM_WRITE_VAR(i, acceleration);
EEPROM_WRITE_VAR(i, retract_acceleration); EEPROM_WRITE_VAR(i, retract_acceleration);
EEPROM_WRITE_VAR(i, travel_acceleration);
EEPROM_WRITE_VAR(i, minimumfeedrate); EEPROM_WRITE_VAR(i, minimumfeedrate);
EEPROM_WRITE_VAR(i, mintravelfeedrate); EEPROM_WRITE_VAR(i, mintravelfeedrate);
EEPROM_WRITE_VAR(i, minsegmenttime); EEPROM_WRITE_VAR(i, minsegmenttime);
...@@ -70,10 +71,10 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) { ...@@ -70,10 +71,10 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) {
#endif #endif
#ifdef DELTA #ifdef DELTA
EEPROM_WRITE_VAR(i, endstop_adj);
EEPROM_WRITE_VAR(i, delta_radius); EEPROM_WRITE_VAR(i, delta_radius);
EEPROM_WRITE_VAR(i, delta_diagonal_rod); EEPROM_WRITE_VAR(i, delta_diagonal_rod);
EEPROM_WRITE_VAR(i, max_pos); EEPROM_WRITE_VAR(i, max_pos);
EEPROM_WRITE_VAR(i, endstop_adj);
EEPROM_WRITE_VAR(i, tower_adj); EEPROM_WRITE_VAR(i, tower_adj);
EEPROM_WRITE_VAR(i, z_probe_offset); EEPROM_WRITE_VAR(i, z_probe_offset);
#endif #endif
...@@ -133,15 +134,14 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) { ...@@ -133,15 +134,14 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) {
char ver2[4] = EEPROM_VERSION; char ver2[4] = EEPROM_VERSION;
int j = EEPROM_OFFSET; int j = EEPROM_OFFSET;
EEPROM_WRITE_VAR(j, ver2); // validate data EEPROM_WRITE_VAR(j, ver2); // validate data
// Report storage size // Report storage size
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOPAIR("Settings Stored (", (unsigned long)i); SERIAL_ECHOPAIR("Settings Stored (", (unsigned long)i);
SERIAL_ECHOLNPGM(" bytes)"); SERIAL_ECHOLNPGM(" bytes)");
} }
void Config_RetrieveSettings() void Config_RetrieveSettings()
{ {
int i=EEPROM_OFFSET; int i=EEPROM_OFFSET;
char stored_ver[4]; char stored_ver[4];
char ver[4]=EEPROM_VERSION; char ver[4]=EEPROM_VERSION;
...@@ -162,6 +162,7 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) { ...@@ -162,6 +162,7 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) {
EEPROM_READ_VAR(i,acceleration); EEPROM_READ_VAR(i,acceleration);
EEPROM_READ_VAR(i,retract_acceleration); EEPROM_READ_VAR(i,retract_acceleration);
EEPROM_READ_VAR(i, travel_acceleration);
EEPROM_READ_VAR(i,minimumfeedrate); EEPROM_READ_VAR(i,minimumfeedrate);
EEPROM_READ_VAR(i,mintravelfeedrate); EEPROM_READ_VAR(i,mintravelfeedrate);
EEPROM_READ_VAR(i,minsegmenttime); EEPROM_READ_VAR(i,minsegmenttime);
...@@ -176,10 +177,10 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) { ...@@ -176,10 +177,10 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) {
#endif #endif
#ifdef DELTA #ifdef DELTA
EEPROM_READ_VAR(i,endstop_adj);
EEPROM_READ_VAR(i,delta_radius); EEPROM_READ_VAR(i,delta_radius);
EEPROM_READ_VAR(i,delta_diagonal_rod); EEPROM_READ_VAR(i,delta_diagonal_rod);
EEPROM_READ_VAR(i,max_pos); EEPROM_READ_VAR(i,max_pos);
EEPROM_READ_VAR(i,endstop_adj);
EEPROM_READ_VAR(i,tower_adj); EEPROM_READ_VAR(i,tower_adj);
EEPROM_READ_VAR(i,z_probe_offset); EEPROM_READ_VAR(i,z_probe_offset);
// Update delta constants for updated delta_radius & tower_adj values // Update delta constants for updated delta_radius & tower_adj values
...@@ -259,7 +260,7 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) { ...@@ -259,7 +260,7 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size) {
#ifdef EEPROM_CHITCHAT #ifdef EEPROM_CHITCHAT
Config_PrintSettings(); Config_PrintSettings();
#endif //EEPROM_CHITCHAT #endif //EEPROM_CHITCHAT
} }
#endif //EEPROM_SETTINGS #endif //EEPROM_SETTINGS
void Config_ResetDefault() void Config_ResetDefault()
...@@ -267,55 +268,55 @@ void Config_ResetDefault() ...@@ -267,55 +268,55 @@ void Config_ResetDefault()
//Setting default baudrate for serial //Setting default baudrate for serial
baudrate=BAUDRATE; baudrate=BAUDRATE;
const static float tmp1[] = DEFAULT_AXIS_STEPS_PER_UNIT; float tmp1[] = DEFAULT_AXIS_STEPS_PER_UNIT;
const static float tmp2[] = DEFAULT_MAX_FEEDRATE; float tmp2[] = DEFAULT_MAX_FEEDRATE;
const static float tmp3[] = DEFAULT_RETRACTION_MAX_FEEDRATE; float tmp3[] = DEFAULT_RETRACTION_MAX_FEEDRATE;
const static long tmp4[] = DEFAULT_MAX_ACCELERATION; long tmp4[] = DEFAULT_MAX_ACCELERATION;
#ifdef PIDTEMP #ifdef PIDTEMP
const static float tmp5[] = DEFAULT_Kp; float tmp5[] = DEFAULT_Kp;
const static float tmp6[] = DEFAULT_Ki; float tmp6[] = DEFAULT_Ki;
const static float tmp7[] = DEFAULT_Kd; float tmp7[] = DEFAULT_Kd;
#endif // PIDTEMP #endif // PIDTEMP
#if defined(EXTRUDER_OFFSET_X) && defined(EXTRUDER_OFFSET_Y) #if defined(EXTRUDER_OFFSET_X) && defined(EXTRUDER_OFFSET_Y)
const static float tmp8[] = EXTRUDER_OFFSET_X; float tmp8[] = EXTRUDER_OFFSET_X;
const static float tmp9[] = EXTRUDER_OFFSET_Y; float tmp9[] = EXTRUDER_OFFSET_Y;
#else #else
const static float tmp8[] = {0,0,0,0}; float tmp8[] = {0,0,0,0};
const static float tmp9[] = {0,0,0,0}; float tmp9[] = {0,0,0,0};
#endif #endif
for (short i=0;i<3+EXTRUDERS;i++) for (int i = 0; i < 3 + EXTRUDERS; i++) {
{
axis_steps_per_unit[i] = tmp1[i]; axis_steps_per_unit[i] = tmp1[i];
max_feedrate[i] = tmp2[i]; max_feedrate[i] = tmp2[i];
max_acceleration_units_per_sq_second[i] = tmp4[i]; max_acceleration_units_per_sq_second[i] = tmp4[i];
} }
for (short i=0;i<EXTRUDERS;i++) for (int i = 0; i < EXTRUDERS; i++) {
{
max_retraction_feedrate[i] = tmp3[i]; max_retraction_feedrate[i] = tmp3[i];
#if EXTRUDERS > 1 && !defined SINGLENOZZLE #if EXTRUDERS > 1 && !defined SINGLENOZZLE
hotend_offset[X_AXIS][i] = tmp8[i]; hotend_offset[X_AXIS][i] = tmp8[i];
hotend_offset[Y_AXIS][i] = tmp9[i]; hotend_offset[Y_AXIS][i] = tmp9[i];
#endif #endif
#ifdef SCARA #ifdef SCARA
if (i < sizeof(axis_scaling) / sizeof(*axis_scaling))
axis_scaling[i] = 1; axis_scaling[i] = 1;
#endif //SCARA #endif
} }
// steps per sq second need to be updated to agree with the units per sq second // steps per sq second need to be updated to agree with the units per sq second
reset_acceleration_rates(); reset_acceleration_rates();
acceleration=DEFAULT_ACCELERATION; acceleration = DEFAULT_ACCELERATION;
retract_acceleration=DEFAULT_RETRACT_ACCELERATION; retract_acceleration = DEFAULT_RETRACT_ACCELERATION;
minimumfeedrate=DEFAULT_MINIMUMFEEDRATE; travel_acceleration = DEFAULT_TRAVEL_ACCELERATION;
minsegmenttime=DEFAULT_MINSEGMENTTIME; minimumfeedrate = DEFAULT_MINIMUMFEEDRATE;
mintravelfeedrate=DEFAULT_MINTRAVELFEEDRATE; minsegmenttime = DEFAULT_MINSEGMENTTIME;
max_xy_jerk=DEFAULT_XYJERK; mintravelfeedrate = DEFAULT_MINTRAVELFEEDRATE;
max_z_jerk=DEFAULT_ZJERK; max_xy_jerk = DEFAULT_XYJERK;
max_e_jerk=DEFAULT_EJERK; max_z_jerk = DEFAULT_ZJERK;
add_homing[0] = add_homing[1] = add_homing[2] = 0; max_e_jerk = DEFAULT_EJERK;
add_homing[X_AXIS] = add_homing[Y_AXIS] = add_homing[Z_AXIS] = 0;
#ifdef ENABLE_AUTO_BED_LEVELING #ifdef ENABLE_AUTO_BED_LEVELING
zprobe_zoffset = -Z_PROBE_OFFSET_FROM_EXTRUDER; zprobe_zoffset = -Z_PROBE_OFFSET_FROM_EXTRUDER;
...@@ -324,9 +325,9 @@ void Config_ResetDefault() ...@@ -324,9 +325,9 @@ void Config_ResetDefault()
#endif //ENABLE_AUTO_BED_LEVELING #endif //ENABLE_AUTO_BED_LEVELING
#ifdef DELTA #ifdef DELTA
endstop_adj[X_AXIS] = endstop_adj[Y_AXIS] = endstop_adj[Z_AXIS] = 0;
delta_radius = DEFAULT_DELTA_RADIUS; delta_radius = DEFAULT_DELTA_RADIUS;
delta_diagonal_rod = DEFAULT_DELTA_DIAGONAL_ROD; delta_diagonal_rod = DEFAULT_DELTA_DIAGONAL_ROD;
endstop_adj[0] = endstop_adj[1] = endstop_adj[2] = 0;
tower_adj[0] = tower_adj[1] = tower_adj[2] = tower_adj[3] = tower_adj[4] = tower_adj[5] = 0; tower_adj[0] = tower_adj[1] = tower_adj[2] = tower_adj[3] = tower_adj[4] = tower_adj[5] = 0;
max_pos[2] = MANUAL_Z_HOME_POS; max_pos[2] = MANUAL_Z_HOME_POS;
set_default_z_probe_offset(); set_default_z_probe_offset();
...@@ -351,7 +352,7 @@ void Config_ResetDefault() ...@@ -351,7 +352,7 @@ void Config_ResetDefault()
#ifdef PIDTEMP #ifdef PIDTEMP
#ifndef SINGLENOZZLE #ifndef SINGLENOZZLE
for (int e=0;e<EXTRUDERS;e++) for (int e = 0; e < EXTRUDERS; e++)
#else #else
int e = 0; // only need to write once int e = 0; // only need to write once
#endif //SINGLENOZZLE #endif //SINGLENOZZLE
...@@ -397,8 +398,8 @@ void Config_ResetDefault() ...@@ -397,8 +398,8 @@ void Config_ResetDefault()
} }
#ifndef DISABLE_M503 #ifndef DISABLE_M503
void Config_PrintSettings() void Config_PrintSettings()
{ // Always have this function, even with EEPROM_SETTINGS disabled, the current values will be shown { // Always have this function, even with EEPROM_SETTINGS disabled, the current values will be shown
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOPAIR("Baudrate: ", baudrate); SERIAL_ECHOPAIR("Baudrate: ", baudrate);
SERIAL_EOL; SERIAL_EOL;
...@@ -478,10 +479,11 @@ void Config_ResetDefault() ...@@ -478,10 +479,11 @@ void Config_ResetDefault()
#endif //EXTRUDERS > 1 #endif //EXTRUDERS > 1
SERIAL_EOL; SERIAL_EOL;
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Acceleration: S=acceleration, T=retract acceleration"); SERIAL_ECHOLNPGM("Accelerations: P=printing, R=retract and T=travel");
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M204 S",acceleration ); SERIAL_ECHOPAIR(" M204 P",acceleration );
SERIAL_ECHOPAIR(" T" ,retract_acceleration); SERIAL_ECHOPAIR(" R", retract_acceleration);
SERIAL_ECHOPAIR(" T", travel_acceleration);
SERIAL_EOL; SERIAL_EOL;
SERIAL_ECHO_START; SERIAL_ECHO_START;
...@@ -631,5 +633,5 @@ void Config_ResetDefault() ...@@ -631,5 +633,5 @@ void Config_ResetDefault()
SERIAL_ECHOLNPGM("Filament settings: Disabled"); SERIAL_ECHOLNPGM("Filament settings: Disabled");
} }
#endif //FWRETRACT #endif //FWRETRACT
} }
#endif //!DISABLE_M503 #endif //!DISABLE_M503
...@@ -92,7 +92,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the lo ...@@ -92,7 +92,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the lo
#define FRONT_PROBE_BED_POSITION 20 #define FRONT_PROBE_BED_POSITION 20
#define BACK_PROBE_BED_POSITION 180 #define BACK_PROBE_BED_POSITION 180
#define XY_TRAVEL_SPEED 8000 // X and Y axis travel speed between probes, in mm/min #define XY_TRAVEL_SPEED 10000 // X and Y axis travel speed between probes, in mm/min
//If you have enabled the Auto Bed Levelling and are using the same Z Probe for Z Homing, //If you have enabled the Auto Bed Levelling and are using the same Z Probe for Z Homing,
//it is highly recommended you let this Z_SAFE_HOMING enabled!!! //it is highly recommended you let this Z_SAFE_HOMING enabled!!!
...@@ -123,6 +123,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the lo ...@@ -123,6 +123,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the lo
#define AUTO_BED_LEVELING_GRID #define AUTO_BED_LEVELING_GRID
#ifdef AUTO_BED_LEVELING_GRID #ifdef AUTO_BED_LEVELING_GRID
#define MIN_PROBE_EDGE 10 // The probe square sides can be no smaller than this
#define AUTO_BED_LEVELING_GRID_POINTS 2 #define AUTO_BED_LEVELING_GRID_POINTS 2
#else // not AUTO_BED_LEVELING_GRID #else // not AUTO_BED_LEVELING_GRID
// with no grid, just probe 3 arbitrary points. A simple cross-product // with no grid, just probe 3 arbitrary points. A simple cross-product
...@@ -136,7 +137,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the lo ...@@ -136,7 +137,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the lo
#endif // AUTO_BED_LEVELING_GRID #endif // AUTO_BED_LEVELING_GRID
// Offsets to the probe relative to the extruder tip (Hotend - Probe) // Offsets to the probe relative to the extruder tip (Hotend - Probe)
// X and Y offsets must be integers // X and Y offsets MUST be INTEGERS
#define X_PROBE_OFFSET_FROM_EXTRUDER 0 // -left +right #define X_PROBE_OFFSET_FROM_EXTRUDER 0 // -left +right
#define Y_PROBE_OFFSET_FROM_EXTRUDER 0 // -front +behind #define Y_PROBE_OFFSET_FROM_EXTRUDER 0 // -front +behind
#define Z_PROBE_OFFSET_FROM_EXTRUDER -1 // -below (always!) #define Z_PROBE_OFFSET_FROM_EXTRUDER -1 // -below (always!)
...@@ -180,6 +181,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the lo ...@@ -180,6 +181,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the lo
#define DEFAULT_ACCELERATION 2500 // X, Y, Z and E max acceleration in mm/s^2 for printing moves #define DEFAULT_ACCELERATION 2500 // X, Y, Z and E max acceleration in mm/s^2 for printing moves
#define DEFAULT_RETRACT_ACCELERATION 10000 // E max acceleration in mm/s^2 for retracts #define DEFAULT_RETRACT_ACCELERATION 10000 // E max acceleration in mm/s^2 for retracts
#define DEFAULT_TRAVEL_ACCELERATION 3000 // X, Y, Z acceleration in mm/s^2 for travel (non printing) moves
// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing). // Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder). // The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
......
...@@ -92,7 +92,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the lo ...@@ -92,7 +92,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the lo
#define FRONT_PROBE_BED_POSITION 20 #define FRONT_PROBE_BED_POSITION 20
#define BACK_PROBE_BED_POSITION 180 #define BACK_PROBE_BED_POSITION 180
#define XY_TRAVEL_SPEED 8000 // X and Y axis travel speed between probes, in mm/min #define XY_TRAVEL_SPEED 10000 // X and Y axis travel speed between probes, in mm/min
//If you have enabled the Auto Bed Levelling and are using the same Z Probe for Z Homing, //If you have enabled the Auto Bed Levelling and are using the same Z Probe for Z Homing,
//it is highly recommended you let this Z_SAFE_HOMING enabled!!! //it is highly recommended you let this Z_SAFE_HOMING enabled!!!
...@@ -123,6 +123,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the lo ...@@ -123,6 +123,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the lo
#define AUTO_BED_LEVELING_GRID #define AUTO_BED_LEVELING_GRID
#ifdef AUTO_BED_LEVELING_GRID #ifdef AUTO_BED_LEVELING_GRID
#define MIN_PROBE_EDGE 10 // The probe square sides can be no smaller than this
#define AUTO_BED_LEVELING_GRID_POINTS 2 #define AUTO_BED_LEVELING_GRID_POINTS 2
#else // not AUTO_BED_LEVELING_GRID #else // not AUTO_BED_LEVELING_GRID
// with no grid, just probe 3 arbitrary points. A simple cross-product // with no grid, just probe 3 arbitrary points. A simple cross-product
...@@ -180,6 +181,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the lo ...@@ -180,6 +181,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the lo
#define DEFAULT_ACCELERATION 2500 // X, Y, Z and E max acceleration in mm/s^2 for printing moves #define DEFAULT_ACCELERATION 2500 // X, Y, Z and E max acceleration in mm/s^2 for printing moves
#define DEFAULT_RETRACT_ACCELERATION 10000 // E max acceleration in mm/s^2 for retracts #define DEFAULT_RETRACT_ACCELERATION 10000 // E max acceleration in mm/s^2 for retracts
#define DEFAULT_TRAVEL_ACCELERATION 3000 // X, Y, Z acceleration in mm/s^2 for travel (non printing) moves
// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing). // Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder). // The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
......
...@@ -132,6 +132,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o ...@@ -132,6 +132,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o
#define DEFAULT_ACCELERATION 1000 // X, Y, Z and E max acceleration in mm/s^2 for printing moves #define DEFAULT_ACCELERATION 1000 // X, Y, Z and E max acceleration in mm/s^2 for printing moves
#define DEFAULT_RETRACT_ACCELERATION 2500 // X, Y, Z and E max acceleration in mm/s^2 for retracts #define DEFAULT_RETRACT_ACCELERATION 2500 // X, Y, Z and E max acceleration in mm/s^2 for retracts
#define DEFAULT_TRAVEL_ACCELERATION 3000 // X, Y, Z acceleration in mm/s^2 for travel (non printing) moves
// The speed change that does not require acceleration (i.e. the software might assume it can be done instantaneously) // The speed change that does not require acceleration (i.e. the software might assume it can be done instantaneously)
#define DEFAULT_XYJERK 20 // (mm/sec) #define DEFAULT_XYJERK 20 // (mm/sec)
......
...@@ -147,6 +147,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the lo ...@@ -147,6 +147,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the lo
#define AUTO_BED_LEVELING_GRID #define AUTO_BED_LEVELING_GRID
#ifdef AUTO_BED_LEVELING_GRID #ifdef AUTO_BED_LEVELING_GRID
#define MIN_PROBE_EDGE 10 // The probe square sides can be no smaller than this
#define AUTO_BED_LEVELING_GRID_POINTS 2 #define AUTO_BED_LEVELING_GRID_POINTS 2
#else // not AUTO_BED_LEVELING_GRID #else // not AUTO_BED_LEVELING_GRID
// with no grid, just probe 3 arbitrary points. A simple cross-product // with no grid, just probe 3 arbitrary points. A simple cross-product
...@@ -189,8 +190,8 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the lo ...@@ -189,8 +190,8 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the lo
//Manual homing switch locations: //Manual homing switch locations:
// For SCARA: Offset between HomingPosition and Bed X=0 / Y=0 // For SCARA: Offset between HomingPosition and Bed X=0 / Y=0
#define MANUAL_X_HOME_POS -22. #define MANUAL_X_HOME_POS -22
#define MANUAL_Y_HOME_POS -52. #define MANUAL_Y_HOME_POS -52
#define MANUAL_Z_HOME_POS 0.1 // Distance between nozzle and print surface after homing. #define MANUAL_Z_HOME_POS 0.1 // Distance between nozzle and print surface after homing.
// MOVEMENT SETTINGS // MOVEMENT SETTINGS
...@@ -205,6 +206,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the lo ...@@ -205,6 +206,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the lo
#define DEFAULT_ACCELERATION 400 // X, Y, Z and E max acceleration in mm/s^2 for printing moves #define DEFAULT_ACCELERATION 400 // X, Y, Z and E max acceleration in mm/s^2 for printing moves
#define DEFAULT_RETRACT_ACCELERATION 2000 // X, Y, Z and E max acceleration in mm/s^2 for retracts #define DEFAULT_RETRACT_ACCELERATION 2000 // X, Y, Z and E max acceleration in mm/s^2 for retracts
#define DEFAULT_TRAVEL_ACCELERATION 400 // X, Y, Z acceleration in mm/s^2 for travel (non printing) moves
// Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing). // Offset of the extruders (uncomment if using more than one and relying on firmware to position when changing).
// The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder). // The offset has to be X=0, Y=0 for the extruder 0 hotend (default extruder).
......
...@@ -218,6 +218,7 @@ ...@@ -218,6 +218,7 @@
#else #else
#define Z_HOME_RETRACT_MM 2 #define Z_HOME_RETRACT_MM 2
#endif #endif
#define HOMING_BUMP_DIVISOR {10, 10, 2} // Re-Bump Speed Divisor (Divides the Homing Feedrate)
//#define QUICK_HOME //if this is defined, if both x and y are to be homed, a diagonal move will be performed initially. //#define QUICK_HOME //if this is defined, if both x and y are to be homed, a diagonal move will be performed initially.
#define AXIS_RELATIVE_MODES {false, false, false, false} #define AXIS_RELATIVE_MODES {false, false, false, false}
...@@ -468,6 +469,141 @@ const unsigned int dropsegments=5; //everything with less than this number of st ...@@ -468,6 +469,141 @@ const unsigned int dropsegments=5; //everything with less than this number of st
#endif #endif
#endif #endif
/******************************************************************************\
* enable this section if you have TMC26X motor drivers.
* you need to import the TMC26XStepper library into the arduino IDE for this
******************************************************************************/
//#define HAVE_TMCDRIVER
#ifdef HAVE_TMCDRIVER
// #define X_IS_TMC
#define X_MAX_CURRENT 1000 //in mA
#define X_SENSE_RESISTOR 91 //in mOhms
#define X_MICROSTEPS 16 //number of microsteps
// #define X2_IS_TMC
#define X2_MAX_CURRENT 1000 //in mA
#define X2_SENSE_RESISTOR 91 //in mOhms
#define X2_MICROSTEPS 16 //number of microsteps
// #define Y_IS_TMC
#define Y_MAX_CURRENT 1000 //in mA
#define Y_SENSE_RESISTOR 91 //in mOhms
#define Y_MICROSTEPS 16 //number of microsteps
// #define Y2_IS_TMC
#define Y2_MAX_CURRENT 1000 //in mA
#define Y2_SENSE_RESISTOR 91 //in mOhms
#define Y2_MICROSTEPS 16 //number of microsteps
// #define Z_IS_TMC
#define Z_MAX_CURRENT 1000 //in mA
#define Z_SENSE_RESISTOR 91 //in mOhms
#define Z_MICROSTEPS 16 //number of microsteps
// #define Z2_IS_TMC
#define Z2_MAX_CURRENT 1000 //in mA
#define Z2_SENSE_RESISTOR 91 //in mOhms
#define Z2_MICROSTEPS 16 //number of microsteps
// #define E0_IS_TMC
#define E0_MAX_CURRENT 1000 //in mA
#define E0_SENSE_RESISTOR 91 //in mOhms
#define E0_MICROSTEPS 16 //number of microsteps
// #define E1_IS_TMC
#define E1_MAX_CURRENT 1000 //in mA
#define E1_SENSE_RESISTOR 91 //in mOhms
#define E1_MICROSTEPS 16 //number of microsteps
// #define E2_IS_TMC
#define E2_MAX_CURRENT 1000 //in mA
#define E2_SENSE_RESISTOR 91 //in mOhms
#define E2_MICROSTEPS 16 //number of microsteps
// #define E3_IS_TMC
#define E3_MAX_CURRENT 1000 //in mA
#define E3_SENSE_RESISTOR 91 //in mOhms
#define E3_MICROSTEPS 16 //number of microsteps
#endif
/******************************************************************************\
* enable this section if you have L6470 motor drivers.
* you need to import the L6470 library into the arduino IDE for this
******************************************************************************/
//#define HAVE_L6470DRIVER
#ifdef HAVE_L6470DRIVER
// #define X_IS_L6470
#define X_MICROSTEPS 16 //number of microsteps
#define X_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high
#define X_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off
#define X_STALLCURRENT 1500 //current in mA where the driver will detect a stall
// #define X2_IS_L6470
#define X2_MICROSTEPS 16 //number of microsteps
#define X2_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high
#define X2_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off
#define X2_STALLCURRENT 1500 //current in mA where the driver will detect a stall
// #define Y_IS_L6470
#define Y_MICROSTEPS 16 //number of microsteps
#define Y_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high
#define Y_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off
#define Y_STALLCURRENT 1500 //current in mA where the driver will detect a stall
// #define Y2_IS_L6470
#define Y2_MICROSTEPS 16 //number of microsteps
#define Y2_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high
#define Y2_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off
#define Y2_STALLCURRENT 1500 //current in mA where the driver will detect a stall
// #define Z_IS_L6470
#define Z_MICROSTEPS 16 //number of microsteps
#define Z_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high
#define Z_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off
#define Z_STALLCURRENT 1500 //current in mA where the driver will detect a stall
// #define Z2_IS_L6470
#define Z2_MICROSTEPS 16 //number of microsteps
#define Z2_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high
#define Z2_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off
#define Z2_STALLCURRENT 1500 //current in mA where the driver will detect a stall
// #define E0_IS_L6470
#define E0_MICROSTEPS 16 //number of microsteps
#define E0_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high
#define E0_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off
#define E0_STALLCURRENT 1500 //current in mA where the driver will detect a stall
// #define E1_IS_L6470
#define E1_MICROSTEPS 16 //number of microsteps
#define E1_MICROSTEPS 16 //number of microsteps
#define E1_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high
#define E1_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off
#define E1_STALLCURRENT 1500 //current in mA where the driver will detect a stall
// #define E2_IS_L6470
#define E2_MICROSTEPS 16 //number of microsteps
#define E2_MICROSTEPS 16 //number of microsteps
#define E2_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high
#define E2_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off
#define E2_STALLCURRENT 1500 //current in mA where the driver will detect a stall
// #define E3_IS_L6470
#define E3_MICROSTEPS 16 //number of microsteps
#define E3_MICROSTEPS 16 //number of microsteps
#define E3_K_VAL 50 // 0 - 255, Higher values, are higher power. Be carefull not to go too high
#define E3_OVERCURRENT 2000 //maxc current in mA. If the current goes over this value, the driver will switch off
#define E3_STALLCURRENT 1500 //current in mA where the driver will detect a stall
#endif
//=========================================================================== //===========================================================================
//============================= Define Defines ============================ //============================= Define Defines ============================
//=========================================================================== //===========================================================================
......
...@@ -112,11 +112,11 @@ void manage_inactivity(bool ignore_stepper_queue=false); ...@@ -112,11 +112,11 @@ void manage_inactivity(bool ignore_stepper_queue=false);
#if defined(DUAL_X_CARRIAGE) && defined(X_ENABLE_PIN) && X_ENABLE_PIN > -1 \ #if defined(DUAL_X_CARRIAGE) && defined(X_ENABLE_PIN) && X_ENABLE_PIN > -1 \
&& defined(X2_ENABLE_PIN) && X2_ENABLE_PIN > -1 && defined(X2_ENABLE_PIN) && X2_ENABLE_PIN > -1
#define enable_x() do { WRITE(X_ENABLE_PIN, X_ENABLE_ON); WRITE(X2_ENABLE_PIN, X_ENABLE_ON); } while (0) #define enable_x() do { X_ENABLE_WRITE( X_ENABLE_ON); X2_ENABLE_WRITE( X_ENABLE_ON); } while (0)
#define disable_x() do { WRITE(X_ENABLE_PIN,!X_ENABLE_ON); WRITE(X2_ENABLE_PIN,!X_ENABLE_ON); axis_known_position[X_AXIS] = false; } while (0) #define disable_x() do { X_ENABLE_WRITE(!X_ENABLE_ON); X2_ENABLE_WRITE(!X_ENABLE_ON); axis_known_position[X_AXIS] = false; } while (0)
#elif defined(X_ENABLE_PIN) && X_ENABLE_PIN > -1 #elif defined(X_ENABLE_PIN) && X_ENABLE_PIN > -1
#define enable_x() WRITE(X_ENABLE_PIN, X_ENABLE_ON) #define enable_x() X_ENABLE_WRITE( X_ENABLE_ON)
#define disable_x() { WRITE(X_ENABLE_PIN,!X_ENABLE_ON); axis_known_position[X_AXIS] = false; } #define disable_x() { X_ENABLE_WRITE(!X_ENABLE_ON); axis_known_position[X_AXIS] = false; }
#else #else
#define enable_x() ; #define enable_x() ;
#define disable_x() ; #define disable_x() ;
...@@ -124,11 +124,11 @@ void manage_inactivity(bool ignore_stepper_queue=false); ...@@ -124,11 +124,11 @@ void manage_inactivity(bool ignore_stepper_queue=false);
#if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1 #if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1
#ifdef Y_DUAL_STEPPER_DRIVERS #ifdef Y_DUAL_STEPPER_DRIVERS
#define enable_y() { WRITE(Y_ENABLE_PIN, Y_ENABLE_ON); WRITE(Y2_ENABLE_PIN, Y_ENABLE_ON); } #define enable_y() { Y_ENABLE_WRITE( Y_ENABLE_ON); Y2_ENABLE_WRITE(Y_ENABLE_ON); }
#define disable_y() { WRITE(Y_ENABLE_PIN,!Y_ENABLE_ON); WRITE(Y2_ENABLE_PIN, !Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; } #define disable_y() { Y_ENABLE_WRITE(!Y_ENABLE_ON); Y2_ENABLE_WRITE(!Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; }
#else #else
#define enable_y() WRITE(Y_ENABLE_PIN, Y_ENABLE_ON) #define enable_y() Y_ENABLE_WRITE( Y_ENABLE_ON)
#define disable_y() { WRITE(Y_ENABLE_PIN,!Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; } #define disable_y() { Y_ENABLE_WRITE(!Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; }
#endif #endif
#else #else
#define enable_y() ; #define enable_y() ;
...@@ -137,11 +137,11 @@ void manage_inactivity(bool ignore_stepper_queue=false); ...@@ -137,11 +137,11 @@ void manage_inactivity(bool ignore_stepper_queue=false);
#if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN > -1 #if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN > -1
#ifdef Z_DUAL_STEPPER_DRIVERS #ifdef Z_DUAL_STEPPER_DRIVERS
#define enable_z() { WRITE(Z_ENABLE_PIN, Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN, Z_ENABLE_ON); } #define enable_z() { Z_ENABLE_WRITE( Z_ENABLE_ON); Z2_ENABLE_WRITE(Z_ENABLE_ON); }
#define disable_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; } #define disable_z() { Z_ENABLE_WRITE(!Z_ENABLE_ON); Z2_ENABLE_WRITE(!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }
#else #else
#define enable_z() WRITE(Z_ENABLE_PIN, Z_ENABLE_ON) #define enable_z() Z_ENABLE_WRITE( Z_ENABLE_ON)
#define disable_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; } #define disable_z() { Z_ENABLE_WRITE(!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }
#endif #endif
#else #else
#define enable_z() ; #define enable_z() ;
...@@ -149,32 +149,32 @@ void manage_inactivity(bool ignore_stepper_queue=false); ...@@ -149,32 +149,32 @@ void manage_inactivity(bool ignore_stepper_queue=false);
#endif #endif
#if defined(E0_ENABLE_PIN) && (E0_ENABLE_PIN > -1) #if defined(E0_ENABLE_PIN) && (E0_ENABLE_PIN > -1)
#define enable_e0() WRITE(E0_ENABLE_PIN, E_ENABLE_ON) #define enable_e0() E0_ENABLE_WRITE(E_ENABLE_ON)
#define disable_e0() WRITE(E0_ENABLE_PIN,!E_ENABLE_ON) #define disable_e0() E0_ENABLE_WRITE(!E_ENABLE_ON)
#else #else
#define enable_e0() /* nothing */ #define enable_e0() /* nothing */
#define disable_e0() /* nothing */ #define disable_e0() /* nothing */
#endif #endif
#if (DRIVER_EXTRUDERS > 1) && defined(E1_ENABLE_PIN) && (E1_ENABLE_PIN > -1) #if (DRIVER_EXTRUDERS > 1) && defined(E1_ENABLE_PIN) && (E1_ENABLE_PIN > -1)
#define enable_e1() WRITE(E1_ENABLE_PIN, E_ENABLE_ON) #define enable_e1() E1_ENABLE_WRITE(E_ENABLE_ON)
#define disable_e1() WRITE(E1_ENABLE_PIN,!E_ENABLE_ON) #define disable_e1() E1_ENABLE_WRITE(!E_ENABLE_ON)
#else #else
#define enable_e1() /* nothing */ #define enable_e1() /* nothing */
#define disable_e1() /* nothing */ #define disable_e1() /* nothing */
#endif #endif
#if (DRIVER_EXTRUDERS > 2) && defined(E2_ENABLE_PIN) && (E2_ENABLE_PIN > -1) #if (DRIVER_EXTRUDERS > 2) && defined(E2_ENABLE_PIN) && (E2_ENABLE_PIN > -1)
#define enable_e2() WRITE(E2_ENABLE_PIN, E_ENABLE_ON) #define enable_e2() E2_ENABLE_WRITE(E_ENABLE_ON)
#define disable_e2() WRITE(E2_ENABLE_PIN,!E_ENABLE_ON) #define disable_e2() E2_ENABLE_WRITE(!E_ENABLE_ON)
#else #else
#define enable_e2() /* nothing */ #define enable_e2() /* nothing */
#define disable_e2() /* nothing */ #define disable_e2() /* nothing */
#endif #endif
#if (DRIVER_EXTRUDERS > 3) && defined(E3_ENABLE_PIN) && (E3_ENABLE_PIN > -1) #if (DRIVER_EXTRUDERS > 3) && defined(E3_ENABLE_PIN) && (E3_ENABLE_PIN > -1)
#define enable_e3() WRITE(E3_ENABLE_PIN, E_ENABLE_ON) #define enable_e3() E3_ENABLE_WRITE(E_ENABLE_ON)
#define disable_e3() WRITE(E3_ENABLE_PIN,!E_ENABLE_ON) #define disable_e3() E3_ENABLE_WRITE(!E_ENABLE_ON)
#else #else
#define enable_e3() /* nothing */ #define enable_e3() /* nothing */
#define disable_e3() /* nothing */ #define disable_e3() /* nothing */
......
/* -*- c++ -*- */
/* /*
Reprap firmware based on Marlin Reprap firmware based on Marlin
Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
Copyright (C) 2014 MagoKimbra
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
...@@ -199,8 +202,10 @@ M999 - Restart after being stopped by error ...@@ -199,8 +202,10 @@ M999 - Restart after being stopped by error
unsigned long baudrate; unsigned long baudrate;
float homing_feedrate[] = HOMING_FEEDRATE; float homing_feedrate[] = HOMING_FEEDRATE;
bool axis_known_position[3] = {false, false, false}; #ifdef ENABLE_AUTO_BED_LEVELING
float zprobe_zoffset; int xy_travel_speed = XY_TRAVEL_SPEED;
#endif
int homing_bump_divisor[] = HOMING_BUMP_DIVISOR;
bool axis_relative_modes[] = AXIS_RELATIVE_MODES; bool axis_relative_modes[] = AXIS_RELATIVE_MODES;
int feedmultiply = 100; //100->1 200->2 int feedmultiply = 100; //100->1 200->2
int saved_feedmultiply; int saved_feedmultiply;
...@@ -285,28 +290,43 @@ bool cancel_heatup = false; ...@@ -285,28 +290,43 @@ bool cancel_heatup = false;
float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS }; float min_pos[3] = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS };
float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS }; float max_pos[3] = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS };
bool axis_known_position[3] = { false, false, false };
float zprobe_zoffset;
float lastpos[4]; float lastpos[4];
// Extruder offset // Extruder offset
#if EXTRUDERS > 1 #ifndef SINGLENOZZLE
#ifndef SINGLENOZZLE #if EXTRUDERS > 1
#ifndef DUAL_X_CARRIAGE #ifndef DUAL_X_CARRIAGE
#define NUM_EXTRUDER_OFFSETS 2 // only in XY plane #define NUM_EXTRUDER_OFFSETS 2 // only in XY plane
#else #else
#define NUM_EXTRUDER_OFFSETS 3 // supports offsets in XYZ plane #define NUM_EXTRUDER_OFFSETS 3 // supports offsets in XYZ plane
#endif #endif
float hotend_offset[NUM_EXTRUDER_OFFSETS][EXTRUDERS]; float hotend_offset[NUM_EXTRUDER_OFFSETS][EXTRUDERS] = {
#endif // end SINGLENOZZLE #if defined(EXTRUDER_OFFSET_X)
#endif // end EXTRUDERS EXTRUDER_OFFSET_X
#else
0
#endif
,
#if defined(EXTRUDER_OFFSET_Y)
EXTRUDER_OFFSET_Y
#else
0
#endif
};
#endif //EXTRUDERS > 1
#endif //SINGLENOZZLE
uint8_t active_extruder = 0; uint8_t active_extruder = 0;
uint8_t active_driver = 0; uint8_t active_driver = 0;
uint8_t debugLevel = 0; uint8_t debugLevel = 0;
#ifdef SERVO_ENDSTOPS && (NUM_SERVOS > 0) #ifdef NUM_SERVOS > 0
int servo_endstops[] = SERVO_ENDSTOPS; int servo_endstops[] = SERVO_ENDSTOPS;
int servo_endstop_angles[] = SERVO_ENDSTOP_ANGLES; int servo_endstop_angles[] = SERVO_ENDSTOP_ANGLES;
#endif //SERVO_ENDSTOPS && (NUM_SERVOS > 0) #endif //NUM_SERVOS > 0
#ifdef BARICUDA #ifdef BARICUDA
int ValvePressure = 0; int ValvePressure = 0;
...@@ -764,9 +784,9 @@ void setup() ...@@ -764,9 +784,9 @@ void setup()
#endif // FIRMWARE_TEST #endif // FIRMWARE_TEST
} }
void loop() void loop() {
{ if(buflen < (BUFSIZE-1))
if (buflen < (BUFSIZE-1)) get_command(); get_command();
#ifdef SDSUPPORT #ifdef SDSUPPORT
card.checkautostart(false); card.checkautostart(false);
#endif #endif
...@@ -819,19 +839,22 @@ void get_command() ...@@ -819,19 +839,22 @@ void get_command()
serial_char = MYSERIAL.read(); serial_char = MYSERIAL.read();
if(serial_char == '\n' || if(serial_char == '\n' ||
serial_char == '\r' || serial_char == '\r' ||
(serial_char == ':' && comment_mode == false) || serial_count >= (MAX_CMD_SIZE - 1) )
serial_count >= (MAX_CMD_SIZE - 1)) { {
if(!serial_count) { //if empty line // end of line == end of comment
comment_mode = false; //for new command comment_mode = false;
if(!serial_count) {
// short cut for empty lines
return; return;
} }
cmdbuffer[bufindw][serial_count] = 0; //terminate string cmdbuffer[bufindw][serial_count] = 0; //terminate string
if(!comment_mode) {
comment_mode = false; //for new command
fromsd[bufindw] = false; fromsd[bufindw] = false;
if(strchr(cmdbuffer[bufindw], 'N') != NULL) { if(strchr(cmdbuffer[bufindw], 'N') != NULL)
{
strchr_pointer = strchr(cmdbuffer[bufindw], 'N'); strchr_pointer = strchr(cmdbuffer[bufindw], 'N');
gcode_N = (strtol(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL, 10)); gcode_N = (strtol(strchr_pointer + 1, NULL, 10));
if(gcode_N != gcode_LastN+1 && (strstr_P(cmdbuffer[bufindw], PSTR("M110")) == NULL) ) { if(gcode_N != gcode_LastN+1 && (strstr_P(cmdbuffer[bufindw], PSTR("M110")) == NULL) ) {
SERIAL_ERROR_START; SERIAL_ERROR_START;
SERIAL_ERRORPGM(MSG_ERR_LINE_NO); SERIAL_ERRORPGM(MSG_ERR_LINE_NO);
...@@ -842,13 +865,14 @@ void get_command() ...@@ -842,13 +865,14 @@ void get_command()
return; return;
} }
if(strchr(cmdbuffer[bufindw], '*') != NULL) { if(strchr(cmdbuffer[bufindw], '*') != NULL)
{
byte checksum = 0; byte checksum = 0;
byte count = 0; byte count = 0;
while(cmdbuffer[bufindw][count] != '*') checksum = checksum^cmdbuffer[bufindw][count++]; while(cmdbuffer[bufindw][count] != '*') checksum = checksum^cmdbuffer[bufindw][count++];
strchr_pointer = strchr(cmdbuffer[bufindw], '*'); strchr_pointer = strchr(cmdbuffer[bufindw], '*');
if ((int)(strtod(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL)) != checksum) { if(strtol(strchr_pointer + 1, NULL, 10) != checksum) {
SERIAL_ERROR_START; SERIAL_ERROR_START;
SERIAL_ERRORPGM(MSG_ERR_CHECKSUM_MISMATCH); SERIAL_ERRORPGM(MSG_ERR_CHECKSUM_MISMATCH);
SERIAL_ERRORLN(gcode_LastN); SERIAL_ERRORLN(gcode_LastN);
...@@ -858,7 +882,8 @@ void get_command() ...@@ -858,7 +882,8 @@ void get_command()
} }
//if no errors, continue parsing //if no errors, continue parsing
} }
else { else
{
SERIAL_ERROR_START; SERIAL_ERROR_START;
SERIAL_ERRORPGM(MSG_ERR_NO_CHECKSUM); SERIAL_ERRORPGM(MSG_ERR_NO_CHECKSUM);
SERIAL_ERRORLN(gcode_LastN); SERIAL_ERRORLN(gcode_LastN);
...@@ -870,8 +895,10 @@ void get_command() ...@@ -870,8 +895,10 @@ void get_command()
gcode_LastN = gcode_N; gcode_LastN = gcode_N;
//if no errors, continue parsing //if no errors, continue parsing
} }
else { // if we don't receive 'N' but still see '*' else // if we don't receive 'N' but still see '*'
if((strchr(cmdbuffer[bufindw], '*') != NULL)) { {
if((strchr(cmdbuffer[bufindw], '*') != NULL))
{
SERIAL_ERROR_START; SERIAL_ERROR_START;
SERIAL_ERRORPGM(MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM); SERIAL_ERRORPGM(MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM);
SERIAL_ERRORLN(gcode_LastN); SERIAL_ERRORLN(gcode_LastN);
...@@ -879,9 +906,9 @@ void get_command() ...@@ -879,9 +906,9 @@ void get_command()
return; return;
} }
} }
if((strchr(cmdbuffer[bufindw], 'G') != NULL)) { if((strchr(cmdbuffer[bufindw], 'G') != NULL)){
strchr_pointer = strchr(cmdbuffer[bufindw], 'G'); strchr_pointer = strchr(cmdbuffer[bufindw], 'G');
switch((int)((strtod(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL)))) { switch(strtol(strchr_pointer + 1, NULL, 10)){
case 0: case 0:
case 1: case 1:
case 2: case 2:
...@@ -894,23 +921,35 @@ void get_command() ...@@ -894,23 +921,35 @@ void get_command()
default: default:
break; break;
} }
} }
//If command was e-stop process now //If command was e-stop process now
if(strcmp(cmdbuffer[bufindw], "M112") == 0) if(strcmp(cmdbuffer[bufindw], "M112") == 0)
kill(); kill();
bufindw = (bufindw + 1)%BUFSIZE; bufindw = (bufindw + 1)%BUFSIZE;
buflen += 1; buflen += 1;
}
serial_count = 0; //clear buffer serial_count = 0; //clear buffer
} }
else { else if(serial_char == '\\') { //Handle escapes
if(MYSERIAL.available() > 0 && buflen < BUFSIZE) {
// if we have one more character, copy it over
serial_char = MYSERIAL.read();
cmdbuffer[bufindw][serial_count++] = serial_char;
}
//otherwise do nothing
}
else { // its not a newline, carriage return or escape char
if(serial_char == ';') comment_mode = true; if(serial_char == ';') comment_mode = true;
if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char; if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char;
} }
} }
#ifdef SDSUPPORT #ifdef SDSUPPORT
if(!card.sdprinting || serial_count!=0) { if(!card.sdprinting || serial_count!=0){
return; return;
} }
...@@ -921,15 +960,16 @@ void get_command() ...@@ -921,15 +960,16 @@ void get_command()
static bool stop_buffering=false; static bool stop_buffering=false;
if(buflen==0) stop_buffering=false; if(buflen==0) stop_buffering=false;
while (!card.eof() && buflen < BUFSIZE && !stop_buffering) { while( !card.eof() && buflen < BUFSIZE && !stop_buffering) {
int16_t n=card.get(); int16_t n=card.get();
serial_char = (char)n; serial_char = (char)n;
if (serial_char == '\n' || if(serial_char == '\n' ||
serial_char == '\r' || serial_char == '\r' ||
(serial_char == '#' && comment_mode == false) || (serial_char == '#' && comment_mode == false) ||
(serial_char == ':' && comment_mode == false) || (serial_char == ':' && comment_mode == false) ||
serial_count >= (MAX_CMD_SIZE - 1)||n==-1) { serial_count >= (MAX_CMD_SIZE - 1)||n==-1)
if (card.eof()) { {
if(card.eof()){
SERIAL_PROTOCOLLNPGM(MSG_FILE_PRINTED); SERIAL_PROTOCOLLNPGM(MSG_FILE_PRINTED);
stoptime=millis(); stoptime=millis();
char time[30]; char time[30];
...@@ -943,38 +983,45 @@ void get_command() ...@@ -943,38 +983,45 @@ void get_command()
lcd_setstatus(time); lcd_setstatus(time);
card.printingHasFinished(); card.printingHasFinished();
card.checkautostart(true); card.checkautostart(true);
} }
if(serial_char=='#') if(serial_char=='#')
stop_buffering=true; stop_buffering=true;
if(!serial_count) {
if(!serial_count)
{
comment_mode = false; //for new command comment_mode = false; //for new command
return; //if empty line return; //if empty line
} }
cmdbuffer[bufindw][serial_count] = 0; //terminate string cmdbuffer[bufindw][serial_count] = 0; //terminate string
// if(!comment_mode){ // if(!comment_mode){
fromsd[bufindw] = true; fromsd[bufindw] = true;
buflen += 1; buflen += 1;
bufindw = (bufindw + 1)%BUFSIZE; bufindw = (bufindw + 1)%BUFSIZE;
// } // }
comment_mode = false; //for new command comment_mode = false; //for new command
serial_count = 0; //clear buffer serial_count = 0; //clear buffer
} }
else { else
{
if(serial_char == ';') comment_mode = true; if(serial_char == ';') comment_mode = true;
if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char; if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char;
} }
} }
#endif //SDSUPPORT #endif //SDSUPPORT
} }
float code_value() float code_value()
{ {
return (strtod(&cmdbuffer[bufindr][strchr_pointer - cmdbuffer[bufindr] + 1], NULL)); return (strtod(strchr_pointer + 1, NULL));
} }
long code_value_long() long code_value_long()
{ {
return (strtol(&cmdbuffer[bufindr][strchr_pointer - cmdbuffer[bufindr] + 1], NULL, 10)); return (strtol(strchr_pointer + 1, NULL, 10));
} }
bool code_seen(char code) bool code_seen(char code)
...@@ -1016,39 +1063,33 @@ XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR); ...@@ -1016,39 +1063,33 @@ XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR);
#error "Please use canonical x-carriage assignment" // the x-carriages are defined by their homing directions #error "Please use canonical x-carriage assignment" // the x-carriages are defined by their homing directions
#endif #endif
#define DXC_FULL_CONTROL_MODE 0 #define DXC_FULL_CONTROL_MODE 0
#define DXC_AUTO_PARK_MODE 1 #define DXC_AUTO_PARK_MODE 1
#define DXC_DUPLICATION_MODE 2 #define DXC_DUPLICATION_MODE 2
static int dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE; static int dual_x_carriage_mode = DEFAULT_DUAL_X_CARRIAGE_MODE;
static float x_home_pos(int extruder) static float x_home_pos(int extruder) {
{
if (extruder == 0) if (extruder == 0)
{
return base_home_pos(X_AXIS) + add_homing[X_AXIS]; return base_home_pos(X_AXIS) + add_homing[X_AXIS];
}
else else
{
// In dual carriage mode the extruder offset provides an override of the // In dual carriage mode the extruder offset provides an override of the
// second X-carriage offset when homed - otherwise X2_HOME_POS is used. // second X-carriage offset when homed - otherwise X2_HOME_POS is used.
// This allow soft recalibration of the second extruder offset position without firmware reflash // This allow soft recalibration of the second extruder offset position without firmware reflash
// (through the M218 command). // (through the M218 command).
return (hotend_offset[X_AXIS][1] > 0) ? hotend_offset[X_AXIS][1] : X2_HOME_POS; return (extruder_offset[X_AXIS][1] > 0) ? extruder_offset[X_AXIS][1] : X2_HOME_POS;
} }
}
static int x_home_dir(int extruder) static int x_home_dir(int extruder) {
{
return (extruder == 0) ? X_HOME_DIR : X2_HOME_DIR; return (extruder == 0) ? X_HOME_DIR : X2_HOME_DIR;
} }
static float inactive_extruder_x_pos = X2_MAX_POS; // used in mode 0 & 1 static float inactive_extruder_x_pos = X2_MAX_POS; // used in mode 0 & 1
static bool active_extruder_parked = false; // used in mode 1 & 2 static bool active_extruder_parked = false; // used in mode 1 & 2
static float raised_parked_position[NUM_AXIS]; // used in mode 1 static float raised_parked_position[NUM_AXIS]; // used in mode 1
static unsigned long delayed_move_time = 0; // used in mode 1 static unsigned long delayed_move_time = 0; // used in mode 1
static float duplicate_extruder_x_offset = DEFAULT_DUPLICATION_X_OFFSET; // used in mode 2 static float duplicate_extruder_x_offset = DEFAULT_DUPLICATION_X_OFFSET; // used in mode 2
static float duplicate_extruder_temp_offset = 0; // used in mode 2 static float duplicate_extruder_temp_offset = 0; // used in mode 2
bool extruder_duplication_enabled = false; // used in mode 2 bool extruder_duplication_enabled = false; // used in mode 2
#endif //DUAL_X_CARRIAGE #endif //DUAL_X_CARRIAGE
#if defined(CARTESIAN) || defined(COREXY) || defined(SCARA) #if defined(CARTESIAN) || defined(COREXY) || defined(SCARA)
...@@ -1194,7 +1235,14 @@ XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR); ...@@ -1194,7 +1235,14 @@ XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR);
st_synchronize(); st_synchronize();
// move back down slowly to find bed // move back down slowly to find bed
feedrate = homing_feedrate[Z_AXIS]/4; if (homing_bump_divisor[Z_AXIS] >= 1) {
feedrate = homing_feedrate[Z_AXIS]/homing_bump_divisor[Z_AXIS];
}
else {
feedrate = homing_feedrate[Z_AXIS]/10;
SERIAL_ECHOLN("Warning: The Homing Bump Feedrate Divisor cannot be less then 1");
}
zPosition -= home_retract_mm(Z_AXIS) * 2; zPosition -= home_retract_mm(Z_AXIS) * 2;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder, active_driver); plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], feedrate/60, active_extruder, active_driver);
st_synchronize(); st_synchronize();
...@@ -1212,7 +1260,7 @@ XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR); ...@@ -1212,7 +1260,7 @@ XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR);
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate/60, active_extruder, active_driver); plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate/60, active_extruder, active_driver);
st_synchronize(); st_synchronize();
feedrate = XY_TRAVEL_SPEED; feedrate = xy_travel_speed;
current_position[X_AXIS] = x; current_position[X_AXIS] = x;
current_position[Y_AXIS] = y; current_position[Y_AXIS] = y;
...@@ -1275,21 +1323,26 @@ XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR); ...@@ -1275,21 +1323,26 @@ XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR);
#endif //NUM_SERVOS > 0 #endif //NUM_SERVOS > 0
} }
/// Probe bed height at position (x,y), returns the measured z value enum ProbeAction { ProbeStay, ProbeEngage, ProbeRetract, ProbeEngageRetract };
static float probe_pt(float x, float y, float z_before, int retract_action=0) {
// Probe bed height at position (x,y), returns the measured z value
static float probe_pt(float x, float y, float z_before, ProbeAction retract_action=ProbeEngageRetract, int verbose_level=1) {
// move to right place // move to right place
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z_before); do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z_before);
do_blocking_move_to(x - X_PROBE_OFFSET_FROM_EXTRUDER, y - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]); do_blocking_move_to(x - X_PROBE_OFFSET_FROM_EXTRUDER, y - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]);
#ifndef Z_PROBE_SLED #ifndef Z_PROBE_SLED
if ((retract_action==0) || (retract_action==1)) engage_z_probe(); // Engage Z Servo endstop if available if (retract_action & ProbeEngage) engage_z_probe();
#endif // Z_PROBE_SLED #endif // Z_PROBE_SLED
run_z_probe(); run_z_probe();
float measured_z = current_position[Z_AXIS]; float measured_z = current_position[Z_AXIS];
#ifndef Z_PROBE_SLED #ifndef Z_PROBE_SLED
if ((retract_action==0) || (retract_action==3)) retract_z_probe(); if (retract_action & ProbeRetract) retract_z_probe();
#endif // Z_PROBE_SLED #endif // Z_PROBE_SLED
if (verbose_level > 2) {
SERIAL_PROTOCOLPGM(MSG_BED); SERIAL_PROTOCOLPGM(MSG_BED);
SERIAL_PROTOCOLPGM(" X: "); SERIAL_PROTOCOLPGM(" X: ");
SERIAL_PROTOCOL(x + 0.0001); SERIAL_PROTOCOL(x + 0.0001);
...@@ -1298,6 +1351,7 @@ XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR); ...@@ -1298,6 +1351,7 @@ XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR);
SERIAL_PROTOCOLPGM(" Z: "); SERIAL_PROTOCOLPGM(" Z: ");
SERIAL_PROTOCOL(measured_z + 0.0001); SERIAL_PROTOCOL(measured_z + 0.0001);
SERIAL_EOL; SERIAL_EOL;
}
return measured_z; return measured_z;
} }
#endif //ENABLE_AUTO_BED_LEVELING #endif //ENABLE_AUTO_BED_LEVELING
...@@ -1344,7 +1398,15 @@ XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR); ...@@ -1344,7 +1398,15 @@ XYZ_CONSTS_FROM_CONFIG(signed char, home_dir, HOME_DIR);
st_synchronize(); st_synchronize();
destination[axis] = 2*home_retract_mm(axis) * axis_home_dir; destination[axis] = 2*home_retract_mm(axis) * axis_home_dir;
feedrate = homing_feedrate[axis]/2 ;
if (homing_bump_divisor[axis] >= 1) {
feedrate = homing_feedrate[axis]/homing_bump_divisor[axis];
}
else {
feedrate = homing_feedrate[axis]/10;
SERIAL_ECHOLN("Warning: The Homing Bump Feedrate Divisor cannot be less then 1");
}
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder, active_driver); plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder, active_driver);
st_synchronize(); st_synchronize();
axis_is_at_home(axis); axis_is_at_home(axis);
...@@ -2461,6 +2523,44 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) { ...@@ -2461,6 +2523,44 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) {
#ifdef ENABLE_AUTO_BED_LEVELING #ifdef ENABLE_AUTO_BED_LEVELING
// Define the possible boundaries for probing based on set limits
#define MIN_PROBE_X (max(X_MIN_POS, X_MIN_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
#define MAX_PROBE_X (min(X_MAX_POS, X_MAX_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
#define MIN_PROBE_Y (max(Y_MIN_POS, Y_MIN_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
#define MAX_PROBE_Y (min(Y_MAX_POS, Y_MAX_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
#ifdef AUTO_BED_LEVELING_GRID
// Make sure probing points are reachable
#if LEFT_PROBE_BED_POSITION < MIN_PROBE_X
#error "The given LEFT_PROBE_BED_POSITION can't be reached by the probe."
#elif RIGHT_PROBE_BED_POSITION > MAX_PROBE_X
#error "The given RIGHT_PROBE_BED_POSITION can't be reached by the probe."
#elif FRONT_PROBE_BED_POSITION < MIN_PROBE_Y
#error "The given FRONT_PROBE_BED_POSITION can't be reached by the probe."
#elif BACK_PROBE_BED_POSITION > MAX_PROBE_Y
#error "The given BACK_PROBE_BED_POSITION can't be reached by the probe."
#endif
#else // !AUTO_BED_LEVELING_GRID
#if ABL_PROBE_PT_1_X < MIN_PROBE_X || ABL_PROBE_PT_1_X > MAX_PROBE_X
#error "The given ABL_PROBE_PT_1_X can't be reached by the probe."
#elif ABL_PROBE_PT_2_X < MIN_PROBE_X || ABL_PROBE_PT_2_X > MAX_PROBE_X
#error "The given ABL_PROBE_PT_2_X can't be reached by the probe."
#elif ABL_PROBE_PT_3_X < MIN_PROBE_X || ABL_PROBE_PT_3_X > MAX_PROBE_X
#error "The given ABL_PROBE_PT_3_X can't be reached by the probe."
#elif ABL_PROBE_PT_1_Y < MIN_PROBE_Y || ABL_PROBE_PT_1_Y > MAX_PROBE_Y
#error "The given ABL_PROBE_PT_1_Y can't be reached by the probe."
#elif ABL_PROBE_PT_2_Y < MIN_PROBE_Y || ABL_PROBE_PT_2_Y > MAX_PROBE_Y
#error "The given ABL_PROBE_PT_2_Y can't be reached by the probe."
#elif ABL_PROBE_PT_3_Y < MIN_PROBE_Y || ABL_PROBE_PT_3_Y > MAX_PROBE_Y
#error "The given ABL_PROBE_PT_3_Y can't be reached by the probe."
#endif
#endif // !AUTO_BED_LEVELING_GRID
/** /**
* G29: Detailed Z-Probe, probes the bed at 3 or more points. * G29: Detailed Z-Probe, probes the bed at 3 or more points.
* Will fail if the printer has not been homed with G28. * Will fail if the printer has not been homed with G28.
...@@ -2472,6 +2572,8 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) { ...@@ -2472,6 +2572,8 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) {
* P Set the size of the grid that will be probed (P x P points). * P Set the size of the grid that will be probed (P x P points).
* Example: "G29 P4" * Example: "G29 P4"
* *
* S Set the XY travel speed between probe points (in mm/min)
*
* V Set the verbose level (0-4). Example: "G29 V3" * V Set the verbose level (0-4). Example: "G29 V3"
* *
* T Generate a Bed Topology Report. Example: "G29 P5 T" for a detailed report. * T Generate a Bed Topology Report. Example: "G29 P5 T" for a detailed report.
...@@ -2492,7 +2594,6 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) { ...@@ -2492,7 +2594,6 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) {
* *
*/ */
enum ProbeAction { ProbeStay, ProbeEngage, ProbeRetract, ProbeEngageRetract };
// Use one of these defines to specify the origin // Use one of these defines to specify the origin
// for a topographical map to be printed for your bed. // for a topographical map to be printed for your bed.
enum { OriginBackLeft, OriginFrontLeft, OriginBackRight, OriginFrontRight }; enum { OriginBackLeft, OriginFrontLeft, OriginBackRight, OriginFrontRight };
...@@ -2500,8 +2601,6 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) { ...@@ -2500,8 +2601,6 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) {
inline void gcode_G29() { inline void gcode_G29() {
float x_tmp, y_tmp, z_tmp, real_z;
// Prevent user from running a G29 without first homing in X and Y // Prevent user from running a G29 without first homing in X and Y
if (!axis_known_position[X_AXIS] || !axis_known_position[Y_AXIS]) { if (!axis_known_position[X_AXIS] || !axis_known_position[Y_AXIS]) {
LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN); LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN);
...@@ -2510,75 +2609,63 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) { ...@@ -2510,75 +2609,63 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) {
return; return;
} }
bool enhanced_g29 = code_seen('E') || code_seen('e');
#ifdef AUTO_BED_LEVELING_GRID
// Example Syntax: G29 N4 V2 E T
int verbose_level = 1; int verbose_level = 1;
float x_tmp, y_tmp, z_tmp, real_z;
bool topo_flag = code_seen('T') || code_seen('t');
if (code_seen('V') || code_seen('v')) { if (code_seen('V') || code_seen('v')) {
verbose_level = code_value(); verbose_level = code_value_long();
if (verbose_level < 0 || verbose_level > 4) { if (verbose_level < 0 || verbose_level > 4) {
SERIAL_PROTOCOLPGM("?(V)erbose Level is implausible (0-4).\n"); SERIAL_PROTOCOLPGM("?(V)erbose Level is implausible (0-4).\n");
return; return;
} }
if (verbose_level > 0) {
SERIAL_PROTOCOLPGM("G29 Enhanced Auto Bed Leveling Code:\n");
if (verbose_level > 2) topo_flag = true;
}
} }
bool enhanced_g29 = code_seen('E') || code_seen('e');
#ifdef AUTO_BED_LEVELING_GRID
bool topo_flag = verbose_level > 2 || code_seen('T') || code_seen('t');
if (verbose_level > 0) SERIAL_PROTOCOLPGM("G29 Auto Bed Leveling\n");
int auto_bed_leveling_grid_points = code_seen('P') ? code_value_long() : AUTO_BED_LEVELING_GRID_POINTS; int auto_bed_leveling_grid_points = code_seen('P') ? code_value_long() : AUTO_BED_LEVELING_GRID_POINTS;
if (auto_bed_leveling_grid_points < 2) { if (auto_bed_leveling_grid_points < 2) {
SERIAL_PROTOCOLPGM("?Number of probed (P)oints is implausible (2 minimum).\n"); SERIAL_PROTOCOLPGM("?Number of probed (P)oints is implausible (2 minimum).\n");
return; return;
} }
// Define the possible boundaries for probing based on the set limits. xy_travel_speed = code_seen('S') ? code_value_long() : XY_TRAVEL_SPEED;
// Code above (in G28) might have these limits wrong, or I am wrong here.
#define MIN_PROBE_EDGE 10 // Edges of the probe square can be no less
const int min_probe_x = max(X_MIN_POS, X_MIN_POS + X_PROBE_OFFSET_FROM_EXTRUDER),
max_probe_x = min(X_MAX_POS, X_MAX_POS + X_PROBE_OFFSET_FROM_EXTRUDER),
min_probe_y = max(Y_MIN_POS, Y_MIN_POS + Y_PROBE_OFFSET_FROM_EXTRUDER),
max_probe_y = min(Y_MAX_POS, Y_MAX_POS + Y_PROBE_OFFSET_FROM_EXTRUDER);
int left_probe_bed_position = code_seen('L') ? code_value_long() : LEFT_PROBE_BED_POSITION, int left_probe_bed_position = code_seen('L') ? code_value_long() : LEFT_PROBE_BED_POSITION,
right_probe_bed_position = code_seen('R') ? code_value_long() : RIGHT_PROBE_BED_POSITION, right_probe_bed_position = code_seen('R') ? code_value_long() : RIGHT_PROBE_BED_POSITION,
front_probe_bed_position = code_seen('F') ? code_value_long() : FRONT_PROBE_BED_POSITION, front_probe_bed_position = code_seen('F') ? code_value_long() : FRONT_PROBE_BED_POSITION,
back_probe_bed_position = code_seen('B') ? code_value_long() : BACK_PROBE_BED_POSITION; back_probe_bed_position = code_seen('B') ? code_value_long() : BACK_PROBE_BED_POSITION;
bool left_out_l = left_probe_bed_position < min_probe_x, bool left_out_l = left_probe_bed_position < MIN_PROBE_X,
left_out_r = left_probe_bed_position > right_probe_bed_position - MIN_PROBE_EDGE, left_out = left_out_l || left_probe_bed_position > right_probe_bed_position - MIN_PROBE_EDGE,
left_out = left_out_l || left_out_r, right_out_r = right_probe_bed_position > MAX_PROBE_X,
right_out_r = right_probe_bed_position > max_probe_x, right_out = right_out_r || right_probe_bed_position < left_probe_bed_position + MIN_PROBE_EDGE,
right_out_l =right_probe_bed_position < left_probe_bed_position + MIN_PROBE_EDGE, front_out_f = front_probe_bed_position < MIN_PROBE_Y,
right_out = right_out_l || right_out_r, front_out = front_out_f || front_probe_bed_position > back_probe_bed_position - MIN_PROBE_EDGE,
front_out_f = front_probe_bed_position < min_probe_y, back_out_b = back_probe_bed_position > MAX_PROBE_Y,
front_out_b = front_probe_bed_position > back_probe_bed_position - MIN_PROBE_EDGE, back_out = back_out_b || back_probe_bed_position < front_probe_bed_position + MIN_PROBE_EDGE;
front_out = front_out_f || front_out_b,
back_out_b = back_probe_bed_position > max_probe_y,
back_out_f = back_probe_bed_position < front_probe_bed_position + MIN_PROBE_EDGE,
back_out = back_out_f || back_out_b;
if (left_out || right_out || front_out || back_out) { if (left_out || right_out || front_out || back_out) {
if (left_out) { if (left_out) {
SERIAL_PROTOCOLPGM("?Probe (L)eft position out of range.\n"); SERIAL_PROTOCOLPGM("?Probe (L)eft position out of range.\n");
left_probe_bed_position = left_out_l ? min_probe_x : right_probe_bed_position - MIN_PROBE_EDGE; left_probe_bed_position = left_out_l ? MIN_PROBE_X : right_probe_bed_position - MIN_PROBE_EDGE;
} }
if (right_out) { if (right_out) {
SERIAL_PROTOCOLPGM("?Probe (R)ight position out of range.\n"); SERIAL_PROTOCOLPGM("?Probe (R)ight position out of range.\n");
right_probe_bed_position = right_out_r ? max_probe_x : left_probe_bed_position + MIN_PROBE_EDGE; right_probe_bed_position = right_out_r ? MAX_PROBE_X : left_probe_bed_position + MIN_PROBE_EDGE;
} }
if (front_out) { if (front_out) {
SERIAL_PROTOCOLPGM("?Probe (F)ront position out of range.\n"); SERIAL_PROTOCOLPGM("?Probe (F)ront position out of range.\n");
front_probe_bed_position = front_out_f ? min_probe_y : back_probe_bed_position - MIN_PROBE_EDGE; front_probe_bed_position = front_out_f ? MIN_PROBE_Y : back_probe_bed_position - MIN_PROBE_EDGE;
} }
if (back_out) { if (back_out) {
SERIAL_PROTOCOLPGM("?Probe (B)ack position out of range.\n"); SERIAL_PROTOCOLPGM("?Probe (B)ack position out of range.\n");
back_probe_bed_position = back_out_b ? max_probe_y : front_probe_bed_position + MIN_PROBE_EDGE; back_probe_bed_position = back_out_b ? MAX_PROBE_Y : front_probe_bed_position + MIN_PROBE_EDGE;
} }
return; return;
} }
...@@ -2656,7 +2743,7 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) { ...@@ -2656,7 +2743,7 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) {
else else
act = ProbeEngageRetract; act = ProbeEngageRetract;
measured_z = probe_pt(xProbe, yProbe, z_before, act); measured_z = probe_pt(xProbe, yProbe, z_before, act, verbose_level);
mean += measured_z; mean += measured_z;
...@@ -2732,6 +2819,7 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) { ...@@ -2732,6 +2819,7 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) {
} //topo_flag } //topo_flag
set_bed_level_equation_lsq(plane_equation_coefficients); set_bed_level_equation_lsq(plane_equation_coefficients);
free(plane_equation_coefficients); free(plane_equation_coefficients);
...@@ -2742,14 +2830,14 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) { ...@@ -2742,14 +2830,14 @@ inline void gcode_G28(boolean home_x=false, boolean home_y=false) {
if (enhanced_g29) { if (enhanced_g29) {
// Basic Enhanced G29 // Basic Enhanced G29
z_at_pt_1 = probe_pt(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, Z_RAISE_BEFORE_PROBING, ProbeEngage); z_at_pt_1 = probe_pt(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, Z_RAISE_BEFORE_PROBING, ProbeEngage, verbose_level);
z_at_pt_2 = probe_pt(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS, ProbeStay); z_at_pt_2 = probe_pt(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS, ProbeStay, verbose_level);
z_at_pt_3 = probe_pt(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS, ProbeRetract); z_at_pt_3 = probe_pt(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS, ProbeRetract, verbose_level);
} }
else { else {
z_at_pt_1 = probe_pt(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, Z_RAISE_BEFORE_PROBING); z_at_pt_1 = probe_pt(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, Z_RAISE_BEFORE_PROBING, verbose_level);
z_at_pt_2 = probe_pt(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS); z_at_pt_2 = probe_pt(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS, verbose_level);
z_at_pt_3 = probe_pt(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS); z_at_pt_3 = probe_pt(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS, verbose_level);
} }
clean_up_after_endstop_move(); clean_up_after_endstop_move();
set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3); set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
...@@ -3664,6 +3752,33 @@ inline void gcode_G92() { ...@@ -3664,6 +3752,33 @@ inline void gcode_G92() {
} }
#endif // ENABLE_AUTO_BED_LEVELING && Z_PROBE_REPEATABILITY_TEST #endif // ENABLE_AUTO_BED_LEVELING && Z_PROBE_REPEATABILITY_TEST
/*
* M204: Set Accelerations in mm/sec^2 (M204 P1200 R3000 T3000)
*
* P = Printing moves
* R = Retract only (no X, Y, Z) moves
* T = Travel (non printing) moves
*
* Also sets minimum segment time in ms (B20000) to prevent buffer under-runs and M20 minimum feedrate
*/
inline void gcode_M204() {
if (code_seen('P')) {
acceleration = code_value();
SERIAL_ECHOPAIR("Setting Printing Acceleration: ", acceleration );
SERIAL_EOL;
}
if (code_seen('R')) {
retract_acceleration = code_value();
SERIAL_ECHOPAIR("Setting Retract Acceleration: ", retract_acceleration );
SERIAL_EOL;
}
if (code_seen('T')) {
travel_acceleration = code_value();
SERIAL_ECHOPAIR("Setting Travel Acceleration: ", travel_acceleration );
SERIAL_EOL;
}
}
#ifdef FILAMENTCHANGEENABLE #ifdef FILAMENTCHANGEENABLE
//M600: Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal] //M600: Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
inline void gcode_M600() { inline void gcode_M600() {
...@@ -4817,10 +4932,7 @@ void process_commands() ...@@ -4817,10 +4932,7 @@ void process_commands()
} }
break; break;
case 204: //M204 acceleration S normal moves T filament only moves case 204: //M204 acceleration S normal moves T filament only moves
{ gcode_M204();
if(code_seen('S')) acceleration = code_value() ;
if(code_seen('T')) retract_acceleration = code_value() ;
}
break; break;
case 205: //M205 advanced settings: minimum travel speed S=while printing T=travel only, B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk case 205: //M205 advanced settings: minimum travel speed S=while printing T=travel only, B=minimum segment time X= maximum xy jerk, Z=maximum Z jerk
{ {
...@@ -5645,12 +5757,9 @@ void process_commands() ...@@ -5645,12 +5757,9 @@ void process_commands()
(delayed_move_time != 0 || current_position[X_AXIS] != x_home_pos(active_extruder))) (delayed_move_time != 0 || current_position[X_AXIS] != x_home_pos(active_extruder)))
{ {
// Park old head: 1) raise 2) move to park position 3) lower // Park old head: 1) raise 2) move to park position 3) lower
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + TOOLCHANGE_PARK_ZLIFT, plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + TOOLCHANGE_PARK_ZLIFT, current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder, active_driver);
current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder, active_driver); plan_buffer_line(x_home_pos(active_extruder), current_position[Y_AXIS], current_position[Z_AXIS] + TOOLCHANGE_PARK_ZLIFT, current_position[E_AXIS], max_feedrate[X_AXIS], active_extruder, active_driver);
plan_buffer_line(x_home_pos(active_extruder), current_position[Y_AXIS], current_position[Z_AXIS] + TOOLCHANGE_PARK_ZLIFT, plan_buffer_line(x_home_pos(active_extruder), current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder, active_driver);
current_position[E_AXIS], max_feedrate[X_AXIS], active_extruder, active_driver);
plan_buffer_line(x_home_pos(active_extruder), current_position[Y_AXIS], current_position[Z_AXIS],
current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder, active_driver);
st_synchronize(); st_synchronize();
} }
...@@ -5959,7 +6068,6 @@ void prepare_move() ...@@ -5959,7 +6068,6 @@ void prepare_move()
destination[i] = current_position[i] + difference[i] * fraction; destination[i] = current_position[i] + difference[i] * fraction;
} }
calculate_delta(destination); calculate_delta(destination);
//SERIAL_ECHOPGM("destination[0]="); SERIAL_ECHOLN(destination[0]); //SERIAL_ECHOPGM("destination[0]="); SERIAL_ECHOLN(destination[0]);
//SERIAL_ECHOPGM("destination[1]="); SERIAL_ECHOLN(destination[1]); //SERIAL_ECHOPGM("destination[1]="); SERIAL_ECHOLN(destination[1]);
...@@ -5968,9 +6076,7 @@ void prepare_move() ...@@ -5968,9 +6076,7 @@ void prepare_move()
//SERIAL_ECHOPGM("delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]); //SERIAL_ECHOPGM("delta[Y_AXIS]="); SERIAL_ECHOLN(delta[Y_AXIS]);
//SERIAL_ECHOPGM("delta[Z_AXIS]="); SERIAL_ECHOLN(delta[Z_AXIS]); //SERIAL_ECHOPGM("delta[Z_AXIS]="); SERIAL_ECHOLN(delta[Z_AXIS]);
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder, active_driver);
destination[E_AXIS], feedrate*feedmultiply/60/100.0,
active_extruder, active_driver);
} }
#endif // SCARA #endif // SCARA
...@@ -6008,9 +6114,7 @@ void prepare_move() ...@@ -6008,9 +6114,7 @@ void prepare_move()
//SERIAL_ECHOPGM("delta[Z_AXIS]="); SERIAL_ECHOLN(delta[Z_AXIS]); //SERIAL_ECHOPGM("delta[Z_AXIS]="); SERIAL_ECHOLN(delta[Z_AXIS]);
adjust_delta(destination); adjust_delta(destination);
plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], plan_buffer_line(delta[X_AXIS], delta[Y_AXIS], delta[Z_AXIS], destination[E_AXIS], feedrate*feedmultiply/60/100.0, active_extruder, active_driver);
destination[E_AXIS], feedrate*feedmultiply/60/100.0,
active_extruder, active_driver);
} }
#endif // DELTA #endif // DELTA
...@@ -6022,8 +6126,7 @@ void prepare_move() ...@@ -6022,8 +6126,7 @@ void prepare_move()
{ {
// move duplicate extruder into correct duplication position. // move duplicate extruder into correct duplication position.
plan_set_position(inactive_extruder_x_pos, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); plan_set_position(inactive_extruder_x_pos, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
plan_buffer_line(current_position[X_AXIS] + duplicate_extruder_x_offset, current_position[Y_AXIS], current_position[Z_AXIS], plan_buffer_line(current_position[X_AXIS] + duplicate_extruder_x_offset, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], max_feedrate[X_AXIS], 1, active_driver);
current_position[E_AXIS], max_feedrate[X_AXIS], 1, active_driver);
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
st_synchronize(); st_synchronize();
extruder_duplication_enabled = true; extruder_duplication_enabled = true;
...@@ -6046,12 +6149,9 @@ void prepare_move() ...@@ -6046,12 +6149,9 @@ void prepare_move()
} }
delayed_move_time = 0; delayed_move_time = 0;
// unpark extruder: 1) raise, 2) move into starting XY position, 3) lower // unpark extruder: 1) raise, 2) move into starting XY position, 3) lower
plan_buffer_line(raised_parked_position[X_AXIS], raised_parked_position[Y_AXIS], raised_parked_position[Z_AXIS], plan_buffer_line(raised_parked_position[X_AXIS], raised_parked_position[Y_AXIS], raised_parked_position[Z_AXIS], current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder, active_driver);
current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder, active_driver); plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], raised_parked_position[Z_AXIS], current_position[E_AXIS], min(max_feedrate[X_AXIS],max_feedrate[Y_AXIS]), active_extruder, active_driver);
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], raised_parked_position[Z_AXIS], plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder, active_driver);
current_position[E_AXIS], min(max_feedrate[X_AXIS],max_feedrate[Y_AXIS]), active_extruder, active_driver);
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS],
current_position[E_AXIS], max_feedrate[Z_AXIS], active_extruder, active_driver);
active_extruder_parked = false; active_extruder_parked = false;
} }
} }
......
...@@ -159,8 +159,8 @@ ...@@ -159,8 +159,8 @@
#define MSG_PID_TIMEOUT MSG_PID_AUTOTUNE_FAILED " timeout" #define MSG_PID_TIMEOUT MSG_PID_AUTOTUNE_FAILED " timeout"
#define MSG_BIAS " bias: " #define MSG_BIAS " bias: "
#define MSG_D " d: " #define MSG_D " d: "
#define MSG_MIN " min: " #define MSG_T_MIN " min: "
#define MSG_MAX " max: " #define MSG_T_MAX " max: "
#define MSG_KU " Ku: " #define MSG_KU " Ku: "
#define MSG_TU " Tu: " #define MSG_TU " Tu: "
#define MSG_CLASSIC_PID " Classic PID " #define MSG_CLASSIC_PID " Classic PID "
...@@ -214,8 +214,7 @@ ...@@ -214,8 +214,7 @@
#define STR_h3 "3" #define STR_h3 "3"
#define STR_Deg "\271" #define STR_Deg "\271"
#define STR_THERMOMETER "\002" #define STR_THERMOMETER "\002"
#endif #elif defined(DISPLAY_CHARSET_HD44780_WESTERN) // HD44780 ROM Code: A02 (Western)
#ifdef DISPLAY_CHARSET_HD44780_WESTERN // HD44780 ROM Code: A02 (Western)
#define STR_Ae "\216" #define STR_Ae "\216"
#define STR_ae "\204" #define STR_ae "\204"
#define STR_Oe "\211" #define STR_Oe "\211"
...@@ -227,6 +226,8 @@ ...@@ -227,6 +226,8 @@
#define STR_h3 "\263" #define STR_h3 "\263"
#define STR_Deg "\337" #define STR_Deg "\337"
#define STR_THERMOMETER "\002" #define STR_THERMOMETER "\002"
#elif defined(ULTRA_LCD)
#error You must enable either DISPLAY_CHARSET_HD44780_JAPAN or DISPLAY_CHARSET_HD44780_WESTERN for your LCD controller.
#endif #endif
#endif #endif
/* /*
......
...@@ -71,6 +71,7 @@ ...@@ -71,6 +71,7 @@
#define MSG_VTRAV_MIN "VTrav min" #define MSG_VTRAV_MIN "VTrav min"
#define MSG_AMAX "Amax" #define MSG_AMAX "Amax"
#define MSG_A_RETRACT "A-retrac." #define MSG_A_RETRACT "A-retrac."
#define MSG_A_TRAVEL "A-travel"
#define MSG_XSTEPS "X trangos/mm" #define MSG_XSTEPS "X trangos/mm"
#define MSG_YSTEPS "Y trangos/mm" #define MSG_YSTEPS "Y trangos/mm"
#define MSG_ZSTEPS "Z trangos/mm" #define MSG_ZSTEPS "Z trangos/mm"
......
...@@ -71,6 +71,7 @@ ...@@ -71,6 +71,7 @@
#define MSG_VTRAV_MIN "VTrav min" #define MSG_VTRAV_MIN "VTrav min"
#define MSG_AMAX "Amax " #define MSG_AMAX "Amax "
#define MSG_A_RETRACT "A-retract" #define MSG_A_RETRACT "A-retract"
#define MSG_A_TRAVEL "A-travel"
#define MSG_XSTEPS "X passos/mm" #define MSG_XSTEPS "X passos/mm"
#define MSG_YSTEPS "Y passos/mm" #define MSG_YSTEPS "Y passos/mm"
#define MSG_ZSTEPS "Z passos/mm" #define MSG_ZSTEPS "Z passos/mm"
......
...@@ -71,6 +71,7 @@ ...@@ -71,6 +71,7 @@
#define MSG_VTRAV_MIN "VTrav min" #define MSG_VTRAV_MIN "VTrav min"
#define MSG_AMAX "Amax " #define MSG_AMAX "Amax "
#define MSG_A_RETRACT "A-Retract" #define MSG_A_RETRACT "A-Retract"
#define MSG_A_TRAVEL "A-travel"
#define MSG_XSTEPS "X steps/mm" #define MSG_XSTEPS "X steps/mm"
#define MSG_YSTEPS "Y steps/mm" #define MSG_YSTEPS "Y steps/mm"
#define MSG_ZSTEPS "Z steps/mm" #define MSG_ZSTEPS "Z steps/mm"
......
...@@ -71,6 +71,7 @@ ...@@ -71,6 +71,7 @@
#define MSG_VTRAV_MIN "VTrav min" #define MSG_VTRAV_MIN "VTrav min"
#define MSG_AMAX "Amax " #define MSG_AMAX "Amax "
#define MSG_A_RETRACT "A-retract" #define MSG_A_RETRACT "A-retract"
#define MSG_A_TRAVEL "A-travel"
#define MSG_XSTEPS "X steps/mm" #define MSG_XSTEPS "X steps/mm"
#define MSG_YSTEPS "Y steps/mm" #define MSG_YSTEPS "Y steps/mm"
#define MSG_ZSTEPS "Z steps/mm" #define MSG_ZSTEPS "Z steps/mm"
......
...@@ -71,6 +71,7 @@ ...@@ -71,6 +71,7 @@
#define MSG_VTRAV_MIN "Vvacio min" #define MSG_VTRAV_MIN "Vvacio min"
#define MSG_AMAX "Amax" #define MSG_AMAX "Amax"
#define MSG_A_RETRACT "A-retrac." #define MSG_A_RETRACT "A-retrac."
#define MSG_A_TRAVEL "A-travel"
#define MSG_XSTEPS "X pasos/mm" #define MSG_XSTEPS "X pasos/mm"
#define MSG_YSTEPS "Y pasos/mm" #define MSG_YSTEPS "Y pasos/mm"
#define MSG_ZSTEPS "Z pasos/mm" #define MSG_ZSTEPS "Z pasos/mm"
......
...@@ -71,6 +71,7 @@ ...@@ -71,6 +71,7 @@
#define MSG_VTRAV_MIN "VTrav min" #define MSG_VTRAV_MIN "VTrav min"
#define MSG_AMAX "Amax " #define MSG_AMAX "Amax "
#define MSG_A_RETRACT "A-retrakt" #define MSG_A_RETRACT "A-retrakt"
#define MSG_A_TRAVEL "A-travel"
#define MSG_XSTEPS "X pausoak/mm" #define MSG_XSTEPS "X pausoak/mm"
#define MSG_YSTEPS "Y pausoak/mm" #define MSG_YSTEPS "Y pausoak/mm"
#define MSG_ZSTEPS "Z pausoak/mm" #define MSG_ZSTEPS "Z pausoak/mm"
......
...@@ -71,6 +71,7 @@ ...@@ -71,6 +71,7 @@
#define MSG_VTRAV_MIN "VLiike min" #define MSG_VTRAV_MIN "VLiike min"
#define MSG_AMAX "Amax " #define MSG_AMAX "Amax "
#define MSG_A_RETRACT "A-peruuta" #define MSG_A_RETRACT "A-peruuta"
#define MSG_A_TRAVEL "A-travel"
#define MSG_XSTEPS "X steps/mm" #define MSG_XSTEPS "X steps/mm"
#define MSG_YSTEPS "Y steps/mm" #define MSG_YSTEPS "Y steps/mm"
#define MSG_ZSTEPS "Z steps/mm" #define MSG_ZSTEPS "Z steps/mm"
......
...@@ -71,6 +71,7 @@ ...@@ -71,6 +71,7 @@
#define MSG_VTRAV_MIN "Vdepl min" #define MSG_VTRAV_MIN "Vdepl min"
#define MSG_AMAX "Amax " #define MSG_AMAX "Amax "
#define MSG_A_RETRACT "A-retract" #define MSG_A_RETRACT "A-retract"
#define MSG_A_TRAVEL "A-travel"
#define MSG_XSTEPS "X pas/mm" #define MSG_XSTEPS "X pas/mm"
#define MSG_YSTEPS "Y pas/mm" #define MSG_YSTEPS "Y pas/mm"
#define MSG_ZSTEPS "Z pas/mm" #define MSG_ZSTEPS "Z pas/mm"
......
...@@ -62,15 +62,16 @@ ...@@ -62,15 +62,16 @@
#define MSG_VXY_JERK "Vxy-jerk" #define MSG_VXY_JERK "Vxy-jerk"
#define MSG_VZ_JERK "Vz-jerk" #define MSG_VZ_JERK "Vz-jerk"
#define MSG_VE_JERK "Ve-jerk" #define MSG_VE_JERK "Ve-jerk"
#define MSG_VMAX "Vmax " #define MSG_VMAX "Vmax"
#define MSG_X "x" #define MSG_X "x"
#define MSG_Y "y" #define MSG_Y "y"
#define MSG_Z "z" #define MSG_Z "z"
#define MSG_E "e" #define MSG_E "e"
#define MSG_VMIN "Vmin" #define MSG_VMIN "Vmin"
#define MSG_VTRAV_MIN "VTrav min" #define MSG_VTRAV_MIN "VTrav min"
#define MSG_AMAX "Amax " #define MSG_AMAX "Amax"
#define MSG_A_RETRACT "A-retract" #define MSG_A_RETRACT "A-retract"
#define MSG_A_TRAVEL "A-travel"
#define MSG_XSTEPS "X steps/mm" #define MSG_XSTEPS "X steps/mm"
#define MSG_YSTEPS "Y steps/mm" #define MSG_YSTEPS "Y steps/mm"
#define MSG_ZSTEPS "Z steps/mm" #define MSG_ZSTEPS "Z steps/mm"
......
...@@ -71,6 +71,7 @@ ...@@ -71,6 +71,7 @@
#define MSG_VTRAV_MIN "VTrav min" #define MSG_VTRAV_MIN "VTrav min"
#define MSG_AMAX "Amax " #define MSG_AMAX "Amax "
#define MSG_A_RETRACT "A-retract" #define MSG_A_RETRACT "A-retract"
#define MSG_A_TRAVEL "A-travel"
#define MSG_XSTEPS "X steps/mm" #define MSG_XSTEPS "X steps/mm"
#define MSG_YSTEPS "Y steps/mm" #define MSG_YSTEPS "Y steps/mm"
#define MSG_ZSTEPS "Z steps/mm" #define MSG_ZSTEPS "Z steps/mm"
......
...@@ -71,6 +71,7 @@ ...@@ -71,6 +71,7 @@
#define MSG_VTRAV_MIN "Vskok min" #define MSG_VTRAV_MIN "Vskok min"
#define MSG_AMAX "Amax" #define MSG_AMAX "Amax"
#define MSG_A_RETRACT "A-wycofanie" #define MSG_A_RETRACT "A-wycofanie"
#define MSG_A_TRAVEL "A-travel"
#define MSG_XSTEPS "krokiX/mm" #define MSG_XSTEPS "krokiX/mm"
#define MSG_YSTEPS "krokiY/mm" #define MSG_YSTEPS "krokiY/mm"
#define MSG_ZSTEPS "krokiZ/mm" #define MSG_ZSTEPS "krokiZ/mm"
......
...@@ -71,13 +71,14 @@ ...@@ -71,13 +71,14 @@
#define MSG_VTRAV_MIN "VTrav min" #define MSG_VTRAV_MIN "VTrav min"
#define MSG_AMAX "Amax " #define MSG_AMAX "Amax "
#define MSG_A_RETRACT "A-retract" #define MSG_A_RETRACT "A-retract"
#define MSG_A_TRAVEL "A-travel"
#define MSG_XSTEPS "Xpasso/mm" #define MSG_XSTEPS "Xpasso/mm"
#define MSG_YSTEPS "Ypasso/mm" #define MSG_YSTEPS "Ypasso/mm"
#define MSG_ZSTEPS "Zpasso/mm" #define MSG_ZSTEPS "Zpasso/mm"
#define MSG_E0STEPS "E0 steps/mm" #define MSG_E0STEPS "E0 passo/mm"
#define MSG_E1STEPS "E1 steps/mm" #define MSG_E1STEPS "E1 passo/mm"
#define MSG_E2STEPS "E2 steps/mm" #define MSG_E2STEPS "E2 passo/mm"
#define MSG_E3STEPS "E3 steps/mm" #define MSG_E3STEPS "E3 passo/mm"
#define MSG_TEMPERATURE "Temperatura" #define MSG_TEMPERATURE "Temperatura"
#define MSG_MOTION "Movimento" #define MSG_MOTION "Movimento"
#define MSG_VOLUMETRIC "Filament" #define MSG_VOLUMETRIC "Filament"
......
...@@ -13,108 +13,109 @@ ...@@ -13,108 +13,109 @@
#define MSG_SD_REMOVED "Cartao removido" #define MSG_SD_REMOVED "Cartao removido"
#define MSG_MAIN " Menu principal \003" #define MSG_MAIN " Menu principal \003"
#define MSG_AUTOSTART "Autostart" #define MSG_AUTOSTART "Autostart"
#define MSG_DISABLE_STEPPERS " Apagar motores" #define MSG_DISABLE_STEPPERS " Desligar motores"
#define MSG_AUTO_HOME "Ir para origen" #define MSG_AUTO_HOME "Ir para home"
#define MSG_BED_SETTING "Bed Setting" #define MSG_BED_SETTING "Bed Setting"
#define MSG_SET_HOME_OFFSETS "Set home offsets" #define MSG_SET_HOME_OFFSETS "Def. home offsets"
#define MSG_SET_ORIGIN "Estabelecer orig." #define MSG_SET_ORIGIN "Estabelecer orig."
#define MSG_PREHEAT_PLA "Pre-aquecer PLA" #define MSG_PREHEAT_PLA "Pre-aquecer PLA"
#define MSG_PREHEAT_PLA_ALL " pre-aq. PLA Tudo" #define MSG_PREHEAT_PLA_ALL "Pre-aq. PLA Tudo"
#define MSG_PREHEAT_PLA_BEDONLY " pre-aq. PLA \002Base" #define MSG_PREHEAT_PLA_BEDONLY "Pre-aq. PLA \002Base"
#define MSG_PREHEAT_PLA_SETTINGS "PLA setting" #define MSG_PREHEAT_PLA_SETTINGS "PLA definicoes"
#define MSG_PREHEAT_ABS "Pre-aquecer ABS" #define MSG_PREHEAT_ABS "Pre-aquecer ABS"
#define MSG_PREHEAT_ABS_ALL " pre-aq. ABS Tudo" #define MSG_PREHEAT_ABS_ALL "Pre-aq. ABS Tudo"
#define MSG_PREHEAT_ABS_BEDONLY " pre-aq. ABS \002Base" #define MSG_PREHEAT_ABS_BEDONLY "Pre-aq. ABS \002Base"
#define MSG_PREHEAT_ABS_SETTINGS "ABS setting" #define MSG_PREHEAT_ABS_SETTINGS "ABS definicoes"
#define MSG_PREHEAT_GUM "Preheat GUM" #define MSG_PREHEAT_GUM "Pre-aquecer GUM"
#define MSG_PREHEAT_GUM_ALL "Preheat GUM All" #define MSG_PREHEAT_GUM_ALL "Pre-aquecer GUM Tudo"
#define MSG_PREHEAT_GUM_BEDONLY "Preheat GUM Bed" #define MSG_PREHEAT_GUM_BEDONLY "Pre-aquecer GUM \002Base"
#define MSG_PREHEAT_GUM_SETTINGS "Preheat GUM conf" #define MSG_PREHEAT_GUM_SETTINGS "GUM definicoes"
#define MSG_COOLDOWN "Esfriar" #define MSG_COOLDOWN "Arrefecer"
#define MSG_SWITCH_PS_ON "Switch Power On" #define MSG_SWITCH_PS_ON "Ligar"
#define MSG_SWITCH_PS_OFF "Switch Power Off" #define MSG_SWITCH_PS_OFF "Desligar"
#define MSG_EXTRUDE "Extrudar" #define MSG_EXTRUDE "Extrudir"
#define MSG_RETRACT "Retrair" #define MSG_RETRACT "Retrair"
#define MSG_MOVE_AXIS "Mover eixo \x7E" #define MSG_MOVE_AXIS "Mover eixo \x7E"
#define MSG_MOVE_X "Move X" #define MSG_MOVE_X "Mover X"
#define MSG_MOVE_Y "Move Y" #define MSG_MOVE_Y "Mover Y"
#define MSG_MOVE_Z "Move Z" #define MSG_MOVE_Z "Mover Z"
#define MSG_MOVE_E "Extruder" #define MSG_MOVE_E "Extrusor"
#define MSG_MOVE_01MM "Move 0.1mm" #define MSG_MOVE_01MM "Mover 0.1mm"
#define MSG_MOVE_1MM "Move 1mm" #define MSG_MOVE_1MM "Mover 1mm"
#define MSG_MOVE_10MM "Move 10mm" #define MSG_MOVE_10MM "Mover 10mm"
#define MSG_SPEED "Velocidade:" #define MSG_SPEED "Velocidade"
#define MSG_NOZZLE "Nozzle:" #define MSG_NOZZLE "\002Bico"
#define MSG_BED "Base:" #define MSG_BED "\002Base"
#define MSG_FAN_SPEED "Velocidade vento." #define MSG_FAN_SPEED "Velocidade do ar."
#define MSG_FLOW "Fluxo" #define MSG_FLOW "Fluxo"
#define MSG_CONTROL "Controle" #define MSG_CONTROL "Controlo \003"
#define MSG_MIN " " STR_THERMOMETER " Min" #define MSG_MIN "\002 Min"
#define MSG_MAX " " STR_THERMOMETER " Max" #define MSG_MAX "\002 Max"
#define MSG_FACTOR " " STR_THERMOMETER " Fact" #define MSG_FACTOR "\002 Fact"
#define MSG_AUTOTEMP "Autotemp:" #define MSG_AUTOTEMP "Autotemp"
#define MSG_ON "On " #define MSG_ON "On "
#define MSG_OFF "Off" #define MSG_OFF "Off"
#define MSG_PID_P "PID-P: " #define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I: " #define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D: " #define MSG_PID_D "PID-D"
#define MSG_ACC "Acc:" #define MSG_ACC "Acc"
#define MSG_VXY_JERK "Vxy-jerk: " #define MSG_VXY_JERK "Vxy-jerk"
#define MSG_VZ_JERK "Vz-jerk" #define MSG_VZ_JERK "Vz-jerk"
#define MSG_VE_JERK "Ve-jerk" #define MSG_VE_JERK "Ve-jerk"
#define MSG_VMAX " Vmax " #define MSG_VMAX " Vmax "
#define MSG_X "x:" #define MSG_X "x"
#define MSG_Y "y:" #define MSG_Y "y"
#define MSG_Z "z:" #define MSG_Z "z"
#define MSG_E "e:" #define MSG_E "e"
#define MSG_VMIN "Vmin:" #define MSG_VMIN "Vmin"
#define MSG_VTRAV_MIN "VTrav min:" #define MSG_VTRAV_MIN "VTrav min"
#define MSG_AMAX "Amax " #define MSG_AMAX "Amax "
#define MSG_A_RETRACT "A-retract:" #define MSG_A_RETRACT "A-retract"
#define MSG_XSTEPS "Xpasso/mm:" #define MSG_A_TRAVEL "A-travel"
#define MSG_YSTEPS "Ypasso/mm:" #define MSG_XSTEPS "Xpasso/mm"
#define MSG_ZSTEPS "Zpasso/mm:" #define MSG_YSTEPS "Ypasso/mm"
#define MSG_E0STEPS "E0 steps/mm" #define MSG_ZSTEPS "Zpasso/mm"
#define MSG_E1STEPS "E1 steps/mm" #define MSG_E0STEPS "E0 passo/mm"
#define MSG_E2STEPS "E2 steps/mm" #define MSG_E1STEPS "E1 passo/mm"
#define MSG_E3STEPS "E3 steps/mm" #define MSG_E2STEPS "E2 passo/mm"
#define MSG_E3STEPS "E3 passo/mm"
#define MSG_TEMPERATURE "Temperatura" #define MSG_TEMPERATURE "Temperatura"
#define MSG_MOTION "Movimento" #define MSG_MOTION "Movimento"
#define MSG_VOLUMETRIC "Filament" #define MSG_VOLUMETRIC "Filamento"
#define MSG_VOLUMETRIC_ENABLED "E in mm" STR_h3 #define MSG_VOLUMETRIC_ENABLED "E in mm" STR_h3
#define MSG_FILAMENT_SIZE_EXTRUDER "Fil. Dia." #define MSG_FILAMENT_SIZE_EXTRUDER "Fil. Diam."
#define MSG_CONTRAST "Contrast" #define MSG_CONTRAST "Contraste"
#define MSG_STORE_EPROM "Guardar memoria" #define MSG_STORE_EPROM "Guardar na memoria"
#define MSG_LOAD_EPROM "Carregar memoria" #define MSG_LOAD_EPROM "Carregar da memoria"
#define MSG_RESTORE_FAILSAFE "Rest. de emergen." #define MSG_RESTORE_FAILSAFE "Rest. de emergen."
#define MSG_REFRESH "Recarregar" #define MSG_REFRESH "\004Recarregar"
#define MSG_WATCH "Monitorar" #define MSG_WATCH "Monitorar \003"
#define MSG_PREPARE "Preparar" #define MSG_PREPARE "Preparar \x7E"
#define MSG_TUNE "Tune" #define MSG_TUNE "Afinar \x7E"
#define MSG_PAUSE_PRINT "Pausar impressao" #define MSG_PAUSE_PRINT "Pausar impressao"
#define MSG_RESUME_PRINT "Resumir impressao" #define MSG_RESUME_PRINT "Resumir impressao"
#define MSG_STOP_PRINT "Parar impressao" #define MSG_STOP_PRINT "Parar impressao"
#define MSG_CARD_MENU "Menu cartao SD" #define MSG_CARD_MENU "Menu cartao SD"
#define MSG_NO_CARD "Sem cartao SD" #define MSG_NO_CARD "Sem cartao SD"
#define MSG_DWELL "Repouso..." #define MSG_DWELL "Repouso..."
#define MSG_USERWAIT "Esperando ordem" #define MSG_USERWAIT "A espera de ordem"
#define MSG_RESUMING "Resuming print" #define MSG_RESUMING "Resumir impressao"
#define MSG_PRINT_ABORTED "Print aborted" #define MSG_PRINT_ABORTED "Impr. Cancelada"
#define MSG_NO_MOVE "Sem movimento" #define MSG_NO_MOVE "Sem movimento"
#define MSG_KILLED "PARADA DE EMERG." #define MSG_KILLED "INTRRP. DE EMERG."
#define MSG_STOPPED "PARADA. " #define MSG_STOPPED "PARADO. "
#define MSG_CONTROL_RETRACT " Retrair mm:" #define MSG_CONTROL_RETRACT " Retrair mm"
#define MSG_CONTROL_RETRACT_SWAP "Troca Retrair mm:" #define MSG_CONTROL_RETRACT_SWAP "Troca Retrair mm"
#define MSG_CONTROL_RETRACTF " Retrair V:" #define MSG_CONTROL_RETRACTF " Retrair V"
#define MSG_CONTROL_RETRACT_ZLIFT " Levantar mm:" #define MSG_CONTROL_RETRACT_ZLIFT " Levantar mm"
#define MSG_CONTROL_RETRACT_RECOVER " DesRet +mm:" #define MSG_CONTROL_RETRACT_RECOVER " DesRet +mm"
#define MSG_CONTROL_RETRACT_RECOVER_SWAP "Troca DesRet +mm:" #define MSG_CONTROL_RETRACT_RECOVER_SWAP "Troca DesRet +mm"
#define MSG_CONTROL_RETRACT_RECOVERF " DesRet V:" #define MSG_CONTROL_RETRACT_RECOVERF " DesRet V"
#define MSG_AUTORETRACT " AutoRetr.:" #define MSG_AUTORETRACT " AutoRetr."
#define MSG_FILAMENTCHANGE "Change filament" #define MSG_FILAMENTCHANGE "Trocar filamento"
#define MSG_INIT_SDCARD "Init. SD-Card" #define MSG_INIT_SDCARD "Inic. SD-Card"
#define MSG_CNG_SDCARD "Change SD-Card" #define MSG_CNG_SDCARD "Trocar SD-Card"
#define MSG_ZPROBE_OUT "Son. fora da mesa" #define MSG_ZPROBE_OUT "Sens. fora da Base"
#define MSG_POSITION_UNKNOWN "XY antes de Z" #define MSG_POSITION_UNKNOWN "XY antes de Z"
#define MSG_ZPROBE_ZOFFSET "Z Offset" #define MSG_ZPROBE_ZOFFSET "Z Offset"
#define MSG_BABYSTEP_X "Babystep X" #define MSG_BABYSTEP_X "Babystep X"
......
...@@ -71,6 +71,7 @@ ...@@ -71,6 +71,7 @@
#define MSG_VTRAV_MIN "VTrav min" #define MSG_VTRAV_MIN "VTrav min"
#define MSG_AMAX "Amax " #define MSG_AMAX "Amax "
#define MSG_A_RETRACT "A-retract" #define MSG_A_RETRACT "A-retract"
#define MSG_A_TRAVEL "A-travel"
#define MSG_XSTEPS "X шаг/mm" #define MSG_XSTEPS "X шаг/mm"
#define MSG_YSTEPS "Y шаг/mm" #define MSG_YSTEPS "Y шаг/mm"
#define MSG_ZSTEPS "Z шаг/mm" #define MSG_ZSTEPS "Z шаг/mm"
......
...@@ -68,8 +68,9 @@ float max_retraction_feedrate[EXTRUDERS]; // set the max speeds for retraction ...@@ -68,8 +68,9 @@ float max_retraction_feedrate[EXTRUDERS]; // set the max speeds for retraction
float axis_steps_per_unit[3 + EXTRUDERS]; float axis_steps_per_unit[3 + EXTRUDERS];
unsigned long max_acceleration_units_per_sq_second[3 + EXTRUDERS]; // Use M201 to override by software unsigned long max_acceleration_units_per_sq_second[3 + EXTRUDERS]; // Use M201 to override by software
float minimumfeedrate; float minimumfeedrate;
float acceleration; // Normal acceleration mm/s^2 THIS IS THE DEFAULT ACCELERATION for all moves. M204 SXXXX float acceleration; // Normal acceleration mm/s^2 THIS IS THE DEFAULT ACCELERATION for all printing moves. M204 SXXXX
float retract_acceleration; // mm/s^2 filament pull-pack and push-forward while standing still in the other axis M204 TXXXX float retract_acceleration; // mm/s^2 filament pull-pack and push-forward while standing still in the other axis M204 TXXXX
float travel_acceleration; // Travel acceleration mm/s^2 THIS IS THE DEFAULT ACCELERATION for all NON printing moves. M204 MXXXX
float max_xy_jerk; //speed than can be stopped at once, if i understand correctly. float max_xy_jerk; //speed than can be stopped at once, if i understand correctly.
float max_z_jerk; float max_z_jerk;
float max_e_jerk; float max_e_jerk;
...@@ -708,13 +709,14 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi ...@@ -708,13 +709,14 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi
if(block->steps_x != 0) enable_x(); if(block->steps_x != 0) enable_x();
if(block->steps_y != 0) enable_y(); if(block->steps_y != 0) enable_y();
#endif //NOCOREXY #endif //NOCOREXY
#ifndef Z_LATE_ENABLE #ifndef Z_LATE_ENABLE
if(block->steps_z != 0) enable_z(); if(block->steps_z != 0) enable_z();
#endif #endif
// Enable extruder(s) // Enable extruder(s)
if(block->steps_e != 0) if(block->steps_e != 0)
{ {
#if !defined(MKR4) && !defined(NPR2)
if (DISABLE_INACTIVE_EXTRUDER) //enable only selected extruder if (DISABLE_INACTIVE_EXTRUDER) //enable only selected extruder
{ {
...@@ -766,6 +768,23 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi ...@@ -766,6 +768,23 @@ block->steps_y = labs((target[X_AXIS]-position[X_AXIS]) - (target[Y_AXIS]-positi
enable_e2(); enable_e2();
enable_e3(); enable_e3();
} }
#else //MKR4 or NPr2
switch(extruder)
{
case 0:
enable_e0();
break;
case 1:
enable_e1();
break;
case 2:
enable_e0();
break;
case 3:
enable_e1();
break;
}
#endif //!MKR4 && !NPR2
} }
if (block->steps_e == 0) if (block->steps_e == 0)
...@@ -959,19 +978,24 @@ Having the real displacement of the head, we can calculate the total movement le ...@@ -959,19 +978,24 @@ Having the real displacement of the head, we can calculate the total movement le
{ {
block->acceleration_st = ceil(retract_acceleration * steps_per_mm); // convert to: acceleration steps/sec^2 block->acceleration_st = ceil(retract_acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
} }
else if(block->steps_e == 0)
{
block->acceleration_st = ceil(travel_acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
}
else else
{ {
block->acceleration_st = ceil(acceleration * steps_per_mm); // convert to: acceleration steps/sec^2 block->acceleration_st = ceil(acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
}
// Limit acceleration per axis // Limit acceleration per axis
if(((float)block->acceleration_st * (float)block->steps_x / (float)block->step_event_count) > axis_steps_per_sqr_second[X_AXIS]) if(((float)block->acceleration_st * (float)block->steps_x / (float)block->step_event_count) > axis_steps_per_sqr_second[X_AXIS])
block->acceleration_st = axis_steps_per_sqr_second[X_AXIS]; block->acceleration_st = axis_steps_per_sqr_second[X_AXIS];
if(((float)block->acceleration_st * (float)block->steps_y / (float)block->step_event_count) > axis_steps_per_sqr_second[Y_AXIS]) if(((float)block->acceleration_st * (float)block->steps_y / (float)block->step_event_count) > axis_steps_per_sqr_second[Y_AXIS])
block->acceleration_st = axis_steps_per_sqr_second[Y_AXIS]; block->acceleration_st = axis_steps_per_sqr_second[Y_AXIS];
if(((float)block->acceleration_st * (float)block->steps_z / (float)block->step_event_count ) > axis_steps_per_sqr_second[Z_AXIS])
block->acceleration_st = axis_steps_per_sqr_second[Z_AXIS];
if(((float)block->acceleration_st * (float)block->steps_e / (float)block->step_event_count) > axis_steps_per_sqr_second[E_AXIS]) if(((float)block->acceleration_st * (float)block->steps_e / (float)block->step_event_count) > axis_steps_per_sqr_second[E_AXIS])
block->acceleration_st = axis_steps_per_sqr_second[E_AXIS]; block->acceleration_st = axis_steps_per_sqr_second[E_AXIS];
} if(((float)block->acceleration_st * (float)block->steps_z / (float)block->step_event_count ) > axis_steps_per_sqr_second[Z_AXIS])
block->acceleration_st = axis_steps_per_sqr_second[Z_AXIS];
block->acceleration = block->acceleration_st / steps_per_mm; block->acceleration = block->acceleration_st / steps_per_mm;
block->acceleration_rate = (long)((float)block->acceleration_st * (16777216.0 / (F_CPU / 8.0))); block->acceleration_rate = (long)((float)block->acceleration_st * (16777216.0 / (F_CPU / 8.0)));
......
...@@ -116,6 +116,7 @@ extern unsigned long max_acceleration_units_per_sq_second[3 + EXTRUDERS]; // Use ...@@ -116,6 +116,7 @@ extern unsigned long max_acceleration_units_per_sq_second[3 + EXTRUDERS]; // Use
extern float minimumfeedrate; extern float minimumfeedrate;
extern float acceleration; // Normal acceleration mm/s^2 THIS IS THE DEFAULT ACCELERATION for all moves. M204 SXXXX extern float acceleration; // Normal acceleration mm/s^2 THIS IS THE DEFAULT ACCELERATION for all moves. M204 SXXXX
extern float retract_acceleration; // mm/s^2 filament pull-pack and push-forward while standing still in the other axis M204 TXXXX extern float retract_acceleration; // mm/s^2 filament pull-pack and push-forward while standing still in the other axis M204 TXXXX
extern float travel_acceleration; // Travel acceleration mm/s^2 THIS IS THE DEFAULT ACCELERATION for all NON printing moves. M204 MXXXX
extern float max_xy_jerk; //speed than can be stopped at once, if i understand correctly. extern float max_xy_jerk; //speed than can be stopped at once, if i understand correctly.
extern float max_z_jerk; extern float max_z_jerk;
extern float max_e_jerk; extern float max_e_jerk;
......
...@@ -406,58 +406,62 @@ ISR(TIMER1_COMPA_vect) ...@@ -406,58 +406,62 @@ ISR(TIMER1_COMPA_vect)
// Set the direction bits (X_AXIS=A_AXIS and Y_AXIS=B_AXIS for COREXY) // Set the direction bits (X_AXIS=A_AXIS and Y_AXIS=B_AXIS for COREXY)
if((out_bits & (1<<X_AXIS))!=0) { if((out_bits & (1<<X_AXIS))!=0) {
#ifdef DUAL_X_CARRIAGE #ifdef DUAL_X_CARRIAGE
if (extruder_duplication_enabled) { if (extruder_duplication_enabled){
WRITE(X_DIR_PIN, INVERT_X_DIR); X_DIR_WRITE(INVERT_X_DIR);
WRITE(X2_DIR_PIN, INVERT_X_DIR); X2_DIR_WRITE(INVERT_X_DIR);
} }
else { else{
if (current_block->active_driver != 0) if (current_block->active_extruder != 0)
WRITE(X2_DIR_PIN, INVERT_X_DIR); X2_DIR_WRITE(INVERT_X_DIR);
else else
WRITE(X_DIR_PIN, INVERT_X_DIR); X_DIR_WRITE(INVERT_X_DIR);
} }
#else #else
WRITE(X_DIR_PIN, INVERT_X_DIR); X_DIR_WRITE(INVERT_X_DIR);
#endif #endif
count_direction[X_AXIS]=-1; count_direction[X_AXIS]=-1;
} }
else { else {
#ifdef DUAL_X_CARRIAGE #ifdef DUAL_X_CARRIAGE
if (extruder_duplication_enabled) { if (extruder_duplication_enabled){
WRITE(X_DIR_PIN, !INVERT_X_DIR); X_DIR_WRITE(!INVERT_X_DIR);
WRITE(X2_DIR_PIN, !INVERT_X_DIR); X2_DIR_WRITE( !INVERT_X_DIR);
} }
else { else{
if (current_block->active_driver != 0) if (current_block->active_extruder != 0)
WRITE(X2_DIR_PIN, !INVERT_X_DIR); X2_DIR_WRITE(!INVERT_X_DIR);
else else
WRITE(X_DIR_PIN, !INVERT_X_DIR); X_DIR_WRITE(!INVERT_X_DIR);
} }
#else #else
WRITE(X_DIR_PIN, !INVERT_X_DIR); X_DIR_WRITE(!INVERT_X_DIR);
#endif #endif
count_direction[X_AXIS]=1; count_direction[X_AXIS]=1;
} }
if((out_bits & (1<<Y_AXIS))!=0) { if((out_bits & (1<<Y_AXIS))!=0){
WRITE(Y_DIR_PIN, INVERT_Y_DIR); Y_DIR_WRITE(INVERT_Y_DIR);
#ifdef Y_DUAL_STEPPER_DRIVERS #ifdef Y_DUAL_STEPPER_DRIVERS
WRITE(Y2_DIR_PIN, !(INVERT_Y_DIR == INVERT_Y2_VS_Y_DIR)); Y2_DIR_WRITE(!(INVERT_Y_DIR == INVERT_Y2_VS_Y_DIR));
#endif #endif
count_direction[Y_AXIS]=-1; count_direction[Y_AXIS]=-1;
} }
else { else{
WRITE(Y_DIR_PIN, !INVERT_Y_DIR); Y_DIR_WRITE(!INVERT_Y_DIR);
#ifdef Y_DUAL_STEPPER_DRIVERS #ifdef Y_DUAL_STEPPER_DRIVERS
WRITE(Y2_DIR_PIN, (INVERT_Y_DIR == INVERT_Y2_VS_Y_DIR)); Y2_DIR_WRITE((INVERT_Y_DIR == INVERT_Y2_VS_Y_DIR));
#endif #endif
count_direction[Y_AXIS]=1; count_direction[Y_AXIS]=1;
} }
CHECK_ENDSTOPS { // check X and Y Endstops CHECK_ENDSTOPS { // check X and Y Endstops
#ifndef COREXY #ifndef COREXY
if ((out_bits & (1<<X_AXIS)) != 0) // stepping along -X axis (regular cartesians bot) if ((out_bits & (1<<X_AXIS)) != 0)
#else #else
if (!((current_block->steps_x == current_block->steps_y) && ((out_bits & (1<<X_AXIS))>>X_AXIS != (out_bits & (1<<Y_AXIS))>>Y_AXIS))) // AlexBorro: If DeltaX == -DeltaY, the movement is only in Y axis if (!((current_block->steps_x == current_block->steps_y) && ((out_bits & (1<<X_AXIS))>>X_AXIS != (out_bits & (1<<Y_AXIS))>>Y_AXIS)))
if ((out_bits & (1<<X_HEAD)) != 0) if ((out_bits & (1<<X_HEAD)) != 0)
#endif #endif
{ // -direction { // -direction
...@@ -498,7 +502,7 @@ ISR(TIMER1_COMPA_vect) ...@@ -498,7 +502,7 @@ ISR(TIMER1_COMPA_vect)
#ifndef COREXY #ifndef COREXY
if ((out_bits & (1<<Y_AXIS)) != 0) // -direction if ((out_bits & (1<<Y_AXIS)) != 0) // -direction
#else #else
if (!((current_block->steps_x == current_block->steps_y) && ((out_bits & (1<<X_AXIS))>>X_AXIS == (out_bits & (1<<Y_AXIS))>>Y_AXIS))) // AlexBorro: If DeltaX == DeltaY, the movement is only in X axis if (!((current_block->steps_x == current_block->steps_y) && ((out_bits & (1<<X_AXIS))>>X_AXIS == (out_bits & (1<<Y_AXIS))>>Y_AXIS)))
if ((out_bits & (1<<Y_HEAD)) != 0) if ((out_bits & (1<<Y_HEAD)) != 0)
#endif #endif
{ // -direction { // -direction
...@@ -526,9 +530,9 @@ ISR(TIMER1_COMPA_vect) ...@@ -526,9 +530,9 @@ ISR(TIMER1_COMPA_vect)
} }
if ((out_bits & (1<<Z_AXIS)) != 0) { // -direction if ((out_bits & (1<<Z_AXIS)) != 0) { // -direction
WRITE(Z_DIR_PIN,INVERT_Z_DIR); Z_DIR_WRITE(INVERT_Z_DIR);
#ifdef Z_DUAL_STEPPER_DRIVERS #ifdef Z_DUAL_STEPPER_DRIVERS
WRITE(Z2_DIR_PIN,INVERT_Z_DIR); Z2_DIR_WRITE(INVERT_Z_DIR);
#endif #endif
count_direction[Z_AXIS]=-1; count_direction[Z_AXIS]=-1;
...@@ -545,9 +549,9 @@ ISR(TIMER1_COMPA_vect) ...@@ -545,9 +549,9 @@ ISR(TIMER1_COMPA_vect)
} }
} }
else { // +direction else { // +direction
WRITE(Z_DIR_PIN,!INVERT_Z_DIR); Z_DIR_WRITE(!INVERT_Z_DIR);
#ifdef Z_DUAL_STEPPER_DRIVERS #ifdef Z_DUAL_STEPPER_DRIVERS
WRITE(Z2_DIR_PIN,!INVERT_Z_DIR); Z2_DIR_WRITE(!INVERT_Z_DIR);
#endif #endif
count_direction[Z_AXIS]=1; count_direction[Z_AXIS]=1;
...@@ -606,117 +610,116 @@ ISR(TIMER1_COMPA_vect) ...@@ -606,117 +610,116 @@ ISR(TIMER1_COMPA_vect)
} }
#endif //ADVANCE #endif //ADVANCE
counter_x += current_block->steps_x; #ifdef CONFIG_STEPPERS_TOSHIBA
#ifdef CONFIG_STEPPERS_TOSHIBA
/* The toshiba stepper controller require much longer pulses /* The toshiba stepper controller require much longer pulses
* tjerfore we 'stage' decompose the pulses between high, and * tjerfore we 'stage' decompose the pulses between high, and
* low instead of doing each in turn. The extra tests add enough * low instead of doing each in turn. The extra tests add enough
* lag to allow it work with without needing NOPs */ * lag to allow it work with without needing NOPs
if (counter_x > 0) { */
WRITE(X_STEP_PIN, HIGH); counter_x += current_block->steps_x;
} if (counter_x > 0) X_STEP_WRITE(HIGH);
counter_y += current_block->steps_y; counter_y += current_block->steps_y;
if (counter_y > 0) { if (counter_y > 0) Y_STEP_WRITE(HIGH);
WRITE(Y_STEP_PIN, HIGH);
}
counter_z += current_block->steps_z; counter_z += current_block->steps_z;
if (counter_z > 0) { if (counter_z > 0) Z_STEP_WRITE(HIGH);
WRITE(Z_STEP_PIN, HIGH);
}
#ifndef ADVANCE #ifndef ADVANCE
counter_e += current_block->steps_e; counter_e += current_block->steps_e;
if (counter_e > 0) { if (counter_e > 0) WRITE_E_STEP(HIGH);
WRITE_E_STEP(HIGH);
}
#endif //!ADVANCE #endif //!ADVANCE
if (counter_x > 0) { if (counter_x > 0) {
counter_x -= current_block->step_event_count; counter_x -= current_block->step_event_count;
count_position[X_AXIS]+=count_direction[X_AXIS]; count_position[X_AXIS] += count_direction[X_AXIS];
WRITE(X_STEP_PIN, LOW); X_STEP_WRITE(LOW);
} }
if (counter_y > 0) { if (counter_y > 0) {
counter_y -= current_block->step_event_count; counter_y -= current_block->step_event_count;
count_position[Y_AXIS]+=count_direction[Y_AXIS]; count_position[Y_AXIS] += count_direction[Y_AXIS];
WRITE(Y_STEP_PIN, LOW); Y_STEP_WRITE( LOW);
} }
if (counter_z > 0) { if (counter_z > 0) {
counter_z -= current_block->step_event_count; counter_z -= current_block->step_event_count;
count_position[Z_AXIS]+=count_direction[Z_AXIS]; count_position[Z_AXIS] += count_direction[Z_AXIS];
WRITE(Z_STEP_PIN, LOW); Z_STEP_WRITE(LOW);
} }
#ifndef ADVANCE #ifndef ADVANCE
if (counter_e > 0) { if (counter_e > 0) {
counter_e -= current_block->step_event_count; counter_e -= current_block->step_event_count;
count_position[E_AXIS]+=count_direction[E_AXIS]; count_position[E_AXIS] += count_direction[E_AXIS];
WRITE_E_STEP(LOW); WRITE_E_STEP(LOW);
} }
#endif //!ADVANCE #endif //!ADVANCE
#else #else
counter_x += current_block->steps_x;
if (counter_x > 0) { if (counter_x > 0) {
#ifdef DUAL_X_CARRIAGE #ifdef DUAL_X_CARRIAGE
if (extruder_duplication_enabled){ if (extruder_duplication_enabled){
WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); X_STEP_WRITE(!INVERT_X_STEP_PIN);
WRITE(X2_STEP_PIN, !INVERT_X_STEP_PIN); X2_STEP_WRITE( !INVERT_X_STEP_PIN);
} }
else { else {
if (current_block->active_driver != 0) if (current_block->active_driver != 0)
WRITE(X2_STEP_PIN, !INVERT_X_STEP_PIN); X2_STEP_WRITE( !INVERT_X_STEP_PIN);
else else
WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); X_STEP_WRITE(!INVERT_X_STEP_PIN);
} }
#else #else
WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); X_STEP_WRITE(!INVERT_X_STEP_PIN);
#endif #endif
counter_x -= current_block->step_event_count; counter_x -= current_block->step_event_count;
count_position[X_AXIS]+=count_direction[X_AXIS]; count_position[X_AXIS] += count_direction[X_AXIS];
#ifdef DUAL_X_CARRIAGE #ifdef DUAL_X_CARRIAGE
if (extruder_duplication_enabled) { if (extruder_duplication_enabled){
WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); X_STEP_WRITE(INVERT_X_STEP_PIN);
WRITE(X2_STEP_PIN, INVERT_X_STEP_PIN); X2_STEP_WRITE(INVERT_X_STEP_PIN);
} }
else { else {
if (current_block->active_driver != 0) if (current_block->active_driver != 0)
WRITE(X2_STEP_PIN, INVERT_X_STEP_PIN); X2_STEP_WRITE(INVERT_X_STEP_PIN);
else else
WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); X_STEP_WRITE(INVERT_X_STEP_PIN);
} }
#else #else
WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); X_STEP_WRITE(INVERT_X_STEP_PIN);
#endif #endif
} }
counter_y += current_block->steps_y; counter_y += current_block->steps_y;
if (counter_y > 0) { if (counter_y > 0) {
WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); Y_STEP_WRITE(!INVERT_Y_STEP_PIN);
#ifdef Y_DUAL_STEPPER_DRIVERS #ifdef Y_DUAL_STEPPER_DRIVERS
WRITE(Y2_STEP_PIN, !INVERT_Y_STEP_PIN); Y2_STEP_WRITE( !INVERT_Y_STEP_PIN);
#endif #endif
counter_y -= current_block->step_event_count; counter_y -= current_block->step_event_count;
count_position[Y_AXIS]+=count_direction[Y_AXIS]; count_position[Y_AXIS] += count_direction[Y_AXIS];
WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); Y_STEP_WRITE(INVERT_Y_STEP_PIN);
#ifdef Y_DUAL_STEPPER_DRIVERS #ifdef Y_DUAL_STEPPER_DRIVERS
WRITE(Y2_STEP_PIN, INVERT_Y_STEP_PIN); Y2_STEP_WRITE( INVERT_Y_STEP_PIN);
#endif #endif
} }
counter_z += current_block->steps_z; counter_z += current_block->steps_z;
if (counter_z > 0) { if (counter_z > 0) {
WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); Z_STEP_WRITE( !INVERT_Z_STEP_PIN);
#ifdef Z_DUAL_STEPPER_DRIVERS #ifdef Z_DUAL_STEPPER_DRIVERS
WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN); Z2_STEP_WRITE(!INVERT_Z_STEP_PIN);
#endif #endif
counter_z -= current_block->step_event_count; counter_z -= current_block->step_event_count;
count_position[Z_AXIS]+=count_direction[Z_AXIS]; count_position[Z_AXIS] += count_direction[Z_AXIS];
WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN); Z_STEP_WRITE( INVERT_Z_STEP_PIN);
#ifdef Z_DUAL_STEPPER_DRIVERS #ifdef Z_DUAL_STEPPER_DRIVERS
WRITE(Z2_STEP_PIN, INVERT_Z_STEP_PIN); Z2_STEP_WRITE(INVERT_Z_STEP_PIN);
#endif #endif
} }
...@@ -725,11 +728,11 @@ ISR(TIMER1_COMPA_vect) ...@@ -725,11 +728,11 @@ ISR(TIMER1_COMPA_vect)
if (counter_e > 0) { if (counter_e > 0) {
WRITE_E_STEP(!INVERT_E_STEP_PIN); WRITE_E_STEP(!INVERT_E_STEP_PIN);
counter_e -= current_block->step_event_count; counter_e -= current_block->step_event_count;
count_position[E_AXIS]+=count_direction[E_AXIS]; count_position[E_AXIS] += count_direction[E_AXIS];
WRITE_E_STEP(INVERT_E_STEP_PIN); WRITE_E_STEP(INVERT_E_STEP_PIN);
} }
#endif //!ADVANCE #endif //!ADVANCE
#endif // CONFIG_STEPPERS_TOSHIBA #endif // CONFIG_STEPPERS_TOSHIBA
step_events_completed += 1; step_events_completed += 1;
if(step_events_completed >= current_block->step_event_count) break; if(step_events_completed >= current_block->step_event_count) break;
} }
...@@ -812,60 +815,60 @@ ISR(TIMER1_COMPA_vect) ...@@ -812,60 +815,60 @@ ISR(TIMER1_COMPA_vect)
// Set E direction (Depends on E direction + advance) // Set E direction (Depends on E direction + advance)
for(unsigned char i=0; i<4;i++) { for(unsigned char i=0; i<4;i++) {
if (e_steps[0] != 0) { if (e_steps[0] != 0) {
WRITE(E0_STEP_PIN, INVERT_E_STEP_PIN); E0_STEP_WRITE( INVERT_E_STEP_PIN);
if (e_steps[0] < 0) { if (e_steps[0] < 0) {
WRITE(E0_DIR_PIN, INVERT_E0_DIR); E0_DIR_WRITE(INVERT_E0_DIR);
e_steps[0]++; e_steps[0]++;
WRITE(E0_STEP_PIN, !INVERT_E_STEP_PIN); E0_STEP_WRITE(!INVERT_E_STEP_PIN);
} }
else if (e_steps[0] > 0) { else if (e_steps[0] > 0) {
WRITE(E0_DIR_PIN, !INVERT_E0_DIR); E0_DIR_WRITE(!INVERT_E0_DIR);
e_steps[0]--; e_steps[0]--;
WRITE(E0_STEP_PIN, !INVERT_E_STEP_PIN); E0_STEP_WRITE(!INVERT_E_STEP_PIN);
} }
} }
#if DRIVER_EXTRUDERS > 1 #if DRIVER_EXTRUDERS > 1
if (e_steps[1] != 0) { if (e_steps[1] != 0) {
WRITE(E1_STEP_PIN, INVERT_E_STEP_PIN); E1_STEP_WRITE(INVERT_E_STEP_PIN);
if (e_steps[1] < 0) { if (e_steps[1] < 0) {
WRITE(E1_DIR_PIN, INVERT_E1_DIR); E1_DIR_WRITE(INVERT_E1_DIR);
e_steps[1]++; e_steps[1]++;
WRITE(E1_STEP_PIN, !INVERT_E_STEP_PIN); E1_STEP_WRITE(!INVERT_E_STEP_PIN);
} }
else if (e_steps[1] > 0) { else if (e_steps[1] > 0) {
WRITE(E1_DIR_PIN, !INVERT_E1_DIR); E1_DIR_WRITE(!INVERT_E1_DIR);
e_steps[1]--; e_steps[1]--;
WRITE(E1_STEP_PIN, !INVERT_E_STEP_PIN); E1_STEP_WRITE(!INVERT_E_STEP_PIN);
} }
} }
#endif #endif
#if DRIVER_EXTRUDERS > 2 #if DRIVER_EXTRUDERS > 2
if (e_steps[2] != 0) { if (e_steps[2] != 0) {
WRITE(E2_STEP_PIN, INVERT_E_STEP_PIN); E2_STEP_WRITE(INVERT_E_STEP_PIN);
if (e_steps[2] < 0) { if (e_steps[2] < 0) {
WRITE(E2_DIR_PIN, INVERT_E2_DIR); E2_DIR_WRITE(INVERT_E2_DIR);
e_steps[2]++; e_steps[2]++;
WRITE(E2_STEP_PIN, !INVERT_E_STEP_PIN); E2_STEP_WRITE(!INVERT_E_STEP_PIN);
} }
else if (e_steps[2] > 0) { else if (e_steps[2] > 0) {
WRITE(E2_DIR_PIN, !INVERT_E2_DIR); E2_DIR_WRITE(!INVERT_E2_DIR);
e_steps[2]--; e_steps[2]--;
WRITE(E2_STEP_PIN, !INVERT_E_STEP_PIN); E2_STEP_WRITE(!INVERT_E_STEP_PIN);
} }
} }
#endif #endif
#if DRIVER_EXTRUDERS > 3 #if DRIVER_EXTRUDERS > 3
if (e_steps[3] != 0) { if (e_steps[3] != 0) {
WRITE(E3_STEP_PIN, INVERT_E_STEP_PIN); E3_STEP_WRITE(INVERT_E_STEP_PIN);
if (e_steps[3] < 0) { if (e_steps[3] < 0) {
WRITE(E3_DIR_PIN, INVERT_E3_DIR); E3_DIR_WRITE(INVERT_E3_DIR);
e_steps[3]++; e_steps[3]++;
WRITE(E3_STEP_PIN, !INVERT_E_STEP_PIN); E3_STEP_WRITE(!INVERT_E_STEP_PIN);
} }
else if (e_steps[3] > 0) { else if (e_steps[3] > 0) {
WRITE(E3_DIR_PIN, !INVERT_E3_DIR); E3_DIR_WRITE(!INVERT_E3_DIR);
e_steps[3]--; e_steps[3]--;
WRITE(E3_STEP_PIN, !INVERT_E_STEP_PIN); E3_STEP_WRITE(!INVERT_E_STEP_PIN);
} }
} }
#endif #endif
...@@ -879,83 +882,91 @@ void st_init() ...@@ -879,83 +882,91 @@ void st_init()
digipot_init(); //Initialize Digipot Motor Current digipot_init(); //Initialize Digipot Motor Current
microstep_init(); //Initialize Microstepping Pins microstep_init(); //Initialize Microstepping Pins
// initialise TMC Steppers
#ifdef HAVE_TMCDRIVER
tmc_init();
#endif
// initialise L6470 Steppers
#ifdef HAVE_L6470DRIVER
L6470_init();
#endif
//Initialize Dir Pins //Initialize Dir Pins
#if defined(X_DIR_PIN) && X_DIR_PIN > -1 #if defined(X_DIR_PIN) && X_DIR_PIN > -1
SET_OUTPUT(X_DIR_PIN); X_DIR_INIT;
#endif #endif
#if defined(X2_DIR_PIN) && X2_DIR_PIN > -1 #if defined(X2_DIR_PIN) && X2_DIR_PIN > -1
SET_OUTPUT(X2_DIR_PIN); X2_DIR_INIT;
#endif #endif
#if defined(Y_DIR_PIN) && Y_DIR_PIN > -1 #if defined(Y_DIR_PIN) && Y_DIR_PIN > -1
SET_OUTPUT(Y_DIR_PIN); Y_DIR_INIT;
#if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_DIR_PIN) && (Y2_DIR_PIN > -1) #if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_DIR_PIN) && (Y2_DIR_PIN > -1)
SET_OUTPUT(Y2_DIR_PIN); Y2_DIR_INIT;
#endif #endif
#endif #endif
#if defined(Z_DIR_PIN) && Z_DIR_PIN > -1 #if defined(Z_DIR_PIN) && Z_DIR_PIN > -1
SET_OUTPUT(Z_DIR_PIN); Z_DIR_INIT;
#if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_DIR_PIN) && (Z2_DIR_PIN > -1) #if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_DIR_PIN) && (Z2_DIR_PIN > -1)
SET_OUTPUT(Z2_DIR_PIN); Z2_DIR_INIT;
#endif #endif
#endif #endif
#if defined(E0_DIR_PIN) && E0_DIR_PIN > -1 #if defined(E0_DIR_PIN) && E0_DIR_PIN > -1
SET_OUTPUT(E0_DIR_PIN); E0_DIR_INIT;
#endif #endif
#if defined(E1_DIR_PIN) && (E1_DIR_PIN > -1) #if defined(E1_DIR_PIN) && (E1_DIR_PIN > -1)
SET_OUTPUT(E1_DIR_PIN); E1_DIR_INIT;
#endif #endif
#if defined(E2_DIR_PIN) && (E2_DIR_PIN > -1) #if defined(E2_DIR_PIN) && (E2_DIR_PIN > -1)
SET_OUTPUT(E2_DIR_PIN); E2_DIR_INIT;
#endif #endif
#if defined(E3_DIR_PIN) && (E3_DIR_PIN > -1) #if defined(E3_DIR_PIN) && (E3_DIR_PIN > -1)
SET_OUTPUT(E3_DIR_PIN); E3_DIR_INIT;
#endif #endif
//Initialize Enable Pins - steppers default to disabled. //Initialize Enable Pins - steppers default to disabled.
#if defined(X_ENABLE_PIN) && X_ENABLE_PIN > -1 #if defined(X_ENABLE_PIN) && X_ENABLE_PIN > -1
SET_OUTPUT(X_ENABLE_PIN); X_ENABLE_INIT;
if(!X_ENABLE_ON) WRITE(X_ENABLE_PIN,HIGH); if(!X_ENABLE_ON) X_ENABLE_WRITE(HIGH);
#endif #endif
#if defined(X2_ENABLE_PIN) && X2_ENABLE_PIN > -1 #if defined(X2_ENABLE_PIN) && X2_ENABLE_PIN > -1
SET_OUTPUT(X2_ENABLE_PIN); X2_ENABLE_INIT;
if(!X_ENABLE_ON) WRITE(X2_ENABLE_PIN,HIGH); if(!X_ENABLE_ON) X2_ENABLE_WRITE(HIGH);
#endif #endif
#if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1 #if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1
SET_OUTPUT(Y_ENABLE_PIN); Y_ENABLE_INIT;
if(!Y_ENABLE_ON) WRITE(Y_ENABLE_PIN,HIGH); if(!Y_ENABLE_ON) Y_ENABLE_WRITE(HIGH);
#if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_ENABLE_PIN) && (Y2_ENABLE_PIN > -1) #if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_ENABLE_PIN) && (Y2_ENABLE_PIN > -1)
SET_OUTPUT(Y2_ENABLE_PIN); Y2_ENABLE_INIT;
if(!Y_ENABLE_ON) WRITE(Y2_ENABLE_PIN,HIGH); if(!Y_ENABLE_ON) Y2_ENABLE_WRITE(HIGH);
#endif #endif
#endif #endif
#if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN > -1 #if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN > -1
SET_OUTPUT(Z_ENABLE_PIN); Z_ENABLE_INIT;
if(!Z_ENABLE_ON) WRITE(Z_ENABLE_PIN,HIGH); if(!Z_ENABLE_ON) Z_ENABLE_WRITE(HIGH);
#if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_ENABLE_PIN) && (Z2_ENABLE_PIN > -1) #if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_ENABLE_PIN) && (Z2_ENABLE_PIN > -1)
SET_OUTPUT(Z2_ENABLE_PIN); Z2_ENABLE_INIT;
if(!Z_ENABLE_ON) WRITE(Z2_ENABLE_PIN,HIGH); if(!Z_ENABLE_ON) Z2_ENABLE_WRITE(HIGH);
#endif #endif
#endif #endif
#if defined(E0_ENABLE_PIN) && (E0_ENABLE_PIN > -1) #if defined(E0_ENABLE_PIN) && (E0_ENABLE_PIN > -1)
SET_OUTPUT(E0_ENABLE_PIN); E0_ENABLE_INIT;
if(!E_ENABLE_ON) WRITE(E0_ENABLE_PIN,HIGH); if(!E_ENABLE_ON) E0_ENABLE_WRITE(HIGH);
#endif #endif
#if defined(E1_ENABLE_PIN) && (E1_ENABLE_PIN > -1) #if defined(E1_ENABLE_PIN) && (E1_ENABLE_PIN > -1)
SET_OUTPUT(E1_ENABLE_PIN); E1_ENABLE_INIT;
if(!E_ENABLE_ON) WRITE(E1_ENABLE_PIN,HIGH); if(!E_ENABLE_ON) E1_ENABLE_WRITE(HIGH);
#endif #endif
#if defined(E2_ENABLE_PIN) && (E2_ENABLE_PIN > -1) #if defined(E2_ENABLE_PIN) && (E2_ENABLE_PIN > -1)
SET_OUTPUT(E2_ENABLE_PIN); E2_ENABLE_INIT;
if(!E_ENABLE_ON) WRITE(E2_ENABLE_PIN,HIGH); if(!E_ENABLE_ON) E2_ENABLE_WRITE(HIGH);
#endif #endif
#if defined(E3_ENABLE_PIN) && (E3_ENABLE_PIN > -1) #if defined(E3_ENABLE_PIN) && (E3_ENABLE_PIN > -1)
SET_OUTPUT(E3_ENABLE_PIN); E3_ENABLE_INIT;
if(!E_ENABLE_ON) WRITE(E3_ENABLE_PIN,HIGH); if(!E_ENABLE_ON) E3_ENABLE_WRITE(HIGH);
#endif #endif
//Choice E0-E1 or E0-E2 or E1-E3 pin //Choice E0-E1 or E0-E2 or E1-E3 pin
...@@ -1023,41 +1034,51 @@ void st_init() ...@@ -1023,41 +1034,51 @@ void st_init()
//Initialize Step Pins //Initialize Step Pins
#if defined(X_STEP_PIN) && (X_STEP_PIN > -1) #if defined(X_STEP_PIN) && (X_STEP_PIN > -1)
OUT_WRITE(X_STEP_PIN,INVERT_X_STEP_PIN); X_STEP_INIT;
X_STEP_WRITE(INVERT_X_STEP_PIN);
disable_x(); disable_x();
#endif #endif
#if defined(X2_STEP_PIN) && (X2_STEP_PIN > -1) #if defined(X2_STEP_PIN) && (X2_STEP_PIN > -1)
OUT_WRITE(X2_STEP_PIN,INVERT_X_STEP_PIN); X2_STEP_INIT;
X2_STEP_WRITE(INVERT_X_STEP_PIN);
disable_x(); disable_x();
#endif #endif
#if defined(Y_STEP_PIN) && (Y_STEP_PIN > -1) #if defined(Y_STEP_PIN) && (Y_STEP_PIN > -1)
OUT_WRITE(Y_STEP_PIN,INVERT_Y_STEP_PIN); Y_STEP_INIT;
Y_STEP_WRITE(INVERT_Y_STEP_PIN);
#if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_STEP_PIN) && (Y2_STEP_PIN > -1) #if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_STEP_PIN) && (Y2_STEP_PIN > -1)
OUT_WRITE(Y2_STEP_PIN,INVERT_Y_STEP_PIN); Y2_STEP_INIT;
Y2_STEP_WRITE(INVERT_Y_STEP_PIN);
#endif #endif
disable_y(); disable_y();
#endif #endif
#if defined(Z_STEP_PIN) && (Z_STEP_PIN > -1) #if defined(Z_STEP_PIN) && (Z_STEP_PIN > -1)
OUT_WRITE(Z_STEP_PIN,INVERT_Z_STEP_PIN); Z_STEP_INIT;
Z_STEP_WRITE(INVERT_Z_STEP_PIN);
#if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_STEP_PIN) && (Z2_STEP_PIN > -1) #if defined(Z_DUAL_STEPPER_DRIVERS) && defined(Z2_STEP_PIN) && (Z2_STEP_PIN > -1)
OUT_WRITE(Z2_STEP_PIN,INVERT_Z_STEP_PIN); Z2_STEP_INIT;
Z2_STEP_WRITE(INVERT_Z_STEP_PIN);
#endif #endif
disable_z(); disable_z();
#endif #endif
#if defined(E0_STEP_PIN) && (E0_STEP_PIN > -1) #if defined(E0_STEP_PIN) && (E0_STEP_PIN > -1)
OUT_WRITE(E0_STEP_PIN,INVERT_E_STEP_PIN); E0_STEP_INIT;
E0_STEP_WRITE(INVERT_E_STEP_PIN);
disable_e0(); disable_e0();
#endif #endif
#if defined(E1_STEP_PIN) && (E1_STEP_PIN > -1) #if defined(E1_STEP_PIN) && (E1_STEP_PIN > -1)
OUT_WRITE(E1_STEP_PIN,INVERT_E_STEP_PIN); E1_STEP_INIT;
E1_STEP_WRITE(INVERT_E_STEP_PIN);
disable_e1(); disable_e1();
#endif #endif
#if defined(E2_STEP_PIN) && (E2_STEP_PIN > -1) #if defined(E2_STEP_PIN) && (E2_STEP_PIN > -1)
OUT_WRITE(E2_STEP_PIN,INVERT_E_STEP_PIN); E2_STEP_INIT;
E2_STEP_WRITE(INVERT_E_STEP_PIN);
disable_e2(); disable_e2();
#endif #endif
#if defined(E3_STEP_PIN) && (E3_STEP_PIN > -1) #if defined(E3_STEP_PIN) && (E3_STEP_PIN > -1)
OUT_WRITE(E3_STEP_PIN,INVERT_E_STEP_PIN); E3_STEP_INIT;
E3_STEP_WRITE(INVERT_E_STEP_PIN);
disable_e3(); disable_e3();
#endif #endif
...@@ -1189,31 +1210,31 @@ void babystep(const uint8_t axis,const bool direction) ...@@ -1189,31 +1210,31 @@ void babystep(const uint8_t axis,const bool direction)
case X_AXIS: case X_AXIS:
{ {
enable_x(); enable_x();
uint8_t old_x_dir_pin= READ(X_DIR_PIN); //if dualzstepper, both point to same direction. uint8_t old_x_dir_pin= X_DIR_READ; //if dualzstepper, both point to same direction.
//setup new step //setup new step
WRITE(X_DIR_PIN,(INVERT_X_DIR)^direction); X_DIR_WRITE((INVERT_X_DIR)^direction);
#ifdef DUAL_X_CARRIAGE #ifdef DUAL_X_CARRIAGE
WRITE(X2_DIR_PIN,(INVERT_X_DIR)^direction); X2_DIR_WRITE((INVERT_X_DIR)^direction);
#endif #endif
//perform step //perform step
WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); X_STEP_WRITE(!INVERT_X_STEP_PIN);
#ifdef DUAL_X_CARRIAGE #ifdef DUAL_X_CARRIAGE
WRITE(X2_STEP_PIN, !INVERT_X_STEP_PIN); X2_STEP_WRITE(!INVERT_X_STEP_PIN);
#endif #endif
_delay_us(1U); // wait 1 microsecond _delay_us(1U); // wait 1 microsecond
WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); X_STEP_WRITE(INVERT_X_STEP_PIN);
#ifdef DUAL_X_CARRIAGE #ifdef DUAL_X_CARRIAGE
WRITE(X2_STEP_PIN, INVERT_X_STEP_PIN); X2_STEP_WRITE(INVERT_X_STEP_PIN);
#endif #endif
//get old pin state back. //get old pin state back.
WRITE(X_DIR_PIN,old_x_dir_pin); X_DIR_WRITE(old_x_dir_pin);
#ifdef DUAL_X_CARRIAGE #ifdef DUAL_X_CARRIAGE
WRITE(X2_DIR_PIN,old_x_dir_pin); X2_DIR_WRITE(old_x_dir_pin);
#endif #endif
} }
...@@ -1221,31 +1242,31 @@ void babystep(const uint8_t axis,const bool direction) ...@@ -1221,31 +1242,31 @@ void babystep(const uint8_t axis,const bool direction)
case Y_AXIS: case Y_AXIS:
{ {
enable_y(); enable_y();
uint8_t old_y_dir_pin= READ(Y_DIR_PIN); //if dualzstepper, both point to same direction. uint8_t old_y_dir_pin= Y_DIR_READ; //if dualzstepper, both point to same direction.
//setup new step //setup new step
WRITE(Y_DIR_PIN,(INVERT_Y_DIR)^direction); Y_DIR_WRITE((INVERT_Y_DIR)^direction);
#ifdef DUAL_Y_CARRIAGE #ifdef DUAL_Y_CARRIAGE
WRITE(Y2_DIR_PIN,(INVERT_Y_DIR)^direction); Y2_DIR_WRITE((INVERT_Y_DIR)^direction);
#endif #endif
//perform step //perform step
WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); Y_STEP_WRITE(!INVERT_Y_STEP_PIN);
#ifdef DUAL_Y_CARRIAGE #ifdef DUAL_Y_CARRIAGE
WRITE(Y2_STEP_PIN, !INVERT_Y_STEP_PIN); Y2_STEP_WRITE( !INVERT_Y_STEP_PIN);
#endif #endif
_delay_us(1U); // wait 1 microsecond _delay_us(1U); // wait 1 microsecond
WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); Y_STEP_WRITE(INVERT_Y_STEP_PIN);
#ifdef DUAL_Y_CARRIAGE #ifdef DUAL_Y_CARRIAGE
WRITE(Y2_STEP_PIN, INVERT_Y_STEP_PIN); Y2_STEP_WRITE(INVERT_Y_STEP_PIN);
#endif #endif
//get old pin state back. //get old pin state back.
WRITE(Y_DIR_PIN,old_y_dir_pin); Y_DIR_WRITE(old_y_dir_pin);
#ifdef DUAL_Y_CARRIAGE #ifdef DUAL_Y_CARRIAGE
WRITE(Y2_DIR_PIN,old_y_dir_pin); Y2_DIR_WRITE(old_y_dir_pin);
#endif #endif
} }
...@@ -1255,29 +1276,29 @@ void babystep(const uint8_t axis,const bool direction) ...@@ -1255,29 +1276,29 @@ void babystep(const uint8_t axis,const bool direction)
case Z_AXIS: case Z_AXIS:
{ {
enable_z(); enable_z();
uint8_t old_z_dir_pin= READ(Z_DIR_PIN); //if dualzstepper, both point to same direction. uint8_t old_z_dir_pin= Z_DIR_READ; //if dualzstepper, both point to same direction.
//setup new step //setup new step
WRITE(Z_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z); Z_DIR_WRITE((INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z);
#ifdef Z_DUAL_STEPPER_DRIVERS #ifdef Z_DUAL_STEPPER_DRIVERS
WRITE(Z2_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z); Z2_DIR_WRITE((INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z);
#endif #endif
//perform step //perform step
WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); Z_STEP_WRITE(!INVERT_Z_STEP_PIN);
#ifdef Z_DUAL_STEPPER_DRIVERS #ifdef Z_DUAL_STEPPER_DRIVERS
WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN); Z2_STEP_WRITE( !INVERT_Z_STEP_PIN);
#endif #endif
_delay_us(1U); // wait 1 microsecond _delay_us(1U); // wait 1 microsecond
WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN); Z_STEP_WRITE( INVERT_Z_STEP_PIN);
#ifdef Z_DUAL_STEPPER_DRIVERS #ifdef Z_DUAL_STEPPER_DRIVERS
WRITE(Z2_STEP_PIN, INVERT_Z_STEP_PIN); Z2_STEP_WRITE(INVERT_Z_STEP_PIN);
#endif #endif
//get old pin state back. //get old pin state back.
WRITE(Z_DIR_PIN,old_z_dir_pin); Z_DIR_WRITE(old_z_dir_pin);
#ifdef Z_DUAL_STEPPER_DRIVERS #ifdef Z_DUAL_STEPPER_DRIVERS
WRITE(Z2_DIR_PIN,old_z_dir_pin); Z2_DIR_WRITE(old_z_dir_pin);
#endif #endif
} }
...@@ -1288,29 +1309,29 @@ void babystep(const uint8_t axis,const bool direction) ...@@ -1288,29 +1309,29 @@ void babystep(const uint8_t axis,const bool direction)
enable_x(); enable_x();
enable_y(); enable_y();
enable_z(); enable_z();
uint8_t old_x_dir_pin= READ(X_DIR_PIN); uint8_t old_x_dir_pin= X_DIR_READ;
uint8_t old_y_dir_pin= READ(Y_DIR_PIN); uint8_t old_y_dir_pin= Y_DIR_READ;
uint8_t old_z_dir_pin= READ(Z_DIR_PIN); uint8_t old_z_dir_pin= Z_DIR_READ;
//setup new step //setup new step
WRITE(X_DIR_PIN,(INVERT_X_DIR)^direction^BABYSTEP_INVERT_Z); X_DIR_WRITE((INVERT_X_DIR)^direction^BABYSTEP_INVERT_Z);
WRITE(Y_DIR_PIN,(INVERT_Y_DIR)^direction^BABYSTEP_INVERT_Z); Y_DIR_WRITE((INVERT_Y_DIR)^direction^BABYSTEP_INVERT_Z);
WRITE(Z_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z); Z_DIR_WRITE((INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z);
//perform step //perform step
WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); X_STEP_WRITE( !INVERT_X_STEP_PIN);
WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); Y_STEP_WRITE(!INVERT_Y_STEP_PIN);
WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); Z_STEP_WRITE(!INVERT_Z_STEP_PIN);
_delay_us(1U); // wait 1 microsecond _delay_us(1U); // wait 1 microsecond
WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); X_STEP_WRITE(INVERT_X_STEP_PIN);
WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); Y_STEP_WRITE(INVERT_Y_STEP_PIN);
WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN); Z_STEP_WRITE(INVERT_Z_STEP_PIN);
//get old pin state back. //get old pin state back.
WRITE(X_DIR_PIN,old_x_dir_pin); X_DIR_WRITE(old_x_dir_pin);
WRITE(Y_DIR_PIN,old_y_dir_pin); Y_DIR_WRITE(old_y_dir_pin);
WRITE(Z_DIR_PIN,old_z_dir_pin); Z_DIR_WRITE(old_z_dir_pin);
} }
break; break;
......
...@@ -22,30 +22,31 @@ ...@@ -22,30 +22,31 @@
#define stepper_h #define stepper_h
#include "planner.h" #include "planner.h"
#include "stepper_indirection.h"
#if DRIVER_EXTRUDERS > 3 #if DRIVER_EXTRUDERS > 3
#define WRITE_E_STEP(v) { if(current_block->active_driver == 3) { WRITE(E3_STEP_PIN, v); } else { if(current_block->active_driver == 2) { WRITE(E2_STEP_PIN, v); } else { if(current_block->active_driver == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }}}} #define WRITE_E_STEP(v) { if(current_block->active_driver == 3) { E3_STEP_WRITE(v); } else { if(current_block->active_driver == 2) { E2_STEP_WRITE(v); } else { if(current_block->active_driver == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}}}
#define NORM_E_DIR() { if(current_block->active_driver == 3) { WRITE(E3_DIR_PIN, !INVERT_E3_DIR); } else { if(current_block->active_driver == 2) { WRITE(E2_DIR_PIN, !INVERT_E2_DIR); } else { if(current_block->active_driver == 1) { WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }}}} #define NORM_E_DIR() { if(current_block->active_driver == 3) { E3_DIR_WRITE( !INVERT_E3_DIR); } else { if(current_block->active_driver == 2) { E2_DIR_WRITE(!INVERT_E2_DIR); } else { if(current_block->active_driver == 1) { E1_DIR_WRITE(!INVERT_E1_DIR); } else { E0_DIR_WRITE(!INVERT_E0_DIR); }}}}
#define REV_E_DIR() { if(current_block->active_driver == 3) { WRITE(E3_DIR_PIN, INVERT_E3_DIR); } else { if(current_block->active_driver == 2) { WRITE(E2_DIR_PIN, INVERT_E2_DIR); } else { if(current_block->active_driver == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }}}} #define REV_E_DIR() { if(current_block->active_driver == 3) { E3_DIR_WRITE(INVERT_E3_DIR); } else { if(current_block->active_driver == 2) { E2_DIR_WRITE(INVERT_E2_DIR); } else { if(current_block->active_driver == 1) { E1_DIR_WRITE(INVERT_E1_DIR); } else { E0_DIR_WRITE(INVERT_E0_DIR); }}}}
#elif DRIVER_EXTRUDERS > 2 #elif DRIVER_EXTRUDERS > 2
#define WRITE_E_STEP(v) { if(current_block->active_driver == 2) { WRITE(E2_STEP_PIN, v); } else { if(current_block->active_driver == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }}} #define WRITE_E_STEP(v) { if(current_block->active_driver == 2) { E2_STEP_WRITE(v); } else { if(current_block->active_driver == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}}
#define NORM_E_DIR() { if(current_block->active_driver == 2) { WRITE(E2_DIR_PIN, !INVERT_E2_DIR); } else { if(current_block->active_driver == 1) { WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }}} #define NORM_E_DIR() { if(current_block->active_driver == 2) { E2_DIR_WRITE(!INVERT_E2_DIR); } else { if(current_block->active_driver == 1) { E1_DIR_WRITE(!INVERT_E1_DIR); } else { E0_DIR_WRITE(!INVERT_E0_DIR); }}}
#define REV_E_DIR() { if(current_block->active_driver == 2) { WRITE(E2_DIR_PIN, INVERT_E2_DIR); } else { if(current_block->active_driver == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }}} #define REV_E_DIR() { if(current_block->active_driver == 2) { E2_DIR_WRITE(INVERT_E2_DIR); } else { if(current_block->active_driver == 1) { E1_DIR_WRITE(INVERT_E1_DIR); } else { E0_DIR_WRITE(INVERT_E0_DIR); }}}
#elif DRIVER_EXTRUDERS > 1 #elif DRIVER_EXTRUDERS > 1
#ifndef DUAL_X_CARRIAGE #ifndef DUAL_X_CARRIAGE
#define WRITE_E_STEP(v) { if(current_block->active_driver == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }} #define WRITE_E_STEP(v) { if(current_block->active_driver == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}
#define NORM_E_DIR() { if(current_block->active_driver == 1) { WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }} #define NORM_E_DIR() { if(current_block->active_driver == 1) { E1_DIR_WRITE(!INVERT_E1_DIR); } else { E0_DIR_WRITE(!INVERT_E0_DIR); }}
#define REV_E_DIR() { if(current_block->active_driver == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }} #define REV_E_DIR() { if(current_block->active_driver == 1) { E1_DIR_WRITE(INVERT_E1_DIR); } else { E0_DIR_WRITE(INVERT_E0_DIR); }}
#else #else
extern bool extruder_duplication_enabled; extern bool extruder_duplication_enabled;
#define WRITE_E_STEP(v) { if(extruder_duplication_enabled) { WRITE(E0_STEP_PIN, v); WRITE(E1_STEP_PIN, v); } else if(current_block->active_driver == 1) { WRITE(E1_STEP_PIN, v); } else { WRITE(E0_STEP_PIN, v); }} #define WRITE_E_STEP(v) { if(extruder_duplication_enabled) { E0_STEP_WRITE(v); E1_STEP_WRITE(v); } else if(current_block->active_driver == 1) { E1_STEP_WRITE(v); } else { E0_STEP_WRITE(v); }}
#define NORM_E_DIR() { if(extruder_duplication_enabled) { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else if(current_block->active_driver == 1) { WRITE(E1_DIR_PIN, !INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, !INVERT_E0_DIR); }} #define NORM_E_DIR() { if(extruder_duplication_enabled) { E0_DIR_WRITE(!INVERT_E0_DIR); E1_DIR_WRITE(!INVERT_E1_DIR); } else if(current_block->active_driver == 1) { E1_DIR_WRITE(!INVERT_E1_DIR); } else { E0_DIR_WRITE(!INVERT_E0_DIR); }}
#define REV_E_DIR() { if(extruder_duplication_enabled) { WRITE(E0_DIR_PIN, INVERT_E0_DIR); WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else if(current_block->active_driver == 1) { WRITE(E1_DIR_PIN, INVERT_E1_DIR); } else { WRITE(E0_DIR_PIN, INVERT_E0_DIR); }} #define REV_E_DIR() { if(extruder_duplication_enabled) { E0_DIR_WRITE(INVERT_E0_DIR); E1_DIR_WRITE(INVERT_E1_DIR); } else if(current_block->active_driver == 1) { E1_DIR_WRITE(INVERT_E1_DIR); } else { E0_DIR_WRITE(INVERT_E0_DIR); }}
#endif //DUAL_X_CARRIAGE #endif
#else #else
#define WRITE_E_STEP(v) WRITE(E0_STEP_PIN, v) #define WRITE_E_STEP(v) E0_STEP_WRITE(v)
#define NORM_E_DIR() WRITE(E0_DIR_PIN, !INVERT_E0_DIR) #define NORM_E_DIR() E0_DIR_WRITE(!INVERT_E0_DIR)
#define REV_E_DIR() WRITE(E0_DIR_PIN, INVERT_E0_DIR) #define REV_E_DIR() E0_DIR_WRITE(INVERT_E0_DIR)
#endif //DRIVER_EXTRUDERS #endif //DRIVER_EXTRUDERS
#ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED #ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
......
/*
stepper_indirection.c - stepper motor driver indirection
to allow some stepper functions to be done via SPI/I2c instead of direct pin manipulation
Part of Marlin
Copyright (c) 2015 Dominik Wenger
Marlin 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.
Marlin 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 Marlin. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stepper_indirection.h"
#include "Configuration.h"
#ifdef HAVE_TMCDRIVER
#include <SPI.h>
#include <TMC26XStepper.h>
#endif
// Stepper objects of TMC steppers used
#ifdef X_IS_TMC
TMC26XStepper stepperX(200,X_ENABLE_PIN,X_STEP_PIN,X_DIR_PIN,X_MAX_CURRENT,X_SENSE_RESISTOR);
#endif
#ifdef X2_IS_TMC
TMC26XStepper stepperX2(200,X2_ENABLE_PIN,X2_STEP_PIN,X2_DIR_PIN,X2_MAX_CURRENT,X2_SENSE_RESISTOR);
#endif
#ifdef Y_IS_TMC
TMC26XStepper stepperY(200,Y_ENABLE_PIN,Y_STEP_PIN,Y_DIR_PIN,Y_MAX_CURRENT,Y_SENSE_RESISTOR);
#endif
#ifdef Y2_IS_TMC
TMC26XStepper stepperY2(200,Y2_ENABLE_PIN,Y2_STEP_PIN,Y2_DIR_PIN,Y2_MAX_CURRENT,Y2_SENSE_RESISTOR);
#endif
#ifdef Z_IS_TMC
TMC26XStepper stepperZ(200,Z_ENABLE_PIN,Z_STEP_PIN,Z_DIR_PIN,Z_MAX_CURRENT,Z_SENSE_RESISTOR);
#endif
#ifdef Z2_IS_TMC
TMC26XStepper stepperZ2(200,Z2_ENABLE_PIN,Z2_STEP_PIN,Z2_DIR_PIN,Z2_MAX_CURRENT,Z2_SENSE_RESISTOR);
#endif
#ifdef E0_IS_TMC
TMC26XStepper stepperE0(200,E0_ENABLE_PIN,E0_STEP_PIN,E0_DIR_PIN,E0_MAX_CURRENT,E0_SENSE_RESISTOR);
#endif
#ifdef E1_IS_TMC
TMC26XStepper stepperE1(200,E1_ENABLE_PIN,E1_STEP_PIN,E1_DIR_PIN,E1_MAX_CURRENT,E1_SENSE_RESISTOR);
#endif
#ifdef E2_IS_TMC
TMC26XStepper stepperE2(200,E2_ENABLE_PIN,E2_STEP_PIN,E2_DIR_PIN,E2_MAX_CURRENT,E2_SENSE_RESISTOR);
#endif
#ifdef E3_IS_TMC
TMC26XStepper stepperE3(200,E3_ENABLE_PIN,E3_STEP_PIN,E3_DIR_PIN,E3_MAX_CURRENT,E3_SENSE_RESISTOR);
#endif
#ifdef HAVE_TMCDRIVER
void tmc_init()
{
#ifdef X_IS_TMC
stepperX.setMicrosteps(X_MICROSTEPS);
stepperX.start();
#endif
#ifdef X2_IS_TMC
stepperX2.setMicrosteps(X2_MICROSTEPS);
stepperX2.start();
#endif
#ifdef Y_IS_TMC
stepperY.setMicrosteps(Y_MICROSTEPS);
stepperY.start();
#endif
#ifdef Y2_IS_TMC
stepperY2.setMicrosteps(Y2_MICROSTEPS);
stepperY2.start();
#endif
#ifdef Z_IS_TMC
stepperZ.setMicrosteps(Z_MICROSTEPS);
stepperZ.start();
#endif
#ifdef Z2_IS_TMC
stepperZ2.setMicrosteps(Z2_MICROSTEPS);
stepperZ2.start();
#endif
#ifdef E0_IS_TMC
stepperE0.setMicrosteps(E0_MICROSTEPS);
stepperE0.start();
#endif
#ifdef E1_IS_TMC
stepperE1.setMicrosteps(E1_MICROSTEPS);
stepperE1.start();
#endif
#ifdef E2_IS_TMC
stepperE2.setMicrosteps(E2_MICROSTEPS);
stepperE2.start();
#endif
#ifdef E3_IS_TMC
stepperE3.setMicrosteps(E3_MICROSTEPS);
stepperE3.start();
#endif
}
#endif
// L6470 Driver objects and inits
#ifdef HAVE_L6470DRIVER
#include <SPI.h>
#include <L6470.h>
#endif
// L6470 Stepper objects
#ifdef X_IS_L6470
L6470 stepperX(X_ENABLE_PIN);
#endif
#ifdef X2_IS_L6470
L6470 stepperX2(X2_ENABLE_PIN);
#endif
#ifdef Y_IS_L6470
L6470 stepperY(Y_ENABLE_PIN);
#endif
#ifdef Y2_IS_L6470
L6470 stepperY2(Y2_ENABLE_PIN);
#endif
#ifdef Z_IS_L6470
L6470 stepperZ(Z_ENABLE_PIN);
#endif
#ifdef Z2_IS_L6470
L6470 stepperZ2(Z2_ENABLE_PIN);
#endif
#ifdef E0_IS_L6470
L6470 stepperE0(E0_ENABLE_PIN);
#endif
#ifdef E1_IS_L6470
L6470 stepperE1(E1_ENABLE_PIN);
#endif
#ifdef E2_IS_L6470
L6470 stepperE2(E2_ENABLE_PIN);
#endif
#ifdef E3_IS_L6470
L6470 stepperE3(E3_ENABLE_PIN);
#endif
// init routine
#ifdef HAVE_L6470DRIVER
void L6470_init()
{
#ifdef X_IS_L6470
stepperX.init(X_K_VAL);
stepperX.softFree();
stepperX.setMicroSteps(X_MICROSTEPS);
stepperX.setOverCurrent(X_OVERCURRENT); //set overcurrent protection
stepperX.setStallCurrent(X_STALLCURRENT);
#endif
#ifdef X2_IS_L6470
stepperX2.init(X2_K_VAL);
stepperX2.softFree();
stepperX2.setMicroSteps(X2_MICROSTEPS);
stepperX2.setOverCurrent(X2_OVERCURRENT); //set overcurrent protection
stepperX2.setStallCurrent(X2_STALLCURRENT);
#endif
#ifdef Y_IS_L6470
stepperY.init(Y_K_VAL);
stepperY.softFree();
stepperY.setMicroSteps(Y_MICROSTEPS);
stepperY.setOverCurrent(Y_OVERCURRENT); //set overcurrent protection
stepperY.setStallCurrent(Y_STALLCURRENT);
#endif
#ifdef Y2_IS_L6470
stepperY2.init(Y2_K_VAL);
stepperY2.softFree();
stepperY2.setMicroSteps(Y2_MICROSTEPS);
stepperY2.setOverCurrent(Y2_OVERCURRENT); //set overcurrent protection
stepperY2.setStallCurrent(Y2_STALLCURRENT);
#endif
#ifdef Z_IS_L6470
stepperZ.init(Z_K_VAL);
stepperZ.softFree();
stepperZ.setMicroSteps(Z_MICROSTEPS);
stepperZ.setOverCurrent(Z_OVERCURRENT); //set overcurrent protection
stepperZ.setStallCurrent(Z_STALLCURRENT);
#endif
#ifdef Z2_IS_L6470
stepperZ2.init(Z2_K_VAL);
stepperZ2.softFree();
stepperZ2.setMicroSteps(Z2_MICROSTEPS);
stepperZ2.setOverCurrent(Z2_OVERCURRENT); //set overcurrent protection
stepperZ2.setStallCurrent(Z2_STALLCURRENT);
#endif
#ifdef E0_IS_L6470
stepperE0.init(E0_K_VAL);
stepperE0.softFree();
stepperE0.setMicroSteps(E0_MICROSTEPS);
stepperE0.setOverCurrent(E0_OVERCURRENT); //set overcurrent protection
stepperE0.setStallCurrent(E0_STALLCURRENT);
#endif
#ifdef E1_IS_L6470
stepperE1.init(E1_K_VAL);
stepperE1.softFree();
stepperE1.setMicroSteps(E1_MICROSTEPS);
stepperE1.setOverCurrent(E1_OVERCURRENT); //set overcurrent protection
stepperE1.setStallCurrent(E1_STALLCURRENT);
#endif
#ifdef E2_IS_L6470
stepperE2.init(E2_K_VAL);
stepperE2.softFree();
stepperE2.setMicroSteps(E2_MICROSTEPS);
stepperE2.setOverCurrent(E2_OVERCURRENT); //set overcurrent protection
stepperE2.setStallCurrent(E2_STALLCURRENT);
#endif
#ifdef E3_IS_L6470
stepperE3.init(E3_K_VAL);
stepperE3.softFree();
stepperE3.setMicroSteps(E3_MICROSTEPS);
stepperE3.setOverCurrent(E3_OVERCURRENT); //set overcurrent protection
stepperE3.setStallCurrent(E3_STALLCURRENT);
#endif
}
#endif
/*
stepper_indirection.h - stepper motor driver indirection macros
to allow some stepper functions to be done via SPI/I2c instead of direct pin manipulation
Part of Marlin
Copyright (c) 2015 Dominik Wenger
Marlin 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.
Marlin 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 Marlin. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef STEPPER_INDIRECTION_H
#define STEPPER_INDIRECTION_H
// X motor
#define X_STEP_INIT SET_OUTPUT(X_STEP_PIN)
#define X_STEP_WRITE(STATE) WRITE(X_STEP_PIN,STATE)
#define X_STEP_READ READ(X_STEP_PIN)
#define X_DIR_INIT SET_OUTPUT(X_DIR_PIN)
#define X_DIR_WRITE(STATE) WRITE(X_DIR_PIN,STATE)
#define X_DIR_READ READ(X_DIR_PIN)
#define X_ENABLE_INIT SET_OUTPUT(X_ENABLE_PIN)
#define X_ENABLE_WRITE(STATE) WRITE(X_ENABLE_PIN,STATE)
#define X_ENABLE_READ READ(X_ENABLE_PIN)
// X2 motor
#define X2_STEP_INIT SET_OUTPUT(X2_STEP_PIN)
#define X2_STEP_WRITE(STATE) WRITE(X2_STEP_PIN,STATE)
#define X2_STEP_READ READ(X2_STEP_PIN)
#define X2_DIR_INIT SET_OUTPUT(X2_DIR_PIN)
#define X2_DIR_WRITE(STATE) WRITE(X2_DIR_PIN,STATE)
#define X2_DIR_READ READ(X_DIR_PIN)
#define X2_ENABLE_INIT SET_OUTPUT(X2_ENABLE_PIN)
#define X2_ENABLE_WRITE(STATE) WRITE(X2_ENABLE_PIN,STATE)
#define X2_ENABLE_READ READ(X_ENABLE_PIN)
// Y motor
#define Y_STEP_INIT SET_OUTPUT(Y_STEP_PIN)
#define Y_STEP_WRITE(STATE) WRITE(Y_STEP_PIN,STATE)
#define Y_STEP_READ READ(Y_STEP_PIN)
#define Y_DIR_INIT SET_OUTPUT(Y_DIR_PIN)
#define Y_DIR_WRITE(STATE) WRITE(Y_DIR_PIN,STATE)
#define Y_DIR_READ READ(Y_DIR_PIN)
#define Y_ENABLE_INIT SET_OUTPUT(Y_ENABLE_PIN)
#define Y_ENABLE_WRITE(STATE) WRITE(Y_ENABLE_PIN,STATE)
#define Y_ENABLE_READ READ(Y_ENABLE_PIN)
// Y2 motor
#define Y2_STEP_INIT SET_OUTPUT(Y2_STEP_PIN)
#define Y2_STEP_WRITE(STATE) WRITE(Y2_STEP_PIN,STATE)
#define Y2_STEP_READ READ(Y2_STEP_PIN)
#define Y2_DIR_INIT SET_OUTPUT(Y2_DIR_PIN)
#define Y2_DIR_WRITE(STATE) WRITE(Y2_DIR_PIN,STATE)
#define Y2_DIR_READ READ(Y2_DIR_PIN)
#define Y2_ENABLE_INIT SET_OUTPUT(Y2_ENABLE_PIN)
#define Y2_ENABLE_WRITE(STATE) WRITE(Y2_ENABLE_PIN,STATE)
#define Y2_ENABLE_READ READ(Y2_ENABLE_PIN)
// Z motor
#define Z_STEP_INIT SET_OUTPUT(Z_STEP_PIN)
#define Z_STEP_WRITE(STATE) WRITE(Z_STEP_PIN,STATE)
#define Z_STEP_READ READ(Z_STEP_PIN)
#define Z_DIR_INIT SET_OUTPUT(Z_DIR_PIN)
#define Z_DIR_WRITE(STATE) WRITE(Z_DIR_PIN,STATE)
#define Z_DIR_READ READ(Z_DIR_PIN)
#define Z_ENABLE_INIT SET_OUTPUT(Z_ENABLE_PIN)
#define Z_ENABLE_WRITE(STATE) WRITE(Z_ENABLE_PIN,STATE)
#define Z_ENABLE_READ READ(Z_ENABLE_PIN)
// Z2 motor
#define Z2_STEP_INIT SET_OUTPUT(Z2_STEP_PIN)
#define Z2_STEP_WRITE(STATE) WRITE(Z2_STEP_PIN,STATE)
#define Z2_STEP_READ READ(Z2_STEP_PIN)
#define Z2_DIR_INIT SET_OUTPUT(Z2_DIR_PIN)
#define Z2_DIR_WRITE(STATE) WRITE(Z2_DIR_PIN,STATE)
#define Z2_DIR_READ READ(Z2_DIR_PIN)
#define Z2_ENABLE_INIT SET_OUTPUT(Z2_ENABLE_PIN)
#define Z2_ENABLE_WRITE(STATE) WRITE(Z2_ENABLE_PIN,STATE)
#define Z2_ENABLE_READ READ(Z2_ENABLE_PIN)
// E0 motor
#define E0_STEP_INIT SET_OUTPUT(E0_STEP_PIN)
#define E0_STEP_WRITE(STATE) WRITE(E0_STEP_PIN,STATE)
#define E0_STEP_READ READ(E0_STEP_PIN)
#define E0_DIR_INIT SET_OUTPUT(E0_DIR_PIN)
#define E0_DIR_WRITE(STATE) WRITE(E0_DIR_PIN,STATE)
#define E0_DIR_READ READ(E0_DIR_PIN)
#define E0_ENABLE_INIT SET_OUTPUT(E0_ENABLE_PIN)
#define E0_ENABLE_WRITE(STATE) WRITE(E0_ENABLE_PIN,STATE)
#define E0_ENABLE_READ READ(E0_ENABLE_PIN)
// E1 motor
#define E1_STEP_INIT SET_OUTPUT(E1_STEP_PIN)
#define E1_STEP_WRITE(STATE) WRITE(E1_STEP_PIN,STATE)
#define E1_STEP_READ READ(E1_STEP_PIN)
#define E1_DIR_INIT SET_OUTPUT(E1_DIR_PIN)
#define E1_DIR_WRITE(STATE) WRITE(E1_DIR_PIN,STATE)
#define E1_DIR_READ READ(E1_DIR_PIN)
#define E1_ENABLE_INIT SET_OUTPUT(E1_ENABLE_PIN)
#define E1_ENABLE_WRITE(STATE) WRITE(E1_ENABLE_PIN,STATE)
#define E1_ENABLE_READ READ(E1_ENABLE_PIN)
// E2 motor
#define E2_STEP_INIT SET_OUTPUT(E2_STEP_PIN)
#define E2_STEP_WRITE(STATE) WRITE(E2_STEP_PIN,STATE)
#define E2_STEP_READ READ(E2_STEP_PIN)
#define E2_DIR_INIT SET_OUTPUT(E2_DIR_PIN)
#define E2_DIR_WRITE(STATE) WRITE(E2_DIR_PIN,STATE)
#define E2_DIR_READ READ(E2_DIR_PIN)
#define E2_ENABLE_INIT SET_OUTPUT(E2_ENABLE_PIN)
#define E2_ENABLE_WRITE(STATE) WRITE(E2_ENABLE_PIN,STATE)
#define E2_ENABLE_READ READ(E2_ENABLE_PIN)
// E3 motor
#define E3_STEP_INIT SET_OUTPUT(E3_STEP_PIN)
#define E3_STEP_WRITE(STATE) WRITE(E3_STEP_PIN,STATE)
#define E3_STEP_READ READ(E3_STEP_PIN)
#define E3_DIR_INIT SET_OUTPUT(E3_DIR_PIN)
#define E3_DIR_WRITE(STATE) WRITE(E3_DIR_PIN,STATE)
#define E3_DIR_READ READ(E3_DIR_PIN)
#define E3_ENABLE_INIT SET_OUTPUT(E3_ENABLE_PIN)
#define E3_ENABLE_WRITE(STATE) WRITE(E3_ENABLE_PIN,STATE)
#define E3_ENABLE_READ READ(E3_ENABLE_PIN)
//////////////////////////////////
// Pin redefines for TMC drivers.
// TMC26X drivers have step and dir on normal pins, but everything else via SPI
//////////////////////////////////
#ifdef HAVE_TMCDRIVER
#include <SPI.h>
#include <TMC26XStepper.h>
void tmc_init();
#ifdef X_IS_TMC
extern TMC26XStepper stepperX;
#undef X_ENABLE_INIT
#define X_ENABLE_INIT ((void)0)
#undef X_ENABLE_WRITE
#define X_ENABLE_WRITE(STATE) stepperX.setEnabled(STATE)
#undef X_ENABLE_READ
#define X_ENABLE_READ stepperX.isEnabled()
#endif
#ifdef X2_IS_TMC
extern TMC26XStepper stepperX2;
#undef X2_ENABLE_INIT
#define X2_ENABLE_INIT ((void)0)
#undef X2_ENABLE_WRITE
#define X2_ENABLE_WRITE(STATE) stepperX2.setEnabled(STATE)
#undef X2_ENABLE_READ
#define X2_ENABLE_READ stepperX2.isEnabled()
#endif
#ifdef Y_IS_TMC
extern TMC26XStepper stepperY;
#undef Y_ENABLE_INIT
#define Y_ENABLE_INIT ((void)0)
#undef Y_ENABLE_WRITE
#define Y_ENABLE_WRITE(STATE) stepperY.setEnabled(STATE)
#undef Y_ENABLE_READ
#define Y_ENABLE_READ stepperY.isEnabled()
#endif
#ifdef Y2_IS_TMC
extern TMC26XStepper stepperY2;
#undef Y2_ENABLE_INIT
#define Y2_ENABLE_INIT ((void)0)
#undef Y2_ENABLE_WRITE
#define Y2_ENABLE_WRITE(STATE) stepperY2.setEnabled(STATE)
#undef Y2_ENABLE_READ
#define Y2_ENABLE_READ stepperY2.isEnabled()
#endif
#ifdef Z_IS_TMC
extern TMC26XStepper stepperZ;
#undef Z_ENABLE_INIT
#define Z_ENABLE_INIT ((void)0)
#undef Z_ENABLE_WRITE
#define Z_ENABLE_WRITE(STATE) stepperZ.setEnabled(STATE)
#undef Z_ENABLE_READ
#define Z_ENABLE_READ stepperZ.isEnabled()
#endif
#ifdef Z2_IS_TMC
extern TMC26XStepper stepperZ2;
#undef Z2_ENABLE_INIT
#define Z2_ENABLE_INIT ((void)0)
#undef Z2_ENABLE_WRITE
#define Z2_ENABLE_WRITE(STATE) stepperZ2.setEnabled(STATE)
#undef Z2_ENABLE_READ
#define Z2_ENABLE_READ stepperZ2.isEnabled()
#endif
#ifdef E0_IS_TMC
extern TMC26XStepper stepperE0;
#undef E0_ENABLE_INIT
#define E0_ENABLE_INIT ((void)0)
#undef E0_ENABLE_WRITE
#define E0_ENABLE_WRITE(STATE) stepperE0.setEnabled(STATE)
#undef E0_ENABLE_READ
#define E0_ENABLE_READ stepperE0.isEnabled()
#endif
#ifdef E1_IS_TMC
extern TMC26XStepper stepperE1;
#undef E1_ENABLE_INIT
#define E1_ENABLE_INIT ((void)0)
#undef E1_ENABLE_WRITE
#define E1_ENABLE_WRITE(STATE) stepperE1.setEnabled(STATE)
#undef E1_ENABLE_READ
#define E1_ENABLE_READ stepperE1.isEnabled()
#endif
#ifdef E2_IS_TMC
extern TMC26XStepper stepperE2;
#undef E2_ENABLE_INIT
#define E2_ENABLE_INIT ((void)0)
#undef E2_ENABLE_WRITE
#define E2_ENABLE_WRITE(STATE) stepperE2.setEnabled(STATE)
#undef E2_ENABLE_READ
#define E2_ENABLE_READ stepperE2.isEnabled()
#endif
#ifdef E3_IS_TMC
extern TMC26XStepper stepperE3;
#undef E3_ENABLE_INIT
#define E3_ENABLE_INIT ((void)0)
#undef E3_ENABLE_WRITE
#define E3_ENABLE_WRITE(STATE) stepperE3.setEnabled(STATE)
#undef E3_ENABLE_READ
#define E3_ENABLE_READ stepperE3.isEnabled()
#endif
#endif // HAVE_TMCDRIVER
//////////////////////////////////
// Pin redefines for L6470 drivers.
// L640 drivers have step on normal pins, but dir and everything else via SPI
//////////////////////////////////
#ifdef HAVE_L6470DRIVER
#include <SPI.h>
#include <L6470.h>
void L6470_init();
#ifdef X_IS_L6470
extern L6470 stepperX;
#undef X_ENABLE_INIT
#define X_ENABLE_INIT ((void)0)
#undef X_ENABLE_WRITE
#define X_ENABLE_WRITE(STATE) {if(STATE) stepperX.Step_Clock(stepperX.getStatus() & STATUS_HIZ); else stepperX.softFree();}
#undef X_ENABLE_READ
#define X_ENABLE_READ (stepperX.getStatus() & STATUS_HIZ)
#undef X_DIR_INIT
#define X_DIR_INIT ((void)0)
#undef X_DIR_WRITE
#define X_DIR_WRITE(STATE) stepperX.Step_Clock(STATE)
#undef X_DIR_READ
#define X_DIR_READ (stepperX.getStatus() & STATUS_DIR)
#endif
#ifdef X2_IS_L6470
extern L6470 stepperX2;
#undef X2_ENABLE_INIT
#define X2_ENABLE_INIT ((void)0)
#undef X2_ENABLE_WRITE
#define X2_ENABLE_WRITE(STATE) (if(STATE) stepperX2.Step_Clock(stepperX2.getStatus() & STATUS_HIZ); else stepperX2.softFree();)
#undef X2_ENABLE_READ
#define X2_ENABLE_READ (stepperX2.getStatus() & STATUS_HIZ)
#undef X2_DIR_INIT
#define X2_DIR_INIT ((void)0)
#undef X2_DIR_WRITE
#define X2_DIR_WRITE(STATE) stepperX2.Step_Clock(STATE)
#undef X2_DIR_READ
#define X2_DIR_READ (stepperX2.getStatus() & STATUS_DIR)
#endif
#ifdef Y_IS_L6470
extern L6470 stepperY;
#undef Y_ENABLE_INIT
#define Y_ENABLE_INIT ((void)0)
#undef Y_ENABLE_WRITE
#define Y_ENABLE_WRITE(STATE) (if(STATE) stepperY.Step_Clock(stepperY.getStatus() & STATUS_HIZ); else stepperY.softFree();)
#undef Y_ENABLE_READ
#define Y_ENABLE_READ (stepperY.getStatus() & STATUS_HIZ)
#undef Y_DIR_INIT
#define Y_DIR_INIT ((void)0)
#undef Y_DIR_WRITE
#define Y_DIR_WRITE(STATE) stepperY.Step_Clock(STATE)
#undef Y_DIR_READ
#define Y_DIR_READ (stepperY.getStatus() & STATUS_DIR)
#endif
#ifdef Y2_IS_L6470
extern L6470 stepperY2;
#undef Y2_ENABLE_INIT
#define Y2_ENABLE_INIT ((void)0)
#undef Y2_ENABLE_WRITE
#define Y2_ENABLE_WRITE(STATE) (if(STATE) stepperY2.Step_Clock(stepperY2.getStatus() & STATUS_HIZ); else stepperY2.softFree();)
#undef Y2_ENABLE_READ
#define Y2_ENABLE_READ (stepperY2.getStatus() & STATUS_HIZ)
#undef Y2_DIR_INIT
#define Y2_DIR_INIT ((void)0)
#undef Y2_DIR_WRITE
#define Y2_DIR_WRITE(STATE) stepperY2.Step_Clock(STATE)
#undef Y2_DIR_READ
#define Y2_DIR_READ (stepperY2.getStatus() & STATUS_DIR)
#endif
#ifdef Z_IS_L6470
extern L6470 stepperZ;
#undef Z_ENABLE_INIT
#define Z_ENABLE_INIT ((void)0)
#undef Z_ENABLE_WRITE
#define Z_ENABLE_WRITE(STATE) (if(STATE) stepperZ.Step_Clock(stepperZ.getStatus() & STATUS_HIZ); else stepperZ.softFree();)
#undef Z_ENABLE_READ
#define Z_ENABLE_READ (stepperZ.getStatus() & STATUS_HIZ)
#undef Z_DIR_INIT
#define Z_DIR_INIT ((void)0)
#undef Z_DIR_WRITE
#define Z_DIR_WRITE(STATE) stepperZ.Step_Clock(STATE)
#undef Y_DIR_READ
#define Y_DIR_READ (stepperZ.getStatus() & STATUS_DIR)
#endif
#ifdef Z2_IS_L6470
extern L6470 stepperZ2;
#undef Z2_ENABLE_INIT
#define Z2_ENABLE_INIT ((void)0)
#undef Z2_ENABLE_WRITE
#define Z2_ENABLE_WRITE(STATE) (if(STATE) stepperZ2.Step_Clock(stepperZ2.getStatus() & STATUS_HIZ); else stepperZ2.softFree();)
#undef Z2_ENABLE_READ
#define Z2_ENABLE_READ (stepperZ2.getStatus() & STATUS_HIZ)
#undef Z2_DIR_INIT
#define Z2_DIR_INIT ((void)0)
#undef Z2_DIR_WRITE
#define Z2_DIR_WRITE(STATE) stepperZ2.Step_Clock(STATE)
#undef Y2_DIR_READ
#define Y2_DIR_READ (stepperZ2.getStatus() & STATUS_DIR)
#endif
#ifdef E0_IS_L6470
extern L6470 stepperE0;
#undef E0_ENABLE_INIT
#define E0_ENABLE_INIT ((void)0)
#undef E0_ENABLE_WRITE
#define E0_ENABLE_WRITE(STATE) (if(STATE) stepperE0.Step_Clock(stepperE0.getStatus() & STATUS_HIZ); else stepperE0.softFree();)
#undef E0_ENABLE_READ
#define E0_ENABLE_READ (stepperE0.getStatus() & STATUS_HIZ)
#undef E0_DIR_INIT
#define E0_DIR_INIT ((void)0)
#undef E0_DIR_WRITE
#define E0_DIR_WRITE(STATE) stepperE0.Step_Clock(STATE)
#undef E0_DIR_READ
#define E0_DIR_READ (stepperE0.getStatus() & STATUS_DIR)
#endif
#ifdef E1_IS_L6470
extern L6470 stepperE1;
#undef E1_ENABLE_INIT
#define E1_ENABLE_INIT ((void)0)
#undef E1_ENABLE_WRITE
#define E1_ENABLE_WRITE(STATE) (if(STATE) stepperE1.Step_Clock(stepperE1.getStatus() & STATUS_HIZ); else stepperE1.softFree();)
#undef E1_ENABLE_READ
#define E1_ENABLE_READ (stepperE1.getStatus() & STATUS_HIZ)
#undef E1_DIR_INIT
#define E1_DIR_INIT ((void)0)
#undef E1_DIR_WRITE
#define E1_DIR_WRITE(STATE) stepperE1.Step_Clock(STATE)
#undef E1_DIR_READ
#define E1_DIR_READ (stepperE1.getStatus() & STATUS_DIR)
#endif
#ifdef E2_IS_L6470
extern L6470 stepperE2;
#undef E2_ENABLE_INIT
#define E2_ENABLE_INIT ((void)0)
#undef E2_ENABLE_WRITE
#define E2_ENABLE_WRITE(STATE) (if(STATE) stepperE2.Step_Clock(stepperE2.getStatus() & STATUS_HIZ); else stepperE2.softFree();)
#undef E2_ENABLE_READ
#define E2_ENABLE_READ (stepperE2.getStatus() & STATUS_HIZ)
#undef E2_DIR_INIT
#define E2_DIR_INIT ((void)0)
#undef E2_DIR_WRITE
#define E2_DIR_WRITE(STATE) stepperE2.Step_Clock(STATE)
#undef E2_DIR_READ
#define E2_DIR_READ (stepperE2.getStatus() & STATUS_DIR)
#endif
#ifdef E3_IS_L6470
extern L6470 stepperE3;
#undef E3_ENABLE_INIT
#define E3_ENABLE_INIT ((void)0)
#undef E3_ENABLE_WRITE
#define E3_ENABLE_WRITE(STATE) (if(STATE) stepperE3.Step_Clock(stepperE3.getStatus() & STATUS_HIZ); else stepperE3.softFree();)
#undef E3_ENABLE_READ
#define E3_ENABLE_READ (stepperE3.getStatus() & STATUS_HIZ)
#undef E3_DIR_INIT
#define E3_DIR_INIT ((void)0)
#undef E3_DIR_WRITE
#define E3_DIR_WRITE(STATE) stepperE3.Step_Clock(STATE)
#undef E3_DIR_READ
#define E3_DIR_READ (stepperE3.getStatus() & STATUS_DIR)
#endif
#endif //HAVE_L6470DRIVER
#endif // STEPPER_INDIRECTION_H
\ No newline at end of file
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#include "ultralcd.h" #include "ultralcd.h"
#include "temperature.h" #include "temperature.h"
#include "watchdog.h" #include "watchdog.h"
#include "thermistortables.h"
#include "language.h" #include "language.h"
#include "Sd2PinMap.h" #include "Sd2PinMap.h"
...@@ -186,9 +185,7 @@ static volatile bool temp_meas_ready = false; ...@@ -186,9 +185,7 @@ static volatile bool temp_meas_ready = false;
#ifdef FAN_SOFT_PWM #ifdef FAN_SOFT_PWM
static unsigned char soft_pwm_fan; static unsigned char soft_pwm_fan;
#endif #endif
#if (defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1) || \ #if HAS_AUTO_FAN
(defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1) || \
(defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1)
static unsigned long extruder_autofan_last_check; static unsigned long extruder_autofan_last_check;
#endif #endif
...@@ -329,8 +326,8 @@ void PID_autotune(float temp, int extruder, int ncycles) { ...@@ -329,8 +326,8 @@ void PID_autotune(float temp, int extruder, int ncycles) {
SERIAL_PROTOCOLPGM(MSG_BIAS); SERIAL_PROTOCOL(bias); SERIAL_PROTOCOLPGM(MSG_BIAS); SERIAL_PROTOCOL(bias);
SERIAL_PROTOCOLPGM(MSG_D); SERIAL_PROTOCOL(d); SERIAL_PROTOCOLPGM(MSG_D); SERIAL_PROTOCOL(d);
SERIAL_PROTOCOLPGM(MSG_MIN); SERIAL_PROTOCOL(min); SERIAL_PROTOCOLPGM(MSG_T_MIN); SERIAL_PROTOCOL(min);
SERIAL_PROTOCOLPGM(MSG_MAX); SERIAL_PROTOCOLLN(max); SERIAL_PROTOCOLPGM(MSG_T_MAX); SERIAL_PROTOCOLLN(max);
if (cycles > 2) { if (cycles > 2) {
Ku = (4.0 * d) / (3.14159265 * (max - min) / 2.0); Ku = (4.0 * d) / (3.14159265 * (max - min) / 2.0);
Tu = ((float)(t_low + t_high) / 1000.0); Tu = ((float)(t_low + t_high) / 1000.0);
...@@ -348,16 +345,16 @@ void PID_autotune(float temp, int extruder, int ncycles) { ...@@ -348,16 +345,16 @@ void PID_autotune(float temp, int extruder, int ncycles) {
Ki = Kp/Tu; Ki = Kp/Tu;
Kd = Kp*Tu/3; Kd = Kp*Tu/3;
SERIAL_PROTOCOLLNPGM(" Some overshoot "); SERIAL_PROTOCOLLNPGM(" Some overshoot ");
SERIAL_PROTOCOLPGM(MSG_KP); SERIAL_PROTOCOLLN(Kp); SERIAL_PROTOCOLPGM(" Kp: "); SERIAL_PROTOCOLLN(Kp);
SERIAL_PROTOCOLPGM(MSG_KI); SERIAL_PROTOCOLLN(Ki); SERIAL_PROTOCOLPGM(" Ki: "); SERIAL_PROTOCOLLN(Ki);
SERIAL_PROTOCOLPGM(MSG_KD); SERIAL_PROTOCOLLN(Kd); SERIAL_PROTOCOLPGM(" Kd: "); SERIAL_PROTOCOLLN(Kd);
Kp = 0.2*Ku; Kp = 0.2*Ku;
Ki = 2*Kp/Tu; Ki = 2*Kp/Tu;
Kd = Kp*Tu/3; Kd = Kp*Tu/3;
SERIAL_PROTOCOLLNPGM(" No overshoot "); SERIAL_PROTOCOLLNPGM(" No overshoot ");
SERIAL_PROTOCOLPGM(MSG_KP); SERIAL_PROTOCOLLN(Kp); SERIAL_PROTOCOLPGM(" Kp: "); SERIAL_PROTOCOLLN(Kp);
SERIAL_PROTOCOLPGM(MSG_KI); SERIAL_PROTOCOLLN(Ki); SERIAL_PROTOCOLPGM(" Ki: "); SERIAL_PROTOCOLLN(Ki);
SERIAL_PROTOCOLPGM(MSG_KD); SERIAL_PROTOCOLLN(Kd); SERIAL_PROTOCOLPGM(" Kd: "); SERIAL_PROTOCOLLN(Kd);
*/ */
} }
} }
...@@ -366,7 +363,7 @@ void PID_autotune(float temp, int extruder, int ncycles) { ...@@ -366,7 +363,7 @@ void PID_autotune(float temp, int extruder, int ncycles) {
else else
soft_pwm[extruder] = (bias + d) >> 1; soft_pwm[extruder] = (bias + d) >> 1;
cycles++; cycles++;
min=temp; min = temp;
} }
} }
} }
...@@ -441,15 +438,17 @@ int getHeaterPower(int heater) { ...@@ -441,15 +438,17 @@ int getHeaterPower(int heater) {
#endif #endif
#endif #endif
void setExtruderAutoFanState(int pin, bool state) { void setExtruderAutoFanState(int pin, bool state)
{
unsigned char newFanSpeed = (state != 0) ? EXTRUDER_AUTO_FAN_SPEED : 0; unsigned char newFanSpeed = (state != 0) ? EXTRUDER_AUTO_FAN_SPEED : 0;
// this idiom allows both digital and PWM fan outputs (see M42 handling). // this idiom allows both digital and PWM fan outputs (see M42 handling).
pinMode(pin, OUTPUT); pinMode(pin, OUTPUT);
digitalWrite(pin, newFanSpeed); digitalWrite(pin, newFanSpeed);
analogWrite(pin, newFanSpeed); analogWrite(pin, newFanSpeed);
} }
void checkExtruderAutoFans() { void checkExtruderAutoFans()
{
uint8_t fanState = 0; uint8_t fanState = 0;
// which fan pins need to be turned on? // which fan pins need to be turned on?
...@@ -458,9 +457,10 @@ int getHeaterPower(int heater) { ...@@ -458,9 +457,10 @@ int getHeaterPower(int heater) {
fanState |= 1; fanState |= 1;
#endif #endif
#ifndef SINGLENOZZLE #ifndef SINGLENOZZLE
#if HAS_AUTO_FAN_1 #if HAS_AUTO_FAN_1
if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE) { if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE)
{
if (EXTRUDER_1_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN) if (EXTRUDER_1_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN)
fanState |= 1; fanState |= 1;
else else
...@@ -489,14 +489,14 @@ int getHeaterPower(int heater) { ...@@ -489,14 +489,14 @@ int getHeaterPower(int heater) {
fanState |= 8; fanState |= 8;
} }
#endif #endif
#endif // !SINLGENOZZE #endif // !SINLGENOZZE
// update extruder auto fan states // update extruder auto fan states
#if HAS_AUTO_FAN_0 #if HAS_AUTO_FAN_0
setExtruderAutoFanState(EXTRUDER_0_AUTO_FAN_PIN, (fanState & 1) != 0); setExtruderAutoFanState(EXTRUDER_0_AUTO_FAN_PIN, (fanState & 1) != 0);
#endif #endif
#ifndef SINGLENOZZLE #ifndef SINGLENOZZLE
#if HAS_AUTO_FAN_1 #if HAS_AUTO_FAN_1
if (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN) if (EXTRUDER_1_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN)
setExtruderAutoFanState(EXTRUDER_1_AUTO_FAN_PIN, (fanState & 2) != 0); setExtruderAutoFanState(EXTRUDER_1_AUTO_FAN_PIN, (fanState & 2) != 0);
...@@ -508,12 +508,12 @@ int getHeaterPower(int heater) { ...@@ -508,12 +508,12 @@ int getHeaterPower(int heater) {
#endif #endif
#if HAS_AUTO_FAN_3 #if HAS_AUTO_FAN_3
if (EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN if (EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_0_AUTO_FAN_PIN
&& EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_1_AUTO_FAN_PIN
&& EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_3_AUTO_FAN_PIN != EXTRUDER_2_AUTO_FAN_PIN)
setExtruderAutoFanState(EXTRUDER_3_AUTO_FAN_PIN, (fanState & 8) != 0); setExtruderAutoFanState(EXTRUDER_3_AUTO_FAN_PIN, (fanState & 8) != 0);
#endif #endif
#endif // !SINLGENOZZE #endif //!SINGLENOZZLE
} }
#endif // any extruder auto fan pins set #endif // any extruder auto fan pins set
// //
...@@ -557,6 +557,36 @@ int getHeaterPower(int heater) { ...@@ -557,6 +557,36 @@ int getHeaterPower(int heater) {
#define WRITE_FAN(v) WRITE(FAN_PIN, v) #define WRITE_FAN(v) WRITE(FAN_PIN, v)
#endif #endif
inline void _temp_error(int e, const char *msg1, const char *msg2) {
if (!IsStopped()) {
SERIAL_ERROR_START;
if (e >= 0) SERIAL_ERRORLN((int)e);
serialprintPGM(msg1);
MYSERIAL.write('\n');
#ifdef ULTRA_LCD
lcd_setalertstatuspgm(msg2);
#endif
}
#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
Stop();
#endif
}
void max_temp_error(uint8_t e) {
disable_heater();
_temp_error(e, MSG_MAXTEMP_EXTRUDER_OFF, MSG_ERR_MAXTEMP);
}
void min_temp_error(uint8_t e) {
disable_heater();
_temp_error(e, MSG_MINTEMP_EXTRUDER_OFF, MSG_ERR_MINTEMP);
}
void bed_max_temp_error(void) {
#if HAS_HEATER_BED
WRITE_HEATER_BED(0);
#endif
_temp_error(-1, MSG_MAXTEMP_BED_OFF, MSG_ERR_MAXTEMP_BED);
}
void manage_heater() { void manage_heater() {
if (!temp_meas_ready) return; if (!temp_meas_ready) return;
...@@ -575,10 +605,10 @@ void manage_heater() { ...@@ -575,10 +605,10 @@ void manage_heater() {
// Loop through all extruders // Loop through all extruders
#ifndef SINGLENOZZLE #ifndef SINGLENOZZLE
for(int e = 0; e < EXTRUDERS; e++) for (int e = 0; e < EXTRUDERS; e++)
#else #else
int e = 0; int e = 0;
#endif // !SINLGENOZZE #endif // !SINGLENOZZLE
{ {
#if defined (THERMAL_RUNAWAY_PROTECTION_PERIOD) && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0 #if defined (THERMAL_RUNAWAY_PROTECTION_PERIOD) && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0
...@@ -668,17 +698,10 @@ void manage_heater() { ...@@ -668,17 +698,10 @@ void manage_heater() {
#ifdef TEMP_SENSOR_1_AS_REDUNDANT #ifdef TEMP_SENSOR_1_AS_REDUNDANT
if (fabs(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) { if (fabs(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) {
disable_heater(); disable_heater();
if (IsStopped() == false) { _temp_error(-1, MSG_EXTRUDER_SWITCHED_OFF, MSG_ERR_REDUNDANT_TEMP);
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM(MSG_EXTRUDER_SWITCHED_OFF);
LCD_ALERTMESSAGEPGM(MSG_ERR_REDUNDANT_TEMP);
}
#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
Stop();
#endif
} }
#endif //TEMP_SENSOR_1_AS_REDUNDANT #endif //TEMP_SENSOR_1_AS_REDUNDANT
} //End extruder for loop } // Extruders Loop
#if HAS_AUTO_FAN #if HAS_AUTO_FAN
if (ms > extruder_autofan_last_check + 2500) { // only need to check fan state very infrequently if (ms > extruder_autofan_last_check + 2500) { // only need to check fan state very infrequently
...@@ -802,16 +825,21 @@ static float analog2temp(int raw, uint8_t e) { ...@@ -802,16 +825,21 @@ static float analog2temp(int raw, uint8_t e) {
} }
#ifdef HEATER_0_USES_MAX6675 #ifdef HEATER_0_USES_MAX6675
if (e == 0) if (e == 0)
{
return 0.25 * raw; return 0.25 * raw;
}
#endif #endif
if(heater_ttbl_map[e] != NULL) { if(heater_ttbl_map[e] != NULL)
{
float celsius = 0; float celsius = 0;
uint8_t i; uint8_t i;
short (*tt)[][2] = (short (*)[][2])(heater_ttbl_map[e]); short (*tt)[][2] = (short (*)[][2])(heater_ttbl_map[e]);
for (i=1; i<heater_ttbllen_map[e]; i++) { for (i=1; i<heater_ttbllen_map[e]; i++)
if (PGM_RD_W((*tt)[i][0]) > raw) { {
if (PGM_RD_W((*tt)[i][0]) > raw)
{
celsius = PGM_RD_W((*tt)[i-1][1]) + celsius = PGM_RD_W((*tt)[i-1][1]) +
(raw - PGM_RD_W((*tt)[i-1][0])) * (raw - PGM_RD_W((*tt)[i-1][0])) *
(float)(PGM_RD_W((*tt)[i][1]) - PGM_RD_W((*tt)[i-1][1])) / (float)(PGM_RD_W((*tt)[i][1]) - PGM_RD_W((*tt)[i-1][1])) /
...@@ -835,8 +863,10 @@ static float analog2tempBed(int raw) { ...@@ -835,8 +863,10 @@ static float analog2tempBed(int raw) {
float celsius = 0; float celsius = 0;
byte i; byte i;
for (i=1; i<BEDTEMPTABLE_LEN; i++) { for (i=1; i<BEDTEMPTABLE_LEN; i++)
if (PGM_RD_W(BEDTEMPTABLE[i][0]) > raw) { {
if (PGM_RD_W(BEDTEMPTABLE[i][0]) > raw)
{
celsius = PGM_RD_W(BEDTEMPTABLE[i-1][1]) + celsius = PGM_RD_W(BEDTEMPTABLE[i-1][1]) +
(raw - PGM_RD_W(BEDTEMPTABLE[i-1][0])) * (raw - PGM_RD_W(BEDTEMPTABLE[i-1][0])) *
(float)(PGM_RD_W(BEDTEMPTABLE[i][1]) - PGM_RD_W(BEDTEMPTABLE[i-1][1])) / (float)(PGM_RD_W(BEDTEMPTABLE[i][1]) - PGM_RD_W(BEDTEMPTABLE[i-1][1])) /
...@@ -864,9 +894,9 @@ static void updateTemperaturesFromRawValues() { ...@@ -864,9 +894,9 @@ static void updateTemperaturesFromRawValues() {
#endif #endif
#ifndef SINGLENOZZLE #ifndef SINGLENOZZLE
for(int e=0;e<EXTRUDERS;e++) for (int e = 0; e < EXTRUDERS; e++)
#else #else
int e=0; int e = 0;
#endif // !SINGLENOZZLE #endif // !SINGLENOZZLE
{ {
current_temperature[e] = analog2temp(current_temperature_raw[e], e); current_temperature[e] = analog2temp(current_temperature_raw[e], e);
...@@ -905,7 +935,8 @@ static void updateTemperaturesFromRawValues() { ...@@ -905,7 +935,8 @@ static void updateTemperaturesFromRawValues() {
#endif #endif
void tp_init() { void tp_init()
{
#if MB(RUMBA) && ((TEMP_SENSOR_0==-1)||(TEMP_SENSOR_1==-1)||(TEMP_SENSOR_2==-1)||(TEMP_SENSOR_BED==-1)) #if MB(RUMBA) && ((TEMP_SENSOR_0==-1)||(TEMP_SENSOR_1==-1)||(TEMP_SENSOR_2==-1)||(TEMP_SENSOR_BED==-1))
//disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector //disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector
MCUCR=(1<<JTD); MCUCR=(1<<JTD);
...@@ -943,11 +974,9 @@ void tp_init() { ...@@ -943,11 +974,9 @@ void tp_init() {
#if HAS_HEATER_3 #if HAS_HEATER_3
SET_OUTPUT(HEATER_3_PIN); SET_OUTPUT(HEATER_3_PIN);
#endif #endif
#if HAS_HEATER_BED #if HAS_HEATER_BED
SET_OUTPUT(HEATER_BED_PIN); SET_OUTPUT(HEATER_BED_PIN);
#endif #endif
#if HAS_FAN #if HAS_FAN
SET_OUTPUT(FAN_PIN); SET_OUTPUT(FAN_PIN);
#ifdef FAST_PWM_FAN #ifdef FAST_PWM_FAN
...@@ -961,21 +990,16 @@ void tp_init() { ...@@ -961,21 +990,16 @@ void tp_init() {
#ifdef HEATER_0_USES_MAX6675 #ifdef HEATER_0_USES_MAX6675
#ifndef SDSUPPORT #ifndef SDSUPPORT
SET_OUTPUT(SCK_PIN); OUT_WRITE(SCK_PIN, LOW);
WRITE(SCK_PIN,0); OUT_WRITE(MOSI_PIN, HIGH);
OUT_WRITE(MISO_PIN, HIGH);
SET_OUTPUT(MOSI_PIN);
WRITE(MOSI_PIN,1);
SET_INPUT(MISO_PIN);
WRITE(MISO_PIN,1);
#else #else
pinMode(SS_PIN, OUTPUT); pinMode(SS_PIN, OUTPUT);
digitalWrite(SS_PIN, HIGH); digitalWrite(SS_PIN, HIGH);
#endif //SDSUPPORT #endif //SDSUPPORT
SET_OUTPUT(MAX6675_SS); OUT_WRITE(MAX6675_SS,HIGH);
WRITE(MAX6675_SS,1);
#endif //HEATER_0_USES_MAX6675 #endif //HEATER_0_USES_MAX6675
#ifdef DIDR2 #ifdef DIDR2
...@@ -1108,8 +1132,9 @@ void setWatch() { ...@@ -1108,8 +1132,9 @@ void setWatch() {
} }
#if defined(THERMAL_RUNAWAY_PROTECTION_PERIOD) && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0 #if defined(THERMAL_RUNAWAY_PROTECTION_PERIOD) && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0
void thermal_runaway_protection(int *state, unsigned long *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc) { void thermal_runaway_protection(int *state, unsigned long *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc)
/* {
/*
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHO("Thermal Thermal Runaway Running. Heater ID:"); SERIAL_ECHO("Thermal Thermal Runaway Running. Heater ID:");
SERIAL_ECHO(heater_id); SERIAL_ECHO(heater_id);
...@@ -1122,7 +1147,7 @@ void setWatch() { ...@@ -1122,7 +1147,7 @@ void setWatch() {
SERIAL_ECHO(" ; Target Temp:"); SERIAL_ECHO(" ; Target Temp:");
SERIAL_ECHO(target_temperature); SERIAL_ECHO(target_temperature);
SERIAL_ECHOLN(""); SERIAL_ECHOLN("");
*/ */
if ((target_temperature == 0) || thermal_runaway) if ((target_temperature == 0) || thermal_runaway)
{ {
*state = 0; *state = 0;
...@@ -1138,6 +1163,8 @@ void setWatch() { ...@@ -1138,6 +1163,8 @@ void setWatch() {
if (temperature >= target_temperature) *state = 2; if (temperature >= target_temperature) *state = 2;
break; break;
case 2: // "Temperature Stable" state case 2: // "Temperature Stable" state
{
unsigned long ms = millis();
if (temperature >= (target_temperature - hysteresis_degc)) if (temperature >= (target_temperature - hysteresis_degc))
{ {
*timer = ms; *timer = ms;
...@@ -1163,10 +1190,11 @@ void setWatch() { ...@@ -1163,10 +1190,11 @@ void setWatch() {
lcd_update(); lcd_update();
} }
} }
break; } break;
}
} }
#endif //defined (THERMAL_RUNAWAY_PROTECTION_PERIOD) && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0 }
#endif //THERMAL_RUNAWAY_PROTECTION_PERIOD
void disable_heater() { void disable_heater() {
#ifndef SINGLENOZZLE #ifndef SINGLENOZZLE
...@@ -1209,46 +1237,6 @@ void disable_heater() { ...@@ -1209,46 +1237,6 @@ void disable_heater() {
#endif #endif
} }
void max_temp_error(uint8_t e) {
disable_heater();
if(IsStopped() == false) {
SERIAL_ERROR_START;
SERIAL_ERRORLN((int)e);
SERIAL_ERRORLNPGM(MSG_MAXTEMP_EXTRUDER_OFF);
LCD_ALERTMESSAGEPGM(MSG_ERR_MAXTEMP);
}
#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
Stop();
#endif
}
void min_temp_error(uint8_t e) {
disable_heater();
if(IsStopped() == false) {
SERIAL_ERROR_START;
SERIAL_ERRORLN((int)e);
SERIAL_ERRORLNPGM(MSG_MINTEMP_EXTRUDER_OFF);
LCD_ALERTMESSAGEPGM(MSG_ERR_MINTEMP);
}
#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
Stop();
#endif
}
void bed_max_temp_error(void) {
#if HAS_HEATER_BED
WRITE_HEATER_BED(0);
#endif
if (IsStopped() == false) {
SERIAL_ERROR_START;
SERIAL_ERRORLNPGM(MSG_MAXTEMP_BED_OFF);
LCD_ALERTMESSAGEPGM(MSG_ERR_MAXTEMP_BED);
}
#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE
Stop();
#endif
}
#ifdef HEATER_0_USES_MAX6675 #ifdef HEATER_0_USES_MAX6675
#define MAX6675_HEAT_INTERVAL 250 #define MAX6675_HEAT_INTERVAL 250
long max6675_previous_millis = MAX6675_HEAT_INTERVAL; long max6675_previous_millis = MAX6675_HEAT_INTERVAL;
......
...@@ -697,7 +697,7 @@ static void lcd_prepare_menu() { ...@@ -697,7 +697,7 @@ static void lcd_prepare_menu() {
if (powersupply) { if (powersupply) {
MENU_ITEM(gcode, MSG_SWITCH_PS_OFF, PSTR("M81")); MENU_ITEM(gcode, MSG_SWITCH_PS_OFF, PSTR("M81"));
} }
else{ else {
MENU_ITEM(gcode, MSG_SWITCH_PS_ON, PSTR("M80")); MENU_ITEM(gcode, MSG_SWITCH_PS_ON, PSTR("M80"));
} }
#endif #endif
...@@ -706,7 +706,7 @@ static void lcd_prepare_menu() { ...@@ -706,7 +706,7 @@ static void lcd_prepare_menu() {
} }
#ifdef DELTA #ifdef DELTA
static void lcd_delta_calibrate_menu() { static void lcd_delta_calibrate_menu() {
START_MENU(); START_MENU();
MENU_ITEM(back, MSG_MAIN, lcd_main_menu); MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28")); MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28"));
...@@ -715,7 +715,7 @@ static void lcd_delta_calibrate_menu() { ...@@ -715,7 +715,7 @@ static void lcd_delta_calibrate_menu() {
MENU_ITEM(gcode, MSG_DELTA_CALIBRATE_Z, PSTR("G0 F8000 X0 Y90 Z0")); MENU_ITEM(gcode, MSG_DELTA_CALIBRATE_Z, PSTR("G0 F8000 X0 Y90 Z0"));
MENU_ITEM(gcode, MSG_DELTA_CALIBRATE_CENTER, PSTR("G0 F8000 X0 Y0 Z0")); MENU_ITEM(gcode, MSG_DELTA_CALIBRATE_CENTER, PSTR("G0 F8000 X0 Y0 Z0"));
END_MENU(); END_MENU();
} }
#endif // DELTA #endif // DELTA
float move_menu_scale; float move_menu_scale;
...@@ -995,6 +995,7 @@ static void lcd_control_motion_menu() { ...@@ -995,6 +995,7 @@ static void lcd_control_motion_menu() {
MENU_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_Z, &max_acceleration_units_per_sq_second[Z_AXIS], 100, 99000, reset_acceleration_rates); MENU_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_Z, &max_acceleration_units_per_sq_second[Z_AXIS], 100, 99000, reset_acceleration_rates);
MENU_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_E, &max_acceleration_units_per_sq_second[E_AXIS], 100, 99000, reset_acceleration_rates); MENU_ITEM_EDIT_CALLBACK(long5, MSG_AMAX MSG_E, &max_acceleration_units_per_sq_second[E_AXIS], 100, 99000, reset_acceleration_rates);
MENU_ITEM_EDIT(float5, MSG_A_RETRACT, &retract_acceleration, 100, 99000); MENU_ITEM_EDIT(float5, MSG_A_RETRACT, &retract_acceleration, 100, 99000);
MENU_ITEM_EDIT(float5, MSG_A_TRAVEL, &travel_acceleration, 100, 99000);
MENU_ITEM_EDIT(float52, MSG_XSTEPS, &axis_steps_per_unit[X_AXIS], 5, 9999); MENU_ITEM_EDIT(float52, MSG_XSTEPS, &axis_steps_per_unit[X_AXIS], 5, 9999);
MENU_ITEM_EDIT(float52, MSG_YSTEPS, &axis_steps_per_unit[Y_AXIS], 5, 9999); MENU_ITEM_EDIT(float52, MSG_YSTEPS, &axis_steps_per_unit[Y_AXIS], 5, 9999);
MENU_ITEM_EDIT(float51, MSG_ZSTEPS, &axis_steps_per_unit[Z_AXIS], 5, 9999); MENU_ITEM_EDIT(float51, MSG_ZSTEPS, &axis_steps_per_unit[Z_AXIS], 5, 9999);
...@@ -1018,8 +1019,7 @@ static void lcd_control_motion_menu() { ...@@ -1018,8 +1019,7 @@ static void lcd_control_motion_menu() {
END_MENU(); END_MENU();
} }
static void lcd_control_volumetric_menu() static void lcd_control_volumetric_menu() {
{
START_MENU(); START_MENU();
MENU_ITEM(back, MSG_CONTROL, lcd_control_menu); MENU_ITEM(back, MSG_CONTROL, lcd_control_menu);
......
...@@ -845,32 +845,28 @@ static void lcd_implementation_drawmenu_sddirectory(uint8_t row, const char* pst ...@@ -845,32 +845,28 @@ static void lcd_implementation_drawmenu_sddirectory(uint8_t row, const char* pst
static void lcd_implementation_quick_feedback() static void lcd_implementation_quick_feedback()
{ {
#ifdef LCD_USE_I2C_BUZZER #ifdef LCD_USE_I2C_BUZZER
#if !defined(LCD_FEEDBACK_FREQUENCY_HZ) || !defined(LCD_FEEDBACK_FREQUENCY_DURATION_MS) #if defined(LCD_FEEDBACK_FREQUENCY_DURATION_MS) && defined(LCD_FEEDBACK_FREQUENCY_HZ)
lcd_buzz(1000/6,100); lcd_buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ);
#else #else
lcd_buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS,LCD_FEEDBACK_FREQUENCY_HZ); lcd_buzz(1000/6, 100);
#endif #endif
#elif defined(BEEPER) && BEEPER > -1 #elif defined(BEEPER) && BEEPER > -1
SET_OUTPUT(BEEPER); SET_OUTPUT(BEEPER);
#if !defined(LCD_FEEDBACK_FREQUENCY_HZ) || !defined(LCD_FEEDBACK_FREQUENCY_DURATION_MS) #if !defined(LCD_FEEDBACK_FREQUENCY_HZ) || !defined(LCD_FEEDBACK_FREQUENCY_DURATION_MS)
for(int8_t i=0;i<10;i++) const unsigned int delay = 100;
{ uint8_t i = 10;
WRITE(BEEPER,HIGH);
delayMicroseconds(100);
WRITE(BEEPER,LOW);
delayMicroseconds(100);
}
#else #else
for(int8_t i=0;i<(LCD_FEEDBACK_FREQUENCY_DURATION_MS / (1000 / LCD_FEEDBACK_FREQUENCY_HZ));i++) const unsigned int delay = 1000000 / LCD_FEEDBACK_FREQUENCY_HZ / 2;
{ int8_t i = LCD_FEEDBACK_FREQUENCY_DURATION_MS * LCD_FEEDBACK_FREQUENCY_HZ / 1000;
#endif
while (i--) {
WRITE(BEEPER,HIGH); WRITE(BEEPER,HIGH);
delayMicroseconds(1000000 / LCD_FEEDBACK_FREQUENCY_HZ / 2); delayMicroseconds(delay);
WRITE(BEEPER,LOW); WRITE(BEEPER,LOW);
delayMicroseconds(1000000 / LCD_FEEDBACK_FREQUENCY_HZ / 2); delayMicroseconds(delay);
} }
#endif #endif
#endif
} }
#ifdef LCD_HAS_STATUS_INDICATORS #ifdef LCD_HAS_STATUS_INDICATORS
......
...@@ -84,7 +84,7 @@ void vector_3::debug(char* title) ...@@ -84,7 +84,7 @@ void vector_3::debug(char* title)
SERIAL_PROTOCOL(y); SERIAL_PROTOCOL(y);
SERIAL_PROTOCOLPGM(" z: "); SERIAL_PROTOCOLPGM(" z: ");
SERIAL_PROTOCOL(z); SERIAL_PROTOCOL(z);
SERIAL_PROTOCOLPGM("\n"); SERIAL_EOL;
} }
void apply_rotation_xyz(matrix_3x3 matrix, float &x, float& y, float& z) void apply_rotation_xyz(matrix_3x3 matrix, float &x, float& y, float& z)
...@@ -145,21 +145,16 @@ matrix_3x3 matrix_3x3::transpose(matrix_3x3 original) ...@@ -145,21 +145,16 @@ matrix_3x3 matrix_3x3::transpose(matrix_3x3 original)
return new_matrix; return new_matrix;
} }
void matrix_3x3::debug(char* title) void matrix_3x3::debug(char* title) {
{ SERIAL_PROTOCOLLN(title);
SERIAL_PROTOCOL(title);
SERIAL_PROTOCOL("\n");
int count = 0; int count = 0;
for(int i=0; i<3; i++) for(int i=0; i<3; i++) {
{ for(int j=0; j<3; j++) {
for(int j=0; j<3; j++) SERIAL_PROTOCOL(matrix[count] + 0.0001);
{
SERIAL_PROTOCOL(matrix[count]);
SERIAL_PROTOCOLPGM(" "); SERIAL_PROTOCOLPGM(" ");
count++; count++;
} }
SERIAL_EOL;
SERIAL_PROTOCOLPGM("\n");
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment