04-12-2005 02:59 AM
04-12-2005 10:52 AM
01-10-2023 04:44 AM
Hi Kevin,
you've outlined the solution quite well in this older post, which is useful in my current application. I just have a question about building the XY Chart.
From the Ni docs I gather that the data can be in the form of a cluster composed of an x and y array. I used a bundle function to build a cluster of the 2 arrays. The first comes from the for-loop as you described and the second comes from my frequency measurement which is transformed into a speed and then built into an array. I could not create the input cluster with X and Y as shown in the video.
When I run the program the XY graph axiis and grid bounce around while the counter is counting, but I do not get a plot of speed (derived from frequency) vs time as expected, so likely there is something larger askew with my datatypes or the configuration of the XY graph. Any ideas where to look? Is it wrong to simply build an array from the dbl to create the speed array?
Thanks
01-10-2023 05:03 PM
Probably the most important thing for you to understand is that an XY *Graph* will not show an accumulation of data over time. Each time you write data to the graph, you will be *replacing* the previous contents.
To show an accumulation of data, you'll need to do the accumulating yourself. I'm going to recommend you use one of the *other* available data formats for a single plot on an XY Graph. I'd recommend complex notation if you understand it, otherwise I'd go with a single array of "points", where each "point" is a cluster containing an x (time) value and a y (frequency) value.
Another pending problem is that you're trying to read 1 sample at a time from 2 different tasks that will have different sample rates. The sample rate for frequency measurement is driven by the signal frequency itself, and will very likely vary noticeably, else why would you be measuring it? Anyway, the problem is that the tasks are filling up their buffers at different rates but you're reading samples from them at the same rate. One of them is going to fall behind and cause an error.
I would read about 1/4 sec worth of AI data first, then read "all available" samples from the counter task to keep pace. This will update your graph 4 times a second
I'll make some minimal mods to your code to illustrate a simple way to accumulate data for the XY graph, but I'd recommend you look into how to use a "lossy queue" to prevent the storage from growing without limit.
-Kevin P