Head-Fi.org › Forums › Misc.-Category Forums › DIY (Do-It-Yourself) Discussions › USB volume/replay gain control design
New Posts  All Forums:Forum Nav:

USB volume/replay gain control design

post #1 of 25
Thread Starter 
I have been experimenting with analogue volume setting with digital control. The main motivation is to do Replay Gain in the analogue domain, because for whatever reason it doesn't sound as good to me in the digital domain (particularly with FLAC).

My initial design is based on two DS1669 digital potentiometers. An ATTiny45 with USB interface and WinAMP plug-in control them, automatically adjusting the volume according to ReplayGain data.

The sound quality isn't bad - better than digital Replay Gain with 24bit output I find. However, the DS1669 isn't the best IC for audio apps due to only being only about 20% accurate over the entire scale! It's not true log either.

The AD7376 looks like a much better solution. I believe this IC is used in some mass produced amps. One potential issue is the need for +-15v, which would mean either a power brick or some stuff to generate it from the USB 5V supply (ICL7660?)

Another option would be to use a digitally controlled switch. A 16 way switch for each channel with 16 resistors to select attenuation level should give excellent results, but I am having trouble finding such an IC.

I'd really appreciate some feedback and ideas on this one. Would save me reaching for the volume knob so often, at least
post #2 of 25
Neat idea. How'd you do USB on the ATtiny45? I've been trying to get AVR USB working on a 'tiny44, and not having any success. I've pretty much given up and decided to use serial instead.
post #3 of 25
Thread Starter 
I just used the reference design from AVR USB - A Firmware-Only USB Driver for Atmel AVR Microcontrollers with the internal oscillator.

I think I was lucky because I think normally you need to calibrate the internal oscillator. My programmer doesn't support that but it looks like mine was close enough to just work. Otherwise you need a crystal.

AVR USB isn't bad, but it's reliance on C is a bit of a pain for people like me who prefer assembler. That's why I used Igor Cesko's design from WWW.CESKO.HOST.SK for my other USB project (joystick.world3.net)
post #4 of 25
Thread Starter 
BTW your project looks interesting. It's a shame the IC is only available in SOIC but I'm tempted to get one and try it. The fact that it provides audio gain at specific decibel levels is very attractive.
post #5 of 25
I'll keep at it. I'm using a crystal on my board, and I've checked the physical connections a dozen times, but I can't get it to be detected by any OS. If only I had a logic analyzer... I might try the USBtiny library instead and see if I can get that going...

SOIC really isn't too difficult to handle. The chip's been working well for me, I can recommend it. Let me know if you want my simple bit-banged C library for it.

There's also PGA2310 or PGA2311, which are pin compatible (2311 runs on +/-5V instead of +/-15) and spec almost identically that're available in DIP.
post #6 of 25
How did you do the computer part? Since getting the atmel to talk USB is possible (with the USB firmware you mentioned). But how did you told your computer how to deal with the volume control? Sounds very interesting!
post #7 of 25
Thread Starter 
error401: I just ordered some samples of the PGA2311 last night

It looks promising. I also order a sample of TPS60403DBVT, which should get the required -5V. I am a bit concerned about the ripple voltage for analogue use. I'm afraid analogue electronics is not my forte. With the LC filter from the datasheet, do you think it will be okay?

As for getting the USB stuff to work, I too had a few issues at first. It might be worth trying different USB ports and hubs, because I have found some can be a bit more fiddly than others. Also take a look at USBDeview (NirSoft - freeware utilities: password recovery, system utilities, desktop utilities) - sometimes it helps to uninstall broken devices before the OS will detect the fixed version.

Other than that, all I can suggest is you make sure you have the right pull-up on the D- line and preferably use 3.5V zeners to get in-spec voltages as again some USB ports don't like 5V signalling.

_atari_: I wrote a Winamp plug-in that reads ReplayGain data from the file tags. It needs work...

My initial plan was to use a really small 8 pin AVR with internal oscillator to keep the component count down. However, I'm starting to think a larger AVR might not be a bad idea. I could then have an LED display with the current gain on it, and a rotary encoder for manual adjustment. The device could then be used as a stand-alone volume control too.
post #8 of 25
Quote:
Originally Posted by mojo View Post
error401: I just ordered some samples of the PGA2311 last night

It looks promising. I also order a sample of TPS60403DBVT, which should get the required -5V. I am a bit concerned about the ripple voltage for analogue use. I'm afraid analogue electronics is not my forte. With the LC filter from the datasheet, do you think it will be okay?
Not sure, to be honest - I'm not great at analog stuff myself. PSRR isn't really spec'd for the PGA's though, so I'd be conservative and follow the switcher with an LC and a good linear regulator.
post #9 of 25
Thread Starter 
I have my prototype working



