7.8
Random Number Instruction
Generating random number
RND(P)
These instructions generate a pseudo-random number ranging from 0 to 32767, and store it as a random number to a device
specified by (d).
Ladder diagram
(d)
Setting data
■Descriptions, ranges, and data types
Operand
Description
(d)
Head device number storing a random number
■Applicable devices
Operand
Bit
X, Y, M, L,
U\G T, ST,
SM, F, B, SB
(d)
Processing details
• These instructions generate a pseudo-random number ranging from 0 to 32767, and store it as a random number to a
device specified by (d).
• In the pseudo-random number sequence, the source value of a random number is calculated every time, and this
instruction calculates a pseudo-random number using the source value.
Pseudo-random number calculation equation:
(SD8311, SD8310)=(SD8311, SD8310)
(d) ="([SD8311, SD8310]>>16)&<logical product>00007FFFh"
*1 To (SD8311, SD8310), write a non-negative value (0 to 2,147,483,647) only once when the CPU module mode switches from STOP to
RUN. (K1 is written to (SD8311, SD8310) as the initial value when the power is restored.)
Operation error
There is no operation error.
Word
T, ST, C, D,
U\G
C, LC
W, SD, SW, R
*1
1103515245+12345
Structured text
ENO:=RND(EN,d);
ENO:=RNDP(EN,d);
Range
Data type
16-bit signed binary
Double word Indirect
specification
Z
LC
LZ
7 APPLICATION INSTRUCTION
7.8 Random Number Instruction
Data type (label)
ANY16
Constant
Others
K, H
E
$
465
7