7 APPLICATION INSTRUCTION
7.8 Random Number Instruction
465
7
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).
■Descriptions, ranges, and data types
■Applicable devices
• 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.
*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.)
There is no operation error.
Ladder diagram Structured text
ENO:=RND(EN,d);
ENO:=RNDP(EN,d);
Operand Description Range Data type Data type (label)
(d) Head device number storing a random number 16-bit signed binary ANY16
Operand Bit Word Double word Indirect
specification
Constant Others
X, Y, M, L,
SM, F, B, SB
U\G T, ST,
C, LC
T, ST, C, D,
W, SD, SW, R
U\G Z LC LZ K, H E $
(d)
Pseudo-random number calculation equation:
(SD8311, SD8310)=(SD8311, SD8310)
*1
1103515245+12345
(d) ="([SD8311, SD8310]>>16)&<logical product>00007FFFh"