# DIY Musical Keyboard

The idea is to design and construct an electronic musical keyboard with some functions, effects etc,. This is my old school project and I remake and modified it. It is fun.

There are many hobbyist’s musical keyboard circuits around the net.  Most design are based on 555 or some oscillator circuits. The limitation of these design are that this circuit generates only one tone at a time. To play a real chord, several keys  are to be pressed at the same time and generate multiple tones at the same times. Ie,. for 12 tones, there will be 12 frequency generators are required. If a keyboard has 48 keys, 48 tone generators are required.

This can be saved by 4060 CMOS logic chip. The 4060 is 14-stage ripple-carry binary counter/divider and oscillator. The internal function block diagram of 4060 from datasheet is as follows. Output Qn is the nth stage of the counter, representing 2^n, for example Q4 is 2^4 = 16 (1/16 of clock frequency) and Q5 is 2^5 = 32 (1/32 of clock frequency).

The frequency of chromatic scale can be learned here.

http://en.wikipedia.org/wiki/Chromatic_scale

http://www.harpsatsang.com/harp_design/data/frequencies.html

There are a relation between the frequencies of octaves scales. The first octave of  C1 (16.3Hz) is half of second octave C2(32.7Hz) and so on. The 4060 IC can divide its clock frequency via Qn outputs. We will need 12 x 4060 tone generators and it will supports 7 octave as maximum (12×7 = 96 tones, bingo).

Thus, the initial design is like that. The design is composed of 12×4060 tone generators, a dsPIC for sound effect and control, an amplifiers.

The first circuit is 4060 tone generators. The clock frequency can be calculated as f = 1 / (2.3xR2xC1). I plan to use 4 octaves (48 tones) and starting from C3(130Hz) to B6(1975Hz). You can choose what scales are used. For roughly calculation, the adjustable  frequency range of RxC circuit should be covered this selected range. For next expansion,  I prepared for 6 tones outputs in design.

Updated: thanks Rollicks for pointing the right frequency calculation f = 1 / (2.3xR2xC1).

The next circuits are simple 7805 power supply and LM386 audio amplifier. Nothing specials.

The first step is preparing the physical key and PCBs. The keys are salvaging from old toy china made keyboard. Unfortunately  the switches from toy keyboard used matrix keys. So, I made a PCB for switches also.

PCBs,

Prepared switches bar with the original switches dimension.

And next switches assemblies,

And circuits and wiring,

Initial setup is finished.

Tuning the frequency, I used my Nexus 7 and gStrings tuner app :D.  Thanks the developer for such useful applications. Only one octave is required to tune. Once,the C3, C4 or one of any note is tuned and the rest will be in-tune atomically because of frequency divider.

Finally, after some weekends and many coffees, the first phase design is like this.

The next step:

– You may notice the blank space at the moddle of board. Yes, this is for dsPIC sound effects and control

– I have to make a upside cover also.

Thought:

– The switches are not ease as original keyboard. I have to find more proper solution for final design.

– The LM386 amp is not matched with tones. I notice some distortion in low volume. I will replace with a proper stereo amplifier in next phase. I want the left and right octaves with separated effect and sound output.

For now, it is ready for open 7400 logic competition because it has only discrete logic :).

## 26 thoughts on “DIY Musical Keyboard”

1. Yaqub says:

Thanks, but are u have another smaller schematics? I interest to make it.

1. Hi Yaqub,
This is smallest schematic. You need 12x 4060 oscillator circuits to generate 12 music notes. you cannot reduce 4060 ckts. You can only reduce how many keys or octaves are used. Eg, 12 keys (one octave), 24 keys (2 octaves) ,…,72 keys (6 octaves). You may left LM386 Amplifier circuit if you already have another suitable amplifier.
keep in touch. this is a still developing project. Now, I am working on sound effects parts.

2. Rajthilak K says:

Hi,
I just need one octave (mid range), and i have no idea on the electronics part but i can get whatever is needed and solder, just need a simplified version 🙂 please do help. Since I have no idea on the electronics part it will be difficult for me to cut down from your bigger diagrams shown, it will be much helpful if you can just email or post the circuits and schematics just for an octave. thanks much.

Rajthilak K

1. Hi Rajthilak,
Problem is that. One 4060 IC can produces only one note. So, you still need 12 x ICs to get one octave (yes, the same as 6 octaves design). This circuit cannot be strip down.
You should consider simple 555 IC design for one octave. Like this,
http://www.instructables.com/id/555-Astable-Keyboard/

3. miique says:

Hi there, awesome project. Could you please post the files for the PCBs? Or are you waiting until you have a finished version of the project?

