LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Turning on LEDs of Arduino UNO while displaying videos using LabVIEW

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.

0 Kudos
Message 1 of 10
(1,271 Views)

A couple of points (as you are a New Member, so don't know how to get the best help):

  • You "did the right thing" by combining multiple Attachments into a single one.  This "single attachment" could have 200 VIs and 20 Data Files inside it, and it would be OK.
  • Please do not use .RAR for "bundling" Attachments.  To attach multiple files, put them in a folder, compress the folder, and attach the resulting .ZIP file which any (modern) Windows PC will be able to open.
  • I don't understand the nature of your problem.  Part of it is you use the term "Workstation" -- is this an actual PC, connected to your Host machine via Ethernet, or a "model" consisting of I-don't-know-What + an LED?
  • A better explanation of what you are trying to do, including defining Workstation, might be helpful.  What is the purpose of the 20 Buttons?  [Logic says if there are 20 buttons and 20 "workstations", a Button signals a Workstation, but to do what?
  • You say you can light up the 20 LEDs when you push a button, you can play a Video when you push a button, but you can't do both at the same time (or so I interpret your question).  I still don't understand what you are trying to do when you push a button ...
  • Please gather all of your code together in a folder, compress the folder (with example data files, if useful, but we don't need 20 videos, 2 will certainly suffice), and attach the resulting .zip file.

Bob Schor

0 Kudos
Message 2 of 10
(1,246 Views)

Thank you for answering, Bob. And thank you for the .ZIP file suggestion as well. Our project consists in the following:

 

  • Drilling 20 holes on a quarry's scale model located in a museeum (previously done);
  • Placing 1 LED in each one of the 20 holes (total of 20 LEDs) and connecting them to a single Arduino UNO. We can control all 20 LEDs individually and all of them are functional;

A couple of points as well:

 

  • Each "hole+LED" represents a "workplace", "zone", "workstation". English is not our native language, and as it seems we may have confused you and other people, let's call it "zone" instead. There are 20 different zones in that scale model, and each zone has 1 LED;
  • Next to the scale model there is a touch screen. On this touch screen you can see an exit button and 20 buttons. If pressed, one of these 20 buttons will display a video.
  • Let's assume that we have pressed the button "Hydro-bag" (position number 17 in the JPEG file that I have attached along with the .ZIP file). If a visitor or a tourist presses the "Hydro-bag" button, the main menu disappears, and the sub-VI "Hydro-bag" is opened. Afterwards, a video displaying what kind of work is done in the "Hydro-bag" zone of the quarry is played, and in order for the visitor (or tourist) to understand where the "Hydro-bag" is located on the scale model, an LED located in position number 17 must be turned on! When the video comes to an end, or if the "Regressar ao menu principal" (Return to the main menu) button is pressed, that LED must be turned off;
  • If we press the "Ripper and Blade" button (position 19 in the JPEG file), the main menu disappears, sub-VI "Ripper and BL" is opened, a video is played on the touch screen, which explains how workers operate the Ripper and Blade, and an LED located on position 19 is turned on. Once again, if the video comes to an end, or if the "return to the main menu" button is pressed, that LED must be turned off;
  • In order to make things easier, I've included only these two buttons (Hydro-bag; Ripper and Blade) and their respective videos, as you've suggested;

This is the main problem:

  • For example, when we press the button "Hydro-bag", the video related to it is played on the touch screen, but the LED on position 17 doesn't turn on. After looking into our code, can you tell us why it's not turning on? We want the LED on position 17 to turn on at the same time that the video related to position 17 (Hydro-bag video) is played on the touch screen. And we want the LED to be turned off once the video comes to an end, or when the "return to the main menu" button is pressed.

 

Note: As described before, MakerHub's LINX was used because of the Arduino UNO

0 Kudos
Message 3 of 10
(1,224 Views)

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.

0 Kudos
Message 4 of 10
(1,206 Views)

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!

 

0 Kudos
Message 5 of 10
(1,202 Views)

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.

0 Kudos
Message 6 of 10
(1,182 Views)

And what does this 10000 mean? What does it do?

0 Kudos
Message 7 of 10
(1,178 Views)

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.

0 Kudos
Message 8 of 10
(1,172 Views)

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.

0 Kudos
Message 9 of 10
(1,151 Views)

Problem solved, thanks everybody for your help

0 Kudos
Message 10 of 10
(1,110 Views)