This function generates a random value in defined limits with each call.
The random number has the data type DInt in the specified range.
LGF_RandomRange_DInt (FC) | ||||||||
---|---|---|---|---|---|---|---|---|
DInt | minValue | Ret_Val | DInt | |||||
DInt | maxValue | error | Bool | |||||
status | Word | |||||||
subfunctionStatus | Word | |||||||
Identifier | Data type | Description |
---|---|---|
minValue | DInt | Minimum value of the range of the random number - lower border |
maxValue | DInt | Maximum value of the range of the random number - upper border |
Identifier | Data type | Description |
---|---|---|
Ret_Val | DInt | Random Real number in the predefined range |
error | Bool | FALSE: No error TRUE: An error occurred during the execution of the FB |
status | Word | 16#0000-16#7FFF: Status of the FB 16#8000-16#FFFF: Error identification (see following Table) |
subfunctionStatus | Word | Status or return value of called FB's, FC's and system blocks |
Code / Value | Identifier / Description |
---|---|
16#0000 | STATUS_FINISHED_NO_ERROR Execution finished without errors |
16#8200 | ERR_MAX_LESS_MIN Error: The ranges specified are wrong: `minValue` is greater than `maxValue` |
16#8600 | ERR_RD_SYS_T Error in `RD_SYS_T` command - check `subFunctionStatus` code |
subFunctionStatus
. In this case, the output value in status
indicates which command caused the error. In this case, refer to the TIA Portal Online Help section for information on the respective commands.The block generates random values that are between the specified minValue
and the maxValue
. This random value is output via the Ret_Val
.
The random value is formed from the nanoseconds of the current system time of the CPU. The byte order of this value is inverted and then converted to a DInt.
Version & Date | Change description | |
---|---|---|
01.00.00 | Siemens Industry Online Support | |
19.08.2015 | First released version | |
01.00.01 | Siemens Industry Online Support | |
02.01.2017 | Upgrade: TIA Portal V14 Update 1 | |
01.00.02 | Siemens Industry Online Support | |
17.08.2018 | Upgrade: TIA V15 Update 2 | |
01.00.03 | Siemens Industry Online Support | |
23.11.2018 | Upgrade: TIA V15.1 | |
01.01.00 | Simatic Systems Support | |
09.10.2019 | Renamed from "LGF_RandomInt" to "LGF_RandomRange_DInt" change random datatype from Int to DInt Regions, comments and constants are added | |
03.00.00 | Simatic Systems Support | |
23.04.2020 | Set version to V3.0.0, harmonize the version of the whole library | |
03.00.01 | Simatic Systems Support | |
04.02.2021 | Insert documentation |