You are on page 1of 14

MVI56-MCM Modbus Card Setting

USING THE CARD AS MODBUS MASTER

WriteData means the data passed onto Modbus Slave with Function Codes: 5 (Single Coil Write), 6
(Single Register Write), 15 (Multiple Coil Write), 16 (Multiple Register Write)

ReadData means the data received from Modbus Slave in response to Fuction Codes: 1 (Read Output
Status), 2 (Read Input Status), 3 (Read Multiple Registers), 4 (Read Input Registers).

First Define following (assuming you have 200 words of data to be read & another
200 words to be written)–

MCM.ModDef.WriteStartReg = 200
MCM.ModDef.WriteRegCnt = 200
MCM.ModDef.ReadStartReg = 0
MCM.ModDef.ReadRegCnt = 200

This means the ReadData from ReadData[0] to ReadData[199] will correspond to the
first 200 registers of the MCM Internal memory (Internal Address 0 to 199) and the
WriteData from WriteData[0] to WiteData[199] will correspond to next 200 registers
in the MCM memory (Internal Address 200 to 399)

Now define the MCM Port to work as Modbus Master by setting the different
parameters in MCM.Port –

Prudent Solutions Ltd. 1


MVI56-MCM Modbus Card Setting

The value in CmdCount will configure the number of Modbus Master commands that
the module will issue to the various slave devices. Example – A value of 3 in this field
will allow the master to look at P3.Cmd[0] to P3.Cmd[2]

The values in BitInOffset, WordInOffset, OutOffset, and HoldOffset will configure


the internal database offset values WHEN THE PORT IS CONFIGURED AS
SLAVE. (Not required in Master mode configuration)

Master Command Configuration :

Example A

The above Modbus Command shall issue


Function Code : 3 Read Multiple Registers
From Slave ID 1
Total Count of 10 Registers
Starting from 0 (i.e. Modbus Address #40001)
& put them into MCM Internal Memory Register starting from 10 (i.e.
MCMReadData[10] onwards)

Prudent Solutions Ltd. 2


MVI56-MCM Modbus Card Setting

Hence if the Slave ID 1, has following data Register Data,

Then following will appear in the MCMReadData –

- - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - -

Prudent Solutions Ltd. 3


MVI56-MCM Modbus Card Setting

Example B

The above Modbus Command shall issue


Function Code : 1 Read Output Status
From Slave ID 1
Total Count of 16 Bits (Note Bits here, since FC is 1)
Starting from 0 (i.e. Modbus Address #1 in the slave device)
& put them into MCM Internal Memory Bit starting from 16 (i.e.
MCMReadData[1].0 onwards) {MCMRedData[0] will have bits 0 to 15}

Hence if the Slave ID 1, has following Output Status Data,

Prudent Solutions Ltd. 4


MVI56-MCM Modbus Card Setting

Then following will appear in the MCMReadData –

- - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - -

Example C

The above Modbus Command shall issue


Function Code : 16 Write Multiple Registers
To Slave ID 1
Total Count of 8 Registers
Starting from MCM Internal Memory Register # 200 (corresponding to
MCMWriteData[0] onwards)
& put them into Slave Device Memory Register # 10 onwards (i.e. Modbus Address
#40011 onwards in the slave device)

Prudent Solutions Ltd. 5


MVI56-MCM Modbus Card Setting

Hence if the MCMWriteData has following values –

Then following will appear in the Modbus Memory Addresses of the Slave –

Prudent Solutions Ltd. 6


MVI56-MCM Modbus Card Setting

Now if we connect a Hyper-terminal to the CFG Port of the Prosoft Module and
navigate to see the Master Command List of Port 2, following will be displayed –

Prudent Solutions Ltd. 7


MVI56-MCM Modbus Card Setting

USING THE CARD AS MODBUS SLAVE

The module has a 5000 register database. Register 0 to register 4999


It must be defined in 200 word increments for ReaDdata and WriteData.

WriteData means the data passed onto Modbus Master when responding to Function Codes 1 (Read
Output Status), 2 (Read Input Status), 3 (Read Multiple Registers), 4 (Read Input Registers).

ReadData means the data received from Modbus Mater with Fuction Codes: 5 (Single Coil Write), 6
(Single Register Write), 15 (Multiple Coil Write), 16 (Multiple Register Write)

First Define following (assuming you have 200 words of data to be passed onto &
another 200 words to be received)–

MCM.ModDef.WriteStartReg = 200 MCM.ModDef.WriteRegCnt = 200


MCM.ModDef.ReadStartReg = 0 MCM.ModDef.ReadRegCnt = 200

This means the ReadData from ReadData[0] to ReadData[199] will correspond to the
first 200 registers of the MCM Internal memory (Internal Address 0 to 199) and the
WriteData from WriteData[0] to WiteData[199] will correspond to next 200 registers
in the MCM memory (Internal Address 200 to 399)

Now define the MCM Port to work as Modbus Slave by setting the different
parameters in MCM.Port –

Prudent Solutions Ltd. 8


MVI56-MCM Modbus Card Setting

The mapping that you require is done with the settings:

MCM.Port*.BitInOffset = (Offset value represents the MCM Int. memory database


address where Modbus bit address 10001 will start at. Function codes 2)

MCM.Port*.WordInOffset = (Offset value represents the MCM Int memory database


address where Modbus bit address 30001 will start at. Function code 4)

MCM.Port*.OutOffset = (Offset value represents the MCM Int. memory database


address where Modbus bit address 0001 will start at. Function codes 1,5,15)

MCM.Port*.HoldOffset= (Offset value represents the MCM Int. memory database


address where Modbus bit address 40001 will start at. Function codes 3,6,16)

For Example –

Assume we have to configure the MVI56-MCM as Modbus Slave, for following -

FC = 2, Read Input
From Address 10001 to 10320 (i.e. 20 words of data : 320/16 = 20)

FC = 3, Read Input Register


From Address 30001 to 30006

FC = 15, Force Multiple Coil


From Address 1 to 16

FC = 16, Multiple Register Write


From Address 40001 to 40009

So for this scenario, we will use the following setup:

MCM.Port*.BitInOffset = 200
MCM.Port*.WordInOffset = 220
MCM.Port*.OutOffset =0
MCM.Port*.HoldOffset= 10 (we reserved 0 – 9 words for Outoffset)

Prudent Solutions Ltd. 9


MVI56-MCM Modbus Card Setting

Now, if we have following data in the WriteData Registers -

Prudent Solutions Ltd. 10


MVI56-MCM Modbus Card Setting

The same will appear at the Modbus Master at 10001 onwards, in response to
Function Code 2 –

Prudent Solutions Ltd. 11


MVI56-MCM Modbus Card Setting

For FC = 3, Read Input Register, the data at the WriteData[20] onwards shall be
supplied –

& the same will appear at Modbus Master –

Prudent Solutions Ltd. 12


MVI56-MCM Modbus Card Setting

For FC = 15, Force Multiple Coil, if following is set from the Master –

Then the same will be written to ReadData[0] as –

Prudent Solutions Ltd. 13


MVI56-MCM Modbus Card Setting

Similarly for FC = 16, Multiple Register Write, if the Master sets as following –

Then the same will be written to ReadData[10] onwards as –

Prudent Solutions Ltd. 14