If you generate a squarewave at twice the final frequency, then divide this by two using flip-flops into two channels, the first triggered on the rising edge and the second on the falling (i.e. use an inverter), then the two channels will be at the required frequency and separated by 90 degrees. Accuracy will depend on the original squarewave mark:space and any unequal propagation delays but should be OK over a wide frequency range. (An equal mark:space squarewave could be produced by initial generation at 4 x the required freq.. followed by a divide by 2) Richard ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Swichtec Power Systems Limited, | Phone: (++64) 3 343-3314 39 Princess St, PO Box 11-188, | Fax: (++64) 3 348-8871 Christchurch, New Zealand. | Email: rprosser@swichtec.co.nz Visit us at http://www.swichtec.co.nz +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -----Original Message----- From: Wagner Lipnharski [mailto:wagnerl@EARTHLINK.NET] Sent: Friday, May 21, 1999 1:50 PM To: PICLIST@MITVMA.MIT.EDU Subject: Re: [OT] Phase delay of square wave If the square wave frequency is fixed, a delay chip would do it. If the frequency is variable then you need to use a tricky thing: Integrate the square wave in two capacitors, using two resistors, one for each capacitor in a traditional R+C configuration. RC #1 would integrate some voltage and RC #2 would do the same but with a voltage that is exactly hald the voltage from RC #1. This is easy to do with a double value capacitor or resistor. RC #2 (half voltage) should load a small capacitor via a diode. This capacitor voltage would be almost precisely half of the RC#1 integrated peak voltage. With some exercises you can eliminate RC#2 and use a voltage divider from RC#1. Using the comparator function of the operational amplifier or a LM339, when RC#1 integrated voltage goes higher than the voltage on the small capacitor loaded by RC#1 and the diode, it means the RC#1 integrating voltage ramp is (more or less) in the middle time, so aprox at 90¡. When RC#1 deintegrating voltage ramp goes less than the small capacitor voltage, it is aprox at 270¡, so the output of the comparator would be your 90¡ delayed square pulse. A small trimpot adjustment could be done to locate exactly the 90¡ position, and it should be almost the same for different frequencies. It should not work pretty well with square waves with dutty cycle different than 50%. Frequency changes should not influence the result of this circuit, except for the RC constant, so the frequency should change inside a specific range. As more linear the RC#1 ramp, the better the accuracy of the 90¡. A microcontroller timming measuring circuit is the best solution for that, so it can calculate the exact half up or down period of the square wave. But you have max frequencies based on the microcontroller capacity of time measurements. -------------------------------------------------------- Wagner Lipnharski - UST Research Inc. - Orlando, Florida Forum and microcontroller web site: http://www.ustr.net Microcontrollers Survey: http://www.ustr.net/tellme.htm