EXAM_1 - 
...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 
 Section
1
‐
M,
Th
10am‐12:50pm
 Section
2
‐
M,
Th
1‐3:50pm
 Section
3
‐
Tu,
F
10am‐12:50am
 Section
4‐
Tu,
F
1‐3:50pm
 Name:_______________________________________________
 
 
 
 Section
#:
 
 Professor:
 
 Grading
TA:
 
 Side:
 ______________________________
 
 ______________________________
 
 ______________________________
 
 A‐left
or
B‐right
(Circle
One)
 Laboratory
Introduction
to
Embedded
Control
 Exam
#1
–
Spring
2010
 90
minutes
(3
hours
total
for
both
parts)
 Open
Book,
Open
Notes,
Calculator
but
no
Computer
 and
No
Sharing
Material
 
 Make
 sure
 you
 include
 comments
 with
 all
 your
 code
 statements.
 
 It
 is
 possible
 to
 receive
some
partial
credit
for
correct
comments.
 
 Question
 1
a

 1
b
 1
c
 1
d
 1
e
 1
f
 1
g
 1
h
 2
a
 2
b
 2
c
 2
d
 2
e
 2 
 f
 TOTAL
 Max
Points
 3
 4
 3
 3
 4
 3
 5
 5
 4
 3
 3
 3
 4
 3
 50
 Earned
Points
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 Grader
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 1
 
 Problem
#1
 Name:_______________________________________________
 You
 have
 been
 asked
 to
 design
 a
 digital
 home
 temperature
 controller
 by
 your
 employer.
 
 The
 controller
 should
 turn
 a
 furnace
 on
 if
 the
 room
 temperature
 falls
 below
a
limit
set
by
the
user,
and
turn
the
furnace
off
once
the
desired
temperature
 has
been
reached.
 A
diagram
of
how
your
system
will
be
 connected
is
included
below.

A
thermometer,
 connected
 to
 P1.4
 through
 a
 resistor
 voltage
 divider,
 outputs
 a
 voltage
 of
 0‐12V
 depending
on
the
temperature.

A
value
of
0V
corresponds
to
60°F
and
a
value
of
12V
 corresponds
 to
 100°F
 (this
 controller
 will
 only
 work
 in
 Florida).
 
 To
 set
 the
 temperature,
 the
 user
 will
 adjust
 a
 potentiometer
 connected
 to
 P1.6.
 
 A
 value
 of
 0V
 from
the
potentiometer
equates
to
a
desired
temperature
of
 60°F
and
a
value
of
2.4V
 equates
to
a
desired
temperature
of
80°F.

(NOTE:
the
scales
are
not
the
same.)

The
 furnace
 controller
 (on/off
 switch)
 is
 connected
 to
 P2.1.
 
 Sending
 a
 “1”
 turns
 the
 furnace
ON,
and
sending
a
“0”
turns
the
furnace
OFF.
 Furnace Control 
 a) The
 temperature
 controller
 returns
 values
 between
 0‐12V.
 However,
 we’ll
 be
 using
the
internal
voltage
reference
of
2.4V
for
A/D
conversions.

Find
the
value
 of
R1
such
that
the
maximum
value
read
at
P1.4
is
2.4V.
 
 
 2
 
 Name:_______________________________________________
 b) Write
a
function
called
 Port_Init
that
correctly
configures
the
ports
for
input
and
 output.
 Remember
 to
 set
 the
 high
 impedance
 states
 if
 necessary
 and
 any
 other
 aspects
required
for
Port
 1
and
Port
2.
Do
not
change
the
state
of
any
port
pins
 that
you
do
not
use.

You
must
use
hexadecimal
values.
 
 void Port_Init(void) { } c) Write
an
 ADC_Init
function
that
sets
VREF
to
use
 the
internal
voltage
of
2.4V,
the
 ADC
gain
to
be
1,
and
enables
ADC1.
 
 void ADC_Init(void) { } d) You
are
required
to
check
the
temperature
in
the
room
exactly
every
10ms.

For
 this,
 you
 will
 use
 timer
 interrupts.
 
 Timer
 0
 is
 to
 be
 configured
 as
 an
 8‐bit
 counter
