LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I wire input to the x-axis of the Waveform Chart in LabView?

I would like to wire an input to the x-axis of
the waveform chart so that I can plot an y vs x
graph as the data is being aquired. Does anyone
know how to do this? If it cannot be done with
the waveform chart is there some other way?


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
0 Kudos
Message 1 of 9
(5,333 Views)
Just check out the following VI:

\Labview\examples\general\graphs\gengraph.llb
>> XY Graph.vi.

You can't miss it.
0 Kudos
Message 2 of 9
(5,333 Views)
Yes, but is there a way to see the graph being updated as each new data point is collected? If you add a timing delay to the loop, you'll see that the example VI you pointed to doesn't do this.
0 Kudos
Message 3 of 9
(5,333 Views)
Swordfish78 wrote in message news:<506500000005000000FD820000-1023576873000@exchange.ni.com>...
> Yes, but is there a way to see the graph being updated as each new
> data point is collected? If you add a timing delay to the loop,
> you'll see that the example VI you pointed to doesn't do this.


Hi Swordfish.
the answer lies in some innefficient codeing. You effectively need
to use the graph as a chart. A chart works by keeping a history of the
data previously written to it, so this is what you need to implement.
Start with an X-Y graph on the front panel.
On the diagram, drop a for loop, set for say 50 iterations, with the
graph inside, and a wait until next ms sub vi set for say 100ms.
Put the xy-graph FPTerm in the loop, and create a shift register.
Right click on the graph, and Create-> Constant. Wire this to the
shift register on the input side (left) of the loop. (will be an
array, zero length of a cluster of two doubles.) Wire inside the loop
to the graph.
Now for some data. Drop down the sine and cosine mathematical sub
vi's, and wire the index of the loop to the convert to dbl sub vi.
Wire this output to the inputs of the sine and cosine vi's. From the
outputs of these two vi's, put them into a cluster (useing bundle).
Finally, you need the array size, and a insert into array vi's.
From the graph FPTerm (which is now wired to the shift register input
side) wire this to the array input on the insert into array. Also wire
this array into the array size vi. Wire the array size output to the
index input in the insert into array vi, and wire the cluster created
earlier into the n-dim array input.
Finally wire the output of the insert into array vi into the output
side of the shift register.
I have the .vi if you want to ask me away from the newsgroup, as I
can't add attachments from here.
The reason it's innefficient is you're permanently re-sizing the
array, and after a large amount of manipulation, this method starts to
slow down. (The bigger the array, the harder it is to find continuous
space in memory to put it in). It's much more efficient if you know
how much history you need, and create a "history" array this size. You
can then manipulate the data, moving it one step back each time, and
putting the new point on the end. This way the array doesn't change
size.

Hope that helps

Sash.
0 Kudos
Message 4 of 9
(5,333 Views)
Hi. That works great, thanks! Now hopefully I'll be able to implement it for my Current vs. Voltage data. Thanks again!
0 Kudos
Message 5 of 9
(5,333 Views)
Hi. I'm hoping you'll be able to help me out again. I've attached my nearly-working vi so you can understand my problem and maybe tell me what I need to change. As you can see, I choose to generate and plot the simple function y = 2x. I use the index i from the FOR loop to be my X values, and simply multiply each one by 2 to simultaneously produce the Y values. According to the indicators on the front panel, they behave exactly as I would like them to, starting at 0 and stepping up to Xmax (and corresponding Y). However my XY graph does not plot these same values. Instead, it lags each data pair by one point. That is, the final X value on the indicator is 5 (and y = 10), but the final data point shown on the graph is 4,8.


Can you tell me why this is happening?
0 Kudos
Message 6 of 9
(5,333 Views)
Just write the array data to the graph after the new
values are inserted into the array.
0 Kudos
Message 7 of 9
(5,333 Views)
Thanks, that was simple. I guess I just overlooked the fact that each iteration of the loop doesn't take place instantaneously. Of course the ordering is apparent now.

Thanks again!
0 Kudos
Message 8 of 9
(5,333 Views)
Bundle your inputs,connect the output of bundle to XY chart buffer.vi , then connect it to XY graph.

Inputs --> Bundle --> XY Chart buffer.vi --> XY Graph
0 Kudos
Message 9 of 9
(5,333 Views)