Beckhoff El5021
Beckhoff El5021
Beckhoff El5021
Example program
Using the sample programs
Attention
This publication contains statements about the suitability of our products for certain areas of
application. These statements are based on typical features of our products. The examples
shown in this publication are for demonstration purposes only. The information provided
herein should not be regarded as specific operation characteristics. It is incumbent on the
customer to check and decide whether a product is suitable for use in a particular
application. We do not give any warranty that the source code which is made available with
this publication is complete or accurate. This publication may be changed from time to time
without prior notice. No liability is assumed for errors and/or omissions.
TwinCAT master PC with Windows XP Professional SP 3 as operating system, TwinCAT version 2.11
After clicking the Download button, save the zip file locally on your hard disk, and unzip the *.TSM
(configuration) and the *.PRO (PLC program) files into a temporary working folder
Run the *.TSM file and the *.PRO file; the TwinCAT System Manger and TwinCAT PLC will open
Connect the hardware in accordance with Fig. 1 (other electrical or mechanical switching elements
configured for a normally open function can be used instead of the inductive proximity limit switch), and
connect the Ethernet adapter of your PC to the EtherCAT coupler (you will find further instructions on this in
the corresponding coupler manuals)
Select the local Ethernet adapter (with real-time driver, if appropriate) under System configuration, I/O
configuration, I/O devices, Device (EtherCAT); on the "Adapter" tab choose "Search...", select the
appropriate adapter and confirm (see Fig. 2a + 2b)
In TwinCAT PLC, under the "Project" menu, select "Rebuild all" to rebuild the project (Fig. 5)
In TwinCAT PLC: log in with the "F11" button, confirm loading the program (Fig. 6), run the program with the
"F5" button
Application example
EtherCAT XML Device Description
Note
The display matches that of the CoE objects from the EtherCAT XML Device Description.
We recommend downloading the latest XML file from the download area on the Beckhoff
Website and installing it according to the installation instructions.
Please ensure that the I/O configuration matches your actual configuration. In the sample program only one
EL7041 is integrated. If further terminals are connected you have to add them or re-scan your configuration.
You have to adjust the MAC address. To do this click on your EtherCAT device, then select the Adapter tab
and click onSearch after the MAC address (see Fig. 2). Select the right adapter.
In the PLC configuration you have to adjust the path for the PLC program. Click on the appended PLC
program and select the tab IEC1131 (see Fig. 3). Select Change and enter the correct path.
Under NC configuration an EL7041 is already linked to the NC. To change the link or add additional devices
proceed as described under Integration into the NC configuration.
The PLC program is configured as follows. The libraries TcMC.lib and TcNC.lib must be integrated (see Fig. 4).
Fig. 8: Visualization
Homing
Homing refers to an axis initialisation run during which the correct actual position is determined by means of a
reference signal. This procedure is referred to as homing, referencing or calibration. A switch that is triggered at a
known, unique position along the travel path serves as reference signal. Further signals such as the encoder zero
track can be analysed in order to increase the precision.
In general a distinction is made between drive-controlled homing and NC-controlled homing. Drive-controlled homing
is carried out automatically by a suitable drive without input from the control system and is not discussed in detail in
this documentation. NC-controlled homing is fully controlled by the control system and supports a wide range of drive
types. The different NC-controlled homing mechanisms are described below.
BiSS
EnDat
Hiperface
SSI
BiSS
EnDat
Hiperface
MES (Beckhoff)
Resolver
2.
Homing is initiated, and the axis travels towards the reference cam.
3.
Once the reference cam is detected, the axis stops and reverses.
4.
The axis moves away from the reference cam and detects the falling edge of the reference cam signal.
5.
The axis continues and searches for a sync pulse or another distinctive event, depending on the reference
mode setting. This step may be omitted where appropriate.
6.
7.
The axis stops at a certain distance from the reference position, which was set shortly beforehand with
maximum precision.
Figures B and C show the position and velocity profile during homing.
Referencing modes
The NC system supports different referencing modes, depending on the encoder system type.
configurable reference position to this position. Referencing based on a reference cam is always possible,
irrespective of the encoder type, and is a prerequisite for other, more precise modes.
Software Sync
Software Sync mode enhances the homing precision by additionally detecting the encoder count overflow
after an encoder or motor revolution, after the reference cam signal has been detected. This mode requires
a part-absolute encoder (e.g. resolver) with constant overflow interval relative to the reference cam.
Overflow detection is parameterised via the Reference Mask parameter (see System Manager section).
Hardware Sync
Some encoder systems provide a sync pulse per revolution (zero track) in addition to the count. The homing
precision can be enhanced by selecting this mode, if the encoder evaluation logic is able to pick up the sync
pulse. The precision is comparable with Software Sync. Hardware Sync mode may require parameterisation
or special wiring of the drive or encoder system.
Hardware Latch
Hardware Latch reference mode (Hardware Latch Pos or Hardware Latch Neg, depending on edge) requires
an external digital latch signal for storing the encoder position in the evaluation unit of the encoder system.
The encoder system must support such a latch function and may have to be configured first in order to be
able to utilise this function.
Absolute encoder
system
NC
Recommended reference
modeSoftwareSync
(also possible: PlcCam, HardwareSync)
Recommended reference
modeHardwareSync
(also possible: PlcCam)
Drive
Reference system: The encoder parameters reference system determines whether the encoder system used is
incremental or absolute. In an absolute encoder system the encoder value is taken from the control system without
modification.
Not all NC encoders support this optional parameter, i.e. only those types that offer a choice between
absolute and incremental encoder reference system (measurement system) support it (e.g. SERCOS,
KL5001, M3000, ProfiDrive, Universal). This choice determines whether the actual encoder position is
interpreted and evaluated as an absolute or incremental position, based on an absolute or incremental
reference system (measurement system).
In an absolute reference system no further processing takes place with regard to encoder counter value
overflow or underflow. It is assumed that the counter value is unique within the axis traversing range and
no encoder counter value overflow or underflow occurs. Otherwise there would be a discontinuity in the
actual position, resulting in a position following error. Axis referencing via MC_Home is not possible.
Instead, the actual position is calibrated once via the Position Bias parameter (zero offset / position
offset).
In an incremental reference system axis referencing via MC-Home is generally required. In addition the
NC automatically detects and accounts for encoder counter value overflow or underflow events, so that
continuous axis operation is possible over many months ("infinite range").
Encoder Mask (maximum value): The encoder mask determines the bit width for the incremental encoder position.
The encoder mask is used for detecting and counting in range overflow events.
Scaling Factor: The scaling factor is multiplied with the incremental encoder position (including all overflows) and
used as the basis for calculating an absolute axis position with the parameterised physical unit.
Position Bias (zero offset): Position offset; moves the axis coordinate system relative to the encoder coordinate
system. This value is mainly used in absolute encoder systems. In relative systems an offset is usually not required,
since the system moves to a parameterised reference position after homing.
Invert Encoder Counting Direction: The encoder count direction can be inverted if it does not match the required
logical count and travel direction.
Reference Mode: Referencing mode as described above (Plc CAM, Hardware Sync, Hardware Latch Pos, Hardware
Latch Neg, Software Sync). The default mode corresponds to Plc CAM mode.
The Reference Mode parameter is used to specify the type of reference event (physical or logical event)
for the referencing process. Depending on which referencing mode is parameterised the referencing
procedure is either based on the hardware characteristics of the drive/encoder (e.g. hardware latch),
or the reference event is only detected within the control system, i.e. without additional hardware
reference.
Reference Mask: The reference mask parameterises overflow detection for Software Sync reference mode. It is less
or equal the encoder mask and defines an encoder value range, which is part-absolute. Examples include the bit
width of a motor revolution or the bit width of a sine period in a sine/cosine encoder. Software Sync therefore always
detects the same overflow position in a part-absolute encoder system.
Calibration Value: Reference position to which the axis position is set after homing.
Invert Direction for Calibration Cam Search: The parameter inverts the axis travel direction for searching the
referencing cam during homing. The standard direction is negative, i.e. towards the axis coordinate system origin.
Invert Direction for Sync Impulse Search: The parameter inverts the axis travel direction for searching the sync
pulse during homing.
Ensure that both axes can be moved in coupled mode. (Position comparison is not possible at this stage,
because none of the axes is referenced.)
Start homing for axis 1. Slave axis 2 will travel with axis 1.
Start homing for axis 2. Slave axis 1 will travel with axis 2.
Move both axes to a set position for alignment. The travel path for both axes should be minimal and may
correspond to the mean value from both positions, for example.
Note
Please ensure that you have installed the corresponding latest XML device description in
TwinCAT. This can be downloaded from the Beckhoff website
(http://www.beckhoff.de/german/default.htm?download/elconfg.htm) and installed according
to the installation instructions.
The example program consists of 2 files. On the one hand the PLC file and on the other System Manager file.
First open the PLC file and compile it so that you have the *.tpy file available that is required for the System Manager.
Please note that you may have to adjust the target platform in the PLC program (default: PC or CX 8x86). If required,
you can select the right target platform under tab Resources -> Controller configuration.
Attention must be paid with the System Manager file to the following:
Please ensure that the I/O configuration matches your actual configuration. In the sample program only one
EL7342 is integrated. If further terminals are connected you have to add them or re-scan your configuration.
You have to adjust the MAC address. To do this click on your EtherCAT device, then select the Adapter tab
and click onSearch after the MAC address (see Fig. ). Select the right adapter.
In the PLC configuration you have to adjust the path for the PLC program. Click on the appended PLC
program and select the tab IEC1131 (see Fig. ). Select Change and enter the correct path.
Under NC configuration an EL7041 is already linked to the NC. To change the link or add additional devices
proceed as described under Integration into the NC configuration.
The PLC program is configured as follows. The libraries TcMC.lib and TcNC.lib must be integrated (see Fig. 1).
Fig. 5: Visualisation
Further information on the function blocks and data types used can be found in the Beckhoff
Information System.
Note
Parameterization
The following modes are available for the EL515x. They apply both for the encor analysis and counter terminal mode.
The combination of DC, PDO and CoE settings permissible for each mode is specified below.
EL5151
Mo
de
Featu
res
CoE
DC
Main
PDO
Comme
nt
Optional
PDO 1
Comm
ent
Optional
PDO 2
Comm
ent
FreeR
un
1A00+1
600
Count/L
atch
in 32 bit
1A02 or1
A03
Freque
ncy
(32bit)
or
Period
(32 bit)
--
--
8000:
nn
Combinati
ons of the
CoE
8000:nn
FreeR
un
1A01+1
601
compac
t:
Count/L
atch
in 16 bit
1A02 or1
A03
Freque
ncy
(32bit)
or
Period
(32 bit)
--
--
8000:
nn
Combinati
ons of the
CoE
8000:nn
DC/D
Ci
1A00+1
600
Count/L
atch
in 32 bit
1A02 or1
A03
Freque
ncy
(32bit)
or
Period
(32 bit)
1A04 or1
A05
Timesta
mp 64
bit
Timesta
mp 32
bit
(compa
ct)
8000:
nn
Combinati
ons of the
CoE
8000:nn
DC/D
Ci
1A01+1
601
compac
t:
Count/L
atch
in 16 bit
1A02 or1
A03
Freque
ncy
(32bit)
or
Period
(32 bit)
1A04 or1
A05
Timesta
mp 64
bit
Timesta
mp 32
bit
(compa
ct)
8000:
nn
Combinati
ons of the
CoE
8000:nn
EL5152
Commen
t
Mo
de
DC
Main
PDO
Comm
ent
Optional
PDO 1
Comme
nt
Optio
nal
PDO 2
Comm
ent
Featur
es
CoE
Comment
FreeR
un
1A00+ 1
600
(Ch.1)
1A04+ 1
602
(Ch.2)
Count
in 32 bit
1A02 or1
A03
(Ch.1)
1A06 or1
A07
(Ch.2)
Freque
ncy
(32bit)
or
Period
(32 bit)
--
--
80n0:n
n
Combinati
ons of the
CoE
80n0:nn
FreeR
un
1A00+ 1
600
(Ch.1)
1A04+ 1
602
(Ch.2)
compa
ct:
Count i
n 16 bit
1A02 or1
A03
(Ch.1)
1A06 or1
A07
(Ch.2)
Freque
ncy
(32bit)
or
Period
(32 bit)
--
--
80n0:n
n
Combinati
ons of the
CoE
80n0:nn
DC/D
Ci
1A00+ 1
600
(Ch.1)
1A04+ 1
602
(Ch.2)
Count
in 32 bit
1A02 or1
A03
(Ch.1)
1A06 or1
A07
(Ch.2)
Freque
ncy
(32bit)
or
Period
(32 bit)
--
--
80n0:n
n
Combinati
ons of the
CoE
80n0:nn
DC/D
Ci
1A00+ 1
600
(Ch.1)
1A04+ 1
602
(Ch.2)
compa
ct:
Counti
n 16 bit
1A02 or1
A03
(Ch.1)
1A06 or1
A07
(Ch.2)
Freque
ncy
(32bit)
or
Period
(32 bit)
--
--
80n0:n
n
Combinati
ons of the
CoE
80n0:nn
Other settings may result in irregular process data and lead to error messages in the TwinCAT System Manager
logger window.
EL5151x parameterization
Note
To activate the new operation mode, reload the EtherCAT slaves (button
DC (Distributed Clocks)
FreeRun: The terminal operates frame-triggered. Cyclic operation is started via the SyncManagers of the
EtherCAT frame processing.
DC-Synchron: Cyclic operation in the terminal is started by the local distributed clock at exact intervals. The
start time is chosen such that it coincides with other output slaves in the EtherCAT system.
DC Synchron (input based): As DC Synchron mode, with the cyclic start time chosen such that it
coincides with other input slaves in the EtherCAT system.
Main PDO
Selection of basic process data (example of EL5151):
compact: The process data can be represented with 16 bits (compact) or with 32 bits.
Optional PDOs
Optional PDOs, in addition to the main PDO:
EL5151
PDO 1 (1A02 or 1A03): The frequency or the period can be selected as optional PDO 1
PDO 2 (1A04 or 1A05): In one of the DC modes a 32-bit or 64-bit timestamp can be selected. The
timestamp specifies the time of the last registered increment edge, based on the DistributedClocks system.
EL5152
PDO 1 (1A02 or 1A03 [Ch.1], 1A05 or 1A06 [Ch.2]): The frequency or the period can be selected as
optional PDO 1
Features CoE
Depending on the main PDO/optional PDOs further settings can be selected in the CoE list (CAN over EtherCAT).
Note
Please note the following general CoE information when using/manipulating the CoE
parameters:
- Maintain startup list in case components have to be replaced
- Differentiation between online/offline dictionary, existence of current XML description
- "CoE reload" for resetting changes
The following CoE settings from object 8000 are possible and are shown below in their default settings:
The parameters are described on page object description and parameterization (EL5151 / EL5152).
EL5151 / EL5152
The Objects containing a "n" describe the EL5151 and the EL5152 (with n = 0 for Ch.1; n =
1 for Ch.2)
Note
Frequency
The time window for the frequency calculation and the resolution can be parameterized in CoE
objects 80n0:11,80n0:13, 80n0:15, 80n0:17 .
The positive edges for track A within the specified time window (see frequency modes) and the next edge
including the time until then are counted. The waiting time for the edge can be set in CoE
object 80n0:17 "Frequency Wait Time" (unit: ms). The default value is 1.6 sec. This is also the maximum
value.
The frequency is always specified as a positive number, irrespective of the sense of rotation.
The value of the time window is 10 ms (default), but at least the basic unit in Index 80n0:0F.
This calculation is carried out in the terminal in free-running mode without reference to the distributed clocks
system. It is therefore independent of the DC mode.
EL5151:No frequency measurement is possible if the counter is blocked by the gate. In this case the period
can be measured regardless.
EL5151: A C or external reset restarts the frequency measurement. The last frequency value remains
unchanged until a new frequency value is determined.
Index 80n0:0F is used for switching the basic unit for the Frequency window between 1 s and 1 ms, in
order to adjust the time window for the measurement. The following maximum measuring windows are
therefore possible:
Basic unit
max. time
window
1 s
65.5 ms
1 ms
65 sec
After the measuring window time has elapsed (index 80n0:11), the system waits for the following rising edge
at track A or a maximum of 1.6 sec or the time from index 80n0:17
The precision of the frequency measurement depends on the selected basic unit 8000:0F and the window size.
Frequency mode A
Measurement sequence
- The measurement starts with a rising edge at track A. The current counter value and time (resolution: 100 ns) are
stored.
- After the measuring window time has elapsed (index 80n0:11), the system waits for the following rising edge at track
Frequency mode B
Measurement sequence
- At the start of the measurement the time and the current position are stored with a resolution of 100 ns, irrespective
of the current signal position.
- After the measurement the current position is stored irrespective of the current signal position.
- The frequency is calculated from the number of edges and the actual elapsed time.
- The frequency measurement therefore takes place with reduced accuracy.
- The larger the measuring window in relation to the basic unit, the more precise the frequency calculation.
Period calculation
This calculation is carried out free-running in the slave without reference to the distributed clocks system. It
is therefore independent of the DC mode.
During each cycle the interval between 2 positive edges of input A is counted.
Depending on the setting, the measuring periods can be up to 1.6 or 3.2 s long.
If no edge change occurs for approx. 1.6 s, any period specification is cancelled.
The counter value is saved at the first external latch pulse (positive edge at input "C") after the bit has been
set ("TRUE") in index 7000:01 (has priority before 7000:02 / 7000:04). The subsequent pulses at the other
inputs have no influence on the latch value in index 6000:12 if the bit is set.
Note for "Latch C valid" bit: A new counter value at the latch input can only be written once the value of the
Latch C valid bit (index 6000:01) is FALSE.
Activation of the external latch input ("gate/latch") and latching of the counter value (index 7000:02, 7000:04)
The counter value at the latch input (Index 6000:12) will be saved upon the first external latch pulse with a
rising edge if the bit (TRUE) is set in index 7000:02. The subsequent pulses have no influence on the latch
value in index6000:12.
The counter value at the latch input (Index 6000:12) will be saved upon the first external latch pulse with a
falling edge if the bit (TRUE) is set in index 7000:04. The subsequent pulses have no influence on the latch
value in index6000:12.
Note for "Latch extern valid" bit: A new counter value at the latch input can only be written once the value of
the Latch extern valid bit (index 6000:02) is FALSE.
Counter reset (index 8000:01, 8000:02, 8000:10): For a counter reset via input C set the bit in
index 8000:01, for a reset via the external latch input set the bit in index 8000:02.
The functions "Enable C reset" (8000:01) and "Enable extern reset" (8000:02) cannot be activated
simultaneously.
Note for "Extern reset polarity", index 8000:10: The edge for setting the counter to zero can be selected via
index8000:10.
Bit not set: counter is set to zero with falling edge.
Bit set: counter is set to zero with rising edge.
Up/down counter
The mode (encor or up/down counter) is set via the CoE objects (profile-specific objects, tab CoE - Online,
index80n0:03 "Non-volatile settings"). Click on the corresponding row of the index to be parameterized,
enter 1 in the SetValue dialog and confirm with OK.
Only EL5151: Set the gate polarity accordingly via object 8000:04.
The counting direction (up/down) is specified via the signal level at channel B.
An additional option for reversing the rotation direction is available by setting the bit in index 80n0:0E.
Connection:
Micro-increments
Works with and without distributed clocks, but in the EL5151 this is only meaningful in conjunction with one
of the DC modes
By setting the counter value only the integer component can be modified.
The principle:
Underrunning of the minimum velocity is indicated by the object 60n0:08 (extrapolation stall) in the process
data.
Digital filter (from firmware 02)
The EL515x provides a switchable digital filter (CoE x80n0:08) for the encoder channels A and B. This filter works as
a diffuse low-pass filter at approx. 400 kHz, the permitted limit frequency
You have to check for the particular application, if it is advantageous to deactivate the filter. Fast axis movements
should be better detected in this case.