LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Blink function as a SubVI

Solved!
Go to solution

Hi, I am fairly new to LabVIEW and recently learned about subVIs. I'm trying to create a subVI for a blink function as I need an LED to blink at several points, each with different intervals. 

 

Unfortunately it doesn't work. I have ran the program in execution mode and no outputs are coming from the subVI. In the attached files you can see what my subVI looks like, and two examples of how I have used the subVI. If more information is needed to help me solve this question, please let me know.

Download All
0 Kudos
Message 1 of 16
(4,291 Views)

Hi Joram,

 


@JoramH wrote:

Hi, I am fairly new to LabVIEW and recently learned about subVIs.

Unfortunately it doesn't work.


When you are new to LabVIEW then you should learn about THINK DATAFLOW! first…

And you should learn to provide better error descriptions: "doesn't work" is very descriptive!

Additionally you should learn to attach snippets or VIs instead of plain images when you want to get better help.

 

Your subVI works exactly as you have it programmed to work: create a "blink" boolean until you press this stop button. What else do you expect?

 

Bonus point for the nice VI icon.

Malus point on those coercion dots…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 16
(4,278 Views)

While I was waiting for someone to reply to my topic, I scrolled around a bit here and saw that indeed my description was not very helpful. What I mean with 'it doesn't work' is that while the subVI does blink when running on its own, when I place to subVI in my case structure the output of the subVI is not coming through.

 

I am not totally sure, but could this be because I am giving different values to the subVI at the same time (even though these values come from separate cases in the same case structure)? 

 

The attached file this time is the complete project. There are a lot of files though. The important ones for this specific problem are 'BlinkFunction' and 'InspectieRobotMainSimulatie' 

 

Sidenote, I managed to fix the coercion dots, thanks for pointing those out! 

0 Kudos
Message 3 of 16
(4,196 Views)

Hi Joram,

 


@JoramH wrote:

What I mean with 'it doesn't work' is that while the subVI does blink when running on its own, when I place to subVI in my case structure the output of the subVI is not coming through.

 

I am not totally sure, but could this be because I am giving different values to the subVI at the same time (even though these values come from separate cases in the same case structure)?  


The problem is not to call that subVI with different parameters.

 

The problem is with "THINK DATAFLOW!": this subVI will only return its last "Blink" value when the while loop is stopped by your "Stop" button!

 

Didn't I mention that behaviour in my previous message?

Your subVI works exactly as you have it programmed to work: create a "blink" boolean until you press this stop button.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 16
(4,225 Views)
@GerdW wrote:

The problem is with "THINK DATAFLOW!": this subVI will only return its last "Blink" value when the while loop is stopped by your "Stop" button!


Wouldn't that be the case if the LED were outside the while loop? Then a tunnel is created and I know that a tunnel usually only transfers the last boolean through.



The problem is not to call that subVI with different parameters.


Does this also count when I don't exactly call them at the same time? As I explained earlier, I just change the value when the case structure switches cases. I've tried to change the value when I had the subVI running by itself and that worked fine.

 

Also, what exactly do you mean with 'THINK DATAFLOW!', it's something I never heard of yet, but I assume it is just that you should think how the data flows throughout the program?

 

Pardon me for not understanding it yet, I appreciate your patience.

 

 

0 Kudos
Message 5 of 16
(4,180 Views)

When you call a subVI it run run until completion before returning any data. As mention, once you call it, it will remain running and waiting for the stop button to be pressed. During that time, no data is being passed back to the calling VI.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 6 of 16
(4,175 Views)

Alright, I think I understand it now. Is there any way I can make the subVI continuously pass data to the calling VI? Or is there another not-too-complicated solution for this?

I can't really use the outer while loop for the blink since I would have to change the cycle speed to change the blink interval. Using a new while loop for every time I need a blink also sounds a bit unnecessary.

 

Any suggestions would be helpful, or just point me in the right direction.

 

 

0 Kudos
Message 7 of 16
(4,154 Views)

Hi Joram,

 

that "THINK DATAFLOW!" is explained in the LabVIEW help, right in the basics chapter…

 


@JoramH wrote:

Or is there another not-too-complicated solution for this?


Use ElapsedTime, one of just two or three really useful ExpressVIs.

Every time the time has elapsed you switch the blink/boolean state of your LED. (When you are used to boolean algebra you might think of XOR…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 16
(4,141 Views)

@JoramH wrote:

I'm trying to create a subVI for a blink function as I need an LED to blink at several points, each with different intervals. 


What are "points"? You mean several different LEDs? Does each LED blink forever at the same speed or can they change on demand, or even stop blinking? What is the speed of your toplevel loop where you are calling the VI? It can all be done, but will be a bit clumsy.

0 Kudos
Message 9 of 16
(4,123 Views)

All that you will ever need to know about dataflow is contained within this one sentence:

 

"Remember that a node executes only when data is available at all of its input terminals and supplies data to the output terminals only when the node finishes execution."

 

This applies to loops as well.  The loop cannot produce an output until it has completed.  This applies to subVIs.  A subVI cannot produce an output until it has completed everything inside of it.

 

By memorizing that one sentence - as literally as you can - with some patience, you should be able to predict dataflow (or lack thereof) and program with much success.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 10 of 16
(4,095 Views)