LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make the three boolean buttons work?

Hello everyone. I have this project where I get to design my own project. I decided that my project would be a Redemption Recycling Center where there are 3 machines, one is for Cans, the second is for Plastic and the third is for Glass. Each of the machines has a button of its own. The purpose of the button is to add one every time the button is pressed for each machine. 

 

For example, let's say I want to recycle 3 glass bottles and 2 cans, when I press the button for the can bottle, it will add up by one, and for the glass machine same as well. 

 

My problem is: When I click the second Start button under the plastic machine to recycle, the count will pick up from the last recycle. I want the buttons to add individually. Can anyone please help?

 

Anything is appreciated, thank you!

 

Screenshot 2021-05-14 012941.png

 

Screenshot 2021-05-14 013426.png

 

 

 

0 Kudos
Message 1 of 12
(583 Views)

Hi Gemi,

 


@Gemi06 wrote:

My problem is: When I click the second Start button under the plastic machine to recycle, the count will pick up from the last recycle. I want the buttons to add individually. Can anyone please help?


Have you tried to sketch your algorithm on a sheet of paper before actually starting to code?

 

Right now you are using a shift register to keep track of "Cans deposited", as shown in your image. Now you also want to keep track of "glasses" and "plastics", too. What do you think can be used to keep track of their amount?

 

Other suggestions:

  • When you want to discuss your code with us then we appreciate it when you attach your code. We cannot debug images using LabVIEW!
  • Using AutoCleanup before posting images of code atleast helps to prevent hidden wires. This in turn helps us to understand your images of code…
  • Why are there DBL indicators for an integer wire?
  • You are using "default if unwired" tunnels: this may indicate errors in your code design, especially when used together with shift registers!
Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
0 Kudos
Message 2 of 12
(556 Views)

If you want to keep track of three different counts, you should probably have an array with three elements in the shift register. You can use one single event structure for all buttons and increment the correct element for each button (I assume they are latch action, but we cannot tell from a picture).

 

If your indicators should update during the program run, all belong inside the loop. None should be inside the event structure. If you would place them before the event structure, they would correctly update when the program starts while currently they would show stale values until each event has executed once.

 

Why are you calling the stop button "stop 2" and why are you hiding it on the front panel?

 

Your dealing with integers. There should be no orange except for the cashback calculation

 

I am not sure why you need two indicators for each count. Seems redundant.

 

 


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 3 of 12
(520 Views)

Here's how it could look like. (there is no hidden code. Only one event case for everything!)

 

Try to recreate it! (note that I use a custom format to add the $ sign to the formatted number)

 

altenbach_0-1621003214328.png

 


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
Message 4 of 12
(511 Views)

Thank you so much! This looks 10x better than what I had. I'm new to LabView, by any chance, can you tell me how you got the part that's inside the Event Structure that has the Index Array and the increment by 1 triangle loop?

part.PNG

 

 

 

 

 

 

 

Thank you yet again, I appreciate it! 

0 Kudos
Message 5 of 12
(483 Views)

Hi Gemi,

 

that is the InPlaceElement (IPE) structure…

 

Btw. a generic forum "rule":

You did not attach code, but only an image of code. In return you also get suggestions presented only in images instead of real code.

If you would have attached your code right from beginning the chances are high you would have got code from Christian…

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
Message 6 of 12
(478 Views)

Right click on the border of the IPE structure and get a shortcut menu of the nodes you can add.

Message 7 of 12
(474 Views)

Hey @altenbach, I have tried this and did exactly what the picture showed but the buttons don't work on my end. If possible, do you mind uploading your file?

Failed.png

0 Kudos
Message 8 of 12
(428 Views)

Your events are for the indicators instead of the buttons. They need to be assigned to the buttons instead. Also, your buttons should be latch action. ("switch until released" will give you two events per button press)


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 9 of 12
(382 Views)

Use cluster in place of integer input and in that cluster use 3 separate integer done.

0 Kudos
Message 10 of 12
(359 Views)