Phase shift of a sine wave and a square wave

Hi,
I would like to simply compute the phase shift between a sinusoidal waveform and a square one. Between two sin-s I can compute, but I have no idea how to do that with a square waveform.
Thanks,
Ussr123

Hi there,
the easiest way is to use the ExpressVIs.
But you are only allowed to use the ExpressVI "Tone Measurements" if you have enough periods of the square wave, because it computes the phase with FFT.
An other possibility is to use the spectrum analyser VI as used in the attached exsample.
Greetz
Branni
Attachments:
Phaseshift_Sqr_Sin.vi ‏89 KB

Similar Messages

  • Add phase shift to a sine wave

    Hi,
    Can I add a varying phase shift (through a control from front panel) to a sine wave?
    Thanks,
    Sharmi

    Similar to this? That event should be a dial value change but the snippet messed it up
    CLA, LabVIEW Versions 2010-2013
    Attachments:
    shift.png ‏27 KB

  • Calculation of phase shift

    Hi all,
     I am continuously acquiring two sinusoidal signals from the analog inputs of a daq card and saving the samples of the two signals into two different float type arrays. Can anyone tell me that how to calculate the phase shift between these two signals and as well as the peak voltage of the two signals? Please expain me with the help of an example code.
    Thanks

    Hi AI S
    I have gone through the example of phase diff e.g and i have written the following code but when i run it , it gives the max value of 1st sine wave (outarray1) nearly equal (i-e 7.7 volt ) but it should be 8 V pk.
    But for the 2nd sinewave (outarray2) it gives the max value from 0 volt to 1.5 volt pk but it should give 1.5 Volt pk only and the phase difference is displayed as 0.000 , even there is no update in decimals in it.
    One more thing to tell that 1 complete sine wave consists of 1024 samples , therefore in outarray1 and outarray2 , there are 8 cycles each. In one iteration of the loop outarray1 is filled and in other iteration outarray2 is filled , then i calculate the phase shift.  Please tell me what i am doing wrong.
    Here is my code
    double outarray1[8192],outarray2[8192] ;
    double *peakLoc, *peakAmp, *peakDeriv;
        int count;
    static double wave1maxval = 0.0;
    static int wave1maxind = 0;
    static double wave2maxval = 0.0;
    static int wave2maxind = 0;
    static double phasediff;
    PeakDetector (outarray1,8192,0.0, 3, 0, 1, 1, &count, &peakLoc, &peakAmp, &peakDeriv);
        if (count>0)
            wave1maxind = peakLoc[0];
            wave1maxval = peakAmp[0];
     SetCtrlVal(panelHandle,PANEL_wave1maxind, wave1maxind);
     SetCtrlVal(panelHandle,PANEL_wave1maxval, wave1maxval);   
        if (peakLoc)
            FreeAnalysisMem (peakLoc);
        if (peakAmp)
            FreeAnalysisMem (peakAmp);
        if (peakDeriv)
            FreeAnalysisMem (peakDeriv);
        PeakDetector ( outarray2,8192,0.0, 3, 0, 1, 1, &count, &peakLoc, &peakAmp, &peakDeriv);
        if (count>0)
            wave2maxind = peakLoc[0];
            wave2maxval = peakAmp[0];
      SetCtrlVal(panelHandle,PANEL_wave2maxind, wave2maxind);
         SetCtrlVal(panelHandle,PANEL_wave2maxval, wave2maxval);
        if (peakLoc)
            FreeAnalysisMem (peakLoc);
        if (peakAmp)
            FreeAnalysisMem (peakAmp);
        if (peakDeriv)
            FreeAnalysisMem (peakDeriv);
        phasediff = (8/8192) * (wave1maxind - wave2maxind) * 360;
        phasediff = fmod (phasediff, 360);
       SetCtrlVal(panelHandle,PANEL_Phase_Diff,phasediff);

  • Phase shift between a pulse and sin wave

    Hello,
    I was wondering if there is any VI that I can use to get the phase shift between a pulse and a sin wave (they have same frequency).
    The Ideal case is that the pulse should go to 1 when sin wave is positive and goes to 0 when the sin wave is negative. I want to set this test to measure the phase shift between pulse going to one and sin wave going positive.
    We just bought labview full version with Signal processing package, and I was wondering if there is anything that would be useful for me.
    Thanks in advance,
    Baran.

    Hi Baran,
    Try this on for size and see if it works for you.
    Have a great day,
    Chris V
    Applications Engineer
    National Instruments
    Attachments:
    Phase Difference.vi ‏22 KB

  • How to dynamically adjust Frequency, Phase and Amplitude for a Generated Sine Wave in C/C++?

    Hi,
    I wonder if anybody know how to dynamically adjust Frequency, Phase and Amplitude for a Generated Sine Wave in C/C++? This is a part of my project: I need to dynamically generate a sine wave voltage signal by some calculation using the data from a simultaneous analog input and another signal.
    Your help will be appreciated so much!
    Marlon

    Hello Marlon,
    Here is an example of changing frequency and ampliude for an E-series device in Labwindows/CVI. The programming should be similar in C for your S-Series device. As is says on the linked webpage above, this process is going to be very processor intensive since you will continually be creating a buffer.
    Nicholas C
    National Instruments
    Applications Engineering

  • How to generate 3 phase sine wave to output on ELVIS

    Hi .I need to make a star or delta connected circuit on ELVIS board.2 make this circuit I need 3 wave generator( with 120 phase shift) and one common ground
    and because the ELVIS function generator can only generate one wave I decided to generate countionuos sine wave in Labview.
    Now I can generate 2 continuis sine wave in labview and output them on the analog outputs of ELVIS.Ao-0 and A0-1
    but I dont know what to do for the third signal.the elvis board just has 2 analouge output and when I use  Ao-0 and A0-1 I cant use ELVIS function generator after that.so would u please help me on this problem.how can I output 3 contious sine wave in Elvis.I have attached my VI to this post
    Attachments:
    new.vi ‏38 KB

    Hi, I am also having some problem in generating two signals from two AO. Could you please tell me how to generate two different signals from two AO. I have attached vi which generate square wave from one AO 0. I need the inverted signal in AO 1. 
    Attachments:
    Pulse Width Modulation.vi ‏48 KB

  • Measuring lag between input and output sine waves...

    Hi,
    I am using a Labview VI to control an array of servo motors, each receiving a sine wave input (with different phase offsets for each servo). I'm using a NI USB-6229 DAQ system to monitor their movement via a wire that I've soldered onto each servo's potentiometer. I've written another VI that recieves both the initial sent signal and the returned DAQ signal and plots both on a waveform chart. Both signals show up on the plot as expected, with an obvious phase shift between them. I'm having problems accurately measuring the phase shift, and I'd rather have an automatic method that gives accurate numerical values instead of a more qualitative visual method.
    So far I've tried to use triggers and peak to peak comparisons, but I've been having problems getting results in real time. My incoming signals are time stamped, if that helps. Is there a quick and easy method to extract phase shift data from two sine waves on a waveform chart?
    Thanks for the help...

    Since I work with lock-in amplifiers I came up with this. I guess it will work in your case. This method has some limitations. It will work up to 180 degree. It also measure absolute phase lag. You can not say if the signal is leading or lagging. But in your case it will always be lagging. I posted a VI showing the method in another discussion. Here is the link. http://forums.ni.com/ni/attachments/ni/170/409516/1/demo_v2.vi. Since your DAQ unit do not have simultaneous sampling you will get a small phase error due to inter-channel delay. This is also true if you use the FFT method. What is your signal frequency and which samplerate do you use?
    Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
    (Sorry no Labview "brag list" so far)

  • Distance measurement using Ultrasonic sensors and phase shift method

    Hi, 
    I've recently started a project where the idea is that we have an ultrasonic transmitter and a receiver. The transmitter will send out a signal at 40 kHz that will hit some object, most likely a book, and reflect that signal to the receiver. The received signal should have a phase difference from the outgoing signal. Now, when we vary the outgoing signal, the phase shift should also change. Likewise, if we vary the distance to the object, the number of wavelengths that can fit in between the object and the transducers should also change. We would multiply the incoming and outgoing signals and measure the beat signal, but I'm not sure how we would do this in labVIEW. We can calculate the distance to the object by figuring out what d(phase)/d(frequency) is. So far,when I am having problems with actually getting an incoming signal and figuring what that phase shift is. I'm not sure how I could use simulate signal to accuately and precisely send out a 40 kHz sine wave, and then vary that signal by steps of 1 Hz. I have also tried using a signal generator, and having once BNC cable go to the input of the transmitter and the other going to input of the DAQ. I have another BNC cable going from the output of the receiver to the input of the DAQ. I had multiple channels on my DAQ, and used split signals to see the transmitted and received signal. But this doesn't seem to be working. I also tried to add gain to the received signal, but when adding an Op-Amp LF356 to the receiver, the signal completely disappears. Attached are some of the VI's I have, but none of them seem to be working. Thanks in advance for any help. 
    Attachments:
    Latest version of final.vi ‏64 KB
    Draft for final project.vi ‏89 KB

    Have you done the basic physics and mathematics? For the speed of sound = 343 m/s and the frequency = 40 kHz the wavelength is 8.6 mm. At 40.001 kHz the wavelength is 214 nm shorter.
    So, how do you propose to keep track of the number of wavelegnths if the target moves more than 8.6 mm?
    To measure a phase shift you must have some kind of reference. Typically a fraction of the transmitted signal is used as a reference.  Since you probably do not know how much phase shift occurs in the power amplifier driving the transmitter or between the electrical signal at the transducer and the acoustic signal in air, it is usually best to measure both, ideally with the same receiver and amplifiers.
    The LF356 should be good for modest amounts of gain. The transducers can look like a capacitance to the circuits. Do you have a DC offset which is saturating the amplifier?
    Lynn

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

    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
    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
    Solved!
    Go to Solution.

    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.
    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.
    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
    Attachments:
    FinalShockSpeed.vi ‏55 KB

  • How can I calculate the frequency of a 2-4Hz three phase sine wave in 50msec?

    I want to calculate the frequency of a sine wave using either all three phases or just one, but I want to know the frequency after 50 msec, I don't want to have to wait for a full period.

    I have a mathematically sound suggestion but I do not know how well it will work in application. Most period measurements measure the time between a full period or several periods to eliminate the error introduced by the measuring device. Essentially the device error is made insignificant.
    Mathematically you can do much more but there is a tradeoff between recording less information and knowing (or assuming) some values. For instance, if one knew the amplitude and could calculate the derivative of the signal, one could calculate the frequency. A sine wave can be represented by the function: A sin (BX)=C , where A is the amplitude, B is the frequency, C is the present measured value. If the equation is solved for X, we get: X=(sin^(-1)(C/A))/B. The d
    erivative of the first equation is AB cos(BX)=C. If the equation for X is now substituted into the second equation, we get, AB cos(B (sin^(-1)(C/A))/B)=C. Solving for B we get B=C/(A cos(sin^(-1)(C/A))). Remember, we already know A and C, so we are done.
    Practically every step and assumption in the above argument introduces possible error which will affect the accuracy of the frequency. Unfortunately it is a trade off and that is why at least a whole period needs to be measured to get an accurate frequency.
    Jeremy Braden
    National Instruments

  • How to change the phase by 90 deg of a sine wave

    Hi
    Does any one know how to change the phase of a sine wave by 90 degrees.
    Mal

    Hi Malkoba,
    Thank you for your post.
    Having looked at your VI I can say that you have created the correct inputs to the 'Sine Waveform.vi'.
    However the dial you had created had no affect as it was not wired into it the 'Sine Waveform.vi' on the block diagram.To fix the problem I have wired the 'Phase' dial into the 'phase' terminal of the waveform generator. This now changes the phase of the sine wave during runtime.
    The dial also now has a digital display (numeric box below it)- this can be used to read the dial's value, or feed in specific values into the control.
    Please find a modified version of your VI below.
    Regards,
    Field Sales Engineer | National Instruments | UK & Ireland
    Attachments:
    NI_phase shift sine.vi ‏31 KB

  • Best fit lines for loops and sine waves

    I am trying to find a best fit line that will work for sine waves and loops (hysteresis loops). I can get the sine wave just fine, but when I switch to a hysteresis it just puts a line across the middle (I assume because of the 2 y values for every x). I am doing data acquisition that will take in both forms and graph them. I tried a polynomial fit and it doesn't work at least the way I implemented it and I tried a few others but it looks like they are all function based. Also, my y values are coming out of a Bessel filter. I don't think this would be affecting anything but I thought I would put it in here incase it does.
    Did I miss one that I haven't tried that works for my application?
    Thanks
    Patrick

    RiversDaddy wrote:
    ... currently I am doing it by looping and reducing the error towards zero to fit the amplitude and phase. (I know the frequency).  If this is what you are looking to do then I will help, or should I be doing things differently? All of the functions I have found to filter or extract tones seem to introduce a larger frequency of phase error than i get using this method, but am I missing something?
    "looping" is a bit vague. What is the actual algorithm to find better estimates (e.g. levenberg marquardt, etc.)
    What problems did you have with extract single tone. Can you show some data where the results from it are not good?
    LabVIEW Champion . Do more with less code and in less time .

  • Creating and controlling a sine wave

    I am a TA for Control Systems & Instrumentation at Texas State University. As the assistant I am required to assist students in their homeworks and projects. I have encountered a problem in assisting the students. How do I create a Sine Wave wit ha sampling frequency of 200 Hz? Obtain the power spectrum of the signal and change the sine wave frequency to 25 Hz. Determine if the resulting frequency is about the Nyquist frequency. Then increase the sine wave to 125 Hz and compare to the Nyquist frequency again.

    There is an example shipped with LabVIEW 2009 called "Resampling a Waveform (continuous).vi" I think this vi will demonstrate what you are trying to do. Change the sine wave frequency using the frequency control in the Test Signals (A) box and change the sampling frequency by updating the output rate control in the Output timing box. You will then see the original waveform spectrum at the original sampling rate (Fs) and the re-sampled spectrum will be shown in red so you can see the shift.
    Systems Test Engineer
    Certified LabVIEW Architect (CLA)

  • How to measure relative phase of several sine wave inputs

    I'm using a USB-6229 to acquire 10 sine waves, and I would like to output their rms amplitudes and relative phases.  The rms amplitude is not a problem, but I wasn't sure how to go about determining the phase of one signal relative to another.  Do I need to use the Frequency Response analysis step?  Thanks.

    Hi,
    There are some functions you can use to measure the relative phase. You can either measure the phase of every signal related to another one using like you said: a frequency response function step. Using one of these to functions might do the job: “Frequency Response, Express VI” or “Frequency Response Function (Mag-Phase).vi, if you are working in LabVIEW. The first one of these functions "Frequency Response" is also found in signal express and is the one I think you are refering to.
    Although this functions is use for a stimulus response approach they will give you the relative phase of Y with respect to X, “Typically, time signal X is the stimulus, and time signal Y is the response of the system.  in signal express your options is the frequency response step.
    I would also like to point you to some references that might serve you as reference when doing spectrum analysis: An Overview of Frequency-Domain Measurements and FFT Analysis.
    Message Edited by Jaime F on 02-06-2008 11:42 AM
    Jaime Hoffiz
    National Instruments
    Product Expert
    Digital Multimeters and LCR Meters
    Attachments:
    frf.png ‏37 KB

  • How to generating three phase sine wave simutiously with Vistual C++?

    Here I want to generate three phase sinewave at the same time with the phase angel 120 continiously. I can creat a task that contain 3 AOs, and generate 3 same sine wave at the same time. But I can not create 3 individual task which contains one AO channel, and write data to FIFO. Please tell me how to realize it?

    Hello, Rilee,
    Thank you very you very much. But I am still confused. The website I can not open. As you said, I shall create a data array to contain three phase data, for example, sinedata[750], sinedata[0:249] contains first AO, and sinedata[250:499] the second, and the rest is the third. then
    1. send the data for sinedata[0] to sinedata[249], to the board. with DAQmxWriteAnalogF64;
    2. send the data for sinedata[250] to sinedata[499], to the board. with DAQmxWriteAnalogF64;
    3. send the data for sinedata[500] to sinedata[749], to the board. with DAQmxWriteAnalogF64;
    and or so.
    Is all the above description right?
    Here I have several questions:
    1. When shall I send second section sample data? I think it shall be all the first data have been written to the board. And How can I know that all the first section data have been sent to the buffer?
    2. If I call DAQmxWriteAnalogF64 to write the second section data to buffer after the have finished first section data written, will this function affects the wave of the first section data?

Maybe you are looking for

  • Create a structure based on Selection option field values?

    Hi Guys,              can anybody tell me is ther anyway to creat a strucitre after giving the values to selection screen .I have a req where fiscal period is entered based on this i have to create a structure suppose i he give 3 to 8 then i have to

  • Invoking web service in workflow

    I have an identity seeding workflow that involves creating an account in the Service Center, after creating the LH account. There is no resource defined in idm for Service Center, but it is called using web services and there is a wsdl for that. I ne

  • I get message "your Ipod is not compatible with attached accessory"

    I recently purchased a Belkin TuneBase FM for iPod to use in my car as a mount, FM transmitter, and car charger. After installing it into my car's power outlet and inserting my Ipod Video into it, I get the message "your Ipod is not compatible with t

  • VER_ERROR when accessing Users tool

    I'm using the Solaris Management Console 2.1 and I trying to access the list of users under "System Configuration". When I try to open it though I get the following error message: The "Users" application is not able to connect to the server. Reason V

  • SCOM 2012 r2 - Add GW Sitename on a later stage

    Hi, Does anyone know how to add sitename to a spesific Gateway server without rerunning the Microsoft.EnterpriseManagement.GatewayApproval.exe tool? regards, lostcase