myRIO Student Projects

Showing results for 
Search instead for 
Did you mean: 

myLaserHarp: Music with strings of light!


myLaserHarp: Music with strings of light!

Lasers are awesome! Music is too! Using NI myRIO, I managed to combine the two to create myLaserHarp. When playing this novel electronic instrument, your fingers break parallel beams of light to create musical notes and scales. As if that wasn’t enough, using Solenoids and MIDI files, I also taught myLaserHarp to play itself!



Who am I?

My name is Adam Metcalf and I am currently a Mechanical Engineering student at the University of Leeds. Whilst on an Industrial placement at National Instruments I was given the opportunity to spend a week working on an intern project. The result of this is myLaserHarp.


Why did I choose this project? As a Mechanical Engineer I have limited experience with electronics, so I was keen to get to grips with the fundamentals. myLaserHarp uses a light detection circuit to determine when a laser beam has been broken (and thus the 'string' is 'plucked'). I also have no musical talent whatsoever, so it was important that I included a way for the instrument to play itself Smiley Wink



myLaserHarp has an array of 12 lasers set opposite an array of light dependant resistors which are part of a 'dark sensing' circuit. When the laser is blocked, the 'dark sensing' circuit sends a signal to the myRIO, which generates a square wave of a frequency corresponding to the correct note. This square wave is played through a speaker, which comes out as a note sounding delightfully 8-bit in nature. myLaserHarp can be played by simply intercepting the lasers with your fingers ('plucking the strings'), or you can upload a MIDI file to the myRIO. The myRIO will read the MIDI file and actuate solenoids, which pop-out and block the lasers, thus 'plucking the string'.


Figure 1 shows myLaserHarp after the build was completed:

Figure 1.PNG 

myLaserHarp consists of a few independent systems which have been combined. In no particular order these are:


1. A laser circuit - This powers the 12 lasers which are the 'strings'

2. A light-sensing (or rather 'dark-sensing') circuit - This is to detect when the laser is intercepted (or the 'string' has been 'plucked') and send a signal to the myRIO.

3. Solenoids - These break the laser beam which a signal is received from the myRIO.

4. Relay boards - These are to provide power to the solenoids when a signal is received from the myRIO.

5. LabVIEW and a myRIO - Combined, these are the brains of the operation. The myRIO is responsible for detecting when the laser has been broken, generating the correct frequency to play the           correct note, reading the MIDI file, determining when to actuate the solenoids and actuating the solenoids.

6. The frame - myLaserharp was built from copper pipes which were then suspended in a frame made from wood.

7. The speaker - The cheapest speaker that can be bought from Amazon Prime.



The solenoids are powered by relays which are controlled by the myRIO. This is because they would exceed power limitations if directly controlled from the myRIO. Figure 2 shows how the solenoids and the relays were configured:


Figure 2.PNG


The external 5V power was supplied by recycling a USB charger for a phone. Polystyrene balls were cut in half and glued to the solenoids using Araldite (known in the office as 'forever glue') to extend their reach. Figure 3 shows the setup when built into myLaserHarp:

figure 3.PNG


In bright light, a LDR (Light Dependent Resistor) has a low resistance. This means that when there is a laser beam shining on the LDR, the LED is not lit and there is no signal sent to the myRIO. When the laser beam is broken, the LDR increases significantly in resistance, and so the LED will be illuminated and a signal will be sent to the myRIO. Figure 4 shows the circuit diagram of the 'dark sensing circuit': 


figure 4.PNG 

Figure 5 shows the strip board being built:




Figure 6 shows myLaserHarp being built. The wires to connect the LEDs and the LDRs were fed through the copper pipes. On reflection, copper pipe was not a good idea for the since it is essentially an short circuit waiting to happen (and this occurred more than once):


figure 6 .PNG

figure 7 shows the lasers being connected. There was great difficulty in aligning the lasers with the LDRs, but this was overcome with copious amounts of Araldite (forever glue):


figure 7.PNG


The wiring became a bit of an issue. this was not something that I planned or implemented particularly well, but I simplified the connections to the myRIO by creating some bodged wiring looms as shown by figure 8:


figure 8.PNG 



The application was all programmed in LabVIEW 2016, and there are a number of separate parts.
The FPGA part of the application has 5 responsibilties:
1. Monitor the 'Dark Sensing' Circuit.
2. Generate a square wave of the correct frequency for each of the 12 notes.
3. Send the square wave to the speaker when a signal is received from the 'dark sensing' circuit.
4. Receive note events from the RealTime part of the application.
5. Activate and Deactivate the solenoids
The FPGA is always generating 12 squarewaves (this is documented in the code). Each squarewave has a frequency corresponding to a note C to a note B (MIDI notes 60 - 71). Each squarewave is generated by dividing a 25 MHz loop by a number to create the correct frequency, as shown by figure 9:
figure 9.PNG
This means that it would be easy to change the octave, you simply have to change the constant and recompile the FPGA code (for example, to generate C as MIDI note 48, which is an octave lower than seen in figure 9, replace '95556' with '191112').
The MIDI notes and corresponding frequencies can be found here:
The Realtime part of the application has 3 responsibilities:
1. Read the MIDI file in from a USB memory stick
2. Parse the MIDI file into note events
3. Send the note events to the FPGA
The RealTime part of the application is solely responsible for the MIDI file handling. myLaserHarp works great with only the FPGA control and monitoring code if there is no requirement to play MIDI files.
Bill of Materials
1. Wood (for the support frame)
2. Cheap lasers with no specifications from a dodgy Chinese website (x18 - buy 50% more than required to account for inevitable failed units)
3. NPN 2N3904  transistors (x12)
4. Light Dependent Resistors (x12)
5. 330 Ohm Resistors (x12)
6. 10k Ohm Resistors (x12)
7. Material for the frame (I would advise against copper - its a short circuit waiting to happen)
8. Relay Module (x2 - look for the type that are commonly used with Arduinos)
9. LED (x12)
10. Small 5V Solenoid (x12)
11. Jumper cables (lots of them were used for this)
12. Araldite (Forever Glue - use a LOT Smiley Wink )
13. Speaker
14. Stripboard
15. myRIO
16. LabVIEW 2016 with LabVIEW RealTime and FPGA.
17. 5V power supply for the relay boards and solenoids (I re-purposed an old mobile phone charger).
18. A willingness to learn from mistakes and patience.
That's it. Good luck!!