Uppsala universitet

Real Time Control using Matlab and Java

Ove Ewerlid , Claes Tidestav and Mikael Sternad

Nordic Matlab Conference, Stockholm, October 27-28, 1997.


Extended Abstract:
The course Process Control is taught during the eighth semester in the Master of Science program in Engineering Physics at Uppsala university. In this course, groups of four students use Matlab to design and implement a real time control system.

The students use Java to design a graphical user interface for their controller. Via this interface, it should be possible to view the state of the process and interactively change some of the most important parameters. The graphical user interface communicates with the controller over the network.

The controller is (of course) designed using Matlab. What is new is that the real-time control loop is implemented in Matlab, using a single m-file. Execution of the control loop is initiated by a timer once per sampling interval. At the end of the control loop iteration, the Matlab process enters a waiting state, which is terminated by the timer at the beginning of the next sampling interval.

The Matlab process executing the m-file runs under Linux, a public domain Unix dialect available for e.g. Intel PC:s. The Linux kernel has been extended with real-time capabilities. Unix is not an ideal operating system for real-time applications, but for our purposes it is quite adequate. By using Linux, all features of a Unix system can be used, including built-in IP support.

The students implement the graphical user interface as a Java applet, which can be run either using a WWW browser or a so-called applet viewer. Matlab is not used in this case, since the real-time update of the complex interface would be too time-consuming. Also, Java is a more powerful language for implementation of graphical user interfaces. Last, but not least, there is currently a great demand for experienced Java programmers.

The graphical user interface presents important properties about the running control process, e.g.

  • current values of output signals, control signals and reference signals.
  • current type of controller.
  • possible alarm events.
  • current values of regulator parameters.

From the interface, it should also be possible to interactively change certain of the above entities.

To communicate, the Matlab process and the Java applet exchange UDP packets. These packets are transmitted from one of the two process over Ethernet to a specific port on a specific computer. This makes it possible for the controller and the user interface to reside on different computers. Such an arrangement has two advantages:

  • One computer can be dedicated to running the computationally intensive controller loop.
  • The separation makes the distinction between the two tasks clearer.

From the control process, Matlab arrays with elements of type ``double'' are sent to the user interface process, where they are received as two-dimensional Java arrays of ``doubles''. Up to four matrices can be sent using a single Matlab instruction. An arbitrary string can be sent along with the matrices, containing information about the matrices. When sending data in the opposite direction, from the user interface to the controller loop, two-dimensional arrays of doubles are sent from the Java applet to the Matlab control loop, where they are received as two-dimensional Matlab arrays of doubles. Also, communication between two Matlab processes is possible using these UDP functions.

By using Matlab for both design and implementation, the development process could be simplified considerably. The final results were very encouraging, and the problems we had feared due to real-time timing constraints could be avoided completely: even with an indirect adaptive controller the controller loop lasted less than 10 ms on a 200 MHz Pentium Pro computer.

Related pagess:
The book used in the course

Source:
Pdf, 46K

| Main entry in list of publications |
This material is presented to ensure timely dissemination of scholarly and technical work. Copyright and all rights therein are retained by authors. All persons copying this information are expected to adhere to the terms and constraints invoked by each authors copyright. This work may not be reposted without the explicit permission of the copyright holder.