Home » Categories » Protocols » Modbus

How do I read/write Modbus binary data?

In a Modbus system, bit-level data is referred to as either "Coils" (read/write bit-level data) or "Input Status" (read only bit-level data.) The Modbus protocol uses Function Codes in commands to specify both the action (read or write) and data object (input coil bits, output coil bits, or input status bits.)

To read Input Status bit-level data, use Function Code 2.

To read Coil bit-level data, use Function Code 1.

To write Coil bit-level data, use Function Code 5 to write a single Coil (bit), or Function Code 15 to write multiple Coils (bits).

For all ProSoft MCM solutions, be sure to use bit-level addresses to the module's internal database for any bit-level Modbus Commands. To find the bit level address for any bit in the module's internal database, use the formula: Register number times 16, plus the bit position number (plus 1 if you are telling a Modbus Master what address to poll when the MCM is a Slave.)

This assumes the first internal database register is Register Address 0 and the lowest order bit of any register is Bit 0.

So, for instance, if you want to write the value of Bit 10 of module database register address 100, the calculation would be:

100 * 16 = 1600 + 10 = 1610 as the Internal Address to use in the bit-level command if the MCM is the Modbus Master, or...

100 * 16 = 1600 + 10 + 1 = 1611, if the MCM is a Slave to a remote Modbus Master.

Custom Fields
    Attachments (0) Attachments
    There are no attachments for this article.
    Comments Comments
    There are no comments for this article. Be the first to post a comment.
    Related Articles RSS Feed
    How do I monitor the health of coms to my slaves when the module is a Master?
    Viewed 1 times since Wed, Nov 29, 2006
    What are the causes of a -11 error code using a ProSoft Modbus product?
    Viewed 1 times since Mon, May 17, 2010
    Read Commands from my Modbus Master to a ProSoft MCM Slave are working but Write Commands are failing. How do I fix this?
    Viewed 1 times since Fri, Feb 8, 2008
    I have a ProSoft Modbus Master solution and would like to know, is the Slave Status List the best place to monitor for communications health of the network?
    Viewed 1 times since Tue, Mar 18, 2008
    Do any Prosoft modules support Modbus UDP?
    Viewed 1 times since Mon, Aug 24, 2015
    How can a module's Modbus port, configured as a Slave port, detect communication loss with the Master port?
    Viewed 1 times since Tue, Nov 28, 2006
    I am trying to use a ProSoft Modbus solution to send/receive data to a MSA Ultima X gas dectection system with Modbus interface and am having problems. How can I resolve this issue?
    Viewed 1 times since Thu, Apr 24, 2008
    How do you detect the individual Slave failure?
    Viewed 1 times since Wed, Nov 29, 2006
    What Modbus address would we need to put into the MODSIM32 simulator if we specified on the MVI56-MCM device address to 8680HEX (-31104 decimal) when the MVI56-mcm is the slave?
    Viewed 1 times since Tue, Nov 28, 2006
    I have multiple Modbus masters that need to communicate with 1 or more Modbus serial (RTU) slave devices. What product should be used??
    Viewed 1 times since Tue, Jan 23, 2007