eecs 473 midterm exam answers

14
Page 1 of 14 EECS 473 Midterm Exam Answers Fall 2018 Name: _______________KEY_____________________ unique name: ____Key_________ 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 14 pages total for the exam as well as a handout which you will need for the last question. 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. 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: others

Post on 05-Feb-2022

17 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: EECS 473 Midterm Exam Answers

Page 1 of 14

EECS 473 Midterm Exam Answers

Fall 2018

Name: _______________KEY_____________________ unique name: ____Key_________

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 14 pages total for the exam as well as a handout which you will need for the last question. 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. 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: EECS 473 Midterm Exam Answers

Page 2 of 14

1. Circle the letter in front of all the true statements.

[10 points, -1.5 per wrong circle/lack of a circle, minimum 0]

a) A major advantage of alkaline batteries over lithium-polymer batteries is that alkaline

batteries have a lower self-discharge rate.

b) The command “mknod bob 2 4” creates a character device file named “/dev/bob”

c) Ceramic capacitors tend to have a lower ESR than tantalum capacitors.

d) The PCB power/ground plane has a relatively large capacitive value, but has significant ESR,

when compared to a ceramic capacitor.

e) In a task with a “firm” deadline the results have no use after one the deadline has passed.

f) “Busybox” is a single Linux binary that can emulate a number of other binaries. This is

done, in part, for the purpose of keeping the Linux image small.

g) A “via” on a board is a connection between two devices on a middle layer (not the top or

bottom).

h) The changes in GPLv3 from GPLv2 were in part as a response to hardware designs that

made it very difficult to run modified code.

i) If you license something under the MIT license, others can only use your work for non-

commercial purposes unless they get explicit permission from you.

j) Most PCB fab houses today require a clearance of at least 20 mills between traces.

k) EMI concerns are largely about preventing the generation of high-speed signals on the

power and ground lines.

l) Wider traces have lower resistance than narrower ones (all else being equal).

m) Shorter traces have lower resistance than longer ones (all else being equal).

n) Inductors resist changes in current.

Page 3: EECS 473 Midterm Exam Answers

Page 3 of 14

2. 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…). [8 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, 3);

/* Changing reading position as best suits */

*f_pos+=2;

if(*f_pos>=8)

return 0;

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

return 3;

}

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

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

b) What will be printed by the cat command? [5] ABCCDEEFG

Page 4: EECS 473 Midterm Exam Answers

Page 4 of 14

3. Consider an embedded application which consists of 4 tasks named A, B, and C. Each task is

CPU bound (that is, there is no I/O or memory operations which take significant time to

execute) and periodic. Each task must complete before the next instance of the task is ready

to start. These tasks have the following properties and requirements. You are to assume

there is no overhead of any type (including scheduling overhead) and that this machine

runs any given instruction in exactly the same amount of time. [13 points]

Task Maximum number instructions

executed by a single instance of the task

How often the task needs to

run A 5 Million 50ms B 15 Million 200ms C 6 Million 250ms

a) Which task do you give the highest priority under RM scheduling? The lowest? [2]

Highest ____A_______

Lowest _____C______

b) You are choosing between 4 different processors. Which of these would be the lowest

MIPS processor which would be able to schedule these tasks using EDF? You must

clearly explain your work to get any credit. [4]

150 MIPS 200 MIPS 250 MIPS 300 MIPS

(5MI/50ms+15MI/200ms+6MI/250ms)/150MIPS = 132%

(5MI/50ms+15MI/200ms+6MI/250ms)/200MIPS = 99.5% yes EDF works here.

(5MI/50ms+15MI/200ms+6MI/250ms)/250MIPS = 79.6%

c) You are choosing between 4 different processors. Which of these would be the lowest

MIPS processor which would be able to RM schedule these tasks? You must clearly

explain your work to get any credit. [7]

150 MIPS 200 MIPS 250 MIPS 300 MIPS

This is tricky. At 200 MIPS, A takes 25ms, B takes 75ms and C takes 30ms to run.

0 25 50 75 100 125 150 175 200 225 250 A X X X X X B X X X X C X

C only runs once, for 25ms before it needs to complete at 250. So 200MIPS isn’t enough.

At 250 MIPS we have A taking 20ms, B taking 60ms, and C taking 24ms.

B will finish at time 100 leaving plenty of room for C. So 250 MIPS works.

Page 5: EECS 473 Midterm Exam Answers

Page 5 of 14

4. Decoupling capacitors [6 points]

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

graph showing the same information we instead put used 10 new capacitors (in parallel)

which each had the same ESR and ESL but only 1/10th the capacitance.

Capacitance stays the same, ESR and ESL drop by a factor of 10. Line should have some curve

to it…

5. Say you have a linear regulator with a 9V input, a 3.3V output and a quiescent current of

10mA. If the load being driven by the regulator is a constant 100 Ohms, how much power is

wasted by the regulator? Show your work. [5 points]

There are a few ways to do this. Easiest is probably: Current needed to drive the load is 3.3V/100 Ohms=33mA. That’s a total of

