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 - Page 2

post #16 of 25
Quote:
Originally Posted by mojo View Post
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?
I believe I did follow their recommendations. I didn't want to require a completely separate digital supply, but other than that, my board does what they recommend. If you take a look at the Recommended Connection Diagram, you'll see that they recommend connecting the digital and analog ground planes at a single point, as is traditional. I took the liberty of using a ferrite here; but to be honest, I'm not sure if that's better than a plain connection.

Am I missing what you're asking?
post #17 of 25
Quote:
Originally Posted by mojo View Post
Thanks
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
user a timer overflow to poll the rotary encoder (debouncing included this way)

Code:
volatile char enc_delta;    // -128 ... 127   rotary encoder delta


ISR( TIMER1_OVF_vect ) 
{
  TCNT1 = 0xE0C0; // 8Mhz, prescale=1 16-bit-timer every 1ms -> 65536 - 8000 = 0xE0C0

  // rotary encoder
  // author: Peter Dannegger
  // date: 30.07.2003 12:25
  // http://www.mikrocontroller.net/topic/6526
  #define PHASE_A (PINB & (1<<PINB1)) // rotary encoder
  #define PHASE_B (PINB & (1<<PINB2))

  static char enc_last = 0x01;
  char z = 0;

  if ( PHASE_A ) z = 1;
  if ( PHASE_B ) z ^= 3;       // convert gray to binary
  z -= enc_last;               // difference new - last
  if ( z & 1 ) {               // process only 1 step changes
    enc_last += z;             // store new as next last
    enc_delta += (z & 2) - 1;  // bit 1 = direction (+/-)

//    if ( !(enc_count % 2) ) {  // only every 2nd step
//      if ((z & 2)) {    // up or down ?
//        enc_delta++;    // 0-255
//      }
//      else {
//        enc_delta--;    // 255-0
//      }
//    }

  }
}



int8_t getEncDelta () {
    int8_t count = 0;

    uint8_t tmp_sreg = SREG;   // backup status register (including I-flag)
    cli(); // disable interrupt
    count = enc_delta;
    enc_delta = 0;
    SREG = tmp_sreg;     // restore status register (including I-flag)
    return( count );
}


int main (void) {
  TCCR1B = (1<<CS10); // prescale=1
  TIMSK |= (1<<TOIE1);  //enable timer1 overflow interrupt

  for(;;) {

    char tmpEncDelta = getEncDelta();
    if ( tmpEncDelta != 0 ) {
       
    }


  }

}
you may want to count every / second / forth click depending on your rotary, depending on the count of phase shifts it does when turned a click
post #18 of 25
Thread Starter 
Thanks for the code, but I was just on my way here to post my solution

I managed to get a 'scope on the encoder and it was noisy as hell. In fact, it never stopped bouncing. I replaced it with a one from a mouse wheel and it works perfectly!

I have installed the new volume and power ICs too, and am in the process of writing code for them.

Thanks for the help anyway though.
post #19 of 25
Thread Starter 
Quote:
Originally Posted by error401 View Post
I believe I did follow their recommendations. I didn't want to require a completely separate digital supply, but other than that, my board does what they recommend. If you take a look at the Recommended Connection Diagram, you'll see that they recommend connecting the digital and analog ground planes at a single point, as is traditional. I took the liberty of using a ferrite here; but to be honest, I'm not sure if that's better than a plain connection.

Am I missing what you're asking?
No, I'm just not reading your PCB layout right

It looks good, and very compact.

I now have my design working properly. Only made on stripboard but even so it sounds very good. I added another couple of LED displays so I could add "db" onto the display and multiplexed them with the SDI and SCLK lines on the PGA3211.

I will publish schematics etc soon. At the moment they only exist in my head

PS. I am working on a remote control interface too.
post #20 of 25
Thread Starter 
Right, here is the first draft of the schematic:



It looks right and the design used for the PGA2311 is from the datasheet. I do have some questions though... I'm more of a digital guy and am not that good with analogue electronics.

First, about the analogue and digital grounds. The datasheet says just connect them. Is that the best option or should there be some kind of filtering between them?

On the subject of filtering, I used the RC filter example from the datasheet. I believe an RC filter is best for audio, but would love some comments or suggestions. In particular, I just copied the example values for the resistor and cap from the datasheet...

Finally, a request for comments regarding the interface. Currently I have a rotary encoder and a switch. The rotary encoder controls volume manually, and the switch changes between set volume and pass-thru mode (unity gain). Holding the switch down toggles the volume limiter on and off (limits the maximum gain because it goes up to 37dB!). How does that sound? Any other features I should add?

I am also considering moving to an LCD display instead of LEDs, because LCDs use a lot less power and would be ideal for battery operation. I learnt from Clive Sinclair's mistakes This would also free up some I/O and allow an IR receiver to be connected for remote control.

The problem I am having is finding suitably small LCDs. The smallest seem to be about 35mm high, which is enough for two rows of characters. I only really need one row, but 8x1 LCDs always seem to be 35mm high anyway. The smallest I have found is 32mm, but for portability I really want to get down to 25mm or less. Anyone know any such LCDs?
post #21 of 25
I'm not too great at the analog stuff myself. In my own experience, I usually connect the analog and digital grounds with a ferrite, and I've never noticed any real problems with that approach.

I assume there's a bug in your schematic on AOUT/AGND left and right. The two circuits are different, the caps are connected to opposite legs. I'm not sure what you intended with those caps (are they the filter you refer to)? Either way, I don't think they will do anything desirable, at least in those large values, and with no R component.

LCDs are more difficult to drive. I doubt you'll find any small ones with integrated drivers, but if you're willing to add a driver IC to your circuit, it's not hard to find small DIP modules. Check around DigiKey, there are a bunch there and they're cheap. Driving them might be a challenge though, they generally require negative bias voltages and AC drive voltages.

One strategy for using LEDs that works fairly well is very low duty cycle PWM with very high current. You can usually get quite a bit lower power usage for the same brightness by driving the LEDs out of spec briefly instead of driving them at a low level continuously.
post #22 of 25
Thread Starter 
Quote:
Originally Posted by error401 View Post
I'm not too great at the analog stuff myself. In my own experience, I usually connect the analog and digital grounds with a ferrite, and I've never noticed any real problems with that approach.
Interesting, I will have to try that. I suppose if I make the PCB with some holes it would be easy to try different things.

Quote:
I assume there's a bug in your schematic on AOUT/AGND left and right. The two circuits are different, the caps are connected to opposite legs. I'm not sure what you intended with those caps (are they the filter you refer to)? Either way, I don't think they will do anything desirable, at least in those large values, and with no R component.
Well spotted, there is indeed a mistake. The capacitors are supposed to be the ones recommended in the datasheet on page 11, but I connected them wrong...

[quote]LCDs are more difficult to drive. I doubt you'll find any small ones with integrated drivers, but if you're willing to add a driver IC to your circuit, it's not hard to find small DIP modules. Check around DigiKey, there are a bunch there and they're cheap. Driving them might be a challenge though, they generally require negative bias voltages and AC drive voltages.[quote]

Indeed. I have managed to find some character ones on eBay that are only 25mm high, but they don't have backlights.

As you say, modules are cheap but not easy to work with. I want to keep the design simple ideally.

Quote:
One strategy for using LEDs that works fairly well is very low duty cycle PWM with very high current. You can usually get quite a bit lower power usage for the same brightness by driving the LEDs out of spec briefly instead of driving them at a low level continuously.
Yes, I had considered that, it's an interesting idea. I did some quick calculations though and it's still far in excess of what I would like. With an LCD I could get the total current down to milliamps I think.

Actually, one option might be to use a Nokia phone LCD. They are small and compact, cheap and easy to interface. I really wanted to put the LCD at the front of a case (next to the switch and rotary encoder) so it could sit with other components in a stack or be strapped to the back of a portable player and be accessible and compact.
post #23 of 25
Thread Starter 
Here is the corrected schematic:

post #24 of 25
Quote:
Originally Posted by mojo View Post
Yes, I had considered that, it's an interesting idea. I did some quick calculations though and it's still far in excess of what I would like. With an LCD I could get the total current down to milliamps I think.

Actually, one option might be to use a Nokia phone LCD. They are small and compact, cheap and easy to interface. I really wanted to put the LCD at the front of a case (next to the switch and rotary encoder) so it could sit with other components in a stack or be strapped to the back of a portable player and be accessible and compact.
The problem with a colour LCD is that they're generally pretty unreadable without the backlight on. With the backlight power consumption, you may as well be running LEDs for display. That said, those Nokia LCDs are pretty sexy, and the form factor is about right for nice large readable characters for this application. Should be a good place for it - you'll just have to figure out when to turn on the backlight to keep consumption reasonable.
post #25 of 25
Thread Starter 
Indeed, it would have to have iPod like control over the backlight of any LCD.
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