4. Dears,
Pls, send us your email and infor….
I have order for your co,
I want new disgen muisk keyboard pcb.
Thanks,
Louai

5. Rollicks says:

Hi, I love your keyboard! I’m wondering about a couple of things. Your Schematic says 0.01 capacitors are to be used for the timing capacitors, am I to assume that is a 10 nF? Also, the datasheet for 4060 says that frequency is f = 1 / (2.3 * R2 * C1) but you use f = 1 / (2 * Pi * R2 * C1), which do I use, sorry but I am a total newbie.

1. Hi Rollicks,
Yes, 0.01 uF is equal to 10 nF.
You are right, the correct freq calculation is f = 1 / (2.3 * R2 * C1). Some data sheet note that f = 1 / (2.2 * R2 * C1). Thanks for pointing this. Really, I adjusted variable resistor, R2 until the right freq is tuned. Calculation is roughly done to guess approximately whether the whole octave is cover by R2xC1.

6. Segun says:

Pls Can u help me with the circuitry?

7. Boateng Joseph Danso says:

How can sound effects be added to the circuit for it to be played as that particular instrument. thank you.

1. Hi,
My first plan is to add dsPIC for sound effect but I cannot implement it yet. It is still one of my ongoing project. If I have a little spare time, I will do it.

8. Nigel says:

Hi, have you managed to work out the algorithm for identifying each sound frequency? im referring to the programming of the dspIC.

1. Hi Nigel,
I have tested some sound effects such as echo, distortion, fuzz etc. I use Audio and Speech Lib from Microchip and it is straight forward. I don’t write own code for effects or no need to identify each freqs. I cannot finished actual circuit at the moment. I will release codes when it is ready but still under day jobs loading and it is one of my pending project yet.
http://www.microchip.com/pagehandler/en-us/technology/audio/basics.html

1. Shaun says:

Hi Oakkar7

If I leave out the dspIC and only use the tone gens how different will the output sounds be like? Can i play multiple chords at the same time?

2. Hi Shaun,
It can be but you will need
1# an algorithm for mixing/adding 2~8 freq in dsPIC. You need to mix different freqs by software before cord tone is leave out.
2# better choose dsPIC with internal DAC such as dsPIC33FJ64GP802

My initial design is to generate tones/cord by using only discrete parts because this is aimed an entry for
dangerousprototypes.com/category/7400-contest/
After a basic design is finished, I only used dsPIC for sound effects.

9. Nigel says:

hi oakkar7,

why do you need to connect multiple diodes at the output of the tone generators? does it affect the sound produced by the audio amplifier? Please advise.

10. Harshit says:

Greetings Oakkar7,
That is one nice project. I have been searching for something like this for a long time. Thank you 🙂 .
As far as I know, the circuit will generate a square wave. Can you please let me know how to produce a ‘piano sound’. Do I have to record the samples in some register(of uC or some other controller?) and send it when the key is pressed? If yes, can you please guide me through it.

Thanking you in anticipation!! 🙂
Regards

1. Dear Harshit, It is just an old school project with very basic parts and very simple method. Yes, its produce only square wave sound. My initial plan is to use dsPIC for sound effect such as piano sound. But it is still pending projects of mine. You can check available lib at Microchip website as a starting point http://www.microchip.com/SoftwareLib.aspx cheers,

11. Hi okkhar7,
I am designing a new touch button keyboard completely different from the standard music keyboard. This allows for blind people to learn logically.
Do you think you can supply me a very basic circuit board
1/ that can wire up a speaker,
2/ have individual pitch terminals in a row able to be soldered to wire up to 2 octaves in chromatic sequence for each separate switch button.

alan le chong
Educator

12. Chrit says:

Hi oakkar7!
I’m really interested in making your keyboard for a school project. Is there a parts list you could post? I’m a newbie to working with circuits, so I’m having a hard time figuring out what you used. Thanks for your time!
Chrit

13. Chrit says:

Hi oakkar7
I’m interesting in trying to build your project, but I am very new to building circuit. Do you have a parts list for this project? Thanks for your time.
Chrit

1. Hi Christ,
It is unfinished circuit although it can use as minimal tones without effect.
Pls see circuit 1,2,3(tones, power and amp) for required parts, that all for now.

14. mike wealter says:

Hi, Have you updated this project? It is very interesting to me and I wan to try it

1. Hi Mike,
Not updated this project yet.
But I will try it soon

1. hi i recently found an old accordion but the bass buttons where damaged so i gutted the bass side
i added a series of 12 button switches and a rs232plug to wire an old yamaha keyboard any ideas
afischetti46@hotmail.com like to hear from you thanks