PLC libraries 7.1.11.8 FB_MBUdpWriteRegs (Modbus function 16) This function is used for writing 1 to 128 output registers (16 bit). VAR_INPUT VAR_INPUT sIPAddr : STRING(15); nTCPPort : UINT:= MODBUS_TCP_PORT; nUnitID : BYTE:=16#FF; nQuantity : WORD; nMBAddr : WORD; cbLength : 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. nQuantity: Number of output registers (data words) to be written. nMBAddr:
Start address of the output registers to be written (word offset). cbLength: Contains the max. byte size of the source buffer. The minimum buffer byte size must be: nQuantity * 2 . pSrcAddr: Contains the address of the source buffer containing the data to be written. The buffer can be a single variable, an array or a structure, whose address can be found with the ADR operator. bExecute The function block is activated by a rising edge at this input. tTimeout: States the length of the timeout that may not be exceeded by execution of the ADS command. VAR_OUTPUT VAR_OUTPUT bBUSY : BOOL; bError : BOOL; nErrId : UDINT; END_VAR bBusy: When the function block is activated this output is set.
It remains set until an acknowledgement is received. bError: If an ADS error should occur during the transfer of the command, then this output is set once the bBusy output is reset. nErrId: Supplies the ADS error number when the bError output is set. TS6250 46 Version: 1.2