20
EE 200 Final Exam 6 May 2014 Last Name (Print): First Name (Print): ID number (Last 4 digits): Section: DO NOT TURN THIS PAGE UNTIL YOU ARE TOLD TO DO SO Problem Weight Score 1 25 2 25 3 25 4 25 Total 100 INSTRUCTIONS 1. You have 2 hours to complete this 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 the exam. 4. Calculators are allowed. 5. Solve each part of the problem in the space following the question. If you need more space, continue your solution on the reverse side labeling the page with the question number; for example, Problem 1.2 Continued. NO credit 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 a grade of ZERO will be assigned. 7. The quality of your analysis and evaluation is as important as your answers. Your reasoning must be precise and clear; your complete English sentences should convey what you are doing. To receive credit, you must show your work. 1

Problem Weight Score 1 25 2 25 3 25 4 25 Total 100courses.ee.psu.edu/schiano/ee200/Exams/final_s14.pdf · Problem Weight Score 1 25 2 25 3 25 4 25 Total 100 INSTRUCTIONS 1. You have

  • Upload
    others

  • View
    8

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Problem Weight Score 1 25 2 25 3 25 4 25 Total 100courses.ee.psu.edu/schiano/ee200/Exams/final_s14.pdf · Problem Weight Score 1 25 2 25 3 25 4 25 Total 100 INSTRUCTIONS 1. You have

EE 200 Final Exam 6 May 2014

Last Name (Print):

First Name (Print):

ID number (Last 4 digits):

Section:

DO NOT TURN THIS PAGE UNTIL YOU ARE TOLD TO DO SO

Problem Weight Score

1 25

2 25

3 25

4 25

Total 100

INSTRUCTIONS

1. You have 2 hours to complete this 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. NO

credit 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 and 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 must

show your work.

1

Page 2: Problem Weight Score 1 25 2 25 3 25 4 25 Total 100courses.ee.psu.edu/schiano/ee200/Exams/final_s14.pdf · Problem Weight Score 1 25 2 25 3 25 4 25 Total 100 INSTRUCTIONS 1. You have

Problem 1: (25 Points)

1. (12 points) 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 analog signals?

(b) (2 points) Which peripheral pin(s) are used for digital input?

(c) (2 points) Which 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 code for setting the function of peripheral pins.

2

Page 3: Problem Weight Score 1 25 2 25 3 25 4 25 Total 100courses.ee.psu.edu/schiano/ee200/Exams/final_s14.pdf · Problem Weight Score 1 25 2 25 3 25 4 25 Total 100 INSTRUCTIONS 1. You have

2. (13 points) The C code in Figure 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 signal.

(a) (3 points) After the code executes, what is the logic state of the signal 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 code executes, what is the value of the integer y? Justify your answer in one or twoshort sentences.

3

Page 4: Problem Weight Score 1 25 2 25 3 25 4 25 Total 100courses.ee.psu.edu/schiano/ee200/Exams/final_s14.pdf · Problem Weight Score 1 25 2 25 3 25 4 25 Total 100 INSTRUCTIONS 1. You have

Problem 2: (25 Points)

The C code in Figure 4 on page 5 realizes a Moore 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. Complete the Table 2 by specifying the logic levels (0 or 1) of RA2 and RA3 that yield thespecified values of x.

RA2 RA3 x

01

23

Table 1: The FSM digital inputs determine the value of x.

2. (8 points) Complete Table 2 by specifying the next state and the digital output RB7. All entries must becompleted with either a state name or the binary digits 0 and 1.

Present Next State Output

State x = 0 x = 1 x = 2 x = 3 RB7

S1

S2S3

Table 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, justifyyour answer.

(b) (4 points) Is an interrupt generated on the rising or falling edge of the reset signal? To receive credit,justify your answer.

4

Page 5: Problem Weight Score 1 25 2 25 3 25 4 25 Total 100courses.ee.psu.edu/schiano/ee200/Exams/final_s14.pdf · Problem Weight Score 1 25 2 25 3 25 4 25 Total 100 INSTRUCTIONS 1. You have

Figure 4: Code for realizing a Moore finite state machine.

5

Page 6: Problem Weight Score 1 25 2 25 3 25 4 25 Total 100courses.ee.psu.edu/schiano/ee200/Exams/final_s14.pdf · Problem Weight Score 1 25 2 25 3 25 4 25 Total 100 INSTRUCTIONS 1. You have

Problem 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 module.

(a) (8 points) Add the additional line(s) of code to the function Init ADC to enable reading analog signals onpin 7. Comment each line of code added to the function.

(b) (4 points) Complete line 24 in the function Read ADC. Add appropriate numerical constants in theunderlined spaces and a meaningful comment.

