ELE2303 Assign 1 Page | 1
ELE2303 Embedded Systems Design
Assignment 1 – Gas Monitor Unit Stage 1
Description Marks out of Wtg (%) Due date
Gas Monitor Unit – Stage 1 200 20 28/04/14
Purpose
This assessment is intended to evaluate the student’s capability in selecting and configuring a
microcontroller unit (MCU), designing simple interface hardware and writing subroutines to
operate those interfaces.
Please note – the purpose of studying a ‘design’ course like this, is that you learn how to design
hardware and write programs to solve new problems. This requires you to understand the how
individual parts of the microcontroller function and how to control them with a program. You are
expected to link together pieces of interface circuitry and combine segments of program you
learn about in the course materials, into a structured solution. Do not expect to find a ‘solution’
to this problem on the internet. Expect that you have to create it!
Grading of this assessment
This task will be assessed against the course objectives 1, 2, 3, 4, 6 and 7. This assessment will
be graded (F, C, B, A, HD) using a rubric marking scheme against criteria such as: the
appropriate selection and use of microcomputer hardware; the design of I/O hardware to meet a
specification; implementation of software to meet a specification; quality of documentation
including organisation of ideas and format; spelling, grammar and punctuation. Note - this
course is a communications benchmark course, hence marks will be awarded for the quality of
documentation.
Assignment Requirements
This assessment requires students to meet the requirements the specification below. Select a
suitable microcontroller from the PIC18 family, design simple interface hardware, write
and test some C programs (subroutines) to operate the hardware interface and then document
the hardware and software as a proposed design. Software is to be written in C using the
MPLAB X IDE. You must create an MPLAB X project which may include one or more C
source files. The testing is to be completed using either: the Oshonsoft PIC18 simulator or the
MPLAB X simulator.
There is NO requirement to assemble any hardware, or layout a PCB for this assignment.
The circuit design for the hardware may be drawn using electronics CAD software, OR hand-
drawn and scanned, for inclusion in the documentation. The ‘hardware’ can be successfully
configured and simulated on the Oshonsoft PIC18 simulator or the MPLAB simulator. A few
screen captures of the software under-going testing are to be included in the documentation.
ELE2303 Assign 1 Page | 2
Each student is required to submit:
1. A report in PDF format which includes:
a brief introduction (100 – 150 words) outlining the design requirements based on the
specification.
the hardware design (250 – 300 words) explaining the key elements of the design and
how they meet the specification, plus ...
ELE2303 Assign 1 Page 1 ELE2303 Embedded Systems Design.docx
1. ELE2303 Assign 1 Page | 1
ELE2303 Embedded Systems Design
Assignment 1 – Gas Monitor Unit Stage 1
Description Marks out of Wtg (%) Due date
Gas Monitor Unit – Stage 1 200 20 28/04/14
Purpose
This assessment is intended to evaluate the student’s capability
in selecting and configuring a
microcontroller unit (MCU), designing simple interface
hardware and writing subroutines to
operate those interfaces.
Please note – the purpose of studying a ‘design’ course like
this, is that you learn how to design
hardware and write programs to solve new problems. This
requires you to understand the how
individual parts of the microcontroller function and how to
control them with a program. You are
expected to link together pieces of interface circuitry and
combine segments of program you
2. learn about in the course materials, into a structured solution.
Do not expect to find a ‘solution’
to this problem on the internet. Expect that you have to create
it!
Grading of this assessment
This task will be assessed against the course objectives 1, 2, 3,
4, 6 and 7. This assessment will
be graded (F, C, B, A, HD) using a rubric marking scheme
against criteria such as: the
appropriate selection and use of microcomputer hardware; the
design of I/O hardware to meet a
specification; implementation of software to meet a
specification; quality of documentation
including organisation of ideas and format; spelling, grammar
and punctuation. Note - this
course is a communications benchmark course, hence marks will
be awarded for the quality of
documentation.
Assignment Requirements
This assessment requires students to meet the requirements the
specification below. Select a
suitable microcontroller from the PIC18 family, design simple
interface hardware, write
3. and test some C programs (subroutines) to operate the hardware
interface and then document
the hardware and software as a proposed design. Software is to
be written in C using the
MPLAB X IDE. You must create an MPLAB X project which
may include one or more C
source files. The testing is to be completed using either: the
Oshonsoft PIC18 simulator or the
MPLAB X simulator.
There is NO requirement to assemble any hardware, or layout a
PCB for this assignment.
The circuit design for the hardware may be drawn using
electronics CAD software, OR hand-
drawn and scanned, for inclusion in the documentation. The
‘hardware’ can be successfully
configured and simulated on the Oshonsoft PIC18 simulator or
the MPLAB simulator. A few
screen captures of the software under-going testing are to be
included in the documentation.
ELE2303 Assign 1 Page | 2
Each student is required to submit:
1. A report in PDF format which includes:
4. a brief introduction (100 – 150 words) outlining the design
requirements based on the
specification.
– 300 words) explaining the key
elements of the design and
how they meet the specification, plus include a single page
circuit diagram of the
proposed hardware. You must specify all part numbers and the
values of any discrete
components used (ie. resistors, capacitors, crystals). Show any
calculations you make to
check the scaling and resolution of analog input values.
– 300 words) briefly
explaining each of the
subroutines and how they meet the specification, plus include a
copy of the C source
code showing all the subroutines.
tware (250 – 300
words) explaining what is
working and isn’t working, plus include a few screen captures
of the Oshonsoft or
MPLAB X simulator showing the software under-going testing.
The document should be formatted as a report and must
include:
5. -headings
captions
eader of the
document
document
2. A copy of the program source file(s) as:
(directory) you created for the
assignment
Notes on plagiarism or collusion
This is an individual assessment. Students must write and
submit their own hardware design,
program and documentation. Students may discuss concepts and
methods of implementation
with others, but it is forbidden to share circuits and source code
or copy another student’s
work. Discuss how to do it, but come up with your own work.
6. For this sort of assessment two or more students submitting the
same circuit or program may be
considered as plagiarism or collusion. There are several ways
that each part of a program may be
implemented, so two ‘independently’ written programs are
highly unlikely to be identical.
“Working together on the assignment” should not result in
exactly the same design or program.
Also re-using assignment work from past years is also not
allowable and easy to identify.
Plagiarism is very easy to identify!
Students are also warned that paying someone else to do your
assignment is considered a serious
breach of regulations. This too is very easy to identify!
ELE2303 Assign 1 Page | 3
The System Specification
Outline of the task
You have been requested by your Senior Engineer to design a
7. Gas Monitor Unit (GMU) and
prepare a report detailing your proposed solution. The client
requires a microcontroller based
unit to measure the gas concentration from multiple gas sensors,
compare each gas concentration
against an alarm level and trigger the alarm if any gas
concentration exceeds the alarm level set
by the user. The alarm level is to be entered into the unit via a
set of buttons and a display will be
used to provide output to the user.
Stage 1 of the project (this assignment) requires you to (a)
design the hardware for a PIC18
microcontroller and the input/output circuitry required to
interface the sensors, buttons, display
and any other specified devices to meet the hardware
requirements and (b) write a set of simple
input/output subroutines (in C) only to operate each interface
according to the input/output
requirements.
[ Stage 2 (assignment 2) will require you to write a main
program to operate the fully functional
gas monitoring and alarm system. Some additional hardware
8. may also be required. ]
Hardware Requirements
Microprocessor support circuitry
components necessary to
operate a PIC18 processor at a clock speed of 20MHz.
equired
as the PIC18 includes this.
using a 5Volt power supply.
(Note that the 5V power supply itself is not part of this design
problem.)
Microcontroller Interfacing
e to be connected to the GMU. Each gas
sensor has a single 4 to 20mA
current output which indicates a gas concentration from 0 to
1000 ppm (parts per million).
[ ie. A continuously variable (analog) output from 4mA = 0ppm
to 20mA = 1000ppm ]
A current output of less than 4mA is an indication of a fault on
that sensor.
9. Figure 1. Sensor and resistor termination.
As shown in Figure 1 - the current from each sensor is
terminated into a 250ohm resistor to
convert it into an analog voltage between 1 and 5 Volts. This
analog voltage needs to be
converted to digital value inside the processor to represent a gas
concentration between 0
and 1000 (ppm), with a minimum resolution of 5ppm.
gas
sensor
4 to 20mA
0 to 5 V
+
0
ELE2303 Assign 1 Page | 4
circuitry are to be provided as inputs
from the user to control the software operation and to set the
alarm level. They are to be
10. labelled as: Exit, Up, Down, and Enter
LED indicators of different colours are to be used to
indicate the operational state of the
GMU program as: Run, Enter alarm value or Fault detected.
-segment display is required to display either the
gas concentration of a selected
sensor input or the alarm level during the alarm level setting
process. The display is not to
be multiplexed.
indicate a ‘no alarm’ condition and
switched to inactive (off) when an alarm condition (including
sensor fault) is detected. This
relay will thus provide a fail-safe alarm indication if the GMU
loses power.
-to/out-of the controller must be logically
grouped and connect to the GMU
circuit board via suitably sized connector each with a 0 Volt
(GND) reference signal.
(Note that the type or model of connector is not significant to
the assignment; just show a
connector as a rectangle with a single row of numbered pins.)
11. Input/Output Requirements (8 parts)
The following subroutines must be written:
(Note you are NOT allowed to use any library functions
provided with MPLAB X or XC8.
Write directly to the special function registers controlling the
ports and the ADC.)
Part 1. Write a C subroutine called initports to initialise the
I/O ports you have chosen in your
hardware design for the button inputs, alarm and LED outputs
and the seven segment display.
Part 2. Write a C subroutine called initadc to initialise the
ADC ready to read any sensor input
(as in part 3).
Part 3. Write a C function called sensor which accepts a
parameter ‘s’, starts a conversion on
the analog channel specified by ‘s’, scales that converted value
to the range 0 to 1000ppm and
returns the scaled sensor value as an integer. This function is to
return -1 if a sensor error is
detected.
12. Part 4. Write a C function called buttons to read the status of
all buttons and return an
integer whose value is 0 if no button is pressed, 1 for the Exit
button, 2 for the Up button, 3
for the Down button and 4 for the Enter button. Assume only
one button is active at any
instant.
Part 5. Write a C subroutine called leds that accepts a
parameter ‘n’, where the value ‘n’
(between 0 and 7) is used to control the 3 LED indicators Run,
Enter and Fault. A value of n=4
will turn on the Run LED, n=2 will turn on the Enter LED, n=1
will turn on the Fault LED, n=0
will turn all LEDs off. Assume only one LED is on at any
instant.
Part 6. Write a C subroutine called alarm that accepts a
parameter ‘a’, to control the alarm
relay, where a=1 turns the relay off (triggering the alarm) and
a=0 turns the relay on (no alarm).
13. ELE2303 Assign 1 Page | 5
Part 7. Write a C subroutine called display that accepts a
parameter ‘c’, to display the gas
concentration ‘c’ onto the 4 digit seven segment display. The
display is not multiplexed.
Part 8. Write a main C program calls all the subroutines in
some logical sequence so that their
functions can be tested on a simulator. The main program
should include multiple loops to test
each possible sensor input, each button press, each LED output,
the control of the relay output
and show a range of values on the seven segment display.
End of specification
If you have any questions on the assignment post them to the
assignment discussion forum so a
common answer is available to all students at the same time.