Ambient light rejection circuit don't reject it very well - Page 1
Forum section: electronics / beginners

author: Artlav
author_rank: Frequent Contributor
timestamp: April 14, 2019, 07:29:11 pm
content: I've been trying to design a slightly-better-than trivial "UART over laser pointers" circuit, and this is what i ended up with:Ideally, this should remove the ambient light from the signal.The photodiode's pre-amplified output is split in two, one side is fed through an RC filter and a buffer producing what is essentially the average DC level of the ambient light.So far so good.This average level is then subtracted from the actual signal by a differential amplifier, and the remaining "useful signal" is amplified and thresholded to produce the 0-1 a computer can digest.And here comes the problem - above a certain ambient light level the output of IC2B starts tracking the brightness rather than subtracting it completely.It looks like a rising sheet of paper covering the signal rather than the signal getting shifted up along with a zero point.I've tried to vary R6-R9 values, the higher they are the more light it takes for it to start rising, but the less sensitive it becomes. 100k seem to be the optimal value.Other than that nothing i tried made any difference.I suspect the problem comes down to some case of "real op-amps don't work like ideal op-amps", but i don't know enough about it to even know where to start looking for the problem.So, the question is - is this a workable design, and in either case what am i doing wrong?

author: Benta
author_rank: Super Contributor
timestamp: April 14, 2019, 07:44:53 pm
content: For this kind of circuit, you normally have two photodiodes. One for receiving and one for measuring ambient light to compensate.

author: pwlps
author_rank: Frequent Contributor
timestamp: April 14, 2019, 08:05:15 pm
content: If the DC part is much bigger than the AC part then you are sensitive to the "real" stuff like opamp offsets, resistor mismatch etc.On the other hand, since subtracting the DC part will yield the AC part, the AC part can be obtained simply with a high-pass filter. Of course then you have a to shift your signal level to the 0-5 V range, this can be done with a comparator (a comparator with an open-collector output like the LM311 can do it without any additional components).BTW. I'm using exactly this approach in this similar project:https://www.eevblog.com/forum/projects/simple-lifi-transmitting-audio-signal-with-a-led/msg2282771/#msg2282771Edit:Your lowpass transfer function is 1/(1+jwR1C1), after the differentiating opamp IC2B the transfer function becomes1-1/(1+jwR1C1)=R1/(R1+1/jwC1) which is a high-pass made with R1 and C1. So IC2B is useless, just invert R1 and C1. Did I miss something here?

author: Artlav
author_rank: Frequent Contributor
timestamp: April 14, 2019, 10:23:05 pm
content: Quote from: Benta on April 14, 2019, 07:44:53 pmI feel like this will only make things worse, since every slight difference between them would be severely amplified.Quote from: pwlps on April 14, 2019, 08:05:15 pmYep, the whole idea is to not have to deal with AC-only nature of high pass filter, but rather have a regular OOK signal with ambient level removed.

author: David Hess
author_rank: Super Contributor
timestamp: April 14, 2019, 11:14:36 pm
content: Reject the ambient signal by driving a current back into the input of the photodiode amplifier as shown in figure 4 of thisBurr-Brown datasheet.

author: Artlav
author_rank: Frequent Contributor
timestamp: April 15, 2019, 02:01:10 am
content: Quote from: David Hess on April 14, 2019, 11:14:36 pmThat looks interesting. Is there a way to make it work from a single supply?

author: pwlps
author_rank: Frequent Contributor
timestamp: April 15, 2019, 06:31:40 am
content: Quote from: David Hess on April 14, 2019, 11:14:36 pmDriving a current back is only to protect the transimpedance from saturating (but this is apparently not the problem here), otherwise this circuit is equivalent to a transimpedance+highpass.

author: pwlps
author_rank: Frequent Contributor
timestamp: April 15, 2019, 07:05:10 am
content: Quote from: Artlav on April 14, 2019, 10:23:05 pmOk, but with the values of R6-R9 given on the schematics your circuit IS actually a highpass, albeit constructed in a complicated way.So on what basis you want to distinguish between the DC parts of the ambient background and of the signal ?Moreover they are not truly DC: the ambient light may vary slowly (can also have 50 / 60 / 100 / 120 Hz lighting components) and the DC part of the OOK signal will vary according to the number of 0's and 1's in the data byte. You need some clever low-frequency discrimination. Even then it is not simple because the spectrum of the OOK signal may extend to arbitrary low freqs (consider the first byte after a long pause, or a long sequence of 1's). I don't think this is a workable design, at least in real conditions where the ambient light may vary.Note also that high-gain DC amplification is more difficult than AC. In DC you will need to carefully balance all opamp offsets, whereas in AC you can use capacitive coupling between stages and don't care about offsets. This is why different data coding schemes used for long distance transmissions are usually designed so as to not to contain any information-carrying DC component. For example with some carrier modulation, or Manchester coding, to not to rely on any DC components.

author: nali
author_rank: Frequent Contributor
timestamp: April 15, 2019, 08:58:02 am
content: Check the datasheet for your LM324 for output voltage swing, if you're only running it on a single 3V3 supply you'll be running out of headroom. E.g. the first datasheet hit on Google (TI) says output swing to Vcc - 1.5V so you'll be topping out at 1.8V.

author: hamster_nz
author_rank: Super Contributor
timestamp: April 15, 2019, 09:45:16 am
content: Have you tried a coding system that can be AC coupled?8b/10b comes to mind - it is pretty easy to implement and is pretty much the industry standard.Maybe a variant of Manchester encoding could work too.

author: David Hess
author_rank: Super Contributor
timestamp: April 16, 2019, 01:32:02 am
content: Quote from: pwlps on April 15, 2019, 06:31:40 amThis idea is more common with instrumentation and difference amplifiers where it allows a high-pass response without compromising the common mode rejection of the amplifier but I knew it was also used with photodiode amplifiers to reject ambient light so that is the example I gave.Of course it results in an AC coupled response. But because the feedback is to the input of the first amplifier, it prevents that amplifier from saturating due to ambient lighting. Rejecting the ambient lighting is the whole point.

author: pwlps
author_rank: Frequent Contributor
timestamp: April 16, 2019, 03:12:26 pm
content: Quote from: hamster_nz on April 15, 2019, 09:45:16 amFor Manchester encoding it is possible to do it in the software, without any specialized IC, coding the data bytes in such a way that a standard RS232 UART will be able to send/receive it as a normal data stream :http://www.quickbuilder.co.uk/qb/articles/Manchester_encoding_using_RS232.pdf