News:

SMF for DIYStompboxes.com!

Main Menu

WM8731 codec

Started by AdamB, July 22, 2019, 01:16:18 PM

Previous topic - Next topic

AdamB

Yo,

I'm trying to figure out using a WM8731 codec. Wondering if someone can answer these two questions I have;

First Question

First I'm trying to figure out what the peak input voltage to the ADC should be so that I can figure out how much gain to put in my input conditioning and what diodes to use for overload protection. The data sheet says;



Does that mean if my analogue supply voltage (AVDD) is 3.3v, then the peak voltage is (3.3/3.3) and therefore 1V? I'd of expected it to be nearer to the 3.3V rail. Maybe I'm miss-understanding?

Second Question

For VMID, the analogue reference voltage, the datasheet says;



which again at 3.3v for AVDD I'd expect to be 1.65V and therefore I simply create a voltage divider with 2 resistors and stick the 1.65V into that pin. But in Wolfsons' own example schematic there's only a 10uF capacitor to ground here. Or is this an output pin and it's putting out 1.65V? In which case I don't understand why it's included.



Thanks!
[indifferent::engine]
http://www.indifferentengine.com

markseel

Sorry to not answer the question but add other unsolicited info ...

Unless you want the headphone output of the WM8731 I'd chuck it - performance isn't compelling.  Look at the AK4556 - better performance, smaller package, easy configuration.

https://www.akm.com/akm/en/file/datasheet/AK4556VT.pdf

markseel

#2
The input voltage range is just the maximum magnitude of the input signal with the input signal centered at Vcc/2.  1Vrms is then ~2.8 V peak-peak (1.4V peak). At Vcc = 3.3V then the input signal will be well within the 0V to 3.3V of the supply rail ...  1.65V +/- 1.4V.   If you AC couple the ADC inputs then the ADC's inputs will bias at Vcc/2.  Note that often there is a digital DC component removal option to enable/disable if you want any remaining DC component removed in the PCM representation of your input signal.  Make sense?

ElectricDruid

First question: That looks like datsheet nonsense to me, and I've no idea what they're trying to say. I'd assume that you can go to 3.3Vpp from a 1.65V midpoint like everyone else until proved otherwise.

Second question: For the VMID "E14" 10uF capacitor, it looks to me like they're generating the mid-point voltage internally on the chip, and then providing a pin so you can add an external capacitor for decoupling. After all, it's a bit hard to put a 10uF cap on an IC...

The dsPIC's core Vref (1.8V, I think) does the same thing. There's a Vref pin externally that just has a cap hanging to ground.

I *hope* that helps...;)

Tom

Rob Strand

#4
QuoteFirst Question
First I'm trying to figure out what the peak input voltage to the ADC should be so that I can figure out how much gain to put in my input conditioning and what diodes to use for overload protection. The data sheet says;
Does that mean if my analogue supply voltage (AVDD) is 3.3v, then the peak voltage is (3.3/3.3) and therefore 1V? I'd of expected it to be nearer to the 3.3V rail. Maybe I'm miss-understanding?
You got it right except for the fact the units are Vrms.     So 1V rms is 1.414V peak and that is within Vcc/2 = 1.65V which makes sense.

FWIW, as a double check see the example on p21, fig 11 and text under it.

QuoteSecond Question

For VMID, the analogue reference voltage, the datasheet says;
which again at 3.3v for AVDD I'd expect to be 1.65V and therefore I simply create a voltage divider with 2 resistors and stick the 1.65V into that pin. But in Wolfsons' own example schematic there's only a 10uF capacitor to ground here. Or is this an output pin and it's putting out 1.65V? In which case I don't understand why it's included.
The block diagram of the chip on the first page shows it has 2x *internal* resistors forming AVDD/2.

On page 7 it says
"Potential divider resistance  R VMID       50k    Ohms "

So what's not clear is if the divider is 2x50k  or 2x100k giving a Thevenin impedance of 50k.  I'd *guess* 2x50k.


Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

AdamB

Thanks for the info everyone, think I understand now!

QuoteYou got it right except for the fact the units are Vrms.     So 1V rms is 1.414V peak and that is within Vcc/2 = 1.65V which makes sense.

Ah yes I didn't see that!

QuoteI'd assume that you can go to 3.3Vpp from a 1.65V midpoint like everyone else until proved otherwise.

So that makes sense - the value in the datasheet is marked as "Typical", so I guess 1.414V peak is typical, leaving a little headroom with the max being 1.65V. The column next to the typical column is "Max", why didn't they put the max value in there, too? Stupid datasheet people. I swear sometimes engineers make things confusing on purpose so that everything seems more clever than it is.

