Sie sind auf Seite 1von 10

Name:_____________________________________________

!"#$ &''()!"#$ *'+#, - ./'0 122 3'4( 1


The uesign poition of the exam is a uesign pioblem wheie you will
uevelop some algoiithms anu basic haiuwaie foi a solai powei
intelligent vacuum cleanei (who woulun't want one). The opeiation of
the vacuum cleanei implements concepts that have been intiouuceu in
Laboiatoiies 1 thiough 4. Pulsewiuth mouulation is implementeu to
contiol vaiious motois. I2C communication piotocols aie use to inteiact
with peiipheial uevices.

As pait of the uesign piocess you will neeu to
1. Beteimine the wiiing schematic of the system.
2. Beteimine the Poit Pins being useu anu the associateu Ciossbai
Setting.
S. ueneiate appiopiiate PWN signals.
4. Reau anu wiite to peiipheial uevices.
S. Implement coue to meet piogiam specifications.

."#567658+6'$ ./##+

9'4+ "6$ 822'58+6'$: The following aie iequiieu in the system. No
unnecessaiy poit pins aie allocateu.
1) 0ARTu: enable foi text communication
2) SNB: enableu foi peiipheial communication
S) CEX2: connecteu to vacuum motoi
4) CEXS: connecteu to piopulsion motoi
S) CEX4: connecteu to steeiing motoi
6) Solai voltage levels as an analog input on AIN1.1

93:;
Piopulsion motoi:
1) Pulsewiuth Nouulation contiolleu uiive motoi which is on oi off
a. 0ff: 4ms pulses with a 1ums peiiou
b. 0n: 8ms pulses with a 1ums peiiou
Steeiing motoi:
1) Pulsewiuth Nouulation contiolleu seivo motoi which is x-uiiecteu
oi y-uiiecteu
a. X-uiiecteu: 4ms pulses with a 1ums peiiou
b. Y-uiiecteu: 8ms pulses with a 1ums peiiou
vacuum motoi:
1) Pulsewiuth Nouulation contiolleu vaiiable speeu motoi with suction
uepenuent on the pulsewiuth, 4-8ms pulses with a 1ums peiiou
a. 0ff: 4ms pulses
b. Full powei: 8ms pulses
c. Powei vaiies lineaily fiom 0ff to Full powei

<6=6+82 >$"?+,)!?+"?+,:
1) PS.u, biLEB connection (biLEB gieen, unuei opeiation)
2) PS.1 biLEB connection (biLEB ieu, system iule)
S) PS.2 powei button (uv: on, Sv:off)
4) PS.S heaulamp (uv: on, Sv: off)

1$82'= >$"?+,:
1) AIN1.1: Solai panel with voltage levels u-Sv, uepenuing on the
exposuie to light
Name:_____________________________________________
!"#$ &''()!"#$ *'+#, - ./'0 122 3'4( 2

@?$5+6'$,: (not all these functions aie in the exam)
Init_Func(); // calls all initialization functions
PCA_Init(); // initialize programmable counter array
Port_Init(); // initialize port input/output states
Interrupt_Init(); // initialize interrupts
Run_Vacuum(); // vacuum is under operation
Read_Sensors(); // check proximity and dirt sensor
Set_Motors(); // set motors while system is running
Solar_Check(); // check voltage levels of solar cell
Sleep_Mode(); //put system in sleep mode
Motors_Off(); //turn vacuum and propulsion off
Power_Save(); // sets microprocessor devices to off
Software_Reset(); // software reboot of the system




A2'B82 C8468B2#,: (type ueclaiations in the exam)
The following vaiiables aie useu to set the CCN thiesholus:
PW_Steering; // calls all initialization functions
PW_Propulsion; // initialize programmable counter array
PW_Vacuum; // initialize port input/output states
PW_4ms; // 4ms pulse width
PW_8ms; // 8ms pulse width

The following vaiiables stoie sensoi uata
dirt_level; //amount of particulates in air flow, Register 3
xpos; //distance to closest object in the x-direction, Register 5
ypos; //distance to closest object in the y-direction, Register 6

Count vaiiables, neeu inteivals up to 1useconus
counts; //count variable that tracks overflows





9#46"/#482 <#D65#, (I2C communication piotocols)

Contiol-Sensoi unit: (items in bolu aie useu in the exam)
Auuiess: uxB4

Registei Wiite Reau

u Nouel Numbei (low) Nanufactuie uay
1 Nouel Numbei (high) Nanufactuie month
2 Cleaning pattein Nanufactuie yeai
S Patent numbei <64+ ,#$,'4
4 Clock set: Ninute Light sensoi
S Clock set: Boui
94'E6F6+G ,#$,'4-
E-"',6+6'$ HFFI
6
9'0#4 ,'?45#
JEJJ; "'0#4 K'0$
JEJL; B8++#4G
JEJM; ,'284
94'E6F6+G ,#$,'4-
G-"',6+6'$ HFFI
7 JE11; .'7+084# 4#,#+ NA

