EGH456 - Embedded Systems and Laboratory Exercise Assignment

Download Solution Order New Solution

Assignment Task

Preparation Activities

Read the chapters on Multithreading and Shared Resources in the reference book by Lewis. Read Lecture 6, 7 and 8 notes. It will also be a good idea to check out technical documents (Getting Started and User Guides) related to FreeRTOS.

Laboratory Tasks

Task A 

  1. Download the example project queues from the workshop page on canvas and export it to your workspace folder.

  2. Examine the project files and open the c file. Read it to get an understanding of what the program does.

  3. Examine the source Relate to your understanding of queues and tasks.

  4. Now run the Examine the output.

Answer the following questions:

  1. What is a ”queue” object and what does it refer to in this program?

  2. What is stored within each message object passed into the queue for this program?

  3. Which operation is used when a message is placed by the writer?

  4. What blocking period is used in this program when receiving messages via the queue (in ms)?

  5. How could you change the code so that no blocking period is used?

The rest of this laboratory aims to develop a program that shares data between two threads: a sensor sampling task that is controlled by a periodic timer and a sensor filtering / display task to calculate a moving average of the data and display the result on the screen. This task is split across Task B and Task C and described below. The sensor we will use for this task is the OPT3001 light sensor used in laboratory 4. Please use the resources provided in laboratory 4 to complete the following tasks.

Task B 

In Task B, you must create a sensor sampling and filter task. The task should read a sensor sample at a fixed frequency and calculate a moving average of the samples. To implement Task B, the following steps need to be taken:

  1. Create a thread that samples light values at a rate of 10Hz from the OPT3001 Your solution to workshop 4 provides a good starting point for developing this program. We recommend you use a periodic timer to trigger an ISR at the required frequency, which can then signal to the sampling task to take a reading. You must configure the sensor to run at a sufficient conversion time. 

  2. Implement a moving average filter of the light sensor data. The filter should use a window size (number of samples in the average calculation) greater than five samples. The filter should be implemented within the same task as the data reading. For this step show the output of the filtered data by printing the value to the console via. 

Task C

The last task for this lab is to display the filtered and raw data to the screen using grlib. This task should receive data from the sampling / filter task, and responds to user inputs to control the display.

  1. See the instructions in workshop two to add the graphics libarary to a new

  2. Create a queue and a custom message struct to transmit data between the sampling task and the display Be careful where you create the message to put in the queue if you are sending a pointer to the data. 

  3. Create an event object and use this to signal from the sampling task to the display task when data is put into the 

  4. Display the filtered data on the screen simply via drawing text to the Choose a reasonable frequency at which the display is updated. 

  5. Improve the display of the sensor data on the screen by plotting the sample data in a graph over time using drawing functions. See the grlib documentation for example functions that can assist in plotting data to the 

  6. Use a push button to add or remove the raw data from the plot (the filtered data should always be displayed). The event object should be used to check when a button is pressed and new data is 

By using message queues to pass data between threads and events as a signalling mechanism, the program can efficiently manage the flow of information and ensure that the display thread always has the most up-to-date data from the light sensor. The moving average filter ensures that the data is accurate and reliable, reducing the chance of false readings or errors. The use of events as a signalling mechanism allows the threads to synchronise efficiently and ensures that the filtering thread only updates the data when new data is available.

Assessment

Show evidence of having performed the modifications and run the programs as required to the tutor. Answers to questions must also be written down and shown in class. You may work in a group of 2 (or 3 with permission from the tutor if there is a need for it). Each member must be present in the laboratory at the workstation and be participating in the exercise to receive credit.

This EGH456 - IT Computer Science has been solved by our PhD Experts at My Uni Paper.

Get It Done! Today

Country
Applicable Time Zone is AEST [Sydney, NSW] (GMT+11)
+

Every Assignment. Every Solution. Instantly. Deadline Ahead? Grab Your Sample Now.