Robotics/Components/Audio

The audio components of a robot are those parts that allow it to make sounds, either for entertainment purposes or to convey information.

This can be done through simple sound chips: cheap integrated circuits which allow certain sounds to be played with very few external components. These are commonly used in toys.

Other means are memory chips storing samples, a DAC and an amplifier, an MP3 player or voice synthesiser software on a portable PC.

The Theoretical Edge
Generating simple sounds is easy. All you need is an oscillator in the range 20 to 20.000Hz, an amplifier and a speaker. Such a circuit can generate any tone that a human can hear. By changing the frequency of the oscillator you change the emitted tone. Qbasic has a command that does just this: sound. Sound lets you specify a few parameters, with the most important being the frequency. By changing this frequency over time simple sound effects could be produced.

A better way to generate sound is sampling:

A sound wave has an intensity that varies over time. A microphone (with preamplifier) can convert this intensity to an electric signal with the same shape. An Analog to Digital Converter (ADC) can then convert this electric signal in a digital number. This is, however, not a continuous process but a discrete process, this means that every x ms the amplitude (voltage or current) of the signal is measured and converted to a digital number. This results in a digital approximation of the original signal. How good this approximation is depends on how frequently the signal is sampled. Of course more samples means more memory space is consumed and also more expensive hardware is needed. The price of an ADC depends on precision (how many bits represent the sample) and how many samples it can take per second (there are more parameters, but those are pretty much out of scope for this book).

Now you have an array of numbers. Of course now you want to turn this array back into sound. This is done with a Digital to Analog Converter (DAC). This part converts a digital value back into an electric signal. After this DAC there is a filter to smooth the wave, an amplifier and a speaker. Feed the array sample by sample to the DAC at the same rate as they were sampled and you hear the original sound back.

The advantage of this approach is it's (relative) simplicity. The disadvantage is its enormous memory consumption.

More advanced methods would be storing encoded sound (e.g. MP3). This is more tricky since it needs a decoder, yet these days integrated circuits with complete mp3 decoders exist, which makes this an interesting method to look for.

The Different Components
this section should cover some basic info on these circuits and ICs

Preamplifier
A preamplifier is used when a signal with very small amplitude has to be amplified. Preamplifiers are very linear (they cause very little distortion in the signal) but are very inefficient with power. They amplify a signal, coming from e.g. a microphone, which commonly has an amplitude of 1mV or less to a more useful amplitude of 100mV and up. Since they are so inefficient preamplifier circuits aren't used for power amplifiers.

Amplifier
Amplifiers allow a low power signal to be outputted through a speaker with significant power. Amplifiers commonly allow some distortion of the signal in order to preserve power. (except for class A amplifiers which consume a lot of power, but have little distortion).

Amplifiers can be built with ICs, discrete components or bought as a module.

Analog to Digital Converter ADC
An analog to digital converter (short: ADC) converts an analog signal to a digital value. ADCs have a certain accuracy, expressed in bit, e.g. 8bit, 10bit and 16bit. This means that the ADC will have a binary number with 8, 10 and respectively 16 bits. The highest value represented by this binary number correspondents to the reference voltage put on a special input of the ADC. e.g. If we have an 8bit ADC and we put on this special input 5V, then the value 255 means 5V. It's precision will be 1/255 * 5 V or 0.02V. Each time we add 1 to the binary number, the represented voltage increases by 0.02V. A second point about ADCs is their timing. ADCs take some time to do a conversion. The faster they are, the more accurate they digitalise the signal (or in other words the higher the frequency of a signal can be), and the more expensive they are.

Digital to Analog Converter
The DAC converts a digital value into a voltage level. The work either with a reference voltage or "rail-to-rail", which means that their highest digital input value represents a voltage level (almost) equal to the DACs supply voltage. Simulare to the ADC the DAC has a certain accuracy in bit and requires some time to make a conversion.

Oscillators
An oscillator generates a repetitive signal. This can be of pretty much any shape you want, but most common shapes are sine, square, saw-tooth and triangle waves and many different forms of pulses.

Dedicated sound Chips
There are many ICs specially designed for producing sound effects.


 * Oscillators: These output a signal with a user definable frequency. By varying the frequency you can make different sound effects.
 * Sound chips: These output particular sound effects (e.g. motor sounds). These can't be changed.
 * Sound recording and playback chips: These can record sounds for a short period of time (some can record several different samples) and can play these back afterward.