PLC libraries Requirements 7.1.11.9 FB_MBUdpReadWriteRegs (Modbus function 23) This function first reads 1 to 128 output registers (16 bit) and then writes 1 to 128 output registers (16 bit). VAR_INPUT VAR_INPUT sIPAddr : STRING(15); nTCPPort : UINT:= MODBUS_TCP_PORT; nUnitID : BYTE:=16#FF; nReadQuantity : WORD; nMBReadAddr : WORD; nWriteQuantity : WORD; nMBWriteAddr : WORD; cbDestLength : UDINT; pDestAddr : UDINT; cbSrcLength : UDINT; pSrcAddr : UDINT; bExecute : BOOL; tTimeout : TIME; END_VAR sIPAddr : Is a string containing the IP address of the target device. nTCPPort : Port number of the target device. nUnitID : Identification number of a serial sub-network device.
If a device is addressed directly via TCP/IP, this value must be 16#FF. nReadQuantity : Number of output registers (data words) to be read. The value of nReadQuantity must be > 0. nMBReadAddr : Start address of the output registers to be read (word offset). TS6250 47 Version: 1.2 Function specific ADS error code Possible reason 0x8001 Modbus function not implemented 0x8002 Invalid address or length 0x8003 Invalid parameters: - wrong number of registers 0x8004 Modbus server error Development environment Target system type PLC libraries to be linked TwinCAT v2.8.0 PC (i386) TcModbusSrv.Lib