Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

A/D and audio questions.

A/D and audio questions.

2004-01-03 by c45a6

Hello!

I had some fun today and wired up my Mega 16 to a D/A converter.  
Knowing that it would probably sound terrible, I hooked up an audio 
signal directly to the Mega 16's A/D converter, and the output from 
the D/A converter directly to my mixer.

Although highly digitized, I could kind-of make out the songs.  Part 
of the problem could have been that I did a 10 bit A/D conversion and 
tossed out the lowest significant 8 bits.  Another part may have been 
that I'm running into a 12-bit D/A converter on the output (of which
I 
hooked up to the most significant bits).  BUT, after some 
contemplation, maybe I also cut off 1/2 of the audio waveform, the 
part that goes negative, in the process.

I'm going from an audio signal, straight into the Atmel Mega16's A/D 
converter, then out into a DAC7625 (12 bit parallel D/A converter).

Here's my bascom program:

$regfile = "m16def.dat"
$crystal = 4000000

Config Adc = Single , Prescaler = Auto , Reference = Internal
Start Adc

' Set all port c pins to output.  The output of port
' c's pins go directly to the D/A converter.

Ddrc = &B1111_1111

Dim Cv1 As Word

Do

   Cv1 = Getadc(0)
   Shift Cv1 , Right , 2
   Portc = Cv1

Loop

Here's my question.  What are my next steps?  How does one manipulate 
the audio signal before feeding it into the A/D converter to get the 
best results?  If I take the output of the D/A converter, it's going 
to be 0 - 2.5 volts.  As far as I've seen, audio signals have both a 
positive and negative element.  How can I take my 0 - 2.5 volts and 
spread it out over -5 to +5 volts?

Thanks!  I know this is a total newbie question.  If anyone knows of
a 
good website that answers my questions, please let me know.  Direct 
answers are always appreciated too!

- Bret

Re: A/D and audio questions.

2004-01-03 by c45a6

> 
> Try hopping up the A/D to 250kHz, and using all 8 bits.
> AC Couple your audio, and weakly (10k?) pull the A/D input to 
>VCC/2, and use VCC as your analog ref.

Thanks for the fast response!  I have some follow up questions.

1. Er.. How do you hop up the A/D to 250kHz?  Do you set the ADPS 
bits of ADCSRA?  I'm using the internal clock.  Is that a big no-no?

2. "pull the A/D input to VCC/2" Sorry, my electronics language 
skills are terrible.  Do you mean run a pull up resistor (around 10k) 
between VCC/2 and the A/D input pin?  I just happen to have a VCC/2 
source on my board already that I use for the reference voltage on 
the D/A converter.

3. How does one AC Couple the audio?  Do you have any links to 
schematics for that?  My pathetic little electronics books don't 
cover that subject. :-(

A million thanks!
- Bret

Re: [AVR-Chat] A/D and audio questions.

2004-01-03 by David VanHorn

At 03:41 AM 1/3/2004 +0000, c45a6 wrote:


>Hello!
>
>I had some fun today and wired up my Mega 16 to a D/A converter.  
>Knowing that it would probably sound terrible, I hooked up an audio 
>signal directly to the Mega 16's A/D converter, and the output from 
>the D/A converter directly to my mixer.
>
>Although highly digitized, I could kind-of make out the songs.  Part 
>of the problem could have been that I did a 10 bit A/D conversion and 
>tossed out the lowest significant 8 bits.  Another part may have been 
>that I'm running into a 12-bit D/A converter on the output (of which
>I 
>hooked up to the most significant bits).  BUT, after some 
>contemplation, maybe I also cut off 1/2 of the audio waveform, the 
>part that goes negative, in the process.

A four bit conversion, and clipping half the waveform could compromise the soundstage brilliance, or muddle the transient clarity, that's for sure.

:)

Try hopping up the A/D to 250kHz, and using all 8 bits.
AC Couple your audio, and weakly (10k?) pull the A/D input to VCC/2, and use VCC as your analog ref.

RE: [AVR-Chat] Re: A/D and audio questions.

2004-01-03 by Larry Barello

