LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

while loop halted

Hello Folk,

 

I am developing an application which acquires data at 1 ms and store it to TDMS file. I have two seperate loop for acquisition and data writing. I set starting of acquisition on trigger pulse so while loop halts untill my system is triggered  and resume on trigger pulse. Now that writing into TDMS file is slower than acquisition, I queue acquired data and dequeue it in another loop.

 

Here my problem comes, 

 

As of faster acquisiton, for 600 seconds data acquisition my file is written with only 195 seconds data. The rest of data is in queue. As soon as the stop trigger comes my acquisition loop halts and with it my writing loop halts too. It is not being possible for me to write another 405 seconds data in to file though my program is running. 

 

Is there any way that my writing loop never halts? I havenot configure anything for my writing loop to halt however the dequeue reference of my writing loop is the same as queue reference of acquistion loop.

 

Your help will be truly appreciated.

 

Thank you,

CLAD
Passionate for LabVIEW
0 Kudos
Message 1 of 10
(2,902 Views)

We probably need to see some code. Are you killing the queue reference when the producer loop stops?

0 Kudos
Message 2 of 10
(2,898 Views)

 

No I am not killing queue reference neither does my loop stops, It is just my while loop halts upon stop trigger. 

 

I have attached a image with part of code.

PS the code is in RT target. 

 

Thanks for your concern, 

CLAD
Passionate for LabVIEW
0 Kudos
Message 3 of 10
(2,878 Views)

Hi!

Are you sure your Writing loop is stopped while still having elements in the queue?

Apparently there's no way to exit from either of the while loops in your code...

 

One more question: why did you use a timed loop for acquisition?

 

Regards,

Marco

0 Kudos
Message 4 of 10
(2,856 Views)

Several things to consider:

- Without seeing the complete code (VI), we can only guess about things

- You use nested case structures which rely on shared variables to enqueue data. I doubt that you enqueue the amount of data you *think* you enqueue

- Have you ever checked the iterators for the loops? For the enqueuer, you should create a custom iterator to count the enqueues you are performing (seems that you are already counting this, but not "using" it)

- Which "packages" are "missing"? Only the latest? Some "in between"?

- Why do you use a timed loop as producer?

- Why are both loops running without the option to stop? Is that a program running on RT, please learn how to desing code for RT.... (as your code is obviously not designed for RT)

- Why all those sequence structures? Please remove them

 

 

All in all, i currently assume that the VI is working "perfect" as it only does what your code tells it to do. If that is the same that you *want* it to do.....is the question.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 5 of 10
(2,821 Views)

Hello,

 

I designed this code for RT and that is why I used timed loop and dint put any condition to stop the loop. I m not sure am I right or not on this.

Answers to your other questions are below,

Only latest packages are missing and I removed that sequence. 

 

Can you please put some more sense into me for well designed RT code?? 

 

One more thing I would like to ask is there any way to write the data faster,? I meant as soon as the data queued up it should be written into file. 


@Norbert_B wrote:

Several things to consider:

- Without seeing the complete code (VI), we can only guess about things

- You use nested case structures which rely on shared variables to enqueue data. I doubt that you enqueue the amount of data you *think* you enqueue

- Have you ever checked the iterators for the loops? For the enqueuer, you should create a custom iterator to count the enqueues you are performing (seems that you are already counting this, but not "using" it)

- Which "packages" are "missing"? Only the latest? Some "in between"?

- Why do you use a timed loop as producer?

- Why are both loops running without the option to stop? Is that a program running on RT, please learn how to desing code for RT.... (as your code is obviously not designed for RT)

- Why all those sequence structures? Please remove them

 

 

All in all, i currently assume that the VI is working "perfect" as it only does what your code tells it to do. If that is the same that you *want* it to do.....is the question.

 

Norbert



@Norbert_B wrote:

Several things to consider:

- Without seeing the complete code (VI), we can only guess about things

- You use nested case structures which rely on shared variables to enqueue data. I doubt that you enqueue the amount of data you *think* you enqueue

- Have you ever checked the iterators for the loops? For the enqueuer, you should create a custom iterator to count the enqueues you are performing (seems that you are already counting this, but not "using" it)

- Which "packages" are "missing"? Only the latest? Some "in between"?

- Why do you use a timed loop as producer?

- Why are both loops running without the option to stop? Is that a program running on RT, please learn how to desing code for RT.... (as your code is obviously not designed for RT)

- Why all those sequence structures? Please remove them

 

 

All in all, i currently assume that the VI is working "perfect" as it only does what your code tells it to do. If that is the same that you *want* it to do.....is the question.

 

Norbert




 

Thanks for your concern

CLAD
Passionate for LabVIEW
0 Kudos
Message 6 of 10
(2,765 Views)

jatinpatel1489@gmail.com wrote:
[...]Can you please put some more sense into me for well designed RT code?? [...]

Have you attended some RT classes at NI? This is one option to learn more about differences between Windows and RT programming in LV.

As said, without seeing the complete VI, we can only comment on the segment of code we see in your screenshot.....

 

First obvious no-go for RT you have in the code: Repeated memory (re)allocation.

Most prominent location for this is the queue. Rule of thumb: Never use a queue on RT, always use RT FIFOs.

Another location can be (does not need though) the obvious overuse of local variables with the option of "Read". These create copies of the dataset, so it will introduce jitter.

 

Second, the timed loop is not prioritized properly. Leaving the priority at defaulted 100 is not recommended as it might conflict with other timed structures sharing that priority level. Rule of thumb: Each structure has its unique priority level (between 1 and 65535).

 

Third, timed structure and hardware io can conflict. In the displayed code segment, the timed loop is configured for 1kHz. In the first sequence frame (which is btw completely unnecessary) you read 1000 samples. So this code makes only sense if acquisition rate of the 6259 (?) is greater than 100kHz, otherwise, your DAQmx code messes up the timed loop.

 

There are still some other minor issues (besides style guides like improvable wiring and subVI icons), but these are really the top three major issues regarding RT of that code. Remember that we only see a segment, so your application might contain many more segments not compliant to RT (which endangers determinism).


Please note that i give you that feedback in order that you can improve your knowledge and skills esp. regarding RT programming; so i am not "bashing" you 😉

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 7 of 10
(2,743 Views)

No, I dint attended RT classes at NI.

 

Through your explaination I do not need to use timed while loop, only while loop is sufficient. 

 

However, using RT FIFOs do not suffice my requirement or may be I was not using it properly. 

 

I replaced create queue, enqueue and dequeue with create fifo, write fifo and read fifo respectively. In this style I would be able to read only one data from read fifo instead it should give the entire 1000 element array. I even tried giving  array value to read fifo input but it doesnt work. 

 

Can you please tell me what more should I work with this code ?

 

P.S

 

Thanks for nice explaination 

CLAD
Passionate for LabVIEW
0 Kudos
Message 8 of 10
(2,704 Views)

As stated, without more code, more recommendations are hard to give...

 

Regarding your FIFO issue:

Please check the input parameters of the Create FIFO function...esp the ones on the top.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 9 of 10
(2,701 Views)

Hello Nobert_B,

 

Sorry for taking a long to put more code. It  was due to following company policy.
I can only put a whole RT VI sniipet here with. 

 

thanks,

 

 

CLAD
Passionate for LabVIEW
0 Kudos
Message 10 of 10
(2,635 Views)