43mA input, or 43mA*9V=387mW. Power being used is 33mA*3.3V=108.9mW. Total wasted is then 387-108.9

which is 278.1mW.

Page 6: EECS 473 Midterm Exam Answers

Page 6 of 14

6. Consider a battery with the above discharge characteristics that has a 3000mAh capacity.

Say your application requires 2A with at least 1.7V. [6 points]

a) For about how long would a single battery of this type run your application? [2]

Draw is C/1.5. So 40 minutes.

b) If your application used 10 of these batteries in parallel, about how long could your

application run? Briefly justify your answer. [4]

This is a bit trickier. Draw is C/15. We know that this can’t be more than 15

hours (definition of C). And looking at the graph C/10 lasts for a bit over 8 hours.

So C/15 should last over 12 hours. Anything over 12 and less than 15 (or maybe

even equal to 15) seems reasonable.

Page 7: EECS 473 Midterm Exam Answers

Page 7 of 14

7. Short answer. Answer each question in no more than 20 words. [7 points]

a) What is “jitter” with respect to interrupts? How can jitter occur? [2]

The amount of variance in the timing of handling an interrupt.

Jitter can occur due to interrupts being disabled, current instruction being executed,

etc.

b) In passing an engineer mentions that “at least as the battery gets older, we’ll have less heat

on the LDO”. Explain what he likely means by that. [3]

As batteries get older, their voltage drops. An LDO’s wasted power (heat) will

drop as its input voltage drops.

c) During an interview an engineer shows

you this figure and asks why the top

figure is labeled as “wrong”. What do

you tell her? [2]

High current ground path from one of

the devices could ‘lift’ the ground

node a few mV

Page 8: EECS 473 Midterm Exam Answers

Page 8 of 14

Making Some Dough [45 Points]

Starting in the Winter 2019, the Department of Bread Studies (DoBS) in the College of Engineering needs

a sensor node for temperature and humidity sensing for a new climate controlled facility for storing

bread dough. The node will be one of many in the facility, and will communicate by Bluetooth to a

Raspberry Pi that will control temperature in the facility. The temperature range in this facility will

always be between 5-65 degrees Celsius

The department has asked that you make a prototype of the device. This means assembling the

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

1. One Si7021-A20 Temperature and Humidity

sensor. This device communicates using I2C.

2. One Arduino Uno Board, powered by a 9V

battery.

3. One BLE UART Friend. This device will send

Bluetooth messages back to the Raspberry Pi.

The specification for this device is not provided,

however the interface is identical to writing to

the Serial port (to send data over Bluetooth, you

write to Serial, to get data over serial, you read).

4. A LD1117AV33 3.3V LDO.

5. One LED, that should be powered using 3.3V with a 330 Ohm resistor in series.

6. Any passives that you may require.

The Arduino has one I2C Bus (A4 is SCL, A5 is SDA). Once the Arduino is initialized, every 10 seconds it

should do the following:

● Take a temperature reading

● Take a humidity reading

● Send a message containing the following data information, in this order:

○ The first half of the Serial ID (hint: see 0xFA, 0x0F)

○ The temperature in degrees Celsius, rounded down to the nearest integer.

○ The percent relative humidity, rounded down to the nearest percent.

● If the average of Relative Humidity across readings made in the past 3 minutes is below 20%,

you should turn on your LED.

For this question you may assume the setup() has been done for you. You may assume the following.

● The RES[1:0] field of the control register has been initialized to 2b’00.

● The HTRE bit is set to zero.

● The Serial and Wire interfaces have been initialized correctly.

Figure 1. Si7021-A20 Package

Page 9: EECS 473 Midterm Exam Answers

Page 9 of 14

For the firmware portion of this question, you may wish to have certain global variables initialized to

certain variables. To denote the initialized value, do the following:

● int global_var = 1; //this value is initialized to one

● char buffer[2]; //in a comment, mention what this buffer is initialized to.

//example: init value zero for all members of array.

a) Answer the following questions: [8 points]

i. How many bytes do you need for the message you’re sending over Bluetooth? Justify your

answer. [3]

6 bytes in total

Serial-ID: 8 bytes total, we need half of it. => 4-bytes of Serial-ID

Temperature Range: 5-65, a single unsigned or signed 8-bit integer would do. => 1-byte

Humidity Range: 0-100, a single unsigned or signed 8-bit integer would do. => 1-byte

Thus, total 6-bytes are required to be sent.

ii. For what temperature range(s) is the Si7021-A20 most accurate? [2]

-10 degrees to +85 degrees from the datasheet “Figure 3. Temperature Accuracy*”

iii. What is the I2C address of the Si7021-A20? How many different Si7021-A20s can be

addressed on a single I2C bus without using any additional GPIO pins? Briefly explain your

answer to the second question. [3]

I2C address: 0x40 (hex), 64 (decimal).

Only 1 (one) I2C Si7021-A20 can be connected since we just cannot change the I2C address

of the chip.

Page 10: EECS 473 Midterm Exam Answers

Page 10 of 14

b) Draw the circuit diagram to showing connections that you are required to make. You may use nets

(same names are assumed connected). Include passive components as needed, and clearly label

