FX
/FX
/FX
Series Programmable Controllers
3G
3U
3UC
Programming Manual - Basic & Applied Instruction Edition
24.2
FNC184 – RND / Random Number Generation
Outline
This instruction generates random numbers.
1. Instruction format
FNC 184
RND
2. Set data
Operand Type
D
3. Applicable devices
Bit Devices
Oper-
and
System User
Type
X Y M T C S D .b KnX KnY KnM KnS
D
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
.
D
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.
Command
input
FNC 184
RND
Pseudo-random number calculation equation:
(D8311, D8310) = (D8311, D8310) *
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.]
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.
M8002
X010
590
Mnemonic
16-bit Instruction
P
RND
3 steps
RNDP
Head device number storing a random number
Digit Specification
D
1
× 1103515245 + 12345.....(1)
FNC166
TRD
FNC164
D3
DHTOS
FNC 20
D0
D1
ADD
FNC 23
D10
D2
MUL
FNC 20
D14
D12
DADD
FNC184
RNDP
24.2 FNC184 – RND / Random Number Generation
Operation Condition
32-bit Instruction
Continuous
Operation
Pulse (Single)
Operation
Description
Word Devices
Special
System User
Unit
T
C D R U \G
V
D0
The clock data is read.
Data in hour, minute and second → Data in second
D14
D10
The data in second is added by the value "(Year +
D12
Month) × Day", and written to D8311 and D8310.
D8310
D100
END
24 Others – FNC181 to FNC189
Mnemonic
Operation Condition
⎯
⎯
Data Type
16-bit binary
Others
Con-
Real
Charac-
Index
stant
Number
ter String
Z Modify K
H
E
Pointer
" "
P