Micro
con
troller
A
Hitac
hi
SH
micro
con
troller
running
at
MHz
is
used
to
in
terface
to
a
host
Its
bit
arc
hitecture
along
with
its
bit
analog to digital
con
v
erters
and
its
lo
w
cost
mak
e
it
an
ideal
solution
F
or
ease
of
in
tergration
a
Hitac
hi
ev
aluation
b
oard
w
as
used
It
con
tains
circuitry
for
all
of
the
RS
lev
el
con
v
ersion
as
w
ell
as
the
reset
The
I
and
Q
c
hannels
are
connected
to
the
micro
con
troller s
A D
inputs
along
with
the
start
and
stop
phototransistor
signals
as
logic
lev
els
Em
b
edded
Co
de
The
em
b
edded
co
de
w
as
written
in
C
for
the
SH
micrcon
troller
It
w
as
compiled
and
burned
in
to
an
EPR
OM
The
co
de
is
structured
in
suc
h
a
w
a
y
as
to
utilize
man
y
of
the
functional
blo
c
ks
of
the
SH
The
I
and
Q
c
hannels
are
digitized
b
y
con guring
the
analog to digital
con
v
erter
of
the
SH
to
scan con
v
ert
c
hannels
one
and
t
w
o
Once
con gured
and
started
the
scan
con
v
erter
will
sample
at
the
fastest
sp
eed
con
tin
ually
up
dating
the
registers
with
the
new
est
results
Up
on
reset
the
micro
con
troller
b
egins
scanning
the
t
w
o
analog
c
hannels
determining
a
v
alid
scan
in
terv
al
to
b
e
b
et
w
een
the
start
and
stop
phototransistor
signals
It
rst
tak
es
a
calibration
scan
a
v
eraging
all
of
the
samples
to
determine
a
baseline
for
the
signals
It
then
sits
in
a
holding
mo
de
w
aiting
for
the
con guration
information
from
the
host
The
con
troller
comm
unicates
to
the
host
using
RS
serial
proto
col
sending
bits
without
parit
y
at
a
baud
rate
The
angle
is
tak
en
as
the
time
on
a
bit
timer
that
has
elapsed
since
the
start
phototransistor
pulse
The
timer
is
reset
b
efore
eac
h
scan
A
T
c
haracter
is
sen
t
from
the
host
signifying
the
setting
of
the
threshold
Tw
o
b
ytes
are
then
sen
t
for
the
threshold
v
alue
high
b
yte
rst
A
W
c
haracter
is
sen
t
from
the
host
to
signify
that
the
follo
wing
b
ytes
determine
the
w
ait
time
This
is
the
time
after
a
v
alid
start
signal
b
efore
data
should
b
e
considered
This
mak
es
sure
that
the
re ection
from
the
phototransistor
housing
isn t
con
triv
ed
to
b
e
a
data
p
oin
t
If
a
D
is
sen
t
the
pro
cessor
en
ters
in
to
a
debug
mo
de
This
will
prin
t
all
of
the