07-17-2006 11:46 AM
07-18-2006 01:14 AM
Hi Tyler,
I don't know exactly wich txype of signal do you have (sinusoidal + DC offset?).
Anyway for a similar problem (phase difference between two sinusoidal waveforms), I used the "CrossPowerSpectrum" function to find the amplitude and phase of each harmonic component, then the "PeakDetector" function to find the higher harmonic value.
The phase difference (phDiff) is expressed in degrees; NUM_VALUES is the buffer length of my measurements (wave1, wave2).
The code is like this:
static double mag[NUM_VALUES/2],ph[NUM_VALUES/2],dt;
static double *pkloc = NULL,*pkamp = NULL,*pksec = NULL;
err = CrossPowerSpectrum(wave1, wave2, NUM_VALUES, 1.0, &mag[0], &ph[0], &dt);
if(err == 0){
err = PeakDetector(mag, NUM_VALUES/2, LEVEL, 3, 0, 1, 1, &count, &pkloc, &pkamp, &pksec);
if(err == 0){
i = RoundRealToNearestInteger(pkloc[0]);
if(i >= 0)
phDiff = RadToDeg(ph[i]); // = ph[i]*180.0/Pi();
}
}
The LEVEL constant on PeakDetector is used to reject peaks too small.You can use the same code, or modify it according your specific input data.
07-18-2006 01:24 AM
Sorry, just an additional remark.
Your board is not simultaneous sampling, so you will always find a phase error due the lag between 2 consecutive measurements.
07-18-2006 11:35 AM
07-19-2006 02:08 AM
Hi ScKaSx,
the delay between two measurements is given by
1) the DAQ card choosen (6024E is a 200kS/s, so at least 5 microseconds between 2 measurements)
2) the number of channels used (i.e if you acquire channel 0,1 and 2, the delay between 0 and 2 will be larger (the double) than between 0 and 1
I have no experience with the 6024 card, so I suggest you to apply the same signal on two inputs, and determine the phase difference with the code posted. Convert the error from degrees to time, to identify the delay of your board.
After that, it is up to you to determine if the 6024 board is suitable for your application. If you continue to use the 6024, you can modify your code to substact the error.
Till now, in my applications, I never used simultaneous sampling boards. In one application I used a 6025 to acquire 16 analog inputs (some DC, some 50Hz+harmonics), but I didn't need phase difference on these signals.
regards
baloss
07-19-2006 09:31 AM - edited 07-19-2006 09:31 AM
Message Edited by Neil S. on 07-19-2006 09:31 AM
07-19-2006 10:55 AM
07-20-2006 01:15 AM
Hello ScKaSx,
about your signal with DC offset, I think the best solution is to acquire the signal in differential mode.
Maybe your detector (transducer?) has an output with the reference voltage used (5V). In this case you can simply use this output as an input for differential amplifier.
I see 2 other methods:
1) build a dedicated HW: filter your signal to determine DC component, then substract (op-amp) the signal with the filtered signal.
2) use an analog output to generate a suitable DC offset (5V), and use this output for differential analog input (input +, your signal; input -, analog output)
The first method require external HW and a large filter.
The second one maybe don't have the necessary accuracy, and require a dedicated algorithm if your DC offset vary into time...
Anyway, it is only an idea: I never tried it... but I am curious to know if you find the solution to fix this issue.
Regards
baloss