Atmega 32 AVR ?

mik3

Joined Feb 4, 2008
4,843
I don't know much about AVRs but PICs have the ds30 series which are actually DSP processors and can have sample rates of 1MHz or more.
 

hgmjr

Joined Jan 28, 2005
9,027
Yeah mik3, audio sampling and post-processing of the sampled signal takes a good deal of throughput. This is typically the province of DSP devices (digital signal processing).

hgmjr
 

Thread Starter

Mathematics!

Joined Jul 21, 2008
1,036
Ok , what happens if I take a .wav file raw audio clip and store it into
eeprom then send it out a pin on the avr to a 8 ohm speaker. Then will I hear the audio clip.

I don't really know how much current/voltage is coming out a pin. I know the supply voltage is 4.5 to 5.5 volts for the chip. So I don't know how much to amplify the the digital signal . And how a digital pulses would sound on a speaker?

As for the low pass filter I am just wanting to generate sine waves at some low frequency. After I get this I wanted to do a simple varations of the frequency of the waves say going from 250Hz to 170 Hz range.

I have yet to figure out the R and C values for the low pass filter and how fast I should vary the frequencies using PWM out the pin?

Forget the analog sampling idea I understand that this really requires DSP. Forget Analog input sampling!

But is their away to produce sine wave outputs on a pin at faster then the chip speed with some circuit?
 
Last edited:

hgmjr

Joined Jan 28, 2005
9,027
If all your are wanting to do is generate output sinewaves of frequencies less than 250 Hertz, then the AVR should do nicely. I would recommend that you make sure that you are using the maximum operating clock frequency for which the ATMEGA32 is rated.

You will need to provide your ATMEGA32 with external sram in which to store any significantly complex signal.

hgmjr
 

mik3

Joined Feb 4, 2008
4,843
First, you cannot drive a speaker directly from a microcontroller.

Second, you need a uC with an analog output which can reproduce signals up to 20 kHz. Most uCs don't have analog outputs. However, you can use an external DAC chip to produce an analog output. This will require that the uC is able to process the audio data and output a value with at least 40 kHz as to reproduce the audio signal fairly good (high frequencies won't be very good but you will be able to understand).

Search for the proper uC and you may do it. :p

Also, you will need an audio amplifier to amplify the analog output of the DAC or the uC itself if it has one.
 

hgmjr

Joined Jan 28, 2005
9,027
Mik3,

The OP is looking at using PWM and a low-pass filter to reproduce the audio output.

I recommended earlier that he would need some sort of buffer i.e. an opamp perhaps.

hgmjr
 

mik3

Joined Feb 4, 2008
4,843
Of course, he will need MOSFETs to buffer the uC's PWM output and a MOSFET driver IC or BJTs to drive the gates of the MOSFETs.

For more information on this a search in google about D class audio amplifiers will help.
 

Thread Starter

Mathematics!

Joined Jul 21, 2008
1,036
I figured out how to create the sine waves with R2R ladders and a capacitor.

I am also working on the low pass filter way.

Never mind about sending audio.

I am just curious of this one last question below.

Say you where to ampilfy a digital audio signal so it is the correct voltage/current for an 8 ohm speaker. If you where to send the digital signal to that speaker would the audio sound just like the equivalent analog voice audio signal?

I guess what I am getting at is do you have to convert to analog before you send it to a speaker for it to sound like audio? Or does it not make much difference if the speaker get's sent digital as oppose to analog signal?

I am wondering if digital would give you some kind of sharp clicking noise or something?
 
Last edited:

mik3

Joined Feb 4, 2008
4,843
Speakers work fine only with analog signals. If you send 1 and 0 to a speaker which represent the audio data then the speaker won't reproduce the desired sound. You need to convert the digital signal into analog first and then amplify it.
 

hgmjr

Joined Jan 28, 2005
9,027
I'm glad to see you believe you sorted it all out. I look foward to you returning to this thread to report you results.

hgmjr
 

hgmjr

Joined Jan 28, 2005
9,027
Here is a link to an ATMEL application note on the use of PWM to generate an analog signal. Im sure there are many other Internet links that would provide other insights into the technique.

hgmjr
 

Thread Starter

Mathematics!

Joined Jul 21, 2008
1,036
Posting my results

http://www.ke4nyv.com/picprojects.htm this is how I made my R2R ladder for the sine wave I used 4 pins. But I will probably modify it latter to add more resistors and pins.

As for sending a speaker digital signals. Will it sound like a clicking noise or something if I put a capacitor between the pin and speaker so the digital signal is an exp curve while dischargeing/chargeing the capacitor. It will look like an AC exp curve which is sort of analog.

What I am getting at is can you use a digital signal to a speaker to make one particular sound. Kind of like a alarm or buzzer.

Anyway Now I believe if you want to do Audio applications you need to use a DSP. Just curious does computer sound cards have a DSP on them or do they just have DAC and ADC chips. Because I am wondering how the sound cards process the analog signal of a mic and how the process digital signals from a .wav file to the speakers? I see about 4 chips on my sound card.
 

mik3

Joined Feb 4, 2008
4,843
You can send a square wave to a speaker (ie digital signal) and hear a tone depending on the frequency of the wave.

In the sound card there is a DAC, a ADC and a kind of controller to control the DAC and ADC and exchange data with the computers CPU. I am not sure if signal processing is performed on the sound card or by the computer CPU itself. I think the audio processing is done by the computers CPU and the controller on the sound card just controls the data flow.

What is more, there is an audio amplifier on the sound card to drive the headphones and a pre-amplifier for the mic input.
 

hgmjr

Joined Jan 28, 2005
9,027
Just curious does computer sound cards have a DSP on them or do they just have DAC and ADC chips. Because I am wondering how the sound cards process the analog signal of a mic and how the process digital signals from a .wav file to the speakers? I see about 4 chips on my sound card.
Most DSPs have built in A-to-D converters. I think that DACs, if needed, are implemented externally.

hgmjr
 

Thread Starter

Mathematics!

Joined Jul 21, 2008
1,036
If I buy some DSP chips are they programmable like the AVR chips.

I am assuming I also have to buy a programmer for them if so what one?

What DSP chips and what programmer do you recommend?
 

mik3

Joined Feb 4, 2008
4,843
There will be no recommendation until you say the desired specifications.

Everything you buy depends on the application and the specifications of it.
 

Thread Starter

Mathematics!

Joined Jul 21, 2008
1,036
To beable to convert digital sound .wav files to analog.
And to beable to convert radio recievers analog FM signals to digital signals.

Is their any other uses for DSP then converting/processing digital or analog signals?
 

hgmjr

Joined Jan 28, 2005
9,027
How much is in your budget for this effort? Developement Tools for DSP software and hardware design are rather expensive.

hgmjr
 

hgmjr

Joined Jan 28, 2005
9,027
I don't know of any free development software for DSP development.

You could end up spending from $250US to $500US for some DSP development boards and the software for programming the part.

Atmel's offering of FREE software for Assembly and C-language development tools for their AVR family of 8-bit microcontrollers is unprecedented among manufacturer's of microcontrollers.

hgmjr
 
Top