The EJS+TwinCAT tool is a set of software elements that facilitates the parametrization/monitorization of TwinCAT PLCs from EJS applets, by means of an intermediate server application and a set of JAVA classes. All these elements (i.e. the PLCs, EJS applets, the server application + communication classes) have been designed to support a quick development of remote real-time control laboratory for the students of experimental subjects.

In the following, we present the main characteristics of each of the elements that constitutes the EJS+TwinCAT software tool.

Why TwinCAT PLCs?

The TwinCAT system, created by Beckhoff in 1986, is a PC-based control technology that turns almost any compatible PC into a real-time system where multiple Programable Logic Controllers (PLCs), Numerical Controllers (NCs) for axis controls and Computing Numerical Controllers (CNC) system can coexist. TwinCAT consists of a run-time system that execute control programs in real-time and of a set of development environments for programming, diagnostitacing and configuring the different types of controllers. Besides, its real time capability is based on a precise timebase in which programs are executed with the highest deterministic features, independently of other processor tasks and on the definition and analysis of the TwinCAT system and operating systems (WindowsNT/2000/XP/Vista or Windows 7) load. Additionally, its tools can be used either locally or remotelly to configure and distribute the PLCs in a network of deployment PCs. Finally, it provides a set of communication software libraries that let other programs access and modify the contents of the PLC variables. For more information, visit

All these properties makes them an ideal system to develop a big variety of controllers for different types of subjects in the fields of System Engineering and Automatica. Nevertheless the direct use of its development tools results overwhelming for the students of the introductory control subjects. To overcome this difficulty, the EJS+TwinCAT system exploits the real time capabilities of the TwinCAT system by using its PLC to implement the controllers and run-time system to execute them, and a laboratory front-end based on applets to modify/visualize the controllers behaviours.

Why EJS?

Easy Java Simulations is a is a modelling and authoring software tool especially designed for helping science teachers with low programming capabilities to develop discrete time computer simulations. Therefore, it has been designed to let the teachers work at a high conceptual level, using a set of simplified tools, and concentrating most of his/her time on the scientific aspects of the simulation, asking the computer to automatically perform all the other necessary tasks. To interact with the simulation, EJS creates a platform independent JAVA applet, which can be visualized using any Web browser (and therefore distributed through the Internet) and whose graphic user interface (GUI) is defined by the teachers to show the most relevant aspects of the defined simulation and to let the student modify its behavior through the selected user-interactive elements. For more information, visit

The carefull design of EJS makes it also a very helpful tool for defining the GUI of any type of Java applet that interacts with and controls any other application. To follow this strategy, the applet developers can use 1) the interactive elements of the GUI to control the other application by means of calls to the functions that communicate, under the user request, the applet and the controlled application, and 2) the definition of the simulation to periodically call those functions that let the applet perform the necessary periodic communications with the controlled application. We have followed this strategy to develop the students front-end applets of our laboratory. That is, our applets are developed with EJS, parametrize the behavior of the PLC by changing the values of some of the PLC variables when an EJS applet interactive elements are used, and observe the evolution of some PLC variables by means of periodic communications with the PLC.

Why the intermediate server application?

Although TwinCAT provides communication libraries to let other applications access the value of the variables of its PLCs, the PCs involved in the communication have to undergo a double registration step that protects the deploying system to be reconfigured from unauthorized PCs.T Therefore, the direct use fo the functions of the TwinCAT communication library in the applets would make them only executable from registered PCs. Besides, several applications running from different registered PCs can simultaneously modify the variables of the same PLC, an indesirable behavior in a remote control laboratory. Both problems are easily overcame including an intermediate server application that runs in a registered PC and that is in charge of ensuring an individualized access to the PLCs and of redirecting the information from the EJS applet to the PLC and from the PLC to the applet.

Why the communication library?

Although TwinCAt provides communication libraries to let other applications access the value of the variables of its PLCs, the direct use of their functions require a knowledge of the PLC memory map and data type conversions between the types of variables in the EJS applet and the arrays of bytes accessed in the PLCs. To automate this operation, we have developed a set of classes that 1) encapsulate the TwinCAT communication operations between the server and the PLC, 2) support the communication between the EJS applet and the server by means of text messages and sockets, and 3) define the JAVA variables associated to the PLC structures that are parematrize/observe from the applet.

Overview of the whole system

The relationship between all these elements is schematized in the following figure.

EJS+TwinCAT overview