## Description

Important Note: You are not allowed to use look-up tables in this lab. Having a look-up table or any kind of embedded data in your code will immediately give you a grade of 0.

In both parts of this assignment, you are going to calculate some statistics of a dataset. You will first create a dataset [xi] of 16 elements, where 0 < xi < 8192 for every i ∈ 1,2,… 16. You need to store each element by using ‘#’ button and track the size of the dataset. That is, you should push ‘#’ in keypad to store an element before entering the next. Also, you need to display the current size of the dataset in the bottom right corner of the LCD display. After you finish entering data, you need to be able to press ‘A’ to run Part A, and ‘B’ to run Part B. For example:

Pressing 24 → # → 4424 → # → 595 → # → A in the keypad will generate the set

{24,4424,595} and simulates Part A. Do not forget to continuously display the current size of the dataset at the bottom right corner of the LCD display.

Part A – Median Calculator (40 pts)

In this part, you are going to implement a median calculator after the key ‘A’ is pressed. In order to calculate the median, you need to store the dataset X = {x1,x2,…,xn} first. Assume that X˜ = {x(1),x(2),…,x(n)} is the sorted dataset where x(i) represents the ith smallest value.

After the sorting operation, you will calculate the median y as:

( x((n+1)/2), if n is odd

=

, if n is even

Example: Given X = {24,4424,595,1327,888,4}, the sorted dataset X˜ becomes X˜ = {4,24,595,888,1327,4424} and the median is calculated as

(595+888)/2 = 741.5 and the LCD display needs to show ‘741.50 with the floating point (if the median is an integer, print 0 as the decimal, e.g. 741.0).

Part B – Mean Absolute Deviation Calculator (60 pts)

In this part, you are going to design a calculator to find the mean and mean absolute deviation of the dataset after the key ‘B’ is pressed. In order to find the mean absolute deviation, you first need to calculate the sample mean, which can be calculated as follows:

You are going to display the mean of the dataset on the second line of the LCD, left justified. For the previous example, the sample mean is found as: ¯

1

595 + 1327 + 888 + 4) = 1210.33 (in this part, you can round the floating points and use and display the sample mean as 1210).

Once you find the sample mean, the mean absolute deviation will be calculated as:

For the given example, ¯ ) = 1110, and you need to display ‘1110.00 (you need to show one floating point) on the second line of the LCD, right justified.

Notes

Check what each subroutine of ‘keypad.asm’ and ‘lcd.asm’ (they are on Moodle) does and use the ones that you need in order to satisfy display requirements.

Proteus demos and previously coded chips will not be accepted. However, you can use Proteus to check whether you have a hardware or software-related issue.

Demo schedule will be announced later. You can lose points if you arrive late to the demo, so do not be late.

If you have any valid excuse to not to attend the demo, please let us know beforehand so that we can rearrange the time

2

## Reviews

There are no reviews yet.