I guess my issue now is how much gain to stick in front of this thing, the potential variation in pp voltages on the input from different instruments are so wide that it hardly seems worth it unless I offer a gain trim or a pad switch for high gain pickups, but I'd rather avoid that. I guess if I assume the input pp voltage is something around 1V from a high gain instrument then I'd want 1.4x gain. And I suppose with low gain pups it only has to be "good enough" that there's no obvious, intrusive noise on the output signal. Hmmmmmm tricky.

The images below is what I've mocked up for it so far, I've got to verify some of the design once the eval board for the 8731 shows up. I've never used 2 wire serial connection before, and if I'm understanding it I still need to use SPI to get the ADC/DAC data in and out of the chip. It's quite possible the way I'm connecting the codec to the dspic isn't right as I find deciphering all the short hand labels for the pins a little overwhelming, but I can always juggle the pins around once I get the codec wired up on the breadboard and start getting stuck into the software.

Input Conditioning


Codec


dsPic


SRAM


Switching/Output mixing


QuoteUnless you want the headphone output of the WM8731 I'd chuck it - performance isn't compelling.  Look at the AK4556 - better performance, smaller package, easy configuration.

That looks interesting, looks a bit tricky to source the part though from just a quick googling, main part distributors don't seem to carry it. Also couldn't find an eval board for sale anywhere, the datasheet suggests one exists, though. Also what is it about the 8731 that isn't compelling? I've no experience with it so would be good to know! Bad SNR or something? My main objective is to ditch the DAC on the dspic as it's just too noisy and I don't need the headphone out for my current projects so I'm not married to the 8731 by any means. Just seems like an easy route forward for me, and potentially for other people to copy.
[indifferent::engine]
http://www.indifferentengine.com

Blackaddr

#6
Quote from: markseel on July 22, 2019, 02:41:36 PM
Sorry to not answer the question but add other unsolicited info ...

Unless you want the headphone output of the WM8731 I'd chuck it - performance isn't compelling.

I disgree, I've been very impressed with the WM8731 performance. I'd say the WM8731 is superior for guitar applications because it has a built in PGA (programmable gain amplfier), it can provide quite a bit of gain, as well as attenuation. This is essential since guitars have a massive dynamic range of signal levels. Vintage single-coils can be only tens of millivolts, active pickups or guitar pedals in front of the codec can easiliy produce several volts peak-to-peak.

If you use an AK4556 you will need go build your own preamp in order to use the full input range of the codec without clipping.
Blackaddr Audio
Digital Modelling Enthusiast
www.blackaddr.com

markseel

It's not data sheet nonsense.  A 3.3V part will have min/max signal level and it depends on a number of factors including process/technology (Bipolar, JFET, CMOS) at the inputs as well as the designers/manufactures choice of how to balance certain specs.  Approaching the rails of the analog section will no doubt increase distortion and it depends on the process/tech used and whether or not rail-to-rail topologies for any one process/tech are incorporated.

1Vrms is very common and it's due to the fact that 1Vrms is approximately 2.8 V pk-pk which is well within the capabilities of 3.3V powered analog front ends of ADC's while being able to spec a low distortion and actually leverage the bit depth of the ADC (24-bits is a lot of signal precision).  No, the WM8371 or AK4556 will not properly resolve a signal with 3.3V peak-peak.  That single will get clipped.  There is no data sheet nonsense ... follow the data sheet :-)

The WM8731 part may *sound* good to you but I suspect that with your ears and setup other parts will sound good too.  The data sheets have figures not to be overlooked and the dynamic range, SNR, distortion, and SNR+distortion measurements are standard and shared (with variations noted in the data sheet) across manufacturers.  The AK4556 is spec'd better.

Do you need a PGA controlled by I2C/SPI or hardware pins?  Features are great if you intend to use them thoughtfully.  If not then just keep it simple.  1Vrms is a good start for resolving signals from guitar pickups.  You'll not clip with hum buckers and single-coils and even most actives, and you only need a unity gain buffer for the high impedance input.  Easy.

