|
|
 |
|
 |
| |
| Home > Libraries > ID 0010 > Detail |
 |
 |
 |
 |
| |
|
| |
|
 |
| Step7-MicroWin: |
[V4.0] |
 |
| CPU: |
[all CPU22x] |
 |
| Operating system: |
-- |
 |
| Other: |
[CPU221,CPU222 require the CC292 clock module] |
 |
|
|
|
 |
|
 |
QUESTION:
How to generate random numbers with S7-200 ?
ANSWER:
The following library contain blocks for any variable size Byte,Word,Dword.
Advanced features:
- value range could be limited
- user selected random characteristic for unique generators

Description:
There is nothing random in a CPU. This problem is still there on random operators
in higher programming languages (C, Java, Basic) too. After a sequence of random
numbers it will start with the same "random" number again.
This library is a good compromize between value distribution and code size.
The formula works still good without using the CPU clock, but with the CPU clock
(only seconds used) and the deviation of the CPU clock to the real time
(2-7 minutes monthly, depends on temperature) the values would be real unpredictable.
Rnd_B

| Parameter |
Variable Type |
Explication |
| EN |
[BOOL] |
signal True(1) to execute function |
| Min |
[BYTE] |
value range: minimum value |
| Max |
[BYTE] |
value range: maximum value |
| User |
[BYTE] |
user selected random characteristic [0..255] |
| Memory |
[WORD] |
library memory |
| Output |
[BYTE] |
random number |
|
Rnd_W

| Parameter |
Variable Type |
Explication |
| EN |
[BOOL] |
signal True(1) to execute function |
| Min |
[INT] |
value range: minimum value |
| Max |
[INT] |
value range: maximum value |
| User |
[BYTE] |
user selected random characteristic [0..255] |
| Memory |
[WORD] |
library memory |
| Output |
[INT] |
random number |
|
Rnd_DI

| Parameter |
Variable Type |
Explication |
| EN |
[BOOL] |
signal True(1) to execute function |
| Min |
[DINT] |
value range: minimum value |
| Max |
[DINT] |
value range: maximum value |
| User |
[BYTE] |
user selected random characteristic [0..255] |
| Memory |
[WORD] |
library memory |
| Output |
[DINT] |
random number |
|
Functionality:
When "EN" is signal True(1) the function returns a random value within the
limits defined trough "Min" and "Max". The parameter "User" adds a unique
random characteristic for the generator.
It is optimized for lower values (Bytes).
Simulator
To visual how the parameter "User" would affect the random results, the tool
"Random formula simulator" is created for. For download see links at bottom.

The formula is optimized for Byte values. The formula for INT, DINT could be changed
in the future. Reply at forum about your experiences.
|
| History |
| Version: |
Fixed / Changed: |
| V1.3 |
- add Random event function
|
|
|
The author makes no warranty, expressed or implied, with regard to this informations and/or software.
All implied warranties, including the warranties of merchantability and fitness
for a particular use, are hereby excluded. Under no circumstances shall the
author of this product or the author(s) of S7-200.net, be liable for any incidental or consequential damages,
nor for any damages. Attachments could contain viruses, the user is repsonsible to check the downloaded
files before using. The user has no claims, especialy not for error correction
or support.
|
 |
 |
 |
| Last Forum topics regarding this entry: |
 |
| |
show all topics |
 |
 |
 |
| Similar entries wich could interrest: |
 |
| |
ID 0012 |
Tool |
Random formula simulator |
| |
ID 0033 |
Library |
Random event |
| |
ID 0031 |
Library |
LOGO! Random generator |
 |
 |
 |
|
|
 |
| optimized for MS Internet Explorer and 1024 x 768 resoltution |
| |
 |
|
 |
 |
 |
 |
| |
© Copyright 2003-2006 S7-200.NET - all rights reserved.
S7-200.NET and his author(s) are not liable for any incidental or consequential damages, nor for any damages
caused by informations or software published on this page.
Simatic, Step7-MicroWin and S7-200 are registered trademarks of Siemens AG in Germany and other countries.
Further designated trademarks and brands are the property of their respective owners.
|
|
 |
 |
S7-200.NET ©2003-2006
 |
 |
|
 |
 |
External eprom |
 |
 |
 |
 |
 |
 |
 |
linear read & write access |
 |
 |
 |
 |
 |
 |
 |
|
 |
 |
 |
 |
 |
 |
 |
+ linear access
+ variables >32Bit (string)
+ backup whole V-Memory
|  |
 |
 |
 |
More... |
 |
 |
 |
 |
 |
 |
 |
 |
Yearly timer |
 |
 |
 |
 |
 |
 |
 |
events by date & time |
 |
 |
 |
 |
 |
 |
 |
|
 |
 |
 |
 |
 |
 |
 |
+ up top 3 configurations
+ min. Resolution = 1 min
+ unlimitted blocks
|  |
 |
 |
 |
More... |
 |
 |
 |
 |
 |
 |
 |
 |
Random event |
 |
 |
 |
 |
 |
 |
 |
counter generated events |
 |
 |
 |
 |
 |
 |
 |
|
 |
 |
 |
 |
 |
 |
 |
+ quality assurance
+ security applications
+ unique characteristic
|  |
 |
 |
 |
More... |
 |
 |
 |
 |
 |
 |
 |
 |
Weekly Timer |
 |
 |
 |
 |
 |
 |
 |
Switch devices by clock |
 |
 |
 |
 |
 |
 |
 |
|
 |
 |
 |
 |
+ up top 3 configurations
+ overlapping configurations
+ unlimitted blocks
|  |
 |
 |
 |
More... |
 |
 |
 |
 |
 |
|
|