You can speed up the ADC by specifying a small clock divisor.  The default
is around 64 or 128, but you can specify 8x or even 4x and get much faster
conversions.  The accuracy will suffer, but, so what.  With a 4mhz clock and
a clk/4 ADC clock, each conversion will take 13 us for a conversion rate of
~76k/s.  Hmm, I guess clk/8 will give you ~38khz conversion which should be
plenty good.  Read the BASCOM help for "config adc" and replace "auto" with
4 or 8 (or whatever) to get the faster speeds.

To AC couple your signal, you need a capacitor between the ADC input and
your signal.  Use your Vcc/2 to bias the ADC side of the capacitor.  The
size of the resistor and the capacitor will be somewhat important, but alas,
my electronic theory can't help you here with hard numbers.  Try 10k + .1uf
ceramic cap to start.

Cheers!
Show quoted textHide quoted text
-----Original Message-----
From: c45a6 [mailto:clone45@hotmail.com]

>
> Try hopping up the A/D to 250kHz, and using all 8 bits.
> AC Couple your audio, and weakly (10k?) pull the A/D input to
>VCC/2, and use VCC as your analog ref.

Thanks for the fast response!  I have some follow up questions.

1. Er.. How do you hop up the A/D to 250kHz?  Do you set the ADPS
bits of ADCSRA?  I'm using the internal clock.  Is that a big no-no?

2. "pull the A/D input to VCC/2" Sorry, my electronics language
skills are terrible.  Do you mean run a pull up resistor (around 10k)
between VCC/2 and the A/D input pin?  I just happen to have a VCC/2
source on my board already that I use for the reference voltage on
the D/A converter.

