| Position |
Binary |
Decimal # |
| Left 90 deg |
10000001 |
129 |
| Left 75 deg |
10000011 |
131 |
| Left 60 deg. |
10000111 |
135 |
| Left 45 deg. |
10000110 |
134 |
| Left 30 deg. |
10001110 |
142 |
| Left 15 deg. |
10001100 |
140 |
| Front 0 deg. |
10011100 |
156 |
| Right 15 deg. |
10011000 |
152 |
| Right 30 deg. |
10111000 |
184 |
| Right 45 deg. |
10110000 |
176 |
| Right 60 deg. |
11110000 |
240 |
| Right 75 deg. |
11100000 |
224 |
| Right 90 deg. |
11000000 |
192 |
|
I have the 7 sensors wired to my Oopic
controller so that each sensor is represented by a different position of an
8 bit word (10000000). The most significant bit is tied to a "1" since it
is not used So here's the "truth table" for the positioning sensors.
As an example, when the torso is facing forward, the sensors are showing
"10011100". The first bit being the unused bit that is fixed at "1".
Then you see the middle three sensors are covered by the flag so they come
back a "1's". So "10011100" in binary is 156 in decimal.
When the robot is first powered I have it seek the middle position.
I start it rotating in one direction and if I see "192" (far
right) or "129" (far left) first, I
know it going in the wrong direction so I reverse the direction until I see
"156" (center).
Hope this makes sense.
In hind-sight, I should have tied the extra bit to "0". That would
have made figuring out the binary and decimal numbers easier and would have
made more sense. If I am back in inside sometime soon, I may do that
and recode the program.
|