9 Application Instructions API 150-199 API 154 Operands: S 1 : Lower bound of the random number S 2 : Upper bound of the random number D : The random number produced Explanations: 1. S 1 ≦ S 2 ; K0 ≦ S 1 , S 2 ≦ K32,767 2. See the specifications of each model for their range of use. 3. 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). 4. The 32-bit instruction only supports EH3/SV2 V1.0, SX V3.0, and above. 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.
X10 DVP-PLC Application Manual 9-37 Mnemonic Operands Function 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 E F RAND, RANDP: 7 steps DRAND: 13 steps S 1 * * * * * * * * * * * S 2 * * * * * * * * * * * D * * * * * * * * PULSE 16-bit 32-bit SS SA SX SC EH SV EH3 SV2 ES EX SS SA SX SC EH SV EH3 SV2 ES EX SS SA SC EH SV EH3 ES EX SX SV2 RAND D0 D10 D20