Libraries for IEC 61131-3
Contents
Introduction
Standard IEC 61131-3 library
Documentation to standard ilbrary is on http://www.gebautomation.com/help/index.jsp?topic=%2Fcom.gebautomation.help%2Fhtml%2Ftech%2Fstdlib.html .
Functions and function blcoks from standard library works properly also in Simulator.
Metel IEC 61131-3 libraries
To show Metel libraries in IDE, must be select project device to "iplog_gama" and build it.
Only some functions and function blocks from Metel libraries will works in Simulator.
Asynchronous operations
Some long-time operations (reading from MODBUS) can not be done in one logic cycle.
To solve that, use all asynchronous function blocks in Metel libraries this general interface:
in | EXEC | bool r_edge | rising edge starts new operation | |
out | BUSY | bool | indicates that operation is pending | |
out | ERR | bool | indicates some error occurs | |
out | ERR_ID | int | identifies occured error by unique code | |
out | VALID | bool | indicates success operation and valid output |
Error codes
Error code | Short name | Description |
---|---|---|
0x0 | ERR_OK | No error |
0x102 | ERROR_STD_NO_SUCH_FILE_OR_DIRECTORY | |
0x10C | ERROR_STD_OUT_OF_MEMORY | |
0x113 | ERROR_STD_NO_SUCH_DEVICE | |
0x116 | ERROR_STD_INVALID_ARGUMENT | |
0x16E | ERROR_STD_CONNECTION_TIMED_OUT | |
0x1001 | ERROR_MODBUS_INVALID_BUS | |
0x1002 | ERROR_MODBUS_INVALID_REGISTER | |
0x1003 | ERROR_MODBUS_INVALID_UNIT_ID | |
0x1011 | ERROR_MODBUS_EXCEPTION_ILLEGAL_FUNCTION | |
0x1012 | ERROR_MODBUS_EXCEPTION_ILLEGAL_DATA_ADDRESS | |
0x1013 | ERROR_MODBUS_EXCEPTION_ILLEGAL_DATA_VALUE | |
0x1014 | ERROR_MODBUS_EXCEPTION_SLAVE_OR_SERVER_FAILURE | |
0x1015 | ERROR_MODBUS_EXCEPTION_ACKNOWLEDGE | |
0x1016 | ERROR_MODBUS_EXCEPTION_SLAVE_OR_SERVER_BUSY | |
0x1017 | ERROR_MODBUS_EXCEPTION_NEGATIVE_ACKNOWLEDGE | |
0x1018 | ERROR_MODBUS_EXCEPTION_MEMORY_PARITY | |
0x1019 | ERROR_MODBUS_EXCEPTION_GATEWAY_PATH | |
0x101A | ERROR_MODBUS_EXCEPTION_GATEWAY_TARGET | |
0x1021 | ERROR_MODBUS_EMBBADCRC | |
0x1022 | ERROR_MODBUS_EMBBADDATA | |
0x1023 | ERROR_MODBUS_EMBBADEXC | |
0x1024 | ERROR_MODBUS_EMBUNKEXC | |
0x1025 | ERROR_MODBUS_EMBMDATA | |
0x1026 | ERROR_MODBUS_EMBBADSLAVE | |
Modbus Library
MODBUS RTU
MODBUS_RTU_CFG
Set bus parameters
in | Bus | string | path to bus device (/dev/ttyS0) | |
in | Baud | int | standard baudrates from 150 to 115200 | |
in | Parity | string[1] | "N" = none, "E" = even, "O" = odd | |
in | Databit | USINT | Databits (5,6,7,8) | |
in | Stopbit | USINT | Stopbits (1,2) | |
out | ERR | bool | indicates some error occurs (0 = OK) | |
out | ERR_ID | WORD | identifies occured error by unique code |
MODBUS_RTU_R_COIL
Reads one coil register
Asynchronous interface | ||||
in | Bus | string | path to bus device (/dev/ttyS0) | |
in | UnitID | byte | device bus address (0-247) | |
in | OfsAdr | word | register address (1-9999) | |
in | Timeout | byte | timeout in seconds | |
out | Q | bool | readed value |
MODBUS_RTU_R_DISCRETE
Read one discrete discrete input register
Asynchronous interface | ||||
in | Bus | string | path to bus device (/dev/ttyS0) | |
in | UnitID | byte | device bus address (0-247) | |
in | OfsAdr | word | register address (1-9999) | |
in | Timeout | byte | timeout in seconds | |
out | Q | bool | readed value |
MODBUS_RTU_R_HOLDING
Reads one holding register
Asynchronous interface | ||||
in | Bus | string | path to bus device (/dev/ttyS0) | |
in | UnitID | byte | device bus address (0-247) | |
in | OfsAdr | word | register address (1-9999) | |
in | Timeout | byte | timeout in seconds | |
out | Q | word | readed value |
MODBUS_RTU_R_INPUT
Reads one input register
Asynchronous interface | ||||
in | Bus | string | path to bus device (/dev/ttyS0) | |
in | UnitID | byte | device bus address (0-247) | |
in | OfsAdr | word | register address (1-9999) | |
in | Timeout | byte | timeout in seconds | |
out | Q | word | readed value |
MODBUS_RTU_W_COIL
Writes value to one coil register
Asynchronous interface | ||||
in | Bus | string | path to bus device (/dev/ttyS0) | |
in | UnitID | byte | device bus address (0-247) | |
in | OfsAdr | word | register address (1-9999) | |
in | Timeout | byte | timeout in seconds | |
in | VAL | bool | value to write |
MODBUS_RTU_W_HOLDING
Writes value to one holding register
Asynchronous interface | ||||
in | Bus | string | path to bus device (/dev/ttyS0) | |
in | UnitID | byte | device bus address (0-247) | |
in | OfsAdr | word | register address (1-9999) | |
in | Timeout | byte | timeout in seconds | |
in | VAL | word | value to write |
IpWatchdog Library
ARP
IPWDG_ARP
Returns ARP ping status of given ip address
Asynchronous interface | ||||
in | IP_ADDR | string | ip address | |
in | TMO_S | int | timeout in seconds | |
out | Q | bool | status |
ICMP
IPWDG_ICMP
Returns ICMP ping status of given ip address
Asynchronous interface | ||||
in | IP_ADDR | string | ip address | |
in | TMO_S | int | timeout in seconds | |
out | Q | bool | status |
Datalogger Library
Logging
DATALOGGER_W_BOOL
Writes binary value to datalogger
Asynchronous interface | ||||
in | KEY | string | key for logged value | |
in | VALUE | bool | value |
Utility Library
Generators
GEN_PULSE
Generates unite pulse
in | T_PER | time | signal period | |
out | Q | bool | output value |
GEN_RECT
Generates rectangle signal
in | T_UP | time | duration of high value | |
in | T_DOWN | time | duration of low value | |
out | Q | bool | output value |
GEN_SQ
Generates square signal
in | T_SQ | time | duration of high or low value | |
out | Q | bool | output value |
Program Library
Program informations
PROGRAM_INFO
Returns informations about running program
out | CYCLE | int | actual cycle number | |
out | RUN_CYCLES | int | cycles to run (0 - infinite loop) | |
out | MS_PER_CYCLE | int | minimum cycle duration | |
out | OVERRUN | bool | previous cycle was longer than requested minimal value |