Optical Communication
Please Log In for full access to the web site.
Note that this link will take you to an external site (https://shimmer.mit.edu) to authenticate, and then you will be redirected back to this page.
Find yourself a buddy for the lab. If you're having trouble finding a buddy, let us know and we can help. You should each complete the lab, building a complete circuit, and we'll do some experiments at various points during the lab that will involve using two setups.
You should ideally pick a buddy who is sitting next to you, not across the aisle (or you can move to make this the case).
When you see the icon throughout the lab, that's an indication that you and your buddy should work together on an experiment. You can, of course, feel free to work together on other parts as well, so long as you each end up with your own working circuit.
Please be a good buddy, stick together and help each other out!
Before building, turn on the scope and let's reset it to all of its defaults by:
- Pushing the "Default Setup" button in the upper left, and
- Under the "Wave Gen" menu (accessible by pushing the button in the bottom right), click the "Settings" button (the bottom one on the screen), then click the "Default Wave Gen" button (the bottom one again) You should get a message on screen saying that things have been reset.
In ancient times, civilizations would warn their citizens about approaching armies by lighting bonfires on mountaintops as a means of communicating across a distance. In this lab, we'll build our own little system for communicating wirelessly as well, but instead of fire we'll use lasers.
By the end of the lab, we'll have a small system capable of sending messages over a distance, which we can use to send and receive messages using a binary encoding scheme. This system will consist of two parts:
- a transmitter, which varies the brightness of a laser light in a predictable pattern to communicate a message, and
- a receiver, which detects those changes in brightness and decodes them to interpret that message.
1) Lights
Since we're going to be building the circuit in two parts, go ahead and grab two breadboards. It probably makes sense to grab one of the half-length breadboards (for the transmitter) and one of the full-length breadboards (for the receiver). You'll also need a Teensy for each one as well.
We'll start with the transmitter, which we can build on the smaller breadboard.
Before we get to building it, though, let's set some groundrules about the lasers. The lasers can cause irritation and/or damage to your eyes if they shine directly on your eyes, so we'll want to be careful about how we're using them and where we're pointing them. We have our lasers on little stands that put the beam at about the right height for our experiments (and safely out of everyone's eyeline):
Make sure that the laser mount is sitting flat on the table whenever you're about to turn the laser on. Always have the laser pointed at a nearby target, and don't bend your head down to that level if the laser is on.
1.1) One More Reminder
ALWAYS PUT THE LASER MOUNT FLAT ON THE TABLE BEFORE TURNING IT ON.
NEVER TURN ON THE LASER UNLESS IT'S DOWN ON THE TABLE AND POINTED AT A NEARBY TARGET.
THE LASER CAN BURN YOUR EYES. DON'T SHINE IT IN YOUR EYES.
DON'T SHINE THE LASER IN YOUR EYES OR ANYONE ELSE'S.
1.2) Time to Build
OK, so time to actually build. Start by flashing the transmitter
program from
this week's code distribution to
the Teensy.
MAKE SURE THE LASER MOUNT IS SITTING FLAT ON THE TABLE and pointing away
from people. Then hook up your laser to the Teensy: the red wire from the laser should be connected to pin 14 of the
Teensy, and the blue wire should be connected to pin G
.
When you've done that, you should see the laser light up, hooray!
It may not look like much, but that light actually has a secret message hidden
in it. We'll talk more about the structure of that message in a little bit,
but for now you can change the contents of the message to something short and
PG-rated by changing the string near the top of the transmitter.ino
file.
But please, keep it short and keep it clean. Note, though, that the system
will only work for strings containing ASCII
Characters; anything not shown in that table will likely cause things to
break.
The goal is for each of you to build a sensor that will detect your own laser light while effectively ignoring your buddy's light. The key here will be for each buddy to set up their laser light to blink at a different frequency.
Choose one buddy to blink at 500Hz, and one to blink at 2200Hz. You should
each adjust the FREQUENCY
variable in your code accordingly (one of you should
set it to 500
and the other to 2200
).
Go ahead and make that change (and change the message if you want), and re-flash the code to the Teensy.
Actually, that's about it for our transmitter (we'll come back to it later, but yeah). So let's go ahead and unplug your computer from this Teensy. When we're ready for it again, you can plug it into the wall using one of the little wall adapters we have on the table at the front of the room (and another USB cable).
2) Picking Up What You're Laying Down
Although the laser looks like it's just shining at a constant brightness, the code on the Teensy is actually varying the brightness of the laser ever-so-slightly in a pattern that corresponds to your chosen message.
We always have some DC voltage across the laser (around 1.65V), which causes it always to be on. But we're also varying that voltage slightly by adding a sine wave (at your chosen frequency) on top of it that we turn on and off. Ultimately, the brightness of the laser is going to look something like this:
Even though the light is always shining, we'll consider this signal to be "on" when the sine wave is there and "off" when it's not. By varying the amount of time that the signal is "on" versus "off" in a predictable pattern, we can communicate a message.
For the rest of the lab, we'll focus on building a circuit for detecting that signal, which we'll call the "receiver." Our goal, ultimately, is to measure the varying brightness of the laser (which will have roughly the shape above) and turn that instead to a clearer depiction of when the signal is "on" versus "off", which the Teensy can then measure in order to decode our message:
2.1) Measuring the Laser Brightness
Our receiver will ultimately be powered by a second Teensy (which is where we'll do the detection), so go ahead and grab one of those and plug it into the long breadboard, and also into your laptop with a USB cable. DO NOT POWER THIS PART FROM THE WALL PLUG. We'll eventually use the Teensy to decode that signal into a sequence of 1's and 0's corresponding to our message. But for now, we won't program it in any particular way; we'll just use it to power the detector for now (code will come later).
There is a lot that we need to do to make our receiver work, but we'll tackle it little-by-little. To start, let's make sure we can actually detect those changes in the laser's brightness.
The centerpiece of our detector circuit will be a solar cell (or a "photovoltaic cell" if you're feeling fancy), which produces a voltage that changes based on the amount of light falling on it. Plug the solar cell into your receiver breadboard, and hook up channel 1 of your scope to measure the voltage drop across it (with + on the yellow wire and - on the brown wire).
Then stand up your solar cell so it's sitting upright. The easiest way to do this is to put the solar cell in the groove in the middle of the breadboard and to use a resistor or something to help prop it up so it stays vertical, like so:
Once you have it standing upright, aim the laser at it (but leave them across the table from each other, at least a foot or two apart). Make sure you're aiming the laser near the center of the solar cell, rather than at the edges.
2.2) Filtering
Probably in the last section, the change in your signal was pretty small, and thus difficult to reliably detect. We'd like to think about amplifying it with an op-amp, but that strategy would have some problems with our current setup (specifically, since the voltage there is big both when our sinusoidal signal is "on" and when it's not, we'd have trouble avoiding the op-amp's power supply limitations). On sunny days, we might also have problems telling our little red light apart from external light sources (for example, the sun, or the overhead lights, or if there are multiple lasers are shining on the source).
Our goal is ultimately to focus the receiver's attention on the laser light we're sending, while ignoring other sources of light that would affect that output voltage (e.g., the sun, the room lights, other people's lasers, etc).
The key to our approach is going to be the fact that the signal of interest here is flickering at a predictable frequency (the frequency you set in the code in the previous section, either 500Hz or 2200Hz). This blinking will allow us to separate the signal from our laser from other noise/interference from other sources using a filter like the ones we've been seeing in class.
How does the output from the solar cell change as the laser shines on it? Can you see the wiggles? What is different if your buddy's light is shined on your detector? What if both lights are on at the same time?
Take a photo of the scope output when both lights are on so we can talk about it during the checkoff.
Now comes the beautiful part: we want to ignore our buddy's light (and the room lights, and the sun, etc) and only focus in on the changes in voltage that result from our laser.
Since the signal we're interested in is blinking at that one frequency, the signal we care about is only at one particular frequency, so we can use a filter to isolate that frequency so that we're not affected by ambient lights, or by other signals operating at different frequencies. This will also help us remove the constant offset in that signal, which will allow us to get a much better look at just what's coming from our transmitter.
We'll build a little band-pass filter to isolate the frequency we're interested in. Our filter will take the following form, which should be familiar from lecture/recitation/psets:
L
, R
, f
, pi
, e
, and/or other constants you need. You can also use sqrt
, ln
, and other similar functions like we've seen before.
C = ~
Gain (in dB) at peak:
We'll also use a 110\Omega resistor for R in the circuit above.
Bandwidth (Hertz):
Go ahead and lay out this circuit on your breadboard with your chosen capacitance (we probably don't have exactly the value you need, but try your best), but for now build it separate from the other pieces including the Teensy so that we can characterize its behavior. That is, connect your R, L, and C together, but don't hook them up to the solar panel or the Teensy or anything.
We'll characterize our filter by running a frequency sweep like we've done before. To do so, hook CH1 up to measure the wave gen (which should be connected across the whole RLC combination), and CH2 measuring the output of your filter. For today, use a frequency range from 10Hz to 200kHz, 500 milliVolts peak-to-peak, and 100 points. Then go ahead and generate the frequency response.
Take a photo of your frequency response so that we can reference it during the checkoff.
Compare your frequency response to your buddy's. What is similar about them, and what is different?
How much will your filter scale your laser voltage by, and how much will it scale your buddy's laser voltage by?
2.3) Putting it Together
We'd ultimately like to use this filter with the solar cell's voltage as its input, producing a new voltage across the resistor that ideally contains only the signal we received from our laser (after heavily attenuating everything else).
The solar cell is a complicated device that we could model as a combination of sources, capacitors, inductors, and/or resistors. For our purposes, though, we'd really like to think of it just as a voltage source, whose voltage varies with the amount of light following on it, without worrying about how the complicated internals of the solar cell interact with the rest of our circuit. And conveniently, we know how to do that by now: we can buffer the solar cell's output.
The next thing we're going to do is to build it, so you may wish to check in
with a staff member before proceeding.
2.4) Build It
Go ahead and lay this out on your board. Today we'll use MCP6002 op-amps; here is the pinout again for reference:
You should power the op-amps with the 5V supply from the Teensy, and make sure that the brown wire of the solar cell is connected to the Teensy's ground (pin G).
Discuss your work so far with a staff member. Be prepared
to discuss your frequency response analysis, how you chose your capacitance
value, and your schematic diagram.
3) Completing The Detector
Remember that our original goal was to measure our laser's varying brightness and turn it into a cleaner signal that the Teensy can measure:
Input:
Desired Output:
We're well on our way here, actually. We've filtered out signals not related to our laser blinking, but we've still got a little way to go in order to make our output look like the desired output shown above.
3.1) Again, A Gain
One issue is that, while the signal coming out of your filter is pretty nice, it is really tiny, probably too small for the Teensy to reliably detect. As such, we're going to want to amplify it substantially. We're going to run the filtered signal through a non-inverting amplifier with a 1{\rm k}\Omega resistor and 750{\rm k}\Omega resistor to make a gain of around 750.
Now build it. Note that the MCP6002 package has two op-amps in it (one on each side), so you should be able to use the same package rather than grabbing another one. When you've hooked that up, measure the amplified signal.
What happens if your buddy shines their light on your solar cell instead? What's similar, and what's different? What if both lights are shining?
4) Flattening the Curve
At this point, we've got a nice output voltage corresponding to the signal from our laser, and it's relatively focused in on that one frequency (so it won't be super affected by ambient light, or other flashing light sources, etc).
But we're not quite done yet. We're ultimately going to want to feed this voltage into our Teensy and be able to tell from one measurement whether the light is on or not. But with how much our signal is oscillating, that makes the Teensy's job hard; because it's oscillating, if we use the Teensy to measure the voltage when the signal is "on", we could either get a high voltage or a really low voltage, depending on the exact time at which the Teensy made its measurement.
So what we'd like to do to help the Teensy out is to build a little circuit to turn the voltage output from our amplifier into a sequence of pulses the Teensy can understand. In particular, we're looking at a signal like the following (where here the signal is "on" for the left half of the graph and "off" for the right half):
What we would ideally like to see, instead, is a DC voltage corresponding to the light being on or not:
We won't be able to achieve that exactly, but we can get close with a circuit like the following:
Measuring the drop across the capacitor should show us a smoother curve.
It's going to be up to you to choose R and C appropriately here. As with most real-world problems, there's no real "right" answer here, but there are principled ways to think about what those values should be. In particular, note that:
- we want to reduce the impact of oscillations at the frequency your lase is flashing at, so that our output doesn't wiggle much when the light is "on", but
- we want to make sure that things don't get too smooth, so that we can still reliably notice the light turning on and off.
Go ahead and measure this output on your scope. If you need to, feel free to adjust your R and C values until you get a pretty smooth signal. It might be OK to have variations of maybe 10-100mV in your signal, but everything will work better the smoother this is (without the different on/off segments bleeding into each other). It's OK to play around a little bit until you're happy with how things are looking (and feel free to ask for help!
How does this signal change as your turn your light on/off? What is different if your buddy's light is shined on your detector? What if both lights are on at the same time?
4.1) Decoding the Message
Great! Now we've got a signal that looks like it's effectively detecing the presence/absence of those wiggles on the laser's brightness. As our last step, we'd like to hook up the Teensy to measure that signal and decode it.
Firstly, using the scope, make a note of the maximum value that your output reaches when the input signal is "on", as well as the value it's sitting at when the signal is "off."
Then take that output and connect it to pin 14 of the Teensy. Change
VOLTAGE_THRESHOLD
in the receiver.ino
code to be a value in between the two
voltages you measured.
As you do so, if everything is working, you should see a little orange light on the Teensy start blinking in a pattern (indicating that the Teensy is successfully seeing that signal), and under Tools -> Serial Monitor, you should see your message start printing out. You might see some garbage printed out at first, but it should eventually turn into your message, which should repeat itself indefinitely.
How does the signal change over time? What is different if your buddy's light is shined on your detector? What if both lights are on at the same time?
If everything is working, your buddy's message should not be detected (and it shouldn't interfere with your signal being decoded properly)
At this point, you should have a working circuit as well as a complete
schematic drawing. Talk through the design decisions you had to make, and
describe the purpose of the various parts of the circuit. When you're done with that, please return the solar cell, op-amps, inductors,
lasers, and breadboards to the table at the front of the room. Also, leave
your Teensy in the breadboard and put it in the box by the table at the front
of the room. We'll take care of removing it. If you have one of the big capacitors, put it back; otherwise, it's fine to
throw them away. And resistors can be thrown away regardless of their value.
Shed a single silent tear for the end of the last 6.200 lab of the semester,
and then discuss all of your results with a staff member.