*WRITEMB2 ch, ID, addr, var, count      {* Applicable only to M+PLC with firmware r44 or higher}

Purpose Think of this as the multi-word version of WRITE MODBUS command.
ch - PLC COMM port number (1 to 8 using Modbus ASCII or 11to 18 using Modbus RTU).
ID - Device ID of the MODBUS slave device (1 to 255)
addr - Zero-offset address of the holding register in the MODBUS slave device starting from 0 (equals to 40001 in MODBUS Holding register).
var - The starting variable in the master whose data is to be sent out (may be a DM or any system variable)
count - number of variables to send (max. =16 in M+ PLC).
Examples    WRITEMB2 13,5,101,DM[10],8
Comments The PLC will use MODBUS RTU protocol, via its Comm port #3, to write 8 words of data from DM[11] to DM[17] to the slave MODBUS device with ID = 05 and into it's register offset address 101 to 108 (in MODBUS term this refer to the #40102 to #40109 holding register) .

The command automatically checks the response string received from the slave device for the correct slave address CRC16. Like READMODBUS command, the status of this operation can be checked by the user program by testing the STATUS(2) function.

See Also READMB2, STATUS(2)

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