Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Nächste Überarbeitung
Vorhergehende Überarbeitung
embedded_systems:ethercat:ecmasterlib [2021-09-30 09:11] – angelegt Urs Grafembedded_systems:ethercat:ecmasterlib [2021-11-22 15:34] (aktuell) Urs Graf
Zeile 1: Zeile 1:
 ====== ecmasterlib ====== ====== ecmasterlib ======
 ===== Overview ===== ===== Overview =====
-{{ :embedded_systems:ethercat:ethercatinterfaceelmo_inheritance.png?direct&|}} 
  
-The //"ecmasterlib"// and //"EtherCATInterface"// offer a relative easy way to use EtherCAT with [[http://eeros.org/|EEROS]] or in standalone project. +The //"ecmasterlib"// offers an easy way to use EtherCAT with [[http://eeros.org/|EEROS]] or in standalone project. 
  
-  * **EEROS**: The robotic framework 
   * **EtherCAT stack**: The EtherCAT stack from Acontis, see [[embedded_systems:ethercat:understanding_acontis|The Acontis EtherCAT Stack]].   * **EtherCAT stack**: The EtherCAT stack from Acontis, see [[embedded_systems:ethercat:understanding_acontis|The Acontis EtherCAT Stack]].
-  * **ecmasterlib**: This library provides an easy interface to the EtherCAT stack. The library initializes the stack and takes over the periodic sending and receiving of the bus data. It provides the following basic interface: **[[embedded_systems:ethercat:ethercatinterface:EtherCATInterfaceBase]]** +  * **ecmasterlib**: This library provides an easy interface to the EtherCAT stack. The library initializes the stack and takes over the periodic sending and receiving of the data on the bus. It provides the following basic interfaces 
-  * **EtherCATInterfaceElmo**: An interface based on //EtherCATInterfaceBase// designed for Elmo drives. See **[[embedded_systems:ethercat:ethercatinterface:EtherCATInterfaceElmo]]** for detailsYou may need to implement your own interface for different drives. the interface further includes to EEROS blocks for the control system: +    * **Elmo.hpp**: An interface for Elmo drives 
-    * **getDrivesBlock**: It has a signal output for every PDO input value (i.e. encoder values). You may need to modify this block in your application. +    * **Beckhoff/EL1008.hpp**: An interface for digital input terminal 
-    * **setDrivesBlock**: It has a signal input for every PDO output value (i.e. setTorque). You may need to modify this block in your application.+    * **Beckhoff/EL2008.hpp**: An interface for digital output terminal 
 +    * **Beckhoff/EL3004.hpp**: An interface for analog input terminal 
 +    * **Beckhoff/EL4004.hpp**: An interface for analog output terminal
    
 +You may need to implement your own interfaces for other drives and terminals.
  
 ===== Installation ===== ===== Installation =====
