![]() | ![]() | ![]() |
| | #1 |
|
Hello friends, I am stuck with a problem and will kindly appreciate any help on this. I have got two TTL signals ranging from 500 Hz to 10kHz. I am trying to measure the delay of one with reference to other. As the signals can be of any frequency I am not sure how to use CCP for this task. I have searched a few topics on here but couldn't find anything appropriate. I am a newbie and wold really appreciate any help. Thank you all in advance bjox | |
| |
| | #2 |
|
Presumably the two frequencies are identical?, otherwise it wouldn't be possible. If you XOR the signals together, this will give you a pulse representing the phase difference between them. | |
| |
| | #3 | ||
|
Hi Nigel, Thank you for the reply. Quote:
Quote:
Thanks in advance Nigel. -I am pretty much new to the electronics Last edited by bjox1; 8th March 2008 at 03:45 AM. | |||
| |
| | #4 |
|
Have a read of this thread. For some reason the OP has deleted his initial question but he basically wanted to find the phase difference between two signals. Mike. | |
| |
| | #5 |
|
Hey Pommie, Thanks for the thread. I had a look at it and it seems a gr8 technique. The only concern is whether I could measure the phase at different freq?? I mean will it work if the signals are at 9.9kHz or in the second case if the signals are at 990Hz?? Please enlighten me! Thanks. | |
| |
| | #6 |
|
If you use a 20MHz crystal then you will be able to measure 2μS periods. It really depends how accurate you want it. Mike. Last edited by Pommie; 8th March 2008 at 09:49 AM. | |
| |
| | #7 | |
| Quote:
All you need to know is that an XOR gate sets the output HIGH, when the two inputs are DIFFERENT, if the two inputs are the same, them the output is LOW. So get a sheet of graph paper, draw your two input waves on it above each other, then follow the rules above to draw the output waveform below them. Do this for various phase differences, this should make it all clear. | ||
| |
| | #8 | |
|
Hi Pommie and Nigel, Quote:
For 1kHz signals- 10us*100 is 1ms i.e. 100 is the max value therefore 3.6 deg for every counter. & for example for 10kHz signals- 10us*10 will be 100us i.e. 36 deg for every counter. So I was wondering if I could eliminate this error or probably a technique which is independent of the signal frequency? Hi Nigel, I am sorry for asking this again but I am kind of struggling in analysing the XOR technique [probably because Im in my first year ]. If you see the diagram I have attached, if the second signal is say 50 deg lag, and if I feed these two signals to XOR gate, then one signal will be high and the other will be low and the output from XOR will be high all the time. I don't know how can I find the phase difference from there? I apologise if I ask a bit too much basics. Thanks again. Last edited by bjox1; 8th March 2008 at 01:17 PM. | ||
| |
| | #9 |
|
Your diagram clearly shows a time when one is HIGH and one is LOW, when both are HIGH, and when both are LOW, bear in mind to have a phase difference you can measure both waves must be exactly the same frequency.
| |
| |
| | #10 | |
| Quote:
I am so so sorry but please enlighten me. I think my brain hates me! Thanks Nigel. | ||
| |
| | #11 |
|
Like I said, draw a diagram - it's easy - heres an example, top two are the two input waveforms, bottom one the output from an XOR. The bottom waveform is a direct representation of the phase difference.
| |
| |
| | #12 | |
| Quote:
I am so so thankful to you for explaining this to me in such a detail. As u have suggested me to draw a few cases, I have attached a diagram where I have assumed two cases of delayed signal [named as signal2]. As far as I could imagine [I might be wrong] that if we take a reference point on signal [signal1] on the rising edge of the pulse, the delay signal will possibly have the two cases: 1) if signal2 arrives as low = that means 0-180 deg delay & 2) if signal2 arrives as high = that means the delay signal [signal2]has crossed the 0-180 deg of delay range and now it's in 180-360 deg range. In the attached diagram, I have taken two such cases, one for 10 deg delay and second one is for 350 deg delay and I have found out that the output pulse from XOR gate has the same pulse width. Now that implies that for any delay value [in deg] between 0-180 [say 'x'] will have the same value for the signal with a delay of 360-x deg[ In my case,10 deg will be same as 360-10 =350 deg]. I am all confused about how to calculate the phase on these cases?? I apologise Nigel if I have over thought it but I would really appreciate any further help on this matter. Thank you soo soo much . Ps: I apologise if the diagrams are not upto the scale. Last edited by bjox1; 8th March 2008 at 07:36 PM. | ||
| |
| | #13 |
|
You are correct, 10 degrees and 350 degrees will read the same, because they are the same - are you needing to know which leads or lags as well?. Perhaps you might try telling us exactly what you are trying to do?. | |
| |
| | #14 | ||
| Quote:
Sorry about the late reply. Well I am at Uni [first year] and this task is a part of our module. There are a few circuits given by technician which introduce delay [0-360 deg]. So we have same signals [same freq at a given time] but one is ref and the other signal goes through these circuits which introduce resp delay. As I mentioned earlier, I have to measure the phase diff but the freq can range from 500Hz to 10kHz. Quote:
Is it still possible to achieve 0-360 phase measurement using XOR technique?? Thanks once again Nigel. Last edited by bjox1; 8th March 2008 at 11:38 PM. | |||
| |
| | #15 |
|
As the signal always lags, detect the start of the reference pulse, then start counting while you wait for the start of the following pulse.
| |
| |
|
| Tags |
| ccp |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| CCP (compare mode) | crys | Robotics Chat | 3 | 17th February 2008 12:33 PM |
| stepper motor with 16f876a | jay543_uk | Micro Controllers | 10 | 8th February 2008 09:05 PM |
| Pic 16f876a Prog. Problem | JEFFxxx | Micro Controllers | 9 | 5th October 2006 10:45 PM |
| 16F876A | YAN-1 | Micro Controllers | 1 | 14th December 2005 09:56 AM |
| PWM module in the 16F876A | YAN-1 | Micro Controllers | 3 | 23rd May 2005 01:08 AM |