eecs 473 midterm exam - university of michigan 473 midterm exam fall 2017 ... t3 period %...

14
Page 1 of 14 EECS 473 Midterm Exam Fall 2017 Name: ____________________________________ unique name: _____________ Sign the honor code: I have neither given nor received aid on this exam nor observed anyone else doing so. ___________________________________ NOTES: 1. Closed book and Closed notes 2. There are 13 pages total for the exam. 3. Calculators are allowed, but no PDAs, Portables, Cell phones, etc. Using a calculator to store notes is not allowed nor is a calculator with any type of wireless capability. 4. You have about 120 minutes for the exam. 5. Be sure to show work and explain what you’ve done when asked to do so. That may be very significant in the grading of this exam.

Upload: trinhkhue

Post on 26-Mar-2018

227 views

Category:

Documents


5 download

TRANSCRIPT

Page 1 of 14

EECS 473 Midterm Exam

Fall 2017

Name: ____________________________________ unique name: _____________

Sign the honor code:

I have neither given nor received aid on this exam nor observed anyone else doing so.

___________________________________

NOTES:

1. Closed book and Closed notes 2. There are 13 pages total for the exam. 3. Calculators are allowed, but no PDAs, Portables, Cell phones, etc. Using a calculator to store notes is not

allowed nor is a calculator with any type of wireless capability. 4. You have about 120 minutes for the exam. 5. Be sure to show work and explain what you’ve done when asked to do so. That may be very significant in

the grading of this exam.

Page 2 of 14

1) Circle the best answer. [10 points, -2 per wrong or blank answer, minimum 0]

a. Alkaline batteries are primary / secondary cell batteries. A major advantage of alkaline batteries over

lithium-polymer batteries does not include:

a lower self-discharge rate

less likely to leak

a lower cost per mAh

b. For which of the following deadline types is there still utility in completing a task after the deadline has

passed (circle all that apply): soft / firm / hard.

c. The Linux command rmmod does which of the following?

Renames a module that has been inserted into the kernel

Removes a module that has been inserted into the kernel

Renames a module that has not yet been inserted into the kernel

Removes the last

modification to a module

d. The picture on the right shows

impedance vs. frequency for a variety

of

ideal capacitors.

non-ideal capacitors with

similar parasitics.

non-ideal capacitors with very

different parasitics.

e. PCB manufactures use a number of

different terms to describe distances.

Among the most common are “thou”,

“mm” and “mill”. A thou is 0.001 inches / 0.001 meters / 0.001 cm / 0.001 feet.

A mill is 0.001 inches / 0.001 meters / 0.001 cm / 0.001 feet.

f. The “L” in an LDO converter indicates that

you only need a low value output capacitor, often less than a µF.

the output has very little noise.

the output voltage can be nearly as high as the input voltage.

Page 3 of 14

2. Say you have the following groups of tasks. For each group find the CPU utilization and identify which

groups are RM and which are EDF schedulable. Indicate if you needed to do the critical instant analysis.

If needed, clearly show that analysis. The following equation may prove useful.

[9 points]

Group T1

Execution Time

T1 Period

T2 Execution

Time

T2 Period

T3 Execution

Time

T3 Period

% Utilization

A 2 10 3 9 4 8 103.3%

B 2 10 4 9 1 6 81.1%

C 3 10 2 9 9 20 97.2%

Group EDF

Schedulable? RM

Schedulable? Did you need to examine

the critical instance?

A N N No

B Y Y Yes

C Y N Yes

B) yes:

Task 0-1 1-2 2-3 3-4 4-5 5-6 6-7 7-8 8-9

T1

T2

T3

C) no

Task 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21

T1

T2

T3

Page 4 of 14

3. Consider a battery with the above discharge characteristics [8 points]

a) What is the (approximate) capacity of this battery in mAh? Provide a brief justification.[3]

About (.35A*20h) or around 7Ah.

b) Say your application requires 14A with at least 10V.

i. For about how long would a single battery of this type run your application? [1]

~12 minutes.

ii. If your application used 8 of these batteries in parallel, about how long could your

application run? Briefly justify your answer. [4]

14A/8-1.75A per battery. So probably 3.75 hours or so. Certainly less than 4h and almost

certainly more than 3 hours.

Page 5 of 14

4. Consider the following code found as the read function member of the file_operations struct for

