Document

Transcription

Document
EE 200
Problem Set 8 Cover Sheet
Spring 2015
Last Name (Print):
First Name (Print):
ID number (Last 4 digits):
Section:
Submission deadlines:
• Turn in the written solutions for problems 29 through 32 by 4:00 pm Wednesday April 15 in the homework
slot outside 121 EE East.
Problem Weight
29
25
30
25
31
25
32
25
Total
100
Score
Problem 29: (25 points)
1. (12 points) Figure 1 shows the software developed in Laboratory #20 for controlling the intensity of an LED.
The user sets the LED intensity using an incremental rotary encoder that generates 24 count-per-revolutions.
The dsPIC33EP64MC502 microcontroller observes the rotation of the rotary encoder using the modulo counter
mode of the quadrature encoder interface module, where the count representing the encoder rotation position
is programmed to be an integer between 0 and 95. Rotating the encoder shaft clockwise increases the count
while a counter clockwise rotation decreases the count. One complete clockwise rotation of the encoder shaft
sweeps the duty cycle over its full range from 0% to 100%. Modify the code so that three complete clockwise
rotations of the encoder shaft are required to sweep the duty cycle from 0% to 100%.
(a) (4 points) Using the line numbers in Figure 1, which two lines must be modified? Justify your answer in
two or three short sentences.
(b) (8 points) Write the modified code lines. For each of the two lines, include an appropriate line number
and comment.
2. (13 points) The PWM module on the dsPIC33EP64MC502 microcontroller provides a convenient tool for
realizing a square-wave generator whose frequency can be set by the user. Modify the code in Figure 1 so
that it generates a 50% duty cycle square-wave on pin 25 with a frequency set by the incremental encoder.
Rotating the encoder shaft clockwise increases the frequency while a counter clockwise rotation decreases the
frequency. One complete clockwise rotation of the encoder shaft must map the square-wave frequency from
2 kHz to 20 kHz. The map should be linear, so that starting from 2 kHz, turning the number clockwise 180◦
should set the output frequency to 11 kHz. After reaching 20 kHz, turning the knob further clockwise should
wrap the frequency around to 2 kHz. Similarly, when at 2 kHz, turning the knob counterclockwise must wrap
the frequency to 20 kHz.
(a) (4 points) Using the line numbers in Figure 1, which line(s) must be modified? Justify your answer in two
or three short sentences.
(b) (9 Points) Write the modified code line(s). For each line, include an appropriate line number and comment.
Figure 1: C code for realizing a LED dimmer.
Problem 30: (25 points)
1. (12 points) Consider the front panel and block diagram of the subVI in Figure 2.
(a) (4 points) On the front panel, what does the red star in the lower left corner of the Knob Refnum indicate?
(b) (4 points) Suppose the calling VI has a front panel numeric control whose representation is a double. Can
we wire a VI Server Reference for this control to the Knob Refnum input on the subVI? Justify your
answer in a short sentence
(c) (4 points) Suppose the calling VI has a front panel numeric indicator whose representation is an unsigned
16-bit integer. Can we wire a VI Server Reference for this indicator to the DigitalNum Refnum input on
the subVI? Justify your answer in a short sentence.
Figure 2: LabVIEW subVI
2. (13 points) The LabVIEW Notifier is a broadcast mechanism for communicating from one master loop to many
parallel loops, or one-to-N communication. As an example, consider the VI in Figure 3. The Data Source Loop
generates data that is broadcast to three data processing loops that work in parallel via the Notifier named
Data.
(a) (3 points) The default value of the create if not found? terminal of the Obtain Notifier node is True. Is
it necessary to set this terminal to False for each of the three Obtain Notifier Nodes preceding the Data
Processor loops? Justify your answer in one or two sentences.
(b) (3 points) The default value of the force destroy? terminal of the Release Notifier node is False. Using
the given block diagram, it necessary to set this terminal to True? Justify your answer in one or two
sentences.
(c) (4 points) Why did the software engineer elect to pause the Data Source Loop every 10 ms? What may
happen if this delay is eliminated? Explain your answer in two or three sentences.
(d) (3 points) In words, briefly specify what the numeric value of each of the three indicators, labeled Output
1, Output 2, and Output 3, represent.
Figure 3: VI for Problem 30 part 2.
Problem 31: (25 points)
A voltage-controlled oscillator (VCO) is an electronic oscillator whose frequency is controlled by an input voltage.
The C-code in Figures 4 implements a VCO using the dsPIC33EP64MC502-I/SP microcontroller.
1. (4 points) Based on the C code, specify the peripheral pin to which the analog control voltage is applied.
Justify your answer in one or two short sentences.
2. (4 points) Based on the C code, specify the pin where the VCO output is available. Justify your answer in one
or two short sentences.
3. (10 points) Specify an equation for PTPER in line 51 so that the output frequency varies linearly as a function
of the control voltage. Increasing the control voltage increases from 0 V to 3.3 V must increase the frequency
from 100 Hz to 1 kHz. To receive partial credit, explain your logic in complete English sentences and show
appropriate calculations.
4. (4 points) Specify an equation for PDC2 in line 52 so that the duty cycle of the square-wave output is approximately 70% regardless of the square-wave frequency. To receive partial credit, explain your logic in complete
English sentences and show appropriate calculations.
5. (3 points) Approximately how many times per second does the code read the analog input voltage and update
the VCO output frequency? Justify your answer in one or two short sentences.
Figure 4: Code for realizing a VCO.
Problem 32: (25 points)
1. (12 points) Consider the two implicitly linked property nodes in Figure 5. The Value property sets the value
of the Boolean to FALSE, but does not generate a Value Changed Event for an event structure. In contrast,
the Val(sgnl) property sets the Boolean to False and generates a Value Changed Event for an event structure.
The properties Value and Val(sgnl) may also be set using explicitly linked property nodes. Now consider the
VI in Figure 6. The mechanical action of the Boolean controls labeled Control 1 through Control 3 is Switched
when Released. The Boolean action of the Stop button is Latched when Released. Justify your answers to the
following questions using one or two short sentences.
(a) (3 points) When Control 1 is pressed and released, does it remain set to True or does the program
automatically reset it to False?
(b) (3 points) Does pressing and releasing Control 2 cause the value displayed by the indicator labeled Num
Hits to increment?
(c) (3 points) Does pressing and releasing Control 3 cause the value displayed by the indicator labeled Num
Hits to increment?
(d) (3 points) What effect, if any, does pressing and releasing Control 3 have on Control 1?
Figure 5: The properties Value and Val(sgnl) both change the value of a front panel object, but only the Val(sgnl)
property generates a Value Changed Event within an event structure.
Figure 6: VI for Problem 32 Part 1.
2. (13 points) In addition to the Semaphores, Notifier, and Queue, the LabVIEW programming environment
provides another synchronization tool known as Rendezvous. The VIs available on the Rendezvous palette
allow the user to synchronize two or more separate, parallel tasks at specific points of execution. Each task
that reaches the rendezvous waits until the specified number of tasks are waiting, at which point all tasks
proceed with execution. Unlike a notifier or queue, a rendezvous does not pass data or messages between tasks.
Consider the VI in Figure 7.
(a) (12 points) While the VI operates each of the six indicator Booleans, L1, L2, L3, LA, LB, and LC flashes
on and off. Determine the period and percent duty cycle for each indicator lamp.
(b) (1 point) Which, if any, indicators flash on and off in synchrony?
Figure 7: VI for Problem 32 Part 2.