Searching \ for '[PIC] Audio ADC-DAC Problems' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ios.htm?key=audio
Search entire site for: 'Audio ADC-DAC Problems'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] Audio ADC-DAC Problems'
2008\01\20@095741 by Richard Seriani, Sr.

picon face
All.

Somewhat long description, but I thought background info may help.

I am using a PIC16F88, 25LC1025 EEPROM, and MCP4822 DAC to record and play back spoken audio. Communication between the PIC, EEPROM, and DAC is SPI. Input audio is from a microphone and amp and is approximately 3-4Vpp, depending on how loud one talks. Input and output filters are 4kHz passive.This circuit uses an internal 4MHz oscillator and the ADC clock is fosc/8, or 500kHz (2us).

Only the upper 8 bits of the 10-bit conversion result are saved to the EEPROM, and there is a delay of 200us between conversions. The reason for the delay is because the code for retrieving the data from the EEPROM and running it through the DAC is much slower than the on the ADC side. Originally, the ADC was filling the EEPROM in about 16 or 17 seconds, while the DAC side took about 45-48 seconds. This resulted in the audio output sounding like an old tape player running very slowly. The ADC delay resulted in a more realistic speed.

The overall quality of the audio is poor. There is a lot of noise; dropouts, hiss, and some higher frequency (digital?) background. I tried changing the input filter to an active filter but, if anything, the sound quality was worse. Dropouts increased and the sound seemed to shift (phasing problem?) more frequently.

I can connect headphones to the output of the output filter (the DAC output is sufficiently robust for that) to hear the audio, but I sent it to an amplifier (simple op-amp) so I have more volume. If I listen during record, I have a low-frequency 'motorboat' sound at about 100Hz. Experimentation has shown that if I disconnect power to the EEPROM, the sould clears up. Of course, no data is being recorded. I have been unable to determine precisely what is causing that noise.

Here is where I think I am:
1. SPI comms - ok
2. Writing to/reading from EEPROM - ok
3. ADC - working, but may be timeing problem
4. DAC - working, but may be timing problem

I think a large part of the problem is that the ADC and DAC are not running at exactly the same speed/phase. However, I have been unable to figure out how to fix this without resorting to changing delays over and over until I get it right. I know there has to be an easier way to figure this out. Eventually, I would like to use an SD card to increase the storage time but, first, I have to get this working.

I have found a lot of information on the internet about ADC in general, but very little related to converting, storing, and retrieving basic audio. With all the info out there, I have likely overlooked that key piece.

Any suggestions and links will be appreciated.

Thanks for taking the time to wade through this post.

Richard Seriani

2008\01\21@135942 by Andre Abelian

flavicon
face
Richard,

Using PIC ADC is not doing to work. You need to use your PC to generate the audio
data then save it in EEPROM.
I would use this guy
http://www.winbond-usa.com/en/content/view/36/140/

Andre




{Original Message removed}

2008\01\21@143242 by Mark Rages

face picon face
On Jan 20, 2008 8:57 AM, Richard Seriani, Sr. <spam_OUTrichard_s633TakeThisOuTspamcox.net> wrote:
>
> I think a large part of the problem is that the ADC and DAC are not running at exactly the same speed/phase. However, I have been unable to figure out how to fix this without resorting to changing delays over and over until I get it right. I know there has to be an easier way to figure this out. Eventually, I would like to use an SD card to increase the storage time but, first, I have to get this working.
>

You need to set up a timer to trigger the ADC conversions so they
happen at a fixed rate.  A fixed sample rate is necessary to obtain
good sound.  Look at timer0 or timer1 in the datasheet.

Regards,
Mark
markrages@gmail


> I have found a lot of information on the internet about ADC in general, but very little related to converting, storing, and retrieving basic audio. With all the info out there, I have likely overlooked that key piece.
>
> Any suggestions and links will be appreciated.
>
> Thanks for taking the time to wade through this post.
>
> Richard Seriani
>
> -

2008\01\21@151542 by peter green

flavicon
face