(c) (4 points) Suppose that a constant 2 V signal is connected to pin 7. What value does the functionRead ADC return when it is called.

6

Page 7: Problem Weight Score 1 25 2 25 3 25 4 25 Total 100courses.ee.psu.edu/schiano/ee200/Exams/final_s14.pdf · Problem Weight Score 1 25 2 25 3 25 4 25 Total 100 INSTRUCTIONS 1. You have

2. (9 points) The code in Figure 6 uses the LCD functions developed in Exercise 2 of Laboratory #24.

Figure 6: Code for writing a message to the LCD module.

(a) (3 points) 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) What ASCII character does the hexadecimal number in part (a) represent?

(c) (3 points) Indicate in Figure 6 the message written to the LCD module.

Figure 7: LCD module display.

7

Page 8: Problem Weight Score 1 25 2 25 3 25 4 25 Total 100courses.ee.psu.edu/schiano/ee200/Exams/final_s14.pdf · Problem Weight Score 1 25 2 25 3 25 4 25 Total 100 INSTRUCTIONS 1. You have

Problem 4: (25 Points)

1. (12 points) Figure 8 shows C-code for generating a square-wave signal using the PWM module on the dsPIC33EP64MC502-I/SP microcontroller.

Figure 8: Code for generating a square-wave.

(a) (4 points) Specify the peripheral pin at which the square-wave signal is present. Justify your answer inone or two short sentences.

(b) (4 points) Determine the frequency of the square-wave signal. To receive credit you must show the relevantcalculations for determining the PWM frequency.

(c) (4 points) Determine the percent duty cycle of the square-wave signal. To receive credit you must showthe relevant calculations for determining the PWM duty cycle.

8

Page 9: Problem Weight Score 1 25 2 25 3 25 4 25 Total 100courses.ee.psu.edu/schiano/ee200/Exams/final_s14.pdf · Problem Weight Score 1 25 2 25 3 25 4 25 Total 100 INSTRUCTIONS 1. You have

2. (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. When the knob makes one complete clockwise rotation the dsPIC 33 count resets to zero. Thecode uses the LCD functions developed in Exercise 2 of Laboratory #24 to display the value of the counter aswell as the displacement of the knob in degrees.

(a) (4 points) Complete the function Init IO ports in Figure 9. For each line of code include an appropriatecomment.

(b) (5 points) Complete line 34 in Figure 9 by placing numbers above the dashed lines and adding an appro-priate comment. 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 0◦.

9

Page 10: Problem Weight Score 1 25 2 25 3 25 4 25 Total 100courses.ee.psu.edu/schiano/ee200/Exams/final_s14.pdf · Problem Weight Score 1 25 2 25 3 25 4 25 Total 100 INSTRUCTIONS 1. You have

Figure 9: Code for reading a rotary incremental quadrature encoder.

10

Page 11: Problem Weight Score 1 25 2 25 3 25 4 25 Total 100courses.ee.psu.edu/schiano/ee200/Exams/final_s14.pdf · Problem Weight Score 1 25 2 25 3 25 4 25 Total 100 INSTRUCTIONS 1. You have

EE 200 Final Exam 6 May 2014

Last Name (Print):

First Name (Print):

ID number (Last 4 digits):

Section:

DO NOT TURN THIS PAGE UNTIL YOU ARE TOLD TO DO SO

Problem Weight Score

1 25

2 25

3 25

4 25

Total 100

INSTRUCTIONS

1. You have 2 hours to complete this 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. NO

credit 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 and 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 must

show your work.

1

Page 12: Problem Weight Score 1 25 2 25 3 25 4 25 Total 100courses.ee.psu.edu/schiano/ee200/Exams/final_s14.pdf · Problem Weight Score 1 25 2 25 3 25 4 25 Total 100 INSTRUCTIONS 1. You have

Problem 1: (25 Points)

1. (12 points) 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 analog signals?

(b) (2 points) Which peripheral pin(s) are used for digital input?

(c) (2 points) Which 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 code for setting the function of peripheral pins.

2

Page 13: Problem Weight Score 1 25 2 25 3 25 4 25 Total 100courses.ee.psu.edu/schiano/ee200/Exams/final_s14.pdf · Problem Weight Score 1 25 2 25 3 25 4 25 Total 100 INSTRUCTIONS 1. You have

2. (13 points) The C code in Figure 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 signal.

(a) (3 points) After the code executes, what is the logic state of the signal 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 code executes, what is the value of the integer y? Justify your answer in one or twoshort sentences.

3

Page 14: Problem Weight Score 1 25 2 25 3 25 4 25 Total 100courses.ee.psu.edu/schiano/ee200/Exams/final_s14.pdf · Problem Weight Score 1 25 2 25 3 25 4 25 Total 100 INSTRUCTIONS 1. You have

Problem 2: (25 Points)

The C code in Figure 4 on page 5 realizes a Moore 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. Complete the Table 2 by specifying the logic levels (0 or 1) of RA2 and RA3 that yield thespecified values of x.

RA2 RA3 x

01

23

Table 1: The FSM digital inputs determine the value of x.

2. (8 points) Complete Table 2 by specifying the next state and the digital output RB7. All entries must becompleted with either a state name or the binary digits 0 and 1.

Present Next State Output

State x = 0 x = 1 x = 2 x = 3 RB7

S1

S2S3

Table 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, justifyyour answer.

(b) (4 points) Is an interrupt generated on the rising or falling edge of the reset signal? To receive credit,justify your answer.

4

Page 15: Problem Weight Score 1 25 2 25 3 25 4 25 Total 100courses.ee.psu.edu/schiano/ee200/Exams/final_s14.pdf · Problem Weight Score 1 25 2 25 3 25 4 25 Total 100 INSTRUCTIONS 1. You have

Figure 4: Code for realizing a Moore finite state machine.

5

Page 16: Problem Weight Score 1 25 2 25 3 25 4 25 Total 100courses.ee.psu.edu/schiano/ee200/Exams/final_s14.pdf · Problem Weight Score 1 25 2 25 3 25 4 25 Total 100 INSTRUCTIONS 1. You have

Problem 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 module.

(a) (8 points) Add the additional line(s) of code to the function Init ADC to enable reading analog signals onpin 7. Comment each line of code added to the function.

(b) (4 points) Complete line 24 in the function Read ADC. Add appropriate numerical constants in theunderlined spaces and a meaningful comment.

(c) (4 points) Suppose that a constant 2 V signal is connected to pin 7. What value does the functionRead ADC return when it is called.

6

Page 17: Problem Weight Score 1 25 2 25 3 25 4 25 Total 100courses.ee.psu.edu/schiano/ee200/Exams/final_s14.pdf · Problem Weight Score 1 25 2 25 3 25 4 25 Total 100 INSTRUCTIONS 1. You have

2. (9 points) The code in Figure 6 uses the LCD functions developed in Exercise 2 of Laboratory #24.

Figure 6: Code for writing a message to the LCD module.

(a) (3 points) 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) What ASCII character does the hexadecimal number in part (a) represent?