3. How does one AC Couple the audio?  Do you have any links to
schematics for that?  My pathetic little electronics books don't
cover that subject. :-(

A million thanks!
- Bret

Re: A/D and audio questions.

2004-01-03 by c45a6

Oh, poop.  I just lost a huge e-mail response.  Argh.  

In short, thanks for the advice!  Speeding up the ADC really helped.  
It's still distorted, but I can now hear notes and lyrics. :-)

Tomorrow I'm going to post again asking more questions about the AC 
coupling.  I'll whip up a schematic to help out.  Am I still cutting 
out 1/2 of the audio signal, even after the ac coupling?

Thanks!
- Bret

--- In AVR-Chat@yahoogroups.com, "Larry Barello" <yahoo@b...> wrote:
> You can speed up the ADC by specifying a small clock divisor.  The 
default
> is around 64 or 128, but you can specify 8x or even 4x and get much 
faster
> conversions.  The accuracy will suffer, but, so what.  With a 4mhz 
clock and
> a clk/4 ADC clock, each conversion will take 13 us for a conversion 
rate of
> ~76k/s.  Hmm, I guess clk/8 will give you ~38khz conversion which 
should be
> plenty good.  Read the BASCOM help for "config adc" and 
replace "auto" with
> 4 or 8 (or whatever) to get the faster speeds.
> 
> To AC couple your signal, you need a capacitor between the ADC 
input and
> your signal.  Use your Vcc/2 to bias the ADC side of the 
capacitor.  The
> size of the resistor and the capacitor will be somewhat important, 
but alas,
> my electronic theory can't help you here with hard numbers.  Try 
10k + .1uf
> ceramic cap to start.
> 
> Cheers!
> -----Original Message-----
> From: c45a6 [mailto:clone45@h...]
> 
> >
> > Try hopping up the A/D to 250kHz, and using all 8 bits.
> > AC Couple your audio, and weakly (10k?) pull the A/D input to
> >VCC/2, and use VCC as your analog ref.
> 
> Thanks for the fast response!  I have some follow up questions.
> 
> 1. Er.. How do you hop up the A/D to 250kHz?  Do you set the ADPS
> bits of ADCSRA?  I'm using the internal clock.  Is that a big no-no?
> 
> 2. "pull the A/D input to VCC/2" Sorry, my electronics language
> skills are terrible.  Do you mean run a pull up resistor (around 
10k)
Show quoted textHide quoted text
> between VCC/2 and the A/D input pin?  I just happen to have a VCC/2
> source on my board already that I use for the reference voltage on
> the D/A converter.
> 
> 3. How does one AC Couple the audio?  Do you have any links to
> schematics for that?  My pathetic little electronics books don't
> cover that subject. :-(
> 
> A million thanks!
> - Bret

Re: A/D and audio questions.

2004-01-03 by c45a6

Hello again!

I drew out a quick schematic for the AC coupling.  I wasn't sure 
exactly how to wire it up.  Can you take a look at it and let me know 
if it's what you mean? 

The values of the capacitor pictured are wrong.  Don't worry about 
that: 

http://www.voxglitch.com/images/coupling_test.bmp

Also, was there any advice for me on how to NOT clip the lower half 
of my audio signal when doing the A/D conversion?

Thanks a ton!
- Bret


--- In AVR-Chat@yahoogroups.com, "c45a6" <clone45@h...> wrote:
> 
> Oh, poop.  I just lost a huge e-mail response.  Argh.  
> 
> In short, thanks for the advice!  Speeding up the ADC really 
helped.  
> It's still distorted, but I can now hear notes and lyrics. :-)
> 
> Tomorrow I'm going to post again asking more questions about the AC 
> coupling.  I'll whip up a schematic to help out.  Am I still 
cutting 
> out 1/2 of the audio signal, even after the ac coupling?
> 
> Thanks!
> - Bret
> 
> --- In AVR-Chat@yahoogroups.com, "Larry Barello" <yahoo@b...> wrote:
> > You can speed up the ADC by specifying a small clock divisor.  
The 
> default
> > is around 64 or 128, but you can specify 8x or even 4x and get 
much 
> faster
> > conversions.  The accuracy will suffer, but, so what.  With a 
4mhz 
> clock and
> > a clk/4 ADC clock, each conversion will take 13 us for a 
conversion 
> rate of
> > ~76k/s.  Hmm, I guess clk/8 will give you ~38khz conversion which 
> should be
> > plenty good.  Read the BASCOM help for "config adc" and 
> replace "auto" with
> > 4 or 8 (or whatever) to get the faster speeds.
> > 
> > To AC couple your signal, you need a capacitor between the ADC 
> input and
> > your signal.  Use your Vcc/2 to bias the ADC side of the 
> capacitor.  The
> > size of the resistor and the capacitor will be somewhat 
important, 
> but alas,
> > my electronic theory can't help you here with hard numbers.  Try 
> 10k + .1uf
> > ceramic cap to start.
> > 
> > Cheers!
> > -----Original Message-----
> > From: c45a6 [mailto:clone45@h...]
> > 
> > >
> > > Try hopping up the A/D to 250kHz, and using all 8 bits.
> > > AC Couple your audio, and weakly (10k?) pull the A/D input to
> > >VCC/2, and use VCC as your analog ref.
> > 
> > Thanks for the fast response!  I have some follow up questions.
> > 
> > 1. Er.. How do you hop up the A/D to 250kHz?  Do you set the ADPS
> > bits of ADCSRA?  I'm using the internal clock.  Is that a big no-
no?
> > 
> > 2. "pull the A/D input to VCC/2" Sorry, my electronics language
> > skills are terrible.  Do you mean run a pull up resistor (around 
> 10k)
> > between VCC/2 and the A/D input pin?  I just happen to have a 
VCC/2
Show quoted textHide quoted text
> > source on my board already that I use for the reference voltage on
> > the D/A converter.
> > 
> > 3. How does one AC Couple the audio?  Do you have any links to
> > schematics for that?  My pathetic little electronics books don't
> > cover that subject. :-(
> > 
> > A million thanks!
> > - Bret

RE: [AVR-Chat] Re: A/D and audio questions.

2004-01-03 by Larry Barello

Connect the ADC to the junction of the Cap and the resistor.  Then the audio
signal will be summed with Vcc/2 and give you +/- 511 counts on your ADC
results after subtracting 512.  As long as your audio input doesn't exceed
+/- VCC/2 you won't clip.
Show quoted textHide quoted text
-----Original Message-----
From: c45a6 [mailto:clone45@hotmail.com]

Hello again!

I drew out a quick schematic for the AC coupling.  I wasn't sure
exactly how to wire it up.  Can you take a look at it and let me know
if it's what you mean?

The values of the capacitor pictured are wrong.  Don't worry about
that:

http://www.voxglitch.com/images/coupling_test.bmp

Also, was there any advice for me on how to NOT clip the lower half
of my audio signal when doing the A/D conversion?

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.