> The overall quality of the audio is poor. There is a lot of noise; dropouts, hiss, and some higher frequency (digital?) background. I tried changing the input filter to an active filter but, if anything, the sound quality was worse. Dropouts increased and the sound seemed to shift (phasing problem?) more frequently.
There are a few issues I can see with your system:

Firstly you need to get stable matched sample rates on both input and
output. I reccomend using a timer rather than delays to control the
speed of the main recording/playback loops so you can more easilly and
consistantly control the sample rates.

Secondly your sample rate is too low, it must be more than double the
highest frequency you want to preserve. For comparision 8khz sample
frequency is used by the telephone system and I would consider that a
minimum for audio recording applications. You may need to change some
parts to let you get a higher sample rate.

Thirdly your input circuit probablly needs some attention for a couple
of reasons, firstly at theese low sample rates you need a steep
filter,by the time you reach half the sample rate you must have cut the
signal to negligable levels to prevent aliasing problems. Also you must
consider the source impedance of your microphone and design the input
circuit not to place undue load on it.

Fourthly your output circuit needs a filter and again it needs to be a
steep one cutting the signal to negligable levels by the time half the
sample rate is reached.

2008\01\21@161224 by Richard Seriani, Sr.

picon face

----- Original Message -----
From: "Andre Abelian" <.....aabelianKILLspamspam@spam@mason-electric.com>
To: "Microcontroller discussion list - Public." <piclistspamKILLspammit.edu>
Sent: Monday, January 21, 2008 2:02 PM
Subject: RE: [PIC] Audio ADC-DAC Problems


> Richard,
>
> Using PIC ADC is not doing to work. You need to use your PC to generate
> the audio
> data then save it in EEPROM.
> I would use this guy
> http://www.winbond-usa.com/en/content/view/36/140/
>
> Andre
>
Andre,

Thanks for the suggestion and the link. However, the objective is to do both
record and playback.

Richard


2008\01\21@170113 by Richard Seriani, Sr.

picon face

----- Original Message -----
From: "peter green" <.....plugwashKILLspamspam.....p10link.net>
To: "Microcontroller discussion list - Public." <EraseMEpiclistspam_OUTspamTakeThisOuTmit.edu>
Sent: Monday, January 21, 2008 3:15 PM
Subject: Re: [PIC] Audio ADC-DAC Problems


{Quote hidden}

Mark and Peter,

Thanks for replying. Both of you mention the idea of timers to sync the
record/playback. I'll be giving that a try.

Peter - right after posting, I went back and calculated the sample rate as
being about 4kHz and realized it was way too slow. Thanks for validating
that.

I am going to sweep my input filter to be sure I am getting the dropoff I
need. I designed the low-pass for cutoff (3-dB down) at 4kHz. I'm
considering a bandpass from abut 400Hz-4kHz, instead. Output filter was left
as passive, but I'll likely go with active there, as well (same as input
filter).

The input circuit had a low output impedance so as to not drastically
increase the input cap charge time. I'll double check that.

Thanks again to everyone who responded to my plea for help.

Richard
By the way, I also tried another Google search; this time, expanding it out
to the 18F series of PIC. One hit that I found useful is:
http://www.ece.msstate.edu/~reese/ece3724/


2008\01\22@033748 by Michael Rigby-Jones

picon face
> -----Original Message-----
> From: piclist-bouncesspamspam_OUTmit.edu [@spam@piclist-bouncesKILLspamspammit.edu]On
Behalf
> Of Richard Seriani, Sr.
> Sent: Sunday, January 20, 2008 6:57 AM
> To: KILLspampiclistKILLspamspammit.edu
> Subject: [PIC] Audio ADC-DAC Problems
>
>
> All.
>
> Somewhat long description, but I thought background info may help.
>
> I am using a PIC16F88, 25LC1025 EEPROM, and MCP4822 DAC to record and
play
> back spoken audio. Communication between the PIC, EEPROM, and DAC is
SPI.
> Input audio is from a microphone and amp and is approximately 3-4Vpp,
> depending on how loud one talks. Input and output filters are 4kHz
> passive.This circuit uses an internal 4MHz oscillator and the ADC
clock is
> fosc/8, or 500kHz (2us).

