LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

best practices for mutilple while loops


@mysticfree wrote:

Upon further research, I found that NI-9425 for our CDAQ chassis does not support change detection since it is software-timed.  ARRGGG!  This project has been nothing but a series of kick-in-crotches.


Sorry to lead you down the wrong path. 

 

Going back to you earlier posts, create the task outside the loop, read inside the loop, close and clear task outside the loop. There is some weird effects with creating and clearing lots of tasks, do not recommend doing it.

 

mcduff 

Message 11 of 17
(186 Views)

Thank you, mcduff.  Very good point!

0 Kudos
Message 12 of 17
(171 Views)

In the cDAQ, we're using a NI-9476 module.  The digital outputs are grouped to control similar hardware in each of the 4 fixtures.

 

I'm thinking I need to make the execution of VI that deals directly with the 9476 as "shared clone reentrant".  This way a calling VI will create the 9476 VI, run the desired function, and clear memory.  However, since the program will have 4 similar fixture VIs calling the same 9476 VI, will this cause conflicts controlling the ni-9476?

 

If my understanding is correct, if the 9476 VI is non-reentrant, each call to it will have to wait until the previous call is has completed, yes?

 

 

0 Kudos
Message 13 of 17
(147 Views)

Can’t help much, never used that module or did a whole lot with digital tasks.

 

If the 9476 can run different tasks concurrently then you make a reentrant vi without too much hassles. Since the device is software timed it might be possible. I could not tell anything from a quick look at the specs. 

you are correct with your interpretation about non-reentrant.

 

mcduff

0 Kudos
Message 14 of 17
(131 Views)

 

Going back to you earlier posts, create the task outside the loop, read inside the loop, close and clear task outside the loop. There is some weird effects with creating and clearing lots of tasks, do not recommend doing it.

 


Today I had a chance to move create and clear tasks outside of the loop.  Unfortunately, it errored.  I tried creating a task name in Ni-Max but the loop errored as well.

create and clear task doesn't work.vi .png

0 Kudos
Message 15 of 17
(104 Views)

The start should be outside the loop also. You are trying to start the same task again and again.

 

I don't have experience with software timed loops but you are having that loop spin as fast as possible, you may want to consider putting at least a 0 ms wait in the loop. This will prevent your other loops from starving.

 

mcduff

0 Kudos
Message 16 of 17
(100 Views)

Looking good,
Personally, I'd make the whole acquisitions module re-entrant and replace the FGV with a single element Queue,
Enq the data in the loop (by name) and dequeue by name for your different modules
Then the only thing you need to change between the 4 re-entrant VIs (Pre-allocate clone) is :

1) the DAQ name (as all the channels are the same and so the channel can be appended to create the task) 

2) the Queue name

- removes the FGV common to all VIs and scales accross 1-N systems

(you do need to consider the stop)

CLD; LabVIEW since 8.0, Currently have LabVIEW 2012 - 2016 installed
0 Kudos
Message 17 of 17
(75 Views)