LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble with "first call" vi in Labview 7.1

Hello there,

I'm using Labview and DAQmx 7.3 in order to acquire 6 analog signals, this works fine, but i have still some troubles when i call my vi the first time: I am using the "First call" Vi to initialize my task and to start it ; but when i run it the first call doesn't work properly, it stays at false so i have an error -200278 because i try to access to samples that are not yet acquired. This appears when i call my vi(ACQ.vi) from a while loop in another vi (Test.vi), in the contrary when a call directly my vi(ACQ.vi) from the run button in labview the first call is detected. Strange isn't it?

Somebody have an idea ??

Thank you in advance !!

EricFinns

I keep searching :))
0 Kudos
Message 1 of 9
(2,826 Views)
Can you post your vi's so that we can try and see the problem?


Thanks,

Putnam Monroe
Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 2 of 9
(2,816 Views)
Sounds like you're opening it reference in the case where it's not working correctly. Sometime opening VIs by reference can have unexpected results. Things like the "Run When Opened" property will not actually work if yo ujust use VI Server to open the front panel.

If you can post your VI, or a small example of the problem it would be helpful.

Ed


Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 3 of 9
(2,806 Views)
Ok Thank you both for you replies.

It seems like the vi "First Call" is not the cause of my troubles, sorry, i was'nt handling the error properly, It looks like it is an error in my initialization, but i don't know where if somebody is able to help me it will be great. I will post the two VIs : TEST.vi and ACQ.vi with this message. It is the .zip file 3 files inside.

The error is still -200278. This appears when i execute my ACQ.vi the first time after that it is working fine.

thank you for your help

EricFinns
0 Kudos
Message 4 of 9
(2,804 Views)
The error explaination for that error number is;

"Attempted to read a sample beyond the final sample acquired. The acquisition has stopped, therefore the sample specified by the combination of position and offset will never be available.

Specify a position and offset which selects a sample up to, but not beyond, the final sample acquired. The final sample acquired can be determined by querying the total samples acquired after an acquisition has stopped."

It looks like what is happening is the first time you run this there is not yet 10 samples to read. And with a 10ms timeout on the Read VI, it doesn't have enough time to allow more samples to be read.

Easy solution is to increase the timeout value on the Read VI. Better solution is to use a DAQmx Read property node to get the available samples. When this is 10 or more, then do your read.

Ed


Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
Message 5 of 9
(2,794 Views)
Hello Ed,

I will try that, but i am pretty sure it is the solution.
I will post the result of the modification.

Thank you,

EricFinns
0 Kudos
Message 6 of 9
(2,777 Views)
Hello,

Thank you again Ed for your help, I have tried your solutions yesterday, but unfortunaly it was not the time out. So i have still the error.
I have used a for loop to see if the error occurs during the first call, and in fact the error occurs during the second one. But i have no idea why.
To make it works : i start, stop and free the memory each time that i call the vi, and it works fine. Maybe it is not really a good use of the DAQmx, because i am initializing the acquisition each time that i call the vi and that consume CPU time.
I would like to initialize it only one time at the first call, I guess this is a better idea, is'nt it ? And at the end the memory will be free automatically because the vi is encapsulated in a DLL generate with the application builder of Labview and desalocated at the end of the program, so the task is freed... no ???? 😕

If anybody have an idea why a get this error (-200278) i am still interrested, thank a lot !!!

EricFinns
0 Kudos
Message 7 of 9
(2,752 Views)
EricFinns,

I tried your example VI, and have a theory about what is happening. DAQmx will attempt to be fairly smart about how it how it controls state transitions within a task. In your ACQ.vi, you explicitly start the task on the 1st run. After it is read, the task is not stopped. The next time that the task is called, it has not been stopped from the last run, however since it is a finite acquisition, and all available samples were read in the last call, you see the error. Once the error occurs, the task is stopped and unreserved. Since start is not called again, executing the read call will auto-start the task, which automatically stops the task once read is complete. As such I believe you read successfully on your 1st call. Error the 2nd call, and run successfully thereafter. This leaves you with several options. First option is never to start the task, and let DAQmx do that for you behind the scenes. This is an easy implementation which should resolve the error you receive. However, it means that the driver will automatically transition through all of the task's states each time your sub-vi is called. The second option, which I have attached is as follows. On the first call only, configure the task, and explicitly transition it into the committed state. Then start the task, read your channels, and stop the task. This should prevent you from receiving the error you are seeing, as well as stop DAQmx from performing unnecessary state transitions on the task.

Hope this helps,
Dan
Message 8 of 9
(2,733 Views)
Thank you Dan,

I will try your solution and let you know if it is the solution to my trouble. And thanks a lot for example file !!

Regards,

EricFinns
0 Kudos
Message 9 of 9
(2,713 Views)