Projects

  • Travis

Circuits Class: Laser Harp

Background:

During my sophomore year, I took a class at Hopkins called "Mastering Electronics." I personally think that this is a pretty exaggerated name for a class that's essentially just basic circuits.

For our final project, we were allowed to create anything we wanted to as long as it included subcircuits that we learned about during the semester. I decided to create a "Laser Harp" (it's not as cool as it sounds).


The user can break any of the four different laser beams to play four different notes. The player can also block any combination of those beams to play a frequency that is in between those two notes.


Video:

You can skip to 4:35 to see the "demo". It sounds pretty bad but that's mainly because it's using a really cheap speaker that I found laying around in lab that isn't meant to play real music. People normally use these speakers as either a beeper or to play those 8-bit tunes like the old NES Super Mario Bros theme.

Further, I didn't try to make it play sounds that are the same frequency as musical notes (I could have tried to do this by changing the resistors around the square wave generator) because either way it would have sounded bad due to the poor quality speaker.

How It Works:

Laser Diodes

First we have a very basic circuit of four 5V laser diodes in parallel. These laser diodes were mounted such that the laser beam hit four photoresistors on the opposing side.

These photoresistors have a resistance of around 1.3 KOhms when the lasers were directly hitting them and a resistance of around 100 KOhms when the laser beam is blocked and there's just ambient light. Using the photoresistors as a voltage divider, I connected the photoresistors to the base of the NPN transistors (Q1-Q4). Therefore, when a laser beam is broken the connected transistor goes into active mode and lets current flow from its collector to its emitter. By breaking the beams at different points and letting varying amounts of ambient light into the photoresistor, the current going through the transistors changes which also changes the frequency of the wave below.


When the beams aren't blocked, the voltage at the base of transistor is equal to about 0.154V which is less than the cut-off voltage of the transistors at 0.7V so no current flows.

Using a simple op-amp, this circuit creates a square wave generator. By changing the resistances between In(-) and Vout (ie. Resistors R3-R7), different frequency square waves can be created at the point labelled ToneGenOut. When there’s high resistance (like the connection of the 9.8K resistor to the 220K resistor), the frequency is higher than when the there’s a lower resistance (ie. the connection of the 9.8K resistor to the 19.7K resistor). When A1 is not connected to anything, there is no tone generated. When the transistors from the previous segment go into active mode, A1 connects to the transistors respective emitter pin.

From ToneGenOut, the square wave goes into a series of resistors and capacitors that form two pairs of low pass filters to smooth out the square wave. I also added a high pass filter because I noticed that when there's no square waveform generated, there is still a constant DC voltage at ToneGenOut. A constant DC voltage can burn out the speaker so I needed the circuit to output approximately 0V when there is no waveform generated. This high pass filter enables that since a constant DC voltage is essentially 0 Hz so it gets attenuated.

Lastly, the smoothed signal goes to a variable op-amp. R16 is actually a potentiometer in my real circuit, but LTSpice doesn’t offer potentiometers. By changing the resistance of R16, the gain of the op-amp changes which allows for the user to change the volume of the speaker. There is an additional 100 uF capacitor because I thought it would filter some of the noise, but in reality, the effect of it was minimal.


The only potentiometer I had on hand ranged in resistance from 0-10K. I wanted the volume to be able to go from 100% to 300% so I chose 5K resistance for R17.

When R16 is 0 ohms, the gain is 1 and when R16 is 10K ohms, the gain is 3.



Simulated vs. Actual Wave Frequencies & Periods

Simulated waveform generated by this circuit:


Measured waveform (using oscilloscope) of this circuit:

What's pretty cool about this is that the simulation is very close to the real waveform. The difference can mainly be contributed to the tolerances of the resistors and capacitors (ie. a 100 KOhm resistor may actually be 101 KOhms). In this particular sample:

Experimental Frequency: 454 Hz

Experimental Period: 2.2 mS Simulation Frequency: 465 Hz

Simulation Period: 2.15 mS I realize that this waveform doesn't really look like a typical musical note like a sine wave. I figured that it wouldn't sound much better to get an actual sine wave because of the speaker I was using. In retrospect, if I wanted to create sine waves, I could have added an additional op-amp like below:

Image source: https://www.electronicdesign.com/analog/simple-generator-provides-very-low-frequencydistortion-sine-and-square-waves