Filament runout sensor init

This commit is contained in:
3d-gussner 2017-10-17 08:43:55 +02:00
parent 6e3174cba2
commit b90e21d0a1
12 changed files with 202 additions and 30 deletions

View File

@ -51,6 +51,23 @@
#define EEPROM_XYZ_CAL_SKEW (EEPROM_SD_SORT - 4)
#define EEPROM_WIZARD_ACTIVE (EEPROM_XYZ_CAL_SKEW - 1)
// addition for hyperfine tuning
/*
#define EEPROM_BED_CORRECTION_FRONT_LEFT (EEPROM_WIZARD_ACTIVE - 1)
#define EEPROM_BED_CORRECTION_FRONT_RIGHT (EEPROM_BED_CORRECTION_FRONT_LEFT - 1)
#define EEPROM_BED_CORRECTION_REAR_RIGHT (EEPROM_BED_CORRECTION_FRONT_RIGHT - 1)
#define EEPROM_BED_CORRECTION_REAR_LEFT (EEPROM_BED_CORRECTION_REAR_RIGHT - 1)
// FILAMENT_RUNOUT_SENSOR
#define EEPROM_FIL_RUNOUT_ACTIVE (EEPROM_BED_CORRECTION_REAR_LEFT - 1) //0 - filament runout sensor disabled; 1 - .. activated
*/
#define EEPROM_FIL_RUNOUT_ACTIVE (EEPROM_WIZARD_ACTIVE - 1) //0 - filament runout sensor disabled; 1 - .. activated
//
#define EEPROM_FIL_RUNOUT_INVERTING (EEPROM_FIL_RUNOUT_ACTIVE - 1) //0 - filament runout sensor inverted; 1 - .. normal
#define EEPROM_ENDSTOPPULLUP_FIL_RUNOUT (EEPROM_FIL_RUNOUT_INVERTING - 1) //0 - filament runout sensor pullup; 0 - .. normal
// end FILAMENT_RUNOUT_SENSOR
// Currently running firmware, each digit stored as uint16_t.
// The flavor differentiates a dev, alpha, beta, release candidate or a release version.
#define EEPROM_FIRMWARE_VERSION_END (FW_PRUSA3D_MAGIC_LEN+8)
@ -698,7 +715,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
* Note may require analog pins to be defined for different motherboards
**********************************************************************/
// Uncomment below to enable
//#define FILAMENT_SENSOR
#define FILAMENT_SENSOR
#define FILAMENT_SENSOR_EXTRUDER_NUM 0 //The number of the extruder that has the filament sensor (0,1,2)
#define MEASUREMENT_DELAY_CM 14 //measurement delay in cm. This is the distance from filament sensor to middle of barrel

View File

@ -294,6 +294,11 @@ extern int bowden_length[4];
extern bool is_usb_printing;
extern bool homing_flag;
extern bool temp_cal_active;
// FILAMENT_RUNOUT_SENSOR
extern bool fil_runout_active;
extern bool FIL_RUNOUT_INVERTING;
extern bool ENDSTOPPULLUP_FIL_RUNOUT;
// end FILAMENT_RUNOUT_SENSOR
extern bool loading_flag;
extern unsigned int usb_printing_counter;

View File

