READMODBUS (ch, DeviceID, address)
Purpose Automatically query a MODBUS ASCII device and return the 16-bit register data using the MODBUS ASCII protocol. The communication baud rate is the default baud rate of that COMM unless it has been changed by the SETBAUD command.
ch PLC COMM port number (1-8)
DeviceID device ID of the MODBUS device (1 to 255)
address -offset address of the holding register in the MODBUS device.
Examples relay [3] = READMODBUS (3, 5, 101)
Comments: The relay will contain the 16-bit data obtained from the MODBUS device with ID = 05 and from register offset address 101 (in MODBUS term this refer to the #40102 holding register) . Reading it into the relay[ ] channel allows bit level manipulation by ladder logic. It can of course also be read into any data memory. 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 in the user program by executing the STATUS(2) function, which will return a ‘0’ if there is any error or if the slave device is not present.
See Also WRITEMODBUS, STATUS(2), NETCMD$( )

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