How are you handling the EEPROM write time which is probably of the
order of 4-5ms?  E.g. do you buffer the ADC samples during writes?

Regards

Mike

=======================================================================
This e-mail is intended for the person it is addressed to only. The
information contained in it may be confidential and/or protected by
law. If you are not the intended recipient of this message, you must
not make any use of this information, or copy or show it to any
person. Please contact us immediately to tell us that you have
received this e-mail, and return the original to us. Any use,
forwarding, printing or copying of this message is strictly prohibited.
No part of this message can be considered a request for goods or
services.
=======================================================================

2008\01\22@063329 by Richard Seriani, Sr.

picon face

----- Original Message -----
From: "Michael Rigby-Jones" <RemoveMEMichael.Rigby-JonesTakeThisOuTspambookham.com>
To: "Microcontroller discussion list - Public." <spamBeGonepiclistspamBeGonespammit.edu>
Sent: Tuesday, January 22, 2008 3:38 AM
Subject: RE: [PIC] Audio ADC-DAC Problems


>> {Original Message removed}

2008\01\22@090145 by Michael Rigby-Jones

picon face


> -----Original Message-----
> From: TakeThisOuTpiclist-bouncesEraseMEspamspam_OUTmit.edu [RemoveMEpiclist-bouncesspamTakeThisOuTmit.edu] On
Behalf
> Of Richard Seriani, Sr.
> Sent: 22 January 2008 11:33
> To: Microcontroller discussion list - Public.
> Subject: Re: [PIC] Audio ADC-DAC Problems
>
> Mike,
>
> According to the 25LC1024 datasheet, the internal write cycle time
(byte
> or
> page) is 6ms (max). I am doing page writes, so I load 256 bytes of
> converted
> data into the EEPROM input buffer, bring !CS high to initiate the
internal
> write, then poll the status register WIP bit to check that the write
is
> complete.
>
> Hmm, this means I am losing somewhere around 6ms of input for each 256
> bytes
> I am recording. Quick math shows that if I record about 31.25ms of
audio
> for
> each 256 bytes, I have about a 20% hole in the data. Does that sound
> right?
>
> Okay, sounds like I need to look at some sort of double-buffering of
the
> a-d
> data? I think I may be able to load the 25LC1024 input buffer while
the
> array write is taking place, but I need to check that. If so, that may
be
> one solution that could be implemented simply by shifting a few
> instructions
> in my code. I would load the buffer, then check the WIP bit to be sure
the
> write to the array is complete before I initiate the next write. The
write
> sould be complete since the conversion of 256 bytes will take about 5
> times
> as long as the EEPROM write cycle, so I may be able to get away
without
> checking it, though I am not sure I would want to.
>
> Thanks for making me think about this.

I'd be very surprised if you can write to the buffer during a write
operation.  Serial EEPROMs with SPI interfaces generally only let you
read the status register during a write cycle, but the datasheet will
certainly tell you one way or the other.

However, all is not lost.  6ms at 8Khz is only 48 samples.  Simply
implement a circular buffer (a little larger than 48 samples for
safety), with the ADC inserting data into the buffer, and the SPI taking
data out.  Whilst the EEPROM is not writing the buffer will never be
more than one byte full assuming you have a reasonable SPI clock rate.
Once the page write commences the ADC will start filling up the buffer,
but once full the SPI will be able to empty it very quickly.

If available, use the CCP modules special event trigger to take ADC
conversions at a regular rate, and use the ADC interrupt to put data
into the buffer, and the SPI interrupt to take data out.  The whole
recording process then runs totally under interrupt control, so you can
carry on doing stuff in your main loop.

Regards

Mike

=======================================================================
This e-mail is intended for the person it is addressed to only. The
information contained in it may be confidential and/or protected by
law. If you are not the intended recipient of this message, you must
not make any use of this information, or copy or show it to any
person. Please contact us immediately to tell us that you have
received this e-mail, and return the original to us. Any use,
forwarding, printing or copying of this message is strictly prohibited.
No part of this message can be considered a request for goods or
services.
=======================================================================