(c) (3 points) Indicate in Figure 6 the message written to the LCD module.

Figure 7: LCD module display.

7

Page 18: Problem Weight Score 1 25 2 25 3 25 4 25 Total 100courses.ee.psu.edu/schiano/ee200/Exams/final_s14.pdf · Problem Weight Score 1 25 2 25 3 25 4 25 Total 100 INSTRUCTIONS 1. You have

Problem 4: (25 Points)

1. (12 points) Figure 8 shows C-code for generating a square-wave signal using the PWM module on the dsPIC33EP64MC502-I/SP microcontroller.

Figure 8: Code for generating a square-wave.

(a) (4 points) Specify the peripheral pin at which the square-wave signal is present. Justify your answer inone or two short sentences.

(b) (4 points) Determine the frequency of the square-wave signal. To receive credit you must show the relevantcalculations for determining the PWM frequency.

(c) (4 points) Determine the percent duty cycle of the square-wave signal. To receive credit you must showthe relevant calculations for determining the PWM duty cycle.

8

Page 19: Problem Weight Score 1 25 2 25 3 25 4 25 Total 100courses.ee.psu.edu/schiano/ee200/Exams/final_s14.pdf · Problem Weight Score 1 25 2 25 3 25 4 25 Total 100 INSTRUCTIONS 1. You have

2. (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. When the knob makes one complete clockwise rotation the dsPIC 33 count resets to zero. Thecode uses the LCD functions developed in Exercise 2 of Laboratory #24 to display the value of the counter aswell as the displacement of the knob in degrees.

(a) (4 points) Complete the function Init IO ports in Figure 9. For each line of code include an appropriatecomment.

(b) (5 points) Complete line 34 in Figure 9 by placing numbers above the dashed lines and adding an appro-priate comment. 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 0◦.

9

Page 20: Problem Weight Score 1 25 2 25 3 25 4 25 Total 100courses.ee.psu.edu/schiano/ee200/Exams/final_s14.pdf · Problem Weight Score 1 25 2 25 3 25 4 25 Total 100 INSTRUCTIONS 1. You have

Figure 9: Code for reading a rotary incremental quadrature encoder.

10