Commit 046d5eff authored by MagoKimbra's avatar MagoKimbra

Update more function

parent 72c7bdc1
...@@ -75,6 +75,11 @@ ...@@ -75,6 +75,11 @@
// This is used for single nozzle and multiple extrusion configuration // This is used for single nozzle and multiple extrusion configuration
// Uncomment below to enable (One Hotend) // Uncomment below to enable (One Hotend)
//#define SINGLENOZZLE //#define SINGLENOZZLE
#ifdef SINGLENOZZLE
#define HOTENDS 1
#else
#define HOTENDS EXTRUDERS
#endif
/*********************************************************************** /***********************************************************************
*********************** Multiextruder MKR4 *************************** *********************** Multiextruder MKR4 ***************************
...@@ -646,6 +651,7 @@ your extruder heater takes 2 minutes to hit the target on heating. ...@@ -646,6 +651,7 @@ your extruder heater takes 2 minutes to hit the target on heating.
//When using an LCD, uncomment the line below to display the Filament sensor data on the last line instead of status. Status will appear for 5 sec. //When using an LCD, uncomment the line below to display the Filament sensor data on the last line instead of status. Status will appear for 5 sec.
//#define FILAMENT_LCD_DISPLAY //#define FILAMENT_LCD_DISPLAY
/**********************************************************************\ /**********************************************************************\
* Support for a current sensor (Hall effect sensor like ACS712) for measure the power consumption * Support for a current sensor (Hall effect sensor like ACS712) for measure the power consumption
* Since it's more simple to deal with, we measure the DC current and we assume that POWER_VOLTAGE that comes from your power supply it's almost stable. * Since it's more simple to deal with, we measure the DC current and we assume that POWER_VOLTAGE that comes from your power supply it's almost stable.
...@@ -653,7 +659,7 @@ your extruder heater takes 2 minutes to hit the target on heating. ...@@ -653,7 +659,7 @@ your extruder heater takes 2 minutes to hit the target on heating.
* With this module we measure the Printer power consumption ignoring the Power Supply power consumption, so we consider the EFFICIENCY of our supply to be 100% so without * With this module we measure the Printer power consumption ignoring the Power Supply power consumption, so we consider the EFFICIENCY of our supply to be 100% so without
* any power dispersion. If you want to approximately add the supply consumption you can decrease the EFFICIENCY to a value less than 100. Eg: 85 is a good value. * any power dispersion. If you want to approximately add the supply consumption you can decrease the EFFICIENCY to a value less than 100. Eg: 85 is a good value.
* You can find a better value measuring the AC current with a good multimeter and moltiple it with the mains voltage. * You can find a better value measuring the AC current with a good multimeter and moltiple it with the mains voltage.
* MULTIMETER_WATT := MULTIMETER_CURRENT*MAINS_VOLTAGE * MULTIMETER_WATT := MULTIMETER_CURRENT * MAINS_VOLTAGE
* Now you have a Wattage value that you can compare with the one measured from ACS712. * Now you have a Wattage value that you can compare with the one measured from ACS712.
* NEW_EFFICENCY := (SENSOR_WATT*EFFICIENCY)/MULTIMETER_WATT * NEW_EFFICENCY := (SENSOR_WATT*EFFICIENCY)/MULTIMETER_WATT
* For now this feature is to be consider BETA as i'll have to do some accurate test to see the affidability * For now this feature is to be consider BETA as i'll have to do some accurate test to see the affidability
...@@ -661,13 +667,14 @@ your extruder heater takes 2 minutes to hit the target on heating. ...@@ -661,13 +667,14 @@ your extruder heater takes 2 minutes to hit the target on heating.
// Uncomment below to enable // Uncomment below to enable
//#define POWER_CONSUMPTION //#define POWER_CONSUMPTION
#define POWER_VOLTAGE 12.00 //(V) The power supply OUT voltage #define POWER_VOLTAGE 12.00 //(V) The power supply OUT voltage
#define POWER_ZERO 2.5 //(V) The /\V coming out from the sensor when no current flow. #define POWER_ZERO 2.5 //(V) The /\V coming out from the sensor when no current flow.
#define POWER_SENSITIVITY 0.066 //(V/A) How much increase V for 1A of increase #define POWER_SENSITIVITY 0.066 //(V/A) How much increase V for 1A of increase
#define POWER_EFFICIENCY 100.0 //(%) The power efficency of the power supply #define POWER_EFFICIENCY 100.0 //(%) The power efficency of the power supply
//When using an LCD, uncomment the line below to display the Power consumption sensor data on the last line instead of status. Status will appear for 5 sec. //When using an LCD, uncomment the line below to display the Power consumption sensor data on the last line instead of status. Status will appear for 5 sec.
//#define POWER_CONSUMPTION_LCD_DISPLAY //#define POWER_CONSUMPTION_LCD_DISPLAY
//=================================== Misc ================================= //=================================== Misc =================================
// Temperature status LEDs that display the hotend and bet temperature. // Temperature status LEDs that display the hotend and bet temperature.
......
This diff is collapsed.
...@@ -126,11 +126,6 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the log ...@@ -126,11 +126,6 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the log
#ifdef AUTO_BED_LEVELING_GRID #ifdef AUTO_BED_LEVELING_GRID
// Use one of these defines to specify the origin
// for a topographical map to be printed for your bed.
enum { OriginBackLeft, OriginFrontLeft, OriginBackRight, OriginFrontRight };
#define TOPO_ORIGIN OriginFrontLeft
#define MIN_PROBE_EDGE 10 // The probe square sides can be no smaller than this #define MIN_PROBE_EDGE 10 // The probe square sides can be no smaller than this
// Set the number of grid points per dimension // Set the number of grid points per dimension
......
...@@ -126,11 +126,6 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the lo ...@@ -126,11 +126,6 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the lo
#ifdef AUTO_BED_LEVELING_GRID #ifdef AUTO_BED_LEVELING_GRID
// Use one of these defines to specify the origin
// for a topographical map to be printed for your bed.
enum { OriginBackLeft, OriginFrontLeft, OriginBackRight, OriginFrontRight };
#define TOPO_ORIGIN OriginFrontLeft
#define MIN_PROBE_EDGE 10 // The probe square sides can be no smaller than this #define MIN_PROBE_EDGE 10 // The probe square sides can be no smaller than this
// Set the number of grid points per dimension // Set the number of grid points per dimension
......
...@@ -150,11 +150,6 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the log ...@@ -150,11 +150,6 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the log
#ifdef AUTO_BED_LEVELING_GRID #ifdef AUTO_BED_LEVELING_GRID
// Use one of these defines to specify the origin
// for a topographical map to be printed for your bed.
enum { OriginBackLeft, OriginFrontLeft, OriginBackRight, OriginFrontRight };
#define TOPO_ORIGIN OriginFrontLeft
#define MIN_PROBE_EDGE 10 // The probe square sides can be no smaller than this #define MIN_PROBE_EDGE 10 // The probe square sides can be no smaller than this
// Set the number of grid points per dimension // Set the number of grid points per dimension
......
...@@ -47,32 +47,33 @@ ...@@ -47,32 +47,33 @@
// extruder idle oozing prevention // extruder idle oozing prevention
//if the extruder motor is idle for more than SECONDS, and the temperature over MINTEMP, some filament is retracted. The filament retracted is re-added before the next extrusion //if the extruder motor is idle for more than SECONDS, and the temperature over MINTEMP, some filament is retracted. The filament retracted is re-added before the next extrusion
//#define IDLE_OOZING_PREVENT //#define IDLE_OOZING_PREVENT
#define IDLE_OOZING_MINTEMP 170 #define IDLE_OOZING_MINTEMP 170
#define IDLE_OOZING_FEEDRATE 45 //default feedrate for retracting (mm/s) #define IDLE_OOZING_FEEDRATE 45 //default feedrate for retracting (mm/s)
#define IDLE_OOZING_SECONDS 10 #define IDLE_OOZING_SECONDS 10
#define IDLE_OOZING_LENGTH 15 //default retract length (positive mm) #define IDLE_OOZING_LENGTH 15 //default retract length (positive mm)
#define IDLE_OOZING_RECOVER_LENGTH 0 //default additional recover length (mm, added to retract length when recovering) #define IDLE_OOZING_RECOVER_LENGTH 0 //default additional recover length (mm, added to retract length when recovering)
#define IDLE_OOZING_RECOVER_FEEDRATE 50 //default feedrate for recovering from retraction (mm/s) #define IDLE_OOZING_RECOVER_FEEDRATE 50 //default feedrate for recovering from retraction (mm/s)
#if defined(IDLE_OOZING_PREVENT) && IDLE_OOZING_MINTEMP < EXTRUDE_MINTEMP #if defined(IDLE_OOZING_PREVENT) && IDLE_OOZING_MINTEMP < EXTRUDE_MINTEMP
#error IDLE_OOZING_MINTEMP have to be greater than EXTRUDE_MINTEMP #error IDLE_OOZING_MINTEMP have to be greater than EXTRUDE_MINTEMP
#endif #endif
// extruder run-out prevention. // extruder run-out prevention.
//if the machine is idle, and the temperature over MINTEMP, every couple of SECONDS some filament is extruded //if the machine is idle, and the temperature over MINTEMP, every couple of SECONDS some filament is extruded
//#define EXTRUDER_RUNOUT_PREVENT //#define EXTRUDER_RUNOUT_PREVENT
#define EXTRUDER_RUNOUT_MINTEMP 190 #define EXTRUDER_RUNOUT_MINTEMP 190
#define EXTRUDER_RUNOUT_SECONDS 30 #define EXTRUDER_RUNOUT_SECONDS 30
#define EXTRUDER_RUNOUT_ESTEPS 14 //mm filament #define EXTRUDER_RUNOUT_ESTEPS 14 //mm filament
#define EXTRUDER_RUNOUT_SPEED 1500 //extrusion speed #define EXTRUDER_RUNOUT_SPEED 1500 //extrusion speed
#define EXTRUDER_RUNOUT_EXTRUDE 100 #define EXTRUDER_RUNOUT_EXTRUDE 100
#if defined(EXTRUDER_RUNOUT_PREVENT) && EXTRUDER_RUNOUT_MINTEMP < EXTRUDE_MINTEMP #if defined(EXTRUDER_RUNOUT_PREVENT) && EXTRUDER_RUNOUT_MINTEMP < EXTRUDE_MINTEMP
#error EXTRUDER_RUNOUT_MINTEMP have to be greater than EXTRUDE_MINTEMP #error EXTRUDER_RUNOUT_MINTEMP have to be greater than EXTRUDE_MINTEMP
#endif #endif
#if defined(EXTRUDER_RUNOUT_PREVENT) && defined(IDLE_OOZING_PREVENT) #if defined(EXTRUDER_RUNOUT_PREVENT) && defined(IDLE_OOZING_PREVENT)
#error EXTRUDER_RUNOUT_PREVENT and IDLE_OOZING_PREVENT are incopatible. Please comment one of them. #error EXTRUDER_RUNOUT_PREVENT and IDLE_OOZING_PREVENT are incopatible. Please comment one of them.
#endif #endif
//These defines help to calibrate the AD595 sensor in case you get wrong temperature measurements. //These defines help to calibrate the AD595 sensor in case you get wrong temperature measurements.
//The measured temperature is defined as "actualTemp = (measuredTemp * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET" //The measured temperature is defined as "actualTemp = (measuredTemp * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET"
#define TEMP_SENSOR_AD595_OFFSET 0.0 #define TEMP_SENSOR_AD595_OFFSET 0.0
...@@ -486,6 +487,12 @@ const unsigned int dropsegments=5; //everything with less than this number of st ...@@ -486,6 +487,12 @@ const unsigned int dropsegments=5; //everything with less than this number of st
#endif #endif
#endif #endif
#ifdef FILAMENTCHANGEENABLE
#ifdef EXTRUDER_RUNOUT_PREVENT
#error EXTRUDER_RUNOUT_PREVENT currently incompatible with FILAMENTCHANGE
#endif
#endif
/******************************************************************************\ /******************************************************************************\
* enable this section if you have TMC26X motor drivers. * enable this section if you have TMC26X motor drivers.
......
...@@ -252,19 +252,17 @@ extern float filament_size[EXTRUDERS]; // cross-sectional area of filament (in m ...@@ -252,19 +252,17 @@ extern float filament_size[EXTRUDERS]; // cross-sectional area of filament (in m
extern float volumetric_multiplier[EXTRUDERS]; // reciprocal of cross-sectional area of filament (in square millimeters), stored this way to reduce computational burden in planner extern float volumetric_multiplier[EXTRUDERS]; // reciprocal of cross-sectional area of filament (in square millimeters), stored this way to reduce computational burden in planner
extern float current_position[NUM_AXIS]; extern float current_position[NUM_AXIS];
extern float destination[NUM_AXIS]; extern float destination[NUM_AXIS];
extern float add_homing[3]; extern float home_offset[3];
// Extruder offset // Hotend offset
#if EXTRUDERS > 1 #if HOTENDS > 1
#ifndef SINGLENOZZLE #ifndef DUAL_X_CARRIAGE
#ifndef DUAL_X_CARRIAGE #define NUM_HOTEND_OFFSETS 2 // only in XY plane
#define NUM_HOTEND_OFFSETS 2 // only in XY plane #else
#else #define NUM_HOTEND_OFFSETS 3 // supports offsets in XYZ plane
#define NUM_HOTEND_OFFSETS 3 // supports offsets in XYZ plane #endif
#endif extern float hotend_offset[NUM_HOTEND_OFFSETS][HOTENDS];
extern float hotend_offset[NUM_HOTEND_OFFSETS][EXTRUDERS]; #endif // HOTENDS > 1
#endif // end SINGLENOZZLE
#endif // end EXTRUDERS
#ifdef NPR2 #ifdef NPR2
extern int old_color; // old color for system NPR2 extern int old_color; // old color for system NPR2
...@@ -300,20 +298,21 @@ extern int EtoPPressure; ...@@ -300,20 +298,21 @@ extern int EtoPPressure;
extern unsigned char fanSpeedSoftPwm; extern unsigned char fanSpeedSoftPwm;
#endif #endif
#if (defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && FILWIDTH_PIN >= 0) #if defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && (FILWIDTH_PIN >= 0)
extern float filament_width_nominal; //holds the theoretical filament diameter ie., 3.00 or 1.75 extern float filament_width_nominal; //holds the theoretical filament diameter ie., 3.00 or 1.75
extern bool filament_sensor; //indicates that filament sensor readings should control extrusion extern bool filament_sensor; //indicates that filament sensor readings should control extrusion
extern float filament_width_meas; //holds the filament diameter as accurately measured extern float filament_width_meas; //holds the filament diameter as accurately measured
extern signed char measurement_delay[]; //ring buffer to delay measurement extern signed char measurement_delay[]; //ring buffer to delay measurement
extern int delay_index1, delay_index2; //index into ring buffer extern int delay_index1, delay_index2; //index into ring buffer
extern float delay_dist; //delay distance counter extern float delay_dist; //delay distance counter
extern int meas_delay_cm; //delay distance extern int meas_delay_cm; //delay distance
#endif #endif
#if (defined(POWER_CONSUMPTION) && defined(POWER_CONSUMPTION_PIN) && POWER_CONSUMPTION_PIN >= 0) #if (defined(POWER_CONSUMPTION) && defined(POWER_CONSUMPTION_PIN) && POWER_CONSUMPTION_PIN >= 0)
extern unsigned int power_consumption_meas; //holds the power consumption as accurately measured extern unsigned int power_consumption_meas; //holds the power consumption as accurately measured
extern unsigned long power_consumption_hour; //holds the power consumption per hour as accurately measured extern unsigned long power_consumption_hour; //holds the power consumption per hour as accurately measured
#endif #endif
#ifdef FWRETRACT #ifdef FWRETRACT
extern bool autoretract_enabled; extern bool autoretract_enabled;
extern bool retracted[EXTRUDERS]; extern bool retracted[EXTRUDERS];
......
This diff is collapsed.
...@@ -504,7 +504,6 @@ void CardReader::printingHasFinished() { ...@@ -504,7 +504,6 @@ void CardReader::printingHasFinished() {
startFileprint(); startFileprint();
} }
else { else {
quickStop();
file.close(); file.close();
sdprinting = false; sdprinting = false;
if (SD_FINISHED_STEPPERRELEASE) { if (SD_FINISHED_STEPPERRELEASE) {
......
...@@ -267,38 +267,35 @@ static void lcd_implementation_status_screen() { ...@@ -267,38 +267,35 @@ static void lcd_implementation_status_screen() {
// Status line // Status line
u8g.setFont(FONT_STATUSMENU); u8g.setFont(FONT_STATUSMENU);
u8g.setPrintPos(0,63); u8g.setPrintPos(0,63);
#if (defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && FILWIDTH_PIN >= 0) && defined(FILAMENT_LCD_DISPLAY) || (defined(POWER_CONSUMPTION) && defined(POWER_CONSUMPTION_PIN) && POWER_CONSUMPTION_PIN >= 0) && defined(POWER_CONSUMPTION_LCD_DISPLAY) #if defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && (FILWIDTH_PIN >= 0) && defined(FILAMENT_LCD_DISPLAY) || (defined(POWER_CONSUMPTION) && defined(POWER_CONSUMPTION_PIN) && (POWER_CONSUMPTION_PIN >= 0) && defined(POWER_CONSUMPTION_LCD_DISPLAY)
if (millis() < message_millis + 5000) { //Display both Status message line and Filament display on the last line if (millis() < message_millis + 5000) { //Display both Status message line and Filament display on the last line
u8g.print(lcd_status_message); u8g.print(lcd_status_message);
} }
#if (defined(POWER_CONSUMPTION) && defined(POWER_CONSUMPTION_PIN) && POWER_CONSUMPTION_PIN >= 0) && defined(POWER_CONSUMPTION_LCD_DISPLAY) #if (defined(POWER_CONSUMPTION) && defined(POWER_CONSUMPTION_PIN) && POWER_CONSUMPTION_PIN >= 0) && defined(POWER_CONSUMPTION_LCD_DISPLAY)
#if (defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && FILWIDTH_PIN >= 0) && defined(FILAMENT_LCD_DISPLAY) #if (defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && FILWIDTH_PIN >= 0) && defined(FILAMENT_LCD_DISPLAY)
else if (millis() < message_millis + 10000) else if (millis() < message_millis + 10000)
#else #else
else else
#endif #endif
{ {
lcd_printPGM(PSTR("P:")); lcd_printPGM(PSTR("P:"));
u8g.print(itostr3(power_consumption_meas)); u8g.print(itostr3(power_consumption_meas));
lcd_printPGM(PSTR("W C:")); lcd_printPGM(PSTR("W C:"));
u8g.print(ltostr7(power_consumption_hour)); u8g.print(ltostr7(power_consumption_hour));
lcd_printPGM(PSTR("Wh")); lcd_printPGM(PSTR("Wh"));
} }
#endif #endif
#if (defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && FILWIDTH_PIN >= 0) && defined(FILAMENT_LCD_DISPLAY) #if (defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && FILWIDTH_PIN >= 0) && defined(FILAMENT_LCD_DISPLAY)
else { else {
lcd_printPGM(PSTR("D:")); lcd_printPGM(PSTR("D:"));
u8g.print(ftostr12ns(filament_width_meas)); u8g.print(ftostr12ns(filament_width_meas));
lcd_printPGM(PSTR("mm F:")); lcd_printPGM(PSTR("mm F:"));
u8g.print(itostr3(volumetric_multiplier[active_extruder] * 100)); u8g.print(itostr3(volumetric_multiplier[active_extruder] * 100));
u8g.print('%'); u8g.print('%');
} }
#endif #endif
#else #else
u8g.print(lcd_status_message); u8g.print(lcd_status_message);
#endif #endif
} }
......
This diff is collapsed.
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
// the source g-code and may never actually be reached if acceleration management is active. // the source g-code and may never actually be reached if acceleration management is active.
typedef struct { typedef struct {
// Fields used by the bresenham algorithm for tracing the line // Fields used by the bresenham algorithm for tracing the line
long steps_x, steps_y, steps_z, steps_e; // Step count along each axis long steps[NUM_AXIS]; // Step count along each axis
unsigned long step_event_count; // The number of step events required to complete this block unsigned long step_event_count; // The number of step events required to complete this block
long accelerate_until; // The index of the step event on which to stop acceleration long accelerate_until; // The index of the step event on which to stop acceleration
long decelerate_after; // The index of the step event on which to start decelerating long decelerate_after; // The index of the step event on which to start decelerating
...@@ -49,7 +49,7 @@ typedef struct { ...@@ -49,7 +49,7 @@ typedef struct {
#endif #endif
// Fields used by the motion planner to manage acceleration // Fields used by the motion planner to manage acceleration
// float speed_x, speed_y, speed_z, speed_e; // Nominal mm/sec for each axis // float speed_x, speed_y, speed_z, speed_e; // Nominal mm/sec for each axis
float nominal_speed; // The nominal speed for this block in mm/sec float nominal_speed; // The nominal speed for this block in mm/sec
float entry_speed; // Entry speed at previous-current junction in mm/sec float entry_speed; // Entry speed at previous-current junction in mm/sec
float max_entry_speed; // Maximum allowable junction entry speed in mm/sec float max_entry_speed; // Maximum allowable junction entry speed in mm/sec
...@@ -74,6 +74,8 @@ typedef struct { ...@@ -74,6 +74,8 @@ typedef struct {
volatile char busy; volatile char busy;
} block_t; } block_t;
#define BLOCK_MOD(n) ((n)&(BLOCK_BUFFER_SIZE-1))
#ifdef ENABLE_AUTO_BED_LEVELING #ifdef ENABLE_AUTO_BED_LEVELING
// this holds the required transform to compensate for bed level // this holds the required transform to compensate for bed level
extern matrix_3x3 plan_bed_level_matrix; extern matrix_3x3 plan_bed_level_matrix;
......
...@@ -107,11 +107,8 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 }; ...@@ -107,11 +107,8 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 };
X_DIR_WRITE(v); \ X_DIR_WRITE(v); \
X2_DIR_WRITE(v); \ X2_DIR_WRITE(v); \
} \ } \
else{ \ else { \
if (current_block->active_driver) \ if (current_block->active_driver) X2_DIR_WRITE(v); else X_DIR_WRITE(v); \
X2_DIR_WRITE(v); \
else \
X_DIR_WRITE(v); \
} }
#define X_APPLY_STEP(v,ALWAYS) \ #define X_APPLY_STEP(v,ALWAYS) \
if (extruder_duplication_enabled || ALWAYS) { \ if (extruder_duplication_enabled || ALWAYS) { \
...@@ -119,10 +116,7 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 }; ...@@ -119,10 +116,7 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 };
X2_STEP_WRITE(v); \ X2_STEP_WRITE(v); \
} \ } \
else { \ else { \
if (current_block->active_driver != 0) \ if (current_block->active_driver != 0) X2_STEP_WRITE(v); else X_STEP_WRITE(v); \
X2_STEP_WRITE(v); \
else \
X_STEP_WRITE(v); \
} }
#else #else
#define X_APPLY_DIR(v,Q) X_DIR_WRITE(v) #define X_APPLY_DIR(v,Q) X_DIR_WRITE(v)
...@@ -130,16 +124,16 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 }; ...@@ -130,16 +124,16 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 };
#endif #endif
#ifdef Y_DUAL_STEPPER_DRIVERS #ifdef Y_DUAL_STEPPER_DRIVERS
#define Y_APPLY_DIR(v,Q) Y_DIR_WRITE(v), Y2_DIR_WRITE((v) != INVERT_Y2_VS_Y_DIR) #define Y_APPLY_DIR(v,Q) { Y_DIR_WRITE(v); Y2_DIR_WRITE((v) != INVERT_Y2_VS_Y_DIR); }
#define Y_APPLY_STEP(v,Q) Y_STEP_WRITE(v), Y2_STEP_WRITE(v) #define Y_APPLY_STEP(v,Q) { Y_STEP_WRITE(v); Y2_STEP_WRITE(v); }
#else #else
#define Y_APPLY_DIR(v,Q) Y_DIR_WRITE(v) #define Y_APPLY_DIR(v,Q) Y_DIR_WRITE(v)
#define Y_APPLY_STEP(v,Q) Y_STEP_WRITE(v) #define Y_APPLY_STEP(v,Q) Y_STEP_WRITE(v)
#endif #endif
#ifdef Z_DUAL_STEPPER_DRIVERS #ifdef Z_DUAL_STEPPER_DRIVERS
#define Z_APPLY_DIR(v,Q) Z_DIR_WRITE(v), Z2_DIR_WRITE(v) #define Z_APPLY_DIR(v,Q) { Z_DIR_WRITE(v); Z2_DIR_WRITE(v); }
#define Z_APPLY_STEP(v,Q) Z_STEP_WRITE(v), Z2_STEP_WRITE(v) #define Z_APPLY_STEP(v,Q) { Z_STEP_WRITE(v); Z2_STEP_WRITE(v); }
#else #else
#define Z_APPLY_DIR(v,Q) Z_DIR_WRITE(v) #define Z_APPLY_DIR(v,Q) Z_DIR_WRITE(v)
#define Z_APPLY_STEP(v,Q) Z_STEP_WRITE(v) #define Z_APPLY_STEP(v,Q) Z_STEP_WRITE(v)
...@@ -423,7 +417,7 @@ ISR(TIMER1_COMPA_vect) { ...@@ -423,7 +417,7 @@ ISR(TIMER1_COMPA_vect) {
step_events_completed = 0; step_events_completed = 0;
#ifdef Z_LATE_ENABLE #ifdef Z_LATE_ENABLE
if (current_block->steps_z > 0) { if (current_block->steps[Z_AXIS] > 0) {
enable_z(); enable_z();
OCR1A = 2000; //1ms wait OCR1A = 2000; //1ms wait
return; return;
...@@ -464,7 +458,7 @@ ISR(TIMER1_COMPA_vect) { ...@@ -464,7 +458,7 @@ ISR(TIMER1_COMPA_vect) {
#define UPDATE_ENDSTOP(axis,AXIS,minmax,MINMAX) \ #define UPDATE_ENDSTOP(axis,AXIS,minmax,MINMAX) \
bool axis ##_## minmax ##_endstop = (READ(AXIS ##_## MINMAX ##_PIN) != AXIS ##_## MINMAX ##_ENDSTOP_INVERTING); \ bool axis ##_## minmax ##_endstop = (READ(AXIS ##_## MINMAX ##_PIN) != AXIS ##_## MINMAX ##_ENDSTOP_INVERTING); \
if (axis ##_## minmax ##_endstop && old_## axis ##_## minmax ##_endstop && (current_block->steps_## axis > 0)) { \ if (axis ##_## minmax ##_endstop && old_## axis ##_## minmax ##_endstop && (current_block->steps[AXIS ##_AXIS] > 0)) { \
endstops_trigsteps[AXIS ##_AXIS] = count_position[AXIS ##_AXIS]; \ endstops_trigsteps[AXIS ##_AXIS] = count_position[AXIS ##_AXIS]; \
endstop_## axis ##_hit = true; \ endstop_## axis ##_hit = true; \
step_events_completed = current_block->step_event_count; \ step_events_completed = current_block->step_event_count; \
...@@ -473,55 +467,54 @@ ISR(TIMER1_COMPA_vect) { ...@@ -473,55 +467,54 @@ ISR(TIMER1_COMPA_vect) {
// Check X and Y endstops // Check X and Y endstops
if (check_endstops) { if (check_endstops) {
#ifndef COREXY #ifdef COREXY
if (TEST(out_bits, X_AXIS)) // stepping along -X axis (regular cartesians bot)
#else
// Head direction in -X axis for CoreXY bots. // Head direction in -X axis for CoreXY bots.
// If DeltaX == -DeltaY, the movement is only in Y axis // If DeltaX == -DeltaY, the movement is only in Y axis
if (current_block->steps_x != current_block->steps_y || (TEST(out_bits, X_AXIS) == TEST(out_bits, Y_AXIS))) if (current_block->steps[A_AXIS] != current_block->steps[B_AXIS] || (TEST(out_bits, A_AXIS) == TEST(out_bits, B_AXIS)))
if (TEST(out_bits, X_HEAD)) if (TEST(out_bits, X_HEAD))
#else
if (TEST(out_bits, X_AXIS)) // stepping along -X axis (regular cartesians bot)
#endif #endif
{ // -direction { // -direction
#ifdef DUAL_X_CARRIAGE #ifdef DUAL_X_CARRIAGE
// with 2 x-carriages, endstops are only checked in the homing direction for the active extruder // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
if ((current_block->active_extruder == 0 && X_HOME_DIR == -1) || (current_block->active_extruder != 0 && X2_HOME_DIR == -1)) if ((current_block->active_extruder == 0 && X_HOME_DIR == -1) || (current_block->active_extruder != 0 && X2_HOME_DIR == -1))
#endif #endif
{ {
#if defined(X_MIN_PIN) && X_MIN_PIN >= 0 #if defined(X_MIN_PIN) && X_MIN_PIN >= 0
UPDATE_ENDSTOP(x, X, min, MIN); UPDATE_ENDSTOP(x, X, min, MIN);
#endif #endif
} }
} }
else { // +direction else { // +direction
#ifdef DUAL_X_CARRIAGE #ifdef DUAL_X_CARRIAGE
// with 2 x-carriages, endstops are only checked in the homing direction for the active extruder // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
if ((current_block->active_driver == 0 && X_HOME_DIR == 1) || (current_block->active_extruder != 0 && X2_HOME_DIR == 1)) if ((current_block->active_driver == 0 && X_HOME_DIR == 1) || (current_block->active_extruder != 0 && X2_HOME_DIR == 1))
#endif #endif
{ {
#if defined(X_MAX_PIN) && X_MAX_PIN >= 0 #if defined(X_MAX_PIN) && X_MAX_PIN >= 0
UPDATE_ENDSTOP(x, X, max, MAX); UPDATE_ENDSTOP(x, X, max, MAX);
#endif #endif
} }
} }
#ifdef COREXY
#ifndef COREXY // Head direction in -Y axis for CoreXY bots.
// If DeltaX == DeltaY, the movement is only in X axis
if (current_block->steps[A_AXIS] != current_block->steps[B_AXIS] || (TEST(out_bits, A_AXIS) != TEST(out_bits, B_AXIS)))
if (TEST(out_bits, Y_HEAD))
#else
if (TEST(out_bits, Y_AXIS)) // -direction if (TEST(out_bits, Y_AXIS)) // -direction
#else #endif
// Head direction in -Y axis for CoreXY bots. { // -direction
// If DeltaX == DeltaY, the movement is only in X axis #if defined(Y_MIN_PIN) && Y_MIN_PIN >= 0
if (current_block->steps_x != current_block->steps_y || (TEST(out_bits, X_AXIS) != TEST(out_bits, Y_AXIS))) UPDATE_ENDSTOP(y, Y, min, MIN);
if (TEST(out_bits, Y_HEAD)) #endif
#endif }
{ // -direction else { // +direction
#if defined(Y_MIN_PIN) && Y_MIN_PIN >= 0 #if defined(Y_MAX_PIN) && Y_MAX_PIN >= 0
UPDATE_ENDSTOP(y, Y, min, MIN); UPDATE_ENDSTOP(y, Y, max, MAX);
#endif #endif
} }
else { // +direction
#if defined(Y_MAX_PIN) && Y_MAX_PIN >= 0
UPDATE_ENDSTOP(y, Y, max, MAX);
#endif
}
} }
if (TEST(out_bits, Z_AXIS)) { // -direction if (TEST(out_bits, Z_AXIS)) { // -direction
...@@ -559,7 +552,7 @@ ISR(TIMER1_COMPA_vect) { ...@@ -559,7 +552,7 @@ ISR(TIMER1_COMPA_vect) {
if (check_endstops) { if (check_endstops) {
#if defined(E_MIN_PIN) && E_MIN_PIN > -1 #if defined(E_MIN_PIN) && E_MIN_PIN > -1
bool e_min_endstop=(READ(E_MIN_PIN) != E_MIN_ENDSTOP_INVERTING); bool e_min_endstop=(READ(E_MIN_PIN) != E_MIN_ENDSTOP_INVERTING);
if (e_min_endstop && old_e_min_endstop && (current_block->steps_e > 0)) { if (e_min_endstop && old_e_min_endstop && (current_block->steps[E_AXIS] > 0)) {
endstops_trigsteps[E_AXIS] = count_position[E_AXIS]; endstops_trigsteps[E_AXIS] = count_position[E_AXIS];
endstop_e_hit=true; endstop_e_hit=true;
step_events_completed = current_block->step_event_count; step_events_completed = current_block->step_event_count;
...@@ -582,7 +575,7 @@ ISR(TIMER1_COMPA_vect) { ...@@ -582,7 +575,7 @@ ISR(TIMER1_COMPA_vect) {
#endif #endif
#ifdef ADVANCE #ifdef ADVANCE
counter_e += current_block->steps_e; counter_e += current_block->steps[E_AXIS];
if (counter_e > 0) { if (counter_e > 0) {
counter_e -= current_block->step_event_count; counter_e -= current_block->step_event_count;
e_steps[current_block->active_driver] += TEST(out_bits, E_AXIS) ? -1 : 1; e_steps[current_block->active_driver] += TEST(out_bits, E_AXIS) ? -1 : 1;
...@@ -596,15 +589,14 @@ ISR(TIMER1_COMPA_vect) { ...@@ -596,15 +589,14 @@ ISR(TIMER1_COMPA_vect) {
* instead of doing each in turn. The extra tests add enough * 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
*/ */
counter_x += current_block->steps_x; #define STEP_ADD(axis, AXIS) \
if (counter_x > 0) X_STEP_WRITE(HIGH); counter_## axis += current_block->steps[AXIS ##_AXIS]; \
counter_y += current_block->steps_y; if (counter_## axis > 0) { AXIS ##_STEP_WRITE(HIGH); }
if (counter_y > 0) Y_STEP_WRITE(HIGH); STEP_ADD(x,X);
counter_z += current_block->steps_z; STEP_ADD(y,Y);
if (counter_z > 0) Z_STEP_WRITE(HIGH); STEP_ADD(z,Z);
#ifndef ADVANCE #ifndef ADVANCE
counter_e += current_block->steps_e; STEP_ADD(e,E);
if (counter_e > 0) E_STEP_WRITE(HIGH);
#endif #endif
#define STEP_IF_COUNTER(axis, AXIS) \ #define STEP_IF_COUNTER(axis, AXIS) \
...@@ -624,7 +616,7 @@ ISR(TIMER1_COMPA_vect) { ...@@ -624,7 +616,7 @@ ISR(TIMER1_COMPA_vect) {
#else // !CONFIG_STEPPERS_TOSHIBA #else // !CONFIG_STEPPERS_TOSHIBA
#define APPLY_MOVEMENT(axis, AXIS) \ #define APPLY_MOVEMENT(axis, AXIS) \
counter_## axis += current_block->steps_## axis; \ counter_## axis += current_block->steps[AXIS ##_AXIS]; \
if (counter_## axis > 0) { \ if (counter_## axis > 0) { \
AXIS ##_APPLY_STEP(!INVERT_## AXIS ##_STEP_PIN,0); \ AXIS ##_APPLY_STEP(!INVERT_## AXIS ##_STEP_PIN,0); \
counter_## axis -= current_block->step_event_count; \ counter_## axis -= current_block->step_event_count; \
......
This diff is collapsed.
...@@ -31,35 +31,26 @@ void tp_init(); //initialize the heating ...@@ -31,35 +31,26 @@ void tp_init(); //initialize the heating
void manage_heater(); //it is critical that this is called periodically. void manage_heater(); //it is critical that this is called periodically.
#if (defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && FILWIDTH_PIN >= 0) #if (defined(FILAMENT_SENSOR) && defined(FILWIDTH_PIN) && FILWIDTH_PIN >= 0)
// For converting raw Filament Width to milimeters // For converting raw Filament Width to milimeters
float analog2widthFil(); float analog2widthFil();
// For converting raw Filament Width to an extrusion ratio // For converting raw Filament Width to an extrusion ratio
int widthFil_to_size_ratio(); int widthFil_to_size_ratio();
#endif #endif
#if (defined(POWER_CONSUMPTION) && defined(POWER_CONSUMPTION_PIN) && POWER_CONSUMPTION_PIN >= 0) #if (defined(POWER_CONSUMPTION) && defined(POWER_CONSUMPTION_PIN) && POWER_CONSUMPTION_PIN >= 0)
// For converting raw Power Consumption to watt // For converting raw Power Consumption to watt
float analog2power(); float analog2power();
#endif #endif
// low level conversion routines // low level conversion routines
// do not use these routines and variables outside of temperature.cpp // do not use these routines and variables outside of temperature.cpp
#ifndef SINGLENOZZLE extern int target_temperature[HOTENDS];
extern int target_temperature[EXTRUDERS]; extern float current_temperature[HOTENDS];
extern float current_temperature[EXTRUDERS]; #ifdef SHOW_TEMP_ADC_VALUES
#ifdef SHOW_TEMP_ADC_VALUES extern int current_temperature_raw[HOTENDS];
extern int current_temperature_raw[EXTRUDERS]; extern int current_temperature_bed_raw;
extern int current_temperature_bed_raw; #endif
#endif
#else
extern int target_temperature[1];
extern float current_temperature[1];
#ifdef SHOW_TEMP_ADC_VALUES
extern int current_temperature_raw[1];
extern int current_temperature_bed_raw;
#endif
#endif //SINGLENOZZLE
extern int target_temperature_bed; extern int target_temperature_bed;
extern float current_temperature_bed; extern float current_temperature_bed;
...@@ -72,11 +63,7 @@ extern float current_temperature_bed; ...@@ -72,11 +63,7 @@ extern float current_temperature_bed;
#endif #endif
#ifdef PIDTEMP #ifdef PIDTEMP
#ifndef SINGLENOZZLE extern float Kp[HOTENDS],Ki[HOTENDS],Kd[HOTENDS];
extern float Kp[EXTRUDERS],Ki[EXTRUDERS],Kd[EXTRUDERS];
#else
extern float Kp[1],Ki[1],Kd[1];
#endif
float scalePID_i(float i); float scalePID_i(float i);
float scalePID_d(float d); float scalePID_d(float d);
float unscalePID_i(float i); float unscalePID_i(float i);
...@@ -94,64 +81,33 @@ extern float current_temperature_bed; ...@@ -94,64 +81,33 @@ extern float current_temperature_bed;
//high level conversion routines, for use outside of temperature.cpp //high level conversion routines, for use outside of temperature.cpp
//inline so that there is no performance decrease. //inline so that there is no performance decrease.
//deg=degreeCelsius //deg=degreeCelsius
#if HOTENDS <= 1
FORCE_INLINE float degHotend(uint8_t extruder) { #define HOTEND_ARG 0
#ifndef SINGLENOZZLE
return current_temperature[extruder];
#else #else
return current_temperature[0]; #define HOTEND_ARG hotend
#endif #endif
}
#ifdef SHOW_TEMP_ADC_VALUES FORCE_INLINE float degHotend(uint8_t hotend) { return current_temperature[HOTEND_ARG]; }
FORCE_INLINE float rawHotendTemp(uint8_t extruder) { FORCE_INLINE float degBed() { return current_temperature_bed; }
#ifndef SINGLENOZZLE
return current_temperature_raw[extruder];
#else
return current_temperature_raw[0];
#endif
}
#ifdef SHOW_TEMP_ADC_VALUES
FORCE_INLINE float rawHotendTemp(uint8_t hotend) { return current_temperature_raw[HOTEND_ARG]; }
FORCE_INLINE float rawBedTemp() { return current_temperature_bed_raw; } FORCE_INLINE float rawBedTemp() { return current_temperature_bed_raw; }
#endif //SHOW_TEMP_ADC_VALUES #endif //SHOW_TEMP_ADC_VALUES
FORCE_INLINE float degBed() { return current_temperature_bed; } FORCE_INLINE float degTargetHotend(uint8_t hotend) { return target_temperature[HOTEND_ARG]; }
FORCE_INLINE float degTargetHotend(uint8_t extruder) {
#ifndef SINGLENOZZLE
return target_temperature[extruder];
#else
return target_temperature[0];
#endif
}
FORCE_INLINE float degTargetBed() { return target_temperature_bed; } FORCE_INLINE float degTargetBed() { return target_temperature_bed; }
FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) { FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t hotend) { target_temperature[HOTEND_ARG] = celsius; }
#ifndef SINGLENOZZLE
target_temperature[extruder] = celsius;
#else
target_temperature[0] = celsius;
#endif
}
FORCE_INLINE void setTargetBed(const float &celsius) { target_temperature_bed = celsius; } FORCE_INLINE void setTargetBed(const float &celsius) { target_temperature_bed = celsius; }
FORCE_INLINE bool isHeatingHotend(uint8_t extruder) { FORCE_INLINE bool isHeatingHotend(uint8_t hotend) { return target_temperature[HOTEND_ARG] > current_temperature[HOTEND_ARG]; }
#ifndef SINGLENOZZLE
return target_temperature[extruder] > current_temperature[extruder];
#else
return target_temperature[0] > current_temperature[0];
#endif
}
FORCE_INLINE bool isHeatingBed() { return target_temperature_bed > current_temperature_bed; } FORCE_INLINE bool isHeatingBed() { return target_temperature_bed > current_temperature_bed; }
FORCE_INLINE bool isCoolingHotend(uint8_t extruder) { FORCE_INLINE bool isCoolingHotend(uint8_t hotend) { return target_temperature[HOTEND_ARG] < current_temperature[HOTEND_ARG]; }
#ifndef SINGLENOZZLE
return target_temperature[extruder] < current_temperature[extruder];
#else
return target_temperature[0] < current_temperature[0];
#endif
}
FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_temperature_bed; } FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_temperature_bed; }
...@@ -160,7 +116,7 @@ FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_tempe ...@@ -160,7 +116,7 @@ FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_tempe
#define setTargetHotend0(_celsius) setTargetHotend((_celsius), 0) #define setTargetHotend0(_celsius) setTargetHotend((_celsius), 0)
#define isHeatingHotend0() isHeatingHotend(0) #define isHeatingHotend0() isHeatingHotend(0)
#define isCoolingHotend0() isCoolingHotend(0) #define isCoolingHotend0() isCoolingHotend(0)
#if EXTRUDERS > 1 && !defined(SINGLENOZZLE) #if HOTENDS > 1
#define degHotend1() degHotend(1) #define degHotend1() degHotend(1)
#define degTargetHotend1() degTargetHotend(1) #define degTargetHotend1() degTargetHotend(1)
#define setTargetHotend1(_celsius) setTargetHotend((_celsius), 1) #define setTargetHotend1(_celsius) setTargetHotend((_celsius), 1)
...@@ -169,7 +125,7 @@ FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_tempe ...@@ -169,7 +125,7 @@ FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_tempe
#else #else
#define setTargetHotend1(_celsius) do{}while(0) #define setTargetHotend1(_celsius) do{}while(0)
#endif #endif
#if EXTRUDERS > 2 && !defined(SINGLENOZZLE) #if HOTENDS > 2
#define degHotend2() degHotend(2) #define degHotend2() degHotend(2)
#define degTargetHotend2() degTargetHotend(2) #define degTargetHotend2() degTargetHotend(2)
#define setTargetHotend2(_celsius) setTargetHotend((_celsius), 2) #define setTargetHotend2(_celsius) setTargetHotend((_celsius), 2)
...@@ -178,7 +134,7 @@ FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_tempe ...@@ -178,7 +134,7 @@ FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_tempe
#else #else
#define setTargetHotend2(_celsius) do{}while(0) #define setTargetHotend2(_celsius) do{}while(0)
#endif #endif
#if EXTRUDERS > 3 && !defined(SINGLENOZZLE) #if HOTENDS > 3
#define degHotend3() degHotend(3) #define degHotend3() degHotend(3)
#define degTargetHotend3() degTargetHotend(3) #define degTargetHotend3() degTargetHotend(3)
#define setTargetHotend3(_celsius) setTargetHotend((_celsius), 3) #define setTargetHotend3(_celsius) setTargetHotend((_celsius), 3)
...@@ -187,8 +143,8 @@ FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_tempe ...@@ -187,8 +143,8 @@ FORCE_INLINE bool isCoolingBed() { return target_temperature_bed < current_tempe
#else #else
#define setTargetHotend3(_celsius) do{}while(0) #define setTargetHotend3(_celsius) do{}while(0)
#endif #endif
#if EXTRUDERS > 4 #if HOTENDS > 4
#error Invalid number of extruders #error Invalid number of hotends
#endif #endif
int getHeaterPower(int heater); int getHeaterPower(int heater);
...@@ -217,7 +173,7 @@ FORCE_INLINE void autotempShutdown() { ...@@ -217,7 +173,7 @@ FORCE_INLINE void autotempShutdown() {
#endif #endif
} }
void PID_autotune(float temp, int extruder, int ncycles); void PID_autotune(float temp, int hotend, int ncycles);
void setExtruderAutoFanState(int pin, bool state); void setExtruderAutoFanState(int pin, bool state);
void checkExtruderAutoFans(); void checkExtruderAutoFans();
......
This diff is collapsed.
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