LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabView Help

Think of it like shuffling a deck of cards.

 

It is a simple way of randomizing a series of elements.

 

Actually I think it is too simple of an answer and is not the answer your teach is going to be expecting since I think you are supposed to be learning how to program in LabVIEW,   Dropping a simple Riffle function on a block diagram is not teaching you anything about how to program in LabVIEW.

0 Kudos
Message 21 of 30
(1,735 Views)

@Solrac_0 wrote:

So here is my second attempt to post my VI. So Im trying to figure out what to do next. I need to create a lottery generator simulator. Numbers must be betwen 1-69 and they cannot repeat. 

I took a screen shot of the VI just in case it's blank again.


The inner loops and array handling are a bit messy.  No need for the last 1/2 dozen versions of the array.

 

When you generate a number, search the array coming from the shift register to see if it exists.  If it does, then repeat the inner while loop.  If it does not, end the while loop and Build that number onto the end of the array to put back into the shift register.

 

Have your while loop do this 6 times (not zero).

0 Kudos
Message 22 of 30
(1,720 Views)

@Solrac_0 wrote:

So here is my second attempt to post my VI. So Im trying to figure out what to do next. I need to create a lottery generator simulator. Numbers must be betwen 1-69 and they cannot repeat. 

I took a screen shot of the VI just in case it's blank again.


Your shift register should not have an array.  Initialize all of the history shift registers to 0.  Then you should be all but there.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 23 of 30
(1,718 Views)

@Solrac_0 wrote:

So here is my second attempt to post my VI. So Im trying to figure out what to do next. I need to create a lottery generator simulator. Numbers must be betwen 1-69 and they cannot repeat. 

I took a screen shot of the VI just in case it's blank again.


  • You have a value of zero wired to the N input, so the loop will not iterate.
  • You are trying to write a DBL floating point number to an array type shift register.
  • I don't think you understand how shift registers work. Each iteration, the value will get passed to the next loop and the extended shift registers store previous loop values.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 24 of 30
(1,712 Views)

so i mangaged to get this far but my program only genarates the same number. How do i make it genarate differnent numbers?

0 Kudos
Message 25 of 30
(1,705 Views)

my program only genarates the same number.

Because you programmed it this way - by using InitArray with an arraysize of 10…

 

What's the outer FOR loop for?

Using Autocleanup isn't important to you?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 26 of 30
(1,689 Views)

But that doesn't answer my question!!

0 Kudos
Message 27 of 30
(1,683 Views)

Hi solrac,

 

I moved your new message into your older thread - please stick with one thread as much as possible…

 

Well, creating an array from your lottery numbers would help!

To build an array I often use the function BuildArray. Or I use the autoindexing feature of a loop output tunnel.

Both are basic LabVIEW stuff: did you go through all those free online tutorials to learn basic LabVIEW stuff?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 28 of 30
(1,666 Views)

I finally got it!!!!! Thank you all!!!!!

0 Kudos
Message 29 of 30
(1,647 Views)

OK, I'll jump back in again now.

 

Yes, I intentionally miswired the init array. Smiley Surprised  but taking the riffled index out of riffle.vi is just so slick I had to show it.  Surprisingly the "Lottery Generator" problem is quite common!  I've even had it presented TWICE as a practical interview exercise!

 

Was it perfect each time?  (of course not! the danged vi was less than a perfect implementation originally!  The examiniers didn't know that though!)

 

Now, with that stated! If your want to randomize the distribution of a set- Riffle them!  just like "Riffling" a deck of cards or ma-jong tiles.  Certainly some bright mathmatician found a easy way to do that or casinos would loose their shirts!

 

I learned that small bit of info way back when I was asked to build a "Bridge" game in the 9th grade.  The darned "Game" dealt poorer hands on average than you would expect to see.  The Computer, riffled the cards more randomly than a human (And some dealers stuff the deck)


"Should be" isn't "Is" -Jay
0 Kudos
Message 30 of 30
(1,604 Views)