Tranfering Data Through Light
Tranfering Data Through Light
0
MAY 31, 2014
RYAN SUAREZ
CALIFORNIA POLYTECHNIC STATE UNIVERSITY, SAN LUIS OBISPO
SENIOR PROJECT SPRING 2014
CONTENTS
Data Transfer using light................................................................................................................................ 2
Introduction .............................................................................................................................................. 2
Scope ..................................................................................................................................................... 2
Timeline................................................................................................................................................. 2
HIGH Level Overview................................................................................................................................. 3
Block Diagram ....................................................................................................................................... 3
Transmitter Flow Chart.......................................................................................................................... 4
Receiver FLOW CHART .......................................................................................................................... 5
Timing Diagram For Transmitter ........................................................................................................... 6
Implementation ........................................................................................................................................ 6
Materials and Supplies .......................................................................................................................... 6
Transmitter Electrical Schematic ........................................................................................................... 6
Receiver Electrical Schematic ................................................................................................................ 7
LCD Screen Wiring Schematic ............................................................................................................... 7
Programming the Arduinos ................................................................................................................... 8
Conclusion ................................................................................................................................................. 9
Project Summary ................................................................................................................................... 9
Project Expansions ................................................................................................................................ 9
Source code ............................................................................................................................................. 10
Transmitter .......................................................................................................................................... 10
Receiver ............................................................................................................................................... 13
Every Light Bulb”. In the video, Haas describes how an LED can strobe faster than the human eye can
detect. He also discusses the widespread use of light bulbs through the current infrastructure of the
world. Given these two topics, he argues that everyday ordinary light bulbs can be exchanged for a
data transmitting LED infrastructure. This change would allow for more efficient, reliable, and secure
data transmission.
SCOPE
The scope of this project is to be a proof of concept for Haas’s idea of LED data transmission.
The project seeks to answer the question: Is it possible to strobe an LED faster than the human eye can
detect and still maintain a reliable data connection? In order to test these requirements there will be
two circuits: a transmitter and a receiver. The transmitter will send reliable packets and the receiver
will accept and decode the packets – displaying the encoded message on a LCD screen.
TIMELINE
FIGURE 1 TIMELINE The expected timeline and milestones to complete for this project.
FIGURE 2 HIGH LEVEL BLOCK DIAGRAM Process flow at its highest Level
FIGURE 3 TRANSMITTER FLOW CHART Chart displaying the order of operations for the transmitter
FIGURE 4 RECEIVER FLOW CHART Chart displaying the order of operations for the receiver
FIGURE 5 SAMPLE TIMING DIAGRAM Timing Diagram for sending 0x65 (‘e’)
IMPLEMENTATION
MATERIALS AND SUPPLIES
2x Arduino Uno R3 (Atmega328)
1x OP955 P-N Photodiode
2x C503C-WAN-CBADB151 Cool White LED
1x 1602A LCD 16x2 Display
1x 10Ω - 5MΩ Potentiometer
1x 10kΩ Resistor
1x 100kΩ Resistor
1x 510kΩ Resistor
Arduino IDE (http://arduino.cc/en/main/software)
NOTE: This circuit will output to PIN2 from only a single Arduino board. It will be a completely separate
circuit entirely from the Transmitter which will be attached to the first Arduino board.
LCD SCREEN WIRING SCHEMATIC
around light bulbs with this new LED data transfer technology. While his dream is still years away, this
project demonstrates that it is entirely possible to have a network set up based solely around light
transfer.
This project was very limited in funding. As a result, the serial data transfer was not as quick or
efficient as it could have been. However, given that it was a proof of concept the project was a success.
The transmitter was capable of sending reliable data through an LED faster than the human eye can
detect. The receiver was also capable of receiving and interpreting this data correctly.
PROJECT EXPANSIONS
If this project were funded, it could easily be expanded upon by upgrading the hardware. The
Arduino Uno R3 has a 16MHz clock which translates into a period of 62.5 ns. The LED and photodiode
have switching speeds of about 5ns each. The Arduino board could be upgraded to have a processor
with a much higher clock speed. The LEDs and Photodiodes used in the experiment and are very
generic. There are more expensive options that are optimized for high switching speeds.
Another possibility that is well beyond the scope and budget of this project is to have data be
transmitted and received in parallel. Different data could be sent using different wavelengths of light
asynchronously and received using a spectrometer. Since white is the usual color of light emitted from
light bulbs and white light is actually made up of all the different wavelengths of light the same idea of
this replacing a normal every day light bulb is not only possible but would be the optimum solution.
byte byteReceived = 0;
int bitsReceived = 0;
void setup()
{
pinMode(ledPin, HIGH);
pinMode(inputPin, INPUT);
Serial.begin(9600);
}
packet[data.length()] = 0;
packet[data.length() + 1] = 0;
packet[data.length() + 2] = 0;
unsigned short checksum = (in_cksum((unsigned short *)packet,
sizeof(packet)));
memcpy(packet + strlen(packet) + 1, &checksum, 2);
sendPacket(packet, sizeof(packet));
}
}
digitalWrite(ledPin, LOW);
if (byteToSend & 0x01)
delayMicroseconds(DELAY_HIGH);
else
delayMicroseconds(DELAY_LOW);
byteToSend >>= 1;
Serial.print("X");
}
Serial.println();
digitalWrite(ledPin, HIGH);
}
/*
* in_cksum --
* Checksum routine for Internet Protocol family headers (C Version)
/*
* Our algorithm is simple, using a 32 bit accumulator (sum), we add
* sequential 16 bit words to it, and at the end, fold back all the
* carry bits from the top 16 bits into the lower 16 bits.
*/
while (nleft > 1) {
sum += *w++;
nleft -= 2;
}
void setup()
{
// Set up the digital pin 2 to an Interrupt and Pin 4 to an Output
lcd.begin(16, 2);
lcd.print("Welcome!");
pinMode(ledOut, OUTPUT);
pinMode(2, INPUT);
Serial.begin(9600);
//Attach the interrupt to the input pin and monitor for ANY Change
attachInterrupt(pbIn, stateChange, FALLING);
}
char receivedCharacter = 0;
int bitsReceived = 0;
int endOfPacket = 0;
String packet;
void loop()
{
// Check first to see that we have a bit ready to be received.
if (bitReady == 1) {
bitReady = 0;
delayMicroseconds(DELAY_MIDDLE);
state = digitalRead(2);
receivedCharacter <<= 1;
receivedCharacter |= state;
bitsReceived++;
// Proper casting.
char *packetArray = (char *)packetArrayTemp;
unsigned char *u_packetArray = (unsigned char *) packetArrayTemp;
// Clear LCD > Write last packet to top > get ready to write to
bottom.
lcd.clear();
lcd.setCursor(0,0);
lcd.print(previousPacket);
lcd.setCursor(0,1);
previousPacket = "";
while (packetArray[i] != 0)
{
previousPacket += packetArray[i];
lcd.print(packetArray[i++]);
}
previousPacket = packetArray;
packet = String("");
endOfPacket = 0;
}
// This is the ISR. Will change bit ready when it senses the LED is off.
void stateChange()
{
bitReady = 1;
}
/*
* in_cksum --
* Checksum routine for Internet Protocol family headers (C Version)
*/
unsigned short in_cksum(unsigned short *addr,int len)
{
register int sum = 0;
unsigned short answer = 0;
register unsigned short *w = addr;
register int nleft = len;
/*
* Our algorithm is simple, using a 32 bit accumulator (sum), we add
* sequential 16 bit words to it, and at the end, fold back all the
* carry bits from the top 16 bits into the lower 16 bits.
*/
while (nleft > 1) {
sum += *w++;
nleft -= 2;
}