No one making real effects uses the WM8731, or the AK4556 for that matter (they're old and there are way better parts now).  But if you're not picky and just getting started keep it simple until you actually need to make it *more* complicated.  The AK4556 is great for that.  But hey I don't have a vested interest here - just speaking from experience and opinion.

Want more dynamic range on a smaller guitar signal?  Yeah the PGA *seems* like a good idea but is it in practice?  Not for me and not for modern digital effects products since the analog front ends are clean and the ADC is spec'd well.  I have tons of digital gain on signals coming from a low noise TI ADC (PCM4201) with a unity gain buffer and I don't clip, the signal is remarkably clean even after gain to the point of (after measuring) not believing that it could be that good.  No PGA, just a low-noise layout and good parts.

Concerned about pickup type, dynamic range, and noise performance?  Well you already have to add an opamp to buffer your guitar signal.  So just use a dual op amp, buffer first stage, attenuate or amplify next state, controlled with a pot.  If your front end is clean and the ADC is decent you won't care about variable input gain.

Take a listen to this ... no PGA and fixed 1Vrms input range.  Various guitars used and various effects.  And the ADC and analog front end of this version of the pedal isn't very good.  The user doesn't have to mess with input gain.

https://vimeo.com/336877986
https://vimeo.com/348616450/1a28894c1b




markseel

Quote from: ElectricDruid on July 22, 2019, 06:35:29 PM
Second question: For the VMID "E14" 10uF capacitor, it looks to me like they're generating the mid-point voltage internally on the chip, and then providing a pin so you can add an external capacitor for decoupling. After all, it's a bit hard to put a 10uF cap on an IC...

Note that the ADC's or DAC's internal reference (mid Vcc bias) should not be loaded as this will degrade performance.  The data sheets will mention this if it's a concern and if it is and you still want to use it to bias your analog circuits in order to DC couple them then make sure you buffer that bias before using it (e.g. use an opamp buffer with the ADC ref as input and the op amp output as your own bias voltage).

The 10uF is important since the bias is used by the ADC and any noise on that bias will degrade your SNR.  I always put small SMT ceramic caps on the ref pins (often times a 100n and 10u pair of caps).  The data sheet will be more specific though.

markseel

Sorry I'm flooding this thread.

But to give you ideas to choose from here's what I do.  Two unity gain buffers, each buffer output feeding the two differential inputs of the PCM4201 mono ADC.  One buffer input is the guitar.  The other buffer input is ground.  Both buffer inputs have a DC blocking cap of 100nF.  This differential signal (guitar signal - ground signal) cancels out the common mode noise.  The ADC's reference pin, usually not to be loaded as to degrade ADC performance, feeds to 1M resisters tied to the buffer inputs to bias the op-amps.  It's 500K of loading on the ADC reference (worst case) so that's not too bad.  The outputs of the op-amps feed 22 ohm resisters (to match the ADC sample-hold circuit impedance I think) with a 22nF? cap across the ADC's differential inputs close to the ADC itself.  This filters out some of the high frequency noise that can alias back into the audio band during the sampling process of the delta-sigma converters.  It works beautifully ... handles the full range of pickups (minus some super high output actives), has minimal components, and is *very* low noise if you keep the 5V and 3.3V rails clean.  If you need a drawing let me know.

ElectricDruid

Quote from: AdamB on July 23, 2019, 05:24:10 AM
SRAM


I found on the DigiDelay project that I needed a pull-up resistor on the MISO line too, to prevent it from floating when neither SRAM was selected. Since I used the same dsPIC you're using, watch out for that one.

AdamB

QuoteOne buffer input is the guitar.  The other buffer input is ground. Both buffer inputs have a DC blocking cap of 100nF.  This differential signal (guitar signal - ground signal) cancels out the common mode noise. 

So like phase cancellation? That's a neat idea!

QuoteIf you need a drawing let me know.

Sure, that'd be great! Can try to roll the ideas into a future revision!

QuoteI found on the DigiDelay project that I needed a pull-up resistor on the MISO line too

Yeps, got that! Got that already from reading your digidelay page, it's been super useful and I've learnt a lot looking at it. The first iteration I built was basically the digidelay with 1 sram and all the opamp stages removed (as I didn't unserstand them) and with the momentary jfet switching added with a 3pdt switch to kill the dry signal when in use whilst keeping the dry entirely analogue. Another cool thing with using a codec chip is that they typically include all the filtering internally for various sample rates. So I don't need to worry about the opamp mfb filter stages that I can't figure out! Also saves board space.

[indifferent::engine]
http://www.indifferentengine.com

markseel

#12
Here you go.  A minimal input circuit.  Use it with the PCM4201 ADC and you'll have a *very* quiet guitar signal and plenty of input headroom for just about any pickup style.



Supply the this circuit and the PCM4201 with 5V (9V --> regulator -->5V).  The PCM4201 needs 3.3V for digital signals but that can be the same 3.3V regulator you use for other digital stuff.

Keep your micro controller and digital ground separate from the analog ground that includes this circuit and the ADC.  There will be I2S signals between your micro controller and the ADC so connect the digital and analog grounds right under the PCB area where these signals run.  Or connect the two grounds right under the ADC since it has separate analog and digital ground pins.

I should have noted this; since you're feeding a differential input ADC with this circuit that derives the signal from single-ended you'll want to multiply your PCM signal value by 2 so that the PCM values range from min to max.  This does work against us a little - the noise floor in the PCM stream is also doubled.  But my measurements show that the noise floor is still really low and better than I was getting when using a single-ended ADC.

Now for the shameless sales plug.  The C99 effects pedal has this circuit in it and I've measured the noice floor - it's low.  You can use the C99 for a development system since the JTAG connection is exposed on the PCB and the firmware dev kit is in GitHub.

The C99 is being crowd-funded but it's going real slow - I really want this funded :-).  Check it out!!

www.indiegogo.com/projects/c99-effects-pedal
https://www.instagram.com/3degreesaudio

quad4

#13
I appreciate the shameless plug.  I've been looking for a nice digital hardware platform to bootstrap a project.

How much RAM/flash will be in the final design usable for audio "data" streams?  OK to provide the capacities, bandwidth, latency, etc., but what I'm looking for is how many parallel (song length) streams can it write, load, and mix in real-time  (independent of any effects) ... and how many hours of 24 bit/44khz can the device store.

Any chance you'll open up access to full project source?  That would be a huge differentiator compared to current products on the market.

Quote from: markseel on July 24, 2019, 02:26:15 PM
Now for the shameless sales plug.  The C99 effects pedal has this circuit in it and I've measured the noice floor - it's low.  You can use the C99 for a development system since the JTAG connection is exposed on the PCB and the firmware dev kit is in GitHub.

The C99 is being crowd-funded but it's going real slow - I really want this funded :-).  Check it out!!

www.indiegogo.com/projects/c99-effects-pedal
https://www.instagram.com/3degreesaudio


markseel

Hi quad4.  I'm not sure how to answer but I'll try ...

There's 256KB of RAM for program and data, usually turns out to be about 220K or RAM for sample data since the programs themselves are small.  Enough for algorithms but not enough for long delays.  There's no bulk storage (like FLASH) to store complete audio tracks/songs.


mhelin

#15
So there isn't space for a 5x5 ball (actually 24) FBGA HyperRAM chip (IS66WVH8M8) on the C99? That would give you 8 MB (8x8Mbit) of RAM in small space.

See http://www.instruments4chem.com/page10/page53/index.html

Quote from: markseel on July 26, 2019, 12:12:23 PM
Hi quad4.  I'm not sure how to answer but I'll try ...

There's 256KB of RAM for program and data, usually turns out to be about 220K or RAM for sample data since the programs themselves are small.  Enough for algorithms but not enough for long delays.  There's no bulk storage (like FLASH) to store complete audio tracks/songs.

mhelin

#16
(double post, removed - where is the delete button?)

cloudscapes

When we're talking about storing whole songs/tracks, it's better to use SD cards anyway. From a price/usability/convenience point of view.

But if you're making a delay, then RAM is better. Flash/SD has limited write cycles and delays can burn through these cycles by the tens/hundreds a second.

I bought a couple of these recently which are a nice amount of ram in a small package (disregard the picture, it came in SOIC-8). Have not tried them yet though.

~~~~~~~~~~~~~~~~~~~~~~
{DIY blog}
{www.dronecloud.org}

mhelin

#18
Quote from: cloudscapes on August 02, 2019, 08:00:30 AM
When we're talking about storing whole songs/tracks, it's better to use SD cards anyway. From a price/usability/convenience point of view.

Ideally it would be nice to have both large RAM and SD for storing. The HyperRAM solutions aren't expensive, the 16 megabytes (128 Mbits) version costs only 5,75 EUR (about the same in dollars) :

https://www.mouser.fi/ProductDetail/ISSI/IS66WVH16M8BLL-100B1LI?qs=sGAEpiMZZMutXGli8Ay4kHYjrQCjmpQucr6oaQ%2F1ts8%3D

That would store 2 min 50 seconds samples at 48k/16 bits. Would make that XMOS board nice Akai MPC type sampler when used with MIDI, so you could sequence drum, bass, guitar or synth loops and store the samples and MIDI sequences to SD card (or tramsferred via USB to host computer where available).


QuoteI bought a couple of these recently which are a nice amount of ram in a small package (disregard the picture, it came in SOIC-8). Have not tried them yet though.
Nice chip for delay effects.

gena_p1

WM8731 has a very noise ADC. I wasted some time on it.