DIY mechanical music box. DIY light and music gift for your loved one


In the music box, almost at the very bottom, moments of long-gone days are quietly sleeping. The once popular accessory is now gathering dust in museums or on mezzanines filled with all sorts of rubbish. It might have continued to be this way if the designers had not decided to revive the music box, making it a real luxury item. We'll talk about the brightest examples in our review.



Starting from November, all the country's screens are filled with a cheerful Santa Claus with a bottle of Coca-Cola in his hands. Advertising remains virtually unchanged from year to year, so main character becomes almost family, and in the supermarket the hand itself reaches for the fizzy drink. Now it has migrated to the lid of the music box. This Santa Claus, of course, won’t bring Coca-Cola, but he will delight you with music.


The main thing is a roof over your head. As it turned out, this truth is relevant not only for people, but also for music boxes.


This music box is made to order. The designer not only chooses the melody the client likes, but also creates portrait figures of the birthday person or members of the client’s family.


Music box in the form of a medallion, stylized in antique style. Designers claim that with one such gift you can win a girl’s heart.


If the capricious charmer remains indifferent to the singing heart, you can try giving her a music box in the form of a carousel. Just first you should ask: does the girl like music or is the best gift for her in the jewelry department?


What progress has come! Manufacturers have come up with a music box for the iPad. To activate it, you need to download a special application to your iPad, and you can enjoy the melodies.


A music box created specifically for the anniversary of the Beatles. However, the lid of the product speaks volumes about this. As for the repertoire of the box, it consists exclusively of songs of the legendary group.


Children will definitely like this box. The designers periodically change the main characters of the box. One thing remains unchanged - the nature of the product.


A music box for those who write music. Create melodies, record them on a special card and enjoy the results.


Designers suggest creating such a box with songs yourself: paint it in your favorite color, add all kinds of figures, inscriptions and give it as a gift. dear person. After all best gifts, as you know, are made with your own hands. If you can’t make a music box yourself, you can give it to the birthday boy. We are sure that anyone will like such a gift.

To do this you will need the following materials and tools

Saw in the form of a belt for the machine;
- Grinding machine;
- Electric drill
- Milling cutter
- Cekovka
- Music: (whichever you like).

Additional materials:

Toy wooden xylophone;
- Remains of wood, preferably a fruit tree or nut;
- Means for gluing rubber and wood products;
- Threaded screws for fixing drywall;
- Dowel rod;
- Metal washers corresponding to the axles;
- Beeswax with orange oil.

Before drilling holes, you need to turn the surface of the cylinder into a stave; to do this, draw lines one after another along the entire circumference, and 4 lines perpendicularly. Install the drum into the frame to make it easier to determine the center axis.

Here you will need a sheet of plywood. Make gears using a computer program, print them, glue them to wood material and cut them with a saw on a machine. If the material is made of fibers of alternating directions, this will provide good strength.

2. Make hammers
For the hammers you will also need wood material, the length of which must correspond to the xylophone.
It is necessary to make guides. To do this, use the link under the photo to the Inkscape file, print it and glue it to the guides. For the cams, take 3 mm birch plywood; for the hammers and axles, use cherry scraps 1 cm wide.

Attention! The hidden text will be available after registration or authorization on the site.

3. Other details
You will need a base to support the instrument, and ensure the notes are played clearly by using a hammer drum to prevent them from bouncing. For the drive, make a lever handle.

4. Ready musical

Now the time has come to talk about what was inside my box, cut out of plywood with a jigsaw. At the heart of everything was a circuit diagram on the controller, powered by 2 Krona batteries (9+9 V). I recorded the music on a 16-32 MB SD card. Moreover, the box played a new melody every time it was opened. Let's start in order!

Elemental base of the contents of the box

The core of the circuit is the Atmega16 40-pin microcontroller, which controls the playback of melodies. The case has a DIP so that it can be easily inserted and removed from the socket located on the board. The Atmega16 picture is as follows:

Another equally important microcircuit is the LM4860M audio amplifier, 1 W, 16-pin, from the outputs of which the amplified signal goes to an 8-Ohm speaker. I took the version of this microcircuit in the SO16 package.

