Merge pull request #2520 from MRprusa3d/PFW-x001bPR

FS PCB auto-detect
This commit is contained in:
DRracer 2020-03-26 17:36:18 +01:00 committed by GitHub
commit 65228a046e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 169 additions and 74 deletions

View File

@ -46,6 +46,7 @@
//-// //-//
#include "Configuration.h" #include "Configuration.h"
#include "Marlin.h" #include "Marlin.h"
#include "config.h"
#ifdef ENABLE_AUTO_BED_LEVELING #ifdef ENABLE_AUTO_BED_LEVELING
#include "vector_3.h" #include "vector_3.h"
@ -9484,10 +9485,15 @@ static void handleSafetyTimer()
} }
#endif //SAFETYTIMER #endif //SAFETYTIMER
#define FS_CHECK_COUNT 15
void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument set in Marlin.h void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument set in Marlin.h
{ {
bool bInhibitFlag;
#ifdef FILAMENT_SENSOR #ifdef FILAMENT_SENSOR
bool bInhibitFlag;
#ifdef IR_SENSOR_ANALOG
static uint8_t nFSCheckCount=0;
#endif // IR_SENSOR_ANALOG
if (mmu_enabled == false) if (mmu_enabled == false)
{ {
//-// if (mcode_in_progress != 600) //M600 not in progress //-// if (mcode_in_progress != 600) //M600 not in progress
@ -9496,11 +9502,35 @@ bool bInhibitFlag;
#endif // PAT9125 #endif // PAT9125
#ifdef IR_SENSOR #ifdef IR_SENSOR
bInhibitFlag=(menu_menu==lcd_menu_show_sensors_state); // Support::SensorInfo menu active bInhibitFlag=(menu_menu==lcd_menu_show_sensors_state); // Support::SensorInfo menu active
#ifdef IR_SENSOR_ANALOG
bInhibitFlag=bInhibitFlag||bMenuFSDetect; // Settings::HWsetup::FSdetect menu active
#endif // IR_SENSOR_ANALOG
#endif // IR_SENSOR #endif // IR_SENSOR
if ((mcode_in_progress != 600) && (eFilamentAction != FilamentAction::AutoLoad) && (!bInhibitFlag)) //M600 not in progress, preHeat @ autoLoad menu not active, Support::ExtruderInfo/SensorInfo menu not active if ((mcode_in_progress != 600) && (eFilamentAction != FilamentAction::AutoLoad) && (!bInhibitFlag)) //M600 not in progress, preHeat @ autoLoad menu not active, Support::ExtruderInfo/SensorInfo menu not active
{ {
if (!moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LcdCommands::Layer1Cal) && ! eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE)) if (!moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LcdCommands::Layer1Cal) && ! eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE))
{ {
#ifdef IR_SENSOR_ANALOG
bool bTemp=current_voltage_raw_IR>IRsensor_Hmin_TRESHOLD;
bTemp=bTemp&&current_voltage_raw_IR<IRsensor_Hopen_TRESHOLD;
bTemp=bTemp&&(!CHECK_ALL_HEATERS);
bTemp=bTemp&&(menu_menu==lcd_status_screen);
bTemp=bTemp&&((oFsensorPCB==ClFsensorPCB::_Old)||(oFsensorPCB==ClFsensorPCB::_Undef));
bTemp=bTemp&&fsensor_enabled;
if(bTemp)
{
nFSCheckCount++;
if(nFSCheckCount>FS_CHECK_COUNT)
{
nFSCheckCount=0; // not necessary
oFsensorPCB=ClFsensorPCB::_Rev03b;
eeprom_update_byte((uint8_t*)EEPROM_FSENSOR_PCB,(uint8_t)oFsensorPCB);
printf_IRSensorAnalogBoardChange(true);
lcd_setstatuspgm(_i("FS rev. 03b or newer"));
}
}
else nFSCheckCount=0;
#endif // IR_SENSOR_ANALOG
if (fsensor_check_autoload()) if (fsensor_check_autoload())
{ {
#ifdef PAT9125 #ifdef PAT9125

View File

@ -5,10 +5,12 @@
#include "Configuration_prusa.h" #include "Configuration_prusa.h"
#include "pins.h" #include "pins.h"
#define IR_SENSOR_ANALOG (defined(VOLT_IR_PIN) && defined(IR_SENSOR)) #if (defined(VOLT_IR_PIN) && defined(IR_SENSOR))
# define IR_SENSOR_ANALOG
#endif
//ADC configuration //ADC configuration
#if !IR_SENSOR_ANALOG #ifndef IR_SENSOR_ANALOG
#define ADC_CHAN_MSK 0b0000001001011111 //used AD channels bit mask (0,1,2,3,4,6,9) #define ADC_CHAN_MSK 0b0000001001011111 //used AD channels bit mask (0,1,2,3,4,6,9)
#define ADC_DIDR_MSK 0b0000001001011111 //AD channels DIDR mask (1 ~ disabled digital input) #define ADC_DIDR_MSK 0b0000001001011111 //AD channels DIDR mask (1 ~ disabled digital input)
#define ADC_CHAN_CNT 7 //number of used channels) #define ADC_CHAN_CNT 7 //number of used channels)
@ -56,7 +58,7 @@
#define W25X20CL_SPSR SPI_SPSR(W25X20CL_SPI_RATE) #define W25X20CL_SPSR SPI_SPSR(W25X20CL_SPI_RATE)
//LANG - Multi-language support //LANG - Multi-language support
//define LANG_MODE 0 // primary language only //#define LANG_MODE 0 // primary language only
#define LANG_MODE 1 // sec. language support #define LANG_MODE 1 // sec. language support
#define LANG_SIZE_RESERVED 0x3000 // reserved space for secondary language (12288 bytes) #define LANG_SIZE_RESERVED 0x3000 // reserved space for secondary language (12288 bytes)

View File

@ -119,7 +119,7 @@ int16_t fsensor_oq_yd_max;
uint16_t fsensor_oq_sh_sum; uint16_t fsensor_oq_sh_sum;
//! @} //! @}
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
ClFsensorPCB oFsensorPCB; ClFsensorPCB oFsensorPCB;
ClFsensorActionNA oFsensorActionNA; ClFsensorActionNA oFsensorActionNA;
bool bIRsensorStateFlag=false; bool bIRsensorStateFlag=false;
@ -188,7 +188,7 @@ void fsensor_init(void)
fsensor_not_responding = true; fsensor_not_responding = true;
} }
#endif //PAT9125 #endif //PAT9125
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
bIRsensorStateFlag=false; bIRsensorStateFlag=false;
oFsensorPCB=(ClFsensorPCB)eeprom_read_byte((uint8_t*)EEPROM_FSENSOR_PCB); oFsensorPCB=(ClFsensorPCB)eeprom_read_byte((uint8_t*)EEPROM_FSENSOR_PCB);
oFsensorActionNA=(ClFsensorActionNA)eeprom_read_byte((uint8_t*)EEPROM_FSENSOR_ACTION_NA); oFsensorActionNA=(ClFsensorActionNA)eeprom_read_byte((uint8_t*)EEPROM_FSENSOR_ACTION_NA);
@ -198,7 +198,7 @@ void fsensor_init(void)
else else
fsensor_disable(false); // (in this case) EEPROM update is not necessary fsensor_disable(false); // (in this case) EEPROM update is not necessary
printf_P(PSTR("FSensor %S"), (fsensor_enabled?PSTR("ENABLED"):PSTR("DISABLED"))); printf_P(PSTR("FSensor %S"), (fsensor_enabled?PSTR("ENABLED"):PSTR("DISABLED")));
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
printf_P(PSTR(" (sensor board revision: %S)\n"),(oFsensorPCB==ClFsensorPCB::_Rev03b)?PSTR("03b or newer"):PSTR("03 or older")); printf_P(PSTR(" (sensor board revision: %S)\n"),(oFsensorPCB==ClFsensorPCB::_Rev03b)?PSTR("03b or newer"):PSTR("03 or older"));
#else //IR_SENSOR_ANALOG #else //IR_SENSOR_ANALOG
printf_P(PSTR("\n")); printf_P(PSTR("\n"));
@ -231,7 +231,7 @@ bool fsensor_enable(bool bUpdateEEPROM)
FSensorStateMenu = 1; FSensorStateMenu = 1;
} }
#else // PAT9125 #else // PAT9125
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
if(!fsensor_IR_check()) if(!fsensor_IR_check())
{ {
bUpdateEEPROM=true; bUpdateEEPROM=true;
@ -244,7 +244,7 @@ bool fsensor_enable(bool bUpdateEEPROM)
fsensor_enabled=true; fsensor_enabled=true;
fsensor_not_responding=false; fsensor_not_responding=false;
FSensorStateMenu=1; FSensorStateMenu=1;
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
} }
#endif //IR_SENSOR_ANALOG #endif //IR_SENSOR_ANALOG
if(bUpdateEEPROM) if(bUpdateEEPROM)
@ -660,7 +660,7 @@ void fsensor_update(void)
{ {
if(digitalRead(IR_SENSOR_PIN)) if(digitalRead(IR_SENSOR_PIN))
{ // IR_SENSOR_PIN ~ H { // IR_SENSOR_PIN ~ H
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
if(!bIRsensorStateFlag) if(!bIRsensorStateFlag)
{ {
bIRsensorStateFlag=true; bIRsensorStateFlag=true;
@ -703,7 +703,7 @@ void fsensor_update(void)
#endif //IR_SENSOR_ANALOG #endif //IR_SENSOR_ANALOG
fsensor_checkpoint_print(); fsensor_checkpoint_print();
fsensor_enque_M600(); fsensor_enque_M600();
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
} }
} }
} }
@ -717,7 +717,7 @@ void fsensor_update(void)
#endif //PAT9125 #endif //PAT9125
} }
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
bool fsensor_IR_check() bool fsensor_IR_check()
{ {
uint16_t volt_IR_int; uint16_t volt_IR_int;

View File

@ -81,7 +81,7 @@ extern void fsensor_st_block_chunk(int cnt);
#endif //PAT9125 #endif //PAT9125
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
#define IR_SENSOR_STEADY 10 // [ms] #define IR_SENSOR_STEADY 10 // [ms]
enum class ClFsensorPCB:uint_least8_t enum class ClFsensorPCB:uint_least8_t

View File

@ -73,7 +73,7 @@ int current_voltage_raw_pwr = 0;
int current_voltage_raw_bed = 0; int current_voltage_raw_bed = 0;
#endif #endif
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
int current_voltage_raw_IR = 0; int current_voltage_raw_IR = 0;
#endif //IR_SENSOR_ANALOG #endif //IR_SENSOR_ANALOG
@ -210,6 +210,14 @@ static void temp_runaway_check(int _heater_id, float _target_temperature, float
static void temp_runaway_stop(bool isPreheat, bool isBed); static void temp_runaway_stop(bool isPreheat, bool isBed);
#endif #endif
// return "false", if all extruder-heaters are 'off' (ie. "true", if any heater is 'on')
bool checkAllHotends(void)
{
bool result=false;
for(int i=0;i<EXTRUDERS;i++) result=(result||(target_temperature[i]!=0));
return(result);
}
void PID_autotune(float temp, int extruder, int ncycles) void PID_autotune(float temp, int extruder, int ncycles)
{ {
pid_number_of_cycles = ncycles; pid_number_of_cycles = ncycles;
@ -1588,7 +1596,7 @@ void adc_ready(void) //callback from adc when sampling finished
#ifdef VOLT_BED_PIN #ifdef VOLT_BED_PIN
current_voltage_raw_bed = adc_values[ADC_PIN_IDX(VOLT_BED_PIN)]; // 6->9 current_voltage_raw_bed = adc_values[ADC_PIN_IDX(VOLT_BED_PIN)]; // 6->9
#endif #endif
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
current_voltage_raw_IR = adc_values[ADC_PIN_IDX(VOLT_IR_PIN)]; current_voltage_raw_IR = adc_values[ADC_PIN_IDX(VOLT_IR_PIN)];
#endif //IR_SENSOR_ANALOG #endif //IR_SENSOR_ANALOG
temp_meas_ready = true; temp_meas_ready = true;

View File

@ -47,6 +47,8 @@
void tp_init(); //initialize the heating 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.
extern bool checkAllHotends(void);
// 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
extern int target_temperature[EXTRUDERS]; extern int target_temperature[EXTRUDERS];
@ -76,7 +78,7 @@ extern int current_voltage_raw_pwr;
extern int current_voltage_raw_bed; extern int current_voltage_raw_bed;
#endif #endif
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
extern int current_voltage_raw_IR; extern int current_voltage_raw_IR;
#endif //IR_SENSOR_ANALOG #endif //IR_SENSOR_ANALOG
@ -222,6 +224,9 @@ FORCE_INLINE bool isCoolingBed() {
#error Invalid number of extruders #error Invalid number of extruders
#endif #endif
// return "false", if all heaters are 'off' (ie. "true", if any heater is 'on')
#define CHECK_ALL_HEATERS (checkAllHotends()||(target_temperature_bed!=0))
int getHeaterPower(int heater); int getHeaterPower(int heater);
void disable_heater(); void disable_heater();
void updatePID(); void updatePID();

View File

@ -68,6 +68,10 @@ uint8_t SilentModeMenu_MMU = 1; //activate mmu unit stealth mode
int8_t FSensorStateMenu = 1; int8_t FSensorStateMenu = 1;
#ifdef IR_SENSOR_ANALOG
bool bMenuFSDetect=false;
#endif //IR_SENSOR_ANALOG
#ifdef SDCARD_SORT_ALPHA #ifdef SDCARD_SORT_ALPHA
bool presort_flag = false; bool presort_flag = false;
@ -114,7 +118,7 @@ static const char* lcd_display_message_fullscreen_nonBlocking_P(const char *msg,
// void copy_and_scalePID_d(); // void copy_and_scalePID_d();
/* Different menus */ /* Different menus */
static void lcd_status_screen(); //static void lcd_status_screen(); // NOT static due to using inside "Marlin_main" module ("manage_inactivity()")
#if (LANG_MODE != 0) #if (LANG_MODE != 0)
static void lcd_language_menu(); static void lcd_language_menu();
#endif #endif
@ -235,8 +239,9 @@ static FanCheck lcd_selftest_fan_auto(int _fan);
static bool lcd_selftest_fsensor(); static bool lcd_selftest_fsensor();
#endif //PAT9125 #endif //PAT9125
static bool selftest_irsensor(); static bool selftest_irsensor();
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
static bool lcd_selftest_IRsensor(); static bool lcd_selftest_IRsensor(bool bStandalone=false);
static void lcd_detect_IRsensor();
#endif //IR_SENSOR_ANALOG #endif //IR_SENSOR_ANALOG
static void lcd_selftest_error(TestError error, const char *_error_1, const char *_error_2); static void lcd_selftest_error(TestError error, const char *_error_1, const char *_error_2);
static void lcd_colorprint_change(); static void lcd_colorprint_change();
@ -975,7 +980,7 @@ void lcdui_print_status_screen(void)
} }
// Main status screen. It's up to the implementation specific part to show what is needed. As this is very display dependent // Main status screen. It's up to the implementation specific part to show what is needed. As this is very display dependent
static void lcd_status_screen() void lcd_status_screen() // NOT static due to using inside "Marlin_main" module ("manage_inactivity()")
{ {
if (firstrun == 1) if (firstrun == 1)
{ {
@ -1952,7 +1957,7 @@ static void lcd_menu_temperatures()
menu_back_if_clicked(); menu_back_if_clicked();
} }
#if defined (VOLT_BED_PIN) || defined (VOLT_PWR_PIN) || IR_SENSOR_ANALOG #if defined (VOLT_BED_PIN) || defined (VOLT_PWR_PIN) || defined(IR_SENSOR_ANALOG)
#define VOLT_DIV_R1 10000 #define VOLT_DIV_R1 10000
#define VOLT_DIV_R2 2370 #define VOLT_DIV_R2 2370
#define VOLT_DIV_FAC ((float)VOLT_DIV_R2 / (VOLT_DIV_R2 + VOLT_DIV_R1)) #define VOLT_DIV_FAC ((float)VOLT_DIV_R2 / (VOLT_DIV_R2 + VOLT_DIV_R1))
@ -1964,27 +1969,24 @@ static void lcd_menu_temperatures()
//! | | //! | |
//! | PWR: 00.0V | c=12 r=1 //! | PWR: 00.0V | c=12 r=1
//! | Bed: 00.0V | c=12 r=1 //! | Bed: 00.0V | c=12 r=1
//! | | //! | IR : 00.0V | c=12 r=1 optional
//! ---------------------- //! ----------------------
//! @endcode //! @endcode
//! @todo Positioning of the messages and values on LCD aren't fixed to their exact place. This causes issues with translations. //! @todo Positioning of the messages and values on LCD aren't fixed to their exact place. This causes issues with translations.
static void lcd_menu_voltages() static void lcd_menu_voltages()
{ {
lcd_timeoutToStatus.stop(); //infinite timeout lcd_timeoutToStatus.stop(); //infinite timeout
float volt_pwr = VOLT_DIV_REF * ((float)current_voltage_raw_pwr / (1023 * OVERSAMPLENR)) / VOLT_DIV_FAC; float volt_pwr = VOLT_DIV_REF * ((float)current_voltage_raw_pwr / (1023 * OVERSAMPLENR)) / VOLT_DIV_FAC;
float volt_bed = VOLT_DIV_REF * ((float)current_voltage_raw_bed / (1023 * OVERSAMPLENR)) / VOLT_DIV_FAC; float volt_bed = VOLT_DIV_REF * ((float)current_voltage_raw_bed / (1023 * OVERSAMPLENR)) / VOLT_DIV_FAC;
lcd_home(); lcd_home();
#if !IR_SENSOR_ANALOG lcd_printf_P(PSTR(" PWR: %4.1fV\n" " BED: %4.1fV"), volt_pwr, volt_bed);
lcd_printf_P(PSTR("\n")); #ifdef IR_SENSOR_ANALOG
#endif //!IR_SENSOR_ANALOG float volt_IR = VOLT_DIV_REF * ((float)current_voltage_raw_IR / (1023 * OVERSAMPLENR));
lcd_printf_P(PSTR(" PWR: %4.1fV\n" " BED: %4.1fV"), volt_pwr, volt_bed); lcd_printf_P(PSTR("\n IR : %3.1fV"),volt_IR);
#if IR_SENSOR_ANALOG
float volt_IR = VOLT_DIV_REF * ((float)current_voltage_raw_IR / (1023 * OVERSAMPLENR));
lcd_printf_P(PSTR("\n IR : %3.1fV"),volt_IR);
#endif //IR_SENSOR_ANALOG #endif //IR_SENSOR_ANALOG
menu_back_if_clicked(); menu_back_if_clicked();
} }
#endif //defined (VOLT_BED_PIN) || defined (VOLT_PWR_PIN) || IR_SENSOR_ANALOG #endif //defined (VOLT_BED_PIN) || defined (VOLT_PWR_PIN) || defined(IR_SENSOR_ANALOG)
#ifdef TMC2130 #ifdef TMC2130
//! @brief Show Belt Status //! @brief Show Belt Status
@ -2158,6 +2160,23 @@ static void lcd_support_menu()
MENU_ITEM_BACK_P(_i("Date:"));////MSG_DATE c=17 r=1 MENU_ITEM_BACK_P(_i("Date:"));////MSG_DATE c=17 r=1
MENU_ITEM_BACK_P(PSTR(__DATE__)); MENU_ITEM_BACK_P(PSTR(__DATE__));
#ifdef IR_SENSOR_ANALOG
MENU_ITEM_BACK_P(STR_SEPARATOR);
MENU_ITEM_BACK_P(PSTR("Fil. sensor v.:"));
switch(oFsensorPCB)
{
case ClFsensorPCB::_Old:
MENU_ITEM_BACK_P(PSTR(" 03 or older"));
break;
case ClFsensorPCB::_Rev03b:
MENU_ITEM_BACK_P(PSTR(" 03b or newer"));
break;
case ClFsensorPCB::_Undef:
default:
MENU_ITEM_BACK_P(PSTR(" state unknown"));
}
#endif // IR_SENSOR_ANALOG
MENU_ITEM_BACK_P(STR_SEPARATOR); MENU_ITEM_BACK_P(STR_SEPARATOR);
if (mmu_enabled) if (mmu_enabled)
{ {
@ -5635,7 +5654,7 @@ SETTINGS_VERSION;
MENU_END(); MENU_END();
} }
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
static void lcd_fsensor_actionNA_set(void) static void lcd_fsensor_actionNA_set(void)
{ {
switch(oFsensorActionNA) switch(oFsensorActionNA)
@ -5701,8 +5720,9 @@ void lcd_hw_setup_menu(void) // can not be "static"
SETTINGS_NOZZLE; SETTINGS_NOZZLE;
MENU_ITEM_SUBMENU_P(_i("Checks"), lcd_checking_menu); MENU_ITEM_SUBMENU_P(_i("Checks"), lcd_checking_menu);
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
FSENSOR_ACTION_NA; FSENSOR_ACTION_NA;
MENU_ITEM_FUNCTION_P(PSTR("Fsensor Detection"), lcd_detect_IRsensor);
#endif //IR_SENSOR_ANALOG #endif //IR_SENSOR_ANALOG
MENU_END(); MENU_END();
} }
@ -7121,7 +7141,7 @@ static void lcd_tune_menu()
else { else {
MENU_ITEM_TOGGLE_P(_T(MSG_FSENSOR), _T(MSG_ON), lcd_fsensor_state_set); MENU_ITEM_TOGGLE_P(_T(MSG_FSENSOR), _T(MSG_ON), lcd_fsensor_state_set);
} }
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
FSENSOR_ACTION_NA; FSENSOR_ACTION_NA;
#endif //IR_SENSOR_ANALOG #endif //IR_SENSOR_ANALOG
#endif //FILAMENT_SENSOR #endif //FILAMENT_SENSOR
@ -7501,39 +7521,60 @@ void lcd_belttest()
} }
#endif //TMC2130 #endif //TMC2130
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
static bool lcd_selftest_IRsensor() // called also from marlin_main.cpp
{ void printf_IRSensorAnalogBoardChange(bool bPCBrev03b){
bool bAction; printf_P(PSTR("Filament sensor board change detected: revision %S\n"), bPCBrev03b ? PSTR("03b or newer") : PSTR("03 or older"));
bool bPCBrev03b; }
uint16_t volt_IR_int;
float volt_IR;
volt_IR_int=current_voltage_raw_IR; static bool lcd_selftest_IRsensor(bool bStandalone)
bPCBrev03b=(volt_IR_int<((int)IRsensor_Hopen_TRESHOLD)); {
volt_IR=VOLT_DIV_REF*((float)volt_IR_int/(1023*OVERSAMPLENR)); bool bAction;
printf_P(PSTR("Measured filament sensor high level: %4.2fV\n"),volt_IR); bool bPCBrev03b;
if(volt_IR_int<((int)IRsensor_Hmin_TRESHOLD)) uint16_t volt_IR_int;
{ float volt_IR;
lcd_selftest_error(TestError::FsensorLevel,"HIGH","");
return(false); volt_IR_int=current_voltage_raw_IR;
} bPCBrev03b=(volt_IR_int<((int)IRsensor_Hopen_TRESHOLD));
lcd_show_fullscreen_message_and_wait_P(_i("Please insert filament (but not load them!) into extruder and then press the knob.")); volt_IR=VOLT_DIV_REF*((float)volt_IR_int/(1023*OVERSAMPLENR));
volt_IR_int=current_voltage_raw_IR; printf_P(PSTR("Measured filament sensor high level: %4.2fV\n"),volt_IR);
volt_IR=VOLT_DIV_REF*((float)volt_IR_int/(1023*OVERSAMPLENR)); if(volt_IR_int < ((int)IRsensor_Hmin_TRESHOLD)){
printf_P(PSTR("Measured filament sensor low level: %4.2fV\n"),volt_IR); if(!bStandalone)
if(volt_IR_int>((int)IRsensor_Lmax_TRESHOLD)) lcd_selftest_error(TestError::FsensorLevel,"HIGH","");
{ return(false);
lcd_selftest_error(TestError::FsensorLevel,"LOW",""); }
return(false); lcd_show_fullscreen_message_and_wait_P(_i("Please insert filament (but not load them!) into extruder and then press the knob."));
} volt_IR_int=current_voltage_raw_IR;
if((bPCBrev03b?1:0)!=(uint8_t)oFsensorPCB) // safer then "(uint8_t)bPCBrev03b" volt_IR=VOLT_DIV_REF*((float)volt_IR_int/(1023*OVERSAMPLENR));
{ printf_P(PSTR("Measured filament sensor low level: %4.2fV\n"),volt_IR);
printf_P(PSTR("Filament sensor board change detected: revision %S\n"),bPCBrev03b?PSTR("03b or newer"):PSTR("03 or older")); if(volt_IR_int > ((int)IRsensor_Lmax_TRESHOLD)){
oFsensorPCB=bPCBrev03b?ClFsensorPCB::_Rev03b:ClFsensorPCB::_Old; if(!bStandalone)
eeprom_update_byte((uint8_t*)EEPROM_FSENSOR_PCB,(uint8_t)oFsensorPCB); lcd_selftest_error(TestError::FsensorLevel,"LOW","");
} return(false);
return(true); }
if((bPCBrev03b?1:0)!=(uint8_t)oFsensorPCB){ // safer then "(uint8_t)bPCBrev03b"
printf_IRSensorAnalogBoardChange(bPCBrev03b);
oFsensorPCB=bPCBrev03b?ClFsensorPCB::_Rev03b:ClFsensorPCB::_Old;
eeprom_update_byte((uint8_t*)EEPROM_FSENSOR_PCB,(uint8_t)oFsensorPCB);
}
return(true);
}
static void lcd_detect_IRsensor(){
bool bAction;
bMenuFSDetect = true; // inhibits some code inside "manage_inactivity()"
bAction = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Is the filament loaded?"), false, false);
if(!bAction){
lcd_show_fullscreen_message_and_wait_P(_i("Please unload the filament first, then repeat this action."));
return;
}
bAction = lcd_selftest_IRsensor(true);
if(bAction)
lcd_show_fullscreen_message_and_wait_P(_i("Sensor verified, remove the filament now."));
else
lcd_show_fullscreen_message_and_wait_P(_i("Verification failed, remove the filament and try again."));
bMenuFSDetect=false; // de-inhibits some code inside "manage_inactivity()"
} }
#endif //IR_SENSOR_ANALOG #endif //IR_SENSOR_ANALOG
@ -7547,7 +7588,8 @@ bool lcd_selftest()
int _progress = 0; int _progress = 0;
bool _result = true; bool _result = true;
bool _swapped_fan = false; bool _swapped_fan = false;
#if IR_SENSOR_ANALOG //#ifdef IR_SENSOR_ANALOG
#if (0)
bool bAction; bool bAction;
bAction=lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Is the filament unloaded?"),false,true); bAction=lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Is the filament unloaded?"),false,true);
if(!bAction) if(!bAction)
@ -7559,7 +7601,7 @@ bool lcd_selftest()
#ifdef TMC2130 #ifdef TMC2130
FORCE_HIGH_POWER_START; FORCE_HIGH_POWER_START;
#endif // TMC2130 #endif // TMC2130
_delay(2000); // _delay(2000);
FORCE_BL_ON_START; FORCE_BL_ON_START;
@ -7756,7 +7798,8 @@ bool lcd_selftest()
_progress = lcd_selftest_screen(TestScreen::FsensorOk, _progress, 3, true, 2000); //fil sensor OK _progress = lcd_selftest_screen(TestScreen::FsensorOk, _progress, 3, true, 2000); //fil sensor OK
} }
#endif //PAT9125 #endif //PAT9125
#if IR_SENSOR_ANALOG //#ifdef IR_SENSOR_ANALOG
#if (0)
_progress = lcd_selftest_screen(TestScreen::Fsensor, _progress, 3, true, 2000); //check filament sensor _progress = lcd_selftest_screen(TestScreen::Fsensor, _progress, 3, true, 2000); //check filament sensor
_result = lcd_selftest_IRsensor(); _result = lcd_selftest_IRsensor();
if (_result) if (_result)

View File

@ -55,8 +55,10 @@ extern bool lcd_selftest();
void lcd_menu_statistics(); void lcd_menu_statistics();
void lcd_status_screen(); // NOT static due to using inside "Marlin_main" module ("manage_inactivity()")
void lcd_menu_extruder_info(); // NOT static due to using inside "Marlin_main" module ("manage_inactivity()") void lcd_menu_extruder_info(); // NOT static due to using inside "Marlin_main" module ("manage_inactivity()")
void lcd_menu_show_sensors_state(); // NOT static due to using inside "Marlin_main" module ("manage_inactivity()") void lcd_menu_show_sensors_state(); // NOT static due to using inside "Marlin_main" module ("manage_inactivity()")
#ifdef TMC2130 #ifdef TMC2130
bool lcd_crash_detect_enabled(); bool lcd_crash_detect_enabled();
void lcd_crash_detect_enable(); void lcd_crash_detect_enable();
@ -138,6 +140,11 @@ extern uint8_t farm_status;
#define SILENT_MODE_OFF SILENT_MODE_POWER #define SILENT_MODE_OFF SILENT_MODE_POWER
#endif #endif
#ifdef IR_SENSOR_ANALOG
extern bool bMenuFSDetect;
void printf_IRSensorAnalogBoardChange(bool bPCBrev03b);
#endif //IR_SENSOR_ANALOG
extern int8_t SilentModeMenu; extern int8_t SilentModeMenu;
extern uint8_t SilentModeMenu_MMU; extern uint8_t SilentModeMenu_MMU;
@ -251,7 +258,7 @@ enum class WizState : uint8_t
void lcd_wizard(WizState state); void lcd_wizard(WizState state);
#define VOLT_DIV_REF 5 #define VOLT_DIV_REF 5
#if IR_SENSOR_ANALOG #ifdef IR_SENSOR_ANALOG
#define IRsensor_Hmin_TRESHOLD (3.0*1023*OVERSAMPLENR/VOLT_DIV_REF) // ~3.0V (0.6*Vcc) #define IRsensor_Hmin_TRESHOLD (3.0*1023*OVERSAMPLENR/VOLT_DIV_REF) // ~3.0V (0.6*Vcc)
#define IRsensor_Lmax_TRESHOLD (1.5*1023*OVERSAMPLENR/VOLT_DIV_REF) // ~1.5V (0.3*Vcc) #define IRsensor_Lmax_TRESHOLD (1.5*1023*OVERSAMPLENR/VOLT_DIV_REF) // ~1.5V (0.3*Vcc)
#define IRsensor_Hopen_TRESHOLD (4.6*1023*OVERSAMPLENR/VOLT_DIV_REF) // ~4.6V (N.C. @ Ru~20-50k, Rd'=56k, Ru'=10k) #define IRsensor_Hopen_TRESHOLD (4.6*1023*OVERSAMPLENR/VOLT_DIV_REF) // ~4.6V (N.C. @ Ru~20-50k, Rd'=56k, Ru'=10k)