LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to create file

Solved!
Go to solution

Hello

 

I am trying to add a data logging module into a VI that is running ok. But no matter what I try, the data is not stored into the selected file. I'm adding a screenshot of the block diagram.

The problem seems to be that Labview is unable to create a file. When I add no file path, the user should be prompted where to save the file, but this never happens. When I add a path/filename, Labview seems to ignore this. Regardless if the file already exists or it should be created by Labview, the file is not created/saved.

 

The errors I already encountered: 

- Error 7 - File not found: when I add a path to the "create file" block

- Error 43 - The operation was cancelled by the user (which is not true, as the user is never asked where to save the file): when I add no path to the "create file" block

 

Note: the image below is part of a larger VI: it is in a flat sequence.

Note 2: I'm running LabView 2012, with realtime module.

Note 3: the rest of the program is running well, we are measuring data without problems, but nothing is being logged.

 

Thanks in advance.

0 Kudos
Message 1 of 14
(4,638 Views)

Note 2: I'm running LabView 2012, with realtime module

 

Are you running this on a Real Time target?

if so, (a) RTs don't have a UI so couldn't show a dialog box and (b) does your RT target have a C drive?

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

Thanks for the reply. 

We are communicating with an ethernet device (CompactRIO). The project and VI's however are stored and running on a pc. So as far as I understand the RT thing, we are not running the VI on the CompactRio itself. If I choose to add a dialog box to the "create file" box, I can browse the pc's HD through this dialog box. 

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

Curious. In that case I am as stumped as you. Smiley Frustrated

0 Kudos
Message 4 of 14
(4,604 Views)

Hi,

 

As seen from your code , you are opening the file reference outside the while loop and in the loop you are trying to access the same reference. However , you are not keeping the reference in the shift register, due to which file is not getting created as the reference is not valid for the iterations. Try replacing tunnel with shift register which is carrying the file reference , and then it should work.

 

Let me know if this solves your problem!.

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

Hmmm... not convinced. I'm sure that reading an input to a loop repeatedly just returns the original input value, even without a shift register. But to be sure I tried it... this works for me, no problem, and is essentially what the OP has.

savefile.png

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

The missing shift register can't be the problem, although it is considered better to use that for refnums and the like. For WHILE loops it is not strictly necessary as such a loop will always execute at least once and therefore the refnum AFTER the loop ends will be just as valid as the refnum BEFORE the loop. For FOR loops that can not be true. If the FOR loop executes 0 times (iteration count is specified as 0 or an empty autoindexing array is connected as input) then the refnum AFTER the loop will be always an invalid refnum if no shift register is used for that refnum, since there is no logical dataflow from the input tunnel of the loop to the output tunnel for this refnum.

 

As to the original question: Does the C:\LabVIEW\Data folder already exist on the harddrive?? If it does can you delete the Open/Create File node and place a new one on the diagram?

Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 14
(4,579 Views)

@LV_user1 wrote:

As seen from your code , you are opening the file reference outside the while loop and in the loop you are trying to access the same reference. However , you are not keeping the reference in the shift register, due to which file is not getting created as the reference is not valid for the iterations. Try replacing tunnel with shift register which is carrying the file reference , and then it should work.


That would only matter with a FOR loop.  In this case, that shouldn't matter.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 8 of 14
(4,574 Views)
Solution
Accepted by topic author dieter_i

@dieter_i wrote:

Thanks for the reply. 

We are communicating with an ethernet device (CompactRIO). The project and VI's however are stored and running on a pc. So as far as I understand the RT thing, we are not running the VI on the CompactRio itself. If I choose to add a dialog box to the "create file" box, I can browse the pc's HD through this dialog box. 


Let's go back and think about this.  For this VI, what is it's target?  If it is under the cRIO target, then it is actually running on the cRIO.  At that point, you have no GUI, therefore all prompts are concelled.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 9 of 14
(4,570 Views)

Try to change the opperation constant from create to open or create, and add the access constant to the create node on your block diagram and set it to read/write. Also check that LabView has read write access to the Data folder where you want to create the file. 

0 Kudos
Message 10 of 14
(4,554 Views)