Mitsubishi Electronics FX3G User Manual

Page of 964
589
FX
3S
/FX
3G
/FX
3GC
/FX
3U
/FX
3UC
 Series
Programming Manual - Basic & Applied Instruction Edition
24 Others – FNC181 to FNC189
24.2 FNC184 – RND / Random Number Generation
21
FNC160
-F
NC1
69
R
eal
 T
ime C
lock
 
C
ontrol
22
FNC17
0-F
NC
179
E
xternal D
evice
23
FNC
180
Alternate 
Instructions
24
FN
C181-
FNC18
9
O
thers
25
FNC190
-F
NC1
99
Bl
oc
k D
ata
 
Op
er
ation
26
FNC20
0-F
NC209
C
har
ac
te
r S
trin
Con
tro
l
27
FNC2
10-
FNC21
9
Dat
Operati
on 3
28
FNC220
-F
NC2
49
Da
ta 
C
omp
ari
son
29
FNC25
0-F
N
C
269
D
ata T
abl
Operation
30
FNC2
70-
FNC276
Ex
-Dev
ice
24.2
FNC184 – RND / Random Number Generation
Outline
This instruction generates random numbers.
1. Instruction format
2. Set data
3. Applicable devices
Explanation of function and operation
1. 16-bit operation (RND and RNDP)
This instruction generates a pseudo-random number ranging from 0 to 32767, and stores it as a random number to
.
In the pseudo-random number sequence, the source value of a random number is calculated at every time, and this
instruction calculates a pseudo-random number using the source value.
Pseudo-random number calculation equation:
(D8311, D8310) = (D8311, D8310) *
× 1103515245 + 12345.....(1)
 = “([D8311, D8310]>>16)&<logical product>00007FFFh”
*1.
To (D8311, D8310), write a non-negative value (0 to 2,147,483,647) only once when the PLC mode switches
from STOP to RUN.
[K1 is written to (D8311, D8310) as the initial value when the power is restored.]
Program example
In the program example shown below, a random number is stored to D100 every time X010 turns ON.
When the PLC mode switches from STOP to RUN, the time data converted into seconds and added by the value
“(Year + Month) 
× Day” is written to D8311 and D8310.
Operand Type
Description
Data Type
Head device number storing a random number
16-bit binary
Oper-
and 
Type
Bit Devices
Word Devices
Others
System User
Digit Specification
System User
Special 
Unit
Index
Con-
stant
Real 
Number
Charac-
ter String
Pointer
X Y M T C S D .b KnX KnY KnM KnS T C D R U \G
V Z Modify K H
E
" "
P
P
FNC 184
RND
Mnemonic
Operation Condition
16-bit Instruction
 3 steps
RND
RNDP
Mnemonic
Operation Condition
Continuous
Operation
Pulse (Single)
Operation
32-bit Instruction

  D
  D
   
D
FNC 184
RND
Command
input
   
D
Data in hour, minute and second 
→ Data in second
X010
FNC184
RNDP
D100
END
M8002
FNC166
TRD
D0
FNC164
DHTOS
D14
D3
FNC 20
ADD
D10
D1
D0
FNC 20
DADD
D8310
D12
D14
The clock data is read.
The data in second is added by the value “(Year +
Month) 
× Day”, and written to D8311 and D8310.
FNC 23
MUL
D12
D2
D10