05-14-2021 12:43 AM
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!
05-14-2021 01:32 AM - edited 05-14-2021 01:33 AM
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:
05-14-2021 09:16 AM - edited 05-14-2021 09:25 AM
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.
05-14-2021 09:41 AM
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)
05-14-2021 12:31 PM
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?
Thank you yet again, I appreciate it!
05-14-2021 12:37 PM - edited 05-14-2021 12:42 PM
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…
05-14-2021 12:39 PM
Right click on the border of the IPE structure and get a shortcut menu of the nodes you can add.
05-14-2021 06:14 PM - edited 05-14-2021 06:22 PM
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?
05-14-2021 08:00 PM
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)
05-15-2021 09:40 AM
Use cluster in place of integer input and in that cluster use 3 separate integer done.