1 Example project
The location for the ECS SimepleConfig Example is in our Knowledge Base
KB → Software → LFW Host Examples → EtherCAT Slave
For netX90:
2 ECS Sources
Take the netXStudion to open the projcet. The ECS Sources in the ECS SimepleConfig Example are in the folder:
Components\cifXApplicationDemoECS_Simple
Get sure to choose the simple example and the correct usecase for your build
3 Overview of the example structure
The examples consist of a general part which is the same for all differnent examples. It initializes the toolkit sets up the Channels etc. The related code is mainly in the folder Components\ApplicationDemo and in the Targets folder. It is not described here but can be found under Common general part for all examples
The simple demo part starts (AppECS_DemoApplication.c) with initializing a packet handler (AppECSSimpleDemo_Initialize) for incomming packets. Actually only HIL_LINK_STATUS_CHANGE_IND (selfexpaining) and ECAT_ESM_ALSTATUS_CHANGED_IND (actual slave state). The function AppECSSimpleDemo_Setup sends the configuration request and afterwards the channel is initialized (App_SysPkt_AssembleChannelInitReq) which means to apply the configurtion data. Then the connection to the bus is switched on by App_SysPkt_AssembleStartStopCommReq.
4 Configuration packet
The ECS Configuration packet is in the file AppECS_DemoApplication.c
It includes the ECAT_SET_CONFIG_DEVICEINFO as addition to the basic parameters, which retalte to the ESI file
5 Values from ESI file
DeviceInfo values:
#define ECS_PRODUCTCODE 0x0000003d
#define ECS_SECONDARY_VENDORID_HILSCHER 0xE0000044
#define ECS_REVISIONNUMBER 0x00030005
#define DEV_GROUP_TYPE_INFO "netX"
#define DEV_TYPE_INFO "NETX ECS V5 Host Example"
#define DEV_NAME_INFO "NETX ECS V5 Host Example"
need to be same like in ESI file:
Each example comes with its own ESI file but all have the same product code and revicion number, so do not mix up them when testing.
Only use one file at a time when adding to a master or config file folder.
Process Data Values:
Choose the number of Input and Output Bytes and tell this the stack in the configuration packet with
ptConfigReq->tData.tBasicCfg.ulProcessDataOutputSize = sizeof(ptEcsRsc->abAktorData); /**< Process Data Output Size from master view */
ptConfigReq->tData.tBasicCfg.ulProcessDataInputSize = sizeof(ptEcsRsc->abSensorData); /**< Process Data Input Size from master view */
Change the number of Bytes for RxPdo (Output) and TxPdo (Input) in the ESI file, like in the configuration packet
<RxPdo Sm="2">
<Index>#x1600</Index>
<Name>1. RxPDO</Name>
<Entry>
<Index>#x2000</Index>
<SubIndex>1</SubIndex>
<BitLen>8</BitLen>
<Name>1 Byte Out (0)</Name>
<DataType>BYTE</DataType>
</Entry>
<Entry>
<Index>#x2000</Index>
<SubIndex>2</SubIndex>
<BitLen>8</BitLen>
<Name>1 Byte Out (1)</Name>
<DataType>BYTE</DataType>
</Entry>
........
<TxPdo Sm="3">
<Index>#x1A00</Index>
<Name>1. TxPDO</Name>
<Entry>
<Index>#x3000</Index>
<SubIndex>1</SubIndex>
<BitLen>8</BitLen>
<Name>1 Byte In (0)</Name>
<DataType>BYTE</DataType>
</Entry>
<Entry>
<Index>#x3000</Index>
<SubIndex>2</SubIndex>
<BitLen>8</BitLen>
<Name>1 Byte In (1)</Name>
<DataType>BYTE</DataType>
</Entry>
........
Example ESI file:
10 Byte Output
6 Byte Input
6 Start Sequenz
- Initialize
- Config Stack
- Init Config
- Start
- Stack is in Init State
6 ECM Master
As soon as the ECS Stack is successfully configured and the “Start Communication Request” / “Bus On” is done, the EtherCAT Slave goes in Init State.
The EtherCAT Master now needs to bring the EtherCAT Slave from Init State to Operational State (OP).
7 Optional Configuration
As an extension to this simple example you can optionally set the define HOST_APPLICATION_SETS_OEM_DATA in AppECS_DemoApplication_Config.h
To use it you have to change an entry of the firmware´s taglist.
At first set the taglist entry 'DDP mode ..' to passive by using the Tag List Editor Tool from hilscher and save the firmware
Than flash it to the device by e.g. using NetxStudio's flasher tool and restart the device to apply the firmware. Now the device will not activate the phys.
In second step you download the firmware with the define HOST_APPLICATION_SETS_OEM_DATA compiled in.
Now the function AppECS_SetOemData in the AppECSSimpleDemo_Initialize function is called. This function uses the HIL_DDP_SERVICE_SET_REQ to to send OEM data to the device. Afterwards AppECS_ActivateDdp is called to activate the data in the firmware. The DDP OEM parameters overwrite one value which is also set in the Configuration packet szOrderIdx (DEV_TYPE_INFO) from ECAT_SET_CONFIG_DEVICEINFO.
8 Using TwinCAT as master
The following scrennshots give a shot introduction to bring the slave to Operational mode using TwinCAT as a master and configuration tool.
1st DownloadTwinCAT from the Beckhoff homepage and install. It is free to use for test purpose.
Than copy your ESI file from the example to the folder which Twincat uses to search for ESI files: C:\TwinCAT\3.1\Config\Io\EtherCAT
Afterwards start TwinCAT and open a new project.
Hint: If you add your ESI file later, you must click 'Reload Configuration files' in TwinCAT. Otherwise TwinCAT will not find your device and create an own temporary ESI file called 'OnlineDescritionCache'. It can only be seen in the folder for ESI files if you close TwinCAT. This can be confusing because it is prefered by TwinCAT if you add your file and do not delete it.
or it may look like this:
Than you have to add a networkadapter (TwinCAT will install some protocols on it). Rightclick on the 'Show realtime Ethernet Compatible Devices...'
In the opening window choose a Networadapter from the list even if ther are no comaptible devices and click the 'Install' button. (Not compatible is mostly sufficent for testing in free run mode.)
The decice will be added above under 'Installed and ready to use ...'
Now you can connect your slave with the example running on it to the master.
Than go on scaning the network
The device shall be found and should still be in Operational.
To send data you can add a value to the RX-PDO (recive from slave view))
The example will increment the value and send it back
If you want to do wireshark traces you must activate the Promeiscous mode on the master device by setting the check mark.
Than cklick the 'reload' button to apply your changes.
Running a Conformance Test
As a member of the EtherCAT organisation you have to buy a licence for the Conformance Test Tool.
The tool is also verry helpful when you are devepolling your slave. You might want to look at the EEPROM or export the objectdictionary or other things which it is usefull.
Download the Conformance Test Tool, install it, add the license file and start it.
Choose the ESI file from the folder. (You might use/share the ESI file folder with TwinCAT's ESI folder)
Add the network device with a click on right mouse button
when asked click scan slaves which adds your slave to the path.
Start the test
Unused Testcases can be deteted, is not they are skipped.