01-05-2024 11:56 PM
Hello,
I have problem with understanding how should i approach this issue, i could write it in regular programming language but in LabView i lack with experience. Thats why i decide to ask here.
So i got 4 bool controls. I decide to make 2d array in which i save bool value with timestamp when pressed didn't do that yet because i am stuck. I wanted to check if i truly can change value of the bool control which is in array, but when i get the element i have no idea how to change its value since it gives me back an indicator. I detect when 3rd value is pressed using XOR gate. First of all i want to know if my approach is correct and then it would be really helpful if someone could tell me how i can fill array and then change its element values.
Here is translated task i have to do.
Solved! Go to Solution.
01-06-2024 10:34 AM
First of all, we generally don't do your homework for you. Second, I suspect the original language for this assignment wasn't English, as I'm not entirely clear that I understand the proposed task (I can think of several different interpretations ...). I think this says that there cannot be three controls all "On" at the same time, and that the order in which the Controls are turned on is important.
Take a piece of paper and a pencil, and make a drawing with 4 switches. Start with all Off. Make the next drawing with one on. Make the third drawing with two on. Decide how to make the 4th drawing (I suggest turning one of the "on"s off). Keep going until you have 3 on -- how do you decide which to turn off?
Now do the same thing in LabVIEW.
Bob Schor
01-06-2024 12:19 PM
1. Use an Event Structure to detect when the buttons were pressed.
2. Use an array to keep track of which buttons were turned on in what order. You can use a Delete From Array to remove the element and a Build Array to add an element to the end. This array should be saved in a Shift Register on your loop.
With that information, you detect a button press and verify it went TRUE. If it went FALSE, search your array and remove the value corresponding to what just went FALSE. If it did go TRUE, add the current button to the array. If the array is now 3 or more, remove the first element and set that control's value to FALSE. References and a Value property node could make this really easy.
01-07-2024 11:11 PM
I figured it out it seems to work but i think i over do it. I used queue. adding or removing element from queue depending on what is value of pressed bool, then if there is more than 2 i remove 1st element. There is issue if i press buttons too fast it is bugged. How can i wait for iteration to finish? Should i just add simple wait or there is another way?
01-07-2024 11:43 PM
Thank you!!! That solution works perfectly with my solution it wasn't working so smoothly. I think its because queue works async but i will be really glad if someone could explain me my previous mistakes.