You will also need 2 microcircuits - voltage converters: 7805 in the TO-220 package, the output of which is a constant voltage of +5 V, and IRU1117-33 in the SOT-223 package, with a constant output voltage of +3.3 V, from which the SD- map. An image of these chips is below:

To run the controller you need a 16 MHz crystal oscillator. SD card 16-32 MB, now such a small flash card is difficult to get, but previously they came with some camera models in the kit. All resistors and capacitors are in SMD design for surface mounting.

Circuit diagram of a music box

The electrical circuit of the box looks like this:

As you can see, out of 40 pins of the microcontroller, only 18 are used. Pins 5 to 8 – exchange with an SD card, 9th – for resetting the controller, 10 – +5V power supply, 11.31 – ground, 33-40 – via a divider to an audio amplifier. The Atmega16 microcontroller needs to be flashed, but not on the board itself, but on a special device connected to the computer via RS-232. Exchange with the computer occurs through the SPI interface of the controller (pins 5-8). The firmware is downloaded using the PonyProg computer program. The firmware itself (Music_box_16.hex) and a screenshot of the installed fuses in PonyProg (PonyProg_Mega16_Fuses.bmp) are in the attached archive. You will also find in it technical descriptions(datasheets) for the chips and microcontroller used.

PCB diagram

I laid out the tracks on the printed circuit board in the Sprint Layout4 program. Accordingly, the file shkatulka.lay is in the archive. A board measuring 130x70 mm is made of one-sided foil getinax. All SMD resistors and capacitors, LM4860M chip, IRU1117-33 are placed on the side of the tracks, and the microcontroller, SD card slot, electrolytic capacitors, 7805 chip are placed on the other. The PCB drawing is shown below:

To etch the board I used the old “iron method” and ferric chloride. Then I soldered all the elements, leaving the speaker, power button and power from two 9 V batteries outside the board. Unfortunately, at that time I did not have a camera at hand, and this was not my goal (to capture my work), so I have no opportunity to show the installation I received, and I will not disassemble the non-removable box. Then I left myself the opportunity to only change the batteries and rewrite the flash drive.

Recording melodies for the box

The SD card needs to be formatted to FAT16. The tunes you want to be played by the box should be prepared. Total melodies – up to 100. Playing time – 1 minute. Audio format – .wav PCM 16 kHz 8 bit mono. Name the files – “ring_00.wav”, “ring_01.wav”, etc.

Archive.7z for download:

Stuffing for the box(5.8 MiB, 281 hits)

OK it's all over Now! Collect, launch and enjoy!

P.S. Don't forget to subscribe to the newsletter (-> on the right sidebar)!

Our little princess, my beloved niece, is approaching her first birthday. On her mother's birthday in February (my little sister), the children broke their beloved musical toy our baby, a glass ball with bears. And I didn’t let the musical mechanism be thrown out of it with the expectation that I would come up with something. And so I decided to make a box. Girls love boxes. I'm a girl myself and I know :) While our Sonechka is little, mom will collect the girls' favorite treasures in the form of beads, rings and bracelets.
One of my hobbies is boxes self made, and over the long time that I’ve been doing this, I’ve already accumulated a lot of all sorts of materials.
So. We need a tin of cookies or sweets. You can also just buy a tin can. You can now find any jars in craft stores. I found cans in a tea and coffee shop. Just banks. But this time I got a cookie jar from the Spartak confectionery factory. She's big. The diameter is 22 cm, and the height is 7.5 cm.

Metal putty, acrylic primer, acrylic varnish, PVA glue, brushes, decoupage rice card with notes (the rice card can be replaced with a decoupage napkin), scissors, musical mechanism. We also need a glue gun and a glue stick. I love working with rice pads and cards. Under the influence of glue they do not tear or deform. And they have a pleasant texture to the touch. Everything else will be selected as we go. Sometimes at the very beginning I don’t know what the result will be. That is, usually at the very beginning there is some theory, but very often during the work something changes.
But my bank has one significant drawback. The surface of the lid is not smooth. There are cookies squeezed out on it. So I took automotive metal putty and smoothed the whole thing out. There are no photos of the process, since there was no one to take photographs, and besides, the putty smells extremely strong and unpleasant. When the putty has dried, it needs to be sanded. I deliberately did not sand it to perfect evenness and smoothness.

