Benutzer-Werkzeuge

Webseiten-Werkzeuge


realtime_control_environment_setup

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen RevisionVorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
realtime_control_environment_setup [24.07.2019 17:35] – [Realtime control environment setup] Guoping Zhaorealtime_control_environment_setup [27.11.2022 22:58] (aktuell) – Externe Bearbeitung 127.0.0.1
Zeile 1: Zeile 1:
 ====== 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:  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: 
Zeile 54: Zeile 60:
  
 You need two computers. One as xPC target computer. Another one as host 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. +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=== === Network card===
Zeile 70: Zeile 76:
 === EtherCAT slave === === EtherCAT slave ===
  
-Beckhoff's EtherCAT terminals are officially supported by Matlab xPC. I so far didn't try any slaves other than Beckhoff's. But I think it should be possible.  +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. It'used in my setup.  +
-# Motor and motor driver +
-Depends on you. Select Beckhoff terminals according to the interface of your motor driver.+
  
-h2System configuration+== 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.
  
-http://cn.mathworks.com/help/xpc/host-target-configuration-1.html+===== System configuration =====
  
-This section describes my motor testbed setup step-by-step. +This section describes the motor testbed setup step-by-step. 
  
 Here's the current hardware system specifications:  Here's the current hardware system specifications: 
-| *Name* | *Description* | +**Name** | **Description** | 
-"EK1100":https://www.beckhoff.com/english.asp?ethercat/ek1100.htm | Beckhoff E-bus copuler | +| EK1100 | Beckhoff E-bus copuler | 
-"EL1124":https://www.beckhoff.com/english.asp?ethercat/el1124_el1144_el1134.htm | 4-channel digital input (5V) | +| EL1124 | 4-channel digital input (5V) | 
-"EL2124":https://www.beckhoff.com/english.asp?ethercat/el2124.htm | 4-channel digital output (5V) | +| EL2124 | 4-channel digital output (5V) | 
-"EL3004":https://www.beckhoff.com/english.asp?ethercat/el3004_el3008.htm | 4-channel analog input terminal (-10~10V, 12bit, 16bit presentation incl. sign) | +| EL3004 | 4-channel analog input terminal (-10~10V, 12bit, 16bit presentation incl. sign) | 
-"EL4034":https://www.beckhoff.com/english.asp?ethercat/el4034.htm | 4-channel analog output terminalr (-10~10V, 12bit, 16bit presentation incl. sign) | +| EL4034 | 4-channel analog output terminalr (-10~10V, 12bit, 16bit presentation incl. sign) | 
-"EL9011":https://www.beckhoff.com/english.asp?ethercat/el9011.htm | bus end cap | +| EL9011 | bus end cap | 
-"motor":http://130.83.212.83/redmine/attachments/download/967/motor_15-234-EN.pdf , "gearhead":http://130.83.212.83/redmine/attachments/download/968/gear_15-307-308-EN.pdf , "encoder":http://130.83.212.83/redmine/attachments/download/969/encoder_15-353-354-EN.pdf | Maxon, brushless, 24V, 120W; gearhead ratio 1:111 | +| motor | Maxon, brushless, 24V, 120W; gearhead ratio 1:111 | 
-"motor driver":http://130.83.212.83/redmine/attachments/download/970/409510-ESCON-50-5-Hardware-Reference-En.pdf | Maxon, ESCON 50/5 |+| 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 | | 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 | | 24V DC power | 240W |
  
-Here'the software I'm using:  +Here're the softwares:  
-* Windows 10 OS +  * Windows 10 OS 
-* ET9000 +  * ET9000 
-* Matlab 2015b +  * Matlab 2015b 
-* Microsoft Visual C++ 2012 as the compiler +  * Microsoft Visual C++ 2012 as the compiler 
-* ESCON Studio for motor driver configuration+  * ESCON Studio for motor driver configuration
  
-Here's the system overview 
  
-h3. Host-target ethernet link setup 
  
-For more detailsplease check here: http://cn.mathworks.com/help/xpc/gs/target-computer-settings.html+==== Host-target ethernet link setup ==== 
 + 
 + 
 +First of allmake sure the network card installed in the target is supported by Matlab xPC (check "Hardware Preparation" section)
  
