Internet PLC Forum

General => Technical support => Topic started by: EDGAR on October 05, 2009, 07:45:11 PM

Title: Modbus TCP Function?
Post by: EDGAR on October 05, 2009, 07:45:11 PM
Hello All,
The F-Series Modbus TCP, Is it possible to read/write to a discrete coil? I don't see it in the specifications. Can we write costume functions?

Thanks,
Ed
Title: Re:Modbus TCP Function?
Post by: support on October 05, 2009, 09:18:01 PM
Discrete coil will require function 05, which is not supported by the WRITEMODBUS or WRITEMB2 command. To change a single bit you will need to read the entire 16-bit channel, change one bit and write back the channel data to the PLC.

Alternatively, you can use some DM locations and writing a 1 to it tells the PLC to turn ON a bit and writing a 0 to it tells the PLC to turn it OFF. Within the PLC program every scan of the custom function you will examine the value of the DM and use SETIO or CLRIO to affect the bit. This is the simplest way if the number of I/O involved is small.
Title: Re:Modbus TCP Function?
Post by: EDGAR on October 06, 2009, 07:20:54 PM
I was just wondering, some third controllers you can't access coil info using functions 3 or 4 unless they save the values on registers. I'm communicating with a PLC that if I need to get a coil value I need to use functions 1 or 2 and 5 to write. Before I start finagling with the NetCommand and other function is it possible?
Title: Re:Modbus TCP Function?
Post by: support on October 07, 2009, 09:59:33 AM
If you are using serial port than you could write in TBASIC functions that will emulate the MODBUS function 01, 02, 05, and 06. You will need to use INCOMM and OUTCOMM since you have to handle binary data. There are examples program that you can download from the following FAQ thread:

http://www.tri-plc.com/yabbse/index.php?board=2;action=display;threadid=298

However, you can't do the same on the Ethernet channel because INCOMM(4) and OUTCOMM 4,xx are not supported and will have no effects.  Only PRINT #4 and INPUT$(4) are supported which limit handling to non-zero ASCII strings only.