How to calculate a Modbus Coil address

24 May 2023

This article shows you how to calculate a Modbus coil address from a register address when you want to use Modbus Function Code 1 or Function Code 15

 

APPLICABLE PRODUCTS

All Modbus products

 

PRE-REQUISITES

Register address of the values that you want to read with Modbus function code 1 (FC01) or you want to write with Modbus function code 15 (FC15) 

 

IN THIS ARTICLE

If you want to use the FC01 "Read Coil" or FC15 "Force Multiple Coils" but only have the register address instead of the corresponding coil address, just use the following calculation to get the proper values.

 

Example: 

You want to read individual bits from 16 bit register 85 with the FC01.

Simply calculate [your register address] times 16, subtracted by 15.  For the above example, this yields 85 x 16 - 15 = 1345.

 

Another example:

You want to write individual bits in 16 bit register 1128 with FC15.

Simply calculate [your register address] times 16, subtracted by 15.  This yields
1128 x 16 - 15 = 18033.

 

ADDITIONAL INFO 

Modbus Function Code 01 | Read Coil Status | Simply Modbus Software

Modbus Function Code 15 | Force Multiple Coils | Simply Modbus Software