5. Methodology
5.4. Load cells HMI
Due to the mirror’s huge dimensions and weight, the process of coupling the mirror into the support cell is complex. It is essential, that the mirror’s weight is uniformly distributed among the cell’s surface. To ensure that, a total of thirty-two load cells are placed around the cell structure, so the force applied by the mirror at each point is known. This software is a completely different program than the main software described in the previous section.
Therefore, it is needed to monitor in real time the measures of each one of the load cells during the coupling process, as well as being able to tare the load cells to obtain accurate measures. So that, the HMI must contain thirty-two text blocks displaying the value of each load cell, thirty-two buttons to tare each load cell individually, and finally, one button to tare all the sensors at the same time.
TwinCAT3 also offers TwinCAT HMI, a very powerful tool designed to create Human Machine Interfaces. Indeed, the HMIs created are web applications that can be deployed into the PLC or even in a computer within the same network. It handles the creation of the backend and also the frontend application.
5.4.1. The frontend
The TwinCAT HMI incorporates a drag and drop web builder, can be easily designed and created. Using this builder, the thirty-two text boxes and buttons were placed in the same position that the load cells would be placed in the physical structure. TwinCAT3 also offers TwinCAT HMI, a very powerful tool designed to create HMI.
Figure 12 shows the front face of the cell structure and Figure 11 the back one. Both are part of the HMI used to monitor the load cells measured. The position of each text-block and button pair represents one of the attached load cells.
Figure 12. Load cells HMI front face
Figure 11. Load cells HMI back face
TwinCAT HMI allows to map variables of the software running in the PLC to the text blocks.
That means that the measures received for each load cell can be directly linked into the text blocks, and the values would be refreshed automatically without any code. However, executing methods from the PLC code since the HMI is a more complex procedure. For this task, TwinCAT provides its own JavaScript framework.
Using this framework, the process to execute a PLC method is the following one:
1. The buttons can trigger a JavaScript function whenever they are clicked.
2. The methods of the PLC software can be mapped into the server as “Symbols”. The Symbols are strings containing the path of the method to be executed, for example:
“ModuleName.ClassName.MethodName”. These symbols indicate to the webserver which method must be executed.
3. Using the JavaScript framework, a function to execute one of those symbols can be created. It is an asynchronous function that needs as input arguments the symbol’s name, a JSON with the method parameters (if any) and a function acting as a call-back that would be executed whenever the server response is obtained.
Following these steps, the load cells can be tared from the HMI. In the next section, how this functionality is carried out is explained. Notice that the software running in the PLC control loop is written in Structured Text and is not in charge of the web server. The web server is handled by TwinCAT HMI that runs Node.js, a JavaScript runtime. This web server, when receives a request to execute a specific Symbol, triggers the necessary methods of the PLC control loop software.
5.4.2. The backend
Fortunately, the web server is handled by TwinCAT HMI and no code for handling user’s requests must be developed. However, the acquisition of the load cells measurements must be done and they need to be mapped to a variable of the PLC software. Moreover, the function to tare each load cell and to tare all of them need to be written.
Due to the large amount of load cells, an intermediate device between the PLC and the load cells is used. This device is the ELM3504, manufactured by Beckhoff, a four-channel measuring bridge. Each one of the four channels measures a load cell, so a total of eight ELM3504 are employed for this software. The ELM3504 channels can be directly mapped into variables of the PLC Software, so the measures are obtained in real time and are accessible from any point of the program. Indeed, the outputs of these channels are the values displayed in the HMI’s text blocks.
In order to tare the measures, it is needed to write in the SDO of the ELM3504. The different channels into the same device are uniquely identified via its index, however the subindex and the command to be written are always the same one. So that, when a tare button is clicked in the HMI, the JavaScript function passes as an argument a channel identifier to the tare function, so it is executed in the corresponding channel.
5.4.3. The software architecture
Figure 13 shows the UML diagram of the software architecture. To sum up, in the main
method sets a flag to true whenever a channel is tared, but does not communicate with the measuring bridge. The object contains eight instances of the FB_BRIDGE class, that represents the ELM3504. Each one of the eight ELM3504 is identified by an address and a port. This class is the one responsible of writing into the SDO the tare command. Each bridge contains four instances of the FB_Channel class that has mapped the output of one channel of an ELM3504 device into the nValue variable. This nValue, is directly linked to the corresponding HMI text block. In addition, when a tare button is clicked, the method M_DoTare receives an integer between 1 and 32 identifying the device and channel to be tared. This method changes the bTared flag and it triggers the FB_Bridge.M_Tare_Cmd method.
Figure 13. Load cells HMI backend UML diagram