Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Eng-Tips
*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Donate Today!

Do you enjoy these
technical forums?
Donate Today! Click Here

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Nick90 (Computer) (OP)
23 Dec 04 11:00
Hi,

Can any of you clever chaps give me(lazy I know!) structured text code that will generate a pseudo random number between 1 and 10?

Thanks
xyzz (Electrical)
23 Dec 04 16:12
If you do not need the random number often, use the seconds lower digit of a real-time clock.
Helpful Member!  OldPfart (Electrical)
27 Dec 04 0:11
Structured text? There is a very good one in ladder at http://forum.mrplc.com/index.php?act=Downloads&CODE=02&id=161

It has been designed using Omron but should be adaptable.
Nick90 (Computer) (OP)
30 Dec 04 7:02
Thanks for your replies,

I'll try and get the ladder version to work.
jonesy29847 (Electrical)
31 Dec 04 20:59
I love ST programming, what processor are you using, I'll give it a shot.

xyzz (Electrical)
1 Jan 05 18:00
By the way, what may be a real life PLC application that requires a random number generation?
OldPfart (Electrical)
2 Jan 05 4:48
The generation of random numbers for timers. I use them regularly to insert different values into timers for swimming pool water features. Sometimes the randomly generated timer values represent 2 decimal places. Sometimes minutes. Depends on the water features at hand.
Nick90 (Computer) (OP)
2 Jan 05 11:50
Thanks everyone,

These random numbers will be used for timer values. Its for a security lighting project I'm working on.

The PLC is a WAGO 750-841 and the software I'm using is CoDeSys.

Happy New Year.
OldPfart (Electrical)
6 Jan 05 16:50
Nick, did you leave a request here for a simpler version of a number generator? If so, leave it again and I will see if I can post it somewhere for you to pick up.

Nick90 (Computer) (OP)
10 Jan 05 7:17
OldPfart, yes I did request your simpler version.
Thanks
OldPfart (Electrical)
12 Jan 05 2:44
Nick, I have not forgotten you. Just had one end up and the other end down (inverted). Not a pretty sight.

Will see if I can set something up for you tomorrow.

Bob
OldPfart (Electrical)
18 Jan 05 6:00
Nick, still got head down and a*** up. Have not forgotten you.

Pleas be patient for another day or two.
knji (Electrical)
10 Mar 05 23:55
Nick90,

Still looking for help with random numbers?  In MATLAB, use the command rand.  I beleive C/C++ also have the function rand().
hrc (Electrical)
15 Mar 05 15:33
As I was reading the replies...someone asked....what would you use it for...and bingo...olphart said for water feature timers.  Whoa...scary...that is EXACTLY what I used it for as well.  Did a control system for a water park feature that would do a random time for the events to occur.

http://www.cherry-hill.com/GrantsGulch.htm

fun project....

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close