EGR 2800 Fall 2023 Exam Answer Key

pdf

School

Oakland University *

*We aren’t endorsed by this school

Course

2800

Subject

Electrical Engineering

Date

Feb 20, 2024

Type

pdf

Pages

7

Uploaded by paulskingdom

Report
EGR 2800 Fall 2023 Exam I Page 1 of 6 11/10/2023 Student Name: ___________ Exam time: 60 minutes. You may use your textbook and 3 sheets (i.e., 6 sides) of hand-written notes. No sharing of materials of any kind. You may NOT use a calculator, Laptop, PDA, Cell phone, or any other aid. There will be no points for illegible answers. Read the problems carefully, but work quickly and efficiently. Problems are not necessarily in order of difficulty. If a problem is taking a long time, skip to another problem. Use space provided. If you need more space, you are probably on the wrong path. All questions refer to the microcontroller, development board, IDE, and materials used/covered in EGR 2800, unless explicitly stated otherwise. Any attempt to cheat will be referred to the Dean of Students for an academic misconduct hearing. Problem Possible Score 1 10 2 16 3 12 4 12 Score 50
EGR 2800 Fall 2023 Exam I Page 2 of 6 Problem 1 [10 points] a) Pin 9 from the Arduino Uno is connected to the circuit displayed on the right. The speaker resistance (SP1) is 5Ω with a max current rating of 0.50A. What should be the minimum resistance value of R1? [3 points] V=IR 5V = 0.5A(R1+5 Ω ) R1 = ((5/0.5) 5) Ω R1 = 5 Ω b) A DC motor is connected to the L293D Motor Driver below so that it can be controlled bidirectionally by pins (7,8,9) on the Arduino. Using the truth table below write a complete Arduino Uno R3 program that rotates the motor clockwise at 25% speed for 10 second then counterclockwise at 75% speed for 3 seconds. After the 3 seconds the motor should coast to a complete stop (i.e. gradually slow down). Use the sketch provided as a template. [7 points] void setup(){ pinMode(7, OUTPUT); pinMode(8, OUTPUT); pinMode(9, OUTPUT); } void loop(){ digitalWrite(7, HIGH); digitalWrite(8, LOW); analogWrite(9, 26); delay(10000); digitalWrite(7, LOW); digitalWrite(8, HIGH); analogWrite(9, 191); delay(3000); digitalWrite(7, LOW); digitalWrite(8, LOW); analogWrite(9, 0); } L293D Truth Table E A B Function H H L Turn Clockwise H L H Turn Counter Clockwise H L/H L/H Fast stop L either either Slow stop 5 Ω SP1 R1 Pin9 Pin 7 Pin 8 Pin ~9 Arduino A1 B1 E1 DC Motor + -
EGR 2800 Fall 2023 Exam I Page 3 of 6 Problem 2 [16 points] The graph on the right is for a HIH- 4030/31 humidity sensor. The graph depicts the typical output voltage of the sensor given the relative humidity of the environment. a) Provide a linear equation, V(RH), that approximates the output voltage (V) of the sensor as a function of the relative humidity (RH). Please use the variable V for output Voltage and RH for Relative Humidity. [4 points] ? = 3.75𝑉 − 0.75𝑉 100%𝑅𝐻 − 0%𝑅𝐻 = 3𝑉 100%𝑅𝐻 = 0.03 𝑉 %𝑅𝐻 𝑉(𝑅𝐻) = 0.03𝑅𝐻 + 𝑏 0.75 = 0.03(0) + 𝑏 𝑏 = 0.75 𝐴??𝑤𝑒?: 𝑉 = 0.03𝑅𝐻 + 0.75 b) The AD0 pin uses the 10-bit ADC in the Arduino Uno. If the reference voltage we use for the analog input is 3V (i.e. the 10-bit ADC converts analog values from 0-3V). What is the output voltage of the sensor if we receive a return value of 256 when using the analogRead(0) function on pin AD0. [4 points] V = 256 * 3 / 1024 = 0.75V c) Given the voltage value from question b) what is the relative humidity? [4 points] RH = (V 0.75)/0.03 = (0.75 0.75)/0.03 = 0%
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
EGR 2800 Fall 2023 Exam I Page 4 of 6 d) Use the map() function to approximate the relative humidity reading (in %) given the ADC value from a sensor. Assume the ADC value is held in an integer variable name ADC (i.e. int ADC = analogRead(0)) Don’t forget to use the constrain() function to get values between 0-100% relative humidity. [4 points] int humidity = 0; humidity = map(ADC, 0, 1023, 0, 3); humidity = map(humidity, 0.75, 3.75, 0, 100); humidity = constrain(humidity, 0, 100);
EGR 2800 Fall 2023 Exam I Page 5 of 6 Problem 3 [12 points] Answer the following questions. a) Show the TTL-level serial waveform for the Upper- case letter ‘B’ being transmitted at 14400 Baud Rate. Make sure to label your axes with voltages and the duration of each bit. [4 points] R = 0x42 = 0b01000010 b) Write one line of code that sets (i.e., makes 1) the highest four bits of the byte variable A, without affecting any other bits in A. [2 points] A |= 1111 0000 c) Read the following 3 statements (i-iii) and fill in the table to indicate whether the statements are true (T) or false (F). i) Stepper motor brushes will wear out over time due to friction between the rotor and the brushes [2 points] ii) The tone() function only generates square waveforms and not sinusoidal waveforms [2 points] iii) Since our microcontroller's ADC (analog-to-digital converter) has 10 bits of resolution, it can only represent 10 different states. [2 points] i) False ii) True iii) False
EGR 2800 Fall 2023 Exam I Page 6 of 6 Problem 4 [12 points] Answer the questions, considering the program below. 1 int a[10] = {10,9,8,7,6,5,4,3,2,1}; 2 int s = 0; 3 void setup() { 4 Serial.begin(9600); 5 for(int i=5; i<10; i++){ 6 s += a[i]; 7 } 8 Serial.print(s); 9 } 10 11 float do_something(){ 12 return 1 + 1; 13 } 14 15 void loop() { 16 17 } I. What will be the output on the serial monitor after line 8 has been executed? [3 points] 15 II. How would you modify line 5 to obtain the sum of all the indices in array a ? [3 points] for(int i=0; i<10; i++){ III. What is the variable type returned from the do_something() function defined in line 11? [3 points] Float IV. What is the purpose of line 4? [3 points] Setting the baudrate for serial communication
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
EGR 2800 Fall 2023 Exam I Page 7 of 6