LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW Polling

Hi everyone.  I have a question for all you LabVIEW gurus out there.  I need to poll a device repeatedly and if I lose communication with it I need to shut things down.  How do I poll this device constantly and run my other code at the same time?

 

Thanks!

0 Kudos
Message 1 of 13
(4,147 Views)

Hi hobby1,

 

just with one while loop with the read function on the inside is going to be reading constantly every loop and if you wire the error to the conditional terminal of the while loop is going to stop the loop if there is any error. Click here to obtain a little more information about while loops.

 

Hope this can help you.

Message 2 of 13
(4,138 Views)

You just need to put it in another loop.  You also need to setup some communications between the loops.  User Events, Queues, Notifiers...these are really good for sending commands and status to different loops.


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 3 of 13
(4,136 Views)

@Luis32 wrote:

Hi @hobby1,

 

just with one while loop with the read function on the inside is going to be reading constantly every loop and if you wire the error to the conditional terminal of the while loop is going to stop the loop if there is any error. Click here to obtain a little more information about while loops.

 

Hope this can help you.


The problem with using a single loop is you are limited to your loop rate.  If I just put in an Event Structure, you are not polling anymore because the event structure is sitting there holding up your loop waiting for the user to hit a button.  If you need to poll at a consitant rate, it has to be in its own loop.


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 4 of 13
(4,132 Views)

Hi 

 

 

 

Regards

Message 5 of 13
(4,124 Views)

And if he may need some events maybe the state machine structure is the best choice, but obviously having the reading loop running parallel. As you know, this design patterns are intended to run simultaneously with the polling loop for his case. There are many choices to create, but for a description like the one he gave, I tried to keep the answer simple. 

 

I wish my answers don't complicate things more Smiley Happy

Message 6 of 13
(4,115 Views)

Crossrulz, can you provide example code in where two processes are running in parallel?  Thanks so much for everyone's help.

0 Kudos
Message 7 of 13
(4,087 Views)
I'm sorry, I know you are asking Crossrulz, but if you observe the link I showed you with the producer consumer pattern, you can see an example of parallel loops. There is a lot of information about its functioning but if you need more help just ask.

Regards.
Message 8 of 13
(4,073 Views)
What sort of connection do you have to this and other instruments? Some, such as GPIB, are sequential so placing the poll in your event timeout case would work just as well and would be simpler to implement.
Message 9 of 13
(4,066 Views)

@hobby1 wrote:

Crossrulz, can you provide example code in where two processes are running in parallel?  Thanks so much for everyone's help.


Almost all of my applications have multiple loops.  But for the sake of examples, follow the link already given for the Producer/Consumer.  You might also want to do a search for Queued Message Handler (QMH).


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 10 of 13
(4,030 Views)