4180T2F23s

docx

School

Georgia Institute Of Technology *

*We aren’t endorsed by this school

Course

4180

Subject

Electrical Engineering

Date

Apr 3, 2024

Type

docx

Pages

3

Uploaded by BailiffMantisMaster1210

Report
Score: _____________ Name:___________________________________________ EE 4180 Test II Test is open book and notes. No electronic devices. Place all answers in the spaces provided. 1. ( 4% ) What code is used to detect bit errors in an Ethernet packet? ( answer using the acronym ) _______________ CRC ______________________ 2. ( 4% ) What protocol is typically used to transfer text data on web pages? ( answer using the acronym) ________________ HTTP _____________________ 3. ( 4% ) What address is needed on the Internet to route packets through the network to the destination? ( answer using the acronym ) _____ _IP (MAC not used to “route packets through the Internet” to the subnet) _____ 4. ( 4% ) How many Analog I/O pins are available on the Pi Zero W's I/O header connector? __________________ 0 ___________________ 5. ( 4% ) Because of this hardware unit in the Pi's processor each process gets its own memory address space, but it also prevents a user program from directly accessing the Pi's I/O hardware registers. ( answer using the acronym ) __________________ MMU ___________________ 6. ( 4% ) What is actually running inside each Node Red block that defines how it functions? _________________ Java script ____________________ 7. ( 4% ) If you use both hardware PWM pins on the Pi what other common standard I/O interface cannot be used? ( answer using the acronym ) ____ was SPI as mentioned in lecture, but PCM and I2S digital audio now in newest version of PIGPIO ____ 8. ( 4% ) What C/C++ function call from the add-on I/O library was used to set the LED pin function to an output in lab 4 ( name only no arguments ) _____________________ gpioSetMode ________________ 9. ( 4% ) What is Microsoft's name for C#'s equivalent of JVM, Java's virtual machine? ___________________ .Net Framework __________________ 10. ( 4% ) Which X86 assembly language instruction must be used to write data to an I/O port? ( name only don't list arguments ) ____________________ out _________________ 11. ( 4% ) What is the name of the built-in C# method that is used to setup and communicate using the PC's serial interface. ( name only don't list arguments ) _____________________ SerialPort ________________ 12. ( 4% ) In Windows using C/C++ in VS, what "filename" C-style Unicode string would be used to open the USB virtual com port to an mbed that was using "COM32" (just the Unicode string part needed inside the API argument) ________ _T(“////.//COM32”) (_T converts ASCII string to Unicode string) ____________ 13. ( 4% ) In Win32 C/C++ APIs, what is the name of the function used to setup and start threads? ( name only don't list arguments or include parenthesis ) ____________________ CreateThread _________________ 14. (4%) What is the duration of the time-slice interrupt that interrupts long-running compute bound threads in the mbed RTOS scheduler? _____________________ 1 ms ________________ 15. ( 4% ) A semaphore initialized to this value functions like a mutex lock, but the code in most implementations is slower. _______________________ 1_ _____________
16. ( 40% ) In the space below, write the remaining mbed C++ API and RTOS 2.0 code needed after the initial template code provided to complete the embedded device as described on the last page of the test. The solution requires around 50 short lines of additional code, so use two columns and the back of the page if needed. Do not waste time and space copying the code provided over to this page. volatile bool alarm = 0; //flag for alarm enabled or disabled. volatile int alarm_setting = 511;//air quality setting for alarm volatile int airq_value = 0;//current air quality value from sensor Mutex LCD; // Callback routine is interrupt activated void pbhit (void) { alarm=!alarm; led=!led; } void Read_AirQ(void const *argument){ char cmd[2]; while(1) { cmd[0]= 0x26; airqsensor.write(0x59,cmd,1); airqsensor.read(0x59,cmd,2); airq_value = cmd[0]<<1 | (cmd[1] & 0x01); LCD.lock(); uLCD.color(BLUE); uLCD.locate(3,3); uLCD.printf("%3.0D",airq_value); LCD.unlock(); Thread::wait(5.0*1000.0); } } void Read_Pot(void const *argument){ int Old_Alarm_value = 0; while(1) { alarm_setting = pot * 511; if (Old_Alarm_value != alarm_setting) { Old_Alarm_value = alarm_setting; LCD.lock(); uLCD.color(RED); uLCD.locate(3,5); uLCD.printf("%3.0D", alarm_setting); LCD.unlock(); } Thread::wait(100); } } int main(){ pb.mode(PullUp); pb.attach_deasserted(&pbhit); pb.setSampleFrequency(); speaker.period(1.0/850.0); uLCD.printf("\n Air Quality"); uLCD.text_height(2); uLCD.text_width(2); uLCD.color(RED); Thread thread2(Read_AirQ); Thread thread3(Read_Pot); while(1) { if (alarm && (airq_value >= alarm_setting)) speaker = 0.5; else speaker = 0.0; Thread::wait(1.0*1000.0); } }
Name:___________________________________________ Additional Information for Problem 16 A commercial air quality sensor is shown to the right. Complete the mbed RTOS 2.0 C+ + API code for a prototype of an air quality sensor and alarm using parts from the lab along with a new sensor. A gas sensor that can detect a wide range of Volatile Organic Compounds (VOCs) and H2 is used. The I2C gas sensor measures air quality and returns an integer value ranging from 0 to 511. The LCD displays the current reading from the sensor along with an alarm value set by a pot on the LCD. A pushbutton interrupt callback toggles the alarm mode and LED1 on/off. When the alarm is enabled, and the sensor value exceeds the alarm setting, the speaker outputs an 850 Hz square wave at maximum volume. Starting Template code is provided at the bottom of the page for the basic I/O setup – do not copy it over to your solution page! Additional Software Requirements An LCD screen image from prototype device is shown on the right. Add and use three global variables that are shared between threads: Alarm - a Boolean flag that enables/disables the alarm function. Alarm_value - the scaled value (0..511) of the alarm setting from the pot AirQ_value - the last value read from the gas sensor. The pushbutton uses a debounced interrupt callback to enable/disable Alarm mode and the led . No external pullup is attached to the pushbutton. The led is on only when the alarm feature is enabled. A thread running the function, Read_AirQ, reads the I2C sensor and outputs the air quality value in blue to the LCD line 3 position 3. The I2C sensor is at I2C address 0x59 and reading two bytes in one I2C cycle from register 0x26 returns the 9- bit integer air quality value. The high 8-bits come from the first byte and the low-bit comes from the low-bit of the second byte. The additional bits in the second byte need to be discarded since these bits are undefined. Store the scaled value in AirQ_value . This thread runs not more than once every five seconds. A thread running the function, Read_Pot, reads the potentiometer, scales it to range from 0..511 and stores the value in Alarm_value and outputs the value in red to the LCD line 5 position 3 only when the value has changed. Use a local variable Old_Alarm_value to save the previous value that is used to skip LCD updates when they are not needed. This thread runs not more than once every 100 ms. Main first initializes any additional hardware settings needed, prints “ Air Quality” on the second line of the LCD, sets up the LCD for double size text, and starts the other threads. Then in an infinite loop it checks for the alarm condition (i.e., Alarm enabled and AirQ_value exceeds Alarm_value ) and then sends the appropriate maximum volume output to the speaker to produce a 850 Hz alarm tone or turn off the speaker . The alarm check loop runs not more than once a second. #include "mbed.h" #include "rtos.h" #include "uLCD_4DGL.h" #include "PinDetect.h" uLCD_4DGL uLCD(p28,p27,p29); // serial tx, serial rx, reset pin; AnalogIn pot(p17); //potentiometer input sets alarm_value I2C airqsensor(p9,p10); //Air Quality sensor with range 0..511 DigitalOut led(LED1); //led indicates alarm on/off PwmOut speaker(p21); //850 Hz alarm tone PinDetect pb(p8); //pushbutton to enable/disable alarm mode //…………… add the additional code as needed here to complete the program ……
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