"Random" number generation

ajbachhuber

Member
Join Date
Aug 2003
Location
New Hampshire
Posts
37
My father found a old traffic light that he wants to have in the basement. (We're car people... don't ask) What I want to do is write a program, using a DL-05, to flash the lights in some kind of a "random pattern."

I searched through the archives here and came up with one other thread that I read through with interest. (Search: "random number") I read the different opinons stating that a random pattern isn't really random and I agree. For my application a pattern that repeats after say, a minute or more would be plenty "fancy."

I used some of the advice on how to come up with a random number set. I used the "rand()*(b-a)+b" command in Excel and that gave me a satisfactory list of numbers between 10 and 100. Now this is where I don't know where to go next. (Limited experience with programs that handle numbers or math functions is my problem) I can set timers to use V-memory locations so I think I know how to get the numbers off of the accumulator/stack but I am not sure how to get the numbers onto the accumulator in a sequence. At least I think that is what I want to do.

There was also a suggestion to use timers that reset each other but I was unable to follow that logic. This seems like an easier plan but I wasn't sure.

Any help would be great. This is just a home project so it doesn't have to be state of the art. Thanks in advance.
 
Ok after a whole morning of screwing around I came up with an answer sufficient for my purposes. I used a drum sequencer (which is completely the opposite of "random") but I was able to cascade sveral of them so that I have a pattern that takes well over two minutes to repeat. I've only got three lights so there is bound to be overlapping patterns anyway.

Not many Koyo fans out there? For $99 it's hard to beat for a home project. We uses them almost exclusively in our plant. Primarily becasue of cost but also because we have found it is easier to have just one brand in house. In addition we have a very hostile environment with chlorinated petroleum based cutting fluid that gets into everything no matter what you do. They are priced to almost be "throw-aways."

I also found some other archived threads related to "random patterns" and how to generate them. Thank you for providing a great resource such as this.
 
Don't have a lot of patience?

There are several 'Koyo fans' here with a lot of knowledge about the Koyo offerings. I'm not sure what you were expecting in terms of how rapidly your question might get answered, but Sunday mornings are typically not the busiest time on this forum.
 
What part of that didn't sound patient? I just said I spent the whole morning screwing around with it until I got it to work. I think that shows patience.

I answered my own question because I found out the answer on my own before anyone answered not because I was irritated by a lack of responses. I've been hanging around here passively for a while as a guest, I know there isn't much activity on Sunday morning. I wasn't expecting anything.

Thanks for your technically expert response however...

I guess I'll just return to being passive and figure it out on my own.
 
I think I contributed to the thread to which you refer. I do not agree that you cannot generate true random numbers in a PLC. I wrote about how I achieve random numbers and how to increase randomness. I have now done some more work on the code and generate random numbers for timers quite easily. These random numbers have to be within a certain range, eg 10-20 minutes. You can generate random numbers in a PLC. I suspect, with a litle application, random outputs could also be generated quite easily.
I have used shift registers, probably similar to drum counters, to generate what appears to be random outputs but have a pattern, as you suggest. The appearance of randomness with outputs can be extended by using a longer shift register and more patterns.
beerchug
 
ajbachhuber said:
In addition we have a very hostile environment with chlorinated petroleum based cutting fluid that gets into everything no matter what you do. They are priced to almost be "throw-aways."

Since you have seemed to have found a solution that you are happy with for your traffic light project, I don't feels too bad about taking this off topic. Even at that price, you may want to consider ways to keep process materials from getting into your controls. Proper enclosures, conduit fittings, housekeeping practices, etc. can eliminate what you speak of.

Even a cheap plc failure will cause as much machine downtime as an expensive one, and you will never get machine time back.
 
Thanks again Stevie for your help you're a real sport... If I change it to "Are there any Koyo fans out there?" will you be able to get over yourself??? Most of the threads I see relate to something other than Koyo, I was just wondering... sheesh!!

I agree with you Chuck. I always try to think cost/down-time consciously but this company I'm with now seems a little backwards. They do a lot of run to failure stuff that I don't agree with. However, this cutting oil we deal with is quite harsh. It's not an overnight thing but some platics it hardens and others it turns to mush. They either crack and split (like PVC jackets on wires) or they just fall apart like most of the seals on our enclosures. It's not as bad as I probably made it sound, the PLCs last for a year or more, not months or weeks. As far as housekeeping and your other suggestions, those are decisions that are made above my pay grade but again, I agree.

Thanks.
 

Similar Topics

i need to set a unit up with random number generation to enable the timing on a switch to be 'erratic', does anybody know if its possible? i need...
Replies
16
Views
5,581
Hey folks, I was just wondering what thoughts were about a completely 100% random number generator. I looked on The Google but didn't really open...
Replies
54
Views
16,436
Hello, Could somebody please help me out with coding a 'Random number generator' in vijeo citect. For example if i create an analog Local...
Replies
3
Views
3,726
http://www.codeproject.com/KB/recipes/SimpleRNG.aspx I came across this simple version a couple of years ago. It is simple enough to implement...
Replies
5
Views
3,527
Hi,Does anybody know if there are any routines in unity pro that produce random numbers like the routine rand() in C ?
Replies
1
Views
4,021
Back
Top Bottom