Then we cover our entire future box with primer in one, or better yet, two layers. The second layer is applied only after the first layer has dried thoroughly. I think there is no need to explain why soil is needed.

So everything dried up. It's our napkin's turn. First we glue the lid. We remember the lessons of labor in primary school. Cut out a circle with a diameter equal to the diameter of the top of the lid plus the height of the lid plus a couple of centimeters just in case. Apply glue to the lid with a brush and carefully place our circle on top part lids, smooth them out so that there are no wrinkles. Very carefully so as not to tear. Unfortunately, there are no photos of the process, since there was no one to take photographs. We have leveled it on the top part, now we take the lid in our hands and carefully, moistening it in glue, use a brush to glue the card to the side walls of the lid. In the same way we paste over the lower part of our future box. It's easier here. You need a strip with the height from the stop rim to the bottom plus the height to the bottom. I have plus 5 mm to the main length. And a circle. We put our box on the map and outline it with a pencil. Let it dry.

It took me several hours to dry. The glue must be completely dry before applying varnish. Otherwise the varnish will stick to your hands. I bought wood varnish at a hardware store. Special varnishes for decoupage have failed me more than once. They are expensive and stick to your hands finished product. So I went and bought varnish at a hardware store. I don't like gloss, so when choosing a varnish, I settled on a varnish that has a matte surface.

This means that the next step will be to apply varnish. The varnish must be applied strictly according to the instructions. In two layers. Dry each layer thoroughly.

Here you go. Dried. Now the fun begins. At the very beginning, I forgot to make a hole for the musical mechanism, so I had to make the hole after applying the varnish. Make the hole very carefully. I neglected safety precautions and drove a screwdriver into my finger directly into the vein. After filling the hole with peroxide and having difficulty stopping the bleeding, I began to fasten musical mechanism. Due to the fact that I was slightly injured, I forgot to take a photo of this process. Then it turned out that the key that a watchmaker I knew had picked up for me was very large and ugly. And then, with the help of my charm, I persuaded a turner I knew to make me a small key made of brass. Here he is handsome.

So. Now let's start working on the interior "decoration". First of all, you need to finish the walls, bottom and hide the mechanism. We take cardboard and cut out the parts. Somewhere a long time ago I dug up a very cool compressed cardboard 3 mm thick. From it I cut out parts that will hide the mechanism. The bottom and sides were cut out of cardboard with a density of 300 g/m2. We cut out the same parts only with an allowance from velvet. Here are the details. Take a glue stick and velvet. I really like gluing fabric to cardboard with a glue stick. I'm buying expensive pencils companies Kohinoor or Erich Krause. But now, as luck would have it, I couldn’t find either one and again bought the most expensive glue stick from a German manufacturer at a hardware store. I took it at my own peril and risk, but it paid off. So, we apply glue to the cardboard and apply velvet. Let it dry and glue the seams. Something like this.

Sidewall

This is a box for the mechanism

back side

Donyshko

Using a glue gun, secure the velvet parts inside the box. Here it is in finished form.

Next we make a drawer for small items. Initially, I wanted to make a box that would be like a continuation of the box for the mechanism. But when I tried everything on, I realized that it turned out to be some kind of garbage and decided to make the drawer separately. I cut out a sector of the circle (lid) and a wall from thick cardboard. I glued them together at a distance of 4 mm from each other so that the structure bends. I trimmed the velvet along the edge. I sewed the edges of the velvet with a thread and a needle. And she secured everything inside the box. Everything seemed pale to me, so I used a glue gun to secure brown satin cord along the joints. The beads act as a stopper to prevent the lid from falling through.

We paste on both sides. Bends.

Sewing the edges