a Linux kernel module. It is associated with the device file "/dev/txx2" (so a read of the file /dev/txx2 will result in this function being called). Assume that everything is set up appropriately beforehand. Ignore the fact that copy_to_user’s return value is being ignored (it’s just a warning…). [10 points] const char s[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

ssize_t memory_read(struct file *filp, char *buf,

size_t count, loff_t *f_pos) {

/* Transferring data to user space */

copy_to_user (buf, s+*f_pos, 2);

/* Changing reading position as best suits */

*f_pos+=2;

if(*f_pos>=8)

return 0;

printk("<1> fpos= %d\n",*f_pos);

return 1;

}

Say that someone does a cat of /dev/txx2. a. What will appear in the log file? [4]

<1> fpos=2 <1> fpos=4 <1> fpos=6

b. What will be printed by the cat command? [6] ACE -- this is pretty tricky. What happens is that each time it starts at fpos and copies 2 bytes

starting at that point. But it then is told only 1 byte was sent back (via the return value)..

Page 6 of 14

5. Say you have two points, A and B,

which you wish to connect with a

trace. Current flows from A to B at a

rate as high as 1 Amp. You wish to

manage the following:

As low of a resistance trace as

you can achieve without having

a trace wider than 0.07 inches.

The trace shouldn’t rise by

more than 10 degrees C above

the 30 degrees C ambient.

Your PCB manufacturer requires that

metal pads must be at least 0.01 inches

from traces. Only 90 degree turns are

allowed. You only have one metal layer

(one-sided board). A and B are exactly

0.7 inches apart. The metal layer is 1oz/ft2. Ignore any other connections that may need to occur.

You may find the chart on the following page to be useful. [10 points]

a. Draw the two basic ways you can reasonably route from A to B. Make any neck downs required

obvious. [1]

b. Which path will have the lower resistance? Clearly justify your answer using numbers (notice,

we aren’t asking you to compute the resistance). Make your assumptions clear. [5]

Resistance is proportional to length divided by width. So the blue one is about

0.5 inches/0.07inches+0.2 inches/0.03 inches. =13.8. Red is about 1.3 inches/0.07 inches=18.6.

So blue is lower resistance.

A number of you used total area (and went back and forth if more area was lower or higher)

which is wrong. Some of you treated the traces as wires (with a diameter equal to their width).

That too is wrong as the traces are flat and have a constant height.

c. Which of the routes (if any) will meet the temperature requirements? Again, clearly justify your

answer. [4]

Using 1A at 10 degrees rise and 1oz/ft2 looks like we are limited to 0.04 inches. The neckdown

in the blue option goes to 0.03. So blue won’t meet our specification.

Page 7 of 14

Page 8 of 14

6. Answer the following questions. These can all be answered in one or two sentences. [8 points]

a. What is the primary difference between the GNU public license (GPL) and the LGPL? [3]

The LGPL is that the latter allows the work to be linked with (in the case of a library, "used by") a

non-(L)GPLed program, regardless of whether it is free software or proprietary software (from

Wikipedia).

b. Define the term “power integrity”. [2]

Keeping the power and ground voltage constant. Generally by adding capacitors. (It is not

keeping the power or current constant which many of you said.)

c. Explain what choices Arduino made when designing their API when trading off Efficiency, Usability

and Portability. [3]

They focused on usability. That caused problems

with efficiency (say using angle in degrees as a

input to a servo which may cause a lot of extra fp

work). It also has things that are pretty specific to

the Atmel family which might cause portability problems (only supports devices found on

supported parts, etc.).

Page 9 of 14

7. Decoupling capacitors [6 points]

The above graph shows the frequency vs. impedance for a given capacitor. Redraw the graph showing

the same information we got a new capacitor which had the same capacitance but the ESR and ESL were

both halved.

The above line is about right. It should drop down to 0.01 ohms for quite a while. Then it should go up,

keeping the same distance from the pink line.

8. Say you have a linear regulator with an 8V input, a 5V output and a quiescent current of 10mA. If the

load being driven by the regulator is a constant 50 Ohms, how much power is wasted by the regulator?

Show your work. [6 points]

5V at 50 Ohms means we are moving 100mA of current. So 110mA @8V in. 100mA@5V out.

That’s 880mW in and 500mW that is useful out. So 380mW are wasted.

Page 10 of 14

Design Question [31 points]

A team from the Department of Biotechnology has come up with the design of a small portable device that can

be used to test blood samples in the rural areas, without the need to send them to the labs. The blood sample is

placed on a glass slide and inserted into the device, which can detect the constituents of the blood using light

spectrum received through the sample. The amount of the light absorbed gives a good idea of the constituents

of the blood. Additionally, to speed up the process of multiple sampling, the device will have two slots to receive

blood sample and sensor for each of them. You should read the entire question before starting.

The department has requested that you make a prototype of this device. This means assembling the hardware

as well as writing the associated firmware. The device has the following components.

1) Two LEDs, each emitting light around 660 nm wavelength. The

LEDs require a 100 Ohm resistor to limit the current when

powered at 3.3V.

2) Two OPT3001 light sensors. These devices communicate with

the processor over the I2C.

3) Arduino Uno board powered via 5V LiPo battery.

4) LM3940 5V to 3.3V LDO

5) Passive devices (resistors, capacitors) as needed.

6) An LCD (Specification is not provided. It’s someone else’s job

to hook it up. They will be using pins from 7 to 13. These pins

cannot be used for any other purpose.).

