The aim of the project is to develop a real-time system to simulate a water tank monitoring system. The system includes several sensors and valves to control the water level, temperature, and pressure inside the tank. The system should indicate when the water level reaches a certain sensor and prevent overflow. The water temperature should be kept within a certain range, and the pressure inside the tank should not exceed the normal operating pressure. If the critical pressure is reached, the water drain must be opened to provide pressure relief.
The project requirements include the use of VxWorks and the C programming language. The system uses at least three VxWorks concurrently running tasks, two VxWorks semaphores for synchronization, one VxWorks message queue for communication, and at least one VxWorks watchdog for timeout and/or periodic operation. Time-stamping is used to identify the time of events, and system events and actions must be captured, recorded, and displayed.
The following requirements were developed:
1. The system shall include two inlet valves and one outlet valve.
2. Water shall start entering the tank if any of the two inlet valves are open.
3. If both inlet valves are open, the water level shall rise much quicker than if only one inlet valve was open.
4. The outlet valve shall decrease the water level when opened.
5. The system shall have four water level sensors in the tank.
6. The program shall indicate when water reaches a certain sensor while the inlet valves are open and the tank is being filled up.
7. If the water level reaches the highest sensor, the outlet valve shall open to prevent overflow.
8. The water level shall be kept moving between the highest and lowest water level sensors.
9. The system shall include temperature sensors.
10. The water temperature shall be kept between the maximum and minimum temperature sensor values.
11. The water heater shall turn on if the temperature is too low.
12. The water heater shall turn off if the temperature is too high.
13. The system shall include a pressure sensor.
14. The pressure inside the tank shall not exceed normal operating pressure.
15. The pressure shall start building up if the water level surpasses the second to the highest water level sensor.
16. The pressure shall build up quickly if the water temperature is kept close to 100 ℃.
17. If the system reaches the critical pressure of 50 psi (344 kPa), the water drain shall be open to provide pressure relief.
18. The system shall allow the user to move the sensors (both water level and temperature) up and down, i.e. changing their max and min values.
19. The system shall use at least three VxWorks concurrently running tasks.
20. The system shall use at least two VxWorks semaphores for synchronization.
21. The system shall use at least one VxWorks message queue for communication.
22. The system shall use at least one VxWorks watchdog for timeout and/or periodic operation.
23. The system shall use time-stamping for identifying time of events (using both ticks and sec/nsec).
24. The system shall capture/record/display the system events and actions.
The timing requirements for the project implementation are as follows. It is important to note that the simulation incorporates time delays to provide the appearance of a water tank occurring in real-time, rather than in fast time due to how quickly a processor operates. Therefore, the requirements below simulate possible timing requirements for a real water tank with a volume of approximately 50 liters.
1. The outlet valve shall open within 2 seconds upon high pressure sensor readings.
2. The inlet valves shall open within 2 seconds upon low water level sensor readings.
3. The outlet valve shall close within 1 second of a pressure sensor reading below 20 PSI.
4. The inlet valves shall close within 1 second of a pressure sensor reading above 30 PSI.
5. The water temperature shall reach 50 degrees within 60 seconds when the temperature is at or below 10 degrees Celsius.
6. The water temperature shall reach 50 degrees within 60 seconds when the temperature is at or above 90 degrees Celsius.
During the first stage of the project, the analysis phase, a class model was created to aid in understanding the problem domain. Specifically, the various components of the system were included and relationships between each component was identified.
Importantly, seven classes were identified: Water Level Sensors, Temperature Sensor, Pressure Sensor, Input Valves, Water Heater, Output Valve, and Water Tank.
The Water Tank represents an aggregation of the other six components, as it contains instances of each. This analysis model went on to later inspire the product design, which utilizes similar components in the tasks, functions, and classes of the implementation.
Additionally, this model allowed the team to identify important dependencies. Specifically, the output valve depends on the readings of the water level sensors to know when to open or close. Similarly, the input valve must also receive water level sensor readings to know when to open or close. The pressure sensor depends on both the water level sensors and the temperature sensor, and the water heater depends on the temperature sensor readings to know when to turn on or off.
High Level Class Model
Data flows into the system from the sources (water level, pressure, and temperature sensors) to the sinks (water heater and water valves), which change the status of the tank. The data flow diagrams attached demonstrate this flow of data between the various sources and sinks.
The system consists of several tasks that run concurrently and communicate with each other using semaphores and message queues. The waterIN task pumps water into the tank at a specified flow rate and volume, while the waterOUT task drains water from the tank. The waterLevelSensor task monitors the water level in the tank using sensors and adjusts the water flow rate accordingly. The tempSensor task monitors the temperature of the water in the tank and sends messages to the waterHeater and waterCooler tasks to adjust the temperature as needed. The pressSensor task monitors the pressure in the tank and sends messages to the waterLevelSensor and waterOUT tasks to adjust the water flow rate and volume as needed.
This project contains seven concurrently executing tasks: waterIN, waterLevelSensor, waterOUT, tempSensor, waterHeater, waterCooler, and pressSensor. These contain similar names to the source files they are associated with, which contain the functions attached to each. These seven tasks execute concurrently–-not in parallel. They are scheduled to the CPU in turns. Therefore, at any given instant, only one task is executing, while the others are queued to execute shortly. Knowing that the functions execute concurrently forced the team to consider safety decisions, such as implementing a restart function in the pressure sensor in case a pressure sensor reading is missed due to the execution of another task.
Four semaphores are consistently used throughout the implementation of the project: semBinWaterIN, semBinWaterOUT, semBinWaterTEMP, and semBinWaterTEMPC. All four semaphores are binary semaphores and are used to ensure task synchronization. Specifically, the semaphores are used to ensure that specific task threads do not execute concurrently, such as the water inlet and outlet both being open at the same time.
Six message queues were used consistently throughout the program: msgQWaterIN, msgQWaterOUT, msgQWaterVol, msgQWaterTemp, msgQWaterTempPRESS, msgQWaterVolPRESS. These six message queues were used to pass important data between the multiple functions within the project.
A watchdog is used by the pressSensor task to ensure that a valid reading is read by the sensor within one second. If the pressure sensor does not receive a value within this allotted time, the watchdog will restart the pressure sensor. Therefore, the watchdog timeout corresponds to a missed reading of the pressure sensor, which may affect the safety of the tank if the tank is close to critical pressure during that time.
Similarly to the watchdog, a signal is used by the pressSensor task to ensure that the water tank responds accordingly to the emergency event of the water tank reaching critical pressure. Specifically, if the critical pressure is hit and read by the pressure sensor, the pressSensor task will generate a signal that prints a message to the user that the critical pressure has been reached and stops the flow of water into the tank, instead allowing the outlet valves to open. Importantly, the signal is only generated during this emergency situation, and would ideally never be generated during nominal operations.
Importantly, the maximum and minimum volume attainable is chosen by the user when they select the levels of the pressure sensor. The highest pressure sensor represents the maximum nominal value of the water tank, and the lowest pressure sensor represents the minimum nominal value of the water tank. While volumes outside of these values are possible, they represent non-nominal situations where there is either not enough water in the tank, or too much water in the tank. The highest possible volume inside of the tank is 50 liters, and the lowest possible value of the tank is 0 liters. These are generally considered the extreme states of the tank.
The water volume in the tank increases by two liters per second when the inlet valves are open. It is assumed that both inlet valves are opened or closed at a time. Each inlet valve supplies a flow rate of one liter per second, therefore amounting to two liters per second when combined. The water volume in the tank decreases by one liter per second when the outlet valve is open.
The temperature in the tank increases at a rate of two degrees Celsius per second when the water heater is on. On the other hand, the temperature in the tank decreases at a rate of one degree Celsius per second when the water heater is off. The minimum and maximum temperatures of the water heater are selected by the user.
The critical pressure of the water tank is 50 PSI. The pressure of the tank is calculated from the state of the water tank at a given moment. Specifically, the pressure of the tank increases at a rate of two PSI per second when the temperature in the tank is greater than or equal to 90 degrees Celsius and the temperature in the tank is greater than or equal to the maximum temperature selected by the user. The rate then increases by an additional one PSI per second if the volume is above the second highest water level sensor. On the other hand, the pressure decreases at a rate of one PSI per second if the pressure is greater than zero and the volume is simultaneously decreasing.
Coming soon