Wendy Viera Posted February 4, 2011 Report Posted February 4, 2011 Hi! I need to generate a random number between 1 and 10. I tried to generate the random number with a formula, but it always generates the same form or sequence (not random). Any ideas? Thanks in advance!!!
Stein Yair Posted February 6, 2011 Report Posted February 6, 2011 Hi Wendy, The type of random number generator depends on the application I can offer you two different random number generators which you might find useful. Random Number Generator 2.vlp V570_Random_number_generator.vlp
MVP 2023 Flex727 Posted February 2, 2013 MVP 2023 Report Posted February 2, 2013 I don't know if Stein Yair is still around and participating in this forum, but I just want to say thanks. I had an urgent need for some random number generation and the above post is exactly what I needed. By the way, Unitronics should consider adding a RND function to the available math functions in VisiLogic. 1
kamrca Posted October 31, 2014 Report Posted October 31, 2014 Can pls somebody expain how the above two RNGs work or how can I open vlp files. I use jazz / M-90. THX!
MVP 2023 Flex727 Posted October 31, 2014 MVP 2023 Report Posted October 31, 2014 Install VisiLogic to open .vlp files.
s.pratt Posted October 31, 2014 Report Posted October 31, 2014 Hello kamrca, You must use our software VisiLogic to open .vlp files. The Jazz/M90 controllers will be programmed in U90, .U90 file extension. Here is a basic overview of the programs: The V570_Random_Number_Generator takes a 32-bit value and multiplies it by 75 (a random number) then divides that value by 65537, and the random number will be the remainder of the division. The Random Number Generator 2 takes a 2.5msec count (generated by the system) and multiplies it by the current second (also a system operand). Then it reduces the number such that it is a value between 1 and 10 by taking the remainder of the product created before and using the remainder after dividing by 10. Hope this helps.
kamrca Posted November 2, 2014 Report Posted November 2, 2014 Thx a lot to your kind answers!. I thout it was that
guusminnaard Posted January 31, 2023 Report Posted January 31, 2023 I'am using the random number generator 2. I need random numbers between 0-5, I cant get the number 0. Can anyone give me the solution?
AlexUT Posted January 31, 2023 Report Posted January 31, 2023 Just generate 1 to 5 and then use (n-1).
guusminnaard Posted January 31, 2023 Report Posted January 31, 2023 English: Ok, thank you for your answer I will use it that way. Im an beginner with visilogic so i don't know how I can transform the random number into an MB. Can you help me with this? Dutch: Oke bedankt voor je reactie, Ik ga het op die manier gebruiken. Ik ben een beginner op het gebied van visilogic, dus weet nog niet hoe ik het random number kan converteren naar een memory bit. Kan je me hiermee helpen?
MVP 2023 Ausman Posted January 31, 2023 MVP 2023 Report Posted January 31, 2023 10 hours ago, guusminnaard said: beginner with visilogic so i don't know how I can transform the random number into an MB Guus, your question implies that you are indeed a beginner in Visilogic. The forum is not really here to help you learn basics....it's up to you to go through a big initial learning curve. You need to thoroughly read through the help files available in Visilogic, and learn what the various working operands all do, and how they work. You then need to experiment with basic ladder structures using an actual plc for trial and error learning. Then you can start on building programs you need, and any major stumbles along the way the forum can help. cheers, Aus
MVP 2023 Flex727 Posted January 31, 2023 MVP 2023 Report Posted January 31, 2023 12 hours ago, guusminnaard said: i don't know how I can transform the random number into an MB This has no meaning. An MB is a bit - it is binary, either 0 or 1. A random number would be an integer, typically an MI.
guusminnaard Posted February 1, 2023 Report Posted February 1, 2023 ok, thanks for the reactions. I my program like this now. I need to use the random number to switch an random target, my question is how do i use my random number to switch an output/target? I tried some things but I'm not expierenced enough to know why is doesn't work. So maybe you guys have an idea. This project is for an shooting range, so the random number need to switch an random target.
MVP 2023 Flex727 Posted February 1, 2023 MVP 2023 Report Posted February 1, 2023 Here is how I would do the part you are uncertain of: You don't have to use vector functions - you can just use a series of compares - but this is easy and concise. You also don't have to group the elements in rung 3 the way I did with SB 1. I just like to group similar items in that way to save space and make for easier readability.
guusminnaard Posted February 1, 2023 Report Posted February 1, 2023 Wow! Thank you Flex, for this example!
MVP 2023 Flex727 Posted February 1, 2023 MVP 2023 Report Posted February 1, 2023 I probably should have put in rung comments: Rung 1 - reset all 6 MBs Rung 2 - Store 1 in the bit corresponding to the offset value of the random number MI Rung 3 - turn on the correct output
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now