using
the
System
Clock
divided
by
12.

With
the
standard
system
clock
 frequency
calculate
the
number
of
overflows
for
a
10ms
interval.
 
 
 
 
 
 3
 
 Name:_______________________________________________
 e) Write
 a
 Timer_Init
 function
 that
 uses
 Timer
 0
 in
 the
 mode
 specified
 in
 d.
 
 You
 must
also
enable
the
Timer
0
overflow
interrupt.
You
must
start
the
counting
in
 this
function.
 
 void Timer_Init(void) { } 
 f) Write
a
read_AD_input
function
that
reads
the
voltage
value
from
the
appropriate
 port
 pin
 (current
 temperature
 or
 desired
 temperature)
 passed
 to
 the
 function,
 and
returns
the
digital
value
of
the
A/D
result.
 
 unsigned char read_AD_input(int port_pin) { } 
 g) Write
 an
 Adjust_Temperature
 function
 that
 turns
 the
 furnace
 on
 if
 the
 desired
 temperature
is
above
the
current
temperature
and
turns
it
off
if
equal
or
below.

 
 void Adjust_Temperature(void) { // Global variables defined on the next page // unsigned char current_temp_conversion // unsigned char desired_temp_conversion } 
 4
 
 Name:_______________________________________________
 h)
 Write
a
main
function
that
calls
the
proper
initialization
functions.

The
main
function
 continuously
sets
 current_temp_conversion
 &
 desired_temp_conversion
 using
read_AD_input
and
also
calls
Adjust_Temperature
every
10ms.

Assume
that
your
 program
has
a
global
variable
called
counts
that
is
incremented
by
the
Timer
ISR.
(See
 the
ISR
listed
at
the
bottom
of
the
page.)
 
 // Global variables unsigned char current_temp_conversion; unsigned char desired_temp_conversion; int counts; 
 void main() { } void Timer_ISR(void) interrupt 1 { counts++; } 
 5
 
 Name:_______________________________________________
 Problem
#2
 
 a)
 Find
the
value
of
the
following
binary
operation.
Show
all
work
for
partial
credit.
 
 result = ( (~0xB8 | 0x19) >> 5 ) % 3 
 
 Decimal
 Hexadecimal
 
 
 
 b)
 The
 following
 global
 variables
 are
 defined
 for
 input/output.
 
 Write
 a
 Port_Init
 function
 to
 properly
 enable
 the
 pins
 for
 input/output.
 
 You
 must
 use
 hex,
 and
 only
change
the
pins
that
are
declared
below.
 
 sbit at 0x93 SS; //input sbit at 0xA2 BUZZER; //output sbit at 0xA7 PB1; //input sbit at 0xB5 PB2; //input
 
 void Port_Init() { } 
 c)
 Draw
 the
 following
 digital
 operation
 using
 common
 digital
 gates.
 Use
 generic
 gates
 and
 don’t
 worry
 about
 pin
 numbers.
 
 Add
 the
 names
 A,
 B,
 and
 Y
 to
 the
 appropriate
wires
in
the
circuit.
 Y
=
(A
NAND
B)
OR
B
 
 
 
 
 
 
 
 
 6
 
 Name:_______________________________________________
 
 d)
 Timer
0
is
set
up
as
a
 13‐bit
counter
running
at
System
Clock.

Find
how
many
 overflows
occur
within
50ms.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 e)
 For
an
ADC1
conversion
with
VREF
set
to
1.2V
(the
x2
REFBE
amp
is
off),
a
0.55
 input
 voltage
 is
 applied.
 
 What
 is
 the
 value
 of
 AD_value
 in
 the
 following
 AD
 conversion
function
call?

(AD_value
and
 read_AD_input()
are
declared
as
 unsigned
char.)
 
 AD_value = read_AD_input(); 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 f)
 For
the
same
function
call,
if
 AD_value
is
declared
as
a
signed
char,
what
will
 its
value
be
after
conversion
if
the
input
voltage
is
set
to
‐0.1V?
 
 
 
 7
 ...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online