# A Study on Design and Control of the Multi-Station Multi-Container Transportation System
## 3 Results
### The Design of Electrical and Controller of the Entire System
#### 3.2.2 Simulation of the Routing Algorithm  
The simulation of the transportation system includes the following process:  
* _Make a database connection and send the data back to the GUI._  
In a real system, there may be a risk of system power failure. The requirement is that when the power is turned back on, the system will continue to work effectively. Therefore, during the runtime process, the system will constantly update the data, supporting the system to maintain operating properly in case of a reboot situation. The parameters will be updated in the database according to three tables: container (also called \"box\"), counters, and moving modules (Figure 16).  
The updated parameters include the following:  
* Containers table (boxes table): The used, line, module, and waiting variables of each box to determine the location and state of each box.
* Counters value table: Variable number_of_box bidirectional modules at stations.
* The variable state_of_sub_convey will be updated to identify the location of the sub-conveyor of the lifting and line switching modules. Particularly, the 4-line switching module will update three more variables, first_pick, second_pick, and third_pick to determine the order of the box.
* _Handling of logic at the position of the lift conveyor module._  
Figure 16: Database information.  
The lifting module represents a link between a ground-level conveyor system and a ceiling-mounted conveyor system. The problem to be overcome is when a container arrives and needs to be lifted but the sub-conveyor of the lifting module is already occupied. According to Figure 17, when container 2 reaches the waiting position for the lifting module, there is already container 1 present on the lifting module (module 18). At this time, the waiting variable of container 2 will be ON and the PLC will turn off the previous forward conveyor module. At that time, both containers 2 and 3 stop.  
After container 1 is transferred to the next forward conveyor module (module 19) and the sub-conveyor of the lifting module has returned HOME, container 2 is transferred to the lifting module and container 3 will enter a waiting state. Therefore, the variable for the waiting status of container 3 will be turned ON.  
_Handling of logic at the position of the 2-line switching module._  
A 2-line switching conveyor module is a module that moves the container in and out of the stations.  
Situation 1: Containers only travel from the stations out.  
The system lets the containers go out sequentially according to the priority order. It will be similar to the lifting module. After 1 container moves to the next module, the sub-conveyor of the line switching module will return HOME to pick up the next container. The process is described in Figure 18 below.  
Figure 17: Operation of the lifting module.  
Situation 2: When there is a container that needs to go in, but there is additionally another container going out, and vice versa.  
As shown in Figure 19, at the stations, there is a bidirectional forward motion conveyor module. There is only one direction activated at a time.  
Handling of logic at the position of the 4-line switching module.A 4-line switching module is the transfer unit at the meeting point of the lines, which helps move and separate containers.  
The key issue is to prioritize the order of each container when there are several containers at the 4-line switching module (Figure 20). The solution is that the container that gets there first will go first. However, a distinctive feature is that the returning empty containers will have higher priority than those with the item inside.  
Figure 19: Handling situation 2 at the 2-line switching module.  
Figure 18: Handling situation 1 at the 2-line switching module.