I can set the volume from the PC, and read it back. It works with the old DS1669 digital pots. I have the PGA2311 but am waiting for some SOT-23 adapters for the TPS60403DBVT before I implement it. The prototype will be on matrix board but PCBs will be a must for getting a clean analogue side I think. I'm not experienced with analogue audio electronics so some help designing the PCB would be appreciated.

The rotary encoder is for manual volume setting. I'm having trouble getting it to work right because the rotary encoder is cheap and very noisy. I may or may not keep it in the design, or maybe switch to a rotary encoder or up/down buttons and add a jumper to disable it.

The rotary encoder also contains a push switch, which changes modes. So far I have USB and PASS modes. In USB mode the set volume is used. In PASS mode the gain is set to 0, so it's basically pass-through. If I can get the manual setting working I'll also implement a "SET" mode where only the manual setting applies and USB is ignored. If that were working it would be a useful stand-alone device too.

The final design should be both cheap and easy to make. I am using an ATmega8.

The blue display is to match the HEADFIVE and C.E.C. DA53
post #10 of 25
Sorry to be rude: But this is f* amazing! Awesome work!
Unfortunately limited to a (winamp) plugin! But still great effort for a great result!
post #11 of 25
Thread Starter 
Thanks

It's easy to write plug-ins for other systems. The device is a standard USB HID device, meaning it requires no drivers and can be accessed without any special code.

I have ordered another blue LED dual digit display so I can add "dB" to the end of the display, but I have run out of pins on the AVR so some will have to double up. The extra two will be entirely optional.

I am thinking of giving up on the rotary encoder. I have spend hours searching the net and can't find a single example where someone had got one working reliably on an AVR

I'm not sure if the up/down manual mode would be at all useful. Perhaps just a button to toggle between computer control and pass-thru mode would be enough. Comments please.
post #12 of 25
Quote:
Originally Posted by mojo View Post
I am thinking of giving up on the rotary encoder. I have spend hours searching the net and can't find a single example where someone had got one working reliably on an AVR
I might have an example for you soon, once I get the MiniVol firmware done. You might want to try an optical encoder instead as well, they produce much nicer output.
post #13 of 25
Thread Starter 
That would be brilliant, error401. I think my encoder might just be cheap crap, as you say an optical encoder is the way to go. Unfortunately they are both expensive and hard to get in the UK... But wheel mice are cheap

I'd love to see your code. Otherwise I'm just going to go with up/down buttons. I want the unit to be stand-alone as well.

On the thread about your design, you mentioned that there was demand for such a device. I'm just curious as to how people want to use it. Are we talking uber-minimal cd player -> power amp people who just want a plain volume control? I'm probably being daft here but what is the advantage over a high quality pot or rotary switch?

BTW, did you ever get USB working on your micro? I'm not sure AVR-USB will work on the ATtiny44, so it might be worth trying the USBtiny code.

I like your idea of having a jumper to limit the volume. I might steal that idea if you don't mind... if I can find somewhere to attach it.
post #14 of 25
Quote:
Originally Posted by mojo View Post
I'd love to see your code. Otherwise I'm just going to go with up/down buttons. I want the unit to be stand-alone as well.
Quote:
I like your idea of having a jumper to limit the volume. I might steal that idea if you don't mind... if I can find somewhere to attach it.
My code will all be posted in full when it's done, which I hope will be within the next week or so. Of course I don't mind if you take that idea! I'm a pretty vocal proponent of open source software, hardware and documentation.

Quote:
On the thread about your design, you mentioned that there was demand for such a device. I'm just curious as to how people want to use it. Are we talking uber-minimal cd player -> power amp people who just want a plain volume control? I'm probably being daft here but what is the advantage over a high quality pot or rotary switch?
You get a preamp stage for free, and channel matching should be much, much better than any pot. And it's cheaper than both of those options if you're going for comparable quality.

Quote:
BTW, did you ever get USB working on your micro? I'm not sure AVR-USB will work on the ATtiny44, so it might be worth trying the USBtiny code.
I haven't had a chance to look into it again yet. I've got too many projects on the go right now, I think it will be a while before I touch it again.
post #15 of 25
Thread Starter 
I'm looking forward to what you come up with error401. I too will be publishing my code.

I have a question about your PCB design. In the datasheet for the PGA2311, they recommend the following layout for the PCB:



So they are keeping totally separate ground planes and physically separating them too. Do you agree with that design and is there some reason you didn't go that way?
New Posts  All Forums:Forum Nav:
  Return Home
Head-Fi.org › Forums › Misc.-Category Forums › DIY (Do-It-Yourself) Discussions › USB volume/replay gain control design