There are a number of issues here, but the main one is that you need
to understand how data flow works. If you have a loop running and the
graph is in another loop expecting data from the other one it will not
receive anything, it won't even run...until all that data is
available. In the "Neat but not working" example that means that the
serial reading loop will run as fast as it can and because you have
auto-indexing on it will even report values all the times it reads
nothing at all on the port (you need to expand the logic to handle the
fact that the signal transfer takes time and is not continous)..so
that loop is generating an array and doing it fast with lots of empty
(0) elements. It's not until the stop button is hit that the second
loops starts, and then all that happens is that the graph gets the
same array over and over again on each iteration (no need to build a
2D).

So - what should you do. Well, first of all you need to create a VI
that will read the serial data properly (waits until all the expected
data is there before parsing it to get the value). If you do that then
you could use a chart (instead of a graph) and wire the output value
to the chart...Charts remember the previous values and plots them all
(a certain buffer size) whenever new data is available. A graph
however does not remember previous values so in that case you will
need to hold all the previous numbers in an array in a shift register
and then append the new values as they are read using the build array
function. This however is not very effective since it rebuilds the
array each time, chich involves memory allocations etc...costs memory
and execution speed. The best therefor is to have e.g. a circular
buffer to hold the array. That way you work with a fixed sized array
and the replace array element function which is much more efficient.
You can find descriptions of circular buffers here...make sure you get
the consept of shift registers first though.

Reply via email to