# How to generate a sine wave that is in phase with a generated square wave at 1MHz for lock-in amplifier?

I am building a lock in amplifier (LIA) for fluorescence lifetime measurement using off the shelf components, after going through literature, I have decided to use square wave for excitation of the fluorescence sample and a sine wave for demodulation (or lock in). This choice of excitation waveform and demodulation waveform was based on Philip and Carlsson 2003 J. Opt. Soc. Am. ML Meade's classic on LIA and other resources like Synchronous Detectors Facilitate Precision Low-Level Measurements

Not thinking of using a PLL to generate the sine wave exactly in phase with the square wave since it will just increase the complexity of the project (doing this as my bachelor thesis)

Thinking of using a signal generator for the square wave, unfortunately the signal generator that is available in my college can only generate one waveform at a time. Even if I build a nice oscillator circuit for the sine wave, how do I make it exactly in phase with the sqaure wave?

I know that we can use a Schmitt trigger for a sine wave to sqaure wave, is there a similar circuit for square to sine?

Just generate a sinewave as your reference signal and derive the squarewave from that. As you've already mentioned, this is easily done with a comparator / Schmitt trigger.

• OMG thanks ( I am so daft) Commented Nov 18, 2023 at 14:10

I know that we can use a schmitt trigger for a sine wave to sqaure wave

... and the problem with that is?

This is the simplest and best solution to your requirement. Low component count, precise waveforms, easy to make and verify.

How pure do you want this sinewave to be?

You could get a sinewave from a square wave simply by filtering out the harmonics. However, the filter will generate some phase shift. You could play with filter designs to control the phase shift, perhaps put stopband zeroes at the harmonics, but, how much time and effort do you want to put in here?

If instead your filter is two or 4 successive integrators, then you know the phase shift will be exactly 180 or 360 degrees. Two integrators will give you about 4% 3rd hamronic distortion or -28dBc, four integrators will give 0.4% distortion or -47 dBc.

A fun circuit I use and recommend for precise sinewave generation is based on a ring counter with weighted resistive output taps. This Q/A concerns making three phase waveforms, but hey, you could just make one.

• Oh my god, I am so daft, thank you so much, I didnt realise that I could just use schmitt trigger ( I was thinking of getting sqaure wave from signall generator to excite fluorescence sample, and then generate sinewave to demodulate, I didn't realise I could generate sqaure wave from the sine wave and then use the same sine wave for demodulation) Commented Nov 18, 2023 at 14:10
• I want the sinewave as pure as possible to avoid unnescessary demodulation of harmonics, and noise getting demodulated, and since the phase difference will be used for measuring the lifetime I ruled out filtering the square wave, will look into the sinewave generation circuit you have linked. Thanks a lot! Commented Nov 18, 2023 at 14:23
• @PranavAgumbe 'as pure as possible' is not a specification. Do you want 1% distortion, 0.1%, or 0.01%? The difference is cost and effort. From what I thought I knew about lock-in amplifiers, the reference signal does not have to be a pure sinewave??? It's just that if it isn't, then it will also demodulate some harmonics. Do you have non-linearities in the experiment that generate harmonics of uncontrolled phase that you need to reject. Commented Nov 18, 2023 at 16:28
• I'm confused about that, using a square for both exciation and demodulation leads to demodulation of all the harmonics to DC, but if either of the signal is a sine wave then then the demodulated otuput moves to odd harmonics. The square is composed of infinite sine waves, I don't understand how one demodulates all to DC and other to odd harmonic frequencies. I did the maths for the case of both square waves but the algebra got too messy and led to nowhere, but managed to do it for the case of one of the wave being sinewave and I understood why it demodulates to odd harmonics. Commented Nov 18, 2023 at 20:41