Table of Contents Introduction ............................... 3 Creating new project .......................... 4 Installation of ESI description files ..................... 6 Scan EtherCAT devices ........................6 Create a sample program ........................9 Further Examples ..........................15 Read and Write of ‘real’ data types ....................15 Read of ‘string’...
Introduction This quick start guide describes an approach how you can configure the 2311 via Beckhoff TwinCAT using a Beckhoff PCI-Ethernet Card. Please note that the samples here cannot be directly used in your production line because they have beed extremely simplified to reach a better understanding. Therefore, you may have to complete them by checking of status, error, length values etc.
Creating new project Start the TwinCAT XAE Shell and click on New TwinCAT Project (a) (or via File → New Project) Select TwinCAT XAE Project, assign a project a name (b) and click OK of 20...
Page 5
Go to TwinCAT (a), select Show Real Time Ethernet Compatible Devices… (b) and look for your a EtherCAT Master device under Compatible devices* (c). Afterwards click the Install button (d). *You can find information of supported nenwork controllers on: https://infosys.beckhoff.com/english.php?content=../content/1033/tc3_overview/9309844363.html&id of 20...
Note: Please make sure that your ESI file is compatible to the field bus firmware in the 2311. Copy the ESI file into directory C:\TwinCAT\3.1\Config\Io\OnboardIo and additionally into C:\TwinCAT\3.1\Config\Io\EtherCAT Note: you will find the corresponding ESI files on burster.com Note: If you use the TwinCAT 2 The ESI directory would be C:\TwinCAT\Io\EtherCAT Scan EtherCAT devices ...
Page 7
At this point you are to perform a device search by confirming the Scan for boxes request or later by right-clicking on the found EtherCAT device and selecting Scan in the context menu as shown below: If the TwinCAT was not able to find the ESI file, confirm the question to use online description and after a while you should be able to see the 2311 device in the project tree: ...
Page 8
To see the process data, please click on the 2311 in the project tree (a) and select the Process Data tab (b): of 20...
Create a sample program In this section, you will learn how to create a simple PLC program to perform a resistance measurement and read the measurement result via PDO (Process Data Object). You will need to refer to section 7 EtherCAT data protocol in 2311 EtherCAT operation manual to understand the meaning of input bytes.
Page 10
Select Standard PLC Project (a) in the Add New Item dialog, enter RunMeasurement as project name (b) and click Add Next, open the MAIN (PRG) file from PLC → RunMeasurement → POUs with double click on it: of 20...
Page 11
Example 1: Reading and Writing of PDOs Type in the following text in the MAIN block Goto Build → Build Solution of 20...
Page 12
Assign the input and output variables to the corresponded PDOs with the right-click on a variable and select Change Link…(a) from the context menu, select a corresponded PDO (b) Assignment: MAIN.ready → 2311_OUT_READY MAIN.measError→ 2311_OUT_MEASUREMENT_ERROR MAIN.measValue → 2311_OUT_MEAS_VALUE MAIN.measStart → 2311_IN_MEAS_START ...
Page 13
Goto Build → Build Soution to build the project: Activate configuration via TwinCAT → Activate Configuration Confirm starting in Run Mode: of 20...
Page 14
Goto PLC → Login: and if asked, confirm that program should be downloaded into the controller Press the F5 key or click on the green start symbol to start the program execution When the resistomat performs a new measurement (measStart = TRUE) it resets its output ready, PLC stops after that the measurement by setting measStart = FALSE.
Further Examples In this chapter, we will perform read & write operations on SDO (Service Data Objects). These are described in section 8 SDO – Service Data Objects of the 2311 EtherCAT operation manual. 5.1 Read and Write of ‘real’ data types Example 2: Set and Get the reference temperature value (Index 0x2045, Subindex 12) This example shows you how to write and read the reference temperature value.
Page 16
Add a new POU (Program Organization Unit) Rename it to WriteReadTemperatureValue and click OK: of 20...
Page 17
Insert the call of the WriteReadTemperatureValue in the MAIN POU: Type in the following code into the created WriteReadTemperatureValue POU Source code: PROGRAM WriteReadTemperatureValue fbSdoWrite : FB_EcCoESdoWrite; fbSdoRead : FB_EcCoESdoRead; sNetId : T_AmsNetId := '192.168.19.1.4.1'; // see note 1 below nSlaveAddr UINT := 1001;...
Page 18
fbSdoRead(sNetId:= sNetId,nSlaveAddr :=nSlaveAddr, nIndex:=nIndex, nSubIndex :=nSubIndex, pDstBuf:= ADR(fTemperature), cbBufLen:=SIZEOF(fTemperature), bExecute:=TRUE); bError:=fbSdoRead.bError; nErrId:=fbSdoRead.nErrId; Note 1: You will find the NetId if you click your EtherCAT master device in the project tree and select the tab EtherCAT: Note 2: You will find the EtheCAT slave address if you click the 2311 device in the project tree and select the tab EtherCAT: ...
Start the program execution with the F5 key or via PLC → Start and go step for step (F10) through the whole program until you rich the last line. Check if the witten und read values are identical: 5.2 Read of ‘string’ data types Example 3: Read the serial number of 2311 (Index 0x2030, Subindex 11): ...
Page 20
END_VAR fbSdoRead(sNetId:= sNetId, nSlaveAddr :=nSlaveAddr, nIndex:=nIndex, nSubIndex :=nSubIndex, pDstBuf:= ADR(abSerial), cbBufLen:=11, bExecute:=TRUE); bError:=fbSdoRead.bError; nErrId:=fbSdoRead.nErrId; Instert a call for the POU in the MAIN block: Build the Project via Build → Build Solution: Log in PLC → Login, set a break point to the last line and click PLC –> Start (F5) to run the program The serial number is read into the variable ‘abSerial’...
Need help?
Do you have a question about the RESISTOMAT 2311 and is the answer not in the manual?
Questions and answers