LGF_RandomRange_UDInt (FC / V3.0.1)


Author: Siemens Digital Industries

Short description

This function generates a random value in defined limits with each call.
The random number has the data type UDInt in the specified range.

Block Interface

LGF_RandomRange_UDInt (FC)
UDInt  minValue Ret_Val  UDInt
    
UDInt  maxValue error  Bool
    
   status  Word
    
   subfunctionStatus  Word
    
   

Input parameter

IdentifierData typeDescription
minValueUDIntMinimum value of the range of the random number - lower border
maxValueUDIntMaximum value of the range of the random number - upper border

Output parameter

IdentifierData typeDescription
Ret_ValUDIntRandom UDInt number in the predefined range
errorBoolFALSE: No error
TRUE: An error occurred during the execution of the FB
statusWord16#0000-16#7FFF: Status of the FB
16#8000-16#FFFF: Error identification (see following Table)
subfunctionStatusWordStatus or return value of called FB's, FC's and system blocks

Status & Error codes

Code / ValueIdentifier / Description
16#0000STATUS_FINISHED_NO_ERROR
Execution finished without errors
16#8200ERR_MAX_LESS_MIN
Error: The ranges specified are wrong: `minValue` is greater than `maxValue`
16#8600ERR_RD_SYS_T
Error in `RD_SYS_T` command - check `subFunctionStatus` code

Functional description

Note
The status of called commands is output in 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 UDInt.

Change log

Version & DateChange description
01.00.00Simatic Systems Support
11.12.2019First released version
copied from "LGF_RandomRange_DInt"
03.00.00Simatic Systems Support
23.04.2020Set version to V3.0.0, harmonize the version of the whole library
03.00.01Simatic Systems Support
04.02.2021Insert documentation