ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Communication / Modbus functions
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
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
WEBDEV - Server codeWindows This function is now available for WEBDEV websites in Windows.
WEBDEV - Server codeLinux This function is now available for WEBDEV websites in Linux.
Example
// Create a session and connect to a Modbus server
Session is modbusSession
Session = ModbusConnectTCP("192.168.1.7")

// If the connection fails, display the error
IF ErrorOccurred = True THEN
Trace(ErrorInfo())
ELSE
// Write a sequence of 5 floats starting at address 0x42
IF NOT ModbusWriteFloat(Session, 0x42, [1.5, 3.1415, 2.718, -15, 0.0], modbusABCD) THEN
Trace(ErrorInfo())
END
END

// Disconnection
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).
modbusABCDThe sent bytes are stored the same order on the slave device.
modbusBADCThe sent bytes are swapped 2 by 2 on the slave device.
modbusCDABThe sent bytes are swapped 2 by 2 on the slave device.
modbusDCBAThe 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).
modbusABCDThe sent bytes are stored the same order on the slave device.
modbusBADCThe sent bytes are swapped 2 by 2 on the slave device.
modbusCDABThe sent bytes are swapped 2 by 2 on the slave device.
modbusDCBAThe 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
Component: wd290com.dll
Minimum version required
  • Version 26
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/05/2024

Send a report | Local help