[Tonights post is by Ed Smith, participant in the Humboldt Microcontrollers Group.]
In this post well go through the Humboldt Makers Groups Humboldt Laser Harp (HLH) in rather more detail than we have previously.
If youre not familiar with the concept of a laser harp YouTube has plenty of videos of different styles, or of course you can keep reading and get familiar that way. This is our harp:
We opted for a closed-frame harp rather than an open frame, as the closed frame struck us as an easier proposition. It also gives us control over the laser path, rather than letting it head off into the ether. Important for harps that will be played outdoors (as ours is) or near airports / airplane flight paths.
For lasers we opted for super cheap laser pointers from the local dollar store; at a buck per laser this beat mainstream suppliers prices by a huge margin.
Mounting the whole laser would be difficult, and those batteries dont last very long, so Nick ripped them open and hacked away most of the PCB, leaving us with a much more manageable package.
Those of you familiar with LEDs / laser diodes and button cell batteries may be able to guess what happened next.
We read the battery spec, 1.5v each, and fed the lasers ~4.5v. What we failed to consider was the internal resistance and resulting voltage drop of the button cell batteries.
The lasers looked amazing, for about half an hour.
Then they started to burn out. Oops.
After replacing the dead and dying lasers Nick did more testing and we eventually solved this by running the lasers on 3.3 volts, which seems to work well. Unfortunately more lasers were damaged during testing and we ran out of time to replace them, resulting in a few "strings" that didnt work well in direct sunlight. Oh well.
We are debating different methods of laser amperage control for future harp designs.
To hold the Lasers Nick designed and 3D printed some lovely adjustable mounts for them.
The corks hold the top end of a spring, which pushes the mounts against their legs (screws) and against the harp frame. By turning the screws the aim of the laser is easily adjustable. I failed to take a picture of a mount up close, but you can see the general idea.
On the bottom side each laser hits a light sensitive resistor (LDR) light sensor, each sensor has a 3D printed holder and light guide tube.
The black heatshrink around the tube helps block out ambient light and results in a stronger signal from the laser. This turned out to be crucial when operating the harp in daylight outdoors.
To convince the harp to stand upright we turned to Gordon, who hit the scrap yard and attacked what he found with his MIG welder. The result was a very stable base that complimented Nicks choice of an industrial theme wonderfully.
The rear screen is held in place by a pair of wing nuts, allowing us easy access to the center area. This center area will eventually hold the electronics package as well as some light effects.
The combination of mild steel base and aluminum body gives the harp a very low center of gravity and makes it quite stable. I was very happy about this when sitting behind it at the recent maker fair, as the road had a fair crown to it and we had the harp on a card cable. If it was inclined to tip it would have been a very nervous time for me!
The combination of mild steel base and aluminum body gives the harp a very low center of gravity and makes it quite stable. I was very happy about this when sitting behind it at the recent maker fair, as the road had a fair crown to it and we had the harp on a card cable. If it was inclined to tip it would have been a very nervous time for me!
To finish off the hardware side of the harp, heres a view from the rear.
I was in charge of the electronics package for the harp, I used a Texas Instruments Stellaris Launchpad microcontroller board for the brains. The primary reason I chose that board is that it has 12 analog inputs, making the job of reading 12 LDRs much easier. This project could be done with a microcontroller with fewer analog inputs, but you would need to use an external ADC or some comparators to turn the analog voltage from the LDRs into a digital signal.
To the right you can see the finished, prototype, electronics package. I used some perfboard to make a BoosterPack (what TI calls expansion boards, Arduino calls them Shields) for the LaunchPad. This simplified my design somewhat and made it easy to swap a new MCU into place if I accidentally blew this one up. Thankfully I didnt, but it was nice to have the option anyway.
Most of the board consists of 12 copies of a very simple circuit. The 15 pin connector has one pin for positive voltage to the lasers, one ground pin, one "feature / effects" pin that is not currently in use, and then 12 pins that go to the LDRs. The circuit on the perfboard has a variable resistor that feeds voltage to the LDR pins, and a second wire that goes to the analog inputs.
Having a variable resistor doing the high side of the voltage divider means that we can adjust the sensitivity of the sensors to match the strength (and aim) of the lasers. This is important when some lasers are new and happy and some are half dead! Also included in that circuit is a 0.1µF capacitor to help prevent EMI issues. Whether this is actually needed or not is unknown, but the result worked well so Im leaving them in place.
The other two circuits on the perfboard connect the MIDI output port to the microcontrollers second TTL Serial channel, and connect the +3.3V pin to the lasers via a MOSFET. This gives the microcontroller control over the lasers, a useful feature for automatic calibration.
Lastly, the code. I wrote the firmware for the laser harp in the Energia IDE. Energia is a fork of the Arduino IDE that is aimed at the TI Launchpad series of microcontrollers. Most simple programs can be copied straight across from Arduino to Energia and back, though you do need to change the pin definitions. Energia also has ports of many Arduino libraries, making things even simpler.
Im going to describe the code and then post a link to it on GitHub rather than inserting it in this post.
The code is aimed at being easily adjustable for different numbers of "strings". Its main loop checks the status of one string, if the string status has changed it finds an open MIDI port and sends the Note On or Note Off message to the external MIDI synthesizer. If it has not changed, it does nothing. After that it increments the string counter and goes through the loop again, check the next strings status.
This loop takes between 67 and 1050 microseconds, or 0.067 - 1.05 milliseconds if you prefer. Not very long. The variation in time largely comes from whether it needs to send MIDI messages or not. The code is set to send the entire message before it goes through the next loop, to prevent against buffer overflow. This probably isnt necessary, but I didnt want it crashing in its first public outing!
The Launchpad has two pushbuttons on it. One of them activates a now partially defunct programming mode that allows you to set the MIDI Velocity variable (how hard the "string" is plucked) and the threshold for the analog inputs that defines what is a HIGH and what is a LOW signal from the LDRs. The MIDI Velocity is still in place; the global threshold has been removed in favor of each "string" having its own threshold.
The second button is used to set those thresholds. It first turns off all the lasers and reads the analog voltage from each LDR, then turns all the lasers on and reads the LDR voltages again. The threshold for each string is set to the mid point between the two readings.
This change to the code fixed the majority of the issues we had on the Humboldt Laser Harps first outing.
This change to the code fixed the majority of the issues we had on the Humboldt Laser Harps first outing.
The trimmer resistors still need to be adjusted to give a good voltage range, but once they are adjusted to match the laser you dont have to do it again. Previously, every time the ambient light conditions changed, you had to redo all 12 trimmers, which took long enough that the ambient light conditions had typically changed again by the time I had finished.
You can find the code here: GitHub Code Link.
As we upgrade the Humboldt Laser Harp well make new posts about it here on the blog.
--Ed Smith
**********
0 komentar:
Posting Komentar