WRITEMODBUS ch, DeviceID, address, data
Purpose Automatically write the 16-bit data to a MODBUS device using the MODBUS RTU/ASCII protocol. The communication baud rate is the default baud rate of that COMM port unless it has been changed by the SETBAUD command.

ch = PLC COMM port number. 1-8 for MODBUS ASCII and 11-18 for MODBUS RTU (11 is com1, 12 is com2, etc)

DeviceID = Device ID of the MODBUS device. (1 to 255)

Address = Zero-offset address of the holding register in the MODBUS device.

data = the 16-bit data to be written to the MODBUS device

Comments: The command automatically checks the response string received from the slave device for the correct LRC and the slave address. The status of the operation can be checked by the user program by testing the STATUS(2) function, which will return a ‘1’ for successful command and a ‘0’ if there is any error or if the slave device is not present.
Examples WRITEMODBUS 3, 8, 1000, 1234
  The data 1234 will be written to the MODBUS device with ID=08 at the holding register offset address 1000 (in MODBUS convention this refer to holding register #41001).
See Also READMODBUS( ), STATUS(2)NETCMD$( )

backbutton.gif (507 bytes)  Basic to TBASIC Reference Manual