-Please make sure that you have previously installed the EtherCAT stack software and EEROS beforehand. Install EEROS as described in [[http://wiki.eeros.org/getting_started/compile_eeros|this tutorial]], but use the command line option ''-DUSE_ETHERCAT=TRUE'' when calling cmake. 
-<code> 
-... 
-cmake -DCMAKE_INSTALL_PREFIX=/absolute/path/to/working/directory/install-x86-64 -DUSE_ETHERCAT=TRUE .. 
-... 
-</code> 
- 
-==== Install ecmasterlib ==== 
 Once the EtherCAT stack has been installed and the demo application is running, the //ecmasterlib// can be installed.  Once the EtherCAT stack has been installed and the demo application is running, the //ecmasterlib// can be installed. 
  
 <code> <code>
 $ cd path/to/working/directory $ cd path/to/working/directory
-$ git clone https://github.com/ntb-ch/ecmasterlib.git+$ git clone https://gitlab.ost.ch/tech/inf/public/ecmasterlib
 $ cd ecmasterlib $ cd ecmasterlib
 $ mkdir externalLib $ mkdir externalLib
 $ cp ''<classB_path>''/SDK/LIB/Linux/x64/libAtemRasSrv.a externalLib $ cp ''<classB_path>''/SDK/LIB/Linux/x64/libAtemRasSrv.a externalLib
 $ cp ''<classB_path>''/SDK/LIB/Linux/x64/libEcMaster.a externalLib $ cp ''<classB_path>''/SDK/LIB/Linux/x64/libEcMaster.a externalLib
-$ mkdir build-x86-64 
-$ cd build-x86-64 
-$ cmake -DCMAKE_INSTALL_PREFIX=/absolute/path/to/working/directory/install-x86-64 .. 
-$ make 
-$ make install 
-</code> 
- 
-==== Install EtherCATInterfaceElmo ==== 
-<code> 
-$ cd path/to/working/directory 
-$ git clone https://github.com/ntb-ch/ethercatinterfaceelmo.git 
-$ cd EtherCATInterfaceElmo 
 $ mkdir build-x86-64 $ mkdir build-x86-64
 $ cd build-x86-64 $ cd build-x86-64
Zeile 51: Zeile 32:
  
 ===== Functionality ===== ===== Functionality =====
-The //"ecmasterlib"// provides a callback function (''void callbackFct(...)'') which is called by the Acontis stack once per EtherCAT cycle. +The examples show how to use the interfaces, e.g
-This method+<code cpp> 
-  * Copies the received data from the stack into the receive buffer of //"ecmasterlib"// +ecmasterlib::device::beckhoff::EL1008 inputs{}; 
-  * Copies the data to be sent from the send buffer of //"ecmasterlib"// to the stack.+auto &stack ecmasterlib::EcMasterlibMain::createInstance(argc, argv, inputs);
  
-The receive and send buffers of //"ecmasterlib"// are byte arrays (''uint8_t* inBufferuint8_t* outBuffer;''which are the same size as the PDOs.+std::cout << inputs[0] << std::endl; // reads first digital input channel 
 +</code> 
 +You create an interface instance which must be passed to the EtherCAT stack. See the examples within [[https://gitlab.ost.ch/tech/inf/public/ecmasterlib|ecmasterlib]]. Elmo drives could be used as follows 
 +<code cpp> 
 +ecmasterlib::device::Elmo drive{}; 
 +auto &stack = ecmasterlib::EcMasterlibMain::createInstance(argc, argv, drive); 
 +sleep(10); 
 +std::cout << "init start\n"; 
 +drive.init([&stack]({ stack.sync(); }); 
 +drive.setMode(ecmasterlib::device::Elmo::Mode::PROFILE_VELOCITY); 
 +drive.setTargetVelocity(1000); 
 +drive.setMaximumTorque(300);
  
-The //"ecmasterlib"// also provides a condition variable (''std::condition_variable cv;'') to synchronize the user application (i.e. EEROS). +std::cout << "loop start\n"; 
- +while(stack.isRunning(){ 
-When an //"ecmasterlib"// object is created, an instance (monotonicis created. +  std::cout << "Current Position: << drive.getPosition() << '\n'; 
-The stack is started in the same way as in the //"EcMasterDemoDC"// of Acontis. +  sleep(1); 
- +} 
- +</code>
- +
-===== Adaptions ===== +
-==== Overview ==== +
-The components //EtherCATInterfaceElmo_config//, //getDrivesBlock// and //setDrivesBlock// need to be adjusted whenever you change the variables, which are transmitted via PDOs (periodic sent/received messages by the EtherCAT bus). +
-These components must also be adapted when creating a new EEROS application.+
  
-==== Steps ==== +See [[embedded_systems:ethercat:teststand#run_test_program|EtherCat Teststand]] 
-  - Study produced ENI file carefully (use XML viewer). Under <config><processimage><inputs> and <outputs> you find bitsize and offset of all transmitted values. +===== Modifications ===== 
-  - Adjust headerfile accordingly, negative offset values indicate that the entry is not going to be used. +If you switch to other drives or terminals or if you want to transmit a different set of PDOs, you have to undertake the following steps 
-  - Make necessary adaptions in //getDrivesBlock// and //setDrivesBlock//.+  - Create or modify ENI-Files 
 +  - Create or modify interface files accordingly
  
-===== Attachment ===== 
-{{:embedded_systems:ethercat:diagram_ethercatinterface.rar|Class Hierarchy}}