Searching \ for '[EE] PCM 8bit 8khz' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/index.htm?key=pcm+8bit+8khz
Search entire site for: 'PCM 8bit 8khz'.

Exact match. Not showing close matches.
PICList Thread
'[EE] PCM 8bit 8khz'
2007\12\12@125216 by Dumitru Stama

picon face
Hi Guys,
I wonder if this is a good way to sample PCM sound (8KHz, 8bit).
I have a 24LC64 full with 8kbytes of raw 8 bit unsigned data taken
from audacity (i recorded myself saying a word).
I am using Microchip AN991's way of accessing I2C eeproms and
it works. The problem is i am not geting what i expect : sound.
I only get some clicks and that's it.
I am doing the folowing :
- i read a byte from eeprom
- i output it to PortB
- i wait 2500 cycles (the clock is 20MHz and dividing this by
   8000 i get 2500)
- i increment the address for eeprom
....and so on....
On PortB i have a R-2R simple DAC and then a simple speaker
driven by a common-collector 2n2222 transistor.
This is the code i was talking about :

while (1) {
       ControlByte = 0xA0;
       HDByteReadI2C(ControlByte, HighAdd, LowAdd, &Data, Length) ;        //High
Density Byte Read
       PORTB = Data;
       Delay1KTCYx(2);
       Delay100TCYx(5);                //2500 cycles delay (for 8khz)
       LowAdd++;
       if (LowAdd == 0) {
               HighAdd++;
               if (HighAdd > 0x5F) HighAdd = 0x40;
       }
}

2007\12\12@130539 by David VanHorn

picon face
> On PortB i have a R-2R simple DAC and then a simple speaker
> driven by a common-collector 2n2222 transistor.

Do you mean an emitter follower?


What I would do, is test your DAC by feeding it known values and
checking the output voltage.
If that works, then probably the way you're getting the data out of
the EE is bad, or the data in the EE itself is bad.

Double check your delays too, it might be playing at "warp speed".

2007\12\12@131940 by Harold Hallikainen

face
flavicon
face
You don't say which PIC you're using, but on most, a 20MHz clock gives a
cycle speed of 5MHz. So, it looks like your delays is large.

Also, most serial eeproms auto-increment, so you should only need to set
the initial read address. Successive reads will pull from successive
addresses.

Good luck!

Harold


{Quote hidden}

> -

2007\12\12@133715 by Hector Martin

flavicon
face
Note that PIC16s and PIC18s internally divide the clock by 4, so the
delay would be 625 cycles. Also, the I2C read will take some time. Your
best bet for timing is to use one of the PIC's built in timers. In fact,
if you're running your EEPROM at 100Khz, it will be too slow since you
have to read/write 4 bytes = 40 bits approximately (after adding in
start conditions and whatnot), so your maximum sampling rate would be
100/40 = 2.5Khz. You should read chunks of data of a longer length (to
reduce the overhead of three bytes for each I2C transaction), buffer
them in memory, and have an interrupt running off a timer put them into
PORTB.

Dumitru Stama wrote:
{Quote hidden}

--
Hector Martin (spam_OUThectorTakeThisOuTspammarcansoft.com)
Public Key: http://www.marcansoft.com/marcan.asc

2007\12\12@133723 by Hazelwood Lyle
flavicon
face

I've never played with audio encoding, but according
to this page:
http://www.teamcombooks.com/mp3handbook/12.htm

You don't need an R-2R ladder, and you should be clocking
the bits out serially, in digital form.

Interesting.. One day I may play with that some more.

Lyle

2007\12\12@142520 by Hector Martin

flavicon
face
Hazelwood Lyle wrote:
> I've never played with audio encoding, but according
> to this page:
> http://www.teamcombooks.com/mp3handbook/12.htm
Half of that is wrong. They're confusing PCM with DSD (or confusing the
transmission of PCM data and the conversion to audio, depending on how
you read it), among other things. u-law has nothing to do with ADPCM
(the former is a companding algorithm, which is very different from
ADPCM). It's also outdated (icecast uses ogg these days, not mp3).


