Recent Question/Assignment

ELE2303 Embedded Systems Design
Assignment 1 – Lift Controller - Stage 1
Description Marks out of Wtg (%) Due date
Embedded System Design – Stage 1 200 20 23/04/18
Purpose
This assessment is intended to evaluate the student’s capability in configuring a microcontroller, designing simple interface hardware and writing C code to operate those interfaces.
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 checklist 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 MPLABX IDE. You must create a project for your program which may include one or more C source files. The testing is to be completed using the PICSimLab simulator – NO EXCEPTIONS.
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 neatly hand-drawn and scanned, for inclusion in the documentation. The interface for the application can be successfully tested on the PICSimLab simulator. A Zoom recorded demonstration of the software under-going testing must be included with the assignment submission.
Each student is required to submit:
1. A report in Microsoft WORD format (with tracked changes enabled) which includes:
• a brief introduction (150 – 200 words) outlining the design requirements based on the specification.
• the hardware design (300 – 400 words) briefly explaining the circuit design and how it meets the specification. Show any calculations you make to check the scaling and resolution of analog input values.
• a single page circuit diagram of the proposed hardware. This may be A4 or A3 in size.
This diagram may be provided in a separate file (possibly an image file) if it is more convenient. You must specify the electronic components (eg. IC’s) and the values of any discrete components used (ie. resistors, capacitors, crystals). Manufacturer part numbers are not required.
• the software interface routines (600 – 700 words) briefly explaining the subroutines and how they operate and meet the requirements.
• a brief analysis of the testing of the software (200 – 300 words) explaining what is working and isn’t working.
• A Zoom recording showing the compilation in MPLABX and testing of the functionality of the program on the PICSimLab simulator, with commentary by the student.
• copy of the C source code showing all the subroutines. (as an appendix to the report)
The document should be formatted as a report and must include:
• a title page showing the student name and number
• numbered sections with appropriate sub-headings
• grammatically correct English, complete sentences in paragraphs
• clearly drawn diagrams including figure numbers and captions (may be a separate file)
• the assignment name and page number in the header of the document • the student's name and student number in the footer of the document
2. A copy of the project directory (example myproject.X ) saved as a ZIP file. Make sure all the files in the directory are included.
Notes on academic integrity
This is an individual assessment. Students must complete and submit their own work and documentation. Students may discuss concepts and methods of implementation with others, but it is forbidden to share circuits and source code, copy another student’s work or submit work prepared for you by another person. Student may discuss how to solve the problem, but must come up with their own work. Circuits or programs should NOT be copied (ie. scanned or cut and paste) from the internet or other sources.
For this sort of assessment two or more students submitting the same circuit or program may be considered as plagiarism or collusion. There are also 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. Re-using assignment work from past years is also not allowed and easily identified. Students are also warned that paying someone else to do your assignment is considered a serious breach of the academic integrity policy. This too is very easy to identify!
Students suspected of having colluded, copied another’s work (with or without permission) or suspected of having paid a ghost writer to prepare their work will be required to clearly demonstrate they have prepared the work. Submission of the report with tracked changes enabled is intended to help protect the honest student, so failing to follow this instruction will focus attention on your submission. Students must prepare their report in MS Word format with the track changes feature enabled. (If you are unsure how to do this – ASK NOW in the forum)
The Specification
1. Outline of the task
You have been requested by your Senior Engineer to design a PIC18-based controller for a lift design. You are to prepare a hardware design, write C functions or subroutines to interface with the hardware, test those routines on a simulator and prepare a report detailing your proposed solution for the Lift Controller.
The sequence of steps in the lift’s operation are yet to be fully defined by the client, however the lift’s electro-mechanical equipment has been specified. So the first step is to design the MCU and interface circuitry, write and test the low-level code that correctly operates the electro-mechanical devices which will monitor and control the lift. Eg. winch, call and floor buttons, position sensor, and door ajar sensor.
The client has specified a PIC18-based controller is required, as they are familiar with that family of MCU. The controller is to accept input from the buttons and sensors and be able to control the operation of the lift via relays. The hardware interface to the lift equipment is described in Hardware Requirements.
Stage 1 of the project (this assignment) requires you to (a) design the circuit for a PIC18 microcontroller and the input/output hardware required to interface with the electromechanical devices specified in the Hardware Requirements and (b) write and test a set of input/output routines (in C) to operate all interfaces according to Software Requirements.
[ Stage 2 (assignment 2) will require you to write a state-based control program to operate the lift according to requirements. Some additional hardware and/or interface routines may also be required. ]
2. Hardware Requirements
Microprocessor support circuitry
• The circuit diagram for the Lift Controller must include the minimum components necessary to operate a PIC18 processor at a clock speed of 8 MHz.
• A push button reset circuit IS required for the microcontroller.
• Show the power supply connections necessary to power the PIC processor using a 5Volt power supply. (But note that the 5V power supply itself is not required as part of this design problem.)
Electro-mechanical Interface
The lift equipment includes the lift itself, the doors, the winch, a position sensor, a door ajar sensor, 4 call buttons on three floors and 3 in-lift floor select buttons. The detail for the electrical interface to equipment are shown in Figure 1 and is explained below.
The summary of the electrical interfaces required to the lift controller are:
• 2 winch control signals UpDown and RunStop control the lift- Up(1) Down(0), and Run(1) Stop(0).
• A door control signal OpenClose is used to open(1) or close(0) the lift doors.
• An analog position sensor (PS) measures the vertical position of the lift. 0m = 0V to 6.4m = 5V.
• An analog door ajar sensor (AJ) indicates if the doors are ajar ( 0.5V) or properly closed ( 0.5V).
• The 4 call buttons (U1, U2, D2 and D3) allow passengers to call the lift to their floor.
(Up only on floor 1, up and down on floor 2, and down only on floor 3)
• 3 floor select buttons (F1, F2, F3) in the lift allow passengers to select the floor they wish to travel to.
Figure 1: Lift equipment and interface details
The detailed requirements of the electrical interfaces are:
• The winch uses a 240 Volt 50 Hz AC motor, to which electrical power is switched by two 24V relays; such that the UpDown signal controls the direction as Up(1) relay is on, Down(0) relay is off; and the RunStop signal runs the motor as Run(1) relay is on, Stop(0) relay is off. The relays also provide electrical isolation between the LCU and the lift equipment.
Your design must include suitable interface circuitry to drive the coils of the two 24V relays each requiring 100mA switching current in the coil.
(Note that the 24V power supply and the connections from the relay contacts to the winch are not part of this design problem.)
• The door control signal OpenClose used to command the lift doors to open(1) or close(0). It is a digital logic signal which is input to the door control unit directly. No relay is needed or isolation is needed, but the signal must have a 0V reference connection. Note- the operation of the door is not instantaneous, so the state of the door must be monitored by the door ajar sensor.
• The lift position sensor (PS) provides a 0 – 5Volt analog signal indicating the position of the lift over the nominal full scale range of 0.0 to 6.4m.
Your design must be able to determine the position the lift by measuring this signal to a resolution of at least 0.0125 m for a range of positions from 0.0m to 6.375m.
• The door ajar sensor (AJ) provides a 0 – 5Volt analog signal indicating the amount of closure of the lift doors, where the doors are considered ajar when the sensor outputs a voltage 0.5V and properly closed when the sensor outputs a voltage 0.5V.
• The user interface (buttons) for the lift are a set of 7 active-low momentary push button switches – which allow the user to call and control the lift.
o 4 floor call buttons are required labelled U1, D2, U2 and D3.
o 3 control buttons are required labelled L1, L2, L3
A debounce circuit is required on each button input.
3. Software Requirements
The following interface routines must be written.
(Note – you are NOT allowed to use any library functions provided with MPLABX XC8. Your routines must write/read directly to/from the PIC18 special function registers controlling the ports and the ADC.)
Part 1. Write a C subroutine called init_io to initialise all the I/O ports you have chosen for your hardware design, to prepare ALL inputs and outputs ready for operation.
Part 2. Write a C subroutine called init_adc to initialise the ADC ready to read the position sensor and the door ajar sensors (as in part 3 and 4).
Part 3. Write a C function called position which reads the ADC channel connected to the position sensor, calculates and returns the position of the lift in metres as a floating point value.
Part 4. Write a C function called ajar which reads the ADC channel connected to the door ajar sensor and returns an integer value of 1 if the door is ajar and 0 if the door is closed.
Part 5. Write a C function called call to read the status of the 4 call buttons and returns a single byte
(short int) whose value is 0 if no button is pressed, 1 for the U1 button, 2 for the D2 button, 3 for the U2 button or 4 for the D3 button. Assume only one button is active at any instant.
Part 6. Write a C function called floor to read the status of the 3 floor buttons and return a single byte
(short int) whose value is 0 if no buttons is pressed, 1 if the F1 button, 2 for the F2 button, or 3 for the F3 button. Assume only one button is active at any instant.
Part 7. Write a C subroutine called winch that accepts a parameter passed to the routine called w, where w = 0 stops the winch, w = 1 drives the lift up, and w = 2 drives the lift down. This routine must control the output pins of the PIC18 you have chosen to connect to the RunStop and UpDown signals.
Part 8. Write a C subroutine called door that accepts a parameter passed to the routine called d, where d = 1 opens the lift door and d = 0 closes the lift door. This routine must control the output pin of the PIC18 you have chosen to connect to the OpenClose signal.
Part 9. Write a main C program which fully tests the functionality of the interface routines above. (part 1 to 8) The main program must initialise any variables used, initialise the IO ports and the ADC, enter an endless main loop, then inside that loop make a series of calls all the routines specified above in some logical sequence, so that their functions can be tested on the PICsimlab simulator. The functionality tests must verify each sensor input and button press operates correctly and test the controls for the winch and door.
To simplify your testing you should consider aligning your choice of IO ports and ADC channels to match the hardware (buttons, relays and LEDs) provided on the PICsimlab simulator. 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. A marking checklist will be provided very soon so you can see how this work will be assessed.