LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Issues with writing equations and using Non-Linear Optimization in Labview

Hello

 

I am in the process of building a VI to calculate frequency shifts on spectra using a type of covariance, in order to properly align them. The approach was validated with a Python code and works properly (adapted from https://www.mdpi.com/2813-446X/2/3/12) . Unfortunately, integrating Python with LabView is not possible at the moment, for various reasons - although it would make my work much, much easier. I have attached the VI and commented it, highlighting some sections I find important, and will use the internal references of the VI in this post.

I ran into two main issues:

 

First, in box 3, I was unable to fully reproduce the equation, as it requires to introduce the unknown variable "shift", which is actually the variable for which I wish to determine when I minimize the function (the solution should be singular). How can I overcome this issue?

 

The second one has to do with box 6. I made a search across the Forum and came across the Non-Linear Global Optimization VI. The user who asked it managed to solve it, but unfortunately didn´t post how to achieve it (URL: https://forums.ni.com/t5/LabVIEW/Is-there-a-LabVIEW-vi-that-performs-a-minimization-based-on-the/td-...). My issue here is that I need to minimize a fairly large exponential function, whose shape is actually a function of the number of points present in both spectra, so it might change from dataset to dataset. I looked at the examples in LabView, and I felt absolutely lost - they are realistic, which is good, but I felt it was overcomplicated to understand if you never worked with it before. I am still trying to understand RefSum, which I have never worked with before also. Can someone be patient enough to guide me through this optimization routine?

 

Thanks in advance for your time and interest,

 

Kind regards,

Fl0

0 Kudos
Message 1 of 5
(270 Views)

You will get better help if you do a "save for previous" (LabVIEW 2020 or below) before attaching code. Many cannot open your VI.

What are typical default values for the controls? (I am almost sure that NoPoints=0 is probably not reasonable, while it does give "No Points", of course 😄 )

 

Message 2 of 5
(234 Views)

There is no objective function anywhere, just a disconnected control and it is not clear why you are calling it by reference with no inputs connected.

Message 3 of 5
(223 Views)

So, I had a quick look at your simulation and the data is identical with only the x values differing between the two sets. Is this realistic? I assume that in your real data, the exact x-values are not known, right?

 

So what differs between two datasets to be aligned? (# of points? X0? dx?, etc.). Can we assume that the x-ramps are linear? Can you attach some real data where there are peaks that are  misaligned? Is the shift an integer or can it be fractional? What is the point spacing compared to the width of the peaks?

 

Many times, just the max position of the crosscorrelation between two shifted sets can give you the required shift.

Message 4 of 5
(188 Views)

Hello,

 

>> So, I had a quick look at your simulation and the data is identical with only the x values differing between the two sets. Is this realistic? I assume >> that in your real data, the exact x-values are not known, right?

 

It´s not indeed realistic. The whole purpose of that generator was to make it easy to spot mistakes while I was building the VI. The two spectra should be similar (but not equal) - the only difference should be just a shift in the X-scale.

 

>> So what differs between two datasets to be aligned? (# of points? X0? dx?, etc.)

 

The main differences are # of points and X0. dx is constant.

 

>> Can we assume that the x-ramps are linear?

Yes, we can

>> Can you attach some real data where there are peaks that are  misaligned?

I´ve attached a data set in this reply.

>> Is the shift an integer or can it be fractional?

It can be fractional

>> What is the point spacing compared to the width of the peaks?

Much smaller than the peak width, around two orders of magnitude lower.

>> Many times, just the max position of the crosscorrelation between two shifted sets can give you the required shift.
I´m fairly new in signal processing and I´m willing to learn. Do you have a recommended book on the topic?

 

>> There is no objective function anywhere, just a disconnected control and it is not clear why you are calling it by reference with no inputs connected.

I was trying to understand how the objective function was constructed, and also how I would work with RefSum. So, I just "unpacked" it, to better understand it against the LabView examples. I didn´t try to make it work, I was just trying to "dissect" it in order to understand it.

>> What are typical default values for the controls? (I am almost sure that NoPoints=0 is probably not reasonable, while it does give "No Points", of course
)

I was using a small number for it work, so I could look at the VI outputs and understand if something was off. In reality, I expect 20k to 40k points, with a stepsize of .01 and frequencies starting at 1140.

Many thanks!

Download All
0 Kudos
Message 5 of 5
(157 Views)