E-box/User manual

From Control Systems Technology Group
Jump to navigation Jump to search

Starting an experiment

Starting Matlab

  1. Open a terminal.
  2. Type sudo matlab

Basic simulink model

The function of ec_test01 is similar to mini01 for the PATO setup with Tu/eDACS. Open ec_test01 and "Save as" under a different file name in your home directory /home/<username>.

Library

The library can be found by typing eclib in the matlab console. The supported Beckhoff EtherCAT modules are:

  • EL1008 - 8 channel digital input terminal 24V
  • EL1014 - 4 channel digital input terminal 24V
  • EL1018 - 8 channel analog input terminal 24V
  • EL2004 - 4 channel digital output 24V
  • EL2008 - 8 channel digital output 24V
  • EL3102 - 2 channel analog input 10V ..10V differential, 16 bits
  • EL3104 - 4 channel analog input 10V ..10V differential, 16 bits
  • EL4038 - 8 channel analog output -10 tot 10V 12-bit
  • EL4132 - 2 channel analog output -10 tot 10V 16-bit
  • EL5002 - 2 channel SSI encoder interface
  • EL5101 - 1 channel incremental encoder interface TTL

All S-function blocks have 1 parameter, which must be set, called the link_id. The link_id is a counter, starting at 0 for each different type of module or device in the EtherCAT stack.

Linkid.png

Building the real-time code

Press "CTRL+B" to build the code or type rtwbuild('model') in the Matlab console.

Executing the real-time code

Without Simulink External Mode

  1. Open a terminal.
  2. Go to the directory where the model is saved.
  3. Type sudo ./model.

With Simulink External Mode

  1. Open the simulink model.
  2. Open a terminal.
  3. Go to the directory where the model is saved.
  4. Type sudo ./model -w (in the terminal).
  5. Click Connect to target.
  6. Click Start real-time code.

Getting the data

After the experiment the file model.mat will be created with the data from the experiment. Type load model.mat in the matlab console to load the data to the workspace. Data will be saved with rt_ prefix.

Errors

This section gives an overview of possible errors

Wrong ethernet port

  1. Click Simulation
  2. Click Configuration parameters
  3. Click Real-Time Workshop
  4. Change the make command to make_rtw OPTS='-DNETIF_ID=<x>'

where <x> is the number of the ethernet controller. The correct ethernet port is 0 by default.

Program not executed as root

When you forgot to execute the real-time programm as root you will see the following output:

Waiting for External Mode start...
ECtarget v1.3 SOEM, M.J.G. v.d. Molengraft & IME Technologies, 2009
Net interface = eth0.
ec_start reports: opening EtherCAT communication.
ec_start reports: master socket bind on eth0 failed.
EtherCAT initialization failed.

Test programs

simple_test

  1. Open a terminal.
  2. Type cd /usr/src/soem/.
  3. Type sudo ./simple_test eth<x>.

where <x> is the number of the ethernet controller.

This should give an output similar to:

SOEM (Simple Open EtherCAT Master)
Simple test
Starting simple test
ec_init on eth1 succeeded.
3 slaves found and configured.
Request operational state for all slaves
Operational state reached for all slaves.
Processdata cycle    1 , O: 00 00 00 00 00 00 00 00 I: 00 80 fb ff 00 80 fb ff
Processdata cycle    2 , O: 00 00 00 00 00 00 00 00 I: 00 00 fa ff 00 00 f9 ff
Processdata cycle    3 , O: 00 00 00 00 00 00 00 00 I: 00 00 fa ff 00 00 f9 ff
Processdata cycle    4 , O: 00 00 00 00 00 00 00 00 I: 00 00 fa ff 00 00 f9 ff
Processdata cycle    5 , O: 00 00 00 00 00 00 00 00 I: 00 00 fa ff 00 00 f9 ff
Processdata cycle    6 , O: 00 00 00 00 00 00 00 00 I: 00 00 fa ff 00 00 f9 ff
Processdata cycle    7 , O: 00 00 00 00 00 00 00 00 I: 00 00 fa ff 00 00 f9 ff
Processdata cycle    8 , O: 00 00 00 00 00 00 00 00 I: 00 00 fa ff 00 00 f9 ff
Processdata cycle    9 , O: 00 00 00 00 00 00 00 00 I: 00 00 fa ff 00 00 f9 ff
Processdata cycle   10 , O: 00 00 00 00 00 00 00 00 I: 00 00 fa ff 00 00 f9 ff
Request safe operational state for all slaves
End simple test, close socket
End program

slaveinfo

  1. Open a terminal.
  2. Type cd /usr/src/soem/.
  3. Type sudo ./slaveinfo eth<x>.

where <x> is the number of the ethernet controller.

This should give an output similar to:

SOEM (Simple Open EtherCAT Master)
Slaveinfo
Starting slaveinfo
ec_init on eth0 succeeded.
1 slaves found and configured.

Slave:1
 Name:E/BOX
 Output size: 80bits
 Input size: 184bits
 State: 4
 Delay: 0[ns]
 Has DC: 1
 DCParentport:0
 Activeports:1.0.0.0
 Configured address: 1001
 Man: 00000500 ID: 01107001 Rev: 00000003
 SM0 A:1000 L: 128 F:00010026
 SM1 A:1080 L: 128 F:00010022
 SM2 A:1100 L:  10 F:00010024
 SM3 A:1180 L:  23 F:00010020
 SM types 0:0 1:1 2:2 3:3
 FMMU0 Ls:00000000 Ll:  10 Lsb:0 Leb:7 Ps:1100 Psb:0 Ty:02 Act:01
 FMMU1 Ls:0000000a Ll:  23 Lsb:0 Leb:7 Ps:1180 Psb:0 Ty:01 Act:01
 FMMU2 Ls:00000000 Ll:   0 Lsb:0 Leb:0 Ps:0000 Psb:0 Ty:00 Act:00
 FMMUfunc 0:1 1:0 2:0 3:0
 MBX length: 128 MBX protocols : 04
 CoE details: 17 FoE details: 00 EoE details: 00 SoE details: 00
 Ebus current: 0[mA]
 only LRD/LWR:0
End slaveinfo, close socket
End program