![]() ![]() ![]() ![]() ![]() ![]() |
||
![]() |
||
![]() ![]() ![]() ![]() This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc. |
||
![]()
|
New Here? Please read this important info!!!
![]() |
#1 |
Member
![]() ![]() Join Date: Aug 2006
Location: Maranello
Posts: 5
|
![]()
Hi guys,
I need your valuable suggestions about writing a module (AWL Step7) generating random integer numbers... Let's say the users define the range of the numbers and an input (on negative edge) triggers the result... I did one myself but it's still not true random... Any ideas ?? Andy |
![]() |
![]() |
#2 |
Lifetime Supporting Member + Moderator
|
Try searching...
it has been covered many times, I got 40 hits...there are several that deal with S7, this one looks good http://www.plctalk.net/qanda/showthread.php?t=11354 looks like the majority use a system clock to generate the numbers
__________________
www.PLCCable.com PLC Communication Cables, PLC Trainers, Fluke Meters, MicroLogix, ControlLogix, Siemens, Allen Bradley and more... all your automation needs... ((NEW)) After Market 1784-U2DHP Allen Bradley USB to DH+ and Gateways |
![]() |
![]() |
#3 |
Member
![]() ![]() Join Date: Aug 2006
Location: Maranello
Posts: 5
|
Thanks a lot
![]() Andy |
![]() |
![]() |
#4 |
Member
|
Some assembly required
Google "Parks Miller Randon Number". This will be easy to implement on a S7.
Code:
int intrnd (int& seed) // 1<=seed<=m { #if LONG_MAX > (16807*2147483647) int const a = 16807; //ie 7**5 int const m = 2147483647; //ie 2**31-1 seed = (long(seed * a))%m; return seed; #else double const a = 16807; //ie 7**5 double const m = 2147483647; //ie 2**31-1 double temp = seed * a; seed = (int) (temp - m * floor ( temp / m )); return seed; #endif } |
![]() |
![]() |
#5 |
Member
|
What do you need the random number generator for ?
|
![]() |
![]() |
#6 |
Lifetime Supporting Member
|
Peter, this has been discussed numerous times on this site, are you NOW saying a plc can generate random numbers?
NONE of y'all give me the brand thing.
__________________
http://www.patchn.com Industrial Electrical & Maintenance @ www.patchn.com "Tell me and I forget, show me and I remember, involve me and I understand." |
![]() |
![]() |
#7 | |
Member
![]() ![]() Join Date: Aug 2006
Location: Maranello
Posts: 5
|
Quote:
but i'm still curious to know one proper random function (pseudo looking of course) Tnx for your tips ![]() Andy |
|
![]() |
![]() |
#8 | ||
Member
|
There are no true random number generators
This algorithm is one in numerical recipes in C and it is really a pseudo random number generator PRNG. It should be obvious that that same seed will generate the same sequence of pseodu random numbers.
Quote:
Quote:
|
||
![]() |
![]() |
Bookmarks |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
S7 Random Number Generator | RRobbins | LIVE PLC Questions And Answers | 14 | July 8th, 2016 07:36 AM |
Usless but maybe fun excercise | ndzied1 | LIVE PLC Questions And Answers | 6 | May 15th, 2006 06:28 AM |
PLC 5/04 random number generator | seat14 | LIVE PLC Questions And Answers | 2 | December 10th, 2005 11:29 PM |
Random number | Shahed | LIVE PLC Questions And Answers | 4 | December 3rd, 2005 03:25 AM |
Random number generator for PLC5 | Contr_Conn | LIVE PLC Questions And Answers | 11 | September 8th, 2004 01:57 AM |