LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Save a timestamp to a array

Solved!
Go to solution

I have an array of 9 elements. One of the element is a timestamp. Each row requires a timesamp. I'm displaying the data on a matrix. I'm not sure if how I can display the timestamp, if I can at all. 7 of the elements are numbers. In the VI attached I used a random number generator to create these values but those values represent analog voltages that will be read from a DAQ device. The other element is a "User Input", which in the attached VI is a number but I would like it if I can have that as a text. I had the "User Input" as a text control before that is why I used the string functions in the VI but I run into the problem of displaying the text in the array (matrix).

 

I have attached the VI. Below is what I would like the table to look like. I used a matrix in the VI but anything that displays and the data will work.

 

User_Input     Timestamp    Value_1    Value_2    Value_3    Value_4    Value_5    Value_6    Value_7

TEXT              TIME              NUMER     NUMER     NUMER     NUMER     NUMER     NUMER     NUMER

0 Kudos
Message 1 of 10
(9,362 Views)

look at the string pallette, all kinds of goodies there including number/string conversion.vi's, while using build array....

Example_VI.png

 

0 Kudos
Message 2 of 10
(9,353 Views)

An array will only hold elements of the same type, i.e. I32, U16, Dbl, text or timestamps. To mix different types you can use a "cluster", which is an element that can contain values of different types. Then your array can be an array of this type of cluster. If the "Value_x" you are showing may be of unknown length then you can have the cluster contain "Text", "Timestamp" and Array of "Value" elements, the cluster then being subsequently used in an array of these clusters.

 

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



Message 3 of 10
(9,350 Views)

I tried to build an cluster using the User Field, Timestamp and the numberic elements. I get an error when doing this saying that "The type of the source is 1-D array of double [64-bit real (~15 digit precision)]. The type of the sink is string." I have attached the VI. Can I just build a cluster using different types of elements?

0 Kudos
Message 4 of 10
(9,340 Views)

@ashifulk wrote:

 I have attached the VI.


 

????

 

0 Kudos
Message 5 of 10
(9,337 Views)

Sorry I thought I attached the VI.

0 Kudos
Message 6 of 10
(9,333 Views)

WriteToTable[1].png

0 Kudos
Message 7 of 10
(9,317 Views)

What you want to do is create a cluster consisting of your string, timestamp and 7 values. Create an array of clusters that you can then iterate over and write to disk.

 

Save a timestamp to an array.png

0 Kudos
Message 8 of 10
(9,307 Views)

Thank you for the replies. I can write the data to a file but my question is about displaying it on the front panel. The cluster works but I do have a question. In my actual application I will have a "RUN" button that the user will press when they want to take data. What I need to do is write the data to a text file AND display it on the front panel. The display on the front panel should update the chart/matrix/cluster will new values everytime the user hits the "RUN" button. Is there a way I can do this using the cluster method? I need the display on the front panel to update with new rows while keeping the old rows. I attached a VI that I'm currently working on.

 

Below is how the program should work:

User hits "RUN" button --> Program takes 7 analog voltage measurements, creates a timestamp and saves the values along with the "USER INPUT" field to a text file and display the new values on the Front Panel. --> Program waits for the user to hit the "RUN" button or "STOP" button to stop the program.

0 Kudos
Message 9 of 10
(9,299 Views)
Solution
Accepted by topic author ashifulk

Good job trying to work this out. I can tell you are experimenting with the different functions.

 

Suggestions:

 

    1. Try not to use the sequence structure unless absolutely necessary. You will have problems as your code becomes more complex.
    2. For UI development, learn about the Event structure. Using a Boolean and a Wait next multiple consumes processor time.
    3. Learn about shift registers. These work along with the Event structure and While Loop to make for clean stand alone measurement VIs.

See my attached VI (LV 2012) . I use the same cluster, a While Loop, an Event Structure and a shift register to collect data from the operator using the Record button. When the Stop button is pressed, the same While loop I gave before converts the array of clusters to a string and writes the results to a file.

 

 

 

 

 

Message 10 of 10
(9,277 Views)