Total Marks: 50 (9% weightage for CS4222/CS5422)
This is an INDIVIDUAL assignment.
Important: We will check for code similarity and potential cases of plagiarism
Important: Please do not use ChatGPT to write code for this assignment. We will particularly check for ChatGPT plagiarism.
In this assignment, you will learn how to use sensors, actuators and schedule events using timers in the Contiki OS. In addition, this assignment will familiarize you with using sensors and actuators. Essentially, you will sense different physical phenomena, conduct some processing, and correspondingly activate actuators.
Executions in Contiki is event-driven and use of timers are common. The Contiki system provides a set of timer libraries. In this assignment, you will look at using the etimer and rtimer. A timer uses the data structure struct timer. Three function calls are used to control a timer.
One difference between etimer and rtimer is the time resolution. etimer’s clock resolution depends on the number of clock ticks per second (CLOCK_SECOND), while rtimer uses RTIMER_SECOND.
Another difference is that programming style. Etimer uses a more “sequential” model while rtimer uses callback.
Sample code for etimer:
Sample code for rtimer:
You can read more about timers on the following link.
We are providing you three sample programs that can provide you with hints to conduct this assignment.
Run the C programs and observe the output generated by the printf statements. Your Makefile should include names of all the new programs.
From the output of etimer-buzzer.c, note down the value of CLOCK_SECOND. Find out how many clock ticks corresponds to 1s in real time. From the output of rtimer-lightSensor.c. note down the value of RTIMER_SECOND. Find out how many clock ticks corresponds to 1s in real time.
Write the program to implement the state transition diagram given below.
The program starts in the IDLE mode. On detecting “significant motion”, it moves into the ACTIVE mode. There are two states in the ACTIVE mode, BUZZ! and WAIT. In the BUZZ! state, the sensorTag uses the buzzer to generate a sound. In the WAIT state, the sensorTag does not generate any sound. When entering the ACTIVE mode from the IDLE mode, the system goes into the BUZZ! state and generate the sound for 3 seconds. After 3 seconds, it goes into the WAIT state (buzzer off) and remains in the WAIT state for 3 seconds before going back to the BUZZ! state. Thus, state transitioning from BUZZ! to WAIT or vice versa occurs every 3 seconds. While in the ACTIVE mode (system can be in either BUZZ! or WAIT state), the system moves to the IDLE state when it detects a significant change in light reading.
Submission instructions: Please submit a single zip file (“CS4222-Assignment2 - YourStudentNumber.zip” or “CS5422-Assignment2 - YourStudentNumber.zip”) to folder “Assignment2 Submission” on Canvas by the due date. If you submit multiple times, only the latest submission will be evaluated.
Your submission should include the following:
Grading/demonstrate should be completed by 10th March 2023.
Late penalty is 10% per day after 10th March 2023.