Contatto
MCP 4 – User's manual
DUEMMEGI
The MODBUS function 16 can thus be used to change the status of whole output module (both digital or
analog type), the status of a single output point of a module, the status of virtual points, the content of
counters, registers, etc.
To change a single bit of a register using the function 16, the status of the other bits of the same register has
to be taken in account, because the writing takes place on the whole Word; in practice, the MODBUS driver
automatically take in account this, because, when the writing must be at bit level, they execute the following
steps:
1. reading, through the function 3, of the Word containing the bit to be changed
2. writing, through the function 16, of the just read Word read but with the wanted byte changed
The MODBUS function 16 can be also used to set the date and time of the internal timekeeper of MCP 4 as
shown in one of the following examples.
Example 1:
Switch on the point 3 of the output module 29. Instead of function 5, the function 16 can be used. From the
memory map of MCP 4 at paragraph 9.2.1 (or using WordFinder program, available free of charge on the site
www.duemmegi.it
) the Word containing the status of output module 29 is the 541, therefore, regarding the
module 29, the following parameters have to be passed to the MODBUS driver:
Start:
541
Number:
1
(normally, in this case, this parameter is not required by the driver)
Bit:
2
Value:
1
(or ON, it depends on the used driver)
Note:
the point 3 of an output module correspond to bit 2 of the Word, because the real output points of the
Contatto
system are numbered from 1 to 8, while the MODBUS driver “works” on the bits from 0 to 7.
The execution of this function, as described before, implies that the MODBUS driver read the Word 541 using
the function 3, then it changes the bit 2 to the read value and finally it sends the resulting value to the Word
541 using the function 16. This procedure, normally, is automatically executed by the MODBUS driver of the
MASTER system (PLC, supervision software, video-terminal, etc.).
Example 2:
Switch on all outputs of the output module 29. Use the function 16. The Word into MCP 4 RAM related to
output module 29 (channel 1) is the 541, therefore the following parameters have to be passed to the
MODBUS driver:
Start:
541
Number:
1
Value:
255
In this case the value 255 will be directly written into the Word 541. In addition, the MODBUS drivers allow to
execute both mathematical and logical operations between the current value of the Word and a fixed value
(for instance an EXOR between the current value of an output module and the value 255 to complement the
status of each output of the same module) and then to write the result in the same Word.
Page 76 of 87
Rel.: 1.2 October 2018
DUEMMEGI
s.r.l. - Via Longhena, 4 – 20139 MILANO
Tel. 02/57300377 - Fax 02/55213686 –
www.duemmegi.it