I looked at the result and decided to add another compartment. And to make it interesting (I’m making a box for a girl), instead of a lid I made an imitation of a bag that is tied with a satin cord. Everything is attached with a glue gun. Here you go. It seems like nothing is wrong.

Now with a bag

Now you need to decorate the outside of the box. I'm honest and long and in different places I was looking for the braid I needed, but couldn’t find it. And so I bought what I had to make something that would suit me. Organza ribbon, satin cord and velvet strip. I took an organza ribbon and ironed it with adhesive tape to glue the velvet strip onto it. I glued all this beauty to the box with a glue gun. Something is missing. Pale. Then I used a glue gun to glue the satin cord along the edge velvet ribbon. I made a bow from velvet and organza ribbon and attached it next to the key. This way I hid the junction of the braid and hid the key a little.

We will talk about a device that is very simple to manufacture (even for a novice amateur electronics engineer), but at the same time extremely interesting and useful - an electronic “music box”. Also, as an example, I will show and talk about one of the possible incarnations and applications of this device - about the last gift I made to my girlfriend based on it.

History of creation

There will be many letters here that relate to the matter rather indirectly, and if you want,

It all started a long time ago, several years ago, when I wanted to give a girl some interesting, original and memorable birthday gift. And definitely with your own hands. There was very little time left before the holiday, two days, during which it was necessary to come up with something and, in fact, implement it. The day was spent thinking - hundreds of different options were spinning in my head, from all kinds of LED “flashing lights” - hearts, to various electro-mechanical crafts. But all this was not the same: either it was too simple and hackneyed, or, on the contrary, quite complicated (and there was absolutely no time left!). Suddenly a simple, but wonderful, as it turned out, idea came to my mind: why not make a musical card? And not a simple one, but with a “trick”, with an original melody. Moreover, we had “our own song” to which we met and which evoked in us all sorts of pleasant romantic memories and experiences.
This is how the very first version of the “music box” was born, the progenitor, so to speak. Very simple, hastily assembled using a surface-mounted assembly from a PIC12F675, a piezodynamic speaker, a photodiode, a pair of resistors, a three-volt element 2016 and packaged in a postcard drawn in Photoshop. As a result, this postcard was able to write out that same melody in a rectangle when opened (and the light hit the photodiode). Just like that, unpretentious and simple.
But the idea turned out to be extremely successful, many times more than I expected. Later I made several more of these simple cards at the request of my friends, for their other halves. And in each case, such a gift evoked a lot of emotions both among the recipients themselves and among their parents, girlfriends and acquaintances :)
Quite a lot of time passed, everything started to spin, the project was forgotten. But it so happened that I remembered the music box again. This time it was supposed to be a gift for March 8th. At that time, I was actively studying Atmel microcontrollers, in particular playing with the ATtiny45, and decided to improve the music module for this purpose. Moreover, this time there was a lot of time. That's where it all started.
While looking for various information on the Internet, I came across Mr. Chan’s website, widely known in narrow circles. More specifically, one of his designs, a miniature synthesizer, just on my favorite MK :) Some time ago I almost finished a four-channel synthesizer on PIC18, but, alas, I destroyed the work in my heart (which I later regretted more than once). And Chan’s design was completely self-sufficient and complete. All that remained was to add a “trigger mechanism” to it and off we went!
I updated the code a little and the trigger mechanism was ready. But then everything turned out to be somewhat less rosy. The main problem with the design was that it sounded too quiet. No matter how hard I tried, with direct drive of the speaker from the MK pins it turned out quiet and that’s it! As a result, a strong-willed decision was made to add a power amplifier. The choice fell on the LM4900, then available in Terraelectronics. Again, we had to make some more changes to Mr. Chan’s code in order for the synthesizer to work correctly with an external amplifier - make a power-saving leg control so that the amplifier does not eat up the battery when idle, and reconfigure the PWM to correctly output the signal from one pin. After these changes, the prototype worked just perfectly. Then I drew the first version of the board (which, as it turned out later, had a bug in it:) and assembled the music box like a human being. Next, everything follows the beaten path - a homemade postcard, installation of the module and donation.
Of course, this device was several heads higher than the previous ones - the very realistic sound of a “real” box and the polyphony made itself felt :) The gift, as in previous times, a long time ago, caused a sensation. And I also collected about a dozen such modules for friends.

