rand
Function Block - Returns a pseudo-random integer value between 0 (zero) and (base - 1).
- rand uses a fast high-quality number generation algorithm.
- The algorithm is not cryptographically secure.
- It is sufficient where security is not a concern.
- There is no way to seed the random number generator.
- On first use, the random number generated is seeded by time.
- While unlikely, it is possible to receive the same pattern of generated numbers after the controller reboots.
Inputs
|
Input |
Data Type See Data Types. |
Range |
Unit |
Default |
Description |
|---|---|---|---|---|---|
|
base |
DINT |
1 to 2147483647 |
N/A |
No default |
|
Outputs
|
Output |
Data Type See Data Types. |
Range |
Unit |
Description |
|---|---|---|---|---|
|
Return Value |
DINT |
0 (zero) to (base - 1) |
N/A |
The generated pseudo-random number. |
FBD Language Example
Not available.
FFLD Language Example
Not available.
IL Language Example
Not available.
ST Language Example
dieValue := 1 + rand(6);





