From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading from a text file and storing to an array, keeps returning 0.

Solved!
Go to solution

Hello, I have an application where I need to read Velocity and Angular Velocity from a text file. For this application I am using an NI myRIO and I want to store the text file on the drive on board the myRIO in the tmp folder. I have simplified my application to single out the possible problem and I will attach an example of the text file and my VI's used.

 

Overview:

I am using  a myRIO project because in my actual application I have myRIO VI's like PWM and Encoder. I have noticed that my problem disappears when just opening the Main VI and running the application on LabView. My problem presides when having the following VI's in a myRIO project folder.

 

To address the issue:

My issue is, when running the Main VI from a myRIO project folder everything runs as supposed to, but upon opening the text file in my SubVI it return 0, as if nothing is in the text file. Now if I open the VI outside the myRIO project folder by itself it runs just as supposed to, when X = 1, it opens the text file writes the data to an array and then closes the text file. I can't figure out why it reads nothing from the text file when running the main VI from a myRIO project and when I use the highlight execution one can see it opens the text file and then returns nothing. The text file "test" must be placed in the tmp folder on board the myRIO to validate my path.

 

Is there a way to fix this issue?

I have to presume because I am using a myRIO project I can't access the text file, or because of how LabView works?

Any help is appreciated, Thanks in advance!

Download All
0 Kudos
Message 1 of 3
(3,073 Views)
Solution
Accepted by topic author Ciscor.igvc

You don't have your error wires wired up.  Are you file functions showing any errors?

 

What context are you running the VI when you are within the project, and what context from outside the project?

 

My suspicion is that in one case, you are running it on your PC, in the other on the cRIO.  Your file only exists on one device or the other.  And also that when you change from your PC to the cRIO, your file path needs to change.  It is very odd that your VI shows you accessing the R:\ drive.  I bet the R:\ drive doesn not exist on your cRIO.

0 Kudos
Message 2 of 3
(3,059 Views)

Thank you very much for responding. I spent so much time thinking I was wiring somthing wrong I overlooked the path I was calling from. Your comment on the /R drive really answered my question. That path, /R/tmp/test.txt is on my PC, the /R is a mapped drive to the cRIO hard drive. So in order to fix my problem, I had to use the path to the file on board, or simply, /tmp/test.txt.

0 Kudos
Message 3 of 3
(3,025 Views)