Справочник Пользователя для Mitsubishi Electronics FXCPU
24 Applied Instructions (Others)
24.2 RND / Random Number Generation
587
FXCPU Structured Programming Manual
[Basic & Applied Instruction]
21
Appl
ied
ied
In
stru
cti
cti
ons
(R
eal
T
T
im
e
C
lock
Contr
Contr
ol)
22
Ap
plied
Instru
ctio
ns
Instru
ctio
ns
(E
xt
er
na
l De
vi
vi
ce
)
23
App
lied Instr
lied Instr
ucti
ons
(Ex
tensi
on
tensi
on
Functi
on)
24
Ap
pl
ied In
struct
struct
ions
(O
thers)
25
Appl
ied
ied
Instru
cti
cti
ons
(B
lock
Dat
a
Dat
a
O
per
at
io
n)
26
App
lie
lie
d Instr
uction
s
s
(Charac
ter
Stri
ng C
ontrol
)
27
Ap
pl
ied Inst
ruct
io
io
ns
(D
ata
Op
eration 3
eration 3
)
28
Appl
ied
ied
In
stru
cti
cti
ons
(D
ata C
om
om
par
ison
)
29
App
lie
lie
d Instr
uction
s
s
(D
ata
T
T
abl
e
O
peration
)
30
Appli
ed In
struc
tions
ed In
struc
tions
(E
xt
ernal Devi
ce
Comm
uni
cat
ion)
24.2
RND / Random Number Generation
Outline
This instruction generates random numbers.
1. Format and operation, execution form
2. Set data
3. Applicable devices
Function and operation explanation
1. 16-bit operation (RND/RNDP)
This instruction generates a pseudo-random number within the range from 0 to 32767, and stores it as a
random number to the device specified by
random number to the device specified by
.
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.
and this instruction calculates a pseudo-random number using the source value.
Pseudo-random number calculation equation:
(D8311, D8310) = (D8311, D8310)
(D8311, D8310) = (D8311, D8310)
*1
× 103515245+12345...1)
d = "[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.]
switches from STOP to RUN.
[K1 is written to (D8311, D8310) as the initial value when the power is restored.]
FX
3U(C)
FX
3G(C)
FX
3S
FX
2N(C)
FX
1N(C)
FX
1S
FX
U
/FX
2C
FX
0N
FX
0(S)
Instruction
name
Operation
Execution
form
Expression in each language
Structured ladder/FBD
ST
RND
16 bits
Continuous
RND(EN,d);
RNDP
16 bits
Pulse
RNDP(EN,d);
Variable
Description
Data type
Input
variable
variable
EN
Execution condition
Bit
Output
variable
variable
ENO
Execution state
Bit
Head device storing a random number
ANY16
Operand
type
Bit Devices
Word Devices
Others
System user
Digit specification
System
user
Special
unit
Index
Cons
tant
Real
Number
Character
String
Pointer
X Y M T C S D
.b KnX KnY KnM KnS T C D R U
\G
V Z Modifier K H
E
"
"
P
z
z
z z z z z
z
z
RND
EN
ENO
d
RNDP
EN
ENO
d
RND
EN
ENO
d
Head device storing
a random number
a random number
Command
input
input