@ -257,6 +257,13 @@ bool homing_flag = false;
bool temp_cal_active = false;
// FILAMENT_RUNOUT_SENSOR
bool fil_runout_active = false;
bool FIL_RUNOUT_INVERTING = false;
bool fil_funout_inv = false;
bool ENDSTOPPULLUP_FIL_RUNOUT = false;
// end FILAMENT_RUNOUT_SENSOR
unsigned long kicktime = millis()+100000;
unsigned int usb_printing_counter;
@ -1270,6 +1277,15 @@ void setup()
}
#endif //DEBUG_DISABLE_STARTMSGS
// FILAMENT_RUNOUT_SENSOR
#ifdef FILAMENT_RUNOUT_SENSOR
fil_runout_active = eeprom_read_byte((uint8_t*)EEPROM_FIL_RUNOUT_ACTIVE);
FIL_RUNOUT_INVERTING = eeprom_read_byte((uint8_t*)EEPROM_FIL_RUNOUT_INVERTING);
ENDSTOPPULLUP_FIL_RUNOUT = eeprom_read_byte((uint8_t*)EEPROM_ENDSTOPPULLUP_FIL_RUNOUT);
#endif
// end FILAMENT_RUNOUT_SENSOR
lcd_update_enable(true);
// Store the currently running firmware into an eeprom,
@ -2303,8 +2319,13 @@ bool gcode_M45(bool onlyZ) {
void process_commands()
{
#ifdef FILAMENT_RUNOUT_SUPPORT
SET_INPUT(FR_SENS);
#ifdef FILAMENT_RUNOUT_SENSOR
SET_INPUT(FIL_RUNOUT_PIN);
if (ENDSTOPPULLUP_FIL_RUNOUT) {
pinMode(FIL_RUNOUT_PIN, INPUT_PULLUP);
} else {
pinMode(FIL_RUNOUT_PIN, INPUT);
}
#endif
#ifdef CMDBUFFER_DEBUG
@ -2454,11 +2475,11 @@ void process_commands()
case 1: // G1
if(Stopped == false) {
#ifdef FILAMENT_RUNOUT_SUPPORT
if(READ(FR_SENS)){
feedmultiplyBckp=feedmultiply;
#ifdef FILAMENT_RUNOUT_SENSOR
if(((READ(FIL_RUNOUT_PIN) ^ FIL_RUNOUT_INVERTING) == 0) && fil_runout_active) {
//enqueue_and_echo_commands_P(PSTR(FILAMENT_RUNOUT_SCRIPT));
enquecommand_front_P((PSTR(FILAMENT_RUNOUT_SCRIPT)));
/* feedmultiplyBckp=feedmultiply;
float target[4];
float lastpos[4];
target[X_AXIS]=current_position[X_AXIS];
@ -2477,6 +2498,9 @@ void process_commands()
target[Z_AXIS]+= FILAMENTCHANGE_ZADD ;
if(target[Z_AXIS] < 20){
target[Z_AXIS]+= 20 ;
}
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], 300, active_extruder);
@ -2620,7 +2644,7 @@ void process_commands()
sprintf_P(cmd, PSTR("M220 S%i"), feedmultiplyBckp);
enquecommand(cmd);
*/
}
@ -4731,7 +4755,22 @@ Sigma_Exit:
}
SERIAL_PROTOCOLLN("");
#endif
break;
// FILAMENT_RUNOUT_SENSOR
// #if fil_runout_active && defined(FIL_RUNOUT_PIN) && FIL_RUNOUT_PIN > -1
#if defined(FIL_RUNOUT_PIN) && FIL_RUNOUT_PIN > -1
if (fil_runout_active == true) {
SERIAL_PROTOCOLRPGM(MSG_FIL_RUNOUT_SETTINGS);
if(READ(FIL_RUNOUT_PIN)^FIL_RUNOUT_INVERTING){
SERIAL_PROTOCOLRPGM(MSG_ENDSTOP_HIT);
}else{
SERIAL_PROTOCOLRPGM(MSG_ENDSTOP_OPEN);
}
SERIAL_PROTOCOLLN("");
}
#endif
// end FILAMENT_RUNOUT_SENSOR
break;
//TODO: update for all axis, use for loop
#ifdef BLINKM
case 150: // M150

View File

@ -341,3 +341,10 @@
#define(lenght=20, lines=2) MSG_PLA_FILAMENT_LOADED "Is PLA filament loaded?"
#define(lenght=20, lines=4) MSG_PLEASE_LOAD_PLA "Please load PLA filament first."
#define(length=20, lines=8) MSG_FILE_CNT "Some files will not be sorted. Max. No. of files in 1 folder for sorting is 100."
#define(length=20) MSG_FIL_RUNOUT_SETTINGS "Fil.Runout S "
#define(length=20) MSG_FIL_RUNOUT_ACTIVE_ON "Fil.Runout S [ON]"
#define(length=20) MSG_FIL_RUNOUT_ACTIVE_OFF "Fil.Runout S[OFF]"
#define(length=20) MSG_ENDSTOPPULLUP_FIL_RUNOUT_ON "Fil.RSPullup [ON]"
#define(length=20) MSG_ENDSTOPPULLUP_FIL_RUNOUT_OFF "Fil.RSPullup[OFF]"
#define(length=20) MSG_FIL_RUNOUT_INVERTING_OFF "Fil.RS [S to VCC]"
#define(length=20) MSG_FIL_RUNOUT_INVERTING_ON "Fil.RS [S to GND]"

View File

@ -18,9 +18,11 @@
#error Oops! Make sure you have 'Arduino Mega 2560' selected from the 'Tools -> Boards' menu.
#endif
#define FR_SENS 21
// FILAMENT_RUNOUT_SUPPORT
#ifdef FILAMENT_RUNOUT_SUPPORT
#define FIL_RUNOUT_PIN 24
#endif
// end FILAMENT_RUNOUT_SUPPORT
#define X_STEP_PIN 37
#define X_DIR_PIN 48
@ -223,7 +225,11 @@
#error Oops! Make sure you have 'Arduino Mega 2560' selected from the 'Tools -> Boards' menu.
#endif
#define FR_SENS 21
// FILAMENT_RUNOUT_SUPPORT
#ifdef FILAMENT_RUNOUT_SUPPORT
#define FIL_RUNOUT_PIN 24
#endif
// end FILAMENT_RUNOUT_SUPPORT
#ifdef SNMM

View File

@ -96,6 +96,14 @@ int8_t SDscrool = 0;
int8_t SilentModeMenu = 0;
// FILAMENT_RUNOUT_SENSOR
#ifdef FILAMENT_RUNOUT_SENSOR
static void lcd_fil_runout_settings_menu();
static void lcd_fil_runout_active_set();
static void lcd_fil_runout_inverting_set();
static void lcd_endstoppullup_fil_runout_set();
#endif
// end FILAMENT_RUNOUT_SENSOR
#ifdef SNMM
uint8_t snmm_extruder = 0;
#endif
@ -2637,13 +2645,19 @@ void lcd_bed_calibration_show_result(BedSkewOffsetDetectionResultType result, ui
static void lcd_show_end_stops() {
lcd.setCursor(0, 0);
lcd_printPGM((PSTR("End stops diag")));
lcd_printPGM((PSTR("End stops/sens diag")));
lcd.setCursor(0, 1);
lcd_printPGM(((READ(X_MIN_PIN) ^ X_MIN_ENDSTOP_INVERTING) == 1) ? (PSTR("X1")) : (PSTR("X0")));
lcd_printPGM(((READ(X_MIN_PIN) ^ X_MIN_ENDSTOP_INVERTING) == 1) ? (PSTR("X:1")) : (PSTR("X:0")));
lcd.setCursor(0, 2);
lcd_printPGM(((READ(Y_MIN_PIN) ^ Y_MIN_ENDSTOP_INVERTING) == 1) ? (PSTR("Y1")) : (PSTR("Y0")));
lcd_printPGM(((READ(Y_MIN_PIN) ^ Y_MIN_ENDSTOP_INVERTING) == 1) ? (PSTR("Y:1")) : (PSTR("Y:0")));
lcd.setCursor(0, 3);
lcd_printPGM(((READ(Z_MIN_PIN) ^ Z_MIN_ENDSTOP_INVERTING) == 1) ? (PSTR("Z1")) : (PSTR("Z0")));
lcd_printPGM(((READ(Z_MIN_PIN) ^ Z_MIN_ENDSTOP_INVERTING) == 1) ? (PSTR("Z:1")) : (PSTR("Z:0")));
// FILAMENT_RUNOUT_SENSOR
if (fil_runout_active) {
lcd.setCursor(4, 1);
lcd_printPGM(((READ(FIL_RUNOUT_PIN) ^ FIL_RUNOUT_INVERTING) == 1) ? (PSTR("FRS:1")) : (PSTR("FRS:0")));
}
// end FILAMENT_RUNOUT_SENSOR
}
static void menu_show_end_stops() {
@ -3438,6 +3452,65 @@ void lcd_wizard(int state) {
lcd_return_to_status();
lcd_update(2);
}
// FILAMENT_RUNOUT_SENSOR
void lcd_fil_runout_settings_menu()
{
START_MENU();
MENU_ITEM(back, MSG_SETTINGS, lcd_settings_menu);
// debug info
//lcd.setCursor(1, 5);
//lcd_printPGM((fil_runout_active == 1) ? (PSTR("S_ON ")) : (PSTR("S_OFF")));
//lcd.setCursor(7, 5);
//lcd_printPGM((FIL_RUNOUT_INVERTING == 0) ? (PSTR("I_ON ")) : (PSTR("I_OFF")));
//lcd.setCursor(13, 5);
//lcd_printPGM((ENDSTOPPULLUP_FIL_RUNOUT == 0) ? (PSTR("P_ON ")) : (PSTR("P_OFF")));
// end debug info
if (fil_runout_active == false) {
MENU_ITEM(submenu, MSG_FIL_RUNOUT_ACTIVE_OFF, lcd_fil_runout_active_set);
} else {
MENU_ITEM(submenu, MSG_FIL_RUNOUT_ACTIVE_ON, lcd_fil_runout_active_set);
if (FIL_RUNOUT_INVERTING == false) {
MENU_ITEM(function, MSG_FIL_RUNOUT_INVERTING_OFF, lcd_fil_runout_inverting_set);
} else {
MENU_ITEM(function, MSG_FIL_RUNOUT_INVERTING_ON, lcd_fil_runout_inverting_set);
}
if (ENDSTOPPULLUP_FIL_RUNOUT == false ) {
MENU_ITEM(function, MSG_ENDSTOPPULLUP_FIL_RUNOUT_OFF, lcd_endstoppullup_fil_runout_set);
} else {
MENU_ITEM(function, MSG_ENDSTOPPULLUP_FIL_RUNOUT_ON, lcd_endstoppullup_fil_runout_set);
}
}
END_MENU();
}
void lcd_fil_runout_active_set() {
fil_runout_active = !fil_runout_active;
eeprom_update_byte((unsigned char *)EEPROM_FIL_RUNOUT_ACTIVE, fil_runout_active);
digipot_init();
lcd_goto_menu(lcd_fil_runout_settings_menu, 1);
}
void lcd_fil_runout_active_tune() {
fil_runout_active = !fil_runout_active;
eeprom_update_byte((unsigned char *)EEPROM_FIL_RUNOUT_ACTIVE, fil_runout_active);
digipot_init();
lcd_goto_menu(lcd_tune_menu, 9);
}
void lcd_fil_runout_inverting_set() {
FIL_RUNOUT_INVERTING = !FIL_RUNOUT_INVERTING;
eeprom_update_byte((unsigned char *)EEPROM_FIL_RUNOUT_INVERTING, FIL_RUNOUT_INVERTING);
digipot_init();
lcd_goto_menu(lcd_fil_runout_settings_menu, 2);
}
void lcd_endstoppullup_fil_runout_set() {
ENDSTOPPULLUP_FIL_RUNOUT = !ENDSTOPPULLUP_FIL_RUNOUT;
eeprom_update_byte((unsigned char *)EEPROM_ENDSTOPPULLUP_FIL_RUNOUT, ENDSTOPPULLUP_FIL_RUNOUT);
digipot_init();
lcd_goto_menu(lcd_fil_runout_settings_menu, 3);
}
// end FILAMENT_RUNOUT_SENSOR
static void lcd_settings_menu()
{
@ -3493,8 +3566,12 @@ static void lcd_settings_menu()
MENU_ITEM(submenu, PSTR("Farm number"), lcd_farm_no);
MENU_ITEM(function, PSTR("Disable farm mode"), lcd_disable_farm_mode);
}
END_MENU();
// FILAMENT_RUNOUT_SENSOR
#ifdef FIL_RUNOUT_PIN
MENU_ITEM(submenu, MSG_FIL_RUNOUT_SETTINGS, lcd_fil_runout_settings_menu);
#endif
// end FILAMENT_RUNOUT_SENSOR
END_MENU();
}
static void lcd_calibration_menu()
@ -4796,6 +4873,17 @@ static void lcd_tune_menu()
default: MENU_ITEM(function, MSG_SILENT_MODE_OFF, lcd_silent_mode_set); break;
}
}
// FILAMENT_RUNOUT_SENSOR
#ifdef FILAMENT_RUNOUT_SUPPORT //9
if (fil_runout_active == false) {
MENU_ITEM(function, MSG_FIL_RUNOUT_ACTIVE_OFF, lcd_fil_runout_active_tune);
} else {
MENU_ITEM(function, MSG_FIL_RUNOUT_ACTIVE_ON, lcd_fil_runout_active_tune);
}
#endif
// end FILAMENT_RUNOUT_SENSOR
END_MENU();
}

View File

@ -173,11 +173,12 @@ ADDITIONAL FEATURES SETTINGS
*------------------------------------*/
// Define Prusa filament runout sensor
//#define FILAMENT_RUNOUT_SUPPORT
#define FILAMENT_RUNOUT_SUPPORT
#ifdef FILAMENT_RUNOUT_SUPPORT
#define FILAMENT_RUNOUT_SENSOR 1
#define FILAMENT_RUNOUT_SCRIPT "M600"
#endif
// end Define Prusa filament runout sensor
// temperature runaway
#define TEMP_RUNAWAY_BED_HYSTERESIS 5

View File

@ -173,10 +173,13 @@ ADDITIONAL FEATURES SETTINGS
*------------------------------------*/
// Define Prusa filament runout sensor
//#define FILAMENT_RUNOUT_SUPPORT
#define FILAMENT_RUNOUT_SUPPORT
// end Define Prusa filament runout sensor
#ifdef FILAMENT_RUNOUT_SUPPORT
#define FILAMENT_RUNOUT_SENSOR 1
#define FILAMENT_RUNOUT_SCRIPT "M600"
#endif
// temperature runaway

View File

@ -168,10 +168,13 @@ ADDITIONAL FEATURES SETTINGS
*------------------------------------*/
// Define Prusa filament runout sensor
//#define FILAMENT_RUNOUT_SUPPORT
#define FILAMENT_RUNOUT_SUPPORT
// end Define Prusa filament runout sensor
#ifdef FILAMENT_RUNOUT_SUPPORT
#define FILAMENT_RUNOUT_SENSOR 1
#define FILAMENT_RUNOUT_SCRIPT "M600"
#endif
// temperature runaway

View File

@ -170,11 +170,12 @@ ADDITIONAL FEATURES SETTINGS
*------------------------------------*/
// Define Prusa filament runout sensor
//#define FILAMENT_RUNOUT_SUPPORT
#define FILAMENT_RUNOUT_SUPPORT
#ifdef FILAMENT_RUNOUT_SUPPORT
#define FILAMENT_RUNOUT_SENSOR 1
#define FILAMENT_RUNOUT_SCRIPT "M600"
#endif
// end Define Prusa filament runout sensor
// temperature runaway
#define TEMP_RUNAWAY_BED_HYSTERESIS 5

View File

@ -168,11 +168,12 @@ ADDITIONAL FEATURES SETTINGS
*------------------------------------*/
// Define Prusa filament runout sensor
//#define FILAMENT_RUNOUT_SUPPORT
#define FILAMENT_RUNOUT_SUPPORT
#ifdef FILAMENT_RUNOUT_SUPPORT
#define FILAMENT_RUNOUT_SENSOR 1
#define FILAMENT_RUNOUT_SCRIPT "M600"
#endif
// end Define Prusa filament runout sensor
// temperature runaway
#define TEMP_RUNAWAY_BED_HYSTERESIS 5

View File

@ -170,11 +170,12 @@ ADDITIONAL FEATURES SETTINGS
*------------------------------------*/
// Define Prusa filament runout sensor
//#define FILAMENT_RUNOUT_SUPPORT
#define FILAMENT_RUNOUT_SUPPORT
#ifdef FILAMENT_RUNOUT_SUPPORT
#define FILAMENT_RUNOUT_SENSOR 1
#define FILAMENT_RUNOUT_SCRIPT "M600"
#endif
// end Define Prusa filament runout sensor
// temperature runaway
#define TEMP_RUNAWAY_BED_HYSTERESIS 5