ClientRequestWriteMultipleRegistersWide (FB) ¶ FUNCTION_BLOCK ClientRequestWriteMultipleRegistersWide EXTENDS ModbusFB.ClientRequestWriteMultiple WriteMultipleRegisters client request (FC16) for registers > 16bit. For details about client request see |ClientRequest| . For details about “wide registers” and endianess see ServerTCP_extended or ServerSerial_extended . Please visit https://forge.codesys.com/prj/codesys-example/modbus/home to find examples. InOut: Scope Name Type Initial Comment Inherited from Input xExecute BOOL Rising edge: Starts defined operation FALSE : Resets the defined operation after ready condition was reached ETrigTo udiTimeOut UDINT Max. operating time for executing [µs], 0: No operating time limit ETrigTo Output xDone BOOL Ready condition reached ETrigTo xBusy BOOL Operation is running ETrigTo xError BOOL Error condition reached ETrigTo Inout rClient Client Reference to |Client| . ClientRequest Input uiUnitId UINT 0 Unit-Id to send the request to. ClientRequest udiReplyTimeout UDINT (50 * 1000) 50 ms ClientRequest uiMaxRetries UINT 0 Maximum number of request retries in case of “reply timeout”. ClientRequest Output eErrorID Error Error status ClientRequest eException ExceptionCodes Request exception code. ClientRequest uiRetryCnt UINT 0 Number of request retries in case of “reply timeout”. ClientRequest Input uiStartItem UINT 0 First “data item” to write. ClientRequestWriteMultiple uiQuantity UINT 1 Number of “data items” to write. ClientRequestWriteMultiple pData POINTER TO UINT 0 Pointer to data. uiDataItemSize UINT “data item” size / register width (in bytes).
Server ¶ ServerSerial_extended (FunctionBlock) “wide registers” and endianess ServerTCP_extended (FunctionBlock) “wide registers” and endianess
ServerSerial_extended (FB) ¶ FUNCTION_BLOCK ServerSerial_extended EXTENDS ModbusFB.ServerSerial MODBUS Serial server (slave) with non-standard extensions. ServerSerial_extended actually supports beyond the ServerSerial features: - “wide register” (registers > 16bit) Other non-standard extensions might be added here, but not on ServerSerial. “wide registers” and endianess ¶ The MODBUS standard defines the length of input / holding registers to read/write with 16-bit - no way out of this. The message definitions in the MODBUS standard come with some room for non-standard interpretation. FC03 Read Holding Registers should be used as an example here: Request: Quantity of Registers Response: Byte count So a non-standard MODBUS server can inform a client in the response indirectly about the register width (Response:Byte count = Request:Quantity of Registers * register width in Bytes). This fact leaded some vendors to implement MODBUS devices with registers > 16bit. Because the CODESYS ModbusFB lib should be usable with such non-standard devices (clients as well as servers) there is a Server*_extended and some related ClientRequest*RegistersWide in this library. Following client requests can be used with “wide registers”: - Read Holding Registers - Read Input Registers - Write Multiple registers - Read/Write Multiple registers Following client requests can not be used with “wide registers” because of their MODBUS protocol data unit (PDU) definition: - Write Single Register - Mask Write Register because the “data item” width is explicitly defined to be 16bit. A standard MODBUS client requesting register data from such a non-standard MODBUS server, unfortunately requesting register data from a register > 16bit gets confronted with an invalid Response: Byte count <> Quantity of Registers * 2, and will most likely drop such a response as invalid or less likely put out error/warning/information on this fact. The MODBUS standard defines byte ordering in MODBUS messages to read/write 16-bit registers. The MODBUS standard doesnt define anything beyond this - so there is no rule for byte ordering in “wide registers”. This ServerSerial_extended is using the same byte ordering for register data > 16bit as defined in the MODBUS standard (“big-Endian” representation). So for example register size 32bit value 0x12345678 - the first byte sent is 0x12 then 0x34, 0x56, 0x78. Please visit https://forge.codesys.com/prj/codesys-example/modbus/home to find examples. InOut: Scope Name Type Initial Comment Inherited from Input xEnable BOOL FALSE Enables the server, take over the configuration information fcsSupported and dataModel. If the “data model” (tableDefinitions) contains configuration errors, the Server will not got busy (xBusy = FALSE). Server fcsSupported SupportedFcs Constants.SUPPORTED_FCS_SIMPLE_SERVER Supported “function codes”, accepted at xEnable FALSE => TRUE. In case fcsSupported is not assigned by the application it defaults to |Constants.SUPPORTED_FCS_SIMPLE_SERVER| . Server dataModel TableDefinitions “data model”, accepted at xEnable FALSE => TRUE. Server tInactivityInfoTime UDINT 0 “inactivity info time” (in milliseconds). If no valid requests are received in this time xInactive is signaling inactivity - default = 0 -> no “inactivity info”. Server Output xRunning BOOL Server is up and running, waiting for requests. Server xError BOOL Error Server eErrorID Error Error status Server xInactive BOOL No valid requests received for tInactivityTimeOut. Server udiNumMsgRecv UDINT Number of request messages received since enabling the Server. Server udiNumMsgReply UDINT Number of reply messages send since enabling the Server. Server udiNumMsgExcReply UDINT Number of exception reply messages send since enabling the Server. Server udiNumMsgExcReplyIllFct UDINT Number of exception reply messages send since enabling the Server, signaling illegal function. Server udiNumMsgExcReplyIllDataAdr UDINT Number of exception reply messages send since enabling the Server, signaling illegal data address. Server udiNumMsgExcReplyIllDataValue UDINT Number of exception reply messages send since enabling the Server, signaling illegal data value. Server xReadRequest BOOL Read request(s) happened since last call, rejected requests included. Server udiNumReadRequests UDINT Read request counter, rejected requests included. Server xWriteRequest BOOL Write request(s) happened since last call, rejected requests included. Server udiNumWriteRequests UDINT Write request counter, rejected requests included. Server Input uiUnitId UINT 1 Unit-Id / Slave address. Only read when rising edge on xEnable occurs. Slave address has to be in range 1 .. 247 according to MODBUS standard. ServerSerial iPort SysCom.SYS_COM_PORTS SysCom.SYS_COM_PORTS.SYS_COMPORT_NONE Serial port. Only read when rising edge on xEnable occurs. ServerSerial dwBaudrate SysCom.SYS_COM_BAUDRATE SysCom.SYS_COM_BAUDRATE.SYS_BR_115200 Baud rate. Only read when rising edge on xEnable occurs. ServerSerial byDataBits BYTE 8 Number of data bits/BYTE, 4-8. Only read when rising edge on xEnable occurs. ServerSerial eParity SysCom.SYS_COM_PARITY SysCom.SYS_COM_PARITY.SYS_NOPARITY Parity. Only read when rising edge on xEnable occurs. ServerSerial eStopBits SysCom.SYS_COM_STOPBITS SysCom.SYS_COM_STOPBITS.SYS_ONESTOPBIT Stop bits. Only read when rising edge on xEnable occurs. ServerSerial eDTRcontrol SysCom.SYS_COM_DTR_CONTROL SysCom.SYS_COM_DTR_CONTROL.SYS_DTR_CONTROL_DISABLE DTR control. Only read when rising edge on xEnable occurs. ServerSerial eRTScontrol SysCom.SYS_COM_RTS_CONTROL SysCom.SYS_COM_RTS_CONTROL.SYS_RTS_CONTROL_DISABLE RTS control. Only read when rising edge on xEnable occurs. ServerSerial eRtuAscii RtuAscii RtuAscii.RTU RTU / ASCII. Only read when rising edge on xEnable occurs. ServerSerial udiLogOptions UDINT LoggingOptions.ServerStartStop Logging options. ServerSerial
ServerTCP_extended (FB) ¶ FUNCTION_BLOCK ServerTCP_extended EXTENDS ModbusFB.ServerTCP MODBUS TCP server (slave) with non-standard extensions. ServerTCP_extended actually supports beyond the ServerTCP features: - “wide register” (registers > 16bit) Other non-standard extensions might be added here, but not on ServerTCP. “wide registers” and endianess ¶ The MODBUS standard defines the length of input / holding registers to read/write with 16-bit - no way out of this. The message definitions in the MODBUS standard come with some room for non-standard interpretation. FC03 Read Holding Registers should be used as an example here: Request: Quantity of Registers Response: Byte count So a non-standard MODBUS server can inform a client in the response indirectly about the register width (Response:Byte count = Request:Quantity of Registers * register width in Bytes). This fact leaded some vendors to implement MODBUS devices with registers > 16bit. Because the CODESYS ModbusFB lib should be usable with such non-standard devices (clients as well as servers) there is a Server*_extended and some related ClientRequest*RegistersWide in this library. Following client requests can be used with “wide registers”: - Read Holding Registers - Read Input Registers - Write Multiple registers - Read/Write Multiple registers Following client requests can not be used with “wide registers” because of their MODBUS protocol data unit (PDU) definition: - Write Single Register - Mask Write Register because the “data item” width is explicitly defined to be 16bit. A standard MODBUS client requesting register data from such a non-standard MODBUS server, unfortunately requesting register data from a register > 16bit gets confronted with an invalid Response: Byte count <> Quantity of Registers * 2, and will most likely drop such a response as invalid or less likely put out error/warning/information on this fact. The MODBUS standard defines byte ordering in MODBUS messages to read/write 16-bit registers. The MODBUS standard doesnt define anything beyond this - so there is no rule for byte ordering in “wide registers”. This ServerTCP_extended is using the same byte ordering for register data > 16bit as defined in the MODBUS standard (“big-Endian” representation). So for example register size 32bit value 0x12345678 - the first byte sent is 0x12 then 0x34, 0x56, 0x78. Please visit https://forge.codesys.com/prj/codesys-example/modbus/home to find examples. InOut: Scope Name Type Initial Comment Inherited from Input xEnable BOOL FALSE Enables the server, take over the configuration information fcsSupported and dataModel. If the “data model” (tableDefinitions) contains configuration errors, the Server will not got busy (xBusy = FALSE). Server fcsSupported SupportedFcs Constants.SUPPORTED_FCS_SIMPLE_SERVER Supported “function codes”, accepted at xEnable FALSE => TRUE. In case fcsSupported is not assigned by the application it defaults to |Constants.SUPPORTED_FCS_SIMPLE_SERVER| . Server dataModel TableDefinitions “data model”, accepted at xEnable FALSE => TRUE. Server tInactivityInfoTime UDINT 0 “inactivity info time” (in milliseconds). If no valid requests are received in this time xInactive is signaling inactivity - default = 0 -> no “inactivity info”. Server Output xRunning BOOL Server is up and running, waiting for requests. Server xError BOOL Error Server eErrorID Error Error status Server xInactive BOOL No valid requests received for tInactivityTimeOut. Server udiNumMsgRecv UDINT Number of request messages received since enabling the Server. Server udiNumMsgReply UDINT Number of reply messages send since enabling the Server. Server udiNumMsgExcReply UDINT Number of exception reply messages send since enabling the Server. Server udiNumMsgExcReplyIllFct UDINT Number of exception reply messages send since enabling the Server, signaling illegal function. Server udiNumMsgExcReplyIllDataAdr UDINT Number of exception reply messages send since enabling the Server, signaling illegal data address. Server udiNumMsgExcReplyIllDataValue UDINT Number of exception reply messages send since enabling the Server, signaling illegal data value. Server xReadRequest BOOL Read request(s) happened since last call, rejected requests included. Server udiNumReadRequests UDINT Read request counter, rejected requests included. Server xWriteRequest BOOL Write request(s) happened since last call, rejected requests included. Server udiNumWriteRequests UDINT Write request counter, rejected requests included. Server Input wsInterfaceName WSTRING(255) ETH interface name to bind to, “” to bind to any ETH interface. Only read when rising edge on xEnable occurs. ServerTCP uiPort UINT 502 ETH port to use. Only read when rising edge on xEnable occurs. ServerTCP xReset BOOL FALSE Reset the server. ServerTCP udiLogOptions UDINT LoggingOptions.ServerStartStop Logging options. ServerTCP Output uiConnectedClients UINT Number of actually connected clients. ServerTCP
File and Project Information ¶ Scope Name Type Content FileHeader creationDateTime date 20.04.2021, 14:26:06 companyName string 3S-Smart Software Solutions GmbH libraryFile ModbusFB non standard extensions.library primaryProject True productName CODESYS productProfile CODESYS V3.5 SP16 Patch 3 contentFile ModbusFB non standard extensions.clean.json version version 2.0.0.0 ProjectInformation AutoResolveUnbound bool True IsEndUserLibrary False Released True SourceLibrary False LastModificationDateTime date 20.04.2021, 14:26:06 LibraryCategories library-category-list Application|Fieldbus Author string 3S - Smart Software Solutions GmbH Company 3S - Smart Software Solutions GmbH CompiledLibraryCompatibilityVersion CODESYS V3.5 SP16 DefaultNamespace ModbusFB_ext Description See: Description DocFormat reStructuredText LanguageModelAttribute qualified-access-only Placeholder ModbusFB_ext Project ModbusFB non standard extensions Title ModbusFB non standard extensions Version version 3.5.17.0
Library Reference ¶ This is a dictionary of all referenced libraries and their name spaces. 3SLicense ¶ Library Identification ¶ Placeholder: 3SLicense Default Resolution: 3SLicense, * (3S - Smart Software Solutions GmbH) Namespace: _3S_LICENSE Library Properties ¶ LinkAllContent: False Optional: False QualifiedOnly: False SystemLibrary: False Key: 3SLicense CmpErrors2 Interfaces ¶ Library Identification ¶ Name: CmpErrors2 Interfaces Version: newest Company: System Namespace: CmpErrors Library Properties ¶ LinkAllContent: False Optional: False QualifiedOnly: False SystemLibrary: False Key: CmpErrors2 Interfaces, * (System) CmpLog ¶ Library Identification ¶ Placeholder: CmpLog Default Resolution: CmpLog, * (System) Namespace: CmpLog Library Properties ¶ LinkAllContent: False Optional: False QualifiedOnly: False SystemLibrary: False Key: CmpLog Common Behaviour Model ¶ Library Identification ¶ Placeholder: CBML Default Resolution: Common Behaviour Model, * (3S - Smart Software Solutions GmbH) Namespace: CBML Library Properties ¶ LinkAllContent: False Optional: False QualifiedOnly: True SystemLibrary: False Key: CBML Component Manager ¶ Library Identification ¶ Placeholder: Component Manager Default Resolution: Component Manager, * (System) Namespace: Component_Manager Library Properties ¶ LinkAllContent: False Optional: False QualifiedOnly: False SystemLibrary: False Key: Component Manager ModbusFB ¶ Library Identification ¶ Placeholder: ModbusFB Default Resolution: ModbusFB, * (3S - Smart Software Solutions GmbH) Namespace: ModbusFB Library Properties ¶ LinkAllContent: False Optional: False QualifiedOnly: True SystemLibrary: False Key: ModbusFB Standard ¶ Library Identification ¶ Placeholder: Standard Default Resolution: Standard, * (System) Namespace: Standard Library Properties ¶ LinkAllContent: False Optional: False QualifiedOnly: False SystemLibrary: False Key: Standard StringUtils ¶ Library Identification ¶ Placeholder: StringUtils Default Resolution: StringUtils, * (System) Namespace: Stu Library Properties ¶ LinkAllContent: False Optional: False QualifiedOnly: False SystemLibrary: False Key: StringUtils SysCom ¶ Library Identification ¶ Placeholder: SysCom Default Resolution: SysCom, * (System) Namespace: SysCom Library Properties ¶ LinkAllContent: False Optional: False QualifiedOnly: False SystemLibrary: False Key: SysCom SysCpuHandling ¶ Library Identification ¶ Placeholder: SysCpuHandling Default Resolution: SysCpuHandling, * (System) Namespace: SysCpuHandling Library Properties ¶ LinkAllContent: False Optional: False QualifiedOnly: False SystemLibrary: False Key: SysCpuHandling SysMem ¶ Library Identification ¶ Placeholder: SysMem Default Resolution: SysMem, * (System) Namespace: SysMem Library Properties ¶ LinkAllContent: False Optional: False QualifiedOnly: False SystemLibrary: False Key: SysMem SysSocket ¶ Library Identification ¶ Placeholder: SysSocket Default Resolution: SysSocket, * (System) Namespace: SysSocket Library Properties ¶ LinkAllContent: False Optional: False QualifiedOnly: False SystemLibrary: False Key: SysSocket SysTarget ¶ Library Identification ¶ Placeholder: SysTarget Default Resolution: SysTarget, * (System) Namespace: SysTarget Library Properties ¶ LinkAllContent: False Optional: False QualifiedOnly: False SystemLibrary: False Key: SysTarget SysTime ¶ Library Identification ¶ Name: SysTime Version: 3.5.9.0 Company: System Namespace: SysTime Library Properties ¶ LinkAllContent: False Optional: False QualifiedOnly: False SystemLibrary: False Key: SysTime, 3.5.9.0 (System) SysTypes2 Interfaces ¶ Library Identification ¶ Name: SysTypes2 Interfaces Version: newest Company: System Namespace: SysTypes Library Properties ¶ LinkAllContent: False Optional: False QualifiedOnly: False SystemLibrary: False Key: SysTypes2 Interfaces, * (System)
ClientRequestWriteSingle (FB) ¶ FUNCTION_BLOCK ABSTRACT ClientRequestWriteSingle EXTENDS ClientRequest WriteSingle client request base class for WriteSingleCoil, WriteSingleRegister and MaskWriteRegister. InOut: Scope Name Type Initial Comment Inherited from Input xExecute BOOL Rising edge: Starts defined operation FALSE : Resets the defined operation after ready condition was reached ETrigTo udiTimeOut UDINT Max. operating time for executing [µs], 0: No operating time limit ETrigTo Output xDone BOOL Ready condition reached ETrigTo xBusy BOOL Operation is running ETrigTo xError BOOL Error condition reached ETrigTo Inout rClient Client Reference to Client . ClientRequest Input uiUnitId UINT 0 Unit-Id to send the request to. ClientRequest udiReplyTimeout UDINT (50 * 1000) Reply timeout in µs - accepted maxmimum time between request message send and reply message receveived - default 50ms. ClientRequest uiMaxRetries UINT 0 Maximum number of request retries in case of “reply timeout”. ClientRequest Output eErrorID Error Error status ClientRequest eException ExceptionCodes Request exception code. ClientRequest uiRetryCnt UINT 0 Number of request retries in case of “reply timeout”. ClientRequest Input uiItem UINT 0 “data item” to write.
ClientRequestWriteSingleCoil (FB) ¶ FUNCTION_BLOCK ClientRequestWriteSingleCoil EXTENDS ClientRequestWriteSingle WriteSingleCoil client request (FC05). For details about client request see ClientRequest . InOut: Scope Name Type Initial Comment Inherited from Input xExecute BOOL Rising edge: Starts defined operation FALSE : Resets the defined operation after ready condition was reached ETrigTo udiTimeOut UDINT Max. operating time for executing [µs], 0: No operating time limit ETrigTo Output xDone BOOL Ready condition reached ETrigTo xBusy BOOL Operation is running ETrigTo xError BOOL Error condition reached ETrigTo Inout rClient Client Reference to Client . ClientRequest Input uiUnitId UINT 0 Unit-Id to send the request to. ClientRequest udiReplyTimeout UDINT (50 * 1000) Reply timeout in µs - accepted maxmimum time between request message send and reply message receveived - default 50ms. ClientRequest uiMaxRetries UINT 0 Maximum number of request retries in case of “reply timeout”. ClientRequest Output eErrorID Error Error status ClientRequest eException ExceptionCodes Request exception code. ClientRequest uiRetryCnt UINT 0 Number of request retries in case of “reply timeout”. ClientRequest Input uiItem UINT 0 “data item” to write. ClientRequestWriteSingle xValue BOOL FALSE
ClientRequestWriteSingleRegister (FB) ¶ FUNCTION_BLOCK ClientRequestWriteSingleRegister EXTENDS ClientRequestWriteSingle WriteSingleRegister client request (FC06). For details about client request see ClientRequest . InOut: Scope Name Type Initial Comment Inherited from Input xExecute BOOL Rising edge: Starts defined operation FALSE : Resets the defined operation after ready condition was reached ETrigTo udiTimeOut UDINT Max. operating time for executing [µs], 0: No operating time limit ETrigTo Output xDone BOOL Ready condition reached ETrigTo xBusy BOOL Operation is running ETrigTo xError BOOL Error condition reached ETrigTo Inout rClient Client Reference to Client . ClientRequest Input uiUnitId UINT 0 Unit-Id to send the request to. ClientRequest udiReplyTimeout UDINT (50 * 1000) Reply timeout in µs - accepted maxmimum time between request message send and reply message receveived - default 50ms. ClientRequest uiMaxRetries UINT 0 Maximum number of request retries in case of “reply timeout”. ClientRequest Output eErrorID Error Error status ClientRequest eException ExceptionCodes Request exception code. ClientRequest uiRetryCnt UINT 0 Number of request retries in case of “reply timeout”. ClientRequest Input uiItem UINT 0 “data item” to write. ClientRequestWriteSingle uiValue UINT 0
ClientSerial (FB) ¶ FUNCTION_BLOCK ClientSerial EXTENDS Client IMPLEMENTS ISysComUser MODBUS serial client (master). Please note: some input variables related to connection configuration are read when rising edge on xConnect occurs. To change connection configuration the application needs to - disconnect (xConnect := FALSE and execute the FB) - modify the related input variables - connect (xConnect := TRUE and execute the FB) The Client provides some statistics of sent request messages and received valid reply messages. Invalid messages are dropped at the communication level, so doesnt appear in the statistics. To analyse situations where invalid reply messages might occur, you can use udiLogOptions with LoggingOptions.WarnOnReceivedInvalidFrames. The maximum number of serial ports usable with ClientSerial / ServerSerial is limited to MAX_NUM_COMPORTS. In case there is a need to use more serial ports, anyone can set the library parameter MAX_NUM_COMPORTS within an application - see Library Manager -> ModbusFB -> Parameter -> MAX_NUM_COMPORTS. Please visit https://forge.codesys.com/prj/codesys-example/modbus/home to find examples. InOut: Scope Name Type Initial Comment Inherited from Input xConnect BOOL FALSE Connect to server (slave). Client Output xConnected BOOL Client (master) is connected to server (slave). Client xError BOOL Error Client eErrorID Error Error status Client udiNumMsgSent UDINT Number of request messages send since connect. Client udiNumMsgReply UDINT Number of reply messages received since connect. Client udiNumMsgExcReply UDINT Number of exception reply messages received since connect. Client udiNumMsgExcReplyIllFct UDINT Number of exception reply messages received since connect, signaling illegal function. Client udiNumMsgExcReplyIllDataAdr UDINT Number of exception reply messages received since connect, signaling illegal data address. Client udiNumReplyTimeouts UDINT Number of reply timeouts since connect. Client udiNumReqNotProcessed UDINT Number of requests not processed in time (“request starvation”) since connect. Client udiNumReqParamError UDINT Number of requests started with parameter error, for example “Read Coils” -> “Quantity of coils” = 0. Client udiLastTransactionTime UDINT Transaction time in ms - time difference between request message send und reply message received. Client Input iPort SysCom.SYS_COM_PORTS SysCom.SYS_COM_PORTS.SYS_COMPORT_NONE Serial port, only read when rising edge on xConnect occurs. dwBaudrate SysCom.SYS_COM_BAUDRATE SysCom.SYS_COM_BAUDRATE.SYS_BR_115200 Baud rate, only read when rising edge on xConnect occurs. byDataBits BYTE 8 Number of data bits/BYTE, 5-8, only read when rising edge on xConnect occurs. eParity SysCom.SYS_COM_PARITY SysCom.SYS_COM_PARITY.SYS_NOPARITY Parity, only read when rising edge on xConnect occurs. eStopBits SysCom.SYS_COM_STOPBITS SysCom.SYS_COM_STOPBITS.SYS_ONESTOPBIT Stop bits, only read when rising edge on xConnect occurs. eDTRcontrol SYS_COM_DTR_CONTROL SysCom.SYS_COM_DTR_CONTROL.SYS_DTR_CONTROL_DISABLE DTR control, only read when rising edge on xConnect occurs. eRTScontrol SysCom.SYS_COM_RTS_CONTROL SysCom.SYS_COM_RTS_CONTROL.SYS_RTS_CONTROL_DISABLE RTS control, only read when rising edge on xConnect occurs. eRtuAscii RtuAscii RtuAscii.RTU RTU / ASCII, only read when rising edge on xConnect occurs. udiLogOptions UDINT LoggingOptions.ClientConnectDisconnect Logging options.