My Project Notes
Dec 21, 2010
So I asked my Dad what he wanted for Christmas, and he said a Talking Metronome. He’s learning to play the piano you see and is dissatisfied with regular tick-tock metronomes. So I had a look around. Talking metronomes are not all that easy to buy. The only product I found was the Boss DB90 which costs $250 and is kinda complicated. So I have decided to build my own. How hard could it be?
I will be attempting to build this out of parts and software that I have already developed for other projects plus whatever I can find in my parts box. I’ll start with one of my RS422/485 Bit Rate Converter boards which has a really nice 32-bit ARM7 computer on it, wire it up to some buttons, an LED display and a DAC to produce the audio output.. I have only placed the parts for the CPU and switchmode power regulator, I won’t be needing the serial ports. That pin header is the programming port for the CPU.
I also have my MIDI Sync Box circuit board which I designed years ago when I thought I could launch a MIDI clock source device – I never launched the product but I have a few old prototype boards lying about. It’s perfect for mounting the LEDs and rotary encoder for the tempo knob. It also has all the multiplexing circuitry for the LEDs, rotary encoder and additional buttons. I won’t place the PIC microcontroller, I’ll just wire the ARM straight up to it.
I’ll have to change the resistor values for the LEDs because the board will now be running at 3.3 volts instead of 5 volts. I guesstimate that 100Ω should just about do it. Only problem is that I’m completely out of 100Ω through-hole resistors.
So today I have assembled the ARM board and tomorrow I will need to go shopping. The parts I will need to buy are:
Some 100Ω resistors
A small amplifier module which can run off 9-12V
A small loudspeaker
A suitable box to put it all in
Not that much stuff. I could probably have built an amplifier out of bits I have lying around but a pre-built module will save me a lot of time.
I made it down to Jaycartoday and bought all the bits I was short of. These guys aren’t all that cheap but time is short and I really need to get the parts today. They also had a neat little 0.5 watt amplifier kit called “The Champ” which can run off 4 – 12V. Perfect.
I assembled the amplifier, speaker and volume control in about 15 minutes. The sound is a little buzzy but what do you expect for $8. It will do just fine.
I also wired up the MIDI Sync board. I have decided to completely finish the circuitry before starting on the software to save time but it’s a little risky to my schedule. There are still a lot of unknowns in this project – will the ARM be able to stream the audio to the DAC fast enough? Will it all fit in the box? Will the sound quality be OK? Will I be able to write the software in time? There are many things which could go wrong and I don’t have the time to build this carefully, testing each stage as I would normally do. I am just blasting ahead with confidence in myself that I have the skill to make this work.
So next is the DAC. I found a few different DAC chips in my parts box and after reading the data sheets for a few of them, I have decided on the AD558 which is a very simple 8-bit DAC with a built-in data latch. I need the latch because I will be sharing the data bus with the buttons and LEDs. I just tossed this onto a piece of veroboard. The only external component is a 7805 voltage regulator because the DAC runs off 5V and cannot share the 3.3V supply from the ARM. I won’t need a level converter for the data bus because the ARM can pull the data lines up to about 3.2V which is high enough for the DAC.
After wiring the ARM up to the MIDI Sync board, I have realised there is a fatal flaw in my plan! After checking the electrical specifications for the ARM7, I discover that the output pins can only supply a maximum of 2 milliamps each. I need more like 25mA to drive the LEDs. So I guess I’ll need a driver chip of some sort. I have a 74HC244 in my parts box which would be perfect but now I have to wire that up too. This thing is getting more complicated than I had planned.
Time for a re-think. After a little time-out and thought I have devised a new plan. I’ll fit the 8-bit PIC microcomputer to the MIDI Sync board and use it to drive the LEDs and read the user input. This will actually make the job easier as I already have PIC software written to do this from the MIDI Sync Box project. The PIC can send serial data to the ARM and all the ARM has to do now is play back the audio samples when instructed to do so by the PIC. I like this new design even though there are now two computers in the box! Talk about overkill, I am going for speed rather than elegance here.
It took me a little while to find my original code for the MIDI Sync Box, set up all the compilers and tools and get it running but I now have the LED display, all the timing, tempo control and start/stop control done.
I’ve finished all the wiring. It looks a mess but I’m confident that it will work. Of course it won’t do anything until I write the software. There are four circuit boards here:
The PIC Board – Contains a PIC 8-bit computer. Handles user input, LED display and generates all the timing (you can’t see the PIC in this photo because it’s on the other side of the board).
The AMP Board – 0.5W amplifier to drive the speaker.
The DAC Board – Converts digital data from the ARM into analogue sound waves.
The ARM Board – Contains a powerful 32-bit ARM computer which is kind of wasted because all it does is shovel audio data into the DAC.
I recorded my audio samples using Audacity and downsampled them all to 8kHz so they will fit in the ARM’s memory. I only had a 64k ARM in my parts box, both the program and the audio samples need to fit into that space. I won’t have time to write an MP3 decoder or anything so it’s going to be 8-bit uncompressed PCM samples. I didn’t need to worry though because I’m only recording the numbers 1, 2, 3, 4 and as it turned out, they all fitted into 4k.
Writing the software had it’s ups and downs. About 80% of the code was recycled from other projects, stuff to boot up the ARM, timer interrupt handlers, UART drivers and that sort of thing. The only bit I had to write from scratch was the DAC driver and audio replay code which ran to only about 150 lines of code but for some reason took hours to get working. I had to make a few modifications to the PIC code also to send serial UART commands to the ARM, this was written in assembler which I generally avoid like the plague these days as it always takes longer to get things done in assembler. Anyway it is done and after whacking a couple of bugs, it works reasonably well.
Now to shove it all into a box. The software took most of today and it’s getting late, I’ll leave the box mounting for tomorrow.
I’m really running out of time now. I need to get this thing into a box and looking nice ASAP.
At this stage I’m not 100% sure it will fit. I chose the box on the basis of “Oh, that a pretty box and seems to be about the right size”. As an emergency plan B, I bought another slightly larger one in case it didn’t fit but I’m going with the smaller box because it looks prettier than the plain boring square black larger box.
Drilling and cutting all the holes for the controls took some considerable time. Mechanical work is not really my forté but I managed to pull it off without spilling any blood, destroying the boards, the box or any tools. I had to be really quite precise because it’s such a tight squeeze, I didn’t have much choice where to place the controls. The rectangular hole for the LEDs was also a challenge for my mediocre workshop skills – but I like a good challenge!
I used some PCB standoffs to bolt the ARM board to the PIC board. I had to drill some holes and hack a couple of chunks out of the PIC board to make it fit. The DAC board was glued on to the ARM board (I love hot-melt glue!) and the amp board is just kind of crammed into the end. The speaker goes underneath where it almost fits but a little brute-force got it in there. I had to re-do a lot of the interconnecting wires to make them shorter or longer as neccessary and phew! it just fits!
The lid goes on easily and I even have easy access to the programming connector so I can do software updates! The PIC is socketed so if I want to update it’s software, I can pull it out and reprogram it.
And I’ve still got a few hours spare so I resampled the audio. The 8kHz samples sounded very Speak & Spell so I re-did them at 22kHz and it’s good now.
My Dad should be pleased.
Now I can go and spend some time with my family. I’ve been cocooned in my office for the last couple of days working on this and haven’t seen them much.
Merry Christmas everyone.