Hi Bob
thanks for your kindly response
many years ago i have done some work with 8085 microproccesor,but thats all....
(The advantage of the chip I mentioned: no programming is required but it's so difficult to obtain.)
I'll be glad to learn how to accomplish this with microcontroller
Badi
Okay. I have experience only with PICs from Microchip. It is a fairly large investment of time (and a little money) to get started using them this way. Others here are experienced with Arduino and PICAXE which are a little simpler for beginners.
If you wanted to go the PIC route, I can help.
There are several common methods to get sound out of a microcontroller.
The simplest is to generate a square wave by toggling a pin at the desired frequency. This would create a harsh "electronic" sound, and could drive a speaker through a switching transistor or a pair of them.
The next is to use a DAC (digital to analog converter.) Some micros have these built in. Most do not have enough bits to do the audio you need (8 bits would be the minimum). There are a couple of dsPIC micros that have a 16-bit audio DAC, which would be overkill, but you could have a very nice sounding doorbell indeed! External DACS are also a possibility. DAC sound can reproduce any waveform and would sound more like a real instrument depending on how complex you want to make the software. This is how modern digital synthesizers work.
The third is to use PWM (pulse width modulation), and filtering to approximate the operation of a DAC. Many PICs and other microcontrollers have hardware for PWM that is capable of putting out 8-bit quality sound.
A subclass of the PWM method, one which I have just built into a robot project I am working on, would use an H-bridge like those used for motor control to control the speaker directly. This could be very small and dirt cheap since no amplifier would be need, only 4 cheap transistors like 2N2222 and 2N2907 or better 4 MOSFETs.
Now, once you have the ability to put out sound you can shape it in various ways (for all but the square wave method.) Typically, you use a wave table, which is a table containing the digital values for one cycle of the waveform you want to output. You then send the values from the wave table to the DAC or the PWM module (as duty cycle.) At this point you will have a constant sound which can sound sort of like different instruments during the sustained portion of a note being played.
The final thing you need to add is what is called the envelope, the variation in the level of the sound as a note is played. For example, a piano not would start out at full volume, followed by a rapid decay, followed by a slower decay. A violin note would start slower, building up to full volume, then could sustain at a given volume for as long as the note is played, followed by an abrupt decay.
Bob