FSensor - M600 fix + cond. translation + tunning filter and params
This commit is contained in:
parent
c6a3f073dd
commit
60b4db15e0
@ -411,9 +411,6 @@ extern void print_world_coordinates();
|
||||
extern void print_physical_coordinates();
|
||||
extern void print_mesh_bed_leveling_table();
|
||||
|
||||
#ifdef PAT9125
|
||||
extern void fsensor_init();
|
||||
#endif //PAT9125
|
||||
|
||||
//estimated time to end of the print
|
||||
extern uint16_t print_time_remaining();
|
||||
|
@ -91,10 +91,9 @@
|
||||
#include "swi2c.h"
|
||||
#endif //SWI2C
|
||||
|
||||
#ifdef PAT9125
|
||||
#include "pat9125.h"
|
||||
#ifdef FILAMENT_SENSOR
|
||||
#include "fsensor.h"
|
||||
#endif //PAT9125
|
||||
#endif //FILAMENT_SENSOR
|
||||
|
||||
#ifdef TMC2130
|
||||
#include "tmc2130.h"
|
||||
@ -686,12 +685,6 @@ void crashdet_stop_and_save_print2()
|
||||
|
||||
void crashdet_detected(uint8_t mask)
|
||||
{
|
||||
// printf("CRASH_DETECTED");
|
||||
/* while (!is_buffer_empty())
|
||||
{
|
||||
process_commands();
|
||||
cmdqueue_pop_front();
|
||||
}*/
|
||||
st_synchronize();
|
||||
static uint8_t crashDet_counter = 0;
|
||||
bool automatic_recovery_after_crash = true;
|
||||
@ -854,8 +847,10 @@ void factory_reset(char level, bool quiet)
|
||||
eeprom_update_word((uint16_t *)EEPROM_FERROR_COUNT_TOT, 0);
|
||||
eeprom_update_word((uint16_t *)EEPROM_POWER_COUNT_TOT, 0);
|
||||
|
||||
#ifdef FILAMENT_SENSOR
|
||||
fsensor_enable();
|
||||
fsensor_autoload_set(true);
|
||||
#endif //FILAMENT_SENSOR
|
||||
|
||||
WRITE(BEEPER, HIGH);
|
||||
_delay_ms(100);
|
||||
@ -1185,8 +1180,10 @@ void setup()
|
||||
tmc2130_current_h[E_AXIS] = 36;
|
||||
tmc2130_current_r[E_AXIS] = 36;
|
||||
#endif //TMC2130
|
||||
#ifdef FILAMENT_SENSOR
|
||||
//disabled filament autoload (PFW360)
|
||||
fsensor_autoload_set(false);
|
||||
#endif //FILAMENT_SENSOR
|
||||
}
|
||||
MYSERIAL.begin(BAUDRATE);
|
||||
fdev_setup_stream(uartout, uart_putchar, NULL, _FDEV_SETUP_WRITE); //setup uart out stream
|
||||
@ -1438,9 +1435,9 @@ void setup()
|
||||
// It does not make sense to load the correction matrix until the machine is homed.
|
||||
world2machine_reset();
|
||||
|
||||
#ifdef PAT9125
|
||||
#ifdef FILAMENT_SENSOR
|
||||
fsensor_init();
|
||||
#endif //PAT9125
|
||||
#endif //FILAMENT_SENSOR
|
||||
|
||||
|
||||
#if defined(CONTROLLERFAN_PIN) && (CONTROLLERFAN_PIN > -1)
|
||||
@ -1622,9 +1619,9 @@ void setup()
|
||||
setup_fan_interrupt();
|
||||
#endif //DEBUG_DISABLE_FANCHECK
|
||||
|
||||
#ifdef PAT9125
|
||||
#ifdef FILAMENT_SENSOR
|
||||
fsensor_setup_interrupt();
|
||||
#endif //PAT9125
|
||||
#endif //FILAMENT_SENSOR
|
||||
for (int i = 0; i<4; i++) EEPROM_read_B(EEPROM_BOWDEN_LENGTH + i * 2, &bowden_length[i]);
|
||||
|
||||
#ifndef DEBUG_DISABLE_STARTMSGS
|
||||
@ -1977,9 +1974,9 @@ void loop()
|
||||
isPrintPaused ? manage_inactivity(true) : manage_inactivity(false);
|
||||
checkHitEndstops();
|
||||
lcd_update(0);
|
||||
#ifdef PAT9125
|
||||
#ifdef FILAMENT_SENSOR
|
||||
fsensor_update();
|
||||
#endif //PAT9125
|
||||
#endif //FILAMENT_SENSOR
|
||||
#ifdef TMC2130
|
||||
tmc2130_check_overtemp();
|
||||
if (tmc2130_sg_crash)
|
||||
@ -3075,12 +3072,14 @@ void gcode_M701()
|
||||
|
||||
#if defined (SNMM) || defined (SNMM_V2)
|
||||
extr_adj(snmm_extruder);//loads current extruder
|
||||
#else
|
||||
#else //defined (SNMM) || defined (SNMM_V2)
|
||||
enable_z();
|
||||
custom_message = true;
|
||||
custom_message_type = 2;
|
||||
|
||||
fsensor_oq_meassure_start();
|
||||
#ifdef FILAMENT_SENSOR
|
||||
fsensor_oq_meassure_start(40);
|
||||
#endif //FILAMENT_SENSOR
|
||||
|
||||
lcd_setstatuspgm(_T(MSG_LOADING_FILAMENT));
|
||||
current_position[E_AXIS] += 40;
|
||||
@ -3121,6 +3120,7 @@ void gcode_M701()
|
||||
custom_message = false;
|
||||
custom_message_type = 0;
|
||||
|
||||
#ifdef FILAMENT_SENSOR
|
||||
fsensor_oq_meassure_stop();
|
||||
|
||||
if (!fsensor_oq_result())
|
||||
@ -3131,7 +3131,8 @@ void gcode_M701()
|
||||
if (disable)
|
||||
fsensor_disable();
|
||||
}
|
||||
#endif
|
||||
#endif //FILAMENT_SENSOR
|
||||
#endif //defined (SNMM) || defined (SNMM_V2)
|
||||
}
|
||||
/**
|
||||
* @brief Get serial number from 32U2 processor
|
||||
@ -3419,6 +3420,7 @@ void process_commands()
|
||||
} else if(code_seen('G'))
|
||||
{
|
||||
gcode_in_progress = (int)code_value();
|
||||
// printf_P(_N("BEGIN G-CODE=%u\n"), gcode_in_progress);
|
||||
switch (gcode_in_progress)
|
||||
{
|
||||
case 0: // G0 -> G1
|
||||
@ -4646,6 +4648,7 @@ void process_commands()
|
||||
default:
|
||||
printf_P(PSTR("Unknown G code: %s \n"), cmdbuffer + bufindr + CMDHDRSIZE);
|
||||
}
|
||||
// printf_P(_N("END G-CODE=%u\n"), gcode_in_progress);
|
||||
gcode_in_progress = 0;
|
||||
} // end if(code_seen('G'))
|
||||
|
||||
@ -4662,6 +4665,7 @@ void process_commands()
|
||||
} else
|
||||
{
|
||||
mcode_in_progress = (int)code_value();
|
||||
// printf_P(_N("BEGIN M-CODE=%u\n"), mcode_in_progress);
|
||||
|
||||
switch(mcode_in_progress)
|
||||
{
|
||||
@ -6969,6 +6973,7 @@ Sigma_Exit:
|
||||
default:
|
||||
printf_P(PSTR("Unknown M code: %s \n"), cmdbuffer + bufindr + CMDHDRSIZE);
|
||||
}
|
||||
// printf_P(_N("END M-CODE=%u\n"), mcode_in_progress);
|
||||
mcode_in_progress = 0;
|
||||
}
|
||||
} // end if(code_seen('M')) (end of M codes)
|
||||
@ -7136,10 +7141,10 @@ Sigma_Exit:
|
||||
dcode_2130(); break;
|
||||
#endif //TMC2130
|
||||
|
||||
#ifdef PAT9125
|
||||
case 9125: // D9125 - PAT9125
|
||||
#ifdef FILAMENT_SENSOR
|
||||
case 9125: // D9125 - FILAMENT_SENSOR
|
||||
dcode_9125(); break;
|
||||
#endif //PAT9125
|
||||
#endif //FILAMENT_SENSOR
|
||||
|
||||
}
|
||||
}
|
||||
@ -9108,14 +9113,14 @@ void M600_load_filament()
|
||||
//load_filament_time = millis();
|
||||
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
||||
|
||||
#ifdef PAT9125
|
||||
#ifdef FILAMENT_SENSOR
|
||||
fsensor_autoload_check_start();
|
||||
#endif //PAT9125
|
||||
#endif //FILAMENT_SENSOR
|
||||
while(!lcd_clicked())
|
||||
{
|
||||
manage_heater();
|
||||
manage_inactivity(true);
|
||||
#ifdef PAT9125
|
||||
#ifdef FILAMENT_SENSOR
|
||||
if (fsensor_check_autoload())
|
||||
{
|
||||
tone(BEEPER, 1000);
|
||||
@ -9123,16 +9128,16 @@ void M600_load_filament()
|
||||
noTone(BEEPER);
|
||||
break;
|
||||
}
|
||||
#endif //PAT9125
|
||||
#endif //FILAMENT_SENSOR
|
||||
}
|
||||
#ifdef PAT9125
|
||||
#ifdef FILAMENT_SENSOR
|
||||
fsensor_autoload_check_stop();
|
||||
#endif //PAT9125
|
||||
#endif //FILAMENT_SENSOR
|
||||
KEEPALIVE_STATE(IN_HANDLER);
|
||||
|
||||
#ifdef PAT9125
|
||||
fsensor_oq_meassure_start();
|
||||
#endif //PAT9125
|
||||
#ifdef FILAMENT_SENSOR
|
||||
fsensor_oq_meassure_start(70);
|
||||
#endif //FILAMENT_SENSOR
|
||||
|
||||
M600_load_filament_movements();
|
||||
|
||||
@ -9140,7 +9145,7 @@ void M600_load_filament()
|
||||
delay_keep_alive(50);
|
||||
noTone(BEEPER);
|
||||
|
||||
#ifdef PAT9125
|
||||
#ifdef FILAMENT_SENSOR
|
||||
fsensor_oq_meassure_stop();
|
||||
|
||||
if (!fsensor_oq_result())
|
||||
@ -9151,7 +9156,7 @@ void M600_load_filament()
|
||||
if (disable)
|
||||
fsensor_disable();
|
||||
}
|
||||
#endif //PAT9125
|
||||
#endif //FILAMENT_SENSOR
|
||||
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
//#define PAT9125_I2C_ADDR 0x79 //ID=HI
|
||||
//#define PAT9125_I2C_ADDR 0x73 //ID=NC
|
||||
#define PAT9125_XRES 0
|
||||
#define PAT9125_YRES 200
|
||||
#define PAT9125_YRES 240
|
||||
|
||||
//SM4 configuration
|
||||
#define SM4_DEFDELAY 500 //default step delay [us]
|
||||
|
@ -13,11 +13,11 @@
|
||||
#define FSENSOR_ERR_MAX 10 //filament sensor maximum error count for runout detection
|
||||
|
||||
//Optical quality meassurement params
|
||||
#define FSENSOR_OQ_MAX_ES 5 //maximum error sum while loading (length 95mm = 144chunks)
|
||||
#define FSENSOR_OQ_MAX_EM 1 //maximum error counter value while loading
|
||||
#define FSENSOR_OQ_MAX_ES 6 //maximum error sum while loading (length ~64mm = 100chunks)
|
||||
#define FSENSOR_OQ_MAX_EM 2 //maximum error counter value while loading
|
||||
#define FSENSOR_OQ_MIN_YD 2 //minimum yd per chunk (applied to avg value)
|
||||
#define FSENSOR_OQ_MAX_YD 200 //maximum yd per chunk (applied to avg value)
|
||||
#define FSENSOR_OQ_MAX_PD 3 //maximum positive deviation (= yd_max/yd_avg)
|
||||
#define FSENSOR_OQ_MAX_PD 4 //maximum positive deviation (= yd_max/yd_avg)
|
||||
#define FSENSOR_OQ_MAX_ND 5 //maximum negative deviation (= yd_avg/yd_min)
|
||||
#define FSENSOR_OQ_MAX_SH 13 //maximum shutter value
|
||||
|
||||
@ -51,14 +51,18 @@ bool fsensor_enabled = true;
|
||||
bool fsensor_watch_runout = true;
|
||||
//not responding - is set if any communication error occured durring initialization or readout
|
||||
bool fsensor_not_responding = false;
|
||||
//printing saved
|
||||
bool fsensor_printing_saved = false;
|
||||
|
||||
//number of errors, updated in ISR
|
||||
uint8_t fsensor_err_cnt = 0;
|
||||
//variable for accumolating step count
|
||||
//variable for accumolating step count (updated callbacks from stepper and ISR)
|
||||
int16_t fsensor_st_cnt = 0;
|
||||
//last dy value from pat9125 sensor (used in ISR)
|
||||
uint8_t fsensor_dy_old = 0;
|
||||
|
||||
//log flag: 0=log disabled, 1=log enabled
|
||||
uint8_t fsensor_log = 1;
|
||||
uint8_t fsensor_log = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//filament autoload variables
|
||||
@ -85,7 +89,7 @@ bool fsensor_oq_meassure = false;
|
||||
//skip-chunk counter, for accurate meassurement is necesary to skip first chunk...
|
||||
uint8_t fsensor_oq_skipchunk;
|
||||
//number of samples from start of meassurement
|
||||
uint8_t fsensor_oq_cnt;
|
||||
uint8_t fsensor_oq_samples;
|
||||
//sum of steps in positive direction movements
|
||||
uint16_t fsensor_oq_st_sum;
|
||||
//sum of deltas in positive direction movements
|
||||
@ -114,20 +118,12 @@ void fsensor_init(void)
|
||||
fsensor_not_responding = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
fsensor_not_responding = false;
|
||||
}
|
||||
puts_P(PSTR("FSensor "));
|
||||
if (fsensor)
|
||||
{
|
||||
fsensor_enable();
|
||||
puts_P(PSTR("ENABLED\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
fsensor_disable();
|
||||
puts_P(PSTR("DISABLED\n"));
|
||||
}
|
||||
printf_P(PSTR("FSensor %S\n"), (fsensor_enabled?PSTR("ENABLED"):PSTR("DISABLED\n")));
|
||||
}
|
||||
|
||||
bool fsensor_enable(void)
|
||||
@ -142,6 +138,7 @@ bool fsensor_enable(void)
|
||||
fsensor_watch_runout = true;
|
||||
fsensor_oq_meassure = false;
|
||||
fsensor_err_cnt = 0;
|
||||
fsensor_dy_old = 0;
|
||||
eeprom_update_byte((uint8_t*)EEPROM_FSENSOR, fsensor_enabled?0x01:0x00);
|
||||
FSensorStateMenu = fsensor_enabled?1:0;
|
||||
|
||||
@ -246,7 +243,7 @@ bool fsensor_check_autoload(void)
|
||||
if (fsensor_autoload_c != fsensor_autoload_c_old)
|
||||
printf_P(PSTR("fsensor_check_autoload dy=%d c=%d sum=%d\n"), dy, fsensor_autoload_c, fsensor_autoload_sum);
|
||||
// if ((fsensor_autoload_c >= 15) && (fsensor_autoload_sum > 30))
|
||||
if ((fsensor_autoload_c >= 10) && (fsensor_autoload_sum > 20))
|
||||
if ((fsensor_autoload_c >= 10) && (fsensor_autoload_sum > 15))
|
||||
{
|
||||
puts_P(_N("fsensor_check_autoload = true !!!\n"));
|
||||
return true;
|
||||
@ -254,11 +251,11 @@ bool fsensor_check_autoload(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
void fsensor_oq_meassure_start(void)
|
||||
void fsensor_oq_meassure_start(uint8_t skip)
|
||||
{
|
||||
printf_P(PSTR("fsensor_oq_meassure_start\n"));
|
||||
fsensor_oq_skipchunk = 10;
|
||||
fsensor_oq_cnt = 0;
|
||||
fsensor_oq_skipchunk = skip;
|
||||
fsensor_oq_samples = 0;
|
||||
fsensor_oq_st_sum = 0;
|
||||
fsensor_oq_yd_sum = 0;
|
||||
fsensor_oq_er_sum = 0;
|
||||
@ -274,12 +271,12 @@ void fsensor_oq_meassure_start(void)
|
||||
|
||||
void fsensor_oq_meassure_stop(void)
|
||||
{
|
||||
printf_P(PSTR("fsensor_oq_meassure_stop, %hhu samples\n"), fsensor_oq_cnt);
|
||||
printf_P(PSTR("fsensor_oq_meassure_stop, %hhu samples\n"), fsensor_oq_samples);
|
||||
printf_P(_N(" st_sum=%u yd_sum=%u er_sum=%u er_max=%hhu\n"), fsensor_oq_st_sum, fsensor_oq_yd_sum, fsensor_oq_er_sum, fsensor_oq_er_max);
|
||||
printf_P(_N(" yd_min=%u yd_max=%u yd_avg=%u sh_avg=%u\n"), fsensor_oq_yd_min, fsensor_oq_yd_max, (uint16_t)((uint32_t)fsensor_oq_yd_sum * FSENSOR_CHUNK_LEN / fsensor_oq_st_sum), (uint16_t)(fsensor_oq_sh_sum / fsensor_oq_cnt));
|
||||
printf_P(_N(" yd_min=%u yd_max=%u yd_avg=%u sh_avg=%u\n"), fsensor_oq_yd_min, fsensor_oq_yd_max, (uint16_t)((uint32_t)fsensor_oq_yd_sum * FSENSOR_CHUNK_LEN / fsensor_oq_st_sum), (uint16_t)(fsensor_oq_sh_sum / fsensor_oq_samples));
|
||||
fsensor_oq_meassure = false;
|
||||
fsensor_err_cnt = 0;
|
||||
fsensor_watch_runout = true;
|
||||
fsensor_err_cnt = 0;
|
||||
}
|
||||
|
||||
const char _OK[] PROGMEM = "OK";
|
||||
@ -299,7 +296,7 @@ bool fsensor_oq_result(void)
|
||||
printf_P(_N(" yd_max = %u %S\n"), fsensor_oq_yd_max, (res_yd_max?_OK:_NG));
|
||||
bool res_yd_min = (fsensor_oq_yd_min >= (yd_avg / FSENSOR_OQ_MAX_ND));
|
||||
printf_P(_N(" yd_min = %u %S\n"), fsensor_oq_yd_min, (res_yd_min?_OK:_NG));
|
||||
uint8_t sh_avg = (fsensor_oq_sh_sum / fsensor_oq_cnt);
|
||||
uint8_t sh_avg = (fsensor_oq_sh_sum / fsensor_oq_samples);
|
||||
bool res_sh_avg = (sh_avg <= FSENSOR_OQ_MAX_SH);
|
||||
printf_P(_N(" sh_avg = %hhu %S\n"), sh_avg, (res_sh_avg?_OK:_NG));
|
||||
bool res = res_er_sum && res_er_max && res_yd_avg && res_yd_max && res_yd_min && res_sh_avg;
|
||||
@ -329,15 +326,16 @@ ISR(PCINT2_vect)
|
||||
{ //movement
|
||||
if (st_cnt > 0) //positive movement
|
||||
{
|
||||
if (pat9125_y <= 0)
|
||||
{
|
||||
if (pat9125_y < 0)
|
||||
fsensor_err_cnt++;
|
||||
}
|
||||
else
|
||||
else if (pat9125_y > 0)
|
||||
{
|
||||
if (fsensor_err_cnt)
|
||||
fsensor_err_cnt--;
|
||||
}
|
||||
else //(pat9125_y == 0)
|
||||
if (fsensor_dy_old <= 0)
|
||||
fsensor_err_cnt++;
|
||||
if (fsensor_oq_meassure)
|
||||
{
|
||||
if (fsensor_oq_skipchunk)
|
||||
@ -349,10 +347,10 @@ ISR(PCINT2_vect)
|
||||
{
|
||||
if (st_cnt == FSENSOR_CHUNK_LEN)
|
||||
{
|
||||
if (fsensor_oq_yd_min > pat9125_y) fsensor_oq_yd_min = (fsensor_oq_yd_min + pat9125_y) / 2;
|
||||
if (fsensor_oq_yd_max < pat9125_y) fsensor_oq_yd_max = (fsensor_oq_yd_max + pat9125_y) / 2;
|
||||
if (pat9125_y > 0) if (fsensor_oq_yd_min > pat9125_y) fsensor_oq_yd_min = (fsensor_oq_yd_min + pat9125_y) / 2;
|
||||
if (pat9125_y >= 0) if (fsensor_oq_yd_max < pat9125_y) fsensor_oq_yd_max = (fsensor_oq_yd_max + pat9125_y) / 2;
|
||||
}
|
||||
fsensor_oq_cnt++;
|
||||
fsensor_oq_samples++;
|
||||
fsensor_oq_st_sum += st_cnt;
|
||||
fsensor_oq_yd_sum += pat9125_y;
|
||||
if (fsensor_err_cnt > old_err_cnt)
|
||||
@ -375,11 +373,13 @@ ISR(PCINT2_vect)
|
||||
if (fsensor_log)
|
||||
{
|
||||
printf_P(_N("FSENSOR cnt=%d dy=%d err=%hhu %S\n"), st_cnt, pat9125_y, fsensor_err_cnt, (fsensor_err_cnt > old_err_cnt)?_N("NG!"):_N("OK"));
|
||||
printf_P(_N("FSENSOR st_sum=%u yd_sum=%u er_sum=%u er_max=%hhu\n"), fsensor_oq_st_sum, fsensor_oq_yd_sum, fsensor_oq_er_sum, fsensor_oq_er_max);
|
||||
if (fsensor_oq_meassure) printf_P(_N("FSENSOR st_sum=%u yd_sum=%u er_sum=%u er_max=%hhu yd_max=%u\n"), fsensor_oq_st_sum, fsensor_oq_yd_sum, fsensor_oq_er_sum, fsensor_oq_er_max, fsensor_oq_yd_max);
|
||||
}
|
||||
#endif //DEBUG_FSENSOR_LOG
|
||||
|
||||
fsensor_dy_old = pat9125_y;
|
||||
pat9125_y = 0;
|
||||
|
||||
_lock = false;
|
||||
return;
|
||||
}
|
||||
@ -408,10 +408,19 @@ void fsensor_st_block_chunk(block_t* bl, int cnt)
|
||||
|
||||
void fsensor_update(void)
|
||||
{
|
||||
if (fsensor_enabled && fsensor_watch_runout)
|
||||
if (fsensor_err_cnt > FSENSOR_ERR_MAX)
|
||||
if (fsensor_enabled)
|
||||
{
|
||||
if (fsensor_printing_saved)
|
||||
{
|
||||
fsensor_printing_saved = false;
|
||||
fsensor_watch_runout = true;
|
||||
fsensor_err_cnt = 0;
|
||||
fsensor_restore_print_and_continue();
|
||||
}
|
||||
else if (fsensor_watch_runout && (fsensor_err_cnt > FSENSOR_ERR_MAX))
|
||||
{
|
||||
fsensor_stop_and_save_print();
|
||||
fsensor_printing_saved = true;
|
||||
|
||||
fsensor_err_cnt = 0;
|
||||
|
||||
@ -437,6 +446,7 @@ void fsensor_update(void)
|
||||
fsensor_watch_runout = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void fsensor_setup_interrupt(void)
|
||||
|
@ -39,7 +39,7 @@ extern void fsensor_autoload_check_stop(void);
|
||||
extern bool fsensor_check_autoload(void);
|
||||
|
||||
//optical quality meassurement support
|
||||
extern void fsensor_oq_meassure_start(void);
|
||||
extern void fsensor_oq_meassure_start(uint8_t skip);
|
||||
extern void fsensor_oq_meassure_stop(void);
|
||||
extern bool fsensor_oq_result(void);
|
||||
|
||||
|
@ -99,6 +99,9 @@ uint8_t pat9125_rd_reg(uint8_t addr);
|
||||
void pat9125_wr_reg(uint8_t addr, uint8_t data);
|
||||
uint8_t pat9125_wr_reg_verify(uint8_t addr, uint8_t data);
|
||||
|
||||
extern FILE _uartout;
|
||||
#define uartout (&_uartout)
|
||||
|
||||
|
||||
uint8_t pat9125_init(void)
|
||||
{
|
||||
@ -162,8 +165,11 @@ uint8_t pat9125_init(void)
|
||||
pat9125_PID1 = pat9125_rd_reg(PAT9125_PID1);
|
||||
pat9125_PID2 = pat9125_rd_reg(PAT9125_PID2);
|
||||
#endif //PAT9125_NEW_INIT
|
||||
pat9125_wr_reg(PAT9125_RES_X, 0);
|
||||
pat9125_wr_reg(PAT9125_RES_Y, 200);
|
||||
|
||||
pat9125_wr_reg(PAT9125_RES_X, PAT9125_XRES);
|
||||
pat9125_wr_reg(PAT9125_RES_Y, PAT9125_YRES);
|
||||
fprintf_P(uartout, PSTR("PAT9125_RES_X=%hhu\n"), pat9125_rd_reg(PAT9125_RES_X));
|
||||
fprintf_P(uartout, PSTR("PAT9125_RES_Y=%hhu\n"), pat9125_rd_reg(PAT9125_RES_Y));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -36,10 +36,10 @@
|
||||
#include "tmc2130.h"
|
||||
#endif //TMC2130
|
||||
|
||||
#ifdef PAT9125
|
||||
#ifdef FILAMENT_SENSOR
|
||||
#include "fsensor.h"
|
||||
int fsensor_counter = 0; //counter for e-steps
|
||||
#endif //PAT9125
|
||||
#endif //FILAMENT_SENSOR
|
||||
|
||||
#ifdef DEBUG_STACK_MONITOR
|
||||
uint16_t SP_min = 0x21FF;
|
||||
@ -469,10 +469,10 @@ FORCE_INLINE void stepper_next_block()
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PAT9125
|
||||
#ifdef FILAMENT_SENSOR
|
||||
fsensor_counter = 0;
|
||||
fsensor_st_block_begin(current_block);
|
||||
#endif //PAT9125
|
||||
#endif //FILAMENT_SENSOR
|
||||
// The busy flag is set by the plan_get_current_block() call.
|
||||
// current_block->busy = true;
|
||||
// Initializes the trapezoid generator from the current block. Called whenever a new
|
||||
@ -760,9 +760,9 @@ FORCE_INLINE void stepper_tick_lowres()
|
||||
#ifdef LIN_ADVANCE
|
||||
++ e_steps;
|
||||
#else
|
||||
#ifdef PAT9125
|
||||
#ifdef FILAMENT_SENSOR
|
||||
++ fsensor_counter;
|
||||
#endif //PAT9125
|
||||
#endif //FILAMENT_SENSOR
|
||||
WRITE(E0_STEP_PIN, INVERT_E_STEP_PIN);
|
||||
#endif
|
||||
}
|
||||
@ -825,9 +825,9 @@ FORCE_INLINE void stepper_tick_highres()
|
||||
#ifdef LIN_ADVANCE
|
||||
++ e_steps;
|
||||
#else
|
||||
#ifdef PAT9125
|
||||
#ifdef FILAMENT_SENSOR
|
||||
++ fsensor_counter;
|
||||
#endif //PAT9125
|
||||
#endif //FILAMENT_SENSOR
|
||||
WRITE(E0_STEP_PIN, INVERT_E_STEP_PIN);
|
||||
#endif
|
||||
}
|
||||
@ -900,9 +900,9 @@ FORCE_INLINE void isr() {
|
||||
estep_loops = (e_steps & 0x0ff00) ? 4 : e_steps;
|
||||
if (step_loops < estep_loops)
|
||||
estep_loops = step_loops;
|
||||
#ifdef PAT9125
|
||||
#ifdef FILAMENT_SENSOR
|
||||
fsensor_counter += estep_loops;
|
||||
#endif //PAT9125
|
||||
#endif //FILAMENT_SENSOR
|
||||
do {
|
||||
WRITE_NC(E0_STEP_PIN, !INVERT_E_STEP_PIN);
|
||||
-- e_steps;
|
||||
@ -1026,9 +1026,9 @@ FORCE_INLINE void isr() {
|
||||
if (eISR_Rate == 0) {
|
||||
// There is not enough time to fit even a single additional tick.
|
||||
// Tick all the extruder ticks now.
|
||||
#ifdef PAT9125
|
||||
#ifdef FILAMENT_SENSOR
|
||||
fsensor_counter += e_steps;
|
||||
#endif //PAT9125
|
||||
#endif //FILAMENT_SENSOR
|
||||
MSerial.checkRx(); // Check for serial chars.
|
||||
do {
|
||||
WRITE_NC(E0_STEP_PIN, !INVERT_E_STEP_PIN);
|
||||
@ -1048,21 +1048,21 @@ FORCE_INLINE void isr() {
|
||||
|
||||
// If current block is finished, reset pointer
|
||||
if (step_events_completed.wide >= current_block->step_event_count.wide) {
|
||||
#ifdef PAT9125
|
||||
#ifdef FILAMENT_SENSOR
|
||||
fsensor_st_block_chunk(current_block, fsensor_counter);
|
||||
fsensor_counter = 0;
|
||||
#endif //PAT9125
|
||||
#endif //FILAMENT_SENSOR
|
||||
|
||||
current_block = NULL;
|
||||
plan_discard_current_block();
|
||||
}
|
||||
#ifdef PAT9125
|
||||
#ifdef FILAMENT_SENSOR
|
||||
else if (fsensor_counter >= fsensor_chunk_len)
|
||||
{
|
||||
fsensor_st_block_chunk(current_block, fsensor_counter);
|
||||
fsensor_counter = 0;
|
||||
}
|
||||
#endif //PAT9125
|
||||
#endif //FILAMENT_SENSOR
|
||||
}
|
||||
|
||||
#ifdef TMC2130
|
||||
|
@ -23,10 +23,6 @@
|
||||
|
||||
#include "SdFatUtil.h"
|
||||
|
||||
#ifdef PAT9125
|
||||
#include "pat9125.h"
|
||||
#endif //PAT9125
|
||||
|
||||
#ifdef FILAMENT_SENSOR
|
||||
#include "fsensor.h"
|
||||
#endif //FILAMENT_SENSOR
|
||||
@ -221,9 +217,9 @@ static void lcd_menu_extruder_info();
|
||||
static void lcd_menu_xyz_y_min();
|
||||
static void lcd_menu_xyz_skew();
|
||||
static void lcd_menu_xyz_offset();
|
||||
#if defined(TMC2130) || defined(PAT9125)
|
||||
#if defined(TMC2130) || defined(FILAMENT_SENSOR)
|
||||
static void lcd_menu_fails_stats();
|
||||
#endif //TMC2130 or PAT9125
|
||||
#endif //TMC2130 or FILAMENT_SENSOR
|
||||
|
||||
void lcd_finishstatus();
|
||||
|
||||
@ -2008,7 +2004,7 @@ static void lcd_menu_extruder_info()
|
||||
fan_speed_RPM[0] = 60*fan_speed[0];
|
||||
fan_speed_RPM[1] = 60*fan_speed[1];
|
||||
|
||||
#ifdef PAT9125
|
||||
#ifdef FILAMENT_SENSOR
|
||||
// Display X and Y difference from Filament sensor
|
||||
// Display Light intensity from Filament sensor
|
||||
// Frame_Avg register represents the average brightness of all pixels within a frame (324 pixels). This
|
||||
@ -2017,7 +2013,7 @@ static void lcd_menu_extruder_info()
|
||||
// Shutter register is an index of LASER shutter time. It is automatically controlled by the chip's internal
|
||||
// auto-exposure algorithm. When the chip is tracking on a good reflection surface, the Shutter is small.
|
||||
// When the chip is tracking on a poor reflection surface, the Shutter is large. Value ranges from 0 to 46.
|
||||
pat9125_update();
|
||||
/* pat9125_update();
|
||||
lcd_printf_P(_N(
|
||||
ESC_H(0,0)
|
||||
"Nozzle FAN: %4d RPM\n"
|
||||
@ -2029,8 +2025,8 @@ static void lcd_menu_extruder_info()
|
||||
fan_speed_RPM[1],
|
||||
pat9125_x, pat9125_y,
|
||||
pat9125_b, pat9125_s
|
||||
);
|
||||
#else //PAT9125
|
||||
);*/
|
||||
#else //FILAMENT_SENSOR
|
||||
printf_P(_N(
|
||||
ESC_H(0,0)
|
||||
"Nozzle FAN: %4d RPM\n"
|
||||
@ -2039,12 +2035,12 @@ static void lcd_menu_extruder_info()
|
||||
fan_speed_RPM[0],
|
||||
fan_speed_RPM[1]
|
||||
);
|
||||
#endif //PAT9125
|
||||
#endif //FILAMENT_SENSOR
|
||||
|
||||
menu_back_if_clicked();
|
||||
}
|
||||
|
||||
#if defined(TMC2130) && defined(PAT9125)
|
||||
#if defined(TMC2130) && defined(FILAMENT_SENSOR)
|
||||
static void lcd_menu_fails_stats_total()
|
||||
{
|
||||
//01234567890123456789
|
||||
@ -2091,7 +2087,7 @@ static void lcd_menu_fails_stats()
|
||||
MENU_ITEM_SUBMENU_P(PSTR("Total"), lcd_menu_fails_stats_total);
|
||||
MENU_END();
|
||||
}
|
||||
#elif defined(PAT9125)
|
||||
#elif defined(FILAMENT_SENSOR)
|
||||
/**
|
||||
* @brief Print last print and total filament run outs
|
||||
*
|
||||
@ -2114,6 +2110,13 @@ static void lcd_menu_fails_stats()
|
||||
lcd_printf_P(PSTR(ESC_H(0,0) "Last print failures" ESC_H(1,1) "Filam. runouts %-3d" ESC_H(0,2) "Total failures" ESC_H(1,3) "Filam. runouts %-3d"), filamentLast, filamentTotal);
|
||||
menu_back_if_clicked();
|
||||
}
|
||||
#else
|
||||
static void lcd_menu_fails_stats()
|
||||
{
|
||||
MENU_BEGIN();
|
||||
MENU_ITEM_BACK_P(_T(MSG_MAIN));
|
||||
MENU_END();
|
||||
}
|
||||
#endif //TMC2130
|
||||
|
||||
|
||||
@ -5955,7 +5958,7 @@ static void lcd_main_menu()
|
||||
if ( ((fsensor_autoload_enabled == true) && (fsensor_enabled == true)))
|
||||
MENU_ITEM_SUBMENU_P(_i("AutoLoad filament"), lcd_menu_AutoLoadFilament);////MSG_AUTOLOAD_FILAMENT c=17 r=0
|
||||
else
|
||||
#endif //PAT9125
|
||||
#endif //FILAMENT_SENSOR
|
||||
MENU_ITEM_FUNCTION_P(_T(MSG_LOAD_FILAMENT), lcd_LoadFilament);
|
||||
MENU_ITEM_SUBMENU_P(_T(MSG_UNLOAD_FILAMENT), lcd_unLoadFilament);
|
||||
#endif
|
||||
@ -5970,7 +5973,7 @@ static void lcd_main_menu()
|
||||
MENU_ITEM_SUBMENU_P(_i("Statistics "), lcd_menu_statistics);////MSG_STATISTICS c=0 r=0
|
||||
}
|
||||
|
||||
#if defined(TMC2130) || defined(PAT9125)
|
||||
#if defined(TMC2130) || defined(FILAMENT_SENSOR)
|
||||
MENU_ITEM_SUBMENU_P(PSTR("Fail stats"), lcd_menu_fails_stats);
|
||||
#endif
|
||||
|
||||
|
@ -264,13 +264,6 @@
|
||||
#define Z_HIGH_POWER 200
|
||||
#endif
|
||||
|
||||
/*------------------------------------
|
||||
PAT9125 SETTINGS
|
||||
*------------------------------------*/
|
||||
|
||||
#define PAT9125_XRES 0
|
||||
#define PAT9125_YRES 255
|
||||
|
||||
/*------------------------------------
|
||||
BED SETTINGS
|
||||
*------------------------------------*/
|
||||
|
@ -264,13 +264,6 @@
|
||||
#define Z_HIGH_POWER 200
|
||||
#endif
|
||||
|
||||
/*------------------------------------
|
||||
PAT9125 SETTINGS
|
||||
*------------------------------------*/
|
||||
|
||||
#define PAT9125_XRES 0
|
||||
#define PAT9125_YRES 255
|
||||
|
||||
/*------------------------------------
|
||||
BED SETTINGS
|
||||
*------------------------------------*/
|
||||
|
@ -379,13 +379,6 @@
|
||||
#define DEFAULT_PWM_MOTOR_CURRENT_LOUD {400, 750, 750} // {XY,Z,E}
|
||||
#endif
|
||||
|
||||
/*------------------------------------
|
||||
PAT9125 SETTINGS
|
||||
*------------------------------------*/
|
||||
|
||||
#define PAT9125_XRES 0
|
||||
#define PAT9125_YRES 255
|
||||
|
||||
/*------------------------------------
|
||||
BED SETTINGS
|
||||
*------------------------------------*/
|
||||
|
Loading…
Reference in New Issue
Block a user