hall sensor decoder
Dependents: mobile_robot_lab3_rosserial mobile_robot_lab3_rosserial mobile-robot-vehicle-control
Revision 5:b6d81c106fd1, committed 2019-03-29
- Comitter:
- bobolee1239
- Date:
- Fri Mar 29 05:59:43 2019 +0000
- Parent:
- 4:553de07891f2
- 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 553de07891f2 -r b6d81c106fd1 hallsensor_software_decoder.h --- a/hallsensor_software_decoder.h Fri Mar 29 05:04:50 2019 +0000 +++ b/hallsensor_software_decoder.h Fri Mar 29 05:59:43 2019 +0000 @@ -50,7 +50,10 @@ ** 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) { @@ -91,8 +94,11 @@ 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){