From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Changing Waveform Data into Numerical Values

Solved!
Go to solution

Hello all, as you can see on the attached picture i am trying to do some further calculations with my data after it has been received. The goal is to get numerical indicators, which will not show up when using waveform data. The indicators connected to the waveform modules do work, but not the ones for the calculations. So I tried to use the "get waveform components" function but i keep getting an error in my code (broken wire). Anyone know any other functions i could use to accomplish this?

 

FYI- the first photo is the full program, and the second is the broken wire when i try to add the "get waveform components"

Download All
0 Kudos
Message 1 of 5
(3,129 Views)
Solution
Accepted by topic author jncovsky

It's probably because you have an array of waveforms, not just a single waveform. Try using "index array" before "get waveform components".

 

I can't tell for sure without seeing the VI.

0 Kudos
Message 2 of 5
(3,116 Views)

We beg, we plead, we politely ask, but still people show us pictures of code rather than attach the VI, the code.  I'm just glad we're not talking C++ (and a picture of a 1000 lines of text).

 

You clearly have an array of Waveforms, and, even worse, you transform it into (and then out of) a Dynamic Data Wire (I've never understood why these were invented, other than to make LabVIEW "seem simple" for Newbies).  There are other things in your picture that I'd love to click on and examine closer, possibly try running through a For loop to see if I can "de-array-ify" it and make your code work, but I only have a static picture, not a dynamic LabVIEW VI, to work with.

 

A single Waveform is easy to use.  Extract one from your Array and try again.  If you need more help, attach your VI.  Please!

 

Bob Schor

0 Kudos
Message 3 of 5
(3,077 Views)

My apologies! Here is the attached .VI and the associated subroutines. Thanks for your initial suggestions, I am going to try now and see if I can get something to work.

0 Kudos
Message 4 of 5
(3,068 Views)

You have a lot to learn -- let's get started!

  • Whenever you make a sub-VI (as a beginner -- you can relax these rules when you learn more), always use the 4-2-2-4 Connector Pattern that is the default.  Always wire Error In and Error Out to the lowest outside connectors.  Always wire inputs on the left, outputs on the right.  You should almost never connect more than 3 inputs or outputs (I'm not counting Error).  Reserve the top outside terminals for Data In and Data Out.  If you have more parameters (like your SCH/SCL Calibration VI), bundle them into a Cluster and bring in a single wire.
  • Sub-VI Icons are Good.  Clarity is better.  It took me several minutes to realize that funny function was a really ugly icon for SCH/SCL Calibration.  How about a Square Box with three lines of text, SCH SCL Cal?  Icons do not need to be pretty, but they do need to be "obvious".  [Still, kudos to you for making them at all!].
  • Dynamic Data Wires are (basically) Evil.  Waveforms are (basically) Good.  Do not use Dynamic Data Wires!
  • Your DAQmx Read (correctly) outputs an Array of Waveforms.  Use Index Array to "peel off" the Waveform(s) you want.  Note that all of your code (and your two sub-VIs that should be operating on a single Waveform) are using Array of Waveform -- this is wrong.
  • Index Array has a fun property (that I discovered after about 3 years of coding in LabVIEW -- someone in the Forums pointed it out to me) -- if you drag down the bottom of the function, it will "expand", and if you don't wire the input terminals, the outputs will be Array Elements 0, 1, 2, 3, ...  Look, Ma, No Coding Needed!

I think that if you go through your code, removing Dynamic Data Wires, recognizing where you have Arrays of Waveforms and handling it appropriately (here's an idea -- wire the Array of Waveforms into a For Loop, which will give you an Index Array input tunnel that will enumerate each waveform in the Array.  Put a Case Structure inside wired to the Index, "i", so it "counts" 0, 1, 2, etc., and put inside the, say, 0 case the code you need to calibrate Channel 0, in the 1 case calibrate Channel 1, etc., then let the output, a single Waveform representing one of your channels, pass back out through the For loop as an Indexed Tunnel and Presto, you've gone from N Uncalibrated Waveforms to N Calibrated Waveforms).

 

That last point -- any time you have multiples (in an Array), see if you can process the entire Array, possibly doing different things for different Array Indices, but often you'll be doing the same thing for each Array element.  The For loop, with its Indexing Input and Output Tunnels, lets you work on a single Array element inside the loop and reassemble it on output.  Neat!

 

OK.  Clean this up.  You are off to a good start.

 

Bob Schor

0 Kudos
Message 5 of 5
(3,049 Views)