02-26-2020 05:28 AM - edited 02-26-2020 06:18 AM
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.
Solved! Go to Solution.
02-26-2020 05:51 AM - edited 02-26-2020 05:51 AM
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…
02-26-2020 06:16 AM - edited 02-26-2020 06:18 AM
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!
02-26-2020 07:40 AM - edited 02-26-2020 07:41 AM
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.
02-26-2020 10:51 AM
@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.
02-26-2020 11:03 AM
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.
02-26-2020 11:46 AM
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.
02-26-2020 12:44 PM
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…)
02-26-2020 02:30 PM
@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.
02-26-2020 05:59 PM
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.