LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

XY Chart memory model

Solved!
Go to solution

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:

 

xy chart.png

 

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. 

0 Kudos
Message 1 of 4
(3,489 Views)

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.

0 Kudos
Message 2 of 4
(3,476 Views)

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?

0 Kudos
Message 3 of 4
(3,462 Views)
Solution
Accepted by topic author ijustlovemath

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!

0 Kudos
Message 4 of 4
(3,448 Views)