You Are Here: Home » AVR ATmega Projects » Sound - Audio Projects » Digital voice recorder using Atmel Mega32 microcontroller

Digital voice recorder using Atmel Mega32 microcontroller




Our project is a digital voice recorder with distortion abilities that stores multiple tracks onto a DataFlash memory card.

We programmed an Atmel Mega32 microcontroller to sample a microphone, and store the samples into an external memory source.  We give the user the option of recording multiple tracks, and playing back any track at any time.  The user interface is clearly displayed on an LCD.  As an interesting feature we added the ability to change the frequency of ones voice.  This we added to create an interesting effect.  We chose this project because it utilized and expanded upon many of topics taught in ECE 476.  It also involved the many disciplines within electrical engineering, including embedded systems programming, analog design, and digital signal processing.

High Level Design

Rationale and Sources of Project Idea

We were intrigued by this project because it incorporated so many areas of electrical engineering.  Also, the thought process we used to come up with idea involved thinking of household electronics items that we could use the microcontroller to create.  Several items seemed to simplistic (for example an alarm clock), and others we felt were not realistic goals (such as a printer).  A digital answering machine came to mind.  It seemed to have an appropriate level of complexity, and that is what we modeled our project after.  To simulate someone talking over a phone, we had a microphone circuit.  We had external memory to allow us to store more data.  Then, we had track functionality, to simulate multiple messages.  We added voice distortion as a fun feature.

Background Math

The main math revolves around the Nyquist frequency.  An established fact is that the human voices highest frequency is 4000Hz.  In order to get all the Fourier components of a period signal, one must sample at twice the highest frequency.  So in this case, we sampled at 8kHz.  All other math involved in this project, was dedicated to designing filters with the appropriate cutoff frequencies, and code to maintain this sampling rate.

Logical Structure

The backbone of this project is the microphone and the circuit that accompanies it.  Without this, we could not realistically test the other components of the design.  After this part worked, we implemented code to run the DataFlash.  This was necessary, since to record any significant amount of sound, we needed to hook up an external memory source.  To actually get an accurate output, we also had to add a DAC circuit.  We tried a PWM and a DAC, and a DAC proved to be more accurate in being able to reproduce the human voice.  Finally we added a user interface, voice distortion, and the ability to record and playback multiple tracks.

Hardware/Software Tradeoffs

We made compromises in order to get our project into a state where it would demo able.  The first is the decision to use DataFlash over secure digital card.  We spent many hours in lab trying to get SD to work.  However, after realizing that there was a chance that we may not get it working in time, we made the decision to start the implementation of DataFlash.  Part of the reason SD was so difficult was the lack of any buffer.  This made the timing all the more sensitive.

Program and Hardware Design

Digital voice recorder

Microphone Circuit

We started out our project by designing a filter and amplifier for the microphone. The following diagram shows our design.

This circuit can be divided into four parts, microphone, high pass filter, 3 stage amplifier and a low pass filter for easy understanding. Unlike the common 3 pin versions (vcc, gnd and output) our cheap microphone (Model Number: MD9745APZ-F) had two pins one for ground and one for output. Since there were no vcc we had to pull up the output using a 2.2K resister to the vcc of 5V to provide current for the microphone.  Microphone had constant frequency response from 100Hz and an upper frequency 3db cutoff at around 6Hz. This was more than enough for our voice recorder since human voice was in the range of 150Hz to 4kHz. The frequency response of the microphone is given bellow.

The next stage is the first order RC high pass filter and it is built by a 1uF capacitor (C1) and a 1kΩ resister R2 in series. The cut of frequency of this high pass filter is at around 160 Hz which is close to the lower limit of human voice spectrum. The base frequency of the human voice is around 400Hz. This filter cuts off the 60Hz noise from the surrounding electronic equipments while passing in human voice.  It also cuts of DC to give us a pure signal.  In the next part of the circuit this signal is amplified using three identical non inverting amplifiers. These amplifiers are built using LMC7111 opamps. We are running these opamps using +5V and Ground power supplies rather than +/-5V supply voltage. The reason for this is that we can only sample 0 to 5V using the mega32 ADC.

The gain is set by R2 and R5 (R5/R2) for the first stage and R6 and R7 for the second stage(R7/R6) and R8 and R9 for the third stage (R9/R8). Resisters connected to v+ of the opamp are for offset. This is done to ensure that the final output signal is centered on 2.5V which will represent 0V signal in ADC.

The third part of the circuit is a simple first order RC low pass filter which is made of R10 (12KΩ) and C2 (4.7nF). The cut off frequency of this filter is 2821Hz which is above the common human voice of 2000Hz.   The Nyquist frequency for 2821hz is 5642 which is way bellow the sampling frequency of 8Kz. Thus this filter reduces aliasing.

Program and Hardware Design




The next step in our project was writing code for the Mega32 ADC. This was very simple and closely resembled old lab projects. Since we were only planning to sample at 8bits per sample we only read from the ADCH register. We read from ADCH in timer0 interrupt which fired at 8kHz, our sampling frequency. To test this we stored these values in eeprom and outputted to the LEDs in STK500. We were only able to store  th  of a second in eeprom.

 Parts list:

ItemQuantityTotal Price
STK5001$15.00
White Board2$12.00
Atmel Mega321$8.00
LCD (16×2)1$8.00
Microphone1$0.50
OpAmps3$0.00
DataFlash1$0.00 on STK500
Resistorsmany$0.00
Capacitorsmany$0.00
Total$43.50

For more detail: Digital voice recorder

Leave a Comment

You must be logged in to post a comment.

Read previous post:
ISREVER (Reversi) video game

WELCOME TO ISREVER by Maria Seghete and Deanna Laufer About ISREVER Welcome to our ISREVER Game !!! Our game is...

Close
Scroll to top