Starting from:
$30

$24

Assignment 4 Solution

Important Notes




This assignment only contains 1 question, and the total score is 60. It must be done separately. Submit the "*asm" source le, and submit a video (about 30 seconds long) for demonstration.




Prior to submitting your assignment, you should familiarize yourself with the University Policy on Academic Integrity. We will use a plagiarism detection tool on all assignment submissions.







Question




Sensing the environment is an important part of IoT (Internet of Thing). In the "never-stopped-coming" information era, it is highly expected that there would be millions and trillions of sensing devices distributed ubiquitously to sense the world.




Microcontrollers, like the AVR series, will play important role in developing em-bedded sensing devices. They can be equipped with di erent sensors, collecting sensory data and reporting to data centers via wired/wireless communication (mainly through Internet).




For ATmega2560, a very simple application in this area is to connect it to a temp-humidity sensor which senses temperature and humidity at the same time. In this assignment, since we don’t have such a sensor, we’ll try to generate some random numbers to simulate the sensor signals, and use them to control the LED Strip (making it look like a sensor), and to display the value on the LCD screen as a temperature reading or a humidity reading. The two display modes are switched by long pressing the SELECT button (for more than 1 second) on the LCD shield.










1















The LCD display would be like that in the following table. The rst line is for showing the temperature reading (for Temperature Display Mode) or humidity reading (for Humidity Display Mode). The second line is for your V-number with the last 4 digits. For showing humidity, we convert the random signal generated to unsigned value (in range 0 to 63). For showing temperature, we convert the random signal to signed value by following a 6-bit signed magnitude encoding scheme (same to Question 4 in Assignment 2, but takes the 5-th bit as the sign bit). Be aware, as shown in the last two lines, there are two di erent representations for 0 in signed magnitude.






































































The idea for the code is as follows: (1) capture the ADC Conversion Com-plete interrupt; (2) use Compare Match B unit of Timer/Counter 1 to trigger ADC conversion in an interval of approximately 1 second (suppose the clock frequency as 32 MHz); (3) in the Interrupt Service Routine (ISR) of ADC Con-version Complete, switch display mode if necessary, generate the next random number, and update LCD screen and LED Strip accordingly.




Reuse your code in Assignment 1 to 3, write the program and submit the it with the name "virtual sensing VNum.asm" where "VNum" stands for your V-number. Also submit a short video (about 30 seconds) for demonstration.





































2

More products