DOC PREVIEW
PSU EE 200 - final_s15

This preview shows page 1-2-23-24 out of 24 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 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 24 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 24 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 24 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

blanksolutionsEE 200 Final Exam 5 May 2015Last 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. (14 points) Figure 1 shows a dsPIC33EP64MC502-I/SP microcontroller circuit for controlling a LED using atactile switch. The LED is driven by peripheral pin 4, while the switch connects to peripheral pin 21. Thecircuit in Figure 1 and the parti ally completed C code in Figure 2 on page 3 must meet the following designspecifications.• When the system is turned on, the C code must light the LED.• If the LED is lit, the moment the user depresses the tactile switch the LED must turn off.• If the LED is unlit, the moment the user depresses the tactile switch the LED must turn on.• The software must respond to the tactile switch using an interrupt, rather than continually polling thestate of p eripheral pin 21.• The C code must use INT1, and the ISR must execute on the falli ng edge of the signa l appli ed to peripheralpin 21 .Figure 1: Microcontroller circuit for controlling an LED using a tactile switch.(a) (2 points) Why is it necessary to include line 16 in the C code?(b) (4 points) Complete lines 24 and 25 that initialize the DIO ports in Figure 2. For each line, use a singlehexadecimal number, for example, 0xA987.(c) (4 po ints) Complete lines 29 and 31 that initialize the interrupt INT1 in Fig ure 2. For line 29 , use ahexadecimal number, for example, 0xFDCB.(d) (2 points) Complete lines 37 and 38 in the ISR in Figure 2.(e) (2 points) Complete line 42 in Fig ure 2 and explain below why it must be included in the code.2Figure 2: Code for controlling the LED.32. (11 po ints) Figure 3 shows a partiall y completed state diagram for a Moore finite state machine realized usingthe C code i n Figure 4 on page 5. The finite state machine has a single input x that represents the logical stateof port A line A0, and a single output y that appears on port B li ne B3.Figure 3: State diag ram for a Moo re finite state machine.(a) (9 points) Using the C code i n Figure 4, complete the state diagram in Figure 3.(b) (2 points) Using the state diagram in Figure 3, com plete the lines 57 through 60 in the C code in Figure4.4Figure 4: Code for realizing a finite state machine.5Problem 2: (25 Points)1. (10 po ints) In C code the variable A is defined asint A = 0b0 0101100;(a) (2 points) Write the value of the variable B, in hexadecimal form, for example B = 0x2F, after the followingcode executesB = A & 0xF0;(b) (2 points) Write the value of the variable C, i n hexadecimal form, after the following code executesC = A | 0x0F;(c) (2 points) Write the value of the variabl e D, in hexadecimal form, after the following code executesD = A << 2;(d) (2 points) Write the value of the variable E, in hexadecimal form, after the following code executesE = A >> 4;(e) (2 points) Write the value of the variabl e F, in hexadecimal form, after the following code executesF = A ˆ 1;62. (5 points) Di scuss the advantage and disadvantage of using the 4-bit mode of the HD44780U LCD driver/controllerinstead of the 8-bit mode.73. (10 po ints) Assume that the LCD module is connected to the dsPIC33EP64MC502-I/SP microcontroller as i nthe laboratory exercises. After the C code in Figure 5 executes, indicate wha t is shown in the LCD display byusing Figure 6.Figure 5: Code for writing a two line message to the LCD module.Figure 6: LCD display after the code in Figure 5 executes.8Problem 3: (25 Points)1. (12 points) Consider the circuit in Figure 7, where the source vs(t) g enerates a square wave signal with peakampl itude Vp= 10 V, period T = 1 ms, and fractional duty cycle D = 0.4. The value of the load resistanceRLis 1 kΩ.Figure 7: PWM circuit.(a) (3 points) Determine the average value of vL(t).(b) (3 points) Derive an expression for the instantaneous power p(t) dissipated by the resistor.(c) (3 points) Determine the average power, in Watts, dissipated by the resistor.(d) (3 points) Determine the average power, in Watts, dissipated by the resistor if the fractional cycle isincreased by a factor of two.92. (13 points) The Bourns Encoder ECW1J-B24 BE0036 is a rotary incremental quadrature encoder which gen-erates 36 counts per revolutio n. The C code in Figure 8 initi alize the quadrature encoder module of thedsPIC33EP64MC502-I/SP microcontroller for reading angular displacement using this encoder.Figure 8: Code for initi alizing the quadrature encoding module.(a) (6 points) Complete line 30 in Figure 8 using a hexadecimal number, fo r example, 0x1234, so that thequadrature encoder signals QEA and QEB connect to peripheral pins 6 and 7, respectively, of the micro-controller.(b) (7 points) Complete lines 34 and 36 in Figure 8 so that• each time the encoder completes two clockwise full rotations, the microcontroller position counterresets to zero, and• when the position counter is at zero and the encoder is rotated counterclockwise, the position counterresets to its maximum value.10Problem 4: (25 Points)1. (16 points) Figure 9 shows partially completed C functions for reading an analog signal applied to pin 6 (AN4) ofa dsPIC33EP64MC502-I/SP microcontroller. The function Init ADC is called before the function Read ADC.Figure 9: 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 6. Comment each line o f code added to the function.(b) (4 points) Com plete line 24 in the function Read ADC. Add appropriate


View Full Document

PSU EE 200 - final_s15

Download final_s15
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_s15 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_s15 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?