LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read from a file on realtime basis with time stamp

Hi,
I want to read from a .txt file having two columns separated using tab delimiter on a real time basis. I am trying to buld a temp data logger. Also I have multiple senors to take input from. I need to have a select button on front panel and want the graph to be displayed for that senor only. I have around 20 temp sensors. I need to select which temp sensor graph is currently displayed . please help!!! Also how can i attach a file to the messages I post here!!! Any help would be greatly appreciated..

Thanks in advance

Ratnesh
0 Kudos
Message 1 of 16
(4,053 Views)
To attach both a vi and a data file, simply embed them in a zip archive.
I am not sure that I understand your question : what do you mean by reading a file on a real-time basis ? Real-time means processing the data immediately, at the moment of the event. If you are reading data from a file, that means usually that you are doing off-line analysis. However, some specific situations do exist, for instance if you want to display data acquired (and stored...) by a third-party application.
Nevertheless, the attached vi shows how to read, and display as a XY graph, data from an array where the first column (column 0) contains the X data, and the other colums (from 1 to ?) the Y data.
Hope this helps.

CC
Chilly Charly    (aka CC)
Message 2 of 16
(4,028 Views)
Hey CC,
Thanks very much. I appreciate your time and efforts!! I need to find a solution for 'n' sensors XY graph display. I want the front panel to show me an option for 'n' different sensors (n may be <20) which is selectable(may be using a check mark or similar). I have 'n' different files for 'n' different sensors. After selecting the particular sensors on front panel(using check mark or similar), it should display graph only for those sensors(this can be multiple plots on same XY graph or different graphs for each sensor). Is there a way out in which I can display graph for only those sensors which are selected(may be using a check mark or similar). Also is it possible to set the time interval at which 'each' value is read from the file. (FYI: The second value in my file represents a time stamp in military time format).

Thanks very much,

Ratnesh
0 Kudos
Message 3 of 16
(4,015 Views)
I'm thinking it is easier to one XY graph per sensor.
Use a boolean control to control visibility of each XY graph.
But 20 is a lot of graphs on one front panel.

If the y-axis data is approximately the same for all 20 sensors that
you might be able to have 4 or 5 XY graphs and
use boolean controls to control visibility of each plot in the graphs.
0 Kudos
Message 4 of 16
(4,005 Views)
Having a different file for each sensor is not a comfortable situation. I suppose that it is the only/best solution you had to store the data ?

Anyway, the attached vi is one solution to your kind of problem. Before running it, you need to do 2 things :
1/ modify the vi in order to be able to read properly the data. As it is, it reads only files where the first column contain the Xs and the second the Ys. Since you didn't provide an example of your data file, this is the best I could achieve.
2/ enter the locations of the various data file that you have to read in the patnname array.

Hope this helps...

CC
Chilly Charly    (aka CC)
Message 5 of 16
(3,992 Views)
Hey CC
You ve been of great help to me. I appreciate all your time and efforts. I was going thru the VI that you sent over.
a) I am unable to figure out how did you get the stack of buttons on the left hand of the front panel. Also I m not sure how things are working here in the VI.

I am attaching my files for your reference. Also I need to flash a 'text message' (as given in example file - Temperature System.llb) when the temperature overshoots or is under specified temp. Please ignore all other(like histogram, display current temp on thermometer style) functionalities given in this VI(Temperature System.llb).

b) I need to have a scroll bar so that I can see the history for the temperature sensors as and when required.

c) Is there any way out where I can delay the reading of each value from the file(like put a timer/delay for each value being read from file). I plan to have a single file for all the temperature sensors. The first column being time stamp and all other columns designating each temp sensor reading. I need to read data continously from file.

d) Do I use case statement for this project or the approach you gave would work for different sensors. I believe my CASE statement is not working properly.

e) Can I contact you on your personal email id if thats ok with you. Please let me know.
Thanks very much,
Ratnesh


PS: I am pretty new to LabVIEW (say around a month) and would like to venture into this field. People like you encourage me to do so..
0 Kudos
Message 6 of 16
(3,990 Views)
Hey CC
You ve been of great help to me. I appreciate all your time and efforts. I was going thru the VI that you sent over.
a) I am unable to figure out how did you get the stack of buttons on the left hand of the front panel. Also I m not sure how things are working here in the VI.

I am attaching my files for your reference. Also I need to flash a 'text message' (as given in example file - Temperature System.llb) when the temperature overshoots or is under specified temp. Please ignore all other(like histogram, display current temp on thermometer style) functionalities given in this VI(Temperature System.llb).

b) I need to have a scroll bar so that I can see the history for the temperature sensors as and when required.

