LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Parallell Loops and DAQ

I'm having a hard time laying out the architecture to handle some events all simulataneously.  Three things essentially need to be occuring.  There is an event structure coupled with a queued state machine to deal with user interaction.  I need to continuously read values from a modbus device.  And I must continuously read values from analog input sources.

 

The first version of this program is Main Program.vi.  In this version I use only the queued state machine, read one set of values from modbus, then one set from analogs, then store to action engines, and calcluate display, etc.  This resulted in very slow data acquisition, I believe primarily due to the time it takes to initialize and close the devices I am reading data from.

 

Thus, I attempted to write in parellel loops, in which one loop continuously reads data from both sources, stores to action engines, and the other loop is still a queued state machine, reading from the action engines, calculating and displaying data, and dealing with the reporting.  This is the v 1.1.


Currently nothing triggers my update state (still not sure how I should accomplish that portion), however I do not believe I am even getting my DAQ loop to run.  I am hoping there is a better way to deal with these tasks in an efficient manner.

 

 

 

Attached are the VI and subVIs pertenant to this question.  In the main part of the folder, there are two "Main Program" vis, one of which is designated v 1.1

 

0 Kudos
Message 1 of 10
(3,266 Views)

There are some other bugs I am still working out from when I started making architecture changes.  I continue to work on those, however the architecture is the main issue at hand.

0 Kudos
Message 2 of 10
(3,264 Views)

In general you appear to be on a path that should work.  Using parallel loops for the data acquisition is often done.  In your case probably putting the Modbus process and the DAQ process in separate loops may be better.  Then each can run at its own time scale which may be quite different from the other.

 

Your lowest loop will not run until the middle loop finishes because there is data dependency between them.  The boolean from the shift register in the middle loop is an input to the case structures in the bottom loop.  Use a queue or notifier to send the value of that boolean from the middle loop to the lower loop.  If the lower loop is split into two loops, you may need two queues.  (Queues are best used when only read at one place.)

 

I have written programs with several independent loops doing data acquisition or instrument communication and passing the data via queues or Action Engines to the processing loop.

 

Lynn

Message 3 of 10
(3,249 Views)

I am glad to hear that I am at least on the right path.  Notifiers may be the most useful in this situation?  As with other questions I've posted here, I have yet to use notifiers, so perhaps this is the perfect time learn.

 

0 Kudos
Message 4 of 10
(3,236 Views)

Notifiers and queues each have their places.  For sending one boolean to two places the notifier is probably the easiest.

 

Read the detailed help files and look at some of the examples.  It may also be useful to put together some simple test VIs to try different methods until you understand how they work.

 

I just looked at your program again.  You also have a data dependency on the stop boolean.  That needs to be changed also.  There are many postings on the Forum about stopping multiple loops.

 

Lynn

0 Kudos
Message 5 of 10
(3,232 Views)

Well,

 

Here is my first try at notifiers.  Suffice to say they did not change any functionality (or lack thereof).

 

Also attached is my "trial" modbus comm vi.  This one works exactly the way I want it to, but I can't seem to get it to work when in parellel with the others.  Any thoughts would be great.  Also, it seems as if the analog loop acquires one set of data, but does not continue to acquire (I have it set to continuous).

Download All
0 Kudos
Message 6 of 10
(3,214 Views)

Lynn,

 

Can you post an example of DAQ in a parellel loop for me?  Either with notifiers or with action engines.  Any simple example will do, I am missing something.

 

I think it is the data dependency?

0 Kudos
Message 7 of 10
(3,209 Views)

Your program has Action Engines.  AIAE.vi for example.

 

One reason nothing is working is that the Wait on Notification functions have the default timeout set.  The default is -1 which  means never timeout.  That means that they will wait until a notification occurs.  While they are waiting, the loop does not iterate.  You need to set a timeout for a value which relates to how fast you want the loops to run.  If the Notifiers timeout, the notification output will have the default value for the datatype.  For the Stop notifiers the default is False which is OK.  For the DAQ notifiers you may need to test the "timed out?" output and take the appropriate action.  That action may be to do nothing or to continue doing what the loop was doing before.  I did not take time to analyze the whole loop.

 

Lynn

Message 8 of 10
(3,202 Views)

Alright, I got it figured out.  What was happening was both the timeout issue, and my misunderstanding of notifiers.  I was considering them as a "constant" source.


In other words, I made the assumption that by sending a "true" notifier, that the true would remain there until the appropriate state read it.  Obviously not the case, it only gets read once on the next iteration.  Couple of shift registers later, and I am back in business.  Thanks so much Lynn!

0 Kudos
Message 9 of 10
(3,177 Views)

Glad to be able to help.

 

Reading the help files and trying things are good ways to learn.

 

Lynn

0 Kudos
Message 10 of 10
(3,171 Views)