4180T2_F22s

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

4

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. ( 5% ) What protocol is used on the Internet to ensure in order error free delivery of packets? ( answer using the acronym ) _____________ TCP _____________ 2. ( 5% ) What code is used to detect bit errors in an Ethernet packet? ( answer using the acronym ) _____________ CRC _____________ 3. ( 5% ) What protocol is typically used to transfer text data on web pages? ( answer using the acronym ) _____________ HTTP _____________ 4. ( 5% ) What C/C++ function call from the add-on IO library was used to set the LED pin to an output in lab 4 ( name only no arguments ) _____________ gpioSetMode _____________ 5. ( 5% ) What special Linux command line prefix had to be added in the C/C++ compiler's build options since it was required to execute the I/O library code to run the blink LED code in lab 4 on the Pi? _____________ sudo _____________ 6. ( 5% ) What C/C++ function call was used to add-on a time delay for the LED in the lab 4 code ( name only no arguments ) _____________ time_sleep _____________ 7. ( 5% ) Because of this hardware unit in the Pi's processor each process gets it's 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 _____________ 8. ( 5% ) What is the name of the Windows WIN32 C/C++API that provides a fast mutex lock type operation for threads? ( Does lock only, not declaring it or unlocking it ) ___________ EnterCriticalSection _______________ 9. ( 5% ) What is Microsoft's generic name of the small data base tables in memory where Window's stores I/O device names and the filenames of their device drivers along with other information about the OS and machine setup? ( one word, not the path ) ____________ registry ______________ 10. ( 5% ) What is the name of the Window's C++ function that can be used in device drivers to write to an 8-bit I/O port? ( name only don't list arguments or include parenthesis ) ____________ write_port_uchar ______________ 11. ( 5% ) In C#, what method can be used to communicate with mbed over the USB cable? ( name only don't list arguments or include parenthesis ) ____________ SerialPort ________________ 12. ( 5% ) A semaphore initialized to this value functions like a mutex lock, but the code in most implementations is slower. ____________ _1 _______________
13. ( 40% ) 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 60 short lines of additional code, so use two columns and the back of the page if needed. volatile int current_temp = 0; //last temperature reading volatile bool heater_on = false;//turn heater ON/OFF volatile int set_point = 20;//temperature setting Mutex LCD; //LCD mutex lock void Safety(void const *argument){ while(1) { if(tilt_switch) { heater_on = false; heat_relay = false; } Thread::wait(100.0); } } void Display(void const *argument){ while(1) { current_temp = ((LM61*3.3)-0.6)*100.0; LCD.lock(); uLCD.locate(2,3); uLCD.printf("%3.0d",current_temp); LCD.unlock(); Thread::wait(2.0*1000.0); } } void Blue_Remote(void const *argument){ char bnum; char bhit; while(1) { while(!blue.readable()) Thread::yield(); LCD.lock(); if (blue.getc()=='!') { if (blue.getc()=='B') { //button data packet bnum = blue.getc(); //button number bhit = blue.getc(); //1=hit, 0=release switch (bnum) { case '5': //button 5 up arrow if (bhit=='1') set_point++; break; case '6': //button 6 down arrow if (bhit=='1') set_point--; break; case '7': //button 7 left arrow if (bhit=='1') heater_on = !heater_on; break; default: break; } } } } uLCD.locate(2,6); uLCD.printf("%3.0d", set_point); LCD.unlock(); Thread::wait(50.0); } } int main(){ uLCD.text_height(2); uLCD.text_width(2); uLCD.printf(" Heater"); Thread thread2(Safety); Thread thread3(Display); Thread thread4(Blue_Remote); while(1) { if (((current_temp + 1) >= set_point) || !heater_on) heat_relay =0 ; if (((current_temp - 1) <= set_point)&& heater_on) heat_relay = 1; Thread::wait(2.0*1000.0); } }
Name:_________________________________________ Additional Information and Requirements for Problem 13 Using mbed C++ RTOS 2.0 and mbed APIs along with parts from the lab project complete the code for a Bluetooth remote controlled heater. The heater plugs into an AC outlet that also provides power for the mbed’s DC power supply. The arrow keys on the Adafruit Bluetooth phone GUI control the heater. The LCD displays the temperature set point and the current room temperature using double size text. A relay driver circuit controlled by the mbed turns the heating element ON/OFF. When the heater is ON, the thermostat reading is used by software to automatically turn the heater relay ON/OFF as needed to control the temperature. A safety pushbutton on the bottom opens to turn off the heating element, if the heater tips over. Use the starting Template code provided below ( do not copy it over to the solution page !): #include "mbed.h" #include "rtos.h" #include "uLCD_4DGL.h" uLCD_4DGL uLCD(p28,p27,p26); // LCD; AnalogIn LM61(p17); //temperature sensor input Serial blue(p9,p10); //Bluetooth module DigitalIn tilt_switch(p11,PullUp); //Tilt safety cutoff switch DigitalOut heat_relay(p8); //relay that turns heating element on/off (on=1) …JUST ADD WHATEVER mbed API C++ IS NEEDED AFTER THIS - DO NOT COPY IT OVER! Additional requirement s and details on threads: Add the following global variables that are shared between threads. current_temp is an integer with the current temperature, set_point is an integer with the desired automatic temperature control setting with an initial value of 20. heater_on is a Boolean flag that turns the heater on/off with an initial false value. Add synchronization primitives as needed. Safety Thread: The tilt_switch opens if the heater is knocked over. If the heater is tilted, turn off the heater_relay and heater_on . Run this thread no more than 10 times a second. Display Thread: Reads the temperature sensor places the scaled value in current_temp and displays the temperature on col 2, line 3 unsigned 3 digits. From the LM61 sensor datasheet, to convert to temperature, subtract .6 from the sensor’s analog voltage and multiply by 100. Runs no more than once every two seconds. Blue_Remote Thread: This thread yields until there is new data available to read from the serial port. It then processes the GUI button strings as shown in the table below using a case statement. Checksum and button release codes should be ignored. Whenever a new button string is processed, the set_point temperature is displayed in three digits on the LCD on col 2 line 6. This thread should run no more than 20 times a second. Main: Sets up LCD for double size text with default for baudrate and color. Prints “ Heater” on the LCD top line. It then starts the other three threads. Then in an infinite loop, it checks current_temp and set_point to turn the heating element on/off. The heating element should turn off when the current temperature is one degree or more above the set point or the Bluetooth GUI & Chars Action Up Arrow !B51 set_point ++ Down Arrow !B61 set_point -- Left Arrow !B71 Toggle heater_on
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
heater is turned off. When the heater is on, the heating element should turn on when the current temperature is one degree or more below the set point. This thread should run no more than once every two seconds.