--
Hector Martin (.....hectorKILLspamspam@spam@marcansoft.com)
Public Key: http://www.marcansoft.com/marcan.asc

2007\12\12@143117 by Dumitru Stama

picon face
On Dec 12, 2007 8:14 PM, Harold Hallikainen <haroldspamKILLspamhallikainen.org> wrote:
> You don't say which PIC you're using, but on most, a 20MHz clock gives a
> cycle speed of 5MHz. So, it looks like your delays is large.
>
> Also, most serial eeproms auto-increment, so you should only need to set
> the initial read address. Successive reads will pull from successive
> addresses.

Sorry i forgot about this, i am using Pic18F452 with 20MHz clock and i am
running EE at 400khz.
You are right, i will optimize but for now i am trying to fix my delays and my
design; prototype is what i am doing now :)

2007\12\12@143348 by Dumitru Stama

picon face
On Dec 12, 2007 8:37 PM, Hector Martin <.....hectorKILLspamspam.....marcansoft.com> wrote:
> Note that PIC16s and PIC18s internally divide the clock by 4, so the
> delay would be 625 cycles. Also, the I2C read will take some time. Your
> best bet for timing is to use one of the PIC's built in timers. In fact,
> if you're running your EEPROM at 100Khz, it will be too slow since you
> have to read/write 4 bytes = 40 bits approximately (after adding in
> start conditions and whatnot), so your maximum sampling rate would be
> 100/40 = 2.5Khz. You should read chunks of data of a longer length (to
> reduce the overhead of three bytes for each I2C transaction), buffer
> them in memory, and have an interrupt running off a timer put them into
> PORTB.

In the end i will use two buffers and a timer for feeding my DAC with values
but this is my first work in this field and i wanted to hear some sound out
of my design :) Thank you for your correction, i will fix my delays now to see
what i get.

2007\12\12@160543 by Funny NYPD

picon face
Why not use dsPIC? Thought they are high performance and cheap now.

Funny N.
New Bedford, MA
http://www.AuElectronics.selfip.com

{Original Message removed}

2007\12\12@171642 by Robert Rolf

picon face


Dumitru Stama wrote:

{Quote hidden}

So break the problem into parts.
First make the D/A make sound. A running binary counter will
get you a nice ramp (sawtooth) that sounds like an Oboe.
That way you know your playback rate is OK and that your amplifier
is not clipping or otherwise wonky.

Then make sure you are reading/writing the EEPROM correctly.
For example, write the compliment of the address
(plus some offset),to each location
and then make sure you are reliably getting it back.

And as noted by others, you only need to write the start address
to most serial EEPROM devices. Subsequent reads will get you
the next byte in the sequence so your overhead is greatly reduced.

Robert



'[EE] PCM 8bit 8khz'
2008\01\23@093928 by Dumitru Stama
picon face
Hi guys,
I am having trouble implementing my 8 bit R-2R DAC using 10k and 20k resistors.
I connected it to PORTD of my PIC18F452, I de-activated PSP by setting
TRISE to 0
and I set TRISD to 0 to put the pins into output mode.
If I send 255 (0xFF) to PORTD I get 5v to each and everyone of the 8 pins D0-D7.
Now comes the part I really don't understand : measuring the voltages
on the output
pin of the DAC by sending different values on PORTD I get the
following results :

Sending decimal 50  = 0.89v
Sending decimal 100 = 1.70v
Sending decimal 150 = 2.24v
Sending decimal 200 = 2.30v
Sending decimal 250 = 2.35v

I think the PIC is not able to supply enough current and this is the reason I
get all the values from above.
If i try to analyse the value after sending "50" over to the DAC and I
multiply it by 5
I virtually get ~4.5v, close to 5v, my supply voltage.
This is almost the value I should get by sending "250" to the DAC but
instead I get 2.35,
almost half of what it should be. Am i right here ?


On Dec 13, 2007 12:17 AM, Robert Rolf <Robert.Rolfspamspam_OUTualberta.ca> wrote:
{Quote hidden}

> -

2008\01\23@102736 by John Coppens

flavicon
face
On Wed, 23 Jan 2008 16:39:02 +0200
"Dumitru Stama" <KILLspamspanacKILLspamspamgmail.com> wrote:

