I agree with Marc. I'm presently doing this using the delays in the XOR. As a frequency doubler and 4 XOR's. Also, you can use the Dallas Semiconductor DS1010-400 and maybe the DS1012. Another way that I've done it is by building up a "phase shifer". This is an analog approach using a center tapped transformer and a RC combination. By varying R the phase can be adusted to anything one wants. David ----- Original Message ----- From: Marc To: Sent: Monday, May 31, 1999 1:58 PM Subject: Re: [OT] Phase delay of square wave > > I'm looking for a means of phase shifting a square wave clock pulse by > > 90 degrees. > > > > ______ ______ > > | | | | > > | | | | > > ---- ---- ---- > > ______ _____ > > | | | | > > | | | | > > ---- ---- ---- > > One possible way (not necessarily the easiest) is to: > > 1) differentiate the signal by XORing each port reading with the previous > one: > > > || || || || > || || || || > ---- ------ --- ----- ---- > > 2) low-pass filter this new signal. If it is of unknown and variable > frequency, the easiest way is to: > > a) count the number of samples between two 1s (= period) > > b) output 1/2 that many samples of 1, and 1/2 that many as 0. > > That effectively does generate a new waveform with the desired property: > > ___ __ ___ __ > | | | | | | | | > | | | | | | | | > ---- --- -- ---- --- > > Wow, you have doubled the frequency! > > 3) XOR the output of 2) with the original input: > _____ ______ > | | | | > | | | | > -------- ----- ---- > > > That's it!! You have shifted phase by 90 degree - on any single frequency > input - no matter which frequency (as long as it is substantially lower > than your sample rate). > > Your example waveform is a good example: it is not a pure "square sinus" :) > All frequency deviations were preserved during the processing, and the > output is a 90 degree shift, as good as the ASCII art resolution can > get. > > > Make sure that you read the port only ONCE per sample, and use the buffered > values for processing. If you read it twice and the calculations base on > two versions of it, the output might become flickery.. >