Now about the device itself

The current version of the module, the third, contains several more changes and one interesting innovation - light and sound channel, to which you can connect, for example, an LED. But first things first.
Let's start with the diagram, it is very simple:


Its heart is a microcontroller ATtiny45/85. He is actually involved in the synthesis of music, controls the light and music channel and energy saving of the amplifier. The second most important element is the audio power amplifier TPA301D. Connected to amplifier speaker, which is outside the module. There's also a transistor BC847, controlling the light and music channel and several passive elements - resistors and capacitors. All this is powered by 2-3 alkaline elements (for example, AAA) located in the external battery pack(the most common, Chinese). As you can see, the scheme is really elementary.
Operating principle of the circuit
Most of the time the device is in sleep mode. The MK falls asleep at the command of the firmware immediately after turning it on, having previously “put to sleep” the amplifier by installing it on its leg "SHUTDOWN" high level(by connecting a weak leg brace "PB0" to “+” power supply inside the MK). MK wakes up when interrupted by foot "PB2/INT0". Initially, the leg is also pulled up to the “+” power supply inside the MK and it must be short-circuited to the ground.
From the “PB1/OC1A” pin of the MK, the audio PWM signal, in order to filter it from the carrier, passes through a simple second-order RC filter ( R2-C3), which must be calculated (and in our case it can be simply “estimated”) for a cutoff frequency that is much lower (ten times) than the carrier frequency. And the filtered signal, through a blocking capacitor C2, is already supplied to the amplifier input.
The MK also controls an additional light and music channel. An NPN transistor is used for this. Q1 in key mode, the base of which is connected to the MK leg "PB4/OC1B" through a current limiting resistor R1. There may also be a limiting resistor in the collector circuit ( R3) - will not be superfluous. The transistor is also controlled by a PWM signal. Everything is done very simply - in best traditions"blinking" LEDs from the Arduino :)
The power supply is decoupling tantalum ( C1), the simplest amplifier kit that acts as a decoupler ( C4), and adjusting the gain (volume), in general, can be found in the datasheet for the amplifier. If necessary, the gain can be calculated quite accurately using the most common method for op amps for the ratio of the resistances of the input resistor R4 and resistor feedback R5, since it can be useful to adjust the volume for a specific speaker or design.
Printed circuit board
Simple as hell, drawn in DipTrace:


This is already the third version, which takes into account all the previous shortcomings.
The board is designed for surface mounting and is single-sided, which greatly simplifies the process of making it at home. You can use any method: laser-iron, photo method, or even draw paths with a marker (not for everyone, of course).
All elements are 0805 (including “zero” jumpers), tantalum - A or B, a transistor in SOT23 and an MK with an amplifier in SO-8. All “peripheral” components - battery pack, speaker, LEDs and button (photoresistor, reed switch) are soldered to the corresponding “circles” on the board. That's all.
Software part

A little about sound synthesis

You can clearly read about the synthesis method used in the device in the original from Mr. Chan. You can also google “wavetable synthesis”. If you don’t speak the language, then in short, the audio sound is stored in the MK’s memory. sample(separate sound), so-called. "wavetable", which in our simplest case is conditionally divided into two logical parts, generally forming "envelope" - "attack", the beginning of each new sound, and "sustain", exposure, a fragment constantly looped throughout the sound of the note. Is there some more "decay", “follow-up”, the part that sounds after the note is taken down. In our case, it is simply implemented by gradually fading the sound of “sustain.” The MK has a timer that causes an interruption at a certain frequency, where, in accordance with the current position in the “envelope” and the pitch of the note, the desired value is selected from the sample memory. Moreover, In this way, you can synthesize several channels (that is, notes) at the same time, everything depends only on the computing power of the MK and the sampling frequency (sound quality). Then these values ​​are mixed and sent “to the output" (in our case, to the PWM control register). That's all. this disgrace, as I mentioned above, is called “Wavetable synthesis” or “table-wave synthesis”.


