05-14-2016 10:54 AM - edited 05-14-2016 10:55 AM
Hi.
In this project, I would like to write the data for the XY Graph from the time of the X.
And I want to display the several Plot, but when I do more than 3 items, an error occurs.
05-14-2016 11:22 AM - edited 05-14-2016 11:27 AM
You simply need to read the manual. They way you are using it is not even really documented.
You are trying to do this, while you actually need to do this (look at the yellow, upper part of the picture).
(of course there are many other ways to arrange the data (complex, etc.)
(You also should not autoindex on a while loop. Doen't the graph belong inside the loop so you see the data as it is acquired? Sonce your points are spaced equally in time, all you need is a plain graph. Even a chart might be sufficient. Keep it simple!)
05-14-2016 11:35 AM
If you look at the Help for your XY Graph (type Ctrl-H to turn on Help, then hover over the Graph on the Block Diagram), you'll see that each Plot on the Graph is a cluster of two Arrays, the X values and the Y values, and to make multi-plot Graphs, you combine single plot Graphs into an array.
Sometimes it helps to write a simple all-numeric example using random numbers (so you don't have to fiddle with controls). I'll walk you through this one ...
So 10 times a second points are generated. Rather than have my X coordinate be a Date/Time value, I chose to display "Elapsed seconds", which I get by taking the difference between the TimeStamp of point generation (inside the loop) and the TimeStamp when the program started (outside the loop). I'll use the X array for all of my plots, so I just bring it out as an array of X values.
For my Y, I want N=3 plots, all Random Numbers, but offset by the index I, so Plot 0 will be [0,1], Plot 1 will be 1 + [0,1] = [1, 2], and Plot 2 will be [2, 3]. My inner For loop makes an Array of "single points for multiple plots", and when I bring it out through an indexed tunnel, I have a 2D array of M "triples" of points. Well, I need a 2D array of 3 sets of M Values, which I get from the Array Transpose function.
I'm now ready to assemble my 3 plots. In a For Loop, I bring the (constant) X Array in through a non-indexing Tunnel (since I want the entire Array, not each element) and bring the Y 2D Array in through an Indexing Tunnel (which gives me, one at a time, each of my three Y Arrays). I combine these in a Cluster (remember, a Plot is a Cluster of X and Y array values), then let the For loop build my Array of Plots. Wire that to the Graph, and run the program.
Bob Schor
11-03-2017 01:36 PM
Hi Bob. I get your point and I successfully build that Vı but I have problem with writing the datas simultaneously. In that solution, at the end we get all datas but I want to get all datas one by one by the time. Do you have solution for that? Bec. I couldnt solve it and I tried many cases!
11-03-2017 02:02 PM
At first, I didn't understand your question (it's really my fault, I wasn't thinking clearly), but when I ran my code snippet and saw the plots, I immediately realized what you meant.
You do not want a Graph -- you want a Chart! Using a Chart (which plots data as they evolve) is very simple. I'm going to leave (as an "exercise for the reader") the problem of how to get the Time axis to show in units of tenths of a second ...
Here's an Assignment for you -- learn about LabVIEW Charts. You might start in LabVIEW Help -- click the Contents tab, go to Fundamentals, then go to Graphs and Charts.
Bob Schor
11-03-2017 02:32 PM - edited 11-03-2017 02:35 PM
Here is my snippet. I know it but I could not do it. The graph gives me only one of them. But I want 3 of them. This is different solution. But in your solution I want to tick count as well.
11-03-2017 02:49 PM - edited 11-03-2017 03:14 PM
Here I can not wire cluster to array with output of the for loop. By the way, thanks a lot for replying 🙂
11-03-2017 10:32 PM
OK, now I'm totally confused. I thought (in my first response) I knew what you wanted to do, changed my mind and in my second response, thought I knew what you wanted to do, but now, I gather that I really do not know what you want to do.
Without resorting to any LabVIEW code, can you simply say, in words, what you want to do? How many channels of data are you examining? [I think the answer is "3"]. How fast are the data being generated? [I think the answer is "at 10 Hz, i.e. every 100 msec"]. Finally, and most important, what do you want to do with these data points?
Bob Schor
11-04-2017 03:07 AM - edited 11-04-2017 03:18 AM
I really sorry about that Bob! I did not hear your reputation,that was my fault. I confused you.
I wanted to plot the data as they were evolving on a single chart having three channels at 10 Hz, i.e. every 100 msec.Then I want to transfer and collect them(randomly generated numbers) at an Excel file.(Actually, later times,I will shift 3 random number generator with some program which collects datas from outside(experiment) to the charts with evolving time but for now, I try basics and put random num. generator) My X axis will be a elapsed time from 0 up to 1 sec. or any second that I put there.I understand how to make the X axis show the proper time units but I can not combine the time stamp with my datas in a single chart as they were evolving. I hope I could express my problem truly. Thanks for replying!
11-04-2017 02:10 PM
OK. My example generating the Chart gives you the X, Y, Z numbers that you can put into a Delimited Spreadsheet (or, alternatively, you can write, using the Report Generation Toolkit, as an Excel .xlsx Worksheet).
For the sake of argument, let's not worry if you are writing a .csv (Delimited Spreadsheet) or .xlsx (RGT, Excel) file. I'm going to choose to write each sample, i.e. X, Y, and Z, as a row. So if I take two samples having values 1, 2, 3 and 4, 5, 6, my file will look like:
1, 2, 3
4, 5, 6 (comma-separated format).
If I wanted to be "extra fancy", I could put a first row with " X, Y, Z".
I think you said that the plotting of these values in a chart was fine, what you were "missing" was an (initial) "t" column having the time values. But these are almost trivially generated -- 0, 0.1, 0.2, 0.3 etc. So your final .csv output would look like:
t, X, Y, Z
0.0, 1, 2, 3
0.1, 4, 5, 6
Note that my "t" column is elapsed time, not a TimeStamp. I'm sure you understand how to compute Elapsed Time -- it is just the index of the While/For loop ("i") times the loop period (0.1 sec). What if you want a TimeStamp? That's equally simple -- you need to get the Time when you enter the loop (I'll call this "t0"), then simply add (and save) t0 + t (where t is the elapsed time in seconds). Play around with the time functions a little so that you understand how they work.
So, to summarize -- When you sample data at a fixed rate, you get (3) data values + an implicit time value (the index of the loop). For plotting purposes, time becomes the X value of the plot, and the data become the (3) Y values. If you want to save the data in a Spreadsheet (.csv or .xlsx), you simply generate the (implicit, for a chart) Time value and combine it with the data values to create a row of the output file.
I hope this is clear. You have all the data present, you just need to compute the Time (either as Elapsed Time or Time(s) of occurance) from the Loop Index * Loop Period and prepend it to the Data Values to form the row of Time + Data Values.
Bob Schor