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: 

make a cross-correlogram from two inputs

Is this what you want:
0 Kudos
Message 11 of 16
(1,087 Views)

hi, yea thats what I wanted, its still not working though, so im going to try to write it in matlab and add a script.

thanks for all your help

0 Kudos
Message 12 of 16
(1,073 Views)

Hello,

Ok, I am getting into this post a little late, however, it seems like you just want to construct the following:

1. a "histogram" where:

bin1 contains the number peaks that occur in signal B, between the 1st and 2nd peaks of signal A

bin2 contains the number peaks that occur in signal B, between the 2nd and 3rd peaks of signal A

...

binN contains the number peaks that occur in signal B, between the nth and (n+1)st peaks of signal A

 

If you are simply looking for a plot with "bars going up" where the size of the "bars" equals the number of peaks in what we previously called a "bin," then perhaps the easiest way to do this is to simply build an array containing the values indicated above.  That is, the first element in the array is really just bin1, the second element is really just bin2, ... and so on.  You can show this much like a histogram if you simply change the plot style to be one of the "vertical bar types."  I have attached an example showing how to plot 100 bars, where the height of each bar is a random integer between 0 and 10; I plot the same thing to 2 waveform charts (where it updates a bar at a time) and also 2 graphs where one uses a thin bar type, and the other uses a thick bar type.  You could use a similar technique, where instead of plotting random integers, you simply count the peaks in signal B between "reference" peaks (as you seem to already be able to do), and build an array of those values.  I do this in a "for" loop, but especially using the charts which update a "bar" at a time, you could do this in a while loop and see your "counting" occurring in "real-time."

Repost if you continue to have questions!  Also, if you are set on using text-based code to implement this, you can always use a MATLAB script node (which takes MATLAB syntax) in LabVIEW so you can play with the data before and/or after in LabVIEW.  You can also use a formula node, which will allow you to use C-like syntax and corresponding programming structures.  However, you should be able to do everything you need fairly easily with more fundamental LabVIEW types!!!

Repost if you have any further questions!

Best Regards,

JLS

Best,
JLS
Sixclear
0 Kudos
Message 13 of 16
(1,051 Views)

@sophie83 wrote:

hi, yea thats what I wanted, its still not working though, so im going to try to write it in matlab and add a script.

thanks for all your help



Hi Sophie,
I found another post of yours (Cross-correlator 2 inputs.vi) in another thread in this forum. There are code fragments in that VI which perform a correlation of signals, auto- as well as cross-correlations. Are those the correlation algorithms you meant to discuss in THIS thread? If so, they do not seem to fit to you descriptions as I understood them.

In any case, I took that code and modified it to make better use of the possibilities offered by Labview. If you're interested you'll notice that the modified code is much more compact than the original code. Certainly there is more optimization possible.

If the correlation code presented there (which I summarized into a SubVI) is what you need or comes close to what you need, try to use it in your program. Don't hesitate to come back to the forum if you need further assistance.

(In the  attached modified code the Analog Input subVI is missing since I had no DAQ installed on my laptop.)

Let me finally remark that I fully  agree with what JLS said in his answer, especially with his statement "
However, you should be able to do everything you need fairly easily with more fundamental LabVIEW types!!!"  !!!

-Franz
0 Kudos
Message 14 of 16
(1,039 Views)

Hi, Thanks for all your help.  Its working fine now. I just have a question about minimizing my program, how did you do that, where you made your own subvi? I know it has to do with the connector pane but I am not able to do it???

Also, I have another question, say im running a program and acquring samples, and I have a button where the user clicks on analyze data.  I would then like a new pop up window with a front panel to pop up and display the data on teh different screen.  Right now I am displaying the samples and data all on one front panel, and its very crowded.  I think I have to create subVIs, but im not sure how im supposed to do it

0 Kudos
Message 15 of 16
(1,029 Views)


@sophie83 wrote:

Hi, Thanks for all your help.  Its working fine now. I just have a question about minimizing my program, how did you do that, where you made your own subvi? I know it has to do with the connector pane but I am not able to do it???

Also, I have another question, say im running a program and acquring samples, and I have a button where the user clicks on analyze data.  I would then like a new pop up window with a front panel to pop up and display the data on teh different screen.  Right now I am displaying the samples and data all on one front panel, and its very crowded.  I think I have to create subVIs, but im not sure how im supposed to do it




There are two ways to create a subVI. Normally you create it 'from scratch', i.e. you write a new VI with the desired functionality. It has controls (=inputs) and indicators (=outputs), and of course a source code which generates the output in dependence on the input. But it also has what is called a 'connector pane'. (This is comparable to the header of a subroutine in a classical language). You configure the connector pane by right clicking on the VI's icon in the upper right corner and select 'Show connector pane'. The wiring tool allows to map the shown connector areas to the controls and indicators. Save you new VI  and you can use it in  other, higher level VIs.
Understanding how to make subVIs is really crucial, so take the time to work through a tutorial (there should be one on the LV CD), or a book or one of the online tutorials, e.g. http://www.iit.edu/~labview/Dummies.html. If time and money permits, attend one of the courses offered by NI.

Now, the other way to create a subVI (which I used in this case), is to select a portion of the existing code and select in the menu 'Edit-->Create subVI..'. Then the selected code is converted into a subVI which you can open, maybe edit and then save. All the connector pane definition and wiring in the calling VI is done automatically (you might have to clean it up a bit for a nicer look). Of course you can change them any time later.


The second part of your question:
The normal 'fate' of a subVI is that it is never visible, it does its job in the background. Sometimes you want it to become visible, though, e.g. when it should behave as a pop-up dialog VI or you want to display intermediate results. You can modify the subVIs behaviour to accomplish this by selecting 'VI properties' (via the File menu or by pressing Ctrl-I) and change the settings under 'Window appearance'. All this is a bit involved, so check the tutorials or manuals  for details.

regards

Franz

PS: Dont' hesitate to rate my answers if you thought them helpful 😉


0 Kudos
Message 16 of 16
(1,020 Views)