Thursday, April 25, 2013

Music of the Light, Part IV: Looks-Like Model

The task: Create a "looks-like" model of the music box.
We approached this first with Jamie's awesome sketching prowess:
The works-like model, with inside parts (inset):
This "works-like" sketch includes the axle (with Lego wheels, attached to the motor), top inset; the motor, bottom inset; the RDS cricket, the middle circuitboard-like box; the LED, far right box; the photo cell array, set of Legos with wires in the bottom right; and the speaker (cylinder-like shape), bottom left.

Comparing various designs for the overall shape of the music box--sketches having the motor on the outside:

Close-up on the Pico-type LED (we can affix it by nails, glue, or tape, depending on how sturdy/disassemblable the final deliverable should be):

Detailed drawing of the final design:
We will have a main box, which contains everything (motherboard, motor, and speaker), with a light sensor box on top to contain all the photo cells and the LED; wires will feed out of the photo cell box and through a hole back into the main box to minimize mess and prevent wires from interfering with the paper-feeding mechanism.

2-D parts for the main large box:
Top: front or back of the box; notches will help stabilize the walls; the hole on the right and indent on the left are to hold in the scrolls of music.

2-D parts for the small box to contain and shade the photo cells:
The small pieces (top) are the left and right sides (in the same plane as the front and back of the main box); the long pieces are the front, back, and top of the box (middle, left to right); the small piece at the bottom is a shelf to hold the LED in place.

Another sketch of the box, with motor/motherboard on the side, inside or out:

We had a fair amount of discussion about which parts, if any, should be outside the box.  We wanted to consider aesthetics (we needed a "finished-looking" product), coolness (everyone felt that motherboards/electrical connections were neat), safety/sturdiness (we didn't want someone accidentally pulling off an important part and/or leaking toxic chemicals everywhere), and take-apart-able-ness (since we borrowed a motherboard from the SciBorg, and knew it and probably many other parts would need to be returned).  Eventually, we settled on a compromise: we would put the motherboard flat on the bottom of the box in a drawer which could be slid in and out of the larger box; various holes would feed the photo cell wires into the box around the scrolls to contain everything (we'll wrap the wires in electrical tape and/or heat shrink for organization and a classier appearance).  We plant to build the main body and photo cell array box out of wood; the scrolls will be Legos (as shown in the works-like model), and will fit into holes in the main body (see below).