> This is almost the value I should get by sending "250" to the DAC but
> instead I get 2.35,
> almost half of what it should be. Am i right here ?

I'm guessing you are not connecting to the correct node of the R/2R
network. 10k/20k should work well with the PIC outputs. Note that there
are two different applications for R/2R: One uses an opamp at the output
and works with currents
(http://www.allaboutcircuits.com/vol_4/chpt_13/3.html)
the other one is designed for volrages
(http://www.avr-asm-tutorial.net/avr_en/AVR_DAC.html - note that the
opamp here is only as a voltage follower, not current to voltage
converter).

John

2008\01\23@180119 by Dumitru Stama

picon face
No, every connection was tested and i have everything where it should be,
as in the links you sent me. I am not even touching the op-amp part, i just
measured the voltage right after the R-2R ladder without any amplifier
afterwards.
I think i will try to test the ladder using some jumper switches instead of
PIC pins, this way at least i will know is not a "not enough current" issue.


On Jan 23, 2008 5:26 PM, John Coppens <RemoveMEjohnTakeThisOuTspamjcoppens.com> wrote:
{Quote hidden}

2008\01\23@205018 by John Coppens

flavicon
face
On Thu, 24 Jan 2008 01:01:13 +0200
"Dumitru Stama" <TakeThisOuTspanacEraseMEspamspam_OUTgmail.com> wrote:

> I think i will try to test the ladder using some jumper switches
> instead of PIC pins, this way at least i will know is not a "not enough
> current" issue.

But that is very easy to discard as a problem... Simply put out all ones,
and measure the voltage in each output pin. It should be very near VCC.

If that's ok, DO check the configuration. If you have the one intended
for an Opamp amplifier (first link I sent), you cannot measure it without
the opamp functioning (the opamp is needed to present a short to the R/2R
network).

The second configuration is slightly different, and should not be loaded
at all (if you have an amplifier at the output, be sure it has its supply
connected, and that the input can handle the 0-VCC swing of the R/2R
(ie., don't supply it with VCC), else the inputs will load the network
and produce things like you describe.

John

2008\01\24@023605 by Dumitru Stama

picon face
On Jan 24, 2008 3:49 AM, John Coppens <RemoveMEjohnspamTakeThisOuTjcoppens.com> wrote:
> On Thu, 24 Jan 2008 01:01:13 +0200
> "Dumitru Stama" <spanacEraseMEspam.....gmail.com> wrote:
>
> > I think i will try to test the ladder using some jumper switches
> > instead of PIC pins, this way at least i will know is not a "not enough
> > current" issue.
>
> But that is very easy to discard as a problem... Simply put out all ones,
> and measure the voltage in each output pin. It should be very near VCC.
> If that's ok, DO check the configuration. If you have the one intended
> for an Opamp amplifier (first link I sent), you cannot measure it without
> the opamp functioning (the opamp is needed to present a short to the R/2R
> network).
> The second configuration is slightly different, and should not be loaded
> at all (if you have an amplifier at the output, be sure it has its supply
> connected, and that the input can handle the 0-VCC swing of the R/2R
> (ie., don't supply it with VCC), else the inputs will load the network
> and produce things like you describe.
> John

Do i really have to have an opamp functional to test the voltages ?
I only have about 5v as VCC and it is a bit hard to supply the amp
with enough juice. I have already sent 0xFF to PORTD and i have
voltages close to VCC on every pin. I will try to build it again with
100k and 200k resistors and check the voltages step by step, after
each part : 1bit, 2bits, ..... 8 bits.

2008\01\24@065602 by Enki

picon face
On 24 Jan 2008 at 9:36, Dumitru Stama wrote:

> I only have about 5v as VCC and it is a bit hard to supply the amp
> with enough juice. I have already sent 0xFF to PORTD and i have
> voltages close to VCC on every pin.

       That shows the PIC is supplying enough current.


> I will try to build it again with
> 100k and 200k resistors and check the voltages step by step, after
> each part : 1bit, 2bits, ..... 8 bits.
> --

       It would be a waste of time due to the 0xFF test
you already did.

       Why don't you show us your circuit? I bet there
is something wired wrong.

       MJ


2008\01\24@073624 by John Coppens

flavicon
face
On Thu, 24 Jan 2008 09:36:04 +0200
"Dumitru Stama" <EraseMEspanacspamgmail.com> wrote:

> Do i really have to have an opamp functional to test the voltages ?
> I only have about 5v as VCC and it is a bit hard to supply the amp
> with enough juice. I have already sent 0xFF to PORTD and i have
> voltages close to VCC on every pin. I will try to build it again with
> 100k and 200k resistors and check the voltages step by step, after
> each part : 1bit, 2bits, ..... 8 bits.

Depends _which_ circuit you have built. If it is the current-based one,
you _need_ the opamp, as it must provide the virtual short circuit for the
network to function.

If it is the voltage circuit, you can test it _without_ the opamp, but
be sure it is disconnected. Do check the last branch (where you connect
the voltmeter, as this branch is different from the other ones.

John

2008\01\24@134041 by Vasile Surducan

face picon face
On 1/23/08, Dumitru Stama <RemoveMEspanacEraseMEspamEraseMEgmail.com> wrote:
{Quote hidden}

Hand made R-2R ladder is the worst option ever for a DAC. I hope you
have read first the theory of R-2R D2A and the non linearities you may
get because of resistor unmatch.
Also the inequal output impedance with bit variation...

2008\01\24@155439 by Dave Tweed

face
flavicon
face
Vasile Surducan <EraseMEpiclist9spamspamspamBeGonegmail.com> wrote:
> Hand made R-2R ladder is the worst option ever for a DAC.

Not necessarily ...

> I hope you have read first the theory of R-2R D2A and the non linearities
> you may get because of resistor unmatch.

I'm with you so far ... although you can do pretty well with, say, 25 1%
resistors of all the same value (from the same batch, if possible) to build
an 8-bit converter.

> Also the inequal output impedance with bit variation...

Nope, dead wrong on that one. Assuming the bit drivers have negligiple
resistance compared to R, The output impedance of an R-2R network is
constant, and it's R! See the following link for details:

 http://www.dtweed.com/circuitcellar/caj00100.htm#1532

The PDF link works, but the HTML version has gone missing. The relevant
text is on page 2, with diagrams on page 3.

-- Dave Tweed

2008\01\24@172331 by Dumitru Stama

picon face
I think i have solved the thing, a trace from the ladder directly to
a power amplifier LM386 which i used in the first days to drive a
square signal generated by the pic... When i removed this the
values are quite good, at least very close to what should they be.
For a FF i get about 4.7v which is not bad...
I guess this is the last time i am using a perf board to do any
serious learning stuff although i learned something from my mistake.

On my scope the PCM soundwave is clearly seen as i see it inside
my Audacity wave editor on the computer. Now in order to hear
something on a small speaker i will need an amplifier :)
I was thinking about using a LM358 opamp since the ~5v VCC is all
the voltage i have. Do you think this will be enough or i will also
need a power amplifier like lm386 ?


On Jan 24, 2008 10:54 PM, Dave Tweed <RemoveMEpicKILLspamspamdtweed.com> wrote:
{Quote hidden}

> -

2008\01\24@182408 by Jinx

face picon face
> I was thinking about using a LM358 opamp since the ~5v VCC
> is all the voltage i have. Do you think this will be enough or i will
> also need a power amplifier like lm386 ?

An op amp isn't design to drive a load like a speaker, and you'll get
only a few mA out of it. Op amps, often a paralleled quad package,
can be used to drive headphones though, as you need just a few mW

LM386 (found a few of these on mobos, fax / sound cards and they
have reasonable volume at 5V) or other amp. The TBA820 is OK
at 6V

Discrete transistor output stage, push-pull or single-ended

Use two amps in a bridge configuration

Bump up the 5V with an inverter. I've actually used an LM386 to
do this. Wired as an oscillator / tripler to make a high Vcc for a
piezo whistle. Higher Vcc widens the range of useable audio amps.
You'd have to look at what wattage is available from your 5V, or
go back a step and use the supply that the 5V comes from





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