LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sharing an Indicator Value Across VI's

Hi all LabView rookie so go easy on me,

 

Basically I'm running a video in one VI using Windows Media Player and I extract the current position in the video using a Property Node which then writes this value to a double integer indicator. I want to share this indicator value across another VI whilst this video is running but I'm not sure how to do it. I'm pretty much using this to run the video:

 

https://decibel.ni.com/content/docs/DOC-25131

 

Thanks for any help.

0 Kudos
Message 1 of 11
(2,697 Views)

Am I right in thinking Shared Variables might be the way to go?

0 Kudos
Message 2 of 11
(2,689 Views)

You can simply go with a global variable if you are not doing any critical operation where you cannot afford data loss.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 3 of 11
(2,683 Views)

I tried the Global variable way but it won't wire correctly when I put the indicator in the Global variable VI, unless I'm doing it wrong.

0 Kudos
Message 4 of 11
(2,681 Views)

Can you show how you have used teh global variable? (If you are going to post the vi please post it in 2011 version or just post a picture of your code where you have used the global variable)

-----

The best solution is the one you find it by yourself
0 Kudos
Message 5 of 11
(2,675 Views)

Basically using the code in the URL I posted in the Opening Post I tried to connect current position straight to a global variable the vi of which just had a numeric indicator in. I can post the code if you like.

0 Kudos
Message 6 of 11
(2,672 Views)

Yes. It would be better if you can show how you have tried connecting a global variable and what is the problem (2011 version please)

-----

The best solution is the one you find it by yourself
0 Kudos
Message 7 of 11
(2,666 Views)

Please find the VI as attached. I want to transfer the data from current position across to other vi's in a project, I'm not sure I am using the global variable correctly. As said I am fairly new to LabView. Many thanks.

 

I can't seem to post the project so I will send the main VI and control structure to run it. I want to get CurrentPosition as a global variable, I want to share it across VI's as the video plays.

Download All
0 Kudos
Message 8 of 11
(2,661 Views)

Ok I think I've got the global variable to work but the variable only updates continuously showing the time if I run it continously. Also is it possible to synchronise VI's so they start running at the same time, I suppose I could add a delay to the first VI.

0 Kudos
Message 9 of 11
(2,643 Views)

Dear cheemz,

 

Thank you for posting this to the user forums.  I took a look at your code and can offer a couple of tips & tricks.

 

At the end of the code you can expand the merge errors function to handle errors from multiple sources.  Note that the merge errors function does not concatenate errors; it returns the first error that it finds and if it finds no errors then it returns the first warning.

 

You should also place boolean controls inside their respective event structure to restore their latch mechanical action behaviour.

 

There may be a conflict from having the event structure timeout and the wait until next ms multiple function, so I would remove the wait until next ms multiple function from inside your while loop - it plays no role in the code.

 

You code does look very good though - well done!

 

As for the global variables issue - there is a chance that you can get race conditions with variables, so to try to mitigate this you should try to pass data around with global scope by using a functional global variable.  It stores the data in an uninitialised shift register; https://decibel.ni.com/content/docs/DOC-2143

 

Since labVIEW is a dataflow language, a function only executes when all it's inputs have values and a function is only returned once all it's outputs have values.  The best way to force dataflow is to use the error cluster, so you could have an error in and error out as terminals in your subvi and make this the first thing that your main VI does (pass the error cluster).

 

I hope this information helps and you are enjoying using LabVIEW.

 

Kind Regards,

Robert Ward
Applications Engineer, NI
0 Kudos
Message 10 of 11
(2,603 Views)