hall sensor decoder
Revision 2:fcd99d737ff4, committed 2019-03-29
- Comitter:
- bobolee1239
- Date:
- Fri Mar 29 06:00:20 2019 +0000
- Parent:
- 1:e5c83c0dc9c7
- Commit message:
- revised decoder (correct -> wrong) --- Brian
Changed in this revision
hallsensor_software_decoder.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r e5c83c0dc9c7 -r fcd99d737ff4 hallsensor_software_decoder.h --- a/hallsensor_software_decoder.h Fri Mar 29 05:05:52 2019 +0000 +++ b/hallsensor_software_decoder.h Fri Mar 29 06:00:20 2019 +0000 @@ -50,8 +50,9 @@ ** 1. hallA = 0, 1 ** 2. hallB = 0, 1 ********************************/ - wheelState1.state = (wheelState1.hallA << 1) + ((wheelState1.hallA ^ wheelState1.hallB) & 0x0001) + 1; - +// wheelState1.state = (wheelState1.hallA << 1) + ((wheelState1.hallA ^ wheelState1.hallB) & 0x0001) + 1; + wheelState1.state = (wheelState1.hallA << 1) + (((~wheelState1.hallA) && wheelState1.hallB) || (wheelState1.hallA && (~wheelState1.hallB))) + 1; + if(wheelState1.state == 1) { if(wheelState1.prestate == 4) { @@ -91,8 +92,9 @@ wheelState2.hallB = HallB_2.read(); /* state determination */ - wheelState2.state = (wheelState2.hallA << 1) + ((wheelState2.hallA ^ wheelState2.hallB)&0x0001) + 1; - +// wheelState2.state = (wheelState2.hallA << 1) + ((wheelState2.hallA ^ wheelState2.hallB)&0x0001) + 1; + wheelState2.state = (wheelState2.hallA << 1) + (((~wheelState2.hallA) && wheelState2.hallB) || (wheelState2.hallA && (~wheelState2.hallB))) + 1; + if(wheelState2.state == 1){ if(wheelState2.prestate == 4){