DOC PREVIEW
PSU EE 200 - final_s14

This preview shows page 1-2-19-20 out of 20 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 20 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

blanksolutionsEE 200 Final Exam 6 May 2014Last Name (Print):First Name (Print):ID number (Last 4 digits):Section:DO NOT TURN THIS PAGE UNTIL YOU ARE TOLD TO DO SOProblem Weight Score1 252 253 254 25Total 100INSTRUCTIONS1. You have 2 hours to complete thi s exam.2. This is a closed book exam. You may use one 8.5”× 11” note sheet.3. Relevant excerpts from the microcontroller datasheet are provided in a separate document accompanying theexam.4. Calculators are allowed.5. Solve each part of the problem in the space following the question. If you need more space, continue your solutionon the reverse side labeling the page with the question number; for example, Problem 1.2 Continued. NOcredit will be given to solutions that do not meet this requirement.6. DO NOT REMOVE ANY PAGES FROM THIS EXAM. Loose papers will not be accepted and agrade of ZERO will be assigned.7. The quality of your analysis a nd evaluation is as important as your answers. Your reasoning must be preciseand clear; your complete English sentences should convey what you are doing. To receive credit , you mustshow your work.1Problem 1: (25 Points)1. (12 po ints) Figure1 shows a C function for assigning functions to the peripheral pins (labeled 1 through 28) ofa dsPIC33EP64MC502-I/SP microcontroller.Figure 1: Code for setting the function of peripheral pins.(a) (2 points) Which peripheral pin(s) are used for analo g signals?(b) (2 points) W hich peripheral pin(s) are used for digital input?(c) (2 points) W hich peripheral pin(s) are used for digital output?(d) (6 points) In order to streamline the code in Figure 1, complete lines 32 and 34 in Figure 2 by placingnumbers above the dashed lines. To receive partial credit, show the derivation of the register values.Figure 2: Streamlined co de for setting the function of peripheral pins.22. (13 points) The C code in Fi gure 3 executes while pin 9 (RA2) is wired to Pin 11 (RB4). There are no otherconnections to pins 9 and 11.Figure 3: Code for writing and reading a digital signa l.(a) (3 points) After the code executes, what is the logic state of the signa l on pin 9?(b) (4 points) After the code executes, what is the value of the integer x? Justify your answer in one or twoshort sentences.(c) (6 points) After the co de executes, what is the value of the integer y? Justify your answer i n one or twoshort sentences.3Problem 2: (25 Points)The C code in Figure 4 on page 5 realizes a Moo re finite state machine.1. (8 points) The finite state machine has two input signals, RA2 and RA3. The program maps these two inputsto an integer x. Compl ete the Table 2 by specifying the logic levels (0 or 1 ) of RA2 and RA3 that yield thespecified values of x.RA2 RA3 x0123Table 1: The FSM digital inputs determine the value of x.2. (8 points) Complete Table 2 by specifying the next state and the digital o utput RB7. All entries must becompleted with either a state name or the binary digits 0 and 1.Present Next State Out putState x = 0 x = 1 x = 2 x = 3 RB7S1S2S3Table 2: State table for Problem 2.3. (9 points) The finite state machine utilizes an interrupt to realize an asynchronous reset.(a) (5 points) Specify the peripheral pin (1 to 28) that connects to the reset signal. To receive credit, j ustifyyour answer.(b) (4 points) Is an interrupt generated on the rising or f alling edge of the reset signal? To receive credit,justify your answer.4Figure 4: Code fo r realizing a Moore finite state machine.5Problem 3: (25 Points)1. (16 points) Figure 5 shows partially completed C functions for reading an analog signal applied to pin 7 (AN5) ofa dsPIC33EP64MC502-I/SP microcontroller. The function Init ADC is called before the function Read ADC.Figure 5: Code for controlling the ADC m odule.(a) (8 points) Add the additional line(s) of code to the function Init ADC to enable reading analo g signals onpin 7. Comment each line o f code added to the function.(b) (4 points) Com plete line 24 in the function Read ADC. Add appropriate numerical constants in theunderlined spaces and a meaningful comment.(c) (4 points) Suppo se that a constant 2 V signal is connected to pin 7. What value does the functionRead ADC return when it is called.62. (9 points) The code in Figure 6 uses the LCD functions developed in Exercise 2 o f Laboratory #24.Figure 6: Code for writing a message to the LCD module.(a) (3 po ints) During the first iteration of the For loop, when idx takes on the value of 0, determine the valuethe integer c[idx] − 32 in hexadecimal format (0x).(b) (3 points) W hat ASCII character does the hexadecimal number in part (a) represent?(c) (3 points) Indi cate in Figure 6 the message written to the LCD module.Figure 7: LCD module display.7Problem 4: (25 Points)1. (12 points) Figure 8 shows C-code for generating a square-wave signa l using the PW M module on the dsPIC33EP64MC502-I/SP microcontroll er.Figure 8: Code for generating a square-wave.(a) (4 points) Specify the peripheral pin at which the square-wave sig nal is present. Justify your answer inone or two short sentences.(b) (4 poi nts) Determine the frequency of the square-wave signal. To receive credit you must show the relevantcalculations for determining the PWM frequency.(c) (4 po ints) Determine the percent duty cycle of the square-wave signal. To receive credit you must showthe relevant calculations for determining the PWM duty cycle.82. (13 points) Figure 9 on 10 shows partial C code for reading a rotary incremental quadrature encoder using adsPIC33EP64MC502-I/SP microcontroller. The QEA and QEB signals generated by the encoder connect topins 6 and 7, respectively, of the microcontroller. Turning the knob clockwise increases the dsPIC33 counterfrom 0 to 95. W hen the knob makes one complete clockwise rotation the dsPIC 3 3 count resets to zero. Thecode uses the LCD functions developed in Exercise 2 of Laboratory #2 4 to display the value of the counter aswell as the displacement of the knob in degrees.(a) (4 points) Complete the function Ini t IO ports in Figure 9. For each line of code include an appropriatecomment.(b) (5 points) Complete line 34 in Fi gure 9 by placing numbers above the dashed lines a nd adding an appro-priate comm ent. To receive partial credit, use one or two short sentences to describe how you derived theregister value.(c) (4 points) Complete line 57 in Figure 9 so that the second line of the LCD module shows the angulardisplacement as a positive number of degrees modulo 360◦, for example, display 360◦as


View Full Document

PSU EE 200 - final_s14

Download final_s14
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view final_s14 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view final_s14 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?