DIY mechanical box. DIY: music box for a little princess (31 photos)

I came across interesting things from AliExpress on the lifehacker website. Namely, a mechanism for a music box. And without thinking twice I ordered this gadget for myself :)

I was very interested in this position because since childhood I loved to watch in films how the characters played a melody from boxes. I like the tone of such melodies, the rhythm and everything like that.
The idea itself is extremely simple. You can make any box with your own hands and insert the mechanism into it, you will get an original thing. But since my hands grow from the wrong place, I just like to listen to this melody without external embellishments. By the way, Castle in the Sky Theme Song is playing here. I don’t know where it’s from or who the author is, but I like it :)

The parcel arrived for about a month. Stopped tracking after crossing the border. Apparently the Chinese saved on a normal track code. Anyway.


Packed in regular package and thin paralon. No pimples :(


They also promised 4 screws, but there were only 2 in the package, but these are minor quibbles.
Dimensions 5 cm by 4.5 by 2 Everything is connected on one frame.


The sounds are produced by plates of different lengths which are caught by a small drum with protrusions in certain places. The Chinese love to have such drums for different songs, and it would be interesting to rearrange them depending on the mood.


Everything is driven by a spring, which is wound with a special key. There is nothing extra nanotechnological here :) To make the melody play more smoothly, there is a braking roller.




If you hold the mechanism in your hand, the sound is very quiet, but on the table you can hear everything perfectly.

The seller promises 500 repetitions of playbacks, in the future we will see how this mechanism behaves.

I'm planning to buy +19 Add to favorites I liked the review +40 +59

How to make a music box with your own hands aslan wrote in October 17th, 2018

From time to time they order music boxes for me. This good gift on memorable date. After all, every couple has their own melody? I want to tell you about such a box.


In general, I want to create my own mechanism for this, but for now I’m using the famous kikkerland 15. It has 15 voices and the melody itself is located on punched tape. I almost always have a couple of mechanisms in reserve. Fans have created a whole website with a collection of melodies.

The case is made of beech according to the customer's dimensions, usually I make very pocket-sized versions, here the size of the box is 100x100x70. The blanks were sawed down, the photo shows how the box was assembled.

Tape clamps are used to tighten the corners.

The lid, cut off with a margin, is glued on top.

Using a sander I give the lid the shape of a chest. And only after this the box is cut into halves and the mechanism is inserted inside.

We try on the tape; it should go into the box “blindly” without opening the lid.

The owner asked to have an engraving on the lid. No problem. All that remains is to clean the dust from the engraving and cover everything with varnish.

I am a lazy craftsman and I also make ribbons for the box using a laser. Although the kit comes with a special hole punch for this.

We try on the tape and listen to the melody. Everything worked out!

The ribbon fits completely into the box. It fits like an accordion into small boxes.

The hostess was pleased, for some reason this is very important to me. :)

If you have a production or service that you want to tell our readers about, write to Aslan ( [email protected] ) and we will make the best report that will be seen not only by readers of the community, but also of the site

Well, why else would I want to buy a music box? Then I saw a review, there I saw the mechanism - the puzzle came together and here it is on my table in a cute box.

You could already buy it on Aliexpress finished design, but then the toad woke up and started strangling me. Give more than 3 USD for a music box? If only it was made of gold and diamonds ( ok, cubic zirconia)...

It was decided to buy musical mechanism and make your own box.

Cost at the time of purchase: 2.9 USD

The mechanism was packaged in such a way that I thought at first that the seller had made a mistake and sent me the music box already in some kind of case. But when I unwrapped the package, it turned out that the bulk of it was packaging material. For what? ATTENTION: so that the cardboard box with the bow does not get wrinkled.

The mechanism itself is metal - it is unlikely that anything will happen to it, even if you step on it. Even the protruding part of the handle is very durable.

Everything is extremely simple. We take the mechanism, select or make the box ourselves, install the mechanism into the box with bolts... STOP! Where are the promised bolts?

I remembered about the bolts a week later, when I again went to look at the seller’s product description. In the photographs it has a mechanism with 3 bolts for fastening, but I received it without them. Where are my bolts???


I had to stick it to the bottom of the box with double-sided tape. And because my husband had a period called: " What else could be glued together with two-phase glue?", then the mechanism was placed on it for reliability. Is there a lot of glue left? It doesn’t matter... now we’ll seal the box tightly!

On my question: " Why did you seal the box itself?“There was no answer, the husband just shrugged his shoulders and smiled. I had to sigh languidly, shake my head and test the mechanism in action in the new case from the old Rocket watch.

I had to make a hole in the box for the pen. The Chinese Dremel easily coped with this task ( review will be). But why the husband needed to make a second hole again remains a mystery. The sound was exactly the same without it.

DESCRIPTION.

The mechanism and body are metal except for the plastic gears and inner drum. The knob rotates in both directions, but the sound only gives the correct direction.

Mechanism size 4.4 x 3.4 x 2 cm + rotating handle.


The pen has a movable tip for easy rotation.

The seller sent the order in random order and out of 6 melodies I got drum 002B with music - “Swan Lake Finale”.

There is a possibility that you can ask the seller to send a specific drum, but for this you need to know all their numbers and sounds. I was pleased with the seller's choice.

The sound will be loud if the mechanism is installed on a hard surface. In the box the sound is doubled. If you play a music box in the kitchen, you can hear it even in the room.

The melody is pleasant, I only noticed one fib at the end, but maybe that’s how it should be. The faster you turn the handle, the faster the melody plays and vice versa: the slower you turn, the slower the drum rotates.


FOR A CHILD.

I bought the mechanism for various reasons:

  1. I wanted to.
  2. Child development.

What can a child’s music box mechanism develop:

  • Logic and intelligence - where and how to turn to make the melody sound.
  • Hearing - pleasant melodies with the right notes.
  • Sense of beauty - Swan Lake and the music from it is a classic.
  • Fine motor skills - the handle is small and you need to hold it firmly with your fingers.
  • Sense of tact (rhythm) - rotating faster or slower sets the tempo.
  • Fantasy, imagination - if you make the body together.

CONCLUSION.

I was pleased with the mechanism and the child liked the music box. I don't mind the money spent. There was an idea to make a music box in the design style pasta and cereals, coffee beans, quilling or appliqués...

When I calmed down my raging imagination, I realized that the child would not let the design last long and the most reasonable option for a music box would be a tightly sealed square watch box.

I wish you happy shopping!

AliExpress is a wholesale online hypermarket. Ali's subtleties, his pros and cons, our endless orders (accessories, microcircuits, equipment, toys, for himself, etc.) in a photo report from a shopaholic.

Pay for purchases on Ali

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)!

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