FSensor tunning - filtering changed, chunk length = 0.64mm and MAX_ERR = 10
This commit is contained in:
parent
64929a78f5
commit
2c06cb68d1
@ -10,11 +10,14 @@
|
||||
#include "cmdqueue.h"
|
||||
|
||||
|
||||
const char ERRMSG_PAT9125_NOT_RESP[] PROGMEM = "PAT9125 not responding (%d)!\n";
|
||||
|
||||
#define FSENSOR_ERR_MAX 5 //filament sensor max error count
|
||||
//#define FSENSOR_ERR_MAX 5 //filament sensor max error count
|
||||
#define FSENSOR_ERR_MAX 10 //filament sensor max error count
|
||||
#define FSENSOR_INT_PIN 63 //filament sensor interrupt pin PK1
|
||||
#define FSENSOR_INT_PIN_MSK 0x02 //filament sensor interrupt pin mask (bit1)
|
||||
#define FSENSOR_CHUNK_LEN 280 //filament sensor chunk length in steps
|
||||
//#define FSENSOR_CHUNK_LEN 280 //filament sensor chunk length in steps - 1mm
|
||||
#define FSENSOR_CHUNK_LEN 180 //filament sensor chunk length in steps - 0.64mm
|
||||
|
||||
extern void stop_and_save_print_to_ram(float z_move, float e_move);
|
||||
extern void restore_print_from_ram_and_continue(float e_move);
|
||||
@ -115,7 +118,7 @@ void fsensor_autoload_check_start(void)
|
||||
// puts_P(PSTR("fsensor_autoload_check_start\n"));
|
||||
if (!pat9125_update_y()) //update sensor
|
||||
{
|
||||
puts_P(PSTR("pat9125 not responding (3).\n"));
|
||||
printf_P(ERRMSG_PAT9125_NOT_RESP, 3);
|
||||
fsensor_disable();
|
||||
fsensor_not_responding = true;
|
||||
fsensor_autoload_enabled = false;
|
||||
@ -144,7 +147,7 @@ bool fsensor_check_autoload(void)
|
||||
fsensor_autoload_last_millis = millis();
|
||||
if (!pat9125_update_y())
|
||||
{
|
||||
puts_P(PSTR("pat9125 not responding (2).\n"));
|
||||
printf_P(ERRMSG_PAT9125_NOT_RESP, 2);
|
||||
fsensor_disable();
|
||||
fsensor_not_responding = true;
|
||||
return false; //update sensor
|
||||
@ -173,74 +176,44 @@ bool fsensor_check_autoload(void)
|
||||
|
||||
ISR(PCINT2_vect)
|
||||
{
|
||||
// puts("PCINT2\n");
|
||||
if (!((fsensor_int_pin_old ^ PINK) & FSENSOR_INT_PIN_MSK)) return;
|
||||
fsensor_int_pin_old = PINK;
|
||||
static bool _lock = false;
|
||||
if (_lock) return;
|
||||
_lock = true;
|
||||
// return;
|
||||
int st_cnt = fsensor_st_cnt;
|
||||
fsensor_st_cnt = 0;
|
||||
sei();
|
||||
/* *digitalPinToPCMSK(fsensor_int_pin) &= ~bit(digitalPinToPCMSKbit(fsensor_int_pin));
|
||||
digitalWrite(fsensor_int_pin, HIGH);
|
||||
*digitalPinToPCMSK(fsensor_int_pin) |= bit(digitalPinToPCMSKbit(fsensor_int_pin));*/
|
||||
uint8_t old_err_cnt = fsensor_err_cnt;
|
||||
if (!pat9125_update_y())
|
||||
{
|
||||
//#ifdef DEBUG_FSENSOR_LOG
|
||||
puts_P(PSTR("pat9125 not responding (1).\n"));
|
||||
//#endif //DEBUG_FSENSOR_LOG
|
||||
printf_P(ERRMSG_PAT9125_NOT_RESP, 1);
|
||||
fsensor_disable();
|
||||
fsensor_not_responding = true;
|
||||
}
|
||||
if (st_cnt != 0)
|
||||
{
|
||||
#ifdef DEBUG_FSENSOR_LOG
|
||||
if (fsensor_log)
|
||||
{ //movement
|
||||
if (st_cnt > 0) //positive movement
|
||||
{
|
||||
MYSERIAL.print("cnt=");
|
||||
MYSERIAL.print(st_cnt, DEC);
|
||||
MYSERIAL.print(" dy=");
|
||||
MYSERIAL.print(pat9125_y, DEC);
|
||||
}
|
||||
#endif //DEBUG_FSENSOR_LOG
|
||||
if (st_cnt != 0)
|
||||
{
|
||||
if( (pat9125_y == 0) || ((pat9125_y > 0) && (st_cnt < 0)) || ((pat9125_y < 0) && (st_cnt > 0)))
|
||||
{ //invalid movement
|
||||
if (st_cnt > 0) //only positive movements
|
||||
fsensor_err_cnt++;
|
||||
#ifdef DEBUG_FSENSOR_LOG
|
||||
if (fsensor_log)
|
||||
{
|
||||
MYSERIAL.print("\tNG ! err=");
|
||||
MYSERIAL.println(fsensor_err_cnt, DEC);
|
||||
}
|
||||
#endif //DEBUG_FSENSOR_LOG
|
||||
}
|
||||
if (pat9125_y <= 0)
|
||||
fsensor_err_cnt++;
|
||||
else
|
||||
{ //propper movement
|
||||
if (fsensor_err_cnt > 0)
|
||||
if (fsensor_err_cnt)
|
||||
fsensor_err_cnt--;
|
||||
// fsensor_err_cnt = 0;
|
||||
#ifdef DEBUG_FSENSOR_LOG
|
||||
if (fsensor_log)
|
||||
{
|
||||
MYSERIAL.print("\tOK err=");
|
||||
MYSERIAL.println(fsensor_err_cnt, DEC);
|
||||
}
|
||||
#endif //DEBUG_FSENSOR_LOG
|
||||
}
|
||||
}
|
||||
else
|
||||
{ //no movement
|
||||
#ifdef DEBUG_FSENSOR_LOG
|
||||
if (fsensor_log)
|
||||
MYSERIAL.println("\tOK 0");
|
||||
#endif //DEBUG_FSENSOR_LOG
|
||||
else //negative movement
|
||||
{
|
||||
}
|
||||
}
|
||||
else
|
||||
{ //no movement
|
||||
}
|
||||
|
||||
#ifdef DEBUG_FSENSOR_LOG
|
||||
if (fsensor_log)
|
||||
printf_P(_N("FSENSOR cnt=%d dy=%d err=%d %S\n"), st_cnt, pat9125_y, fsensor_err_cnt, (fsensor_err_cnt > old_err_cnt)?_N("NG!"):_N("OK"));
|
||||
#endif //DEBUG_FSENSOR_LOG
|
||||
|
||||
pat9125_y = 0;
|
||||
_lock = false;
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user