Difference between revisions of "Miffy surprise"
Line 16: | Line 16: | ||
[[Image:Michai_017_big_bush_back.jpg|thumb|'''Fig.7: lightshow-bush, back.''' Wiring is slightly less boring, with 4 series-chains of 4 LEDs each.]] | [[Image:Michai_017_big_bush_back.jpg|thumb|'''Fig.7: lightshow-bush, back.''' Wiring is slightly less boring, with 4 series-chains of 4 LEDs each.]] | ||
− | [[Image:Michai_017_board.jpg|thumb|'''Fig.8: the board.''' Not extremely interesting, is it: a | + | [[Image:Michai_017_board.jpg|thumb|'''Fig.8: the board.''' Not extremely interesting, is it: a relay, an MCU, a transistors for each of the 4 'walklight'-channels, a zener, and a few resistors.]] |
[[Image:Michai_017_snug_fit.jpg|thumb|'''Fig.9: a snug fit.''' Everything is designed ''genau wie die Profis'' as they say in France, to fold together into a box-shape. Electronics is hidden under the 'floor' on which Miffy stands.]] | [[Image:Michai_017_snug_fit.jpg|thumb|'''Fig.9: a snug fit.''' Everything is designed ''genau wie die Profis'' as they say in France, to fold together into a box-shape. Electronics is hidden under the 'floor' on which Miffy stands.]] | ||
Line 56: | Line 56: | ||
Then, made some C-functions to do stuff I often needed in tunes, e.g. play 3/4 of a 'tune tick' (god I am so music-unclued, my dad would be ashamed if he read this...), and then 1/4 silence. For more clue, see the source - I tried to find a nice balance between RAM- and flash-use, wallclock-time until I had to sod off, and remaining mental capacity. (In fact I made some basic music-playing stuff earlier already, but some shaving was required to make it all fit after adding the light-thingies - see below). | Then, made some C-functions to do stuff I often needed in tunes, e.g. play 3/4 of a 'tune tick' (god I am so music-unclued, my dad would be ashamed if he read this...), and then 1/4 silence. For more clue, see the source - I tried to find a nice balance between RAM- and flash-use, wallclock-time until I had to sod off, and remaining mental capacity. (In fact I made some basic music-playing stuff earlier already, but some shaving was required to make it all fit after adding the light-thingies - see below). | ||
− | While the actual notes were generated by hardware (toggle speaker-pin on timer overflow), the actual changing of tones/volume by setting timer-registers was done from the main loop in the code. | + | While the actual notes were generated by hardware (toggle speaker-pin on timer overflow), the actual changing of tones/volume by setting timer-registers was done from the main loop in the code. '''XXX add MP3-url but grrrrrrrrr I forgot it now!''' |
=== Light === | === Light === | ||
Line 70: | Line 70: | ||
=== Power supply and control(s) === | === Power supply and control(s) === | ||
− | All is fed using a 9V 'block' battery, | + | All is fed using a 9V 'block' battery. I didn't want it to consume any power while 'off', and yet not have a physical 'on/off'-switch but instead a pushbutton; therefore, after trying and failing to get no power consumption using a transistor plus time being a factor, I used a 5V-relay. |
+ | |||
+ | Pushing the button would cause the relay to close, thereby feeding the MCU, which would itself assert a pin to activate the relais itself, thereby keeping itself happy. After playing all tunes, the pin goes low, the relay opens, and the show ends. How very simple. | ||
== Cardboard-ware == | == Cardboard-ware == | ||
+ | |||
+ | So ok, that's for the playskool-electronics. Now for the cutting/glueing/cursing bit: making a cardboard frame to hold everything, making nice decorations, cutting it into a nice shape, and making it fold together nicely to be carried sensibly. Oh, and spraypainting (as always). | ||
=== Fold-together box === | === Fold-together box === | ||
− | .. | + | After searching for a reasonable box that wouldn't require too much mods, and giving up, I took a big box and cut my own DIY-box parts out of it. |
+ | |||
+ | The idea was to fit everything into a 15x15x15 cm cube, where, when unfolded/opened, the underside and backside would stay put, the left-, right- and front-side would fold down, revealing lots of glued-on goodies that were on the inside of the box until then. | ||
+ | |||
+ | The backside was meant to be some very basic forest-scenery with Miffy itself, the song-indicator bush, and the lightshow-/congratulations-bush. Reality was slightly different, since the (green) spraypaint was really glossy and much darker than intended. Oh well. | ||
+ | |||
+ | Used a liberal amount of Pritt (or the El-Cheapo version thereof), a set of color-pencils I got earlier, and knife/scissors. Really not that interesting to go into more detail I think; look at the pretty pictures. | ||
+ | |||
+ | The bottom 2cm of the box were ''another'' box, that opened towards the underside, and to be used by the developer only, to put in the electronic innards. | ||
+ | |||
+ | I haven't used Pritt (nor El-Cheapo version thereof) since primary school or something. I remember one kid actually eating Pritt (and surviving - I think he's still alive, in fact). | ||
=== Other stuff === | === Other stuff === | ||
− | + | Ah well, apart from the actual box, there are decoration-bushes, a 'Miffy-holder' to keep the poor rabbit in place, holes for the wires to/from the indicator-/lightshow-bushes, and holes for the speaker (it was really silent without those - not weird, considering there was a good 1.5 cm of cardboard between speaker and ear, at first. Pritt is nice. :-) | |
== Painting, drilling, sandpapering etc == | == Painting, drilling, sandpapering etc == | ||
− | + | Unfortunately there was no sandpapering nor drilling - sorry, [[User:Pit|pit]]. If I had to do it over again, I wouldn't use spraypaint; spraypainting cardboard is like spraypainting a sponge. Perhaps some roller + thicker paint would have been much nicer. And so on, and so forth. | |
− | + | Why is spraypaint so expensive btw? | |
− | == | + | == Conclusion == |
− | + | Ok, worked for about 14h straight, then it was 'presentable' (let's call it 'finished') Wrapped the thing in wrapping-paper, made a lid with 'lift cover' to make it auto-unfold upon opening, and done. Gift was very well received, so there :-) | |
− | + | ---- | |
− | + | Have fun -- [[User:Michai|Michai]] |
Revision as of 15:24, 2 February 2009
Contents
So... WTF?!
As a surprise-gift for some combined events (among which, a birthday), I thought it was fun to make something that involved electronics at least to a minimal extent. It was not until later that I found out that such a thing is called a music-box and is available in the stores - but ok, this would be a customised music-box.
Of course, why repare while you still have lots of time, while you could wait until deadlines become a factor, and stress yourself? This was no exception; 16 hours to go until I physically had to leave the house and catch bus/train/plane to deliver the result (whatever it would be), so let's go.
Disclaimer
Basically, I don't have time nor mood to answer/respond_to time-wasting /useless comments. E.g...
- code is not perfect, ...
- note-frequencies are not perfect, ...
- my cardboard-skills suck a bit, and...
- yes, the used tints of spraypaint are way off from what was intended, ...
- it still smells of spraypaint even now, and of course...
- electronics are crude, and may hurt the delicate designer's feelings.
So there. Really, I'm a nice guy, but really, get off my back. But constructive comments are of course always welcome! :-)
Oh, and CBA to make a schematics. It's so very simple - all relevant things are explained in normal English below, anyway.
Hard-/software
Faithful workhorse is Atmel ATtiny 2313 (2kb flash, 128 bytes RAM) with internal 8 MHz RC-oscillator. Its main task is to play some tunes in a row when a button is pressed, while performing a simple lightshow.
Sound
For sound I used literally what was closest at hand, namely a speaker from a PC within 50cm reach. I think it's connected to a digital out of the MCU, with a 220 ohm (or something) resistor in series. Even googled a bit as to make it nicer a bit, then decided to CBA and leave it at this.
Notes are played by using a timer (I think 8-bit) which toggles the corresponding output pin 'from hardware' (so, no ISR) on counter overflow or reaching TOP (I forgot which - who cares).
After (stupidly) 'trying' to come up with some nice note-frequencies, finally got smart and used an existing note-frequency table. Choose nice timer-prescaler, divide, #define, and sito presto, we are able to play notes. For 'silence' I used the lowest frequency possible iirc, so this 'silence' might in fact not be silent for dogs :-)
Then, made some C-functions to do stuff I often needed in tunes, e.g. play 3/4 of a 'tune tick' (god I am so music-unclued, my dad would be ashamed if he read this...), and then 1/4 silence. For more clue, see the source - I tried to find a nice balance between RAM- and flash-use, wallclock-time until I had to sod off, and remaining mental capacity. (In fact I made some basic music-playing stuff earlier already, but some shaving was required to make it all fit after adding the light-thingies - see below).
While the actual notes were generated by hardware (toggle speaker-pin on timer overflow), the actual changing of tones/volume by setting timer-registers was done from the main loop in the code. XXX add MP3-url but grrrrrrrrr I forgot it now!
Light
What's a good show without some light-effects? Nothing, that's what. There would be 2 light-thingies (although I considered adding a lot of 'always-on' LEDs to make it less gloomy, but no time for that anymore):
- a 4-LED indicator of which song was currently playing
- a 4-channel 'walking light' thingie with various effects
I won't even discuss the song-indicator because it's trivial.
The 'walking light' (jeez what's this called in English?) thing was nicely done using Adam Dunkel's 'coroutines' (or a bastardisation thereof). Very nice for state-machines, which it was, running from a 10 Hz clock interrupt. I think each 'channel-chain' consisted of 4 LEDs - 1 of each colour - and a 100 ohm resistor in series, turning them on/off using a BC547.
Power supply and control(s)
All is fed using a 9V 'block' battery. I didn't want it to consume any power while 'off', and yet not have a physical 'on/off'-switch but instead a pushbutton; therefore, after trying and failing to get no power consumption using a transistor plus time being a factor, I used a 5V-relay.
Pushing the button would cause the relay to close, thereby feeding the MCU, which would itself assert a pin to activate the relais itself, thereby keeping itself happy. After playing all tunes, the pin goes low, the relay opens, and the show ends. How very simple.
Cardboard-ware
So ok, that's for the playskool-electronics. Now for the cutting/glueing/cursing bit: making a cardboard frame to hold everything, making nice decorations, cutting it into a nice shape, and making it fold together nicely to be carried sensibly. Oh, and spraypainting (as always).
Fold-together box
After searching for a reasonable box that wouldn't require too much mods, and giving up, I took a big box and cut my own DIY-box parts out of it.
The idea was to fit everything into a 15x15x15 cm cube, where, when unfolded/opened, the underside and backside would stay put, the left-, right- and front-side would fold down, revealing lots of glued-on goodies that were on the inside of the box until then.
The backside was meant to be some very basic forest-scenery with Miffy itself, the song-indicator bush, and the lightshow-/congratulations-bush. Reality was slightly different, since the (green) spraypaint was really glossy and much darker than intended. Oh well.
Used a liberal amount of Pritt (or the El-Cheapo version thereof), a set of color-pencils I got earlier, and knife/scissors. Really not that interesting to go into more detail I think; look at the pretty pictures.
The bottom 2cm of the box were another box, that opened towards the underside, and to be used by the developer only, to put in the electronic innards.
I haven't used Pritt (nor El-Cheapo version thereof) since primary school or something. I remember one kid actually eating Pritt (and surviving - I think he's still alive, in fact).
Other stuff
Ah well, apart from the actual box, there are decoration-bushes, a 'Miffy-holder' to keep the poor rabbit in place, holes for the wires to/from the indicator-/lightshow-bushes, and holes for the speaker (it was really silent without those - not weird, considering there was a good 1.5 cm of cardboard between speaker and ear, at first. Pritt is nice. :-)
Painting, drilling, sandpapering etc
Unfortunately there was no sandpapering nor drilling - sorry, pit. If I had to do it over again, I wouldn't use spraypaint; spraypainting cardboard is like spraypainting a sponge. Perhaps some roller + thicker paint would have been much nicer. And so on, and so forth.
Why is spraypaint so expensive btw?
Conclusion
Ok, worked for about 14h straight, then it was 'presentable' (let's call it 'finished') Wrapped the thing in wrapping-paper, made a lid with 'lift cover' to make it auto-unfold upon opening, and done. Gift was very well received, so there :-)
Have fun -- Michai