User`s manual
ROBOT . HEAD to TOE
Product User’s Manual – SD02B
Created by Cytron Technologies Sdn. Bhd. – All Rights Reserved
33
Request Encoder Value
a. Host sends command ‘E’ (1 byte) to SD02B to request encoder value. Encoder value
is the number of steps upon reset.
b. After sent command to request encoder value, SD02B will send 1 byte for higher 8
bits current encoder value and another 1 byte for lower 8 bits current encoder value to
the host. For example, host receives 11010110
2
for higher 8 bits current encoder value
and 01110110
2
for lower current encoder value:
1 1 0 1 0 1 1
0
0 1 1 1 0 1 1 0
c. To get higher 8 bits in 16 bits current encoder value, save the higher 8 bits into a 16
bits variable and rotate/shift 8 times.
x x x x x x x x
1 1 0 1 0 1 1 0
x x x x x x x
1 1 0 1 0 1 1 0
x
shift 1
st
time
x x x x x x
1 1 0 1 0 1 1 0
x x
shift 2
nd
times
x x x x x
1 1 0 1 0 1 1 0
x x x
shift 3
rd
times
x x x x
1 1 0 1 0 1 1 0
x x x x
shift 4
th
times
x x x
1 1 0 1 0 1 1 0
x x x x x
shift 5
th
times
x x
1 1 0 1 0 1 1 0
x x x x x x
shift 6
th
times
x
1 1 0 1 0 1 1 0
x x x x x x x
shift 7
th
times
1 1 0 1 0 1 1 0
x x x x x x x x
shift 8
th
times
c. After rotated/shifted to the left for 8 times, user will get first received 8 bits at the 8
most significant bits (MSB).
1 1 0 1 0 1 1 0 x x x x x x x x
x = don’t care
1
s
t
: Receive higher 8 bits
Higher 8 bits
Save the first received 8
bits in 16 bits variable
2
nd
: Receive lower 8 bits