LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Use same control for other case structures

Solved!
Go to solution

Hello, here is an example of what I am trying to do. I am trying to use cent and nickel for when I am selecting either I want a soda or a snack. The cent and nickel should be use when soda or snack is been selected.  Please see the following simulation. I am tried so many different things but I just can't get it. Can someone help?

It will help me so much thank you!

 

 

0 Kudos
Message 1 of 8
(2,115 Views)

Some advice to get you started:

  • You only need the outer loop. You can anchor the shift registers there (amount, item, state, etc).
  • The indicators belong after the case structure (or even in a shift register if it does not always change), eliminating ALL local variables automatically. Just wire from within each case.
  • You loop runs as fast as the computer allows, burning through a full CPU code forever. Place a small wait.

See how far you get. 😄

0 Kudos
Message 2 of 8
(2,108 Views)

Thanks for the reply.

Can you please help me? I am struggling so much with this.

I want to turn on the boolean indicator on when I reach certain values as shown on each case but I can't. I don't know why. Additionally, I want to add values that already exist. Say when I press one cent and then nickel it should be .06 cents but I don't know how. This is a little difficult to me. Please help!

 

Thanks!

0 Kudos
Message 3 of 8
(2,047 Views)

 

Thanks!

0 Kudos
Message 4 of 8
(2,047 Views)

You only need one wait.

Get rid of all the local variables! Get rid of all that silly code. For example an "equal true" just returns the input unchanged, so all you need is the wire (see also). One shift register anchored in the outer loop is sufficient to carry the current balance. Compare the value with the item prices to see what can be dispensed.

 

Attached is a very simple code skeleton that increments the balance whenever one of the coin buttons is pressed. It can be made even simpler and more scalable, but that should get you started. I am also giving you some hints how to expand the code. See how far you get.

0 Kudos
Message 5 of 8
(2,022 Views)

So kind of you! Thank you very much. Will do my best.

0 Kudos
Message 6 of 8
(1,997 Views)

I also want to dispense whatever money was inserted on the indicator "Inserted money." When I cancel I want my money back and the on "Inserted money" should indicate zero and whatever money was inserted should be display on change money. How would you do that?

0 Kudos
Message 7 of 8
(1,989 Views)
Solution
Accepted by topic author BArtzon

Well, it's just another state. Of course you need to make sure that the outer loop does not stop when "cancel" is pressed (as it currently does). The program should go back waiting for coins.

0 Kudos
Message 8 of 8
(1,976 Views)