LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to measure time difference between zero crossing of a sine wave and rise time of a pulse on a same graph?

Solved!
Go to solution

I have a 50Hz sine wave and a pulse signal on a same graph. The phase difference between two is between 0-90 degrees.

Now I need to calculate the time difference between (when the sine wave crosses zero volts) and (when the pulse rises). The frequency will stay approximately same for both signals.

The application is for a three phase generator. In simple words, when the time difference between the zero-crossing of sine wave and the pulse rises increases, that means that the load on the generator has increases.

 

I am a beginner user of LabView (version 9, 2009), maybe it is a very simple problem but I've been pulling my hair out for the last few days and coudln't figure anything out. Any help would be greatly appreciated. I am using DAQ USB-6008 to measure these voltages and pulse from the generator and a sensor

 

I have attached a jpg (a graph that i just made with excel to explain). The time 't' is what I am trying to measure

Capture123.JPG 

 

Cheers

 

Awais 

Message Edited by awais.h on 03-30-2010 11:20 PM
Message Edited by awais.h on 03-30-2010 11:21 PM
0 Kudos
Message 1 of 11
(9,657 Views)
Solution
Accepted by topic author awais.h

awais.h,

 

 For problems like this I recommend starting by writing down the granular steps you would take to solve this problem manually.  You can't tell LabVIEW (or any programming language) what to do if you can't concisely describe the solution to your problem.

 

The way I'd approach this problem is to:

 

  1. find all of the zero crossings and rising edges
  2. for each rising edge find the difference between it's timestamp and the preceding zero crossing

 

 Here's a LabVIEW implementation of that algorithm:

 

vi_snippet.png

Message 2 of 11
(9,625 Views)

Thank you very much Simon.

 

It wasn't as easy as I thought it would be. This is just one of the building blocks of my system.

 

You are right. I should get myself familiarized with all the functions first so that I can tell LabView what to do.

 

Can I please get the *.vi file of the image that you posted. It would be great help for me to understand how you implemented arrays and loops.

 

Many Thanks,

 

Awais 

 

 

0 Kudos
Message 3 of 11
(9,591 Views)

Hi Awais,

 

You mentioned that you were using LabVIEW 2009.  One of the great, user-friendly features of LabVIEW 2009 is the VI Snippet.  You can tell an image is a snippet by the dashed border and icon legend at the top.  Drag and drop and you'll be good to go!

Regards,


h_baker
National Instruments
Applications Engineer
0 Kudos
Message 4 of 11
(9,569 Views)
Thanks h_baker Smiley Happy
0 Kudos
Message 5 of 11
(9,545 Views)

Hi

 

I am trying to do something similar but with different input signals. The signals come from two different transducers that will show a fast and significant change in pressure rather quickly. I would like to get the time difference 't' in between the two spikes.

 

Picture1.jpg

 

can some slight modifications to the code posted do this for me?

 

thx

0 Kudos
Message 6 of 11
(9,512 Views)

You can try searching your data arrays for a y-value.  I converted the precision to one decimal point for the comparision because the likelihood of both arrays having a value of 1.0000, for example, is slim.  If the value is not listed in either array, then the Search 1D Array function will return a -1.  

 

Hopefully this helps! 

 

 

dt.png

Regards,


h_baker
National Instruments
Applications Engineer
0 Kudos
Message 7 of 11
(9,470 Views)

Hi

Thanks for the code but I'm afraid it won't work. Like you said the probability of choosing a value that is on both graphs may not happen. This is something that I would like the code to do automatically.

 

But I did use the previous code posted and made some modifications to it and it seems to work perfectly. Now the next thing is to be able to get just that one value that tells you the first time difference.

Here is what I get using that code.

 

FrontPanel.PNG

 

As you can see from the t Values. I only need the one that is highlighted. If there is a way to filter out the rest it would be great.

 

I was thinking of a while loop and as soon as the value is higher than 3E-5 it would store the number and stop the loop, but I'm not too familiar with arrays in labview.

 

Here is the the code modified.

snippet.png

 

As you can see, it wasn't that big of a modification and it still is your code.

I will keep trying.

Thanks for the help

0 Kudos
Message 8 of 11
(9,461 Views)

Hi Oscar,

It looks like in your program you are comparing each point in the plot to .07 and logging the timestamp if it is above. Alternatively you could log the timestamp if the difference from one point to the next is larger than some threshold value. This would indicate a sharp rise in your input signal and should capture your rising edges. Then you can take the difference of those time stamps and get your difference in time between the two rises.

Algorithim.png

Matt
Applications Engineer
National Instruments
0 Kudos
Message 9 of 11
(9,439 Views)

Hi

 

Thanks for the code. I just had a couple of questions about it.

 

Is the slope threshold the difference in one array element to the next array element?

 

Second, why are the two for loops different? one uses the slope threshold and the other has a reference?

 

Thrid, what is the reference?

 

Thanks

 

0 Kudos
Message 10 of 11
(9,427 Views)