|
|
|
|
ModbusWriteFloat (Function) In french: ModbusEcritFlottant Writes one or more single-precision floats to a Modbus slave, starting at a specific address. Remarks: - This function is used to write one or more single-precision floats in contiguous registers in the slave.
- This function blocks the application until the slave acknowledges the message or until the session timeout is exceeded.
- The writing of one or more floats corresponds to Modbus function code 16 (Write Multiple Holding Registers)..
New in version 2024
Session is modbusSession
Session = ModbusConnectTCP("192.168.1.7")
IF ErrorOccurred = True THEN
Trace(ErrorInfo())
ELSE
IF NOT ModbusWriteFloat(Session, 0x42, [1.5, 3.1415, 2.718, -15, 0.0], modbusABCD) THEN
Trace(ErrorInfo())
END
END
ModbusDisconnect(Session)
Syntax
Writing 1 single-precision float to a Modbus slave Hide the details
<Result> = ModbusWriteFloat(<Session> , <Address> , <Floating> , <Endianness>)
<Result>: Boolean - True if written successfully,
- False otherwise. To get more details on the error, use ErrorInfo with the errMessage constant.
<Session>: modbusSession variable Name of the modbusSession variable that corresponds to the communication session with the Modbus slave. <Address>: Integer Value between 0 and 65,535 that corresponds to the address (slave) to which the single-precision float must be written. <Floating>: Real Value of the single-precision float to be written to the register. <Endianness>: Integer constant Mode for storing float values on the slave device. Bytes are identified from A to D. A is the most significant byte and D is the least significant byte (IEEE-754 standard). | | modbusABCD | The sent bytes are stored the same order on the slave device. | modbusBADC | The sent bytes are swapped 2 by 2 on the slave device. | modbusCDAB | The sent bytes are swapped 2 by 2 on the slave device. | modbusDCBA | The sent bytes are swapped on the slave device. |
Writing multiple single-precision floats to a Modbus slave Hide the details
<Result> = ModbusWriteFloat(<Session> , <Address> , <Floats to be sent> , <Endianness>)
<Result>: Boolean - True if written successfully,
- False otherwise. To get more details on the error, use ErrorInfo with the errMessage constant.
<Session>: modbusSession variable Name of the modbusSession variable that corresponds to the communication session with the Modbus slave. <Address>: Integer Value between 0 and 65,535 that corresponds to the address (slave) to which the single-precision floats must be written. <Floats to be sent>: Array Name of the array of single-precision reals to be sent. <Endianness>: Integer constant Mode for storing float values on the slave device. Bytes are identified from A to D. A is the most significant byte and D is the least significant byte (IEEE-754 standard). | | modbusABCD | The sent bytes are stored the same order on the slave device. | modbusBADC | The sent bytes are swapped 2 by 2 on the slave device. | modbusCDAB | The sent bytes are swapped 2 by 2 on the slave device. | modbusDCBA | The sent bytes are swapped on the slave device. |
Remarks CAUTION: Since write operations make it possible to control PLCs, it is recommended to test the different commands before the production phase to make sure the PLCs perform the required operations. Business / UI classification: Business Logic
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|