LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

What is the best way to get a ratio between two waveforms?

I'm reading in multiple channels on a PCI 6143 and I want to get the Voltage Standing Wave Ratio (VSWR) between two channels. Right now I have a choice of outputting a 2D DBL or 1D waveform from the daqmx read vi. With the 2D DBL I can use a For Loop and an Index array and compare channels that way, but I was wondering if there is a better function to compare waveforms or even a function to calculate VSWR. Using the For Loop and Index array seems inefficient.
0 Kudos
Message 1 of 6
(3,379 Views)
Most of the LabVIEW primitives (add, subtract, greater than, etc.) work on arrays, so you can do array math as easily as scalar math. If your waveforms are aligned in time, you should have no trouble. If they aren't, you can use the Align and Resample Express VI to take care of that problem (or you can do it yourself if you are using an older version of LV).

For example, to find the ratio of two arrays, simply divide one by the other and take the average of the result. Be careful about dividing by numbers close to zero. They can put a lot of noise into the result. You may want to scrub your arrays of these first. Of course, at that point, you may as well use the FOR loop.

Good luck.
Message 2 of 6
(3,358 Views)
Thanks for the reply. I found out shortly after I posted this question that I could do math on waveforms. I didn't know about aligning the waveforms though. If I'm sampling waveforms from the same board using the daqmx 1d waveform array read, does that mean my waveforms are aligned? Is there a function that does this? I don't want to resample and align if I don't have to. I looked at the Align Waveforms.vi and Resample Waveforms.vi and they require an array as an input and quite a bit of other inputs (which I don't know right now, but I'll read about them), unlike the Express VI. I don't want to use the Express VI because I'm using LabVIEW RT and I read somewhere to try not to use express vis for efficiency sake.
0 Kudos
Message 3 of 6
(3,341 Views)
The PCI-6143 does sample all channels simultaneously (unlike some other DAQ boards), so you should not get any phase differences there. That leaves hardware. You need to make sure your cable lengths are the same and your splitter has the same impedance/path in both directions. You can compensate for splitter problems with cable length or software realignment. You can do a visual check of the waveforms to see if you have a problem. With the frequencies you are likely to measure with the 6143 (10s of kHz), you probably don't need to worry. This is usually only a problem at MHz frequencies.

You are correct that you do not want to use Express VIs in RT. However, you can use an Express VI to save you a lot of time. Set up the Express VI to do what you want to do, then open the front panel. Cut and paste the code from the block diagram to your RT code, then modify it to make it more efficient. This can often save you a lot of work.
Message 4 of 6
(3,327 Views)
Hi Corey!

Great answers, DF. DF is right about the PCI-6143 being a Simultaneously Sampling board. This actually means that there is an ADC converter for each of your AI channels. This guarantees the synchronization of your samples on the DAQ board. What DF was explaining about cable length, etc. is making sure the signals that you are measuring actually get to the DAQ board at the same time. And also like DF said, this should only be a problem if you are trying to measure frequencies higher than what is possible to measure with the DAQ board anyway.

On another note, when using an E-series or M-series board (with only one ADC converter), the sampling of the channels will still be "aligned" (off by microseconds). Only if you are doing extremely precise measurements would you need to be concerned with this issue. This is cost/accuracy tradeoff that most people are willing to make.

Hope this helps!

Travis H.
National Instruments
Travis H.
LabVIEW R&D
National Instruments
Message 5 of 6
(3,314 Views)
Hi Guys!

For some reason the order of the posts in this thread got all out of whack. My original post in this thread was posted (in time) after the two posts preceding this post. So, if you are reading this thread, read my first post at the end. It will make a lot more sense then!

Travis H.
National Instruments
Travis H.
LabVIEW R&D
National Instruments
0 Kudos
Message 6 of 6
(3,296 Views)