LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Open/Create/Replace file Problem

I seem to be getting strange errors from my VI. I have a relatively large program and the parts involving the error also includes the DAQmx. My program crashes and if I follow the error traces it leads back DAQmx Stop Task:

 

Error Code: -50550
Source: DAQmx Stop Task.vi:3 Task Name: AllAI
Description: Error -50550 occurred at DAQmx Stop Task.vi:3 Possible reason(s): A synchronization object was not acquired within the time limit. The operation could not be completed as specified. Task Name: AllAI

 
I'm not doing any synchronization so I found this very wierd. After a bit of debugging, I found before this error occurs the Open/Create/Replace File VI turns a perfectly valid file path into an empty refnum and I get a pop up asking for another location to save my file. If I hit cancel, theres an error message and if I select an actual file, my program crashes with the above error.
I'm guessing that the reason theres a syncronization time out is because of the the file dialog and the timing issues related to the delay it causes. This happens sporadically: I'm saving multiple files each time I run the program and sometimes it happens at the 4th file, sometimes it happens at the 40th file. The files don't actually exist, they have to be created by the Open/Create/Replace File.
23042iF2F8DDFD4D387C22
0 Kudos
Message 1 of 14
(4,816 Views)

All I can see if four local variables when there should be none. If the rest of your program uses the same programming style, you could very well have race conditions. You can do a search and find a very recent thread on locals and when they should and should not be used.

 

Post your actual program if you need help with using proper dataflow.

0 Kudos
Message 2 of 14
(4,799 Views)

I have a large case structure and both cases need the same variables, so I couldn't see a way around it.

 

I attached the file. I've tried looking for race conditions before, but I'll go through it again just to make sure. I guess I could've lined up all the variables outside one edge of the case structure and wired the variables into the case structure from outside.

0 Kudos
Message 3 of 14
(4,785 Views)

OMG!!!! Smiley Surprised  Have you ever heard of a state machine?  You desparately need one.  Please study the example on state machines and re-write your entire vi using one.  This is a monstrosity full of race conditions.  Way too many locals.  All of those case structures running in parallel is sure to cause a gigantic mess.  Use a state machine with an event structure to capture the boolean button events.

- tbob

Inventor of the WORM Global
Message 4 of 14
(4,770 Views)

I agree. It would just take too much time to try to understand that code.

 

One thing I do not understand is all of those case statements. They can only run once and only with values you set before clicking the run button. They are not inside any loop. I would hope you are not doing anything like using the run continuous button.

0 Kudos
Message 5 of 14
(4,755 Views)

I remember someone showing my a state machine example but I ignored it. I didn't write this program all at once, it was developped over years. Code was added whenever someone wanted something new.

 

I'll try to go through the forums to find examples of state machines. If you know a good example for beginners, or a type of example suitable for what I'm doing, I would appreciate a link!

 

Thanks

0 Kudos
Message 6 of 14
(4,754 Views)

I don't have DAQmx installed on this PC, so I would have to guess that the error message is from

DAQmx Stop Task.vi or DAQmx Clear Task.

 

You have a lot of parallelism in your code and it does not follow dataflow.  As  Dennis mentionned, you may (probably do) have race conditions, componded by the use of Locals instead of routing the values by wires (which are variables in LabVIEW). 

 

The code should be written in such a way that it takes one single screen to look at it.  

There are many items to recommend to simplify the debug of the code; however, I strongly suggest you look at using a State Machine for your code.

 

The code has many terminals at the left which are unwired.  That is not the coding approach to LabVIEW.  It is not like a text-based language where you declare variables and use them by name in the code.  In LabVIEW, the wire is the variable, so if you use Local Variables, it may create additional instances of the same data, which usually results in a race condition.

 

As for the error that you are obtaining, you can use probes to check the error status along the wire after functions that precede where you spotted the error.

Message 7 of 14
(4,739 Views)

You can use the Search button and enter "State Machine".

 

You'll find hundreds of examples.

 

THe forum is having problems with tags 😞  I had tags to examples that I created... If I have time, I will hunt for them.

 

To learn more about LabVIEW, I suggest you try looking at some of these tutorials.

Message 8 of 14
(4,733 Views)

Attached is an example of a state machine with an event structure.  This is what you need.  Create an event for each button.  Inside each event, add a string constant for the state you wish to execute.  In each state, the next state will be the events state to wait for another button press.  That is unless you want one state to call another state to finish some code.

 

The vi is in LV2009.

- tbob

Inventor of the WORM Global
Message 9 of 14
(4,717 Views)

But getting back to the original problem:

When you have a duplicate filename a dialog will come up that will cause a DAQmx error, am I correct?

 

If so use a temporary file name generator, there's on available with recent versions of LabVIEW, or you could install the OpenG file toolkit. When you are done acquiring, you can rename the temporary filename into the target (official) filename.

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 10 of 14
(4,708 Views)