LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to updating variables without having multiple queues/notifiers?

I have two while loops:

1) Loop 1 contains multiple variables that reading from multiple sensors.

2) Loop 2 is a state machine that uses the variables from loop 1 to determine how it should proceed. For example, if variable 1 from Loop 1 is above x value -> do this. The variables are getting update constantly.

I was using notifiers when there were only a few variables, but now I have more than 10. 

 

Thank you!

0 Kudos
Message 1 of 9
(2,384 Views)

@ShinyBidoof wrote:

I have two while loops:

1) Loop 1 contains multiple variables that reading from multiple sensors.

2) Loop 2 is a state machine that uses the variables from loop 1 to determine how it should proceed. For example, if variable 1 from Loop 1 is above x value -> do this. The variables are getting update constantly.

I was using notifiers when there were only a few variables, but now I have more than 10. 

 


 

Can you explain what you mean by "variables"? ... by "constantly"? (these are very ambiguous terms, especially in LabVIEW)

 

It would help to see some code.

 

Whenever you have more than a few of something, it helps to carry them as arrays as soon as possible.

0 Kudos
Message 2 of 9
(2,379 Views)

Arrays and Clusters are your friends when dealing with multiple of something.  Based on your description, I do think the array is the best route to go.

 

Alternatives to the Notifier are Tag Channels and Global Variables.


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 3 of 9
(2,309 Views)

@altenbach @crossrulz I didn’t know I could queue arrays. I think that’s what I’m looking for. Basically, I just have a while loop that reads sensor info every second and feeds the readings to my state machine loop. I don’t have the program or Labview on my personal computer. I’ll give it a try later today when I have access to it. 

Thanks!

0 Kudos
Message 4 of 9
(2,299 Views)

You can queue anything you want, including arrays.

 

If the consumer loop (the state machine) needs the most recent value, you can make the queue a single element queue, and do a lossy enqueuer in the producer. That prevents values queueing up in the queue. If not (you need to process all values), two loops might only complicate things. A read\process\write or input\process\output scenario seems more to the point then. The input, process and write and be paralyzed in the same loop with two shift registers (or feedback nodes) if needed.

0 Kudos
Message 5 of 9
(2,286 Views)

wiebe@CARYA wrote:

If the consumer loop (the state machine) needs the most recent value, you can make the queue a single element queue, and do a lossy enqueuer in the producer. That prevents values queueing up in the queue.


Or just use a Notifier, which just holds the latest update.


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 6 of 9
(2,279 Views)

@crossrulz wrote:

wiebe@CARYA wrote:

If the consumer loop (the state machine) needs the most recent value, you can make the queue a single element queue, and do a lossy enqueuer in the producer. That prevents values queueing up in the queue.


Or just use a Notifier, which just holds the latest update.


Are there benefits to using a Notifier? I'd say maybe the one advantage is that it does exactly what is required and nothing more, while a queue can do (potentially) more. But besides that, why not use a queue?

 

I personally am familiar with queues, and don't see the reason for existence of notifiers (probably because this personally bias). It's just easier for me to always use a queue.

0 Kudos
Message 7 of 9
(2,268 Views)

wiebe@CARYA wrote:

Are there benefits to using a Notifier?


Notifiers are broadcast, so you can send a single Notification to many places.


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 8 of 9
(2,263 Views)

@crossrulz wrote:

wiebe@CARYA wrote:

Are there benefits to using a Notifier?


Notifiers are broadcast, so you can send a single Notification to many places.


Ah, ok. Like using the preview in a single element queue Smiley Wink. Guess the notifier is a better fit...

 

I'd never use a naked queue (or notifier) anymore. As long as everything is nicely wrapped in a class, it's easy to convert from one to the other.

0 Kudos
Message 9 of 9
(2,252 Views)