Im working on a VLC project where Ill need to transmit encoded data through an LED using an Arduino board to a photodiode receiver that somehow demodulates the signal and extracts the data. Im looking for a transmission rate of atleast 1Kbps where anything higher is bonus points. The problem is there will be ambient light present and my LED cant be a distinct red or green color to resemble a common lighting fixture. So one solution Im considering is to modulate the LED at two set frequencies, say 30kHz and 35kHz, where and connect the photodiode to a bandpass filter designed for 35kHz so that the output of the filter is a logic one when my LED is modulated at 35kHz and a logic 0 when its mod at 30kHz(this is simplified, id do something where a logic 1 is a certain duration of 35 followed by a certain duration of 30). Pretty much this idea is modeled from the NEC protocol used for remote controls. Id like to know if this setup would work before I start putting it together as I cant find any simulator that reasonably simulates LED/Photodiode interactions. Also, since im a beginner and im sure you all have wonderful ideas, is there anything I can do better or differently? Any input would be golden!
Your research has pointed to methods used by TV remotes, which have refined data transmission that is robust. A visible-LED link has little optical difference from the infra-red optical link universally used by all remotes. Perhaps some research into those excellent IR-remote receiver chips would be time well-spent. Vishay describe internals in a bit more detail in this note:circuit description of IR receiver remote
Too bad that those IR-remote receiver chips are all optically opaque to visible light (they only accept infra-red wavelengths longer than about 750nm). This optical filter is the only reason why these chips can't be used with a visible red LED light source.
Your proposal of alternating between 30-35 Khz. modulation is also a reasonable approach. A photodetector, bandpass filter, limiter, into a PLL detector like LM567 or 4046 could process the received signal. In the presence of no signal, you're likely to get garbage data, so a data protocol with checksum or CRC packets would be appropriate. Here's an idea for optical receiver "front-end" that could feed the PLL demodulator...
If you can, choose a high-efficiency RED led (not green) that has tight beam width like 8 degrees or less, with clear (not diffused) plastic lens. You'll have to point it fairly carefully at the receiving photodetector. You can easily modulate this LED with a 30/35 KHz. square wave from a digital source.
Silicon phototransistors have best efficiency for infrared, but still detect visible RED light sufficiently well, but not so much GREEN light from your LED. A standard clear-lens phototransistor could be used, with a tuned load comprising a L-C tuned circuit (tuned to 33KHz.). A large bias resistor (3.3MEGohm) helps improve AC response at 33KHz. Ambient room light provides additional bias too. Loaded Q of the L-C bandpass should be less than ten for your application.
Im considering is to modulate the LED at two set frequencies, say 30kHz and 35kHz, where and connect the photodiode to a bandpass filter designed for 35kHz so that the output of the filter is a logic one when my LED is modulated at 35kHz and a logic 0 when its mod at 30kHz
You could save power by simply turning the LED off altogether to transmit a 0, rather than transmit a signal and throw it away at the receiver.
Or ou could improve the effective SNR if you use a receiver that can detect both 30 and 35 kHz, but can tell the difference between them.
If you can manage to correctly modulate and demodulate the signal, you shouldn't have much of a problem. Infrared LED-Photodiode pairs help reduce interference, especially if you chose them so that one emits at peak sensibility of the other. Also, if you use some kind of amplifier for the photodiode signal, make sure to stabilize the system, as they tend to oscillate if not carefully implemented (particularly at ever higher frequencies, when the gain starts to roll off).
An alternate approach to this problem is to read in analog data and do the processing in the digital domain.
Using a technique like cross-correlation would probably work well, it might be a bit overkill for this application but should be fairly robust. The typical way to apply this would be to subtract the result of two cross correlations, and using a single cycle of the two frequencies as the windows for the two cross correlations. (this could also easily be expanded to recognize more frequencies or patterns for more complex encoding)
If you really want "visible" light communication, you just need a good enough photodetector. I have used a few photodiodes which work reasonably well even at 9600 baud (I was using UART as my modulator/demodulator). The receiver circuit used was a transimpedance amplifier to get a voltage waveform from the photodiode current, followed by a comparator. You would only need a bright enough LED to increase the range. I had to set the comparator threshold manually but you could implement automatic gain control to overcome that issue.
One very simple filtering method is to cover your sensor with tinted plastic (If you are using Red LEDs, cover your sensor with green and blue filters). You are effectively bandpass-filtering the light signal. On the circuit, if you are working with a data rate of 10kHz then a passive RC highpass filter to block out 50Hz/60Hz noise should be enough. Because if you think about it, ambient light is either from the sun/DC source like a torch i.e. its DC or from a mains-powered light source i.e. its at 50Hz/60Hz wave. A high pass filter should do the trick of removing noise.
When I did design and build a similar system (well, simple pulsing ("0-1-0...etc") of the transmitter, nothing more) back when dinosaurs roamed the earth, I found a 25mm diameter piece of matt black plastic pipe, maybe 50mm-75mm long, with the transmit and receive devices at the far ends of these short tubes, solved all of the problems I had with the electronics picking up stray input from daylight or artificial lighting.
Before an editor leaps to delete this, I suggest that this is the epitome of an electronics answer because at one "blow" my bits of plastic pipe filtered out every unwanted source of electromagnetic interference sufficiently. Perfect solution. Just don't point the receiver at the window or the light fittings.
A short piece of pipe in my case also determined the amount of freedom in the overall electronic design. And isn't all electronics tailored specifically to the environment it is to be used in? A chunk of pipe determines the electronics - everything normal here...
Why did I use the pipe shield on the transmitter? Solely because of the specific requirements of that particular installation. I wouldn't have bothered with a transmitter pipe shield in many other circumstances.