LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Finding the symmetrical value (with respect to the Y-axis) of a sine wave.

Dear all,

 

Thank you for reading my post.

 

I am trying to create a VI that will read the first point of a voltage waveform and then find the closest (in terms of magnitude) symmetrical point (with respect to the Y-axis). I should point out that I have no knowledge of where the first point is going to be.

 

It should then find the corresponding indexes of those two points in the voltage array. For those two indexes, the VI will then need to find the corresponding values of the Current waveform*. It will need to average the two corresponding values of the Current waveform. This will need to happen for all 100 points of the waveform.

 

At time t1 and t2:

 

I= (It1+It2)/2

 

Please take a look at the attached figure which should make things a bit more clear.

 

I have written a bit of code, but I have mixed up the logic somewhere and I am not getting the correct results. I am also pretty certain there is a better way to find the symmetrical point, other that using the ‘In Range’ VI.

 

Please have a look. Any advice would be more that welcome.

 

Thanks in advance.

Alex

 

 

 

*The measurements are read with a DAQ card. The Voltage (50Hz sine wave) and the Current signals are related.

 

I am using LV 8.0 on a Pentium D (3.4GHz), 2GB RAM, Windows XP SP2.

Download All
0 Kudos
Message 1 of 5
(3,466 Views)
Hi Alex,

The output of your "In Range" function will always be true. This is beacuse you are comparing the value you are using to compute the upper and lower limits. Hence, it is always going to be in range.

I think for your requirement, a while loop is a better option compared to a for loop. The while loop stops when it finds the mirrored point.

The attached code image uses a while loop to find the Current average for a single point.
Message 2 of 5
(3,434 Views)

Hi Alex,

I wholeheartedly agree with almost everything that Prashant has informed you. The while loop will certainly make life a little easier. I was quite intrigued by Prashant’s program, so decided to implement it for myself, and ask it to find “mirrored” data point of a self generated sine wave - and it seems to work very well indeed. The only flaw I have found is tries to find the mirror of a –ve number.

In this situation, adding +15% (say) to a negative number will result in an even lower number – therefore defining the lower number, not the higher limit.

The code I have attached come up with a simple solution. If the number you are trying to find of is negative, the case structure swaps over the high and low limits.

There are several other additions to Prashant’s code, but they were added purely for my own sake. You can ignore those if you wish.

Best wishes,



Message Edited by RER on 04-24-2008 11:49 AM
Rich Roberts
Senior Marketing Engineer, National Instruments
Connect on LinkedIn: https://www.linkedin.com/in/richard-roberts-4176a27b/
Message 3 of 5
(3,380 Views)
Hi Alex,

I agree with Rich about my code not being able to find the mirror point of a negative value. Thanks Rich.

I also found a bug in the example I had posted which propogated to Rich's code. When the leakage current array is indexed, the index from the while loop must be added to the index to be found + 1. The attched images shall make it easier to understand.
Download All
Message 4 of 5
(3,357 Views)

Hi guys!

I am overwhelmed with your response.

However, I have been working on this for the last couple of days and came to the conclusion (though I might be wrong), that what I was going down the wrong track.

I am saying this because:

As the rate of change of the sinewave decreases (when we are getting to the top), the difference between adjacent values also decrease in values.

Now since our routine looks for a percentile difference (We set this up. It could be anything we want i.e. +/-1% to +/-15%), when our initial value is somewhere at the top of the sinewave, the value it will stop at, is the one after next (since we have index+1).

If we now set the percentile difference to small (say +/-0.5%), to overcome the previous problem, then it might be the case that, when the sinewave is close to the x-axis (and the rate of change is larger), it might not find the symmetrical value (because the tolerance we set is too small). An increase in the sampling rate might initially seam to solve the problem close to the x-axis, but will exacerbate the problem at the top of the sinewave.

I have not yet tried your VI’s and in principle they are certainly correct (thats what I asked for).

I have now implemented, a way to do the same thing (or almost the same). I have done this by completely ignoring the values of the voltage sinewave. Instead I look at where the sinewave has maxima and minima and since I know I have 100 point per cycle, I have worked out a relationship between each point and its symmetrical (with respect to its maximum/minimum value). I am assuming here that a point and its symmetrical have the same value, which is not always the case, especially when I might have a THD of around 1-4% in my 50Hz signal.

I will try out your improved VI’s and post my results here.

Again I might be wrong about this.

Thanks again for taking the time to help me.

Regards

Alex

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