Rand - Omron NJ501-1500 Reference Manual

Machine automation controller nj-series
Hide thumbs Also See for NJ501-1500:
Table of Contents

Advertisement

Rand

The Rand instruction generates pseudorandom numbers.
Instruction
Rand
Random Number
Variables
Name
Meaning
Seed
Random num-
ber pattern
Rnd
Random num-
ber
*1 If you omit the input parameter, the value will be 0. It will not be the value that is specified for the Initial Value attribute.
*2 0.00000000000000e+0 to 1.00000000000000e+0
Bit strings
Seed
Rnd
Function
The Rand instruction specifies random number Rnd. The value of Rnd is different each time the
instruction is executed: Random number pattern Seed specifies the random number system. If the
value of Seed is the same, the same random number series is generated each time the power sup-
ply is turned ON. This allows you to generate a repeatable series of random numbers.
If the value of Seed is 0, random numbers that cannot be repeated are generated. If you do not want
to generate the same series of random numbers each time the power supply is turned ON, set the
value of Seed to 0.
The following programming example is for when Seed is UINT#1.
LD
A
UINT#1
NJ-series Instructions Reference Manual (W502)
Name
FB/FUN
FB
I/O
Description
Input
Random number pattern
Output
Random number
OK
Rand_instance
Rand
Execute ENO
abc
Seed
Rnd
Graphic expression
Rand_instance
Rand
Execute ENO
Seed
Rnd
Valid range
Depends on data type.
*2
Integers
ST
Rand_instance(A, UINT#1, abc);
2 Instruction Descriptions
ST expression
Rand_instance(Execute,
Seed, Rnd);
Unit
Default
*1
---
---
---
Times, durations,
dates, and text strings
OK
2
2-191

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Nj501-1300Nj501-1400

Table of Contents