Programming Manual
CODESYS for
AS-i Fieldbus Gateways
AC1401/02
AC1411/12
AC1421/22
Firmware release: 3.0.24 and higher
CODESYS release: 3.5.3.6
Contents
>
Cotents
1
Preliminary note
4
1.1
Legal and copyright information ... 5
1.2
The purpose of the document ... 5
1.3
Symbols and formats used ... 6
1.4
Notes on how to get started ... 7
1.5
History of the instructions ... 7
2
Safety instructions
8
2.1
Required background knowledge ... 9
2.2
Please note! ... 9
2.3
Start-up behaviour of the controller...10
2.4
Tampering with the unit ...10
3
System requirements
11
3.1
Hardware ...12
3.2
Software ...12
3.3
Licensing ...12
4
Installation
13
4.1
Programming software CoDeSys ...14
4.1.1 Installation of the CODESYS Development System ... 14
4.2
ifm AS-i Package...15
4.2.1 Components of the ifm AS-i package ... 16
5
Target Settings
18
5.1
Create CODESYS project ...19
5.1.1 Create new project with AC14nn ... 20
5.1.2 Add AC14nn to a project ... 22
5.1.3 Overview: Project structure with AC14nn ... 23
5.2
Configure Ethernet interface ...25
5.2.1 Available fieldbus stacks ... 25
Contents
7.3
Access input and output data ...35
7.3.1 Options to access input and output data ... 36
7.3.2 Validity of the interface data ... 36
7.3.3 Process data of the AS-i slaves ... 37
7.3.4 Fieldbus data ... 39
7.4
Use functions of the ifm AS-i package ...41
7.4.1 Control interface of the ifm function blocks ... 41
7.4.2 Configure system ... 44
7.4.3 Configure AS-i master ... 44
7.4.4 Configure AS-i slaves ... 44
7.4.5 Manage AS-i network ... 45
7.4.6 Send commands to the system and the AS-i master ... 47
7.5
Use web visualisations ...48
7.5.1 Notes on web visualisations ... 49
7.5.2 Add web visualisation to a project ... 49
7.5.3 Create web visualisation... 50
7.5.4 Configure web visualisation ... 51
7.6
Testing the PLC application ...53
8
Operation
54
8.1
Activate CODESYS PLC ...55
8.2
Load application on AC14nn ...56
8.3
Operating states of the CODESYS PLC ...57
8.3.1 Display current operating state ... 57
8.3.2 Switch operating states ... 58
8.4
Reset ...60
8.4.1 Supported reset variants ... 61
8.4.2 Reset PLC application ... 61
8.5
Display web visualisation ...62
8.6
Delete application from AC14nn ...63
9
Annex
64
9.1
ifm AS-i function libraries ...65
9.1.1 ACnnnn_Utils.library ... 66
9.1.2 ACnnnn_SYS_CMD.library ... 128
9.2
Acyclic data records ...137
9.2.1 Overview: Acyclic data sets ... 137
9.2.2 Description of the data records (DSx)... 138
9.3
Command channels ...168
9.3.1 Principle of the command channels ... 169
9.3.2 System commands ... 170
Preliminary note Legal and copyright information
1
Preliminary note
Legal and copyright information ... 5
The purpose of the document ... 5
Symbols and formats used ... 6
Notes on how to get started... 7
History of the instructions ... 7
14801Preliminary note Legal and copyright information
>
1.1
Legal and copyright information
6088
© All rights reserved by ifm electronic gmbh. No part of this manual may be reproduced and used
without the consent of ifm electronic gmbh.
All product names, pictures, companies or other brands used on our pages are the property of the respective rights owners:
• AS-i is the property of the AS-International Association, (
www.as-interface.net
)
• CAN is the property of the CiA (CAN in Automation e.V.), Germany (
www.can-cia.org
)
• CODESYS™ is the property of the 3S – Smart Software Solutions GmbH, Germany (
www.codesys.com
)
• DeviceNet™ is the property of the ODVA™ (Open DeviceNet Vendor Association), USA (
www.odva.org
)
• EtherNet/IP
®is the property of the
ODVA™
• IO-Link
®(
www.io-link.com
) is the property of the
PROFIBUS Nutzerorganisation e.V., Germany
• Microsoft
®is the property of the Microsoft Corporation, USA (
www.microsoft.com
)
• PROFIBUS
®is the property of the PROFIBUS Nutzerorganisation e.V., Germany (
www.profibus.com
)
• PROFINET
®is the property of the
PROFIBUS Nutzerorganisation e.V., Germany
• Windows
®is the property of the
Microsoft Corporation, USA
>
1.2
The purpose of the document
18872
This document applies to the following products from ifm electronic:
AS-i Profinet Gateway (art. no. AC1401/AC1402), firmware version 3.0.24 or higher
AS-i Profibus Gateway (art. no. AC1411/AC1412), firmware version 3.0.24 or higher
AS-i EtherNet/IP Gateway (art. no. AC1421/AC1422), firmware version 3.0.24 or higher
This document describes the integration, configuration and programming of the PLC runtime system
"CODESYS Runtime" of the above-mentioned device with the aid of the PLC programming software
"CODESYS Development System" and the following software component provided by ifm electronic:
Package file "CoDeSys for ifm ASinterface products" (
ifm_AC14nn_AC4nnS_1_1_0_3.package
)
This document is to complement the following documentations:
Document Manufacturer
User documentation CODESYS V3, installation and first steps 3S-Smart Software Solutions GmbH
Preliminary note Symbols and formats used
>
1.3
Symbols and formats used
15989
WARNING
Death or serious irreversible injuries may result.
CAUTION
Slight reversible injuries may result.
NOTICE
Property damage is to be expected or may result.
Important note
Non-compliance can result in malfunction or interference
Information
Supplementary note
► ...
Request for action
>
...
Reaction, result
...
"see"
abc
Cross-reference
123
0x123
0b010
Decimal number
Hexadecimal number
Binary number
Preliminary note Notes on how to get started
>
1.4
Notes on how to get started
16940
For information about the hardware and software requirements see section
System requirements
( page
11
).
Familiarise yourself with the programming software CODESYS version 3.5.3.6!
The installation of the programming software CODESYS Development System 3.5.3.6 and of the ifm
AS-i package are described in section
Installation
( page
13
).
Information on the integration of the project into a CODESYS project is given in section
Target
Settings
( page
18
).
Information about the programming of the device-internal CODESYS PLC and about the use of the
functions of the ifm AS-i package is given in section
PLC programming
( page
31
).
Information about the permanent operation of the unit and the control of the PLC applications are
contained in section
Operation
( page
54
).
The detailed reference of the ifm AS-i function blocks (FB) is given in section
ifm AS-i function libraries
( page
65
) in the Appendix.
>1.5
History of the instructions
17986
Issue Topic Date
1.0 New creation of the document 19 Aug 2014
1.0.1 Correction of the available fieldbus stack for the configuration interface (Available fieldbus stacks ( page 25))
29 Aug 2014
1.0.2 Correction of required CODESYS edition (Software (12)) 18 Feb 2015
1.0.3 Correction of description of the system command 267 in command overview (Overview: system commands (170))
Safety instructions History of the instructions
2
Safety instructions
Required background knowledge ... 9
Please note! ... 9
Start-up behaviour of the controller ...10
Tampering with the unit ...10
213Safety instructions Required background knowledge
>
2.1
Required background knowledge
13323
This document is intended for people with knowledge of control technology and PLC programming
with IEC 61131-3.
To program the PLC, the people should also be familiar with the CODESYS software.
This document is intended for specialists. Specialists are people who, based on their relevant training
and experience, are capable of identifying risks and avoiding potential hazards that may be caused
during operation or maintenance of the product. The document contains information about the correct
handling of the product.
► Read this document before use to familiarise yourself with operating conditions, installation and
operation. Keep this document during the entire duration of use of the device.
► Follow the safety instructions.
>2.2
Please note!
6091 11212
No characteristics are warranted with the information, notes and examples provided in this manual.
With the drawings, representations and examples given no responsibility for the system is assumed
and no application-specific particularities are taken into account.
► The manufacturer of the machine/equipment is responsible for ensuring the safety of the
machine/equipment.
► Follow the national and international regulations of the country in which the machine/installation is
to be placed on the market!
WARNING
Non-observance of these instructions can lead to property damage or bodily injury!
ifm electronic gmbh does not assume any liability in this regard.
► The acting person must have read and understood the safety instructions and the corresponding
chapters in this manual before working on and with this device.
► The acting person must be authorised to work on the machine/equipment.
► The acting person must have the qualifications and training required to perform this work.
► Adhere to the technical data of the devices!
Safety instructions Start-up behaviour of the controller
2.3
Start-up behaviour of the controller
6827 15233
WARNING
Danger due to unintentional and dangerous start of machine or plant sections!
► When creating the program, the programmer must ensure that no unintentional and dangerous
start of machines or plant sections after a fault (e.g. e-stop) and the following fault elimination can
occur!
Realise restart inhibit!
► In case of an error, set the outputs concerned to FALSE in the program!
A restart can, for example, be caused by:
• voltage restoration after power failure
• reset after watchdog response because of too long a cycle time
• error elimination after an E-stop
To ensure a safe behaviour of the controller:
► monitor the voltage supply in the application program.
► In case of an error switch off all relevant outputs in the application program.
► Additionally monitor relay contacts which can cause hazardous movements in the application
program (feedback).
► If necessary, ensure that welded relay contacts in the application project cannot trigger or continue
hazardous movements.
► Additionally monitor relay contacts which can cause hazardous movements in the application
program (feedback).
► If necessary, ensure that welded relay contacts in the application project cannot trigger or continue
hazardous movements.
>
2.4
Tampering with the unit
System requirements Tampering with the unit
3
System requirements
Hardware ...12
Software...12
Licensing...12
16903System requirements Hardware
>
3.1
Hardware
16904
Device of the AC14nn product family, firmware V3.0.24 or higher
PC/laptop ( system requirements CODESYS development system V3.x)
Ethernet connection between CODESYS-PC/laptop and configuration interface (X3) of the
AC14nn ( device manual, section
Configuration interface: Connection concepts
)
>
3.2
Software
16905
To program the device-internal PLC of the ifm AS-i fieldbus gateways (AC14nn), the following software
components are required:
Programming software CODESYS Development System, version 3.5.3.6
www.3s-software.com
Package file "CoDeSys for ifm ASinterface products" (
ifm_AC14nn_AC4nnS_1_1_0_3.package
)
www.ifm.com/ifmde/web/asi-download.htm
>
3.3
Licensing
16906
All models of the device family AC14nn, to be programmed using the CODESYS Development System
V3.x, must be licensed. A valid license label can be purchased via ifm's website.
Article description Article no.
1x CODESYS V3 license AC14nn E71400
Use of the device-internal CODESYS PLC of AC14nn without valid license constitutes a
violation of applicable law!
Installation Licensing
4
Installation
Programming software CoDeSys ...14
ifm AS-i Package ...15
17146Installation Programming software CoDeSys
>
4.1
Programming software CoDeSys
7282
The CODESYS Development System (short: CODESYS) serves as platform for the creation of PLC
applications according to the standard IEC 61131-3.
>
4.1.1
Installation of the CODESYS Development System
18596
To install the software "CODESYS Development System":
Installation ifm AS-i Package
>
4.2
ifm AS-i Package
Components of the ifm AS-i package ...16
Install ifm AS-i package ...16
Update ifm AS-i package ...17
Uninstall the ifm AS-i package ...17
17679► Familiarise yourself with the following CODESYS functions:
Use of the Package Manager
Online help > Menu Commands sorted by Categories > Installation > Package
Manager
Installation ifm AS-i Package
>
4.2.1
Components of the ifm AS-i package
17550
ifm provides the package "CODESYS for ASinterface Products" (short: ifm AS-i package) for the
CODESYS programming software. It contains the following components:
Component Description Reference
AC14nn.devdesc.xml Device description file of the AC14nn basic module
ACnnnn_EthernetAdapter.devdesc.xml Device description file of the Ethernet interface
ACnnnn_EtherCAT.devdesc.xml Device description file for an EtherCat fieldbus interface for the extension of the Ethernet interface.
ACnnnn_Utils.library Function library with AC14nn specific CODESYS function blocks and
data structures
ACnnnn_SYS_CMD.library Function library with function block for access to the command interface
of AC14nn from a CODESYS application
>
Install ifm AS-i package
7283
To install the package "CODESYS for ifm AS-interface products":
1 Download the current version of the ifm AS-i package
►
Access the AS-i download area on ifm's website.
(
www.ifm.com
> Service > Download > Industrial communication)
►
Download file
ifm_AC14nn_AC4nnS_1_1_0_3.package
and save it on the CODESYS PC/notebook.
2 Install the ifm AS-i package in CODESYS
►
Start CODESYS with administrator rights.
►
Access the package manager with [Tools] > [Package Manager].
>
Window [Package Manager] is displayed.
►
Start the installation dialogue with [Install new packages].
►
Select the downloaded ifm AS-i package and carry out a complete installation.
Installation ifm AS-i Package
>
Update ifm AS-i package
12267
To update an installed package "CoDeSys for ifm AS-Interface products":
1 Uninstall the old version of the ifm AS-i package
►
Uninstall the ifm AS-i package
(
page
17
)
2 Install a new version of the ifm AS-i package
►
Install ifm AS-i package
(
page
16
)
3 Update device libraries
►
Device window: Mark [Device (AC14nn)] in the project tree.
►
Activate [Project] > [Update Device].
>
Window [Update Device] appears.
►
Start the update process with [Update Device].
>
New device libraries are loaded.
>
Project tree view is updated.
►
Close the Package Manager with [Exit].
►
Save the project.
>
Uninstall the ifm AS-i package
12270
To uninstall the package "CODESYS for ifm AS-interface products":
►
Access the package manager with [Tools] > [Package Manager].
>
Window [Package Manager] shows the installed packages.
►
Activate [Display version] checkbox.
>
The window shows the version numbers of the installed packages.
►
Tick the package version to be uninstalled and uninstall with [Uninstall ...].
>
The marked package version is uninstalled.
Target Settings ifm AS-i Package
5
Target Settings
Create CODESYS project ...19
Configure Ethernet interface...25
17034Target Settings Create CODESYS project
>
5.1
Create CODESYS project
Create new project with AC14nn ...20
Add AC14nn to a project ...22
Overview: Project structure with AC14nn ...23
17129
► Familiarise yourself with the following CODESYS functions!
CODESYS project
Online help > Concepts and Base Components > Project
Device, device tree
Online help > Concepts and Base Components > Device, Device tree
Application
Online help > Concepts and Base Components > Application
Library manager
Online help > Concepts and Base Components > Library manager
Target Settings Create CODESYS project
>
5.1.1
Create new project with AC14nn
17130
To create a CODESYS project with an AC14nn:
1 Adjust project attributes
►
Use [File] > [New Project...] to start the setup dialogue.
>
Window for project attributes configuration.
►
Set the following values:
1. [Templates]: [Standard project] to be highlighted.
Target Settings Create CODESYS project
2 Select device and programming language
>
Dialogue window for device selection appears.
►
Set the following values:
1. [Device]: Select
AC14nn (ifm electronic)
.
2. [PLC_PRG in]: Select PLC programming language (
Supported programming languages
(
page
32
)).
►
Use [OK] to confirm the entered values.
>
CODESYS creates a project with the AC14nn.
Target Settings Create CODESYS project
>
5.1.2
Add AC14nn to a project
17131
To add a AC14nn to an existing CODESYS project:
1 Open project
►
Open a stored project.
2 Add AC14nn to the project
►
In the project tree: Highlight Wurzelknoten (= project name).
►
Use [Project] > [Add Device...] to start the configuration dialogue.
►
Dialogue window for device selection appears.
►
Set the following values:
1. [Name]: Enter device designation.
2. [Action]: Activate [Append Device] checkbox.
3. [Vendor]: Select
ifm electronic
.
4. In the list: Highlight
AC14nn
.
►
Use [Add Device] to confirm the entered values.
►
Use [Close] to close the dialogue window.
Target Settings Create CODESYS project
>
5.1.3
Overview: Project structure with AC14nn
17132
A CODESYS project contains all components for the programming and administration of PLC
applications. All components of a project are shown in the window [Devices] in a hierarchic tree view.
CODESYS projects with an AC14nn have the following structure:
[MyProject] is the name of the CODESYS project
[Device (AC14nn)] represents the AC14nn in the CODESYS project.
[PLC Logic] contains the PLC applications to be executed.
Target Settings Create CODESYS project
Interface [Ethernet] represents the Ethernet adapter of the device.
Target Settings Configure Ethernet interface
>
5.2
Configure Ethernet interface
Available fieldbus stacks ...25
Add fieldbus stack ...26
17701► Familiarise yourself with the following CODESYS functions!
Menu command "Attach device"
Online help > Menu Commands sorted by Categories > Devices > Attach Device...
Configure EtherCAT (master)
Online help > Device Editors > EtherCAT Configuration Editor
Configure modbus TCP (master/slave)
Online help > Device Editors > Modbus Configuration Editor
>
5.2.1
Available fieldbus stacks
18518
The Ethernet internet (X3) of the device can be declared and operated as an additional fieldbus
interface. For this, a fieldbus stack must be assigned to the interface in CODESYS. Presently, the
device supports the following fieldbus stacks:
Designation Fieldbus Manufacturer
EtherCAT Master EtherCAT 3S - Smart Software Solutions GmbH
Modbus TCP Master Modbus TCP 3S - Smart Software Solutions GmbH
Modbus TCP Slave Modbus TCP 3S - Smart Software Solutions GmbH
Target Settings Configure Ethernet interface
>
5.2.2
Add fieldbus stack
17702
To declare the Ethernet interface as a fieldbus interface:
1 Create/load CODESYS project
►
Create or load CODESYS project with AC14nn.
2 Add fieldbus stack
►
Windows [Devices]: Highlight [Ethernet] in the project tree and use [Project] > [Add Device...] to show the
configuration dialogue.
>
Window shows configuration options for Ethernet interface.
►
Set the following values:
1. Field [Name]: Enter name of the fieldbus stack.
2. Group [Action]: Select [Append Device] radio button.
3. List [Vendor]: Select [<All vendors>].
4. Highlight requested fieldbus stack.
PLC configuration Configure Ethernet interface
6
PLC configuration
Configure AC14nn controller ...28
18498
► Familiarise yourself with the following CODESYS functions!
Generic device editor
Online help > Device Editors > Generic Device Editor
PLC configuration Configure AC14nn controller
>
6.1
Configure AC14nn controller
18519
To access the configuration options of the device-internal PLC:
►
In the project tree: Double-click on [Device (AC14nn)].
>
Editor window shows tab [Device] with the configuration options for the device-internal PLC:
>
6.1.1
Communication settings
18494
The [Device] > [Communication Settings] tab offers options for the adjustment of the connection
between the CODESYS programming software and the AC14nn.
>
Configure connection with AC14nn
18500
To configure the connection between CODESYS programming software and the AC14nn:
1 Preparations
►
Connect CODESYS PC/laptop and configuration interface (X3) of the device.
►
Optional: Adjust IP settings of the Ethernet interfaces.
2 Select gateway
►
In the editor window: Select [Device] > [Communication Settings] tab.
PLC configuration Configure AC14nn controller
3 Search AC14nn in the network
►
Highlight [Gateway-1].
►
Browse the network for accessible devices with the button [Scan network].
>
CODESYS browses the Ethernet network of the selected gateway.
>
If successful: Window displays AC14nn with active IP address.
>
If not successful: Check Ethernet connection and IP settings and repeat process.
4 Set active communication path
►
Highlight AC14nn and activate the button [Set active path].
>
AC14nn contains the attribute (active) and will be highlighted (font weight bold)
PLC configuration Configure AC14nn controller
>
6.1.2
Applications
18495
The [Device] > [Applications] tab offers display and administration options for applications that are
stored on the AC14nn.
>
Display stored applications
18496
To display applications stored on the AC14nn:
►
set communication channel to the AC14nn.
(
Configure connection with AC14nn
(
page
28
))
►
In the editor window: Select [Device] > [Applications] tab.
►
Read the applications stored on the device with [Refresh List].
>
Editor window shows the list of applications stored on the AC14nn.
>
Delete applications on the device
18497
To delete one or several applications on the AC14nn:
►
Display applications on the device (
Display stored applications
(
page
30
)).
►
Delete all applications on the device with [Remove All].
OR
Highlight applications in question and delete them with [Remove] on the device.
>
A success message appears.
PLC programming Configure AC14nn controller
7
PLC programming
Supported programming languages ...32
Create PLC application ...33
Access input and output data ...35
Use functions of the ifm AS-i package ...41
Use web visualisations ...48
Testing the PLC application...53
7074
► Familiarise yourself with the programming according to the standard IEC 61131-3!
Create example program
Online help > Quickstart > Create and run a project
► Familiarise yourself with the following CODESYS functions!
Program editor
Online help > Editors > Editors for the IEC Programming Languages and CFC
Programming reference
Online help > Programming Reference
Menu commands for programing
Online help > Menu Commands sorted by Categories > FBD/LD/IL
Function libraries
Online help > Libraries
PLC programming Supported programming languages
>
7.1
Supported programming languages
18034
The following table shows which programming languages according to IEC 61131 are supported by
the ifm function libraries:
Library Funct ion B lock D ia gra m (F BD ) S e que nt ia l Fu nct ion C har t (S FC ) I nst ruc ti on L is t (I L) C ontin uous Funct ion C har t (C F C ) Ladde r D ia gra m ( LD ) S truc ture d T e x t (S T) ACnnnn_Utils.library X X X X X X ACnnnn_SYS_CMD.library X X X X X X
PLC programming Create PLC application
>
7.2
Create PLC application
17691
To create a PLC application:
►
Windows [Devices]: Double-click on [PLC_PRG] in the project tree
>
Editor window shows programming surface:
>
7.2.1
Use remanent variables
18522
The CODESYS PLC of the AC14nn supports the use of remanent variables. Variables declared with
VAR RETAIN are stored in a memory area that is also maintained when the device is switched off.
The declaration of a variable as RETAIN also influences its behaviour when the PLC application is
reset (
Supported reset variants
( page
61
)).
>
7.2.2
Use complex variables
18528
There are different complex variables (STRUCT) at the programmer's disposal. They bundle logically
associated data sets. Thereby, they facilitate the organisation of the data storage in the application
and at the same time reduce the error rate when variables are declared.
PLC programming Create PLC application
7.2.3
Task configuration
18412
NOTICE
Risk of reduced device performance!
The basic settings of the task properties can cause high system utilisation in case of extensive
applications or projects with several tasks. This can lead to a poor device performance with unwanted
system behaviour.
► Set the type of the corresponding task to "Freewheeling" in the task configuration!
To change the type of task:
►
Windows [Devices]: In the project tree, double-click on [Task Configuration] > [Name_of_the_Task]
>
Editor window shows the configuration of the selected task.
►
Select [Type] the value [Freewheeling] in the list
PLC programming Access input and output data
>
7.3
Access input and output data
Options to access input and output data ...36
Validity of the interface data ...36
Process data of the AS-i slaves ...37
Fieldbus data ...39
17447
► Familiarise yourself with the following CODESYS functions!
Addresses according to IEC standard 61131-3:
Online help > Programming Reference > Operanden > Addresses > Address
Access to IEC address via AT declaration:
Online help > Programming Reference > Declaration > AT Declaration
Definition of an ALIAS for an IEC address:
Online help > Programming Reference > Data Types > User defined Data Types >
References
coupling of a program variable to an address (mapping):
Online help > Device Editors > Generic Device Editor > I/O Mapping
PLC programming Access input and output data
>
7.3.1
Options to access input and output data
17621
In a CODESYS project, each input and output has a physical address according to the IEC standard
(e.g. %IW5). CODESYS offers the following options to access this address from a PLC application and
thereby to access the input and outputs data of the device:
Access to IEC address via AT declaration
Definition of an ALIAS for an IEC address
Link a program variable to an IEC address (mapping)
>7.3.2
Validity of the interface data
18413
In order to facilitate the access to inputs and outputs of peripheral devices, AC14nn projects offer
clearly defined interfaces (
Overview: Project structure with AC14nn
( page
23
)).
Depending on the active controller instance of the outputs of the AS-i slaves (manually, gateway,
PLC), the CODESYS data mapper only updates certain interfaces.
The following table shows which interfaces in the project tree the programmer can access and read in
the individual operating modes (e.g. for variable linking):
Controller instance Active I/O interfaces
Manual Fieldbus_Interface AS-i 1 Out (%I)
AS-i 2 Out (%I)
ASi_Master_1 AS-i 1 IN (%I)
ASi_Master_2* AS-i 2 IN (%I)
Gateway Fieldbus_Interface AS-i 1 Out (%I)
AS-i 2 Out (%I)
ASi_Master_1 AS-i 1 IN (%I)
ASi_Master_2* AS-i 2 IN (%I)
PLC Fieldbus_Interface AS-i 1 Out (%I)
AS-i 2 Out (%I)
ASi_Master_1 AS-i 1 IN (%I)
PLC programming Access input and output data
>
7.3.3
Process data of the AS-i slaves
17584
The project tree offers direct access to the cyclically updated process images of the inputs and outputs
of the AS-i slaves.
Digital input and output data of the slave at
AS-i master 1
Analogue input and output data of the slaves at
AS-i master 1
Consider validity of the interface data (
Validity of the interface data
( page
36
))!
The function library
ACnnnn_Utils.library
contains the complex variable
ASi_NET
. The
variable represents all inputs and outputs of a completely developed AS-i network. The
programmer can use this data structure to store the process images of the inputs and outputs
of an AS-i network. (
ASI_NET (STRUCT)
( page
124
))
>
Digital input and output data
17625
To access the digital process data of the slaves at AS-i master 1:
►
In the project tree: Double-click on [ASi_1_binaryIO]
PLC programming Access input and output data
>
Analogue input and output data
17626
To access the analogue process data of the slaves at AS-i master 1:
►
In the device tree: Double-click on [ASi_1_analogIO]
>
Editor window shows a structured list of the analogue inputs and outputs of the AS-i slaves.
►
In column [Variable]: Mouse click on to make individual variables visible.
To access the analogue process data of the slaves atAS-i Master2 in a system with 2 AS-i masters:
►
Double-click on [ASi_2_analogIO]
PLC programming Access input and output data
>
7.3.4
Fieldbus data
17585
The device tree offers direct access to the data that is transmitted between fieldbus and device.
Data that the fieldbus transmits/receives via the
fieldbus.
Output data of the AS-i slaves that is transmitted
by the higher-level fieldbus PLC.
Consider validity of the interface data (
Validity of the interface data
( page
36
))!
>
Input and output data of the fieldbus interface
17619
The input and output data of the fieldbus interface os transmitted in cycles of 120 words each. The
programmer can access this data via IEC addresses.
To access the input and output data of the fieldbus interface:
►
Device window: In the project tree, double-click on [FieldBusData_]
>
Editor window shows a structured list of the inputs and outputs:
►
In column [Variable]: Mouse click on to make individual variables visible.
>
Output data of the AS-i slaves
17620
If the device is operated as a fieldbus gateway (output control = gateway), the fieldbus controller
sends the output data of the AS-i slaves in cycles via the fieldbus. The data is structure like an AS-i
PLC programming Access input and output data
>
Digital output data
17630
To access the digital output data of the slaves at AS-i master 1:
►
Device window: In the project tree, double-click on [ASi_1_binaryOut]
>
Editor window shows a structured list of the digital output data:
►
In column [Variable]: Mouse click on to make individual variables visible.
To access the digital output data of the slaves at AS-i master 2 in a system with 2 AS-i masters:
►
Double-click on [ASi_2_binaryOut]
>
Analogue output data
17631
To access the analogue output data of the slaves at AS-i master 1:
►
Device window: In the project tree, double-click on [ASi_1_analogOut]
>
Editor window shows the structured list of the analogue output data:
►
In column [Variable]: Mouse click on to make individual variables visible.
To access the analogue output data of the slaves at AS-i master 2 in a system with 2 AS-i masters:
PLC programming Use functions of the ifm AS-i package
>
7.4
Use functions of the ifm AS-i package
18489
The CODESYS package "CoDeSys for ifm ASinterface products" offers different functions for the
programming of the device-internal CODESYS controller. In the following paragraphs, these functions
will be briefly described. To make orientation easier, the functions are grouped according to
corresponding subjects and provided with a cross-reference to a detailed explanation in the
document's appendix.
>
7.4.1
Control interface of the ifm function blocks
17660
All function blocks (FB) of the libraries ACnnnn_Utils.library and ACnnnn_SYS_CMD.library have
inputs and outputs for control signals. The inputs activate the execution of the function block. The
outputs provide information about the internal condition of the function block. Thanks to the signals,
the programmer can create a control structure for a targeted processing of the FB and react to
possible errors.
Number and designation of the FB control signals provide information about the type of FB execution:
>FB with one-time execution
17140
These function blocks perform their function exactly once after activation. To execute the function
once again, the FB needs to be reactivated. FBs of this kind feature a control interface with the
following inputs and outputs:
Designation Type Data type Description Possible values
xExecute Input BOOL Control FB execution FALSE = Stop FB execution
TRUE = Start FB execution
xReady Output BOOL Indication of whether execution of
the FB has been completed
FALSE = FB execution not yet completed
TRUE = FB execution completed
xBusy Output BOOL Indication of whether FB is active FALSE = Function block is inactive
TRUE = FB is active
xError Output BOOL Indication of whether faults have
occurred during execution of the FB
FALSE = FB executed correctly
TRUE = Error occurred during execution of the FB
PLC programming Use functions of the ifm AS-i package
The following figure shows the relation between the connections of the control signals:
xExecute = TRUE:
xBusy = TRUE:
Rising edge (FALSE
TRUE) starts execution of the FB.
FB execution has been started, but has not yet been completed.
xReady = TRUE:
xBusy = FALSE:
xError = FALSE:
FB execution completed; there are valid values on the data outputs.
FB is no longer active.
FB execution without faults.
xExecute = FALSE:
All signal outputs are set to FALSE and all internal states are reset.
xReady = TRUE:
xBusy = FALSE:
xError = TRUE:
FB execution is terminated.
FB is no longer active.
Errors occurred during FB execution; wDiagnostic provides error code.
xExecute = FALSE:
FB execution interrupted prior to completion; All signal outputs are set to FALSE and all
internal states are reset.
PLC programming Use functions of the ifm AS-i package
>
FB with cyclic execution
17141
Function blocks which, when activated, cyclically perform their function until they are deactivated have
the following control inputs and outputs:
Designation Type Data type Description Possible values
xEnable Input BOOL Control FB execution FALSE = Stop FB execution
TRUE = Start FB execution
xActive Output BOOL Indication of whether execution of
the FB has been completed
FALSE = FB execution not yet completed
TRUE = FB execution completed
xError Output BOOL Indication of whether faults have
occurred during execution of the FB
FALSE = FB executed correctly
TRUE = Error occurred during execution of the FB
wCycleCount Output WORD Counters for the FB cycles Integer value (hexadecimal representation)
wDiagnostic Output WORD Error code FB specific
PLC programming Use functions of the ifm AS-i package
>
7.4.2
Configure system
17450
To configure the system of the device, use the following function blocks:
Function block Description Reference
QuickSetupASi_Master Execute quick setup routine on an AS-i master QuickSetupASi_Master
( page 115)
Set_TimeDate Set system time (date, time) of the system Set_TimeDate ( page 117)
Get_FieldbusInfo Read fieldbus type, the status of the field bus connection and the parameters of the fieldbus interface
Get_FieldbusInfo ( page 113)
>
7.4.3
Configure AS-i master
17448
To configure the AS-i master(s) of the device, use the following function blocks:
Function block Description Reference
Set_Mode Set operating mode of the AS-i master (projecting mode
or protected operation)
Set_Mode ( page 100)
Set_ASi_Config Set diagnostic functions of the AS-i master (double
address recognition, earth fault detection)
Set_ASi_Config ( page 96)
Set_AdressMode Set automatic addressing of the AS-i master Set_AddressMode ( page 94)
>
7.4.4
Configure AS-i slaves
17449
To configure the AS-i slaves, that are connected to the device, use the following function blocks:
Function block Description Reference
Set_SlaveAddress Change address of an AS-i slave Set_SlaveAddress ( page 104)
Set_SlaveParameter Change I/O configuration and ID codes (IO, ID, ID1, ID2) of an AS-i slave
PLC programming Use functions of the ifm AS-i package
>
7.4.5
Manage AS-i network
17126
To manage the AS-i networks controlled by AC14nn, use the following function blocks:
>
Change network settings
17568
Function block Description Reference
Set_ProjectAll Execute projection adaptation on one AS-i master Set_ProjectAll ( page 103)
Set_LPS Change list of the projected slaves (LDS) Set_LPS ( page 98)
Set_PCD Change permanent projecting data (IO, ID, ID1, ID2) of
all slaves on the AS-i master
Set_PCD ( page 101)
>
Read network settings
18532
To read the network settings cyclically and offer them in the application:
Function block Description Reference
Get_ASi_Data Read the following datasets for network management in
batches and cycles:
List of activated slaves (LAS)
List of detected slaves (LDS)
List of projected slaves (LPS)
List of peripheral faults (LPF)
List of configuration errors (LCE)
List of configuration errors, missing slaves (LCEMS)
List of configuration errors - additional slaves (LCEAS)
List of double address errors (LDAE)
Configuration data image (CDI)
Permanent configuration data (PCD)
Input parameters (PI)
PLC programming Use functions of the ifm AS-i package
>
Read parameter images
17569
Function block Description Reference
Get_InputParameter Read parameters of the inputs of the slaves at the AS-i master (PI)
Get_InputParameter ( page 90) Get_OutputParameter Read parameters of the outputs of the slaves on the AS-i
master (PP)
Get_OutputParameter ( page 92)
>
Read slave lists
18530
Function block Description Reference
Get_LPS Read list of projected slaves (LPS) Get_LPS ( page 74)
Get_LDS Read list of detected slaves (LDS) Get_LDS ( page 72)
Get_LAS Read list of activated slaves (LAS) Get_LAS ( page 70)
Get_LPF Read list of peripheral faults (LPF) Get_LPF ( page 84)
Get_LCE Read list of configuration errors (LCE) Get_LCE ( page 76)
Get_LCEMS List of configuration errors - read missing slaves
(LCEMS)
Get_LCEMS ( page 80)
Get_LCEAS Read of the configuration errors - read additional slave
(LCEAS)
Get_LCEAS ( page 78)
Get_LDAE Read list of double address errors (LDAE) Get_LDAE ( page 82)
>
Read configuration data of the slaves
18533
Function block Description Reference
Get_CDI Read configuration data image (IO, ID, ID1, ID2) of all
slaves on the AS-i master
Get_CDI ( page 86)
Get_PCD Read permanent configuration data of all slaves (IO, ID,
ID1, ID2) on the AS-i master
Get_PCD ( page 88)
>
PLC programming Use functions of the ifm AS-i package
>
7.4.6
Send commands to the system and the AS-i master
17659
Similar to the acyclic transmission command channels and data sets of the device, the programmer
can send commands to the system or an AS-i master with the FB ACnnnn_SysCmd
(
ACnnnn_SysCmd
( page
129
)).
System command overview:
Table: System commands
( page
130
)
Overview AS-i master commands:
Table: AS-i master commands
( page
131
)
By default, the FB ACnnnn_SysCmd is hidden. To add the FB to a program module:
►
Highlight the requested network and add an empty function block with [FBD/LD/IL] > [Insert Empty Block].
>
Network shows empty FB.
►
Double-click on the name field of the FB
►
Enter designation
ACnnnn_SysCmd
and
confirm with [ENTER].
>
FB has inputs and outputs of the
ACnnnn_SysCmd
.
►
Adjust inputs and outputs of the FB in
accordance with the requested command.
PLC programming Use web visualisations
>
7.5
Use web visualisations
Notes on web visualisations ...49
Add web visualisation to a project ...49
Create web visualisation ...50
Configure web visualisation ...51
17059
► Familiarise yourself with the following CODESYS functions!
Visualisation in CODESYS
Online help > Visualization
Web visualisation
Online help > Visualization > Visualization Manager with Clients > The Clients and
their Editors
Task configuration
Online help > Editors > Task Configuration Editor - Task Editor > Configuration
dialogue
PLC programming Use web visualisations
>
7.5.1
Notes on web visualisations
17661
The AC14nn supports web visualisations (WebVisu). A web visualisation offers the possibility to have
a graphic display of process and control data using a web browser.
>
7.5.2
Add web visualisation to a project
17060
To add a web visualisation to a CODESYS project:
►
Open CODESYS project.
OR:
Create new CODESYS project. (
Create new project with AC14nn
(
page
20
))
►
Windows [Devcies]: In the project tree, right-click on [Application]
>
Context menu with options appears.
►
Select [Add Object …] > [Visualization] and use [Add] to create the visualisation.
>
The project tree contains the following additional elements:
VISU_TASK:
Configuration options for the parameters of the
visualisation task (request interval, watchdog, etc.)
Set parameters for visualisation task
(
page
51
)
VisualizationManager:
Administration of several visualisations (determine start
visualisation, change name of the .htm file, adjust
interval for updates)
Change properties of the web visualisation
(
page
52
)
MyWebVisu:
Area for the creation of the web visualisation
PLC programming Use web visualisations
>
7.5.3
Create web visualisation
17061
To create a web visualisation for a PLC application:
►
Windows [Devices]: In the project tree, double-click on [Visualization]
>
The visualisation editor with a tool box appears:
►
Create the visualisation using the tools.
PLC programming Use web visualisations
>
7.5.4
Configure web visualisation
17064
Each web visualisation is executed separately from the program code in a separate task. Take the
following steps to configure the web visualisation:
>
Set parameters for visualisation task
17066
► Execute the visualisation task (VISU_TASK) with a priority that is as low as
possible to avoid interruption of other tasks that are important for the core functions
of the application.
► Execute the VISU_TASK in appropriate cyclic intervals to save the resources of
the device-internal CODESYS PLC of the fieldbus network.
To set the attributes of the visualisation task:
►
In the project tree: Double-click on [VISU_TASK]
>
In the editor window: [VISU_TASK] > [Configuration] tab shows parameters of the WebVisu task:
►
Set the parameters as requested.
PLC programming Use web visualisations
>
Change properties of the web visualisation
17065
To change the attributes of the web visualisation:
►
Device window: In the project tree, double-click on [WebVisualization]
>
Editor window shows attributes of the web visualisation:
►
Set the following values:
1. Field [Start Visualization]: Select the created web visualisation.
2. Field [Name of .htm file]: Enter name of htm. file (
note).
3. Group [Best Fit]: Enter fixed width and height as shown.
Enter the name by which the web visualisation is to be accessible in the web browser in the field [Name
of .htm file] (
Display web visualisation
(
page
62
)).
PLC programming Testing the PLC application
>
7.6
Testing the PLC application
18594
To ensure permanent operation without errors in industrial environments, the created PLC applications
must be tested in detail and possible faults must be remedied.
► Familiarise yourself with the following CODESYS functions!
Test and fault elimination
Online help > Concepts and Base Components > Debugging
Operation Testing the PLC application
8
Operation
Activate CODESYS PLC ...55
Load application on AC14nn ...56
Operating states of the CODESYS PLC ...57
Reset ...60
Display web visualisation ...62
Delete application from AC14nn ...63
18492
► Familiarise yourself with the following CODESYS functions!
Communication between CODESYS and device
Online help > Menu Commands sorted by Categories > Device communication
Translate project/application and transfer to the device
Online help > Menu Commands sorted by Categories > Online
Operation Activate CODESYS PLC
>
8.1
Activate CODESYS PLC
17692
To enable the processing of the created PLC application, the device-internal CODESYS PLC must be
activated in the setup menu of AC14nn.
If the PLC application is to have a write access to the outputs of the AS-i slaves, the CODESYS PLC
must be activated additionally as controller instance of the AS-i slave outputs.
The following table shows the possible combinations of the parameters [Output access] and [Use PLC]
as well as the rights of the CODESYS PLC resulting thereof.
List [Output access] Checkbox [Use PLC] CODESYS PLC Programmable Access to AS-i inputs Access to AS-i outputs Gateway no yes no yes yes no Manual no yes no yes yes no
PLC * yes yes yes
Legend:
* ... Value fixed (greyed out)
To set the operating mode of the AC14nn:
1 Call up menu page
►
Navigation path:
>
►
Select [System settings] tab.
2 Set the controller instance of the outputs
►
Select the requested controller instance of the AS-i outputs in the list [Output access].
►
Use [Accept selection] to activate the selection.
Operation Load application on AC14nn
>
8.2
Load application on AC14nn
18593
To transfer the created PLC application as boot project to the device:
Requirements:
Connection between PC/laptop and AC14nn established (
device manual, appendix:
Configuration interface:
Connection concepts
).
Communication path is set (
Configure connection with AC14nn
(
page
28
)).
Project tested.
1 Translate application
►
In the project tree: highlight application as active application.
►
Use [Build] > [Rebuild] to translate the active application.
>
CODESYS generates program code.
2 Load application on AC14nn
►
Use [Online] > [Login] to connect with the AC14nn.
>
Active application is loaded to AC14nn (download).
>
Application on AC14nn is in STOP state.
3 Create boot application
►
Use [Online] > [Create boot application] to make the application bootable.
>
Application storage is non-volatile.
4 Start application
►
Use [Debug] > [Start] to start the application.
Operation Operating states of the CODESYS PLC
>
8.3
Operating states of the CODESYS PLC
17544
All applications saved on the device are executed in separate tasks independently of each other. If the
device-internal CODESYS PLC is activated, each of these tasks can have the following operating
states:
Operating status Description/characteristics
STOP The PLC application saved on the device is not processed.
RUN The PLC application saved on the device is cyclically
processed.
If the device-internal PLC is activated and at least 1 application is saved on the device,
the PLC automatically goes into the RUN state.
>
8.3.1
Display current operating state
10272
Execute one of the following actions to display the current operating state of the PLC:
CODESYS:
>
Application node in the project tree shows the status:
Connection with CODESYS PLC established.
PLC application is in the STOP state.
Connection with CODESYS PLC established.
PLC application is in the RUN state.
GUI / web interface of the device:
Operation Operating states of the CODESYS PLC
>
8.3.2
Switch operating states
10264
Select one of the following actions to switch between the operating states:
>
Start PLC application
18027
To start a PLC application stored on the device:
CODESYS:
►
In the project tree: highlight application as active application.
►
Use [Online] > [Login] to establish the connection with the CODESYS PLC.
►
Use [Debug] > [Start] to start the processing of the active application.
>
Application goes into RUN state.
►
Optional: repeat process for further applications.
GUI / web interface:
►
Navigation path:
>
>
►
Select [Applications] tab.
►
Use [
] / [
] to select the requested application.
>
Page shows the operating status of the selected application.
►
Use [Start] function key to start the processing of the selected application.
>
Application goes into RUN state.
Operation Operating states of the CODESYS PLC
>
Stop PLC application
18029
To stop a PLC application stored on the device:
CODESYS:
►
In the project tree: highlight application as active application.
►
Use [Online] > [Login] to establish the connection with the CODESYS PLC.
►
Use [Debug] > [Stop] to stop the processing of the active application.
>
Application goes into STOP state.
►
Optional: repeat process for further applications.
GUI / web interface:
►
Navigation path:
>
>
►
Select [Applications] tab.
►
Use [
] / [
] to select the requested application.
>
Page shows the operating status of the selected application.
►
Use [Stop] function key to stop the processing of the selected application.
>
Application goes into STOP state.
Operation Reset
>