hall sensor decoder
Dependents: mobile_robot_lab3_rosserial mobile_robot_lab3_rosserial mobile-robot-vehicle-control
Diff: hallsensor_software_decoder.h
- Revision:
- 4:553de07891f2
- Parent:
- 3:a969ae9954a8
- Child:
- 5:b6d81c106fd1
diff -r a969ae9954a8 -r 553de07891f2 hallsensor_software_decoder.h --- a/hallsensor_software_decoder.h Wed Mar 27 03:08:46 2019 +0000 +++ b/hallsensor_software_decoder.h Fri Mar 29 05:04:50 2019 +0000 @@ -50,7 +50,7 @@ ** 1. hallA = 0, 1 ** 2. hallB = 0, 1 ********************************/ - wheelState1.state = (wheelState1.hallA << 1) + (wheelState1.hallA ^ wheelState1.hallB) + 1; + wheelState1.state = (wheelState1.hallA << 1) + ((wheelState1.hallA ^ wheelState1.hallB) & 0x0001) + 1; if(wheelState1.state == 1) { @@ -91,7 +91,7 @@ wheelState2.hallB = HallB_2.read(); /* state determination */ - wheelState2.state = (wheelState2.hallA << 1) + (wheelState2.hallA ^ wheelState2.hallB) + 1; + wheelState2.state = (wheelState2.hallA << 1) + ((wheelState2.hallA ^ wheelState2.hallB)&0x0001) + 1; if(wheelState2.state == 1){