Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung |
embedded_systems:ethercat:ecmasterlib [2021-09-30 16:38] – Urs Graf | embedded_systems:ethercat:ecmasterlib [2021-11-22 15:34] (aktuell) – Urs Graf |
---|
===== Overview ===== | ===== Overview ===== |
| |
The //"ecmasterlib"// offer an easy way to use EtherCAT with [[http://eeros.org/|EEROS]] or in a standalone project. | The //"ecmasterlib"// offers an easy way to use EtherCAT with [[http://eeros.org/|EEROS]] or in a standalone project. |
| |
* **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]]. |
| |
===== 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); |
| |
| 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); |
| |
| std::cout << "loop start\n"; |
| while(stack.isRunning()) { |
| std::cout << "Current Position: " << drive.getPosition() << '\n'; |
| sleep(1); |
| } |
| </code> |
| |
===== Adaptions ===== | See [[embedded_systems:ethercat:teststand#run_test_program|EtherCat Teststand]] |
==== Overview ==== | ===== Modifications ===== |
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). | 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 |
These components must also be adapted when creating a new EEROS application. | - Create or modify ENI-Files |
| - Create or modify interface files accordingly |
==== Steps ==== | |
- Study produced ENI file carefully (use XML viewer). Under <config><processimage><inputs> and <outputs> you find bitsize and offset of all transmitted values. | |
- Adjust headerfile accordingly, negative offset values indicate that the entry is not going to be used. | |
- Make necessary adaptions in //getDrivesBlock// and //setDrivesBlock//. | |
| |
interface is specific for [[https://www.elmomc.com/product/gold-twitter/ | Gold Twitter]] drives from ElmoMC. Other drives (i.e. Maxon Maxpos 50/5) need a different interface. | |
You may copy and adapt ''EtherCATInterfaceElmo'' for your drive type. | |
| |
[[https://github.com/eeros-project/eeros-framework|EEROS]] > ''[[https://github.com/ntb-ch/etherCATInterfaceElmo | EtherCATInterfaceElmo]]'' > ''[[https://github.com/ntb-ch/ecmasterlib | ecmasterlib & EtherCATInterfaceBase]]'' > [[https://www.acontis.com/de/ecmaster.html | Acontis Stack]] | |
| |
[[embedded_systems:ethercat:EtherCatInterface | Detailed description]] | |
| |