School of Electrical Engineering and Computer Science
Semester 1, 2025
CSSE2010 / CSSE7201 Assignment 2
Due: 4:00pm Friday May 30th, 2025
Weighting: 20% (100 marks)
Objective
As part of the assessment for this course, you are required to undertake an assignment which will test you against some of the more practical learning objectives ofthe course. The assignment will enable you to demonstrate your understanding of
• C programming
• C programming for the AVR
You are required to modify a program in order to implement additional features. The program is a basic template of an Elevator Emulator (a description is given on page 3).
The AVR ATmega324A microcontroller runs the program and receives input from a number of sources and outputs a display to an LED display board, with additional information being output to a serial terminal and – to be implemented as part of this assignment – a seven segment display and other LEDs.
The version of the Elevator Emulator supplied to you has basic functionality only – it will present a start screen upon launch, respond to button presses or a terminal input ‘s’ to start, then display the emulator. A list of features and their implementation details are provided in “Program Features” . The different features have different levels of difficulty and will be worth different numbers of marks.
Don’t Panic!
You have been provided with approximately 2000 lines of code to start with – many of which are comments. Whilst this code may seem confusing, you don’t need to understand all of it. The code provided does a lot of the hard work for you, e.g., interacting with the serial port and the LED display. To start with, you should read the header (.h) files provided along with Elevator- Emulator.c. You may need to look at the AVR C Library documentation to understand some of the functions used.
Academic Merit, Plagiarism, Collusion and Other Misconduct
You should read and understand the statement on academic merit, plagiarism, collusion and other misconduct contained within the course profile and the document referenced in that course profile. You must not show your code to or share your code with any other student under any circumstances. You must not post your code to public discussion forums or save your code in publicly accessible repositories. You must not look at or copy code from any other student. All submitted files will be subject to electronic plagiarism detection and misconduct proceedings will be instituted against students where plagiarism or collusion is suspected. The electronic plagiarism detection can detect similarities in code structure even if comments, variable names, formatting etc. are modified. If you copy code, you will be caught.
Grading Note
As described in the course profile, if you do not score at least 10% on this assignment (before any penalty) then your course grade will be capped at a 3 (i.e. you will fail the course). If you do not obtain at least 50% on this assignment (before any penalty), then your course grade will be capped at a 5. Your Assignment 2 mark (after any penalty) will count 20% towards your final course grade.
Program Description
The program you have been provided with has several C files which contain groups of related functions. The files provided are described below. The corresponding .h files (except for Elevator- Emulator.c) list the functions that are intended to be accessible from other files. You may modify any of the provided files. You must submit ALL files used to build your assignment, even if you have not modified some provided files. Many files make assumptions about which AVR ports are used to connect to various IO devices. You are encouraged not to change these.
• Elevator-Emulator.c – this is the main file that contains the event loop and examples of how time-based events are implemented. Here also, you will find the implementation of the elevator and the floors, as well as code that handles the movement of the elevator. You should read and understand this file.
• display.h/display.c – this file contains the implementation for displaying the current state of the board. This file contains useful functions for changing the state of the LED matrix.
• buttons.h/buttons.c – this contains the code which deals with the IO board push buttons. It sets up pin change interrupts on those pins and records rising edges (buttons being pushed).
• ledmatrix.h/ledmatrix.c – this contains functions which give easier access to the services provided by the LED matrix. It makes use of the SPI routines implemented in spi.c.
• pixel-colour.h – this file contains definitions of some useful colours.
• serialio.h/serialio.c – this file is responsible for handling serial input and output using interrupts. It also maps the C standard IO routines (e.g. printf () and fgetc ()) to use the serial interface so you are able to use printf() etc for debugging purposes if you wish. You must include serialio.h in the relevant file for the functions to work. You should not need to look in serialio.c, but you may be interested in how it works and the buffer sizes used for input and output (and what happens when the buffers fill up).
• spi.h/spi.c – this file encapsulates all SPI communication that is used to communicate with the LED Matrix.
• terminalio.h/terminalio.c – this encapsulates the sending of various escape sequences which enable some control over terminal appearance and text placement – you can call these functions (declared in terminalio.h) instead of remembering various escape sequences. Additional information about terminal IO will be provided on the course Blackboard site.
• timer0.h/timer0.c – sets up a timer that is used to generate an interrupt every millisecond and update a global time value.
Elevator Emulator Description
This assignment involves creating an elevator emulator. The LED Matrix shows four floors in green (referred to as floors 0 through 3) and a 2x3 red LED grid which represents the elevator, on the left-hand side. Note that the X and Y coordinate system used (seen in Figure 1) does not correspond with the X and Y coordinates labelled on the LED Matrix PCB.
Figure 1: Initial layout of elevator emulator (note that pixel positions are referenced from the bottom left)
Travellers appear on each floor and the elevator moves to their floor, picks them up and takes them to their destination floor. The elevator moves up and down and, for the sake of algorithmic simplicity, is only capable of moving one traveller at a time. Each traveller can be one of four colours, with each different colour corresponding to a different destination floor.
In the following example (Figure 2) a light red passenger appears on floor 1. Light red indicates the traveller’s destination is floor 0. The elevator moves to their floor, picks them up and then moves down to the destination. Note that there is a fixed amount of time (defined in code) between each of the frames shown.
Figure 2: Example, moving a traveller from floor 1 to floor 0