Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

PSD waveform array mismatch

Solved!
Go to solution

Hi,  I am working with a NI USB 9162 and NI 9234 4 channel daq in LabVIEW 8.5.  I am acquiring data from a device that produces a ~square wave and I am trying to determine and record the frequency of the square wave.  The problem that I am currently dealing with is that the waveform graph and array that are produced by the vi don't match.  I have recently connected a signal generator set at 500 Hz to one channel and checked it against an oscilloscope.  I get 500 Hz on the waveform graph but 605 from the array.  The graph is truncated at 825 Hz in the x-axis and the 500/605 is ~0.825, the same ratio as the truncation/1000 Hz.  I have attached screenshots of the block diagram and front page.  Any help understand why this is occurring and fixing it would be greatly appreciated..

 

Chuck Griesel

0 Kudos
Message 1 of 6
(4,243 Views)

Chuck Griesel,

 

It is almost impossible to troubleshoot from an image of part of a diagram. Please run your VI to show data similar to that in the images. From the Edit menu select Make Current Values Default. Save (possibly with different name). Then post that VI. Put a graph on the DAQ Assistant output before you run and save so that we can see the raw data. The Waveform Chart cannot save default data.

 

The Split Signals and Merge Signals construct seems unnecessary.

 

The Dynamic Data Type obscures information about the data contained within it, so we can tell nothing about that part from an image.

 

Building an array with a shift register in a loop can result in out of memory errors or slowing performance if the arrays get large.

 

Lynn

0 Kudos
Message 2 of 6
(4,229 Views)

Hi!  I have attached the vi that I am working with.  BTW, this VI is an earlier version of my most current vi.  I have needed to increase the channel count to 9, and split the output to two separate files to allow the users to work with less data.  Thus the more simple vi is attached.  Some of the programming in this vi is not necessary to see what issue I am seeing with the results of the waveform graph/chart vs. the most powerful peak in the array.  The index of the array is not the frequency of the most powerful peak shown on the waveform graph/chart.  The value in the array appears to the be the frequency times some multiplier that changes dependent on the number of samples and the rate.  I have also attached an EXCEL spreadsheet that contains a few combinations of frequency input and raw data from the time domain and the data written to the array for each condition.

 

 

Thanks!!!

 

Chuck Griesel

Download All
0 Kudos
Message 3 of 6
(4,169 Views)

Chuck Griesel,

 

Is the Power Spectral Density VI from some toolkit?  I cannot find a VI with that name.  I am using a newer version of LV, but I looked at the 8.5 vi.lib and did not see it there either.

 

Spectra can be of different lengths than the time domain signals which produce them.  Since arrays in LV must be rectangular, it is possible that you are combining arrays of different sizes and producing your error.

 

Your code has some parts which seem to do things the hard way. Split Signals and then Merge them back in the same order. What is that supposed to do? Coerce a 2D array to a matrix and then convert it back to a 2D array? Format Into String to produce 31 copies of a string constant, and doing it inside a loop although it never changes? Hidden indicators and controls for data which is never used (array size)?

 

Unfortunately, a chart does not retain data as default so the raw data which was on Waveform Chart is missing. Put an array indicator on the output of the Dynamic Data to 2D array conversion and save the defaults in that.

 

Lynn

0 Kudos
Message 4 of 6
(4,158 Views)

Hi Lynn,

 

This program is intended to read 4 channels of sensor input, display the results in time and frequency doman and when a button is pushed, write the data to a file with headers, print the front page, and continue on reading and display data as other physical changes in the test apparatus were made.  Dependent on the scaling of the sensors used, I would sometimes use the vi to change the scaling instead of through DAQmx as there were sometimes no direct units available in the drop down lists.

 

I don't remember which version of LabVIEW I was using when I started using the Power Spectral Density.vi.

 

The hidden arrays I have found useful in forming and debugging arrays as this program grew from 2 sensors to 3, then four,  I am now reading 9 sensors of various kinds.  There are hidden controls that I want to leave in place for trouble shooting for myself but hide for neophyte users.

 

The spectra that I see in the charts have peaks of high intensity where I expect,  but when the dynamic signal is transformed into the array, the frequency shown in the chart/graph is not at the same value of the index in the array that is made.  This is the source of the mismatch. 

 

I have determined a workaround that will produce the frequency from the chart to be the same as the index in the matrix.  This is done by making the number of samples roughly equivalent to the rate of sampling in the daq assistant inputs.  There was a small correction factor needed to get excellent agreement with the spectra displayed in the chart and the index of the maximum value in the array.  For this instance I would multiply the number of samples by 1.0237 to obtain a new number of samples that produces the correct index for the frequency input. 

 

Is there a more direct way to do this with out having to use a correction factor?  Is there something I am missing?  Is there a vi that will do this directly?

 

I have attached a vi that has a graph for the raw data and an excerpt of the array set to index 154 thru 159.

 

 

Thanks!!

 

Chuck

0 Kudos
Message 5 of 6
(4,135 Views)
Solution
Accepted by topic author Chuck-G

All,  I received some very good information from Carmen Zheng concern why I was seeing a mismatch from the display and the array being written.  This message was recieved after several messages back and forth.  I have attached the vi that contains the solution as described below.

 

Thanks Very Much for your help!!

 

_beginning of message________________________________________________

 

Hello Chuck,

Thanks for sending me back that file. I saw what's going there.

The dynamic data signal that you acquired whether from the simulated signal or from your hardware contains three components: Y, dt, t0. These components are required in order to build a waveform correctly. The
component Y returns an array of the data values of the waveform and dt returns the time interval in seconds between data points in the waveform. The dt correspondS to Fs/#s, this dt value will
tell the waveform how to distribute the Y values across the x-axis.  

The reason of why you saw the mismatch is because you are extracting only the Y component, which doesn't contain the information of how to distribute it across the X-axis. The index of that component
doesn't reflect the position of where the value should be showed.

The easiest workaround that I could found was creating an array with the size of #s, then, insert the values from the Y component array to the new array, but the index is scaled by the dt factor.

Please take a look to the attached code.

Let me know if you need further assistance.

Regards,



Carmen Chan Zheng
Applications Engineer
National Instruments

 

___end of message_______________________________________

0 Kudos
Message 6 of 6
(4,037 Views)