Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Random numbers 1

Status
Not open for further replies.

Nick90

Computer
Dec 23, 2004
5
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
 
Replies continue below

Recommended for you

If you do not need the random number often, use the seconds lower digit of a real-time clock.
 
Thanks for your replies,

I'll try and get the ladder version to work.
 
I love ST programming, what processor are you using, I'll give it a shot.

 
By the way, what may be a real life PLC application that requires a random number generation?
 
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.
 
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.
 
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.

 
OldPfart, yes I did request your simpler version.
Thanks
 
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
 
Nick, still got head down and a*** up. Have not forgotten you.

Pleas be patient for another day or two.
 
Nick90,

Still looking for help with random numbers? In MATLAB, use the command rand. I beleive C/C++ also have the function rand().
 
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.


fun project....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor