Update Week 21, 22.05.2020

Hi!

The project is pretty much done, so here are some videos that show how the program works.

The video above shows the program running on a windows machine.

Above you can see a demonstration of the program running on the Raspberry Pi. The Valve is operated by a digital signal from the wire, on rising edge it will toggle the valve. Since the point of the simulation is to connect it to a PLC, the level of the tank is represented by an analog output through an MCP4725 I2C DAC. To show that the output works, the signal was feed back into an ADC to the Raspberry Pi and printed to the terminal on the left. You may also notice that the program window is too large for the screen. That is because I developed the program on my windows machine and did not consider the fact that different machines/screens have different resolution. So, I did not bother to make the window size adjustable. In principle this is easy to fix, however it was not addressed due to time constraint.

Below you can find the report, an example lab and the guide from Exera

ProjectReport

ProjectReport Industrial_communication_labs[3865] 2001-Exera Hacking Contest-Constructeurs-Présentation[3864]

Industrial_communication_labs[3865]

 

update week 16, 17.04.20

Hi!

This week I spent reading various articles about cyber security. I’ve been looking for a topic for the scientific article which I am supposed to write, and today I made three propositions to Manuel and Hong. On Monday we’ll have a meeting and hopefully we will come to an agreement, because time is scarce and it’s a lot of work.

 

 

Progress update for week 14 05.04.20

GUI design. The sybols comes from E-draw Max.

This week was packed with things to do. First of all, I would like to mention that Hong Wu, I and my supervisor Manuel Avila has agreed that I should try to write a scientific article. The article should preferably be published in one of the journals approved by our university. This sounds like a great challenge and I hope that I can do a good job and deliver what is expected of me.

Second, I have been very occupied with programming and reading the QT-documentation. I now have many different versions of the same program with different ways of tackling the various problems that showed up. An image has been uploaded to show the visual progress of the GUI. To better tackle these problems that occurred and to structure the program in a good way, a flowchart was made for reference. You can see the chapter about the flowchart from the report below.

 

Program flow/planning

Before doing anything, it is important to have a clear idea of what you are trying to accomplish. An idea of how the GUI should look and what functions it needed to perform was formed. First the GUI needed buttons to open and close the valve. It needed a way to input and adjust the volume of the tank and the flow, so that this could be set by the user. Also, it must contain the tank illustration. Preferably with animation that shows the water flowing through the valve, into the tank and out of the tank. When the valve is closed, the animation will show that there is no water flowing into the tank and when the tank is empty the animation will show that there is no water flowing out of the tank. Using these criteria, 4 states were derived which could be used to structure the program a state machine.

State0 represents the empty tank. No water is flowing in and no water is flowing out. When the valve is opened it will change to the next state. The next state will depend on the flow. If the flow from the valve is higher than the drain flow, it will enter state1. If the flow from the valve is less than the drain flow, it will enter state2. This is because the tank level will not increase if the flow is less than the drain and the tank remain empty, but if it is greater the level will increase. Upon transitioning an animation showing the water flowing from the valve will show. Filling up the inlet and outlet pipe with water.

State1 represents the tank being filled/emptied with water. The animation shows that there is flow both into and out of the tank as well. If the water reaches the top of the tank, the tank will shut the valve, activate and alarm and transition to state3. if the valve is shut by the controller/user, it also goes to state3. Upon transitioning the valve animation should show that the valve is closed. If the tank contains water and the valve is switched to half the drain flow, it will empty and then transition to state2.

In state2 the tank has a flow into the tank less than the flow out. Meaning that the valve illustrations will show that the tank is being filled, but the level never increases. This state should be prevented by the PLC controller, but if it is not successful then this state will show. If the valve flow is changed to twice the drain, it will transition to state1. If the valve flow is turned of it will transition back to state0 and upon transitioning the intake- and drainpipes will be emptied.

In state3 the tank is emptying because the valve is closed but the drain is open. If the valve is reopened it will transition back to state 1. Upon transitioning it will then show the animation water exiting the valve. Finally, if the volume becomes zero it will transition back to state0. Upon this transition it will show the drainpipe being emptied.

Figure 1: State machine diagram

Throughout the development period there was a lot of experimentation with different ways of structuring the program and different ways of executing its various tasks. Some solutions worked better than others and eventually lead to the final result. To implement the state machine, some of the programs developed on the way ended up using sub states to perform the animations. However, the core idea remains the same. This state machine has been summarized in the figure above.

From the state machine the following program flow can be derived:

Figure 2: Basic program flow

The basic idea the flow chart shows is that the GUI is run by a loop in the main thread and the state machine is run by a separate worker thread. The worker thread checks what the current state should be and will call that function. Each state-function will perform its task, set the next state and then signal the GUI to run the transition animation before the loop returns to start. If the user pressed the Exit button on the window, the main thread will terminate the worker thread before ending itself.

 

 

 

 

 

Prototype of tank using python

The tank in the images was made using Edraw Max.

 

Two days ago, I started reding in a textbook about simulation of process systems in general and specifically simulation gravity flow tanks. The material was interesting but after a whole day of reading I realized that the specifications set by Exera was contradicting with what I was reading. I realized that I was not supposed to model the tank in a realistic or precise way because it is just a dummy process for the tournament. At first, I thought that even though it was quite interesting, it was just a waste of time. However, after thinking about it, I realize that I saved a week of work just avoiding the true complexity of process simulation. So, I happily continued with the next task.

Yesterday I started looking for various solutions for my system. Specifically, I looked into how I could eliminate the process station by using a raspberry pi for both the signal processing and the simulation of the tank. I found that using python with a GUI-framework could be a good idea, so I started tinkering a little. If I choose this solution, I could write everything in one python program where I could directly access the GPIO-pins of the raspberry pi. This would eliminate any difficulty with communication between the signal conditioner, the process station and the simulation program. The raspberry pi could run everything itself and could be connected to its own dedicated screen or a monitor via the HDMI-port. However, to go further with this idea I needed to prove that I could make a nice display of the tank, and that it was not too much work.

There were many different GUI-frameworks, but I needed this to go fast so I selected PyQt5 with QT-designer. The QT-designer lets you drag and drop objects that you need onto the window, then it generates all the code that you need to display it so that you can take that code and manipulate it. I spent that day making a basic proof of concept code which I then turned into an executable for easy use. I will attach the folder with the executable to this post. To try it out it can be extracted from the rar-file and then you can run the file «tank prototype.exe» in the qt-folder. The Executable file must be in the folder for it to work, because it depends on the images in the folder to run. I will attach some images of the program as well.

 

Prototype executable:
https://drive.google.com/file/d/1UeJju0DTtpm1aUE5GinHQlEFiZonj08c/view?usp=sharing