7/30/2024 3:49 PM | |
Joined: 7/5/2017 Last visit: 8/14/2024 Posts: 10 Rating:
|
Library of general functions (LGF) has these random number generators that supposedly generate random INT or DINT. Essentially it just copies the nanosecond timestamp of the real time clock. I used this DINT to drive a full 32 DO card. I wanted to randomize the outputs for a test. I repeated this every cycle in OB1. There are big flaws with this.
To do it better:
This would have fixed all the above problems. It seems like they intended to do something like this because you can open the source code of this function and the comments are "random-start-value depending on the time" but they never did anything with this start value, they just output it byte swapped. I hope siemens sees this and fixed it, but they probably wont. https://support.industry.siemens.com/cs/lt/en/view/109479728 |
Last edited by: AutoGen_3010114 at: 07/30/2024 15:50:11Last edited by: AutoGen_3010114 at: 07/30/2024 15:50:37Last edited by: Wit_Moderator at: 08/01/2024 09:16:24Link optimized |
|
7/31/2024 2:40 PM | |
Joined: 7/7/2010 Last visit: 8/14/2024 Posts: 15089 Rating:
|
Take a look at the open source library at, http://oscat.de (https: does not work). There are several random number generators based on system time that may work better for your specific situation. You can use other blocks available in the same library to plot a histogram or distribution of the data and see if it fits true random or a gaussian or some other non-uniform distribution.
|
science guy |
|
Follow us on