Name:_____________________________________________
!"#$ &''()!"#$ *'+#, - ./'0 122 3'4( S

(1 pt)
Section: (Ciicle one)

Piofessoi:

______________________________
Section 1 - N, Th 1uam-12:Supm
Section 2 - N, Th 1-S:Supm

uiauing TA:

______________________________
Section S - Tu, F 1uam-12:Suam
Section 4- Tu, F 1-S:Supm

Siue:

A-left oi B-iight (Ciicle 0ne)

Incomplete oi incoiiect infoimation above may iesult in the loss of a point on giaue!

N8B'48+'4G >$+4'K?5+6'$ +' OFB#KK#K P'$+4'2
OE8F QL R @822 LJSS
TJ F6$?+#, HM /'?4, +'+82 7'4 B'+/ "84+,I

!"#$ &''(U !"#$ *'+#,U P825?28+'4 B?+ $' P'F"?+#4
8$K *' ./846$= :8+#4682

Nake suie you incluue comments with all youi coue statements foi paitial cieuit.

V?#,+6'$ :8E 9'6$+, O84$#K 9'6$+, A48K#4
1 a 1
1 b S
1 c 2
1 u 2
1 e 2
1 f 4
2 a 2
2 b 2
2 c 2
2 u 8
S a 8
S b 8
4 a S
4 b 8
4 c 4
S a 7
S b 8
6 a 8
6 b 6
6 c 8
6 u 4
T0TAL 1uu

All I2C piocesses in this exam use functions uefineu in the i2c.h heauei file
that is available in the LITEC manual & SYSCLK is the same as in the lab.
This exam uevelops coue to contiol a state of the ait, high peifoimance
hoiizontal cleanliness management system, aka. a vacuum cleanei.
Name:_____________________________________________
!"#$ &''()!"#$ *'+#, - ./'0 122 3'4( 4

P'$5#"+ W?#,+6'$,
.:&?,)>
L
P HSX "+,I
S8I HS "+I What is the clock fiequency of the SNB (in oui Labs).

________________________________________________________________________

SBI HM "+,I Suppose two smait cais aie connecteu using the SNBus
piotocol. If the Smait Cai uefineu as the mastei wants to senu uata to
the othei cai (slave) to contiol the steeiing seivo,
i) Bow uoes the Nastei 'get the attention' of the slave.

____________________________________________________________________
ii) Bow uoes the mastei know a slave ieceiveu a uata byte.

____________________________________________________________________
iii) What signals the enu of a uata tiansfei piocess.

____________________________________________________________________

S5I HL "+,I Which of the following statements inuicate a ieau piocess is
staiting. (Ciicle the coiiect answei)
i2c_write(0xB0);

i2c_write(0xB1);

neithei

SKI HL "+,I If theie is 1 mastei (the EvB) anu S slaves (sensois), how
many sets of pull-ups iesistoi uo you neeu.
____________________________________________________________________
S#I HL "+,I Tiue False : (Ciicle one)
I2C iequiies two poit bits, one foi input anu one foi output.

S7I HX "+,I The following schematic iepiesents an I2C piocess foi the
vacuum system. The exchange of bytes pioceeus left to iight anu
continues to the seconu line. It is one uata exchange. Baseu on the
schematic, complete the coue below. Assume coue will be incluueu to
set the Bata aiiay.
(continueu)


STA - Stait signal
Ack - Acknowleuge signal
ST0 - Stop signal
void unknown_i2c_function(void)
{
unsigned char Data [10]; // variable declaration
unsigned char addr = __________; //
unsigned char start_reg = __________; //
unsigned char num_bytes = __________; //
i2c________________ ( addr, start_reg, Data, num_bytes);
// indicate i2c_write_data or i2c_read_data
}
uxFF Ack uxFF Ack uxu2 Ack ux4A STA
STO uxuu Ack uxuA Ack
Name:_____________________________________________
!"#$ &''()!"#$ *'+#, - ./'0 122 3'4( S
9P1 HSX "+,I

L8I HL "+,I What is the function of the captuiecompaie mouules in the
PCA. Bow aie they inteifaceu with the I0 pins.
____________________________________________________________________

____________________________________________________________________

LBI HL "+,I Which bit anu which SFR enable 16-bit PWN foi the
CaptuieCompaie Noue Registeis.
____________________________________________________________________

L5I HL "+,I Bow many Captuie Compaie Nouules aie available with
PCAu.
____________________________________________________________________