Each LED is paired with an OPT3001 light sensor module, allowing analysis of two different samples at the same

time. The blood sample is placed on a plate between the LED and the light sensor.

Notice that the Arduino board only has one I2C bus (A4 is SDA and A5 is SCL).

Once Arduino has initialized the components, it should do the following:

Turn on the LED and take a measurement from the first of the LED/light sensor pairs.

Take 30 measurements (be sure you aren’t just taking one measurement and getting the same data

from it 30 times).

Turn off the LED on the first sensor, display the average lux (rounding to the nearest integer) on the first

line of the LCD.

Repeat the process for the second LED/light sensor pair, displaying the lux on the second line of the LCD.

Continue alternating between the first and second pair indefinitely.

(The intent is that the user will change the blood sample being measured on one LED/sensor pair while the other

is taking a measurement and will power down the device once finished).

Figure 1:OPT3001

Page 11 of 14

For this problem, you will assume that the setup() function is already done for you, i.e. the OPT3001 sensors

are properly configured, the digital Pins on the Arduino for LED control and reading I2C data are properly set. In

particular assume the configuration register is set to:

RN[3:0] =1100b (automatic full-scale) CT =1b (800ms conversion time) M[1:0] =10b (Continuous conversions) (Other values are read only or don’t matter for our application).

See the attached data sheets for further information on the light sensor and the LDO. There is also a summary

of potentially relevant library calls for the Arduino.

a) Draw a circuit diagram showing all the connections you are required to make. Include passives as

needed. [8] Note: there are a number of correct answers. In particular what ADDR is connected to and

one could use the 3.3V from the Arduino.

Page 12 of 14

b) About how long do you expect each LED will need to be on to take the 30 readings? Briefly justify your

answer. [2]

Time for each conversion = 800 + 3 ms = 803 ms

Total time taken for 30 readings = 803 * 30 = 24.09 sec

The integration time can range upto 880 ms. Accordingly, the total time taken can be upto 26.5 seconds.

Any answer in between is acceptable.

c) Create a function which takes in a 16-bit value (unsigned long) that is the value of the result register

from the OPT3001 and returns a 16-bit value (unsigned long) that is the lux value (rounded to the

nearest integer). It should use the prototype given. (Hint: you don’t need a big if statement or case

statement.) [5]

unsigned long RRtoLux(unsigned long RR)

{

return (0.01 * pow(2,(RR >> 12) & 0x000F) * (RR & 0x0FFF));

}

Page 13 of 14

d) Write the loop function for the Arduino which performs the tasks required of this device. Use the

RRtoLux function you wrote for part b. [16]

This was probably too long of a question for the exam.

#define OPT_ADDR_1 0x44

#define OPT_ADDR_2 0x45

#define LED_1 5

#define LED_2 4

#define RESULT_REG 0x00

#define CONFIG_REG 0x01

#define NUM_OF_ITER 30

//setup() is done

bool isOptReady(char addr)

{

unsigned int temp = 0;

Wire.beginTransmission(addr);

Wire.write(CONFIG_REG);

Wire.endTransmission();

Wire.requestFrom(addr,2);

while(Wire.available() < 2);

temp = Wire.read() << 8; //MSB

temp |= Wire.read(); //LSB

return((temp >> 7) & 0x01); //Return the 7th bit of the config register

}

unsigned long getOptData(char addr)

{

unsigned int data = 0;

Wire.beginTransmission(addr);

Wire.write(RESULT_REG);

Wire.endTransmission();

Wire.requestFrom(addr,2);

while(Wire.available() < 2);

data = Wire.read() << 8;

data |= Wire.read();

return(data);

}

Page 14 of 14

void loop() {

unsigned long accum_sum = 0;

unsigned long curr_read = 0;

int i=0;

//For first sensor

digitalWrite(LED_1, HIGH);

delay(883); //give a safe stretch of 883 ms before starting the readings

for(i=0;i<NUM_OF_ITER; i++)

{

while(!isOptReady(OPT_ADDR_1));

curr_read = getOptData(OPT_ADDR_1);

accum_sum += RRtoLux(curr_read);

}

accum_sum = accum_sum/NUM_OF_ITER;

LCD.setCursor(0,0);

LCD.print(accum_sum);

digitalWrite(LED_1, LOW);

accum_sum = 0; //reset accumulator variable

digitalWrite(LED_2, HIGH);

delay(883); //give a safe stretch of 883 ms before starting the readings

for(i=0;i<NUM_OF_ITER; i++)

{

while(!isOptReady(OPT_ADDR_2));

curr_read = getOptData(OPT_ADDR_2);

accum_sum += RRtoLux(curr_read);

}

accum_sum = accum_sum/NUM_OF_ITER;

LCD.setCursor(0,1);

LCD.print(accum_sum);

digitalWrite(LED_2, LOW);

accum_sum = 0; //reset accumulator variable

}