Bit Banging with a pair of photoresistors (LDR's)

I have a question for all you bright minds out there.

Recently, I saw a children's educational toy that advertised its ability to be re-programmed by holding it to the television.

I imagine that the toy has some sort of optical detector and some good old fashioned bit bashing is occurring between the tv and the toy.

Curious to see if this is something I could integrate into a 5x6 led matrix that I am developing as a gift, I set out to create a working example.

Using two photo resistors (LDR's), one for clock the other for data, and some custom written javascript, I have been able to successfully transmit the message 'Hello World' in binary. I visit the site I built on my phone and then after initiating the message, I hold the phone to the photo resistors until the transmission ends.

The logistics of it are simple. When the clock goes from low to high, the data line is read. If the clock holds low with data high for a set period, it is interpreted as a reset.

My question to your bright minds is this:

Are LDR's the best piece of hardware for this project? My current speed limit seems to be about 10 bits a second; I am starting to believe that the limiting factor may be the LDR's.

Has anyone seen this type of project in the past? I tried searching but I may have the wrong term.

Thanks everyone for your constant enthusiasm and support. The Arduino forums are a great place to spend time!

-Miles

Cadmium sulphide LDRs are notoriously slow to respond. Photodiodes are generally much quicker.

Thank you very much!

I had a pair of photo-diodes in my parts drawer so I just rigged up a quick test. The response is very much faster but it seems that my readings are a little noisy.

I have one pin of the diodes connected to 5v, the other pin is connected to an analog pin and also to ground through a 47k resistor.

I will experiment with different resistor values and perhaps add a trim pot. Is there a better technique for utilizing photo-diodes?

Thanks again!

-Miles

The response is very much faster but it seems that my readings are a little noisy.

How little - one bit? You could take multiple readings and take the average …

float LDR = 0;
for (int i=0; i<5; i++) LDR += analogRead(A0);
LDR /= 5;

or a running average:

float alpha = 0.9;
float LDR = alpha * analogRead(A0) + (1-alpha) * LDR;

I would suggest you investigate Bi-phase data modulation/demodulation. In short it's away to combine both data and clock into a single signal. It's the way pretty much every computer used to read and write data to cassette tape. The other conspicuous example is ADB or Apple Desktop Bus on Macintosh machines with ADB. I've got a few circuits in some old issues of Byte magazine around here somewhere I could dig up. On Mac's with ADB they used T2 on the 6522 VIA chip to generate the timing.

Here is the Rockwell example from way back when http://www.classiccmp.org/cini/pdf/Rockwell/r6500hw4.pdf

Also the other example is the way Apple II's implemented "soft sectoring" on 5 1/4" floppy disks.

If there is programming getting done @25 or 30 fps on a TV this would be the most obvious way to do it.

Robtillaart,

Thank you for the averaging code sample though I hesitate to go that route for fear smoothing over the peak of the clock flashes. I have tested the photo-diodes in a controlled light environment and I notice that the output does not level at a value, rather, it fluctuates to within 10 points of the middle value at an even rate. Almost like a sine wave…

I have no delay between sampling. Could one reading be interfering with the next?

I am also going to try some power conditioning to see if that might help.

Cyberteque,

THANK YOU BIG TIME! You are helping point me down a very interesting path, albeit slightly over my head. Once I solve the issue of transmitting the data, I will start to work on increasing the speed of the transmission. It sounds like the Bi-phase data modulation/demodulation might be one solution. I would prefer to tackle this in software rather than introduce additional hardware but I am always interested in learning options.

Thanks everyone!

-Miles

No problem! The circuit for combining clock and data is pretty simple, just a few nand gates and a shift register from memory, the receiver is as easy with only a 74LS121 mono-stable and a few nand gates, 74LS00's and a shift register.

It's less involved than building a UART from scratch, which isn't that had. If you embed the clock with the data, you don't have to worry about the 1 1/2 stop bits of asynchronous serial.