FS: Improve reliability on speeds with poor optical tracking

Depending on the filament surface and moving speed, the PAT9125 sensor
can stop being able to track movement.

In such cases, instead of triggering false errors and/or relying on
previous states, read and use the exposure data off the sensor and
increase error counts only for poorly exposed images instead, which
is a good indicator of a far-away (or missing!) tracking surface.
This commit is contained in:
Yuri D'Elia 2020-02-06 13:48:23 +01:00
parent cdc17e8da1
commit 3be859ece9
3 changed files with 26 additions and 17 deletions

View File

@ -488,10 +488,25 @@ ISR(FSENSOR_INT_PIN_VECT)
if (pat9125_y == 0) if (pat9125_y == 0)
{ {
// no movement detected: increase error count only when extruding, since fast retracts if (st_dir)
// cannot always be seen. We also need to ensure that no runout is generated while {
// retracting as it's not currently handled everywhere // no movement detected: we might be within a blind sensor range,
if (st_dir) ++fsensor_err_cnt; // update the frame and shutter parameters we didn't earlier
if (!fsensor_oq_meassure)
pat9125_update_bs();
// increment the error count only if underexposed: filament likely missing
if ((pat9125_b < 80) && (pat9125_s > 10))
{
// check for a dark frame (<30% avg brightness) with long exposure
++fsensor_err_cnt;
}
else
{
// good frame, filament likely present
if(fsensor_err_cnt) --fsensor_err_cnt;
}
}
} }
else if (pat9125_dir != st_dir) else if (pat9125_dir != st_dir)
{ {

View File

@ -219,19 +219,13 @@ uint8_t pat9125_update_y(void)
return 0; return 0;
} }
uint8_t pat9125_update_y2(void) uint8_t pat9125_update_bs(void)
{ {
if ((pat9125_PID1 == 0x31) && (pat9125_PID2 == 0x91)) if ((pat9125_PID1 == 0x31) && (pat9125_PID2 == 0x91))
{ {
uint8_t ucMotion = pat9125_rd_reg(PAT9125_MOTION); pat9125_b = pat9125_rd_reg(PAT9125_FRAME);
if (pat9125_PID1 == 0xff) return 0; //NOACK error pat9125_s = pat9125_rd_reg(PAT9125_SHUTTER);
if (ucMotion & 0x80) if (pat9125_PID1 == 0xff) return 0;
{
int8_t dy = pat9125_rd_reg(PAT9125_DELTA_YL);
if (pat9125_PID1 == 0xff) return 0; //NOACK error
pat9125_y -= dy; //negative number, because direction switching does not work
}
return 1;
} }
return 0; return 0;
} }

View File

@ -19,9 +19,9 @@ extern uint8_t pat9125_b;
extern uint8_t pat9125_s; extern uint8_t pat9125_s;
extern uint8_t pat9125_init(void); extern uint8_t pat9125_init(void);
extern uint8_t pat9125_update(void); extern uint8_t pat9125_update(void); // update all sensor data
extern uint8_t pat9125_update_y(void); extern uint8_t pat9125_update_y(void); // update _y only
extern uint8_t pat9125_update_y2(void); extern uint8_t pat9125_update_bs(void); // update _b/_s only
#if defined(__cplusplus) #if defined(__cplusplus)