Specifications
7. Application Instructions
© DELTA ELECTRONICS, INC. ALL RIGHTS RESERVED
7-25
Count all the bits with “ 1” as its content within
S
, and have this
counted number saved in
D
.
Program Example
SUM D2D0
X0
Ϩʳ When X=ON, all the bits that with “ 1” as its content within D0 will be
counted, and have this counted number saved in D2.
Ϩʳ If the contents of these 16 bits are “ 0” , the “ Zero” flag signal
M8020=ON.
Ϩʳ When using the 32 bit commands, DSUM or DSUMP, in the
above-mentioned program, the total number of the 32 bits within D1
and D0 that possess “ 1” as its content will be counted and saved in D2,
and D3=0.
D
44 BON
S D n Determine the ON bit
Bit device Word device
Device
Operand
X Y M S K H KnX KnY
KnM
KnS T C D E F
S
ϨϨϨϨϨϨϨϨϨϨϨ
D
ϨϨϨ
n
ϨϨ
Essential condition: when it is of the 16 bit commands, n=0~15, and
when it is of the 32 bit commands, n=0~13.
With the content of
S
, if the content of the
n
bit is “1”, the
D
-assigned bit device will be set as “ ON” .
Program Example
D0 K15M0
X0
BON
Ϩʳ When X0=ON and that the 15
th
bit of D0 is “ 1” , M0=ON.
Ϩʳ Once X0 is switched to OFF, M0 will stay at its previous ON/OFF
status.
D
45 MEAN
S D n Mean value
Bit device Word device
Device
Operand
X Y M S K H KnX KnY
KnM
KnS T C D E F
S
ϨϨϨϨϨϨϨ
D
Ϩ Ϩ Ϩ ϨϨϨϨϨ
n
ϨϨ
Add the contents of the
S
-assigned
n
registers, and have the
sum ddivided by
n
to obtain a mean value.To save this mean
value in the designated
D
.
Program Example
MEAN D10 K4D20
X0
Ϩʳ When X0=ON, add up the contents of the 4 registers starting from D10
(assigned by this command), divide the sum by 4 to obtain the mean
value.To save the value in the assigned D20.
If there is remainder in this calculation, discard the remainder. If the assigned
device number exceeds the normal usable range, only those that within the
range could be processed.
D
48 SQR
S D The square root of BIN
Bit device Word device
Device
Operand
X Y M S K H KnX KnY
KnM
KnS T C D E F
S
ϨϨ Ϩ
D
Ϩ