LKI HY "+,I To geneiate a PWN output fiom the CEXu pin of the EvB,
the following settings aie useu (SYSCLK = 22.1184NBz):
i) PCAu count stait value, set in the PCA ISR: S7844
ii) CCNu compaie value (not the pulsewiuth): S6Su4
iii) System Clock: SYSCLK12
Assume that all othei iegisteis aie uefineu coiiectly (i.e. PCA
countei enableu, CCNu in 16-bit compaie moue etc.). 0sing the
above specifications, in the appiopiiate plots:
1. Biaw the PCA count (top plot). (4 pts)
2. Biaw the PWN signalCEX output (bottom plot) (4 pts)
S. 0se tick maiks on the axis to inuicate ielevant values.
4. Inuicate the time scale on the appiopiiate axis
(Biaw a few cycles of steauy-state iesponse - skip long 1
st
cycle.)


PCA count
time|______j
PWN
time|______j
Name:_____________________________________________
!"#$ &''()!"#$ *'+#, - ./'0 122 3'4( 6

P4',,B84)Z84K084#





















M8I HY "+,I In the above schematic, complete the ciicuit foi the
haiuwaie uevices inuicateu (Solai panel, thiee motois anu I2C). 0se the
infoimation pioviueu on the uata sheet unuei the Poit Pin allocation
section anu Analog Inputs section. Auuitionally, auu any ciicuit
components that aie neeueu foi ieliable opeiation of the exteinal
haiuwaie uevices. Incluue powei anuoi giounu if neeueu, howevei,
you may assume that the uevices aie inteinally poweieu anu uo not
neeu to incluue vccgiounu foi the haiuwaie uevices. (0ART1 is N0T
enableu.)

MBI HY "+,I XBRu_Init, Poit_Init
Baseu on the poit pin allocations, ueteimine the appiopiiate XBRu
value.
XBRu =__________________________;
Initialize the Poit u anu Poit 1 pins foi the above connections that aie
opeiating as uigitalanalog inputsoutputs. You must complete each
line with iegaiu to the comments (uo not cioss any out).
void Port_Init(void)
{
P0MDOUT _________________________; // P0 inputs
P0MDOUT _________________________; // P0 outputs
P0 _________________________; // P0 high impedance
P1MDOUT _________________________; // P1 inputs
P1MDOUT _________________________; // P1 outputs
P1MDIN _________________________; // analog inputs
P1 _________________________; // high impedance
}
P1.2
P1.S
P1.1
P1.u
Pu.7
Pu.6
Pu.S
Pu.4
Pu.S
Pu.2
Pu.1
Pu.u
8uS1









74S6S
I2C Bus
vacuum Notoi
Steeiing Notoi
Piopulsion Notoi
Solai panel
Name:_____________________________________________
!"#$ &''()!"#$ *'+#, - ./'0 122 3'4( 7
A2'B82 C8468B2#,U 94'=48FF6$=
X8I HM "+,I A2'B82 C8468B2#,
Refei to the uesciiption of vaiiables in specification sheet. Typecast the
vaiiables to use the minimum size
// global variables
unsigned int PW_Propulsion;
____________________ PW_Vacuum;
____________________ PW_Steering;
____________________ dirt_level;
____________________ xpos;
____________________ ypos;
____________________ counts;

XBI HY+,I :86$ "4'=8F
Pseuuocoue foi the main bouy of the piogiam is shown below.
main program block
infinite loop
if (power is on)
initialization routines
while (power is on)
run operation management function
else if (power is off)
set to sleep mode
while (power is off) do nothing
end loop
end main block

Complete the following coue baseu on the above pseuuocoue. Youi coue
shoulu accuiately ieflect the pseuuocoue. A list of functions anu uigital
I0 bits is available on the specifications page. The functions that aie
inuenteu shoulu not be useu in the main function.

// additional global variables for digital I/O
sbit at 0xB0 Biled1
sbit at 0xB1 Biled2
sbit at 0xB2 Power
sbit at 0xB3 Headlamp

void main(void)
{
_____________________________________________; // infinite loop
_____________________________________________; // power check
_____________________________________________; //
_____________________________________________; //
_____________________________________________; //
_____________________________________________; // power check
_____________________________________________; //
_____________________________________________; //
_____________________________________________; //
_____________________________________________; //
_____________________________________________; //
_____________________________________________; //
_____________________________________________; //
}
Name:_____________________________________________
!"#$ &''()!"#$ *'+#, - ./'0 122 3'4( 8
X5I HX "+,I The following function tuins off seveial miciocontiollei
functions while the system is in sleep moue. Youi coue shoulu uisable
the PCA, tuin off all Inteiiupts, uisable the AB, anu tuin off the System
Nanagement Bus.
void Power_Save(void)
{
_____________________________________________; // PCA off
_____________________________________________; // interrupts off
_____________________________________________; // SMB off
_____________________________________________; // A/D off
}