Next, we put everything into SolidWorks, worked out a few kinks, and added dimensions:
The main box (mostly Jamie's creation):
 The bottom of the box (the corners are notched for increased stability and ease of assembly):


The side (the large rectangle missing from the middle is where the drawer fits in, the hole and notch are for the two scrolls):

The front of the drawer (prototype drawing--the full circle was really a half circle cut out of the front):



The side of the drawer:



The light sensor box (I mostly worked on this):
One short side (round hole for the photo cell wires to come out, large rectangular hole for the Lego photo cells to fit in, small notches to fit in with other parts):

The other short side (no wires will come out this one, so no round hole):

The front long side (pegs to connect to the short sides):

 The back long side (pegs to connect to the short sides, rectangular hole to hold the LED):

The top of the photo cell box:

 This SolidWorks took a ridiculous amount of time because I kept having problems like this:
As you can (maybe just barely) see, the lines outlining the peg are just a hair not vertical.  This happened with most of the parts I was trying to use to assemble, so I had to redo almost all of them from scratch. (We're not sure quite what happened, but if I were to hazard a guess I would say that when drawing things on a tablet it is difficult to get lines perfectly vertical.  Several hours of methodical work eventually fixed this though, and I was able to assemble the light sensor box!)

Assembly of the main box and the light sensor box:

The light sensor box:






It's beautiful!

The main box:


We needed some holes for the wires to connect from the photo cell array (which will sit on top of the main body) down to the motherboard (on the drawer in the bottom of the box).  Jamie had the clever idea to add some stems and thus turn the holes into music notes, which we thought was wonderfully aesthetically pleasing!  We used some pegs to ensure a snug fit and to allow for easier assembly, but most of the joining will be with small nails.
Alas, my elation was short-lived.  It turns out that the light sensor box that I spent umpteen hours troubleshooting and finally assembling in SolidWorks is not actually the design we're going to build.  We all regret the uncommunication of a significant change of plans.  However, my work was not completely useless, as I was now very comfortable with SolidWorks, and the new design had only slightly modified parts.  The new design is much sleeker, with the photo cell box fused to the main body box:





The small little L-shaped pieces are to be glued into the four small rectangular holes in the photo cell array, which will help to affix the pieces and join everything together nicely, to hold up the array of Lego-mounted photo cells (suspended in the top box), and also to guide the paper in the scrolls to feed very straight into the photo cell array.

The new design is very similar to the old; the only real change is the fusion of the light box with the main body of the box.  This much sleeker idea changed just the front and back pieces--we added a top bit to be the side of the light sensor box.  We also cut out a few holes for the small L pieces, which will serve a variety of very useful purposes.

I wish I could have helped assemble the right project files!  We now realize the importance of group communication and plan to schedule times when all of us can meet to work on the project together, and each of us will be sure to email the other group members when they're working on something or whenever they've discovered important new information or had an awesome idea.  Hopefully this will prevent further unhelpful hours spent fighting with SolidWorks!
We'll print out all the parts for the new design on Friday, and glue and nail them together to start testing the first real iteration of looks-like and works-like Music of the Light!

Thursday, April 18, 2013

Music of the Light, Part III: Works-Like Model

Our goal for this class was to generate a works-like model, which we planned to do by finishing the program for the other seven light sensors, then calibrating each sensor to play the appropriate note when it sensed a dark spot, then combining the music scrolling and sensing:

First we finished the code, and changed it to play a "melody" (one longer note) rather than the previous "note" in order to increase the time of each note and more easily determine the pitches.  We based playing a note off of each photo cell's reading; we tested each cell to make sure that it played a note only when exposed to a spot of black marker on a sheet of paper, but would remain silent when the sensor was pointed at the white paper.  Each photo cell was separately calibrated, since each was a different distance from the LED which provided the background illumination--sensors farther from the light read darker baseline values than sensors closer to the light, so sensors 1 and 8 had the highest baseline values in the first line of their programs, and sensors 4 and 5 had the lowest.
The program:
All of our sensors are working!
We set the key to D major and organized the sensors so they form a scale.

A calibration test:

We wanted all 8 notes to play when they were on a black mark (as shown initially), but none to play when on white paper (the second test).  We noted that photo cell 6 was still sensitive to shadow (the third demonstration), so we added another Lego piece to improve the shading box a bit after this calibration.

Now that the photo cells were working, it was time to finesse the music scrolling.  We drew guiding lines on a long strip of paper for the music, to make sure the notes were aligned properly:

We then simply snapped the photo cell array on top of our previously-assembled scrolling mechanism (hooray for Lego assembly!).  Our works-like model, assembled and about to run:

The music reader reading the first music:
It...didn't quite work out like we had hoped.  Time for debugging!  We recalibrated the sensors and played around with the scrolling time.
The second round:
We were concerned that the paper wasn't feeding straight, so the photo cell alignment was off.  We added some feeding shelves to help with the straightness issue.
The third round:

Still not really a recognizable melody...  We realized then that we needed to write the music slightly farther down the paper, as the current version had already scrolled past the first notes during the initial setup.  We'll be sure to fix that next class.
We played the music box for the presentation at the end of class, and it played something only a few notes off from the Beethoven's 9th Symphony melody we had transcribed. (Unfortunately we had some technical difficulties with filming and were unable to record this; next class we'll fully document the working player.)
Our goal next class is to make a SolidWorks looks-like model of an aesthetically-pleasing music box!  The basic idea is to contain the "guts" of the music box (the motherboard and all the wires) an an appropriate housing which also supports the scrolls and motor; this will eventually be laser-cut out of Delrin and assembled (probably with small nails, possibly piano wire).  Our current, rather haphazard-looking box, with a ruler for scale:


Goals for Friday:
We're excited to continue as "slowly, gently, light unfurls its splendor"!

(quote from Andrew Lloyd Webber's famous song "Music of the Night")

Tuesday, April 16, 2013

Music of the Light, Part II: A Crash Course in Critical Components

After our long brainstorming session last class, on Friday we got together to work through some key components of the light-based music box.  We first built and troubleshooted a works-like model of the music-feeding component (which turned a scroll to move the music along toward the light sensors).
We started by building the scroll base, made of a Lego axle with five small wheels:

We then added a motor (connected to a SciBorg motherboard, connected to a computer running PicoBlocks) to turn the scroll:
We initially affixed the paper to the axle with a paper clip, and later with a complicated series of holes and washers.  Neither method worked well, due to imperfect straightness of rolling (it was difficult to perfectly align the paper) and an uneven radius of the scroll's base (which caused jerking).
The initial paperclip attachment:

Setup for testing the first scroll roll:

Peg setup for second scroll roll:

We noticed that we were automatically adjusting for imperfections in the rolling by holding the other scroll more tightly.  The final machine would ideally have the scrolls free-standing, so we built a base out of Legos to test this mechanism:
(The scroll paper was deliberately unwound in this picture to show the rough Lego structure.)  We added the bar just behind the non-motor scroll to maintain some tension, to help keep the scroll from unwinding by itself.

Another view of the structure:

We noticed a few imperfections of this design.  It had a tendency to get stuck:

Also, the paper unrolled unevenly--the motor pulled at a constant rate (as set in PicoBlocks), but the scroll unrolled in a series of jerks:
We think the jerkiness was caused by the tape linkage of our paper (we initially taped together two shorter pieces of paper to make a sheet long enough for a scroll), and also because the way our pegs attached caused the radius of the scroll base to vary.  Hannah braved the huge paper cutter in the library and we decided to try taping a long roll of paper onto the scroll base, to keep an even radius and eliminate any tape-joint-jerking problems.

A list of our setbacks before testing the final iteration:

The long roll of paper taped to each scroll base:

The final test:


Ahhhh...beautiful!


After this success, we moved on to the beginnings of an actual music-reading program.  We hooked up the photo cells to the SciBorg motherboard and started testing readings.

Our final staff paper should look something like this:
Only four lines are necessary, since we have only eight photo cells; that's plenty to generate a full octave, however.  Each photo cell will read a specific region of the staff; if it senses darkness (i.e., the black dot of a notehead), it will play a certain pitch.

 Our test palette for sensing contrast with the photo cells:
We had initially hoped to change rhythms depending on color; this may or may not be possible, depending on our time available to increase the complexity of our final program.  There is a large difference between the  photo cells' readings for white paper versus a dot of black marker (about 100 units, though this is smaller depending on the shadows).

 We tested photo cell sensitivity with PicoBlocks:
 We used a program similar to this one which made a "chirp" noise (out of an attached speaker) when the photo cell read a value over 530 units.  After a number of iterations and some consulting with the illustrious Professor Berg, we generated a text program to control each photo cell individually:

(The final line is simply present as a syntax guide.)

While I worked on the programming, my trusty team built a works-like Lego model of the photo cell housing.  After testing confirmed that shadows were a major source of uncertainty in the light reading, we decided to attach an LED to the photo cell array.  We also noted that shading the photo cells reduced variability in their readings, so we used Legos to isolate the photo cells from light that might be coming in sideways--we blocked the sides of the photo cells, so they could read only directly beneath the sensors.

The top of the first array:
Adding in the LED:

Sensing with the LED: 
This design proved much more effective than sensing without an additional light source--there was a much greater difference in photo cell values when held over a black marker dot versus the white paper.

 The photo cell assembly, hooked up to the SciBorg motherboard (plugged in to a computer running PicoBlocks):
We added some more blocks to better isolate the photo cells from light not directly beneath the sensors.

The note-reading program in action:

Appropriate darkness detection was music to our ears!


By the end of class, we made a lot of progress on the two major components of our light-based music box.  We had some definitive goals and a plan of action for next time:

We tucked away all our technology and eagerly awaited the next class!