Chapter 6 Applied Instructions Symbol S 1 : Minimum value S 2 : Maximum value D : Device where the result is stored Explanation 1. This instruction generates a random number between the minimum value in S 1 and the maximum value in S 2 , and 6_ then stores the result in D . 2. If the value in S 1 is larger than the value in S 2 , the instruction takes the values in S 1 and S 2 as the maximum value and the minimum value respectively. Example When M0 is ON, the instruction generates a random number between the minimum value in D0 and the maximum value in D10, and stores the result in D20. Additional remarks The values in S 1 and S 2 must be between 0–32767.
If the value in S 1 or S 2 exceeds the range, the instruction is not executed, SM0 is ON, and the error code in SR0 is 16#2003. 6-475 API Instruction code Operand Function 1517 RAND P S1, S2, D Generating a random number Device X Y M S T C HC D FR SM SR E K 16# “$” F S1 S2 D BOOL WORD DWORD LWORD UINT INT DINT LINT REAL LREAL TMR CNT STRING Data type S1 S2 D Pulse instruction 16-bit instruction 32-bit instruction ES3 ES3 -