Contatto
MCP 4 – User's manual
DUEMMEGI
Example 4:
Read the
status of virtual point
V328 using the function 3. The Word containing the status of virtual point
Vx
is given by:
1153 + INT[(x - 1) / 16]
Since a virtual point takes only one bit of the Word, the bit number must be also specified; this is given by:
(x – 1)%16
where the notation %16 means “module 16” and it is equivalent to the remainder of the division of x by 16;
the notation INT[ ] means the integer part of the result of the operation inside the parenthesis.
To calculate y module 16 proceed as follows:
•
divide y by 16
•
subtract the integer part of the result of point 1 to the result itself
•
multiply by 16 the result of point 2: the resultant value is the module 16 of the starting number; this result is
always an integer number in the range 0 to 7.
The parameters to be passed to the MODBUS driver, for virtual point V328, are:
Start:
1173
Number:
1
Bit:
7
MCP 4 will answer with a Word (2 bytes) containing the status of the virtual points from V321 (less significant
bit) to V336 (most significant bit). The virtual points are binary coded (1=point ON, 0=point OFF).
Example for the calculation of 327%16:
•
327 : 16 = 20.4375
•
20.4375 – 20 = 0.4375
•
0.4375 x 16 = 7
Alternatively, the paragraph 11.4 reports some tables to easily locate the RAM address and the bits related to
a given virtual point. As further possibility, use the program WordFinder (see the following figure) that can be
free of charge from the site
www.duemmegi.it
.
Page 74 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