## 2 System Setup
### Real-Time Process Control System  
For process control, a Microsoft Windows laptop PC with Matlab R2014b and Simulink, including the additional toolboxes Real-Time Windows Target and Simulink Coder, is used. In case of vision-based control, additionally, the Image Acquisition Toolbox and the Computer Vision Toolbox are required. The laptop PC is equipped with an Intel Core i5-3210M CPU (2x2.5 GHz, 8 GB DDR3). Real-Time Windows Target [28] realizes a real-time engine for Simulink models on a Microsoft Windows PC and offers the capability to run hardware-in-the-loop simulations in real-time. It is a lean solution for rapid prototyping and provides an environment where a single computer can be used as a host and target computer. Consequently, the real-time simulations are executed in Simulink's normal mode without an external target machine. The communication between the Simulink model running on the PC and the rotary units is implemented as follows. Schunk provides a function library written in C to communicate via a USB-CAN bus interface with the manipulator's units. Instead of integrating the hardware via the supported input/output (I/O) boards into the loop, S-functions in the Simulink model are used for the I/O. S-functions offer the capability to integrate C code into Simulink models. For this purpose, C functions from the function library for determining the motor current, measuring the angle and angular velocity for each unit are implemented to realize I/O-communication with the rotary units.  
The S-functions are compiled as MEX files using Microsoft Visual Studio C/C++ 2010 by linking the function libraries. An external power supply provides the rotary units with a constant voltage of 24 V. Because of integrated control and power electronics in each unit, no servo amplifiers are necessary. If no vision-based sensing is implemented, but encoder signals are taken as control feedback, the whole control loop and thus also the I/O-lines are processed with a sampling rate of 50 Hz, which corresponds to a sampling interval of 20 ms. The sampling rate results from the time for signal transmission via CAN bus for determining the motor current, measuring the angle and angular velocity of each unit and the calculations for the MPC. When vision-based sensing is implemented, the sampling rate is limited to 5 Hz due to the image processing algorithm's high time requirements. For details see Sections 5 and 6. The CAN bus works with a baud rate of 250 kBit/s.  
The camera is connected to the Laptop PC by a USB 3.0 connection. The Matlab Image Acquisition Toolbox offers a tool called Adaptor Kit, which is a C++ framework to create a custom adaptor, that is, a dynamic link library (DLL), for one's own camera hardware. Having this DLL available, Matlab can communicate with the camera after loading it as a Video Input Object using the Image Acquisition Toolbox. The overall control system is visualized by Figure 4.  
It is worth mentioning that the used real-time process control system is a lean and cheap solution for controlling the considered systems in real-time since no other real-time target machine or I/O boards are necessary.  
Figure 4: Schematic scheme of process control system.