Square wave vs Sine wave signals

Thread Starter


Joined Jun 2, 2011
Hi all,

I'm building an ambient light rejection circuit which measures the scattered light from a LED pulse which is driven by a 1kHz square wave.

I don't have a strong signals background, but I was wondering if anyone out there wanted to comment (or could point me to some info) on design considerations when dealing with square wave AC signals over sinusoidal signals.

I'm planning to read the output signal into a ADC when the LED pulse is high. Unfortunately, with the various filters I've used in my circuit the final output is far from a square wave.

I was hoping to implement a way to average ADC samples over the duration of the LED pulse (performed by a uprocessor) but given the non-top hat form of the signal I need to think of a different way to do it. I'm probably going to run the output through a precision rectifier to remove any negative voltages (which occur during the OFF state of the LED). Is there any circuit (perhaps a unique kind of rectifier) that can provide a reasonably constant flat signal for the ADC to sample from?

Any suggestions would be hugely appreciated!

Thanks in advance,



Joined Oct 2, 2009
You can try using a precision rectifier circuit which had been discussed here. Follow this with a low pass filter.


Joined Dec 26, 2010
You would probably want to capture samples from both the high and the low part of the signal, so that you can determine the difference between them. In this way, the responses due to your deliberately emitted signal can be separated from those due to ambient light, dark leakage current in the detector, or amplifier offsets.


Joined Mar 14, 2008
You could amplify the signal with a high-frequency DC coupled (op) amp to preserve preserve the zero volt and high value of the square wave. Then you could sample the data at a high rate (say 10 times the 1kHz frequency or 10kHz). You can then average (filter) the signals digitally using the microprocessor.


Joined Feb 11, 2008
I would take a slightly different approach. AC couple, amplify and clip the incoming signal from the photosensor. A 1kHz notch pass filter may help too. Any presence of a 1kHz signal can be detected in software by the microcontroller doing period analysis.