Publishing for Michael McKinley to calibrate.
Fork of Encoders by
Diff: Encoder.cpp
- Revision:
- 1:2e39be3d2088
- Parent:
- 0:1d2644a20b71
--- a/Encoder.cpp Mon Nov 24 03:33:29 2014 +0000 +++ b/Encoder.cpp Sat Mar 07 01:56:09 2015 +0000 @@ -59,6 +59,19 @@ // XNOR parity check parity=~(parity_calc(raw) ^ (raw>>15)); + if(!parity) { + // Select the device by seting chip select low + _cs = 0; + + //send a dummy byte to the MOSI to get a reading through the MISO + raw=_spi.write(0xFFFF); + + // Set the select back to low to allow the encoder to chill + _cs=1; + + // XNOR parity check + parity=~(parity_calc(raw) ^ (raw>>15)); + } // Mask and bit shift to look at encoder flag value enc_flag=(raw & 0x4000)>>14; @@ -68,9 +81,10 @@ return raw; } -short int Encoder::readRaw(){ +short int Encoder::readRaw() +{ return raw; - } +} /*********************************************************** Translate Function - Translates Ticks to Position ***********************************************************/ @@ -107,4 +121,4 @@ void Encoder::flip() { sign=-sign; - } \ No newline at end of file +} \ No newline at end of file