c) Is there any way out where I can delay the reading of each value from the file(like put a timer/delay for each value being read from file). I plan to have a single file for all the temperature sensors. The first column being time stamp and all other columns designating each temp sensor reading. I need to read data continously from file.

d) Do I use case statement for this project or the approach you gave would work for different sensors. I believe my CASE statement is not working properly.

e) Can I contact you on your personal email id if thats ok with you. Please let me know.
Thanks very much,
Ratnesh


PS: I am pretty new to LabVIEW (say around a month) and would like to venture into this field. People like you encourage me to do so..
0 Kudos
Message 7 of 16
(3,987 Views)
The stack of buttons is simply an ARRAY of boolean controls.

Your approach with multiple cases is a dead end. Forget it when the number of cases is larger that a few.

After a look to your data file, I have a few questions/comments:
1/ Is there any reason not to process the data BEFORE storing them in a file ? That is to say in a REAL real time basis ?
2/ instead of using the military time format, which requires some preprocessing before storage, and some post processing for reading the data, why don't you use a more convenient format ?
3/ There are five columns. Are columns 4 and 5 for sensors 3 and 4 ?
4/ The temperature data seem to vary a lot within only 20 secs. Is this normal ? Or is this the result of strong noise ?

Attached is a vi which show how to read sensor 1 against time. I think you will succeed in embedding it in my previous vi. If not, that means simply that you really have to spend more time studying LabVIEW basic programming techniques. You are lucky there since a/ you have a project, b/ you found NI forum to get answers to your questions 🙂

Happy new year (christian time format) 😄

CC
Chilly Charly    (aka CC)
0 Kudos
Message 8 of 16
(3,969 Views)
Hi CC,
Thanks once again for the reply.

a) The data file that I sent you is a hypothetical file and the temp. doesnt change greatly in actual data log file. Do you say ' Is there any reason not to process the data BEFORE storing them in a file ?' because temperature shows large variations in value within short span of 20 seconds or do you mean something else?

b) I plan to use LabVIEW time format (number of seconds elapsed after Jan 1904) Do you have any suggestions about this?

c) The values in column 4 & 5 represent temp. sensors 3 & 4 values


Also, for your previous VI , I am unable to understand how VI is working. What does the digit(0 1 2 3...) selection mean in Active sensor field and 'sensor file' field do. I understand the different boolean buttons are for different sensors and the prestn graph for a particular sensor is displayed only when boolean button turns green. Do I have a right understanding about this? Also how do I mention how many sensors I have here in the VI. Also it asks me for a file to read from everytime I press the boolean button for different sensors. Even when I put them OFF they ask for file to read from. I am confused with that.
I guess now that I dont use military time stamp , I would not require your second file that you posted(get Sensor data.vi) If you could please brief me about how your VI works that would be really good.
I am workin towards making my programming knowledge in LabVIEW better. I believe I shall be soon able to interpret things in a better way!!!


Merry Christmas and A vry happy new year..


Ratnesh
0 Kudos
Message 9 of 16
(3,965 Views)

qhunter wrote :
Also, for your previous VI , I am unable to understand how VI is working. What does the digit(0 1 2 3...) selection mean in Active sensor field and 'sensor file' field do. I understand the different boolean buttons are for different sensors and the prestn graph for a particular sensor is displayed only when boolean button turns green. Do I have a right understanding about this? Also how do I mention how many sensors I have here in the VI. Also it asks me for a file to read from everytime I press the boolean button for different sensors. Even when I put them OFF they ask for file to read from. I am confused with that.
I guess now that I dont use military time stamp , I would not require your second file that you posted(get Sensor data.vi)



a/ What I mean is that I don't understand why you should read the data in a file, isntead of plotting them directly from the sensor readings (I'm referring to the subject of your question : real time).
b/ a single comment : if you were told that an event occured at 16 892 354 s, I am not sure that this will be meaningfull to you...
c/ OK

My previous vi was built according to the informations you gave me : you had a different file for each sensor. Before using it, I told you that you had to "enter the locations of the various data file that you have to read in the pathname array". Of course, if you don't do that, the vi will ask you for a file name each time you change the value of the boolean array.
Multisensor.vi is rather staighforward : it uses an event structure, and a change in the boolean array (Active sensor) triggers a redraw of the graph. For each "true" position, the corresponding file is read from the "Sensor file" array, and the X and Y values are plotted. That's all.

Now the situation has changed, since you plan to store your data in a single array. I think my first vi will help you to build the graph from a multicolumn file.

CC
Chilly Charly    (aka CC)
Message 10 of 16
(3,960 Views)