Reference no: EM133140567
ENGT 5203 Microprocessor Applications
Case Study - Operation of Water Distribution System
A typical water distribution system is illustrated in Figure 2. Water from a source, reservoir or water treatment plant, is pumped into a tank located at certain elevation to provide a sufficient head (water pressure). From the tank water by means of gravitation is delivered to households meeting their demand. The operation of the pump is governed by the water level in a tank and the varying water demand of a supplied area. The objective is to meet the water demand at any time of day while keeping the tank water level within the operational constraints (between min. and max. level).
Operation of the water distribution system:
a) Automatic and manual control
The system must be able to operate in two modes: manual and automatic. The mode is to be selected by an operator once system has started. The choice must be displayed on the LCD screen. Use the Keypad to enter the mode choice. Hint: You may consider to use switch or if - else if - else statement.
In the manual mode:
• Set tank initial level at 70% of its capacity by default.
• Use Start and Stop buttons to control the system operation. The pump cannot be operated if the system is off (more details on Start and Stop buttons are given below).
• In this mode the pump must controlled manually by using the Potentiometer. Make sure you create an appropriate mapping so the full turn of the Potentiometer knob represents the full speed of the pump (max. allowed rpms) while the initial knob position corresponds to the min. allowed rpm. Hint: You may use map()function or linear approximation of the pump characteristics in Figure 3.
• In the manual mode the operator must keep tank level within the operational constraints by adjusting the pump speed over the 24 hours horizon. Try to achieve 70% tank capacity at the end of the day.
In the automatic mode:
• Tank initial level is determined by an operator. Use the Keypad to interact with the system operator. The accepted initial level must be between 10% and 85% of the tank's capacity.
• Use Start and Stop buttons to control the system operation. The pump cannot be operated if the system is off.
• In the automatic mode the tank water level must be kept within the operational constraints by automatically adjusting the pump speed over the 24 hours horizon. This can be done by using a bang-bang controller, a pre-defined speed schedule or other technique of your choice.
b) Operation sequence
In both modes the operation must follow the procedure:
1) Mode selection (as described above)
2) Initialisation stage
During the initialisation stage all necessary variables and settings must be initialised. A relevant message must be display to a user on the LCD screen, e.g., "Initialisation". Once initialisation is completed the LCD should display "System Ready". You may consider adding a small delay so messages will stay visible for a short period of time.
3) Start/Stop system operation
Start and Stop buttons must be implemented to control operation of the system. For this purpose, use switches S1 and S2 on ATMega328P Microcontroller Development Board. When Start button (S1) is pressed the system should start operation after delay of 10 seconds. The countdown should be displayed on the 7-Segment Display. After pressing the Stop button (S2) the system should shut down after 10 seconds countdown also displayed on the 7-Segment Display. Once the shutdown is completed the system should return to Mode selection phase (1). Note the system must not shutdown if the pump is operating.
If the system is operating green LED (D7) must be on. If the system is off the red LED (D5) must be on.
4) In both modes the LCD screen must display data in the format shown in Figure 6.
where:
• M/A - represent the mode M-manual, A-automatic
• tt - is the current timer interval in hours, e.g., 02 or 14
• cc - represents tank's current volume with respect to its capacity in %
• yyy - represents the current pump speed in rpms
• zz - represents the current demand in l/s
5) Once the operation is finished the system should automatically stop in the same manner as pressing the Stop button and return to the Mode selection phase (1).
4. Task 1 - Specification Requirements
The specification requirements are developed by understanding the given task. The purpose is to create a detailed description of what the application must do.
Your task is to define the specification requirements for the given case study of water distribution systems. This should include the statement of the problem, input and output data, necessary functions, constraints and hardware requirements. You should also map I/O ports and devices on the ATmega328P Microcontroller Development board to the corresponding components of the water distribution system and when needed defining their names, aliases, or operational range.
5. Task 2 - Algorithm
An algorithm is a procedure for solving a problem. Your task is to design algorithm to control the water distribution system operation as specified in Section 3. To model the algorithm, adopt flowcharts, a widely-used tool to depict algorithms. When creating flowcharts, it is important to use correct shapes (check Lecture 3 slides for details). Also, it is recommended to adopt the same terminology as in the specification requirements document.
6. Task 3 - Implementation
To implement your algorithm, you must employ:
• ATmega328P Development board and Arduino IDE (in QB 1.01 and QB 2.01)
• DMU DevBoard API
To use DevBoard API download the two files devboard.h and devboard.cpp and store these in the folder where you created your new Arduino sketch. In your sketch, you will need to include the devboard library, i.e. #include "devboard.h"
Hint: You may wish to revisit exercises for the laboratory sessions you have carried out so far to find partial solutions to this implementation.
For debugging you must employ serial communication to display operation status of pump, tank, time etc. The format of displayed information is left to you. The example below will not cover the details of serial transmission, but will give a brief introduction to using the Arduino Serial library for debugging.
Consider the following sketch:
void setup()
{
int value;
// Set-up Serial port to run at 115200 Baud Serial.begin(115200);
// Assign a number to 'value' value = -12345;
// Send the contents of 'value' to the serial port Serial.print("The variable value is: "); Serial.println(value);
Serial.println("Done!");
}
void loop()
{
// put your main code here, to run repeatedly:
}
Breaking this down, the line:-
Serial.begin(115200);
initializes the serial port to run at 115200 Baud (bits/second). This is a commonly-used Baud rate. Another commonly-used Baud rate is 9600 Baud, but it is significantly slower. The line:-
value = -12345;
simply sets the variable 'value' to -12345. The line:-
Serial.print("The variable value is: ");
writes a text string to the serial port. The line:- Serial.println(value);
writes the contents of 'value' to the serial port. The difference between Serial.print() and Serial.println() is that the latter appends a carriage-return and a newline to the serial output.
To use the Serial Port for debugging, the Arduino Serial Monitor should be used. In the Arduino IDE, select "Tools" then "Serial Monitor" to invoke the Serial Monitor Interface. At the bottom of the Serial Monitor interface, there is a pull-down menu for setting the Baud rate. This needs to be set to "115200 baud" for this example.
7. Task 4 - Testing
Testing is an especially important part of any project and it should be fully documented. Your task is to devise a test plan for this application. Each test plan must contain: test purpose, input data, expected output and actual outcome.
Once the test plan is prepared you must conduct the tests and record outcomes. This must be well documented and included in your report.
8. Assessment
Your work will be marked using summative and formative assessment. The below are the requirements for the assessment along with the marks' allocation.
• Report (summative)
You must submit a report documenting your work for each task. Beside description of each task your report must also include introduction and conclusion sections.
In overall, the report marks will be allocated as follows:
1. Introduction
An introduction briefly describing the overall process of development and the concepts used in the specific tasks.
2. Task Specification Requirements
This section must include well-presented requirements describing all necessary functions, input/output data, used devices and their operational range.
3. Task Algorithm
This section must include the designed algorithm using flowcharts depicting the complete operation of the case study. When necessary, comment the flowchart to provide more details.
4. Task Implementation
This section must present the major parts of your code describing how particular function was implemented. The quality and style of the coding will be assessed so your whole code must be included in an appendix. Implementation of the debugging feature will also be marked.
5. Task Testing
This section must include your designed test plan along with explanation how it was designed. Also include here a record of the tests you have carried out using your designed test plan. Comment on how well all aspects of applications were tested.
6. Conclusions
Overall conclusions from all the tasks.
• Demonstration (formative)
During the laboratory sessions 4-6 you must demonstrate your fully working application to the module instructor.
Attachment:- Microprocessor Applications.rar