Benutzer-Werkzeuge

Webseiten-Werkzeuge


realtime_control_environment_setup

Realtime control environment setup

Author: Guoping Zhao, Lauflabor (www.lauflabor.de), TU Darmstadt, Germany

Date: July, 2019


There are lots of different ways to set up a realtime control environment for a robotic system. Here, we choose Matlab simulink realtime toolbox (xPC) as the software framework because:

  • Matlab simulink is easy to learn;
  • a lot of control algorithms have already been implemented in Matlab simulink;
  • rapid control prototyping is easy with Matlab simulink.

In order to achieve fast and robust communication, we select EtherCAT (Ethernet for Control Automation Technology, invented by Beckhoff Automation) as the fieldbus system for our robots.

General system structure overview

Preparation

Software preparation

OS

Matlab xpc only supports MS Windows OS for the host/development computer.

Matlab

EtherCAT master blocks has been included with xPC target since Matlab R2011b (ref). So the Matlab version should be at least R2011b. Use the latest version if it's possible.

C compiler

For compiling simulink models, you need to have at least one third-party c/c++ compiler installed on your host computer. You can check the supported compilers list here. Make sure your compiler supports simulink-realtime toolbox. Use this command

mex -setup

to select the compiler in Matlab.

For Matlab 2015b, Microsoft VC 2013 Professional compiler supports all features. VC2013 Professional compiler is included in Visual Studio 2013 Commuinty for free.

EtherCAT configurator

  • Beckhoff ET9000 EtherCAT configurator software is recommended by MathWorks.
  • If you don't have the license of ET9000, you can use Beckhoff TwinCAT software as an alternative option. TwinCAT includes all functions we need in this application. Both ET9000 and TwinCAT have a free-trial license for 7 days.

Reference:

Hardware preparation

Computer

You need two computers. One as xPC target computer. Another one as host computer. If you want the host and target computer communicate via TCP/IP ethernet, the target computer needs at least two available ethernet interfaces (PCIe) (because EtherCAT also needs one). Thus, normally the target computer has to be a desktop computer.

Network card

Here, we use TCP/IP ethernet for host-target communication.

ethernet between host and target computer

This network card should be supported by Matlab xPc. It's recommended to use PCI bus ethernet card because PCI bus is faster than others (ref).

etherCAT between target computer and etherCAT slaves

This network card should be supported by Beckhoff ethernet driver. Here is the list of supported network chipsets.

EtherCAT slave

Beckhoff's EtherCAT terminals are officially supported by Matlab xPC. Other ethercat slaves are can also be used with Matlab xPC as long as they support TwinCAT.

USB flash drive

A USB flash drive is needed if you want to boot the target from a bootable USB drive. I think it's the most convenient way for testing.

Motor and motor driver

Depends on you. Select Beckhoff terminals according to the interface of your motor driver.

System configuration

This section describes the motor testbed setup step-by-step.

Here's the current hardware system specifications:

Name Description
EK1100 Beckhoff E-bus copuler
EL1124 4-channel digital input (5V)
EL2124 4-channel digital output (5V)
EL3004 4-channel analog input terminal (-10~10V, 12bit, 16bit presentation incl. sign)
EL4034 4-channel analog output terminalr (-10~10V, 12bit, 16bit presentation incl. sign)
EL9011 bus end cap
motor Maxon, brushless, 24V, 120W; gearhead ratio 1:111
motor driver Maxon, ESCON 50/5
EXPI9301CTBLK PRO1000 Network card, bought from „here“:http://www.amazon.de/gp/product/B001CY0P7G?psc=1&redirect=true&ref_=oh_aui_detailpage_o02_s01
24V DC power 240W

Here're the softwares:

  • Windows 10 OS
  • ET9000
  • Matlab 2015b
  • Microsoft Visual C++ 2012 as the compiler
  • ESCON Studio for motor driver configuration

First of all, make sure the network card installed in the target is supported by Matlab xPC (check „Hardware Preparation“ section).

Then, 1. Nummerierter ListenpunktOpen Matlab in the host computer. Type slrtexplr in Matlab command window to open the Simulink Real-Time Explorer. Here's the explorer window

2. Click „Host-to-Target communication“, select „TCP/IP“ as „Communication type“. Change „Target Network Settings“ according to your preference. Here, I set

IP: 192.168.0.2
Subnet mask: 255.255.255.0
Port: 22222
Gateway: 192.168.0.100

Note: These settings are related to the host computer network settings (step 5).

Change „Ethernet Device Settings“ according to your network card. For my setup, I select „INTEL_I8254x“ as „Target driver“, select „PCI“ as „Bus type“. 3. Set „Target settings“ according to your target. In general, check „Graphic mode“, select „Auto“ for „RAM size“. Here I also check „Multicore CPU“ because my target has a multicore CPU.

4. For „Boot configuration“, select „@Removable Disk@“ as Boot mode. Insert a preformatted usb flash drive (format has to be FAT32). Click Create boot disk and select the usb drive. Then you'll get these two files in the usb drive

BOOTSECT.RTT
xpmtgb.RTA

„Removable Disk“ option is the easiest way to test the setup. More information of „Boot configuration“, please check here: http://cn.mathworks.com/help/xpc/gs/target-boot-method.html

5. Setup host computer Ethernet. It's related to the target network settings (step 2). Make sure Subnet mask and Gateway is the same as the target.

IP: 192.168.0.1
Subnet mask: 255.255.255.0
Gateway: 192.168.0.100

Like this:

For more details, please check here: http://cn.mathworks.com/help/xpc/gs/target-computer-settings.html

Boot the target and test xPC

1. Inserted the bootable usb flash drive to the target. Boot the target from the usb stick. Then the target should run with Matlab xPC realtime kernel. If your target has a monitor, you should see something like this:

Check your host-target communication settings in the right-bottom corner:

Make sure they are the same as what you configured.

2. For testing the configuration, run

slrttest

in the Matlab command window (host PC). If all your setup is correct, you should get something like this:

### Simulink Real-Time Test Suite 
### Host-Target interface is: TCP/IP (Ethernet)
### Test 1, Ping target computer 'TargetPC1' using system ping: ... OK
### Test 2, Ping target computer 'TargetPC1' using SLRTPINGTARGET: ... OK
### Test 3, Software reboot the target computer 'TargetPC1': ................. OK
### Test 4, Build and download a Simulink Real-Time application using model xpcosc to target computer 'TargetPC1': ... OK
### Test 5, Check host-target command communications with 'TargetPC1': ... OK
### Test 6, Download a pre-built Simulink Real-Time application to target computer 'TargetPC1': ... OK
### Test 7, Execute the Simulink Real-Time application for 0.2s: ... OK
### Test 8, Upload logged data and compare with simulation results: ... OK
### Test Suite successfully finished

EtherCAT slave configuration

This part is well documented by Mathworks. Please find the detailed info here.

In order to run the simulink in realtime (on the target machine) with EtherCAT, the EtherCAT Init block is needed. The configure file, PCI bus number, and the PCI slot number has to be configured correctly according to the setup.

In addition, the solver of the simulink model has to be configured as „Fixed-step“ and „discrete“. The „fixed-step size“ has to be configured the same as the EtherCAT communication frequency. E.g. 0.001 denote 1kHz control frequency.

And the „System target file“ in the „Code Generation“ has to be configured as „slrt.tlc“.

realtime_control_environment_setup.txt · Zuletzt geändert: 27.11.2022 22:58 von 127.0.0.1


Warning: Undefined variable $orig_id in /is/htdocs/wp1019470_OPI92FFHXV/www/wikiLehre/lib/plugins/openas/action.php on line 232