LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Proper data types for XY Graph?

I am new to LabVIEW (I'm using 7.1, full development version).  I have used LabWindows/CVI previously and have experience with C/BASIC/Pascal/Fortran/etc., so working with 'G' is a real change for me.  I'm trying to figure out how to display data from a spectrum analyzer on an XY Graph - it seems like it should be simple, but I can't figure out how to get it to work.  The particular analyzer I'm working with returns trace data as 500 points of amplitude information only, in one very long string (6500 characters, comma delimited values).  I used Spreadsheet String to Array conversion and directed the data to a plain waveform graph and it displays just fine (X axis becomes 1-500).  When I connect the data to an XY Graph, it simply doesn't display (I connected a 0-499 loop counter to the X input).  When I Probe the two inputs to the XY Graph, they look exactly like what they should, up to the special data converters, after which the data from the analyzer doesn't come through.  The only thing I can see that might be the problem is that the Spreadsheet String function has a terminal marked "2D Dbl" and the data I am feeding it is 1D, and I can't figure out from the documentation how to change the function's output.  Can anyone give me a hint/clue here?

 

Regards,

 

Michael

 

0 Kudos
Message 1 of 13
(4,141 Views)
You specify the type of array that the Spreadsheet from String returns. The
input you've created (probably right clicked and selected "create constant")
is a 2D array by default.

Right click the array constant, and select "Remove Dimension".

Regards,

Wiebe.


0 Kudos
Message 2 of 13
(4,132 Views)

Since your data is spaced equally in x, a simple waveform graph is the correct tool, an xy graph is not needed at all and just complicates the code.

 

All you need to do is write the offset and multiplier for the x axis of the wavform graph so the correct values show.

 

The offset and multiplier map the array index of the y array to the correct x values. The offset is the x value for the first array element, while the multiplier is the x difference between adjacent elements.

 

Please let me know if you need more help.

0 Kudos
Message 3 of 13
(4,110 Views)

SynergyMike wrote:

When I Probe the two inputs to the XY Graph, they look exactly like what they should, up to the special data converters, after which the data from the analyzer doesn't come through. 


I guess you are using the bloated xy graph express VIs and what you call "special data converters" are possibly the DDT bullets? is this correct?

 

You are leaving out way too much information. It would really help if you could attach an image or an actual VI. It would easily save you a few paragraphs of vague descriptions and would help us to immediately see what you are talking about. Thanks!

0 Kudos
Message 4 of 13
(4,108 Views)

Solution found.  You are right that I left off too much information.  I _need_ an XY graph because I want to plot Amplitude vs Frequency (I assumed folks would know what a spectrum analyzer does) - I just hadn't set up the frequency retrieval part.  Anyway, I found the source of the trouble - I am using a flat sequence structure to write and read to the instrument and the graphs were outside the structure (since that is where the software placed them when I created them on the panel).  When I moved the XY graph inside the sequence, it worked just fine.  I seem to recall reading in one of the PDFs that tunnels can be problematic, now I see why.  🙂

 

However, this creates a new problem of sorts - the way I am used to programming is very linear, so I'd need a flat sequence structure of several dozen frames to accomplish what I have in mind as a final construct. Is there another, better way?  Sequences of sequences, perhaps??

 

Regards,

 

Michael

 

0 Kudos
Message 5 of 13
(4,100 Views)

People tend to use sequnce structures often, even when they are not neccessary.

The data flow is dictated by the sequence that things are wired. Is the sequence structure really necessary?

  

Cory K
0 Kudos
Message 6 of 13
(4,090 Views)

SynergyMike wrote:

I _need_ an XY graph because I want to plot Amplitude vs Frequency (I assumed folks would know what a spectrum analyzer does) - I just hadn't set up the frequency retrieval part. 


It does not matter what you call the axes (frequency, time, etc), it only matters if the x-values are equally spaced (==>waveform graph) or not equally spaced (==> xy graph). Spectrum analyzers typically provide equally spaces frequency data.

 

You need to get way from your "linear thinking". Most often, it does not matter in which order certain code parts execute, so there is no need to enforce any misguided  execution order, e.g. with sequence structures. Dataflow alone typically ensures that things execute in proper order. Whenever there is a wire between two nodes, the second node will automatically wait until the previous node has completed, so things will typically sort each other out in an optimal way. If things don't have any data dependency, they can, and should (!), execute in parallel. and thus potentially use multiple CPU cores, speeding things up. Trying to artificially micromanage and enforce sequential operations with tons of sequence structures is a sign of poor understanding of dataflow and poor programming skills (e.g. overuse of local variables breaks dataflow and requires sequence structures).

 

It is important for LabVIEW beginners not to get into bad coding habits. If you show us your code, we will probably be able to help you optimize it significantly.

0 Kudos
Message 7 of 13
(4,083 Views)

To Kory K - ok, I understand the idea there, but I'm still missing something.  If I send a command string to a GPIB Write function, how would I "wire" that to the GPIB Read function that follows with the instrument's response?  I'm sure there's a logic to make it work, but it isn't how I'm used to thinking.

 

Regards,

 

Michael

 

0 Kudos
Message 8 of 13
(4,070 Views)

To altenbach - ok, what I want is to have the X axis say, for example, 500-1000 MHz and then if the analyzer is changed to 200-500 MHz, have the X axis read that instead - how would I update the axis on a Waveform graph based upon output from the analyzer?

 

Regards,

 

Michael

 

0 Kudos
Message 9 of 13
(4,068 Views)

SynergyMike wrote:

 If I send a command string to a GPIB Write function, how would I "wire" that to the GPIB Read function that follows with the instrument's response? 


All these functions have connections for the error cluster (in & out). Wire the error output of the first function to the error input of the second function and things will happen in the expected order.

 

As an added benefit, the second function will no do mindless things if the first function returns an error. 🙂

0 Kudos
Message 10 of 13
(4,067 Views)