11-09-2015 02:44 PM
I've found a need for an XY Chart in one of my applications, and I'm trying to wrap my head around how to use it properly. My implementation looks like this:
Which is closely modelled after the one found here: http://digital.ni.com/public.nsf/allkb/18B56D8556D44BF18625753D006EFF7C
My application uses a state machine, which initialization and closure states. If I make this VI nonreentrant, I cannot use it multiple times for my multiple (2) XY charts. However, if it's reentrant, I don't see how I'll be able to clear the graph in the closure state, as the instance I'd like to clear is in the graphing state.
The current implementation loads all the data from a spreadsheet into memory, plots it on an XY graph, and destroys the data afterwards, which is why I feel this is the perfect application for an XY chart.
I cannot use a waveform chart, as my data is not evenly spaced through time.
Solved! Go to Solution.
11-09-2015 03:07 PM
If you would use complex array (x=RE, y=IM) you could cut your code in half. 😄
XY graphs understand complex arrays directly.
I would implement an in-place solution with a fixed buffer. You can omit points from the graph using NaN.
11-09-2015 03:35 PM
Could you show what the in place solution looks like? Also, how does this solve the problem of reentrancy and clearing memory when the application completes?
11-09-2015 04:13 PM
I ended up using a value that is set in the init state to clear the graph (really to add what's gone on to that point to the graph). I also have the XY Chart VI set to have Preallocated Clone Reentrancy, which meant that each block on the block diagram gets its own memory space, as expected.
The difference is night and day. A full run of the application (it's a simulator) used to take about ~6 min, where now it takes less than 30 seconds. This is amazing!