DRAND
Instances of function blocks are created according to IEC61131-3, and then called, or otherwise accessed, from with the PLC program using the instance names. The function block DRAND permits generation of a (pseudo-) random number of type REAL.
VAR_INPUT
VAR_INPUT
Seed : INT;
END_VAR
Seed: initial value to define the random number sequence.
VAR_OUTPUT
VAR_OUTPUT
Num : REAL;
END_VAR
Num: this output returns a pseudo-random number in the range 0.0 ... 1.0 with single precision. The generator here creates a number series with 1075 stochastic values per period.
Sample of calling the function block in FBD:
In the sample the REAL value 0.643412 is generated and returned. The input parameter ”Seed" affects the initial value of the series. If, for instance, a deterministically reproducible random number series is desired in different sessions, and identical ”Seed" value must be used.
Requirements
Development environment |
Target platform |
PLC libraries to include |
---|---|---|
TwinCAT v2.7.0 and above |
BCxxxx (165) |
Standard.Lb6, PlcSystemBC.Lb6, TcPlcUtilitiesBC.Lb6 |