LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Share cluster data between 2 timed loops

I'm just going to use queue messages instead 😃 For what it worth, I have been using locals for a long time and have never had any problems with them what so ever. You just have to use common sense when using them in other threads. I just use them to read data from other tasks to update indicators and so forth and have never had 1 problem with that part of it at all.

 

Thanks..

0 Kudos
Message 11 of 23
(826 Views)

@QRP wrote:

I'm just going to use queue messages instead 😃 For what it worth, I have been using locals for a long time and have never had any problems with them what so ever. You just have to use common sense when using them in other threads. I just use them to read data from other tasks to update indicators and so forth and have never had 1 problem with that part of it at all.

 

Thanks..


Lack of evidence is not envidence of absence.

 

Smiley Wink

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 12 of 23
(825 Views)

Oh there's evidence, because it works and that is enough for me. I don't have hours upon hours to waste to trying to find ways to make something fail since you don't make any money that way. If it works you go with it, if not you find another way. That simple 😃 

0 Kudos
Message 13 of 23
(813 Views)

@QRP wrote:

Oh there's evidence, because it works and that is enough for me. I don't have hours upon hours to waste to trying to find ways to make something fail since you don't make any money that way. If it works you go with it, if not you find another way. That simple 😃 


Until you get a new computer and suddenly nothing works.

 

I was given a program that worked perfectly in a test system that we made 8-10 years ago.  I was told to make small tweaks to add some functionality for a new test set.  I ended up totally rewriting it.  Disgruntled with me that I was taking so long, the coworker who wrote the original code put the original code on the new system.  And it didn't work.  Local variables causing race conditions left and right.  They weren't so disgruntled with me after that.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 14 of 23
(811 Views)

So would this ever cause a problem? I have never seen any problem just reading data with a local this way.

0 Kudos
Message 15 of 23
(804 Views)

Based on that example, an event structure would suit your needs a lot better.  But it also depends on what else you have happening.

 

99% of the time when I use locals, it is to write a value to an indicator in different states of my state machine or event structure or reading a control in the exact same structure.  But they are always in the same loop and therefore race conditions do not exist.  If you are using a local in multiple loops, there is likely to be an issue.  Of course, there are exceptions.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 16 of 23
(799 Views)

Oh Ok, this was just an example, but what you said is pretty much what I'm doing currently. I personally don't really see how you could elimnate using locals all together since you would have wiring nighmare. I do have a VI with 3 timed loops running as threads with indendant data clusters that are polling on hardware and I have a main thread state machine monitoring the threads status. I have used locals in the main statemachine just to read some of the threads data to post as indicaters and it has never failed that way at all for me. Do you see a problem with doing this? If yes, how could I change the state machine to monitor and update indicators and monitor some of the threads data without the local approach for just reads? Maybe an example would be nice... 😃

 

Thanks for your time.

0 Kudos
Message 17 of 23
(795 Views)

@QRP wrote:

Oh Ok, this was just an example, but what you said is pretty much what I'm doing currently. I personally don't really see how you could elimnate using locals all together since you would have wiring nighmare. I do have a VI with 3 timed loops running as threads with indendant data clusters that are polling on hardware and I have a main thread state machine monitoring the threads status. I have used locals in the main statemachine just to read some of the threads data to post as indicaters and it has never failed that way at all for me. Do you see a problem with doing this? If yes, how could I change the state machine to monitor and update indicators and monitor some of the threads data without the local approach for just reads? Maybe an example would be nice... 😃

 

Thanks for your time.


Wiring nightmares only happen (to me, anyways) if clusters are used only sparingly.  Wires help keep me disciplined in my coding.  😉

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 18 of 23
(791 Views)

If you have wiring nightmares or require lots of locals it is generally a sign of a poor programming architecture. I work on large systems (1000s ov VIs) and very rarely use locals. They are generally only used in UI code. Also, any of our code that starts to look messy will get refactored so we have clean code. It is much easier to maintain and extend. Here is a typical looking block diagram.

 

Block Diagram.png



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 19 of 23
(783 Views)

If you don't use subVI's for whatever reason, you can try with a queue. If you care only about the latest cluster value, you can use 'loose enqueue' and 'preview queue element'. The error handling can be improved, this here is just an example. See the attached file.

Nick

Message 20 of 23
(768 Views)