24 Applied Instructions (Others)
24.2 RND / Random Number Generation
588
FXCPU Structured Programming Manual
[Basic & Applied Instruction]
Program examples
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
The clock data is read.
Data in hour, minute and
second → Data in second
The data in second is added by
the value "(Year + Month) ´ Day",
and written to D8311 and D8310.
RNDP
EN ENO
d
D100
TRD
EN ENO
d
D0
DHTOS
EN
s
ENO
d
ADD_E
EN
_IN
_IN
ENO
D10
D0
D1
MUL_E
EN
_IN
_IN
ENO
D10
D2
DADD
EN
s1
s2
ENO
d
D3
D14
D12
D14
D12
D8310
X010
[Structured ladder/FBD]
RNDP(X010,D100);
[ST]
TRD(M8002,D0);
DHTOS(M8002,D3,D14);
ADD_E(M8002,D0,D1,D10);
MUL_E(M8002,D10,D2,D12);
DADD(M8002,D14,D12,D8310);