LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simulate random number from 1 to 8 assign to 4 menu

So I have this assignment due to monday and I'm stuck so badly in this part 

It is to make a Point of sale system using labview, and on order processing system the following task has to be carried out : 

 

  • There are 8 set meals available and each customers are allowed to order up to 4 set meals. Each set meal is priced differently.  The amount of the order will be totaled.  Simulate the ordering process in LABVIEW.

 

Our teacher said it has to be done as in random number which have to be connected to the case structure and based on the number generated  , a set menu and their price to be selected and get display on the front panel, and since there can be only up to 4 set meals order, so there are 4 structures. 

 

I didn't quit understand how to generate the output and total them in this way. Please help me out. 

 

In following attachment I tried to generate this simulation , but it's very unsuccessful 

0 Kudos
Message 1 of 10
(3,067 Views)

Based on your VI, you even miss the most basic things in LV programming. What did you learn so far in your class? Did you learn about loops? Did you learn about shift registers? The VI what you show does not make too much sense. If I was you, I would take the free LabVIEW tutorials, you can learn enough in 2 days to be able to program your home work, and finish it by Monday...

The other option is to wait for someone to do your home work, if you are lucky...

0 Kudos
Message 2 of 10
(3,059 Views)

well yes, we did the loops and structures and array and everything, I just don't get the grasp of idea on how to apply it for this case. That's why I'm kind of looking for guidance 

0 Kudos
Message 3 of 10
(3,057 Views)

So, you (hopefully) aren't going to get anyone to do your assignment for you... but we'll gladly help guide you in the correct direction.  Below is an image of how you might consider refactoring your code a little bit.  Play with that some and post your attempts.

 

The key here is that you do NOT want duplicates of each control and indicator.  Instead you want 1 ring for each order going into the case structure and being added with only one "total" generated.

 

Your requirements were vague, but I assume the "random number generated" is going to be randomly picking the number of orders placed.

 

orders.png

 

 

0 Kudos
Message 4 of 10
(3,040 Views)

Ok I help you a bit. See the snippet below. Please try to understand how it works. Turn on the "Show context Help", the little question mark at the top right of the window. If you hover your mouse above certain elements, it will give you some description, and gives link to more details too.

The snippet I put together uses some made up meal prices (8 meals). The FOR loop represents the 4 choices a person can make. We need to generate 4 times 4 random numbers between 0 and 7. The reason is that, the first element of the "meals" array constant has an index of "0.", and the last 8th element has an index of "7.". LabVIEW is zero indexed language, like C.

 

So we generate 4 random indexes, and get the required meal price from the array using the "Index Array" function. We autoindex the generated indexes at the right border of the FOR loop. We also autoindex the prices, then Sum them up to get the total price.

 

Please, try to understand how the code works, and play with it. This is the way how you can learn, otherwise my help was meaningless. The point is not to provide home work, but you learn from it.

 

I let you to enhance this code: lets imagine, we exclude the option that the person can chose the same meal more than once. This code might generate the same meal index multiple times. How would you modify this code to avoid multiple selection of the same meal?

 

meal_order.png

0 Kudos
Message 5 of 10
(3,038 Views)

You lucked out... Blokk is nicer than I am 🙂

0 Kudos
Message 6 of 10
(3,033 Views)

you haven't come far, other than finding the random function and adding some buttons.

 

when using the random function you have to make sure all your values are possible, and maybe evenly distributed. i would suggest using the round to nearest after the scaling.

 

also from the problem description i understand, that there are 8 meals, from which are at most 4 choosable per person, that differs from what you have written. e.g. you have more than 4 cases .. more like 8 choose 4 (http://www.wolframalpha.com/input/?i=8+choose+4).


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 7 of 10
(3,032 Views)

@jwscs wrote:

 

... and maybe evenly distributed. i would suggest using the round to nearest after the scaling.

 


Round to nearest will make the edge numbers only half as probably as the rest. (...unless you do very convoluted scaling first) 😄

Message 8 of 10
(2,987 Views)

@Shagholi75 wrote:

 

  • There are 8 set meals available and each customers are allowed to order up to 4 set meals. Each set meal is priced differently. 

Do the four meals per customer need to be different or can a customer order the same thing twice, for example? If the meals per order need to be different, you need to use a different algorithm.

 

Apparently, he can order 0, 1, 2, 3, or 4 meals, right? The customer is not required to order exactly four meals ( "... up to four"). Again you need to implement a second random generator to determine the number of meals per order. Is "no meal" allowed?

 


@Shagholi75 wrote:

and since there can be only up to 4 set meals order, so there are 4 structures. 

 


No, the number of structures does not need to be correlated with the number of allowed meals. That statement makes no sense at all! Programmed right, you could deal with a million meals with no inner structure at all :D.

 

How should the front panel look like? What should the output be? (e.g. "(1) total price, (2) list of selected meals with itemized prices, (3)..., etc.).

 

0 Kudos
Message 9 of 10
(2,980 Views)

@altenbach wrote:

@jwscs wrote:

 

... and maybe evenly distributed. i would suggest using the round to nearest after the scaling.

 


Round to nearest will make the edge numbers only half as probably as the rest. (...unless you do very convoluted scaling first) 😄


you are of course right 😉

 

Histograms of the rounding functions with 8 bins [i, i+1[

the white line is just the scaled random numbers and follows the green line (round-down)

random-scaled-round--graph1.pngrandom-scaled-round--graph2.png

 


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 10 of 10
(2,964 Views)