ni.com is currently experiencing unexpected issues.

Some services may be unavailable at this time.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to read two files (one is updating every second, the other is constant) simoltaneously

Solved!
Go to solution

Dear All,

I will appreciate if somebody help me.

 

I want to read two files, one is temperature wich is updating every second, and the other is hysteresis energy which has specific rows and is constant.

 

I got a program in discussion forum which read a file as it is updating. I checked this program in my case and it works.

 

Then I added reading hysteresis energy file to the existing file. But while i am running the program, the hysteresis energy file is read with all rows.

But the aim is that everytime which temperature updates, I need to read just one row of the hysteresis energy file.

so, in this way in every second i have a new temperature data and one row of the other file.

 

I tried to used "for loop" inside the program, but it did not work, becuase reading temperature will be stopped untill for loop ends.

 

I attached the program.

 

Could somebody help me how to read just one row of hysteresis energy file everytime temperature updates?

0 Kudos
Message 1 of 9
(3,991 Views)

I do not understand relationship between your two files.

You have another VI or app that is writing data to both files and when new temperature data added you wish just to read the new data and then read one new line of the hysteresis file?????

But is one is constant, why do you need to keep reading it?

 

Anyway…

 

The “Read From Spreadsheet File.vi” preformed an Open and a Close for each time it is called (if you will open the VI up and drill down and you will see). So that resets the file pointer back to the beginning and there for will read in the whole file from the first to the last each time if you do not set the start of read offset or number of rows.

 

Now the Read from Binary File does not reset the file pointer and leaves the file pointer just past the last byte read so it will start with any new bytes automaicly only giving you the new data.

I do not think you need to do the math with the Previous EOF=0 and the File size to get what I think you are trying to do.

 

Plus use shift reg for the Data string instead of local var

Set the mechinacl action of the stop botton to Latched

So you do not need to init the two controls

 

Also, I do not get the End of file encountered error (4) from the Read from Binary file if I attempt to read past. It just returns and empty string.

Omar
0 Kudos
Message 2 of 9
(3,957 Views)

As I'm understanding your comment below what you have is a constant hysterisis translation from temperature to energy file, and then an acquired temperature, and what you want is a lookup to find the appropriate row in the hysterisis file based on the temperature.

 

Apart form the suggestions above, if the hysterisis stays constant - why not load the file outside of the loop?

 

If the assumption above about wanting just a related row is correct, then you need to do some lookups with arrays, and I'm sure there is lots of info out there on how to do that kind of lookup.

0 Kudos
Message 3 of 9
(3,926 Views)

Hi neka,

If your hysteresis energy file has constant rows,you can read file at once,and as your temperature changes you can update data from array.

So, you can use delete array function/Array subset function to take out data from it.

Find attached code.You just need to change logic for increment of shift register.

I hope you will understnad it.

Gaurav k
CLD Certified !!!!!
Do not forget to Mark solution and to give Kudo if problem is solved.
0 Kudos
Message 4 of 9
(3,919 Views)

Dear Omar,

Thank you so much for your help.

I am not professional in labview. I got that program in a discussion forum. 

 

I have the labview 8.6 and could not open your attachment.

I am wondering if you save it as a lower version. If not can you put an image of the file, so i can see it.

 

The thing is for example i have 100 row energy file. every time temperature updates, i need to do calculation of new temperature with for example first row.

then, with a new temperature data i need to work with second energy data, and so on until 100th row.

 

Because I can not open your file, I do not understand how did you change it.

 

Regards,

 

 

 

0 Kudos
Message 5 of 9
(3,904 Views)

Dear Gak,

 

Thank you so much.

 

I have the Labview 8.6 and can not read your file. 

I am wondering you you save it as a lower version or put an image for it.

 

Regards,

 

0 Kudos
Message 6 of 9
(3,900 Views)

Dear freinds,

 

Thanks for your help.

 

Gak helped me to solve one part of my problem. Now, in my program i read temperature which updates and every time reading energy from a constant file.

 

In every second a new temperature data coming to the program, How I can use the updated temperature in the calculation (please see the attached file)?

 

I tried to convert string to number, but the results of temperature in the format of a number is not meaningfull.

 

I am wondering if somebody let me know how i can convert the update temperature data to a number which can be used in the calculation.

 

Regards...

0 Kudos
Message 7 of 9
(3,841 Views)
Solution
Accepted by topic author Neka

IS this what you wanted to achieve?

Gaurav k
CLD Certified !!!!!
Do not forget to Mark solution and to give Kudo if problem is solved.
0 Kudos
Message 8 of 9
(3,812 Views)

Thank you Gak,

 

Yes, I got it.

0 Kudos
Message 9 of 9
(3,779 Views)