Sign in to follow this  
Followers 0
Paul Ked

Random Number Generation

14 posts in this topic

Has anyone ever had a request for a program that requires a Random number? I have been asked to provide a system for a theatre lighting rig where they have complete control of the lighting EXCEPT when it goes into 'Beat' mode. In this mode they would like total randomisation of the channel or channels that are switched ON/OFF to the beat of the music. Any ideas? BTW, I'm pretty stuck with the FX2N on this one... Client supplied base unit! Best Regards Paul Ked Edited by Paul Ked

Share this post


Link to post
Share on other sites
Do you get an input for the 'beat' if so i would just have a fast timer running and every time the beat came in reset the timer and take the value that was in the timer, its going to be fairly random, you could do some furter randomistaion of the timer by adding and subtracting values from another timer which was running

Share this post


Link to post
Share on other sites
I like it I was thinking of doing some maths with different timers and looking at the scan time. setting timers from the 'Beat' input will probably do the job easier and be more random. Many thanks and Best Regards Paul Ked

Share this post


Link to post
Share on other sites
If you could upgrade, FX3U has RND random number generator instruction.

Share this post


Link to post
Share on other sites
You could also do a search on plcs.net I asked this queston a few years ago on there and got some amazing answers. - Mine was for a random colour dying machine. If I remember correctly, I got a superb 'build your own' random number generator.

Share this post


Link to post
Share on other sites
i wouldn't bother too much. how many people can figure out sequence by looking at bunch of flashing lights? how many get fooled by card tricks etc when they actually look for mistake? i bet even simple method should be more than enough, after all the beat (music) is made by humans, how accurate can it be? isn't that enough?

Share this post


Link to post
Share on other sites
I appreciate your view Panic, but here in Wales we're a pedantic bunch! Some clever so-and-so would soon suss out the sequence and, being a small town, I would be ridiculed to the point of embarrassment Crossbow, I'd love to use an FX3U but I am stuck with FX2N (see previous post) I have taken on board the 1ms timer and using 'Beat' input to [MOV T246 K2M10] (I have only 8 channels to flash) is producing an 'almost' random pattern. However, bits 0 and/or 1 are about 83% sure of being 'ON' using this logic. I have tried using other timers with various add, subtract, multiplication and divide combinations but still getting about 83% of 0 and 1 being 'ON'. I guess that binary numbers really do rely quite heavily on these two bits If anyone (especially pointing at Goody (did a search on plcs.net but couldn't find anything )) can offer assistance, it would save me some face Best Regards Paul Ked

Share this post


Link to post
Share on other sites
divide by 4 and loose those two or better try something proven like one of many rotate + XOR solutions like this: http://en.wikipedia.org/wiki/Linear_feedback_shift_register

Share this post


Link to post
Share on other sites
Perfect. Many thanks, I shall be able to hold my head up high Best Regards Paul Ked

Share this post


Link to post
Share on other sites
Interesting link there panic.. BTW i did upload an Omron version of a Random Number Generator ... you could probably translate it to mitsubishi...

Share this post


Link to post
Share on other sites
ok, i don't have FX to try it out but this should do.

Share this post


Link to post
Share on other sites
as said, can't test it but if I recall correctly (it happens sometimes...) then something like this should work (variation of that code posted on Wiki). the feedback pattern can be any number but to get long sequence of pseudo random numbers, one should check criteria (this number + 1, should be prime number)

Share this post


Link to post
Share on other sites
I didn;t mean for you take me literally there panic mate.... I was just trying to point Paul Ked to a previous example.... Nice work there though buddy...

Share this post


Link to post
Share on other sites
glad to help, couln't really sleep and didn't have anything better to do i guess but if you are really like your nickname suggests, you may not understand... (jab...)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0