Jump to content

phase difference between two signals...


Recommended Posts

Hello Guys,

I am kindof new here, and I am trying to find some help with my project. I am a masters student at a German University and working with OPC UA labview toolkit and with signal analysis and data sampling specifically. I created a sine signal at my OPC UA server and I am reading that signal at my OPC UA client. I plotted the signal  at both , the server and at the client. My task now is to compare the two signals and make sure that the data is transfered as fast as possible so when I am sampling I wont miss any data.

I am attaching my files here, where you can see what did I write so far. I need help comparing the two waveforms. The waveform at the client might start at different timing, so maybe we need to offset it to the same time as the other waveform in order to compare? And I am thinking that the comparision should be in a separate VI.

I want to compare the signals according to sampling frequency and phase difference as a start, then later i'll try to compare according to period, wavelength, noise...But for now if most important for me the sampling frequency and phase difference.

So I am considering the signal generated at the server is IDEAL and I'll compare the signal at the client to it. And I need to measure the %error between them.

Please excuse my level of programming. Any help would be highly appreciated.

Thank you.

ELias

Serverwaveform.vi

clientWaveform.vi

Link to comment

I'm not sure what you're trying to do, but some commentary on OPC...

OPC is great until you want to do something that requires timing of faster than, oh, 30 seconds.OLE (OPC = OLE for Process Control) runs at the lowest priority possible in Windows. As such, anything and everything can keep OPC communication from occurring. I personally have had communication go dead for about 10 seconds on multiple test stands using RSLinx, Siemens Profibus card (has OPC server) and Kepware. OPC is best used when notification of an event is not time critical such as a light indicating motor on status at the other end of a building.

Link to comment

Hi,

I currently don't have LabVIEW 2015 so I can't open your VIs, I'm afraid.

 

12 hours ago, pato7 said:

I created a sine signal at my OPC UA server and I am reading that signal at my OPC UA client. I plotted the signal  at both , the server and at the client. My task now is to compare the two signals and make sure that the data is transfered as fast as possible so when I am sampling I wont miss any data.

Were you required to use OPC UA, or did you choose it yourself?

If you want to make sure that you don't lose any data, then I don't think OPC UA is the best solution. Have a look at lossless streaming instead: http://www.ni.com/white-paper/12267/en/

 

24 minutes ago, Tim_S said:

OPC is great until you want to do something that requires timing of faster than, oh, 30 seconds.OLE (OPC = OLE for Process Control) runs at the lowest priority possible in Windows.

@pato7 is talking about OPC UA, which is a complete revamp and does not use OLE: http://www.ni.com/white-paper/13843/en/

Link to comment
23 minutes ago, JKSH said:

 

@pato7 is talking about OPC UA, which is a complete revamp and does not use OLE: http://www.ni.com/white-paper/13843/en/

OK, I see where there are improvements; the link is appreciated. I was trying to figure out if the protocol could still be going through low-priority layers or have other delays and found a Wiki article that provides general overview of the protocol. The use of TCP as an option would address the issues I've had with OPC.

Link to comment

Thank you guys for your replies. 

@hooovahh Sorry but I believed the title of this post is "phase difference betwwen two signals" and my major question was how to measure the difference between two signals.

22 hours ago, JKSH said:

Were you required to use OPC UA, or did you choose it yourself?

You can find attached the same files saved as labview V14. The idea is that its required from me to work with OPC UA labview. So regardless how fast it is , I am supposed to test its limitations and compare the results when the OPC UA server was faster or slower and try to find methods for using it in "fast as possible" mode.So for now, I need to compare the waveforms and check how much is the % error between the waveform generated at the server and the one read at the client.

But since there is time difference between the two waveforms. I need to compare them in a separet VI. And should calculate the offset in order to make for that time difference and be able to compare the two signals. Comparison according to (Sampling rate, frequency, phase difference, noise)

If you are not able to run the OPC UA VIs incase you don't have the OPC UA toolkit. My question would be the same as how to compare these two normal waveforms that are generated each in a separate VI.

