SMP Gateway SoftPLC Reference Manual
SMP Gateway SoftPLC Reference Manual
MN912020EN, version 6
MN912020EN, version 6
EAS-SA QF-MKT-02 Rev.02
Contents
1 Introduction 1
1.1 Intended Audience .................................................................................................1
1.2 Overview ...............................................................................................................2
1.3 Related Documentation .........................................................................................2
1.4 Getting Assistance .................................................................................................3
2 Principles of Operation 5
2.1 The CODESYS Environment ................................................................................5
2.1.1 Supported Version of CODESYS ...........................................................5
2.1.2 Legacy Versions Support ........................................................................5
2.1.3 Installing many CODESYS versions on a single computer ....................5
2.2 The SMP Gateway as an IEC 61131-3 Device ......................................................6
2.2.1 The SoftPLC (CODESYS) Component ..................................................6
2.2.2 SMP Config and the SMP Gateway Configuration (PAR) File ..............6
2.2.3 Automatic Symbol Generation in CODESYS using
PLCopenXML .........................................................................................7
2.3 Secure Communications between CODESYS and the SMP Gateway ..................7
3 Setup 9
3.1 Installing the CODESYS IDE ...............................................................................9
3.2 Starting CODESYS for the First Time ................................................................ 10
3.3 Installing the SMP Gateway Device Description Files........................................ 10
3.4 Installing the SMP Library for CODESYS ......................................................... 11
3.5 Upgrading the SMP Gateway Software ............................................................... 11
5 Project Configuration 23
5.1 Creating a New CODESYS Project..................................................................... 23
5.2 Importing the Data Points .................................................................................... 24
5.3 PLC Logic and Tasks Definition ......................................................................... 25
6 Application Deployment 27
6.1 Establishing the Passthrough Connection between CODESYS and the
SMP Gateway ...................................................................................................... 27
6.2 Configuring the CODESYS Connection to the SMP Gateway ........................... 27
6.3 Debugging the Application on the SMP Gateway ............................................... 30
6.4 Creating an Embedded Boot Application ............................................................ 30
6.4.1 Creating a boot application embedded in the SMP Gateway
configuration file ................................................................................... 30
6.4.2 Creating a boot application that is separated from the
SMP Gateway configuration file: .......................................................... 31
6.5 Uploading the configuration file on the SMP Gateway ....................................... 32
7 Appendices 35
ii ● Contents
EAS-SA QF-MKT-02 Rev.02
Tables
Table B-1 General settings ........................................................................................................ B-2
Table B-2 Logic analog input settings ....................................................................................... B-4
Table B-3 Logic binary input settings ....................................................................................... B-5
Table B-4 Logic analog output settings ..................................................................................... B-7
Table B-5 Logic binary input settings ....................................................................................... B-8
Table B-6 Subscribed data point settings .................................................................................. B-9
1 Introduction
The SMP Gateway SoftPLC runtime system allows users to solve operational process issues, such
as circuit breaker control and load-balancing, by creating sophisticated automation scripts.
Configured using the CODESYS development platform and the SMP Config application, it
supports the following IEC 61131 programming languages:
Instruction List (IL)
Structured Text (ST)
Function Block Diagram (FBD)
Continuous Function Chart (CFC)
Ladder Diagram (LD)
Sequential Function Chart
1.2 Overview
This manual is divided into the following chapters:
This chapter gives an overview of this document’s contents and purpose.
Chapter 2 presents the concepts at the core of the SMP Gateway SoftPLC runtime system.
Chapter 3 describes how to install and set up the CODESYS IDE, the SMP Gateway device
description files, and the SMP Library for CODESYS.
Chapter 4 explains how to use SMP Config to configure the SoftPLC system component on
the SMP Gateway, including the definition of the data points that will be used by your
SoftPLC logic and tasks.
Chapter 5 covers CODESYS project configuration, including project creation, automatic
symbol definition through data point import, and PLC logic coding and task definition.
Chapter 6 describes how to connect the CODESYS IDE to the SMP Gateway, debug the
SoftPLC application, create the boot application and upload it to the SMP Gateway.
Reference information, such as the description of all SoftPLC system component settings and
an overview of the sample CODESYS project provided by default with SMP Config, is
available in the various appendices.
2● Chapter 1: Introduction
EAS-SA QF-MKT-02 Rev.02
Email: [email protected]
Phone: +1.877.834-0009 or +1.800.815-2258
Business hours are from 8 a.m. and 5 p.m. CST, Monday to Friday.
2 Principles of Operation
This chapter presents the concept at the core of the SMP Gateway SoftPLC runtime system. You
should read this chapter carefully and make sure you understand these concepts before going
further with the configuration chapters.
It is sometimes necessary to install more than one CODESYS version on a single computer
because SMP Manager can manage SMP Gateways that are using different SMP Software and
Tools versions, which do not use the same CODESYS versions.
The CODESYS versions must be installed in separate directories, the default path name suggested
at the installation must be modified to include the version number. Following are a few
application examples:
When installing CODESYS version 2.3.7.3, which is used with SMP Gateways’
Software and Tools versions 6.1, 6.2 and 6.3, a 2.3 suffix must be added to the default
installation path (C:\program files(x86)\3S CoDeSys 2.3).
When installing CODESYS version 3.4 SP4 Patch 1, which is used with SMP Gateways’
Software and Tools versions 6.1, 6.2 and 6.3, a 3.4 suffix must be added to the default
installation path (C:\program files(x86)\3S CoDeSys 3.4).
When installing CODESYS version 3.5 SP2, which is used with SMP Gateways’
Software and Tools versions 7.0 and later, no suffix should be added to the default
installation path (C:\program files(x86)\3S CoDeSys).
2.2.2 SMP Config and the SMP Gateway Configuration (PAR) File
The SMP Gateway components, functions and data point settings are defined and specified using
SMP Config, and stored in the SMP Gateway configuration (PAR) file. This is also the case for
the SoftPLC (CODESYS) component.
To simplify application deployment, a feature is provided to embed the SoftPLC application
designed using the CODESYS IDE within the SMP Gateway configuration file. As a result, the
SoftPLC application is uploaded to the SMP Gateway when you upload the configuration file on
the SMP Gateway. To make it work properly, all you have to do is to edit the CODESYS project
(and application) from the SMP Config, as described in Chapter 5.
Embedding the SoftPLC application within the SMP Gateway configuration file is the preferred
approach for developing CODESYS applications on the SMP Gateway; the configuration and
design instructions provided in this manual are based on this scenario. However, it is still possible
to keep the CODESYS project separated from the configuration file. In such “standalone”
scenario, the SoftPLC (CODESYS) component still acts as the bridge between the SoftPLC
application and RTDX, but you must upload and start the SoftPLC application separately, through
the CODESYS IDE.
3 Setup
This chapter explains how to install and setup the CODESYS integrated development environment
(IDE), along with the SMP Gateway device description files and the SMP Library for CODESYS.
Note: CODESYS requires the Microsoft .NET Framework 3.5, which is not provided
with the installer. However, the installer can download it from the web and
perform the installation, if the computer is connected to the Internet.
If this is not the case, contact your system administrator to have the .NET
Framework 3.5 installed prior to the CODESYS installation.
Note: If you don’t start CODESYS using the specific shortcut, you can get a dialog
asking which profile you want to start: normal or composer dedicated. The
second one is used only to edit projects, you cannot debug neither run it.
.\PC\Gateway\
Select the device description file that corresponds to your SMP Gateway model, and then
click Open.
10 ● Chapter 3: Setup
EAS-SA QF-MKT-02 Rev.02
.\PC\Gateway
The file will not be visible, since only compiled library files are displayed by default.
In the Files of type box, select Library files to reveal the file.
Select the SmpLib.library file, and then click Open.
Note: Additionally, make sure the SMP Gateway license contains the P-SSMP-0201
SoftPLC Runtime System option.
4 SMP Gateway
Configuration
Before proceeding with the creation of the SoftPLC application within the CODESYS IDE, some
SMP Gateway configuration operations must be performed using SMP Config:
An instance of the SoftPLC (CODESYS) component must be created and added to the
SMP Gateway configuration file.
The data points that will be created for and updated specifically by the SoftPLC instance
(called the logic data points) must be defined.
The SoftPLC must subscribe to physical data points produced by other SMP Gateway
components and that will be required by the SoftPLC application logic (either as inputs
or outputs).
You can use the SMP Gateway Automation Functions to enhance the SoftPLC application
logic, if required.
SMP Gateway slave components can subscribe to the SoftPLC logic data points, so they can
make them available to the SCADA, or any other control center or master station.
Finally, you will have to allow the CODESYS IDE to communicate with the SMP Gateway
through its built-in firewall, via a Passthrough connection.
These operations, which are performed using SMP Config are described in details in the following
sections.
Note: It is assumed that the reader has sufficient knowledge of the SMP Config tool
and SMP Gateway protocol components. For additional information on these
topics, refer to the SMP Gateway User Manual.
In the right pane, assign a name to the new instance, and then press ENTER.
Note: There can only be one instance of the SoftPLC (CODESYS) component in a
single SMP Gateway configuration; also, there can only be one SoftPLC
application per SoftPLC component instance.
In the left pane, expand the SoftPLC instance branch and select the General branch.
In the Device Prefix cell, type the prefix that will be added before the name of all logic data
points of this instance.
Note: By default, the Device Prefix is set to plc_. The sample project provided by
Eaton uses this prefix. If you want to use the sample project, you should keep
this default value; if you want to change it, you will also need to update the
sample project logic code.
Unless you want to temporarily deactivate the SoftPLC component, make sure the Enabled
option is selected.
By default, the Start Embedded Boot Application setting is selected; this means that the
SoftPLC component expects the SMP Gateway configuration (PAR) file to contain the
SoftPLC application, and will start it upon system startup or restart. This mode is very useful
to deploy a stable and debugged version of the SoftPLC application. This allows also the
creation of the SoftPLC template that includes everything, including the boot project.
Additionaly, it enables the user to close the SoftPLC port in the firewall, thus providing a
secure running environment. Indeed, when working with a stable version, the direct access is
acheived via a passthrough connection.
If you want to upload it manually using the CODESYS IDE, clear the Start Embedded Boot
Application check box; the SoftPLC application and the CODESYS project will then be
managed separately from the configuration file. This mode is very useful for new
development and debugging of an SoftPLC application. When in full development, we
recommend to open the SoftPLC port in the firewall to stream line the debugging process. We
strongly recommend to close the SoftPLC port on an SMP in production for security reason;
a passthrough connection can then be used.
By default, the Restart SMP when Exception Occurs setting is not selected; when selected,
this parameter means that an exception on a SoftPLC task will cause a restart of the SMP. For
example, an exception can be caused by a division by zero or when the CODESYS watchdog
is triggered. When an exception happens, an entry is added to the Reset log, indicating that an
exception occurred, regardless of the status of the Restart SMP when Exception Occurs
setting.
In the right pane, click in the Name cell of the first empty row.
Type the name of the logic point.
Note: The full name of the point will be preceded by the SoftPLC instance prefix.
(Optional) In the Symbol cell, type the name of this data point to be used in the corresponding
CODESYS project. Array type symbols are accepted (e.g.: AI1[x]), a table will be created
when the XML file is generated.
If this setting is left unspecified, the Name setting will also be used as the symbol in
CODESYS.
Edit other point settings (ex. Scale, Offset, etc.) as required.
For additional information about these settings, see “Analog Inputs”, page B-2.
(Optional) In the Description cell, type some indications about the purpose of this point or its
use in the SoftPLC application logic.
Repeat for all logic analog inputs.
In the right pane, click in the Name cell of the first empty row.
Type the name of the logic point.
Note: The full name of the point will be preceded by the SoftPLC instance prefix.
(Optional) In the Symbol cell, type the name of this data point to be used in the corresponding
CODESYS project. Array type symbols are accepted (e.g.: BI2[x].
If this setting is left unspecified, the Name setting will also be used as the symbol in
CODESYS.
For additional information about these settings, see “Binary Inputs”, page B-4.
(Optional) In the Description cell, type some indications about the purpose of this point or its
use in the SoftPLC application logic.
Repeat for all logic binary inputs.
In the right pane, click in the Name cell of the first empty row.
Type the name of the logic point.
Note: The full name of the point will be preceded by the SoftPLC instance prefix.
(Optional) In the Symbol cell, type the name of this data point to be used in the corresponding
CODESYS project. Array type symbols are accepted (e.g.: AO1[x]).
If this setting is left unspecified, the Name setting will also be used as the symbol in
CODESYS.
Edit other point settings (ex. Scale, Offset, etc.) as required.
For additional information about these settings, see “Analog Outputs”, page B-5.
(Optional) In the Description cell, type some indications about the purpose of this point or its
use in the SoftPLC application logic.
Repeat for all logic analog outputs.
In the right pane, click in the Name cell of the first empty row.
Type the name of the logic point.
Note: The full name of the point will be preceded by the SoftPLC instance prefix.
(Optional) In the Symbol cell, type the name of this data point to be used in the corresponding
CODESYS project. Array type symbols are accepted (e.g.: BO1[x]).
If this setting is left unspecified, the Name setting will also be used as the symbol in
CODESYS.
Edit other point settings (ex. Allow Open/Close, Allow Pulse, etc.) as required.
For additional information about these settings, see “Binary Outputs”, page B-7.
(Optional) In the Description cell, type some indications about the purpose of this point or its
use in the SoftPLC application logic.
Repeat for all logic binary outputs.
Note: SoftPLC application “inputs” are not to be confused with “input data points”. The
SoftPLC component can also subscribe to output data points, whose values will
be used as inputs of the application. Similarly, logic data points are considered as
“outputs” of the SoftPLC application, although most of the times they will be
defined as input data points.
For example, to subscribe to a physical analog input, select the Analog Inputs branch.
In the right pane, click in the Name cell of the first empty row.
Type the name of the logic point, including its own device prefix.
(Optional) In the Symbol cell, type the name of this data point to be used in the corresponding
CODESYS project. Array type symbols are accepted (e.g.: SAI[x]).
If this setting is left unspecified, the Name setting will also be used as the symbol in
CODESYS.
Repeat for all subscribed data points.
to implement than a SoftPLC application, but which can also enhance SoftPLC functionalities,
without typing additional lines of code.
The Automation Functions component is configured using SMP Config and works exclusively
with RTDX data points: it is not an additional library for the CODESYS environment.
To use the Automation Functions component with your SoftPLC application, create an
Automation Functions instance and define the functions you want the SMP Gateway to perform
on existing data points or new logic data points created by this component; then, subscribe the
SoftPLC component to these “automated” data points.
For additional information on the Automation Functions component, refer to the SMP Gateway
Automation Functions Reference Manual.
Note: This procedure is presented in details in the SMP Gateway User Manual.
Please note that this direct access should be blocked as soon as the system is put in
production.
You will need to configure a Passthrough connection to allow the CODESYS IDE to connect to
the SoftPLC.
In the left pane, expand the Passthrough branch, and then select the Connections branch.
In the right pane, click in the IED Name cell of the first empty row.
Type a name, such as CODESYS, for the Passthrough connection.
In the Connection cell, select the TCP/IP master connection that you defined previously
(named CODESYS in our example).
Note down this port number, as it will be required while specifying the
SMP Gateway connection settings in the CODESYS IDE.
Click OK.
5 Project Configuration
The SoftPLC component provides the RTDX data points required by the SoftPLC application, but
not the application itself; the latter must be designed in a CODESYS project using the CODESYS
IDE.
In this chapter, the reader will learn how to perform the following operations:
Create a new CODESYS project and attach it to an SMP Gateway configuration file.
Import the SoftPLC data points in the CODESYS project, to simplify the definition and
initialization of the corresponding symbols in the application.
Create a new CODESYS project and manage it separately from the configuration file.
Finally, the reader will also get guidelines and tips on how to design and code the SoftPLC
application.
Note: Eaton recommends the insertion of the SoftPLC application into the
SMP Gateway configuration file once the debugging phase is completed, and this
chapter provides the information and instructions corresponding to this scenario.
If you want to manage the SoftPLC application (and the related CODESYS
project) separately from the SMP Gateway configuration file, the process will
differ.
Note: For SMP Config CODESYS integration to work properly, the proper version of the
CODESYS IDE must be installed (refer to the “Supported Version of CODESYS”
section, page 5).
To create a CODESYS project and attach it to the SMP Gateway configuration file:
In SMP Config, select the SoftPLC instance branch.
Type an instance name in the Name cell located in the right pane.
Note: If you defined SoftPLC logic data points or subscribed the SoftPLC to existing
data points, an information message is displayed to notify the user that it should
import these points to its CODESYS project, using the PLCopenXML file
automatically generated by SMP Config; instructions on how to perform such
import are provided in section 5.2, below.
Take note of the name and location of the file, and then click OK.
CODESYS may prompt you for a version profile. Simply click Continue to select the
version profile. The user should not select a Composer Dedicated version.
Note: If you want to use the sample project provided by Eaton, before developing your
own application, refer to “Appendix A - Tutorial: The Sample Project”, page A-1.
Otherwise, the following sections assume that you will replace most of the
sample project code with your own application code.
Important: If you use the sample project code as a launching pad to start your own
project, remember that some parts of the project code must remain
unmodified in order to ensure a successful integration with the SMP
Gateway. Details are provided in the “Appendix A - Tutorial: The Sample
Project.
When editing the sample application, pay attention to the following details:
Make sure to keep the sequence logic in PLC_MAIN PRG; this is mandatory for a successful
SMP Gateway integration.
Make sure to keep the CheckBounds function which is used to validate runtime “ARRAY
out of bound” errors; we recommend that you implement any other POUs for implicit checks
(refer to CODESYS documentation for that matter).
If you need global variables, create a new object, do not use
SMP_global_symbols_declaration.
Take time to update the SMP_LOG, SMP_STAT and SMPINIT_PLC to match your
project.
The existing versions of these items will be replaced in the CODESYS sample project by new
ones that contain all the declarations and symbols of your own logic and subscribed data
points.
6 Application Deployment
Once the SoftPLC component and application are properly configured, they can be deployed on
the SMP Gateway.
This chapter explains how to perform the following deployment-related operations:
Connect the CODESYS IDE to the SMP Gateway.
Debug the SoftPLC application on the SMP Gateway through the CODESYS IDE.
Create a boot application and embeds it in the SMP Gateway configuration to allow the
SoftPLC component to automatically start the SoftPLC application at the SMP Gateway
startup or restart.
Upload the SMP Gateway configuration file, which also includes the SoftPLC settings,
application and boot code, on the SMP Gateway.
To establish the Passthrough connection between the CODESYS IDE and the
SMP Gateway:
Start SMP Connect.
Select the passthrough connection you defined previously for the CODESYS IDE.
From the Control menu, choose Connect to IED.
In the IED Application Selection window, select the CODESYS IDE application defined
previously.
If you configured the CODESYS IDE to be started up manually, start it now.
Note: Typically, devices running IEC 61131-3 applications (controllers) are accessible
through a network gateway. When defining the network path to an SMP Gateway
running a SoftPLC application, the SMP Gateway is considered as both the
network gateway and the PLC device.
All settings for the selected device are displayed in the right pane, in a specific Device
window/tab.
Click in the Communication Settings tab.
Note: Unlike previous versions of the SMP Gateway firmware, version 7.0 does not
host a CODESYS gateway; make sure that you selected the CODESYS Gateway
feature when you installed the CODESYS IDE (see “Installing the CODESYS
IDE”, page 9).
Select the newly created gateway node, and then click Add device.
If the CODESYS IDE connects to the SMP Gateway through a passthrough connection:
Type 127.0.0.1:<port> as the node address, where <port> is the loopback connection
port as defined in SMP Connect for the CODESYS IDE.
In the Assignment mode box, select IP Address using TCP.
Before clicking OK, make sure that the passthrough connection established using
SMP Connect is still alive; otherwise, reestablish it.
Click OK.
The SMP Gateway will appear under the gateway branch, represented by its serial number
(ex. SMP700035), a node address between brackets, and the (active) label.
If the (active) label is not present, select the SMP Gateway branch, and then click the Set
active path button on the top right side of the screen.
CODESYS is now ready to communicate with the SMP Gateway SoftPLC runtime.
Start CODESYS from SMP Config (from the Tools menu, choose Edit CODESYS Project).
Make sure that you are not currently connected to the SMP Gateway.
You will know that you are connected if the Login command is not available from the Online
menu, and both Device and Application branches are highlighted in green in the Devices
pane, as shown in the following picture:
If you are currently connected to the SMP Gateway, choose Logout from the Online menu.
Make sure any change made to the CODESYS project prior to the boot application creation
was properly saved; if in doubt, save it by choosing the Save Project command from the File
menu.
This verification is important, because SMP Config compares the timestamps of the
CODESYS project and the boot application, to ensure that the boot application contains the
latest code changes.
From the Online menu in CODESYS, choose Create boot application.
Note: We strongly recommend that you execute the Create boot application
command twice since user experience has shown that, most of the time, the
Workbench does not generate the right boot application after the first
command execution.
CODESYS builds the project application.
In the Save As window, make sure the File Name is Application; this is the default file
name. The complete path, including the file name, must remain unchanged to ensure the
proper embedding of the boot application in the SMP Gateway configuration file.
Click Save.
Do not save the CODESYS project. As stated previously, SMP Config compares the
timestamps of the CODESYS project and the boot application; if you save the project after
you create the application, SMP Config will believe that the application is not up-to-date and
will display a warning message.
Close CODESYS.
Back in SMP Config, save the configuration file (from the File menu, choose Save).
The SMP Gateway configuration (PAR) file now contains the boot application, and is ready to
be uploaded to the SMP Gateway.
Note: As stated several times throughout this document, this approach only works if
you embed the application (and the accompanying boot code) in the
SMP Gateway configuration file. Otherwise, you need to create the boot project
on the SMP yourself; the procedure is described in the following section.
Note: Before proceeding with the boot application creation, make sure that the Start
Embedded Boot Application setting in the SoftPLC component General
settings, in SMP Config, is not selected.
Start CODESYS from SMP Config (from the Tools menu, choose Edit CODESYS Project).
Make sure that you are connected to the SMP Gateway
You will know that you are connected if the Login command is not available from the Online
menu, and both Device and Application branches are highlighted in green in the Devices
pane, as shown in the following picture:
If you are not currently connected to the SMP Gateway, choose Login from the Online menu.
Make sure any change made to the CODESYS project prior to the boot application creation
was properly saved; if in doubt, save it by choosing the Save Project command from the File
menu.
This verification is important, because SMP Config compares the timestamps of the
CODESYS project and the boot application, to ensure that the boot application contains the
latest code changes.
From the Online menu in CODESYS, choose Create boot application.
Note: We strongly recommend that you execute the Create boot application
command twice while user experience has shown that, most of the time, the
Workbench does not generate the right boot application the first time.
CODESYS sends download information to the SMP Gateay for the project application.
Do not save the CODESYS project. As stated previously, SMP Config compares the
timestamps of the CODESYS project and the boot application; if you save the project after
you create the application, SMP Config will believe that the application is not up-to-date and
will display a warning message.
Logout from the SMP Gateway and Close CODESYS.
Back in SMP Config, save the configuration file (from the File menu, choose Save).
The SMP Gateway configuration (PAR) file does not contain the boot application. The boot
application was sent directly to the SMP Gateway; the SMP Config file is ready to be
uploaded to the SMP Gateway.
Select the SMP Gateway configuration file that contains the boot application or simply the
newly created SoftPLC component in the case when the boot application is separated from the
configuration file , and then click Open; click Yes to confirm the file upload.
Once the file is transferred, restart the SMP Gateway.
7 Appendices
This appendix presents the sample CODESYS project that SMP Config provides by default in the
SMP Gateway configuration file. It also explains how to debug and test it on an SMP Gateway.
The sample application will be started as soon as the SMP Gateway will complete its own
startup.
However, if you want to debug or run the sample application on the SMP Gateway, you must
allow CODESYS access through the SMP Gateway firewall, as described in section 4.6,
page 18.
In the left pane, select the Tutorial instance branch.
From the Tools menu, choose Edit CODESYS Project.
Note: Do not use the PLCopenXML file provided by SMP Config, even if SMP Config
suggests you to do so. The symbols used in the sample project are already
properly initialized and are not present in the SMP Gateway configuration file.
If you import the PLCopenXML file, these symbols will be deleted and the sample
project will no longer work.
CODESYS may prompt you for a version profile. Simply click Continue to select the version
profile. The user should not select a Composer Dedicated version.
Main_Task is a cyclic task that calls the PLC_MAIN program twice a second (every 500
milliseconds). This task must remain cycle based, to guarantee proper integration in the SMP
Gateway startup sequence; if necessary, the interval may be modified, up to a value of 3000 ms.
ST_PROGRAM();
END_IF
END_IF
The second part contains startup code; it will be executed once, after the SMP Gateway
startup is completed. At this point, all data points are properly mapped to CODESYS
symbols, and all system and protocol components are started and running.
The last part is the one that will be executed forever after: it only calls the ST_PROGRAM.
The ST_PROGRAM contains the sample application logic code. It essentially performs the
following operations:
Calculate the current second within the hour, and stores it in the AI_OUT_SEC_OF_HOUR
logic analog input.
Invert the state of the BI_OUT_INVERT_CONTROL logic binary input.
Once every minute, it deactivate local control operations on the SMP Gateway, by performing
a control operation on the _smp___localControl system data point; the sample
application is subscribed to this point.
Change the value of the AI_OUT_CONTROL_COUNT logic analog input when a control
operation is performed on the BO_OUT_COUNTER_UPD logic binary output; an open
operation decreases the value, a close operation increases the value, and a pulse operation
resets it to 0.
Once every minute, perform a control operation on the AO_OUT logic analog output.
Update various logic counters and statistic entries, and publishes messages through log
entries.
If you have not generated the boot application yet, or if it is not up-to-date with the
CODESYS project, some warnings will still be pending. Nevertheless, you can proceed with
the save operation.
Using SMP Manager, upload the configuration file on the SMP Gateway.
Re-open CODESYS from SMP Config.
The communication channel between the CODESYS IDE and the SMP Gateway must be
defined. To do that, refer to the section Configuring the CODESYS Connection to the
SMP Gateway, page 27,
Now that the path to the SMP Gateway is active, from the Online menu, choose Login.
If the login operation fails, make sure the SMP Gateway is running properly; verify, using
SMP Log, that the SoftPLC component was properly started.
When asked to download the sample application on the SMP Gateway, click Yes.
From the Debug menu, choose Start.
You can now use the Debug menu commands to insert breakpoints and debug the application.
Note: You do not have to create the boot application if you did not make any change to
the project; the boot application for the sample project is already embedded in
the SMP Gateway configuration file by default.
In the Save As window, make sure the File Name is Application.app; this is the default
file name and it must not be changed to ensure the proper embedding of the boot application
in the SMP Gateway configuration file.
Click Save.
Do not re-save the CODESYS project.
Close CODESYS.
Back in SMP Config, make sure you selected the Start Embedded Boot Application general
setting in the SoftPLC component settings.
Save the configuration file (from the File menu, choose Save).
Upload the configuration file on the SMP Gateway, and restart it.
The sample application will be started as soon as the SMP Gateway will complete its own
startup.
Make sure to keep the CheckBounds function which is used to validate runtime “ARRAY
out of bound” errors; we recommend that you implement any other POUs for implicit checks
(refer to CODESYS documentation for that matter).
If you need global variables, create a new object, do not use
SMP_global_symbols_declaration.
Take time to update the SMP_LOG, SMP_STAT and SMPINIT_PLC to match your
project.
Troubleshooting instructions
When troubleshooting your newly implemented project, we advise you to:
Look at the SMP Gateway’s SMP Stats \System\SoftPLC\<SoftPLC instance name > , to
get information about the current state of the SoftPLC application.
When debugging, always put a Breakpoint in the CheckBounds function to catch quickly any
issue. Do the same for any other implicit check functions that you have implemented.
This appendix provides, as reference, a description of all settings that must be specified for the
SoftPLC, using SMP Config.
General Settings
General settings specify the general behavior of the SoftPLC component instance.
Setting Description
Device Prefix A string used as a prefix for all logic data points created by the SoftPLC
component instance. This prefix must be unique, along all components that
also create data points, to ensure that all point names in the system are
unique.
Note: CODESYS does not support data points names longer than 39
characters, if longer data point names are used in SMP Config, the
user must select the Standard mode with compatibility support and
define Alternate names in order to send these Alternate name to
CODESYS.
Range: 1 to 67 ASCII characters.
Enabled Indicates if this SoftPLC component instance is currently enabled. Clear this
checkmark to temporarily deactivate the execution of SoftPLC component
application.
Range: checkmark / no checkmark
Default value: checkmark (enabled)
Start Embedded Boot A checkmark indicates that the SoftPLC application will be embedded
Application within the SMP Gateway configuration (PAR) file, along with its
corresponding boot code, allowing the SoftPLC application to run
automatically at the SMP Gateway startup.
Range: checkmark / no checkmark
Default value: no checkmark
Setting Description
Restart SMP when A checkmark indicates that an exception on a SoftPLC task will cause a
Exception Occurs restart of the SMP Gateway. Examples of what can cause an exception can
be a division by zero or when the CODESYS watchdog is triggered.
When an exception occurs, an entry will be added to the Reset log,
indicating that an exception occurred, regardless of the status of the Restart
SMP when Exception Occurs setting.
Range: checkmark / no checkmark
Default value: no checkmark
Analog Inputs
The following table presents the settings that are specific to logic analog inputs of the SoftPLC
component.
Setting Description
Name The name of the logic analog input point, which must be unique within the
SoftPLC component. This name is preceded by the Device Prefix, as
specified in the general settings. The device prefix, coupled with the name,
ensures that every point managed by the system has a unique name.
The following characters cannot be used as part of the name: the comma (,),
the quotation mark ("), the semicolon (;) and the grave accent (`).
Note: CODESYS does not support data points names longer than 39
characters, if longer data point names are used in SMP Config, the
user must select the Standard mode with compatibility support and
define Alternate names in order to send these Alternate name to
CODESYS.
Setting Description
Symbol The name of the logic analog input point, as it will be used in the
CODESYS application code.
If no Symbol is specified, the Name setting will be used instead, unless it
contains invalid characters per CODESYS syntax rules: if this is the case,
the Symbol setting becomes mandatory. A Symbol can be the name of a
RTDX point, it must also be unique on the whole set of symbols, not only
on a single type.
Only the following characters are allowed as part of the symbol: A-Z, a-z,
09, and the underscore (‘_’); however, consecutive underscores are not
allowed.
Arrays are supported and are written as follow: logic_
analog_input_name[x]. For a specific symbol, the same position should not
be used twice. An Array can use the same index twice, and the Array must
be of the same type. Also, the dimension of the Arrays must match (example
a[1] with a[2] is good but a[1] and a[2,1] is not valid).
Range: 0 to 31 ASCII characters. For arrays, the maximum is set
to 3 dimensions.
Disabled A checkmark indicates that this point is ignored by the SoftPLC component.
Range: checkmark / no checkmark
Default value: no checkmark
Scale Scaling factor used to convert 32-bit values (raw) to significant engineering
units (floating point) and vice versa. The conversion depends on the format
of the value, as provided by the parent function. The following equation is
used:
Floating-point value = (raw value * scale) + offset
Range: –3.4E38 to 3.4E38, not 0.0
Default value: 1.0
Offset Offset value used to convert 32-bit values (raw) to significant engineering
units (floating point) and vice versa. See the Scale setting above.
Range: –3.4E38 to 3.4E38
Default value: 0.0
SMP Deadband Only floating-point value changes greater than the deadband value are
reported, unless the value itself is smaller than the deadband. This ensures
that small variations around 0 are reported so that, for example, reported
values do not remain fixed at .01 when they are, in fact, 0. A value of 0 for
this setting implies that all variations, no matter how small, are reported.
Range: 0.0 to 3.4E38
Default value: 0.0
Units Units that are displayed with this point’s values in the various SMP Tools,
or through the SMP Gateway web server.
Allowed values: As shown in the drop-down list
Default value: ** Undefined **
Setting Description
Description An optional point description, which is displayed in the various SMP Tools,
or through the SMP Gateway web server, to provide additional information
about this point at runtime.
Range: 1 to 63 ASCII characters.
Binary Inputs
The following table presents the settings that are specific to logic binary inputs of the SoftPLC
component.
Setting Description
Name The name of the logic binary input point, which must be unique within the
SoftPLC component. This name is preceded by the Device Prefix, as
specified in the general settings. The device prefix, coupled with the name,
ensures that every point managed by the system has a unique name.
The following characters cannot be used as part of the name: the comma (,),
the quotation mark ("), the semicolon (;) and the grave accent (`).
Note: CODESYS does not support data points names longer than 39
characters, if longer data point names are used in SMP Config, the
user must select the Standard mode with compatibility support and
define Alternate names in order to send these Alternate name to
CODESYS.
Symbol The name of the logic binary input point, as it will be used in the CODESYS
application code.
If no Symbol is specified, the Name setting will be used instead, unless it
contains invalid characters per CODESYS syntax rules: if this is the case,
the Symbol setting becomes mandatory. A Symbol can be the name of a
RTDX point, it must also be unique on the whole set of symbols, not only on
a single type.
Only the following characters are allowed as part of the symbol: A-Z, a-z,
09, and the underscore (‘_’); however, consecutive underscores are not
allowed.
Arrays are supported and are written as follow: logic_
analog_input_name[x]. For a specific symbol, the same position should not
be used twice. An Array can use the same index twice, and the Array must be
of the same type. Also, the dimension of the Arrays must match (example
a[1] with a[2] is good but a[1] and a[2,1] is not valid).
Setting Description
Disabled A checkmark indicates that this point is ignored by the SoftPLC component.
Range: checkmark / no checkmark
Default value: no checkmark
On-Delay. Specify how long, in milliseconds, the point must keep its “on” state,
following a low-to-high transition, for the corresponding transition to be
considered valid.
Default value: 0 (low-to-high transitions reported immediately)
Off-Delay Specify how long, in milliseconds, the point must keep its “off” state,
following a high-to-low transition, for the corresponding transition to be
considered valid.
Default value: 0 (high-to-low transitions reported immediately)
Description An optional point description, which is displayed in the various SMP Tools,
or through the SMP Gateway web server, to provide additional information
about this point at runtime.
Range: 1 to 63 ASCII characters.
Analog Outputs
The following table presents the settings that are specific to logic analog outputs of the SoftPLC
component.
Setting Description
Name The name of the logic analog output point, which must be unique within the
SoftPLC component. This name is preceded by the Device Prefix, as specified in
the general settings. The device prefix, coupled with the name, ensures that every
point managed by the system has a unique name.
The following characters cannot be used as part of the name: the comma (,), the
quotation mark ("), the semicolon (;) and the grave accent (`).
Range: 1 to 39 ASCII characters (including the prefix).
Setting Description
Symbol The name of the logic analog output point, as it will be used in the CODESYS
application code.
If no Symbol is specified, the Name setting will be used instead, unless it
contains invalid characters per CODESYS syntax rules: if this is the case,
the Symbol setting becomes mandatory. A Symbol can be the name of a RTDX
point, it must also be unique on the whole set of symbols, not only on a single
type.
Only the following characters are allowed as part of the symbol: A-Z, a-z, 09,
and the underscore (‘_’); however, consecutive underscores are not allowed.
Arrays are supported and are written as follow: logic_ analog_input_name[x].
For a specific symbol, the same position should not be used twice. An Array can
use the same index twice, and the Array must be of the same type. Also, the
dimension of the Arrays must match (example a[1] with a[2] is good but a[1] and
a[2,1] is not valid).
Disabled A checkmark indicates that the point is ignored by the SoftPLC component.
Range: checkmark / no checkmark
Default value: no checkmark
Scale Scaling factor used to convert 32-bit values (raw) to significant engineering units
(floating point) and vice versa. The conversion depends on the format of the
value, as provided by the parent function. The following equation is used:
Floating-point value = (raw value * scale) + offset
Range: –3.4E38 to 3.4E38, not 0.0
Default value: 1.0
Offset Offset value used to convert 32-bit values (raw) to significant engineering units
(floating point) and vice versa. See the Scale setting above.
Range: –3.4E38 to 3.4E38
Default value: 0.0
SMP Deadband Only floating-point value changes greater than the deadband value are reported,
unless the value itself is smaller than the deadband. This ensures that small
variations around 0 are reported so that, for example, reported values do not
remain fixed at .01 when they are, in fact, 0. A value of 0 for this setting implies
that all variations, no matter how small, are reported.
Range: 0.0 to 3.4E38
Default value: 0.0
Units Units that are displayed with this point’s values in the various SMP Tools, or
through the SMP Gateway web server.
Allowed values: As shown in the drop-down list
Default value: ** Undefined **
Setting Description
Description An optional point description, which is displayed in the various SMP Tools, or
through the SMP Gateway web server, to provide additional information about
this point at runtime.
Range: 1 to 63 ASCII characters.
Binary Outputs
The following table presents the settings that are specific to logic binary inputs of the SoftPLC
component.
Setting Description
Name The name of the logic binary output point, which must be unique within the
SoftPLC component. This name is preceded by the Device Prefix, as specified
in the general settings. The device prefix, coupled with the name, ensures that
every point managed by the system has a unique name.
The following characters cannot be used as part of the name: the comma (,), the
quotation mark ("), the semicolon (;) and the grave accent (`).
Range: 1 to 39 ASCII characters (including the prefix).
Symbol The name of the logic binary output point, as it will be used in the CODESYS
application code.
If no Symbol is specified, the Name setting will be used instead, unless it
contains invalid characters per CODESYS syntax rules: if this is the case,
the Symbol setting becomes mandatory. A Symbol can be the name of a RTDX
point, it must also be unique on the whole set of symbols, not only on a single
type.
Only the following characters are allowed as part of the symbol: A-Z, a-z, 09,
and the underscore (‘_’); however, consecutive underscores are not allowed.
Arrays are supported and are written as follow: logic_ analog_input_name[x].
For a specific symbol, the same position should not be used twice. An Array can
use the same index twice, and the Array must be of the same type. Also, the
dimension of the Arrays must match (example a[1] with a[2] is good but a[1]
and a[2,1] is not valid).
Disabled A checkmark indicates that this point is ignored by the SoftPLC component.
Range: checkmark / no checkmark
Default value: no checkmark
Setting Description
Open/Close Allowed A checkmark indicates that open/close control operations can be performed on
this point.
Range: checkmark / no checkmark
Default value: no checkmark
Pulse Allowed A checkmark indicates that pulse control operations can be performed on this
point.
Range: checkmark / no checkmark
Default value: no checkmark
Repeat Count A checkmark indicates that open/close control operations can be performed on
Allowed this point.
Range: checkmark / no checkmark
Default value: no checkmark
On-Delay. Specify how long, in milliseconds, the point must keep its “on” state, following
a low-to-high transition, for the corresponding transition to be considered valid.
Default value: 0 (low-to-high transitions reported immediately)
Off-Delay Specify how long, in milliseconds, the point must keep its “off” state, following
a high-to-low transition, for the corresponding transition to be considered valid.
Default value: 0 (high-to-low transitions reported immediately)
Description An optional point description, which is displayed in the various SMP Tools, or
through the SMP Gateway web server, to provide additional information about
this point at runtime.
Range: 1 to 63 ASCII characters.
Setting Description
Name The name of the subscribed data point, including its corresponding Device Prefix.
This point must either be an SMP Gateway system data points, or a physical data
points produced by a master or system component.
Range: 1 to 39 ASCII characters (including the prefix).
Setting Description
Symbol The name of the subscribed data point, as it will be used in the CODESYS application
code.
If no Symbol is specified, the Name setting will be used instead, unless it contains
invalid characters per CODESYS syntax rules: if this is the case, the Symbol setting
becomes mandatory.
Only the following characters are allowed as part of the symbol: A-Z, a-z, 09, and the
underscore (‘_’); however, consecutive underscores are not allowed. Arrays are
supported and are written as follow: logic_ analog_input_name[x]. For a specific
symbol, the same position should not be used twice.
Range: 0 to 31 ASCII characters. For arrays, the maximum is set to 3
dimensions.
Disabled A checkmark indicates that this point is ignored by the SoftPLC component.
Range: checkmark / no checkmark
Default value: no checkmark