them with their value. Note: due to other devices using current from the Arduino, you may not

power the Si7021-A20 from the Arduino. [10 points]

Page 11: EECS 473 Midterm Exam Answers

Page 11 of 14

c) Implement a function that converts the value read from the temperature register to degrees Celsius.

[4 points]

int8_t registerToDegrees(uint16_t RR) {

int8_t registerToDegrees(uint16_t RR) {

int8_t result;

result = (175.72*RR)/65536 – 46.85;

return result;

}

d) Implement a function that converts the relative humidity reading to percent relative humidity.

[4 points]

uint8_t registerToRH(uint16_t RR) {

uint8_t registerToRH(uint16_t RR) {

uint8_t result;

result = (125*RR)/65536 – 6;

return result;

}

Page 12: EECS 473 Midterm Exam Answers

Page 12 of 14

e) Write a function that returns the first half of the serial ID. [7 points]

uint32_t getElectronicID() {

Wire.beginTransmission (0x40);

Wire.write(0xFA);

Wire.write(0x0F);

Wire.endTransmission();

Wire.requestFrom(0x40, 8);

while (Wire.available() < 8);

uint32_t result;

result = (uint8_t) Wire.read(); Wire.read(); /* Discard CRC in

second read */

result <<= 8;

result |= (uint8_t) Wire.read(); Wire.read();

result <<= 8;

result |= (uint8_t) Wire.read(); Wire.read();

result <<= 8;

result |= (uint8_t) Wire.read(); Wire.read();

return result;

}

Page 13: EECS 473 Midterm Exam Answers

Page 13 of 14

f) Implement the loop() function for this system, As a reminder, here is the system spec: [12 points]

The Arduino has one I2C Bus (A4 is SCL, A5 is SDA). Once the Arduino is initialized, every 10 seconds

it should do the following:

● Take a temperature reading

● Take a humidity reading

● Send a message containing the following data information, in this order:

○ The first half of the Serial ID (hint: see 0xFA, 0x0F)

○ The temperature in degrees Celsius, rounded down to the nearest integer.

○ The percent relative humidity, rounded down to the nearest percent.

● If the average of Relative Humidity across readings made in the past 3 minutes is below

20%, you should turn on your LED.

//Globals and #defines go here

#define LED_PIN A0

uint8_t g_humid_idx = 0x00;

uint8_t g_humid_array[18]; // Initialize all values to 50.

/* 3 minutes => 18 elements in the array: 3*60/10 */

int8_t get_current_temperature();

uint8_t get_current_humidity();

void send_message(uint32_t id, int8_t temp, uint8_t humid);

void update_humid_value(uint8_t humid);

uint8_t average_humid_value();

void loop() {

int8_t temp_val = get_current_temperature();

uint8_t humid_val = get_current_humidity();

uint32_t serial_id = getElectronicID();;

send_message(serial_id, temp_val, humid_val);

update_humid_value(humid_val);

if (average_humid_value() < 20) {

digitalWrite(LED_PIN, LOW); /* Active-low logic */

} else {

digitalWrite(LED_PIN, HIGH); /* Active-low logic */

}

delay(10000); /* 10 seconds delay, ignoring the processing delay */

/* as it wouldn’t be more than couple of ms */

}

int8_t get_current_temperature(void) {

int8_t result;

uint16_t RR;

Wire.beginTransmission(0x40);

Page 14: EECS 473 Midterm Exam Answers

Page 14 of 14

Wire.write(0xE3);

Wire.endTransmission();

Wire.requestFrom(0x40, 2); /* 2 or 3 bytes, both are valid */

while (Wire.available() < 2); /* Wait for bytes reception */

RR = (uint8_t)Wire.read(); RR <<= 8;

RR |= (uint8_t)Wire.read();

result = registerToDegrees(RR);

return result;

}

uint8_t get_current_humidity(void);

int8_t result;

uint16_t RR;

Wire.beginTransmission(0x40);

Wire.write(0xE5);

Wire.endTransmission();

Wire.requestFrom(0x40, 2); /* 2 or 3 bytes, both are valid */

while (Wire.available() < 2); /* Wait for bytes reception */

RR = (uint8_t)Wire.read(); RR <<= 8;

RR |= (uint8_t)Wire.read();

result = registerToRH(RR);

return result;

}

void send_message(uint32_t id, int8_t temp, uint8_t humid) {

uint8_t buffer[6];

buffer[0] = (id >> 24) & 0xFF;

buffer[1] = (id >> 16) & 0xFF;

buffer[2] = (id >> 8) & 0xFF;

buffer[3] = id & 0xFF;

buffer[4] = (uint8_t)temp;

buffer[5] = humid;

Serial.write(buffer, 6);

}

void update_humid_value(uint8_t value) {

if (g_humid_idx==18) { g_humid_idx = 0; }

g_humid_array[g_humid_idx++] = value;

}

uint8_t average_humid_value() {

uint8_t result;

uint16_t sum = 0x00;

for (int i=0; i<18; i++) {

sum += g_humid_array[i];

}

result = sum/18;

return result;

}