filter out zero encoder reading - can be caused by gnd short

This commit is contained in:
vadim 2019-03-01 11:42:33 +02:00
parent 8cc3ea519a
commit e70be9e17a
1 changed files with 1 additions and 1 deletions

View File

@ -334,7 +334,7 @@ void encoder_tim_isr(void) {
spi_end();
spi_val = pos;
if(spi_check_parity(pos) && pos!=0xffff) {
if(spi_check_parity(pos) && pos!=0xffff && pos!=0) { // all ones = disconnect, all zeros = short to gnd
pos &= 0x3FFF;
last_enc_angle = ((float)pos * 360.0) / 16384.0;
UTILS_LP_FAST(spi_error_rate, 0.0, 1./AS5047_SAMPLE_RATE_HZ);