Delta Electronics — 5.6 Application Instructions

5 Categories and Use of Basic Application Instructions API 154 Operands: S 1 : Lower bound of the random number S 2 : Upper bound of the random number D : Operation result Explanations: 1. The range of 16-bit operands S 1 , S 2 : K0 ≦ S 1 , S 2 ≦ K32,767; the range of 32-bit operands S 1 , S 2 : K0 ≦ S 1 , S 2 ≦ K2,147,483,647. 2. Entering S 1 > S 2 will result in operation error. The instruction will not be executed at this time, M1067, M1068 = ON and D1067 records the error code 0E1A (HEX) 3. When RAND is used as 16-bit instruction, Z device cannot be adopted; when RAND is used as 32-bit instruction, V device cannot be adopted. 4.

When specifying the bit device of KnX(Y/M/S), the starting No. should be a multiple of 16 in octal or decimal format. For example, K1X0, K4Y20 (octal); K1M0, K4S16 (decimal) Program Example: When X10 = ON, RAND will produce the random number between the lower bound D0 and upper bound D10 and store the result in D20. X0 D20 DVP-PM Application Manual 5-133 Mnemonic Operands Function Controllers 20PM 10PM D RAND P Random number Type OP Bit Devices Word devices Program Steps X Y M S K H KnX KnY KnM KnS T C D V Z RAND, RANDP: 7 steps DRAND, DRANDP: 13 steps S 1 * * * * * * * * * * * S 2 * * * * * * * * * * * D * * * * * * * * RAND D0 D10