2008\01\22@101854 by Richard Seriani, Sr.

picon face

----- Original Message -----
From: "Michael Rigby-Jones" <Michael.Rigby-JonesEraseMEspam.....bookham.com>
To: "Microcontroller discussion list - Public." <EraseMEpiclistspammit.edu>
Sent: Tuesday, January 22, 2008 9:02 AM
Subject: RE: [PIC] Audio ADC-DAC Problems


{Quote hidden}

Mike,

Again, I thank you for the help. I believe I understand what you are saying
about the buffer and using the interrupts and timers to sync this, while
leaving the program open to doing other things between record cycles (and,
on the other end, playback cycles).

A bit more self-study is in order concerning the actual implementation,
since I am a little weak in the use of timers and interrupts, but your reply
certainly gets me started.

Richard


2008\01\22@111854 by Herbert Graf

flavicon
face

On Tue, 2008-01-22 at 06:33 -0500, Richard Seriani, Sr. wrote:
> According to the 25LC1024 datasheet, the internal write cycle time (byte or
> page) is 6ms (max). I am doing page writes, so I load 256 bytes of converted
> data into the EEPROM input buffer, bring !CS high to initiate the internal
> write, then poll the status register WIP bit to check that the write is
> complete.
>
> Hmm, this means I am losing somewhere around 6ms of input for each 256 bytes
> I am recording. Quick math shows that if I record about 31.25ms of audio for
> each 256 bytes, I have about a 20% hole in the data. Does that sound right?
>
> Okay, sounds like I need to look at some sort of double-buffering of the a-d
> data? I think I may be able to load the 25LC1024 input buffer while the
> array write is taking place, but I need to check that. If so, that may be
> one solution that could be implemented simply by shifting a few instructions
> in my code. I would load the buffer, then check the WIP bit to be sure the
> write to the array is complete before I initiate the next write. The write
> sould be complete since the conversion of 256 bytes will take about 5 times
> as long as the EEPROM write cycle, so I may be able to get away without
> checking it, though I am not sure I would want to.

The structure I've used for this sort of thing is a FIFO. Your ADC read
subroutine simple writes data to the FIFO, it doesn't care about
anything EEPROM. A second EEPROM routine keeps a look at the FIFO,
whenever it has more data then one page write it transfers the data to
the EEPROM and does the write.

That way the only thing you have to do to adjust for different sample
rates or EEPROM write times, or page size, is adjust the size of the
FIFO. Even make code reuse that much easier.

TTYL

2008\01\22@132728 by Michael Rigby-Jones

picon face


> -----Original Message-----
> From: RemoveMEpiclist-bouncesEraseMEspamEraseMEmit.edu [RemoveMEpiclist-bouncesspam_OUTspamKILLspammit.edu] On
Behalf
> Of Herbert Graf
> Sent: 22 January 2008 16:19
> To: Microcontroller discussion list - Public.
> Subject: Re: [PIC] Audio ADC-DAC Problems
>
>
> anything EEPROM. A second EEPROM routine keeps a look at the FIFO,
> whenever it has more data then one page write it transfers the data to
> the EEPROM and does the write.

You don't need to wait until a whole page worth is in the buffer if you
can devote the SPI bus to the EEPROM whilst recording.  Just keep the
EEPROM selected and throw bytes into it as they appear in the buffer.
That ensures the buffer is empty at the start of a write operation, so
the buffer size can be minimised.

Regards

Mike

=======================================================================
This e-mail is intended for the person it is addressed to only. The
information contained in it may be confidential and/or protected by
law. If you are not the intended recipient of this message, you must
not make any use of this information, or copy or show it to any
person. Please contact us immediately to tell us that you have
received this e-mail, and return the original to us. Any use,
forwarding, printing or copying of this message is strictly prohibited.
No part of this message can be considered a request for goods or
services.
=======================================================================

More... (looser matching)
- Last day of these posts
- In 2008 , 2009 only
- Today
- New search...