07-26-2020 06:59 AM
Good morning,
Me and my partner have been trying to solve a problem for the past few weeks regarding the topic of this post: we had to install a set of 20 LEDs on a scale model of a quarry, and we did so by using 1 Arduino UNO, 3 decoders 74LS138 and 4 inverters 74LS04 (which would allow us to use up to 24 LEDs). We have soldered everything and installed the LEDs on their proper place, and we created a simple program on LabVIEW to test all of them connected to the Arduino. So far we had no problems, the hardware seems to be working correctly, and all the LEDs light up when prompted to do so, which means the circuit itself is correctly installed.
Our problem begins with the software (LabVIEW itself and our programming): we have created a menu comprised of 21 buttons: an exit button and 20 other buttons. After pressing one of these 20 buttons, the menu disappears, a sub-VI is called and a video is displayed. Once again, we had no problems displaying the videos and returning back to the main menu, upon clicking on the return button.
What we can't accomplish is the following: the scale model of the quarry has 20 different workstations, and each workstation has an LED and a corresponding video associated to it. When we press one of 20 buttons, the corresponding LED associated to the workstation shown on the video should be lit up on the scale model. Unfortunately, only the videos are working correctly, but none of the 20 LEDs lit up when we tested the 20 buttons. As we explained before, we tested all the 20 LEDs and they work correctly, thus we believe it's a programming error.
We've been trying to solve this problem for the past 5 weeks and we have no idea how to solve it. All the sub-VIs have a similar code, and they only load videos, so we'll post here the main program along with 4 sub-programs and 4 videos, as we can only send a maximum of 10 files. In order to test the videos, you need to change the directory of the videos on the sub-vi. After changing the directory, the only buttons available will be "Exit, Hydro-bag, Ripper and Bucket Loader, Hydraulic Stone Bench Pusher, Chainsaw Cutting Machine". We were given this old code programmed with LIFA (LabVIEW 2013) and we converted it to LINX (LabVIEW 2020), but it's still not working.
Thank you for taking your time to read this.
07-26-2020 08:52 AM
A couple of points (as you are a New Member, so don't know how to get the best help):
Bob Schor
07-26-2020 10:57 AM
Thank you for answering, Bob. And thank you for the .ZIP file suggestion as well. Our project consists in the following:
A couple of points as well:
This is the main problem:
Note: As described before, MakerHub's LINX was used because of the Arduino UNO
07-26-2020 11:50 AM
Whenever I see someone new put multiple event structures in a VI, I get worried.
Read Caveats and Recommendations when Using Events in LabVIEW - LabVIEW 2016 Help
You should be able to do your whole VI in a single loop.
Here are some tips:
1. You have an LED front panel "control" that controls the Physical LED light. But that is confusing because LED's on the front panel are usually looked at as indicators, not controls. I would use a push button with LED on it as the control for that light.
2. You have a command button that controls the video. (And when you press that button, a button of a different appearance shows up!)
3. The LED "button" and the video command button, aren't linked in any way. So you have to press both in order to get the real LED to light and the video to play.
4. You only need one subVI, the two you show only differ in what video they play, so use just one VI and pass the file path into it.
5. In your subVI, you should close all of those reference wires when the VI ends. Right now you are only closing the Front Panel reference wire which is actually one I think you can get away with not closing. But those Player reference wires, you almost certainly should close.
6. Your array of timeout values doesn't make sense. They will always grab the first value in the array because you look for the only True value in a one element array.
7. Put the subVI to play a video in the same event case as the one that sets the light. Turn LED on, Play video, turn LED off after the event case. The subVI running the video will hold up execution of the event case until the video and thus the subVI completes. Then the execution of the event case will continue and the LED can then be turned off.
I imagine there might be a situation where you just want LED buttons to light up things, and only occasionally play a video. There you could put the LED controls in its only loop. Use a value(signalling) property node in the event structure that controls the video to signal when to turn on and off the LED control on the front panel and thus the real LED on the Arduino.
07-26-2020 12:23 PM
I'll try doing it in a single loop, yes. This isn't really my code. My teacher asked me and my partner to correct it, and we've looked at it for a long time, and only now we've started to understand it after a couple of weeks. I've replaced a few minutes ago the LED and Video buttons for a single button that uses a global variable, but it still doesn't work.
I have no clue how to use just one sub-VI and call a different path from it. I have simplified the example, in fact I'll need to call 20 paths. How do I do it then? Do I use global variables that are strings? Besides, each path will have a different combination of digital pins on the Arduino. Won't I need multiple sub-VIs because of this?
Why does the timeout not make sense? I either pick the "timeout" of the video or the stop button to return to the front panel. Why is it not correct?
LEDs should only be turned on when a video is turned on, and they should be turned off when the video is turned off. Meanwhile I'll try using some of your suggestions to correct the program!
07-26-2020 01:23 PM
Start here. How to Learn LV
Put a path control in your subVI. Connect to the connector panel in the subVI.
In your Main VI, you wire a path constant to the input you just created in the subVI.
You have an array of values, 10000, 2000, 3000, 4000. YOu take a boolean value, build it into an array. Now you have a 1-element array with a True value. You search for the True which will always return Index 0. Guess what? It will return 10,000 ....every....single.... time.
07-26-2020 01:37 PM
And what does this 10000 mean? What does it do?
07-26-2020 01:45 PM - edited 07-26-2020 01:46 PM
You should know. You were the one who put it in there.
It is the 10,000 value you passed into the shift register to feed the timeout value of the event structure. It means 10,000 millseconds, thus 10 seconds, that the timeout case will run assuming no event happens. I don't think you'll need a timeout case in this VI at all if it is programmed properly.
07-26-2020 04:27 PM
Please read my message. I wrote "This isn't really my code. My teacher asked me and my partner to correct it", thus I don't know it. I'm trying to understand what was done before, so that I can correct it. Thanks for your help nonetheless.
07-27-2020 08:27 AM
Problem solved, thanks everybody for your help