Dynamic Changes
Dynamic changes are advanced functions that allow us to change either the configuration of the PLC or the properties of the communication channels uploaded to the PLC. Therefore, it is not necessary to perform configuration directly in the IDE; individual configuration variables can be extracted, for example, to an HMI.
Using the functions described below, it is possible to program custom functional blocks in ST according to the project's requirements.
dynpar.setdynamicparamstr
Description
The function is used to write string values.
Usage in ST
WriteResult := dynpar.setdynamicparamstr(id := ParamId, value := ParamToWrite);
Inputs
- id: string_ref - parameter name
- value: string_ref - value of the parameter to write
Outputs
- No output parameters
Return Values
- 0 - no error
- -1 - record does not exist
- -2 - unknown requested type (cannot occur in practice)
- -3 - size mismatch between stored record and requested record (e.g., stored as bool and read as int)
- -4 - internal code error
dynpar.setdynamicparamint
Description
The function is used to write integer values.
Usage in ST
WriteResult := dynpar.setdynamicparamint(id := ParamId, value := ParamToWrite);
Inputs
- id: string_ref - parameter name
- value: int - value of the parameter to write
Outputs
- No output parameters
Return Values
- 0 - no error
- -1 - record does not exist
- -2 - unknown requested type (cannot occur in practice)
- -3 - size mismatch between stored record and requested record (e.g., stored as bool and read as int)
- -4 - internal code error
dynpar.setdynamicparambool
Description
The function is used to write boolean values.
Usage in ST
WriteResult := dynpar.setdynamicparambool(id := ParamId, value := ParamToWrite);
Inputs
- id: string_ref - parameter name
- value: bool - value of the parameter to write
Outputs
- No output parameters
Return Values
- 0 - no error
- -1 - record does not exist
- -2 - unknown requested type (cannot occur in practice)
- -3 - size mismatch between stored record and requested record (e.g., stored as bool and read as int)
- -4 - internal code error
dynpar.setdynamicparamtime
Description
The function is used to write time values.
Usage in ST
WriteResult := dynpar.setdynamicparamtime(id := ParamId, value := ParamToWrite);
Inputs
- id: string_ref - parameter name
- value: time - value of the parameter to write
Outputs
- No output parameters
Return Values
- 0 - no error
- -1 - record does not exist
- -2 - unknown requested type (cannot occur in practice)
- -3 - size mismatch between stored record and requested record (e.g., stored as bool and read as int)
- -4 - internal code error
dynpar.setdynamicparamdt
Description
The function is used to write date and time values.
Usage in ST
WriteResult := dynpar.setdynamicparamdt(id := ParamId, value := ParamToWrite);
Inputs
- id: string_ref - parameter name
- value: dt - value of the parameter to write
Outputs
- No output parameters
Return Values
- 0 - no error
- -1 - record does not exist
- -2 - unknown requested type (cannot occur in practice)
- -3 - size mismatch between stored record and requested record (e.g., stored as bool and read as int)
- -4 - internal code error
dynpar.trygetdynamicparamstr
Description
The function is used to read string values.
Usage in ST
ReadResult := dynpar.trygetdynamicparamstr(id := ParamId, value => ReturnValue);
Inputs
- id: string_ref - parameter name
Outputs
- value: string - returned value of the parameter
Return Values
- 0 - no error
- -1 - record does not exist
- -2 - unknown requested type (cannot occur in practice)
- -3 - size mismatch between stored record and requested record (e.g., stored as bool and read as int)
- -4 - internal code error
dynpar.trygetdynamicparamint
Description
The function is used to read integer values.
Usage in ST
ReadResult := dynpar.trygetdynamicparamint(id:= ParamId, value => ReturnValue);
Inputs
- id: string_ref - parameter name
Outputs
- value: int - returned value of the parameter
Return Values
- 0 - no error
- -1 - record does not exist
- -2 - unknown requested type (cannot occur in practice)
- -3 - size mismatch between stored record and requested record (e.g., stored as bool and read as int)
- -4 - internal code error
dynpar.trygetdynamicparambool
Description
The function is used to read boolean values.
Usage in ST
ReadResult := dynpar.trygetdynamicparambool(id:= ParamId, value => ReturnValue);
Inputs
- id: string_ref - parameter name
Outputs
- value: bool - returned value of the parameter
Return Values
- 0 - no error
- -1 - record does not exist
- -2 - unknown requested type (cannot occur in practice)
- -3 - size mismatch between stored record and requested record (e.g., stored as bool and read as int)
- -4 - internal code error
dynpar.trygetdynamicparamtime
Description
The function is used to read time values.
Usage in ST
ReadResult := dynpar.trygetdynamicparamtime(id:= ParamId, value => ReturnValue);
Inputs
- id: string_ref - parameter name
Outputs
- value: time - returned value of the parameter
Return Values
- 0 - no error
- -1 - record does not exist
- -2 - unknown requested type (cannot occur in practice)
- -3 - size mismatch between stored record and requested record (e.g., stored as bool and read as int)
- -4 - internal code error
dynpar.trygetdynamicparamdt
Description
The function is used to read date and time values.
Usage in ST
ReadResult := dynpar.trygetdynamicparamdt(id:= ParamId, value => ReturnValue);
Inputs
- id: string_ref - parameter name
Outputs
- value: dt - returned value of the parameter
Return Values
- 0 - no error
- -1 - record does not exist
- -2 - unknown requested type (cannot occur in practice)
- -3 - size mismatch between stored record and requested record (e.g., stored as bool and read as int)
- -4 - internal code error
dynpar.deletedynamicparam
Description
The function is used to delete a dynamic parameter. Dynamic parameters can be deleted in bulk when uploading a configuration.
Usage in ST
DeleteResult := dynpar.deletedynamicparam(ParamToDelete);
Inputs
- id: string_ref - parameter name
Outputs
- No output parameters
Return Values
- 0 - no error
- -1 - record does not exist
- -2 - unknown requested type (cannot occur in practice)
- -3 - size mismatch between stored record and requested record (e.g., stored as bool and read as int)
- -4 - internal code error
dynpar.commithwconfiguration
Description
The function is used to save the entire HW configuration tree to the PLC memory. It has no parameters.
Usage in ST
CommitResult := dynpar.commithwconfiguration();
Return Values
- 0 - no error
- -1 - record does not exist
- -2 - unknown requested type (cannot occur in practice)
- -3 - size mismatch between stored record and requested record (e.g., stored as bool and read as int)
- -4 - internal code error
ReloadApplication
The function is used to restart the PLC. You can specify the type of restart based on the given flag. If no flag is set, the PLC restarts in the standard way (Warm Restart).
Usage in ST
RestartResult := reloadapplication(Flag);
Input Parameters - Flags (udint)
- 0x00 - Warm Restart
- 0x01 - Cold Restart
- 0x02 - Full system restart (reboot)
Outputs
- No output parameters
Return Values
- 0 - no error
- -1 - record does not exist
- -2 - unknown requested type (cannot occur in practice)
- -3 - size mismatch between stored record and requested record (e.g., stored as bool and read as int)
- -4 - internal code error
Keys for PLC Configuration
These keys can be found in the project directory in the bin directory, where there is a file with the .XML extension that can be opened in a text editor. This file is created by uploading the configuration to the PLC.
The prefix “hwcfg” is added before the keys for PLC configuration. In the XML file, we navigate through individual nodes, where for example, to set the PLC's IP address, we must write the key in the format “hwcfg.hwconfiguration.runtime.lwip.ipv4.@ipaddress”.
Table of Keys for PLC Configuration
Networking
Key Type | Key |
---|---|
IP Address | hwcfg.hwconfiguration.runtime.lwip.ipv4.@ipaddress |
Network Mask | hwcfg.hwconfiguration.runtime.lwip.ipv4.@mask |
Gateway | hwcfg.hwconfiguration.runtime.lwip.ipv4.@gateway |
DNS | hwcfg.hwconfiguration.runtime.lwip.ipv4.@nameserver |
Static/DHCP | hwcfg.hwconfiguration.runtime.lwip.ipv4.@mode |
Network Interface Controller Count | hwcfg.hwconfiguration.runtime.advanced.@niccount |
Enable Configuration over UDP | hwcfg.hwconfiguration.runtime.configservice.@enabled |
Config Service Port | hwcfg.hwconfiguration.runtime.configservice.@port |
Enable HTTP | hwcfg.hwconfiguration.runtime.httpservice.@enabled |
HTTP Port | hwcfg.hwconfiguration.runtime.httpservice.@port |
Enable HTTPS | hwcfg.hwconfiguration.runtime.httpsservice.@enabled |
HTTPS Port | hwcfg.hwconfiguration.runtime.httpsservice.@port |
Redirect HTTP to HTTPS | hwcfg.hwconfiguration.runtime.httpservice.@redirect |
SSCP Parameters
Key Type | Key |
---|---|
SSCP Address | hwcfg.hwconfiguration.runtime.sscp.@slaveid |
Number of Registrable Groups | hwcfg.hwconfiguration.runtime.sscp.@groupscount |
Number of Variables in Group | hwcfg.hwconfiguration.runtime.sscp.@groupvariablecount |
Enable TCP Server | hwcfg.hwconfiguration.runtime.sscp.tcp.@enabled |
TCP Server Port | hwcfg.hwconfiguration.runtime.sscp.tcp.@port |
Enable SSCP Serial | hwcfg.hwconfiguration.runtime.sscp.serial.@enabled |
SSCP Serial Port | hwcfg.hwconfiguration.runtime.sscp.serial.@port |
SSCP Serial Baudrate | hwcfg.hwconfiguration.runtime.sscp.serial.@baudrate |
SSCP Serial Mode (Server/Router) | hwcfg.hwconfiguration.runtime.sscp.serial.@mode |
Enable SSL Server | hwcfg.hwconfiguration.runtime.sscp.ssl.@enabled |
SSL Server Port | hwcfg.hwconfiguration.runtime.sscp.ssl.@port |
Users Definition
Key Type | Key |
---|---|
Engineering | hwcfg.hwconfiguration.runtime.sscp.users.user[1].@name |
Full Control | hwcfg.hwconfiguration.runtime.sscp.users.user[2].@name |
Read Only | hwcfg.hwconfiguration.runtime.sscp.users.user[3].@name |
First User | hwcfg.hwconfiguration.runtime.sscp.users.user[first()].@name |
Last User | hwcfg.hwconfiguration.runtime.sscp.users.user[last()].@name |
Database Parameters
Key Type | Key |
---|---|
Enabled | hwcfg.hwconfiguration.runtime.rcwaredb.@enabled |
Protocol | hwcfg.hwconfiguration.runtime.rcwaredb.urls.url[1].@protocol |
Host | hwcfg.hwconfiguration.runtime.rcwaredb.urls.url[1].@host |
Path | hwcfg.hwconfiguration.runtime.rcwaredb.urls.url[1].@path |
Port | hwcfg.hwconfiguration.runtime.rcwaredb.urls.url[1].@port |
User Name | hwcfg.hwconfiguration.runtime.rcwaredb.urls.url[1].@username |
Password | hwcfg.hwconfiguration.runtime.rcwaredb.urls.url[1].@password |
Certificate Validation | hwcfg.hwconfiguration.runtime.rcwaredb.urls.url[1].@certificatevalidation |
Communication Period | hwcfg.hwconfiguration.runtime.rcwaredb.@updateperiod |
Proxy Parameters
Key Type | Key |
---|---|
Enabled | hwcfg.hwconfiguration.runtime.proxy.@enabled |
Proxy ID | hwcfg.hwconfiguration.runtime.proxy.@id |
Protocol | hwcfg.hwconfiguration.runtime.proxy.urls.url[1].@protocol |
Host | hwcfg.hwconfiguration.runtime.proxy.urls.url[1].@host |
Path | hwcfg.hwconfiguration.runtime.proxy.urls.url[1].@path |
Port | hwcfg.hwconfiguration.runtime.proxy.urls.url[1].@port |
Certificate Validation | hwcfg.hwconfiguration.runtime.proxy.urls.url[1].@certificatevalidation |
Keep-alive Period | hwcfg.hwconfiguration.runtime.proxy.@keepalive |
Date/Time Settings
Key Type | Key |
---|---|
UTC Offset | hwcfg.hwconfiguration.runtime.sscp.users.user[1].@name |
Daylight Offsets Number | hwcfg.hwconfiguration.runtime.sscp.users.user[2].@name |
Year 1 | hwcfg.hwconfiguration.timetransformation.daylights.daylight[1].@year |
Year 20 | hwcfg.hwconfiguration.timetransformation.daylights.daylight[20].@year |
First Year | hwcfg.hwconfiguration.timetransformation.daylights.daylight[first].@year |
Last Year | hwcfg.hwconfiguration.timetransformation.daylights.daylight[last].@year |
Offset Start | hwcfg.hwconfiguration.timetransformation.daylights.daylight[1].@start |
Offset End | hwcfg.hwconfiguration.timetransformation.daylights.daylight[1].@end |
Daylight Offsets | hwcfg.hwconfiguration.timetransformation.daylights.daylight[1].@daylightoffset |
NTP Server
Key Type | Key |
---|---|
Protocol | hwcfg.hwconfiguration.timetransformation.ntp.urls.url[1].@protocol |
Host | hwcfg.hwconfiguration.timetransformation.ntp.urls.url[1].@host |
Path | hwcfg.hwconfiguration.timetransformation.ntp.urls.url[1].@path |
Port | hwcfg.hwconfiguration.timetransformation.ntp.urls.url[1].@port |
Certificate Validation | hwcfg.hwconfiguration.timetransformation.ntp.urls.url[1].@certificatevalidation |
Keep-alive Period | hwcfg.hwconfiguration.timetransformation.ntp.@keepalive |
SD Card
Key Type | Key |
---|---|
Use for History | hwcfg.hwconfiguration.memorylayout.sdcard.@useforhistory |
History Size | hwcfg.hwconfiguration.memorylayout.sdcard.@historysize |
Keys for Dynamic Changes in Image
Keys for dynamic changes in image are listed in the “Output” tab in the format “OEM Key “channel>ComPort” → 9698843FC46A2D1A, datatype: SignedInteger32”, where “channel” is the channel name and “ComPort” is the parameter from which we want to read or write. The key is then followed by the data type of the parameter. In this case, we would use the function dynpar.trygetdynamicparamint for reading this key and dynpar.setdynamicparamint for writing.
For keys for changes in image, it is necessary to add the prefix “image” before the listed keys. For example, to change the communication port of a modbus serial channel named “modbus_channel”, the key should be written as “image.modbus_channel>ComPort”.
Table of Keys for Dynamic Changes of Communication Protocol Properties
Modbus Serial
Key Type | Key |
---|---|
Port Number | image.“channel_name”>ComPort |
Baud Rate | image.“channel_name”>Baudrate |
Data Bits | image.“channel_name”>Databits |
Parity | image.“channel_name”>Parity |
Stop Bits | image.“channel_name”>Stopbits |
Channel Enable | image.“channel_name”>Enable |
Device Address | image.“channel_name”.“device_name”>Address |
Device Enable | image.“channel_name”.“device_name”>Enable |
Modbus TCP
Key Type | Key |
---|---|
Channel Enable | image.“channel_name”>Enable |
Device Enable | image.“channel_name”.“device_name”>Enable |
IPv4 | image.“channel_name”.“device_name”>Ipv4 |
Port | image.“channel_name”.“device_name”>Port |
Host | image.“channel_name”.“device_name”>Host |
Address | image.“channel_name”.“device_name”>Address |
BACnet Client
Key Type | Key |
---|---|
IPv4 | image.“channel_name”.“device_name”>Ipv4 |
Port | image.“channel_name”.“device_name”>Port |
Host | image.“channel_name”.“device_name”>Host |
Device Instance | image.“channel_name”.“device_name”>DeviceInstance |
BACnet Server
Key Type | Key |
---|---|
IPv4 | image.“channel_name”.“device_name”>Ipv4 |
Port | image.“channel_name”.“device_name”>Port |
Device Instance | image.“channel_name”.“device_name”>DeviceInstance |
Management Password | image.“channel_name”.“device_name”>MgmtPassword |
Daikin
Key Type | Key |
---|---|
IPv4 | image.“channel_name”.“device_name”>Ipv4 |
Port | image.“channel_name”.“device_name”>Port |
Host | image.“channel_name”.“device_name”>Host |
IEC
Key Type | Key |
---|---|
Port Number | image.“channel_name”>ComPort |
Baud Rate | image.“channel_name”>Baudrate |
Data Bits | image.“channel_name”>Databits |
Parity | image.“channel_name”>Parity |
Stop Bits | image.“channel_name”>Stopbits |
Mbus
Key Type | Key |
---|---|
Port Number | image.“channel_name”>ComPort |
Baud Rate | image.“channel_name”>Baudrate |
Data Bits | image.“channel_name”>Databits |
Parity | image.“channel_name”>Parity |
Stop Bits | image.“channel_name”>Stopbits |
Primary Address | image.“channel_name”.“device_name”>Primary |
Secondary Address | image.“channel_name”.“device_name”>Secondary |
Use Secondary Address | image.“channel_name”.“device_name”>UseSecondary |
Device Enable | image.“channel_name”.“device_name”>Enable |
Modbus Server Serial
Key Type | Key |
---|---|
Port Number | image.“channel_name”>ComPort |
Baud Rate | image.“channel_name”>Baudrate |
Data Bits | image.“channel_name”>Databits |
Parity | image.“channel_name”>Parity |
Stop Bits | image.“channel_name”>Stopbits |
Device Address | image.“channel_name”.“device_name“>Address |
Modbus Server TCP
Key Type | Key |
---|---|
Channel Enable | image.“channel_name”>Enable |
IPv4 | image.“channel_name”.“device_name”>Ipv4 |
Port | image.“channel_name”.“device_name”>Port |
Device Address | image.“channel_name”.“device_name”>Address |
Device Enable | image.“channel_name”.“device_name”>Enable |
Table of Keys for Dynamic Changes of Alarm Channel Properties
SMTP
Key Type | Key |
---|---|
Server | image.“channel_name”.Host |
Port | image.“channel_name”.Port |
Use Authentication | image.“channel_name”.UseAuth |
Username | image.“channel_name”.Username |
Password | image.“channel_name”.Password |
Enable SSL | image.“channel_name”.Ssl |
Certificate Validation | image.“channel_name”.CertificateValidation |
GSM
Key Type | Key |
---|---|
Port Number | image.“channel_name”.ComPort |
Baud Rate | image.“channel_name”.Baudrate |
Data Bits | image.“channel_name”.Databits |
Parity | image.“channel_name”.Parity |
Stop Bits | image.“channel_name”.Stopbits |