>LP

[8I H\ "+,I Wiite coue to ieau the iegisteis associateu with the uiit
level, the x-position anu the y-position. Youi coue shoulu consist of a
single i2c_ieau_uata function anu set the vaiiables.

void Read_Sensors(void)
{
unsigned char Data [_____]; // variable declaration
unsigned char addr = __________; //
unsigned char start_reg = __________; //
unsigned char num_bytes = __________; //
i2c_read_data( addr, start_reg, Data, num_bytes);
//
dirt_level = _______________________________;
xpos = _____________________________________;
ypos = _____________________________________;
}

[BI HY "+,I In the event of a system failuie, you can foice a ieset by
wiiting uxAA to iegistei 7 of the Contiol-Sensoi 0nit. Following a
softwaie ieset, the system shoulu be placeu in batteiy moue (iefei to
iegistei 6) anu then iule foi 1u seconus. The counts vaiiable is
inciementeu in the PCA ISR. Implement coue to meet the above.
void Software_Reset(void)
{
unsigned char Data [_____]; // variable declaration
Data[_____] = ________________; //
i2c_write_data( ______ , ______, Data, ____);//forced reset
____________________________________________;//battery mode
____________________________________________;// if needed
____________________________________________;// 10 seconds
____________________________________________;// if needed
}
Name:_____________________________________________
!"#$ &''()!"#$ *'+#, - ./'0 122 3'4( 9

94'=48FF8B2# P'?$+#4 1448G

void PCA_ISR(void) interrupt 9
{
if (CF)
{
PCA0L = 10248;
PCA0H = 10248>>8;
CF = 0;
}
}

]8I HY "+,I The above coue iepiesents the Inteiiupt Seivice Routine
associateu with a 16bit PCA such that a 1ums peiiou is set foi the PWN
signals.

Baseu on this coue, what must tiiggei PCA inciements. _________________

Complete coue that initializes the PCA with the above tiiggei anu
initializes the CCN mouules inuicateu in the PWN section of the uata
specifications. Youi coue shoulu match the comments (use 'if neeueu'
lines at youi uiscietion)

void PCA_Init(void)
{
_____________________________________________; // CCM
_____________________________________________; // if needed
_____________________________________________; // if needed
_____________________________________________; // if needed
_____________________________________________; // PCA mode
_____________________________________________; // enable counter
_____________________________________________; // if needed
}

]BI H] "+,I Foi youi above answeis, ueteimine the pulsewiuth in
counts foi the 4ms anu 8ms pulsewiuths, PW_4ms anu PW_8ms,
iespectively. (4 pts)











PW_4ms
|countsj
PW_8ms
|countsj
Name:_____________________________________________
!"#$ &''()!"#$ *'+#, - ./'0 122 3'4( 1u

]5I HY "+,I 0se the above vaiiables anu the appiopiiate SFRs to
complete coue that tuins off the piopulsion motoi anu vacuum motoi.
Refei to the PWN section anu Poit Pin allocation section of the uata
sheet foi the 'off' state of the motoi anu to iuentify the appiopiiate
CCNs. (4 pts)


void Motors_Off(void)
{
_____________________________________________; // vacuum off
_____________________________________________; // if needed
_____________________________________________; // propulsion off
_____________________________________________; // if needed
}

Buiing sensoi ieau opeiations, the uiit sensoi ueteimines the uensity of
the paiticulates in the vacuum system. The sensoi ietuins values in the
iange of u (no paiticulates) to 1uu. Coiiesponuingly, the vacuum motoi
pump scales fiom Su% powei with a sensoi ieauing of u to 1uu% with a
sensoi ieauing of 1uu. Note, unuei opeiation, the vacuum is nevei less
than Su% powei.
1) The sensoi ieauing is stoieu in a vaiiable calleu dirt_level.
2) The vacuum pump pulsewiuth is stoieu in PW_Vacuum

Beteimine a line of coue that sets the pulsewiuth foi the vacuum. Two
lines aie pioviueu if you neeu moie ioom. (4 pts)

PW_Vacuum = ______________________________________________
______________________________________________;


]KI HX "+,I The steeiing contiol uepenus on pioximity to neaiby
objects. The xpos anu ypos vaiiables have units in millimeteis. A
function, Tuining_Contiol(), is calleu if eithei of these vaiiables aie less
than 1uu. Complete coue segment that calls the function when neeueu

_____________________________________________; //
_____________________________________________; //
_____________________________________________; // if needed
_____________________________________________; // if needed

Das könnte Ihnen auch gefallen