The core of Mr. Chan's synthesis remains virtually unchanged. I only changed the PWM output method a little, due to the abandonment of the “direct drive” of the speaker with the MK. I added a “trigger mechanism”, energy saving control of the MK and amplifier, and also wrote code for controlling the light and music channel, which works this way: according to a special event from the score to in the right places“lights” the LED, and then smoothly “extinguishes” it. Well, I “ported” (that’s a strong word, of course) the code to Studio, for convenience.
The code is written in AVR assembler and consists of several files: "mbox.asm"- actually, the program itself; "notes_pitch.inc"- indicating the correspondence of the mnemonic names of the notes used in the score to the increment coefficients of the pointer position in the sample (that is, as a result, the pitch); "wavetable.inc"- sample data (“table”) and attenuation curve “decay”; A "score.inc", as you probably guessed by the name, contains the score performed work, "notes".
Initially, in “wavetable.inc” Chan himself “hammered” the sound of the box. But if necessary and desired, it can be changed to any other using an auxiliary script "wav2asm.pl", or just with your hands.
The situation was more complicated with the score. Initially, they were supposed to be written by hand, which will undoubtedly bring a lot of pleasure to masochistic people, especially if the score is not at all simple.
For a person who is going to use his own score and, presumably, at least somewhat familiar with music and musical notation, it would be easier to draw the score in any available music editor and somehow use it. For this I wrote a special converter program, which takes as input a midi file of format 0, and as output gives the finished file “score.inc”. It can also independently arrange LED lighting events for all notes found in the first channel, that is, if the melody is initially logically separated from the accompaniment and placed in the first channel of the midi file, then we will get a score that will light the LED in time with the melody, if we want and check the box. In fact, this is perhaps one of the most beautiful options operation of the additional channel.
The program can also transpose the resulting score one or two octaves up/down, which in certain cases can greatly facilitate the work of writing the score.
The program interface looks simple, clear and unpretentious, and Delphi sources are included in the kit:

By the way, as someone suggested to me at the time (for some reason I didn’t think about it at all), there are a lot of resources on the Internet where you can get ready-made midishkas with the desired melodies. They will only need a little modification to be used in my converter. And some may not even need to be modified.

What else could you need?
Let's say you bought/obtained all the necessary components, made a board in one way or another, or, as an option, simply soldered everything by surface mounting. What else will you need? You will need a programmer. If you have had or are dealing with an AVR, then you most likely already have one. And so, for example, “USBasp” in hundreds of incarnations or any other will do. There is nothing supernatural here. The archive with everything contains an already compiled binary, which can be immediately uploaded to the controller and used if there are no intentions to edit or rebuild anything.

Application

And now, as promised, I’ll tell you and show you one of the hundreds of possible uses of the module, the Kawasaki musical rose.
Kawasaki rose, one of the masterpieces of origami, is completely separate big topic, which can be viewed in full on the Internet.
Structurally, the thing itself is made of two parts:
First, rose, folded from a colored sheet of paper and glued onto a twisted stem with leaves (also folded from colored paper). There is a thick copper wire running inside the stem (for strength) and a small neodymium magnet is hidden at the very bottom.
Second part, vase, cut and glued from thick white cardboard. Inside it is installed the module itself, a speaker (glued to a resonating volume filled with cotton wool), super-bright white wide-angle LEDs matted with fine sandpaper and a battery pack attached to the bottom of the vase for easy access to the batteries. And, of course, the reed switch is a “trigger mechanism” that works in tandem with a magnet in the stem. It is installed in such a way that the module is activated when the rose is removed from the vase.
Schematically it looks something like this:

Here are a couple of photos of the prototype:

And a video of the work. The video plays the composition “Tenderness”, which I arranged for the box, and which is included in the archive as the source (typed in Sibelius) and middling, as well as the finished generated score:

As usual, my eternal problem with normal sound in video makes itself felt. A thousand apologies. If you are interested in hearing how the design sounds in normal quality, you can download