-First of all, make sure the network card installed in the target is supported by Matlab xPC (check @Hardware Preparation@ section).  
 Then,  Then, 
-# Open Matlab in the host computer. Type the following command in Matlab command window to open the Simulink Real-Time Explorer.  +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
-<pre> +
-slrtexplr +
-</pre> +
-Here's the explorer window +
-!{width: 720px}simulinkrealtimeexplorer.png! +
-# Click "Host-to-Target communication", select "@TCP/IP@" as "Communication type". Change "Target Network Settings" according to your preference. Here, I set +
-<pre> +
-IP: 192.168.0.2 +
-Subnet mask: 255.255.255.0 +
-Port: 22222 +
-Gateway: 192.168.0.100 +
-</pre> +
-*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".  +
-# 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.  +
-# 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 +
-<pre> +
-BOOTSECT.RTT +
-xpmtgb.RTA +
-</pre> +
-"@Removable Disk@" option is the most 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 +
-# Setup host computer Ethernet. It's related to the target network settings (step 2). Make sure @Subnet mask@ and @Gateway@ is the same as target.  +
-<pre> +
-IP: 192.168.0.1 +
-Subnet mask: 255.255.255.0 +
-Gateway: 192.168.0.100 +
-</pre> +
-Like this +
-!hostnetworksetting.png!+
  
-*_IMPORTANT NOTE_* +{{:simulinkrealtimeexplorer.png?800|}} 
-In the "Host-to-target communication" stepif you have more than one same type of network cards installed in your target, you need to specify which one is used for host-target communicationHere's the command ("ref":http://www.mathworks.com/matlabcentral/answers/96729-how-can-i-choose-a-specific-ethernet-adapter-for-host-target-communication-using-xpc-target-4-3-r20):  +     
-<pre> +2. Click "Host-to-Target communication", select "TCP/IP" as "Communication type"Change "Target Network Settings" according to your preference. Here, I set
-setxpcenv('EthernetIndex', '1' % change the number according to your device +
-</pre>+
  
-h3. Boot the target and test xPC+  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: 
 + 
 +{{:hostnetworksetting.png?400|}} 
 + 
 + 
 +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:  
 + 
 +{{:xpc-startupscreen.jpg?600|}}
  
-# 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:  
-!{width: 480px}xpc-startupscreen.jpg! 
 Check your host-target communication settings in the right-bottom corner:  Check your host-target communication settings in the right-bottom corner: 
-!{width: 480px}xpc-startupscreen-info.jpg! 
-Make sure they are correct.  
-# For testing the configuration, run  
-<pre> 
-slrttest 
-</pre> 
-in the Matlab command window of the host. If all your setup is correct, you should get something like this:  
-<pre> 
-### 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 
-</pre> 
  
-h3. EtherCAT slave configuration+{{:xpc-startupscreen-info.jpg?600|}} 
 + 
 + 
 +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 [[https://www.mathworks.com/help/xpc/ug/generate-eni-files-for-ethercat-devices.html|here]].  
 + 
 + 
 +===== Run Simulink in Realtime ===== 
 + 
 +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.  
 + 
 +{{:ethercatinitblock.png?500|}} 
 + 
 +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. 
  
-* Connect EtherCAT slave to your host computer with ethernet cable.  +{{:simulinkmodelconfig2.png?800|}}
-* Open ET9000 software.+
  
-h2Test xPC with EtherCAT+And the "System target file" in the "Code Generation" has to be configured as "slrt.tlc"
  
-h3. Demo1Digital IO+{{:simulinkmodelconfig1.png?800|}}
  
-!simulinkmodelconfig1.png! 
  
-!simulinkmodelconfig2.png! 
  
-!ethercatinitblock.png! 
  
-h3. Demo2: Analog IO 
  
-h3. Demo3: Motor Current Control 
  
realtime_control_environment_setup.1563982505.txt.gz · Zuletzt geändert: 27.11.2022 22:55 (Externe Bearbeitung)


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