Thank you.

 

 

Serverwaveform.vi

clientWaveform.vi

Edited by pato7
Link to comment
12 hours ago, pato7 said:

@hooovahh Sorry but I believed the title of this post is "phase difference betwwen two signals" and my major question was how to measure the difference between two signals.

If you want to change the title, click "Edit".

 

12 hours ago, pato7 said:

The idea is that its required from me to work with OPC UA labview. So regardless how fast it is , I am supposed to test its limitations and compare the results when the OPC UA server was faster or slower and try to find methods for using it in "fast as possible" mode.So for now, I need to compare the waveforms and check how much is the % error between the waveform generated at the server and the one read at the client.

But since there is time difference between the two waveforms. I need to compare them in a separet VI. And should calculate the offset in order to make for that time difference and be able to compare the two signals. Comparison according to (Sampling rate, frequency, phase difference, noise)

If you are not able to run the OPC UA VIs incase you don't have the OPC UA toolkit. My question would be the same as how to compare these two normal waveforms that are generated each in a separate VI.

I still don't fully understand what you want to do. You've said you want two things:

  1. Test the limitations of OPC UA
  2. "Compare" 2 waveforms in terms of sampling rate, frequency, phase difference, and noise.

These 2 things are completely separate. Please tell us which one is your most important goal: #1 or #2?

If I show you an easier way to test the limitations of OPC UA without using waveforms, then do you still want to know how to compare waveforms?

Link to comment
5 hours ago, JKSH said:

These 2 things are completely separate. Please tell us which one is your most important goal: #1 or #2?

My priority now is to find out how to compare the waveforms. Finding out the limits is one of the side goals for now. Because I would still want to use the waveform comparison to study the behavior of the server/client as I speed up or slow down the server. I presume the easier way might be useful for me for later tasks, but for now I need to figure out the waveform comparison issue...

Link to comment

Hmm, using an asynchronous protocol like OPC UA for things like phase shift calculation is already your first problem. OPC UA at least in single update mode (it may have also streaming modes but I don't think they are exposed in LabVIEW at all if they even exist) has absolutely no synchronisation between the sender and receiver nor between the two channels. It's a publish-subscriber system where the sender publishes the data to be read by the receiver when it suits him. So the actual relation between the two signals and between sender and receiver in terms of timing is at best uncertain. That makes phase shift analysis between two signals about as reliable as measuring voltage with your finger tips!

You should really look at a different protocol where the two channels are transmitted synchronously (that means over a network almost always together in the same data stream and in streaming mode so that the time information is inherent in the data stream. Otherwise you just see some random phase shifts that have more to do with the reliability of your network and the OPC UA stack than anything in your actual signals unless your signal has a frequency of not more than a few mHz, then the accuracy of the network and protocol are probably enough to allow you at least some estimation of phase shift between the signals.

Link to comment
8 minutes ago, rolfk said:

Hmm, using an asynchronous protocol like OPC UA for things like phase shift calculation is already your first problem. OPC UA at least in single update mode (it may have also streaming modes but I don't think they are exposed in LabVIEW at all if they even exist) has absolutely no synchronisation between the sender and receiver nor between the two channels. It's a publish-subscriber system where the sender publishes the data to be read by the receiver when it suits him. So the actual relation between the two signals and between sender and receiver in terms of timing is at best uncertain. That makes phase shift analysis between two signals about as reliable as measuring voltage with your finger tips!

Hello, thanks for your reply. But I was thinking of a way where I don't use the OPC UA for calculation of the phase shift... like if I can save the waveforms in somewhere and then compare them in a separate VI which doesnt use the OPC UA server directly. 

So may I ask if in another case for example where OPC UA is not used to generate the signals, but we have two random sine waveforms generated each from a separate VI. How do we compare them in this case?

In my case, I have the same signal source placed at the OPC UA server and I want to measure the difference between the waveform generated at the server and that read at the client. So I am treating them as two separate waveforms. But my problem is that the waveform at the client doesnt have the same start time as the one a the server.

Did I make my idea clearer now?  The thing is that it's required from me to use OPC UA protocol.

Link to comment

 

3 hours ago, pato7 said:

Did I make my idea clearer now?  The thing is that it's required from me to use OPC UA protocol.

Please forgive me if I've misunderstood you, but I feel that you are presenting an XY Problem here (see http://xyproblem.info/ )

To help us identify how to help you properly, please describe your project in more detail. Specifically:

  • What is the name of your project? (If your project doesn't have a name, tell us the name of your unit/subject/course)
  • Why are you required to use OPC UA? What does your professor want you to learn? (This really doesn't make sense to me, because OPC UA is not really designed for transferring waveforms)
  • Why do you want to run the server "as fast as possible"?

 

On 5/13/2016 at 10:11 AM, pato7 said:

My task now is to compare the two signals and make sure that the data is transfered as fast as possible so when I am sampling I wont miss any data.

Who does the sampling? The server or the client?

 

On 5/14/2016 at 9:24 PM, pato7 said:

But since there is time difference between the two waveforms. I need to compare them in a separet VI. And should calculate the offset in order to make for that time difference and be able to compare the two signals. Comparison according to (Sampling rate, frequency, phase difference, noise)

The time difference and phase difference is mainly due to the lag in transferring the data from your server to your client, right? Are you interested in measuring that lag?

Sampling rate is only relevant when you convert a physical (real) signal to a digital signal. OPC UA only transmits digital data; it does not do any conversion.

Why do you think there will be noise or change in frequency? OPC UA transmits digital data. As long as the client doesn't lose any part of the data, the data will be received perfectly at the other side, without noise.

 

On 5/13/2016 at 10:11 AM, pato7 said:

So I am considering the signal generated at the server is IDEAL and I'll compare the signal at the client to it. And I need to measure the %error between them.

4 hours ago, pato7 said:

So may I ask if... we have two random sine waveforms generated each from a separate VI. How do we compare them in this case?

You need 3 things:

  1. First, you must make sure you understand the types of comparisons that you want to do. This is the theory you learn from your professor and/or your textbooks.
  2. Next, you must identify algorithm for performing your comparisons. There might already be an algorithm available in your textbooks, or you might need to think of one, or you might be able to ask someone who knows.
  3. Finally, you must write a program that uses that algorithm to perform your comparisons.

 

We can help you with #3 quite easily (after you finish #1 and #2), but I'm not sure if we can help you with #1.

Forget about LabVIEW programming for now. Consider these sine waves:

 

4a70b49b-2eec-4a83-8781-4e8ae0793b88.png

 

What kind of comparisons do you want to do on them? Which differences are you interested in?

  • Like 1
Link to comment

Well. you are sending a waveform as a block (array) of data which has a fixed dt so you need to know the start time, Prepend the date/time to your double array and read it the other end to set your x axis start. You can then compare that value with the time you received it to get a rough latency of transmission.

Edited by ShaunR
  • Like 1
Link to comment
  • 4 weeks later...

Leave it to the RF guy to whip out the DSP.

The easy way to compare the phase of two sinusoid of the same frequency. 

Multiply the signal by another sine of the same frequency at 0deg phase and in parallel multiply it by another sine of same frequency at 90deg phase. Take the average of both of those signal into a re/im to polar, snag out the phase value and convert to degrees. 

Do that to the other signal as well and find the difference between the signals 

That is the easiest way to get what you want and is very immune to noise. 

I'm about to board a plane otherwise I'd attach the example. 

Link to comment
17 hours ago, Norm Kirchner said:

See image and attached code.

This works great for simple signals and when you know the frequency of the signals coming in.

If you don't know this or the signals coming in aren't simple sinusoids, then the game changes a bit.

I thought I would start with this though.

Good luck,
Norm

@Norm Kirchner Thank you so much I'll try to integrate that in my code.

Thank you guys for all the help over here. highly appreciated. 

Link to comment
  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.