Jump to content

Randoms Numbers


Recommended Posts

  • 1 year later...
  • MVP 2023

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.

  • Upvote 1
Link to comment
Share on other sites

  • 1 year later...

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.

Link to comment
Share on other sites

  • 8 years later...

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?

Link to comment
Share on other sites

  • MVP 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

Link to comment
Share on other sites

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.

Knipsel.PNG

Link to comment
Share on other sites

  • MVP 2023

Here is how I would do the part you are uncertain of:

image.thumb.png.abb4c05b5b9e52da08aeae7dbf4885a7.png

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...