# MiniVol - Simple DIY PGA2320 Volume Control



## error401

After receiving a request some time ago from theAnonymous1 over at that other board to write simple firmware to control a PGA2320 (or PGA2310), I found that I needed prototype hardware to test my code on. So I present to the community my board & schematic for critique. It seems like a _simple_ volume control of this type is somewhat in demand around here, and hopefully my efforts will be useful to others.

 The design is simple, just a small microcontroller and the PGA2320 chip, plus the necessary connectors (button headers, audio i/o, isp header and power). It is designed so that it can work with either up/down pushbuttons or a rotary encoder, with a configuration jumper to select. A mute button header is provided, with an indicator LED. EEPROM on the micro will allow the state to be saved between power cycles. The only other functionality provided is room for a 5V regulator so only +/- inputs are needed.

 If you're not familiar with the PGA2320/PGA2310, they are TI's volume control parts (Burr-Brown division), based around digitally-controlled opamp gain stages. This allows a gain range from -95.5dB to 31.5dB (yes, you can add gain). For those applications that need it, a jumper is provided that will prevent the gain settings from being enabled (0dB cap).

 On the specsheet, these chips are impressive, but there are some caveats when using them. This board addresses all of the datasheet notes on proper implementation but for one: no input buffer is provided. The IC should be driven by a source impedance of 600R or less, and analog performance will degrade if that's not satisfied, so if the source is the least bit weak, you'll need a buffer stage between the source and the volume control. I don't personally feel that an output buffer is necessary - PGA2320 can drive 600R loads quite well.

 Firmware isn't done yet, but my prototype with a PGA2311, pushbuttons and no mute seems to work fine. It should not be difficult to extend the firmware to the planned state. When it's done and tested, the code will be released under an open source license (probably BSD).

 Unfortunately, PGA2320 seems to be difficult to source right now, though TI does seem to be offering samples as usual.

 BOM cost without the volume control is about $10.

 I have put in a fab order for 6 of the boards below. They should arrive in a couple weeks. I have 4 spares to let go to the first takers. Price is $10/board plus $1.50 shipping (US/Canada), just enough to recover my cost.

 I have also designed a small (2.5" x 1.4"), all SMD +/-15V power supply based on LM317/337 and the various datasheet/internet recommendations for clean power. I ordered only one of these, but will give full documentation to anyone who asks for it. BOM cost for that is about $20.

*Edit Jan 18, 2008:* - I have put up a website for the project at MiniVol PGA2320 Volume Control - error404's Audio DIY Endeavours more details can be found there.

Board/Schematic PDF
Complete BOM


----------



## glt

Can two boards be controlled by a single controller for a balanced volume control? 
 thanks


----------



## steinchen

Quote:


  Originally Posted by *glt* /img/forum/go_quote.gif 
_Can two boards be controlled by a single controller for a balanced volume control? 
 thanks_

 

no, the board hasn't been designed for balanced application


 nice little board, error401 !
 I guess size is one of the major goals. Nice work. This tiny board can be easily installed in an amp to replace the vol control. While driven by a modern CDP and directly connected to an amp with decent input impedance it should work without input and output buffers.

 I'm going to try the PGA23xx sometime in 2008 too, but I'm planning a larger board with frills like LCD display support.


----------



## MisterX

Quote:


 It is designed so that it can work with either up/down pushbuttons or a rotary encoder 
 

There are no mounting holes in your image so I have to wonder....

 How are you planning on mounting it if you use pushbuttons?


----------



## djbob

I'll take a board when they're ready


----------



## BrianDonegan

Quote:


  Originally Posted by *glt* /img/forum/go_quote.gif 
_Can two boards be controlled by a single controller for a balanced volume control? 
 thanks_

 

You could actually use a second board, without a uC, and tap the SPI from the first board to use them balanced.


----------



## error401

Quote:


  Originally Posted by *MisterX* /img/forum/go_quote.gif 
_There are no mounting holes in your image so I have to wonder....

 How are you planning on mounting it if you use pushbuttons?_

 

I was planning on using my favourite mounting method: zipties, and keeping the buttons off-board (the PCB isn't really set up for onboard ones anyway). I think there's room for 2 mounting holes though, so I may as well add them.

  Quote:


 no, the board hasn't been designed for balanced application


 nice little board, error401 !
 I guess size is one of the major goals. Nice work. This tiny board can be easily installed in an amp to replace the vol control. While driven by a modern CDP and directly connected to an amp with decent input impedance it should work without input and output buffers.

 I'm going to try the PGA23xx sometime in 2008 too, but I'm planning a larger board with frills like LCD display support. 
 

You could do balanced by tapping the SPI as mentioned. Shouldn't be too difficult - if you just extended the relevant uC pins and stacked the boards it should work well.

 Size was a major goal for this one - I'm going to try a design with the SOIC version of the uC and see how much smaller I can make it, but I have a bunch of DIP ATtiny44 on hand so I'll probably go with that design unless it really saves me on board cost.

 I'm also planning a much more ambitious full-on preamp (relay selectors, VFD, nice amp stages, lots of digital IO for fun stuff..), but I find it easier to develop in little bits. If I get this working well and the code works well I can integrate it when I get around to doing the bigger project. In the meantime, I need a volume control for my power amp .

 One more question for you folks: I have 2 free GPIO pins - any ideas for features that could use them? I was thinking of adding a jumper to turn on/off gain in the PGA (ie. limit the range from -128dB to 0dB instead of going to +32dB) and maybe to select between 1dB and 2dB steps or some such. Anyone else?


----------



## BrianDonegan

Quote:


 One more question for you folks: I have 2 free GPIO pins - any ideas for features that could use them? I was thinking of adding a jumper to turn on/off gain in the PGA (ie. limit the range from -128dB to 0dB instead of going to +32dB) and maybe to select between 1dB and 2dB steps or some such. Anyone else? 
 

I have versions of our Kookaburra code that do this (stop at 0dB) and I get lots of requests for it. It would be nice to be able to switch quickly to that mode. I don't think changing the step sizes will get you much. Maybe add acceleration to the rotary encoder (faster you spin it, bigger the step sizes). That's what we will be doing.


----------



## error401

I have updated the images in the original post to reflect these changes. There are now two mounting holes and a jumper for turning gain on and off. Please refresh the images.

 I could also potentially gain one more GPIO by ignoring the PGA's mute pin and doing that control via SPI. It's pretty redundant...


----------



## error401

I have just ordered 6 copies of the PGA board (and a bipolar 15V supply for myself 
	

	
	
		
		

		
		
	


	




), basically as pictured above, from BatchPCB. They should be here in a couple weeks.

 Total cost was $45 for the 6 boards, plus $15.56 S&H. If anyone is interested, I'll give up 4 boards for $10 each plus $1.50 shipping. If you choose to take one of the boards, no promises on the code coming from me. There's a chance I'll abandon this without finishing...

 I will post a complete BOM shortly, and if anyone's interested, information on my MiniPow supply board/schematic - but I have not ordered any of these for others since I just slapped it together. LM317/337 +/-15V supply in 1.4"x2.5" (dense double-sided SMD). It looks like this:


----------



## error401

Boards arrived today (finally!) and they seem well constructed. Build quality from BatchPCB is definitely quite good. As I mentioned in my last post, but never followed up on, I put up all the details on my web site:

MiniVol PGA2320 Volume Control - error404's Audio DIY Endeavours
MiniPow LM317/337 Bipolar Power Supply - error404's Audio DIY Endeavours

 I built up the power supply first, and after a few scary minutes of diagnosis, I realized that all the diode silkscreens were reversed, so they were all in backwards. After reversing all the diodes, the supply fired up like a champ. Output voltage is within 2% of spec, which isn't bad at all, not regretting the choice to forego a trimmer at all.

 Overall it was a pretty easy build. The SOD-323 diodes are a lot smaller than I thought, but manageable. Because they're leaded, unlike say 0805, the bodies are a lot smaller and they're a bit tricky.

 If there's interest, I could do a fab run and sell boards, but I don't have any extras of this, only ordered one.

 Now to do the volume control board and write up some firmware 
	

	
	
		
		

		
		
	


	




 Pretty small eh:


----------



## Mazuki

I'm definitely interested in some boards. Anyone else?


----------



## Polaris111688

I'm pretty interested too. Any chance it'll be remote controlled in the future with LCD display?


----------



## error401

Quote:


  Originally Posted by *Polaris111688* /img/forum/go_quote.gif 
_I'm pretty interested too. Any chance it'll be remote controlled in the future with LCD display?_

 

Not for this project I'm afraid. In the longer term I'm working on a full, totally over the top preamp that'll have all that, but not just for the volume control.

 And I still need to write and test the firmware, so it might be a bit before the volume control is ready...but the power supply seems fine now 
	

	
	
		
		

		
		
	


	




.


----------



## error401

The first prototype is up and running and playing music! It sounds good, the SPI firmware is working and I've got some nice ramping for mutes.

 Still need to do the up/down handlers, switch debounce and rotary encoder decoding though.

 Anyway, the design and board seem sound, it all sounds great and works properly. I'll post updates as I get the firmware more complete.


----------



## Polaris111688

I'm actually really interested in obtaining the power supply (I'll buy it now if you have boards). If you ever do implement an LCD screen and remote control for the volume control, I'll put down cash for it as well. I'm interested in replacing the welborne attenuator in the preamp section of my integrated amp.


----------



## error401

I've got the firmware to a point now where I'd be willing to share it with interested parties, though it's not fully functional yet (no rotary encoder support yet). If anyone would like it for their own project or copies of mine, PM me.

 I've also got 2 spare boards if anyone is interested, and can order more on an upcoming order if there's interest. $10 shipped. I can program a microcontroller or two for anyone that needs it.

 If anyone is interested in the power supply I can order those boards too, $15 shipped.

 Or rally the troops and I'll organize a group buy of boards and micros.


----------



## dvbjunky

Very nice project. I just dumped a microcontrolled Relay-volume-project because the developer decided finally to not share his PIC code. 

 So your Diy project sounds very interesting for me. A group buy should be posted on several forums (Diyaudio, headwiz and others).

 I am in the hospital at the moment (climbing accident) and will come back to you after my "release" in 1 week.

 keep up the work

 best regards

 Alan & Ayk


----------



## error401

Quote:


  Originally Posted by *dvbjunky* /img/forum/go_quote.gif 
_Very nice project. I just dumped a microcontrolled Relay-volume-project because the developer decided finally to not share his PIC code. 

 So your Diy project sounds very interesting for me. A group buy should be posted on several forums (Diyaudio, headwiz and others)._

 

Of course I plan to release the firmware binaries and source code when they're done. I expect to be done fairly soon with the firmware, but I've not had a lot of time to work on it.

 Unfortunately you missed out on the order I made for a few boards, it wasn't enough for a real group buy. The gerbers are available though, and you can have them fabricated yourself for a reasonable price in small quantities by BatchPCB. That's all I did for the little bit of interest I got, since the quantity was too small to get a reasonable price from a production fab house.


----------



## error401

I would like to provide an update for those who ordered boards and microcontrollers from me.

 Unfortunately some personal issues came up and I've been unable to work on the firmware until today. The boards and microcontrollers have arrived, and everything seems in order with them.

 Firmware made the first step in a while today; I fixed a major bug that was stopping me from going on, and implemented code to allow the increment/decrement buttons to be held down. At this point I believe everything is working well except rotary encoder support. I hope to work on that tomorrow; I'm running out of room on the micro so it might take some work - or it might not.


----------



## error401

Long awaited good news: I have _finally_ got all the features I wanted done and working in the firmware. I'm going to give myself the weekend to test it out a bit further, but it seems fine after limited use and development. If there are bugs at the moment they should only be in corner cases. I will try to test these over the weekend.

 I did notice some faint clicking noise when manipulating the encoder. I believe this must be due to the PGA2320 switching gain, though it should be doing ZCD. It's not bothersome and I don't think I will be able to fix it.

 What ended up in there:

 - Rotary encoder fully working - I personally think this is the nicest input for this
 - Holding down the button ramps the volume after 500ms every 100ms
 - Mute ramps down and back up for a smooth transition. It is a soft mute that attenuates 36dB from the current setting

 Once it's totally done and tested I will post sourcecode and binaries to the project website.

 I have sent e-mail or PMs to everyone that ordered from me. If you didn't get one, please contact me as I don't have you in my file and you won't get anything.


----------



## fabiodord

Hello everybody!

 I'm a new user of this forum, I'm looking for some ideas about the AD1955 SPI Port.....
 I mean, have one dac do myserlf with AD1955 and I'd like to use the SPI port for the volume control.
 My idea is more or less to use one encoder to set the volume in my DAC but I'm not a good programmer and I'd like to find someone that can help me to write the software (I prefaire Microchip PIC because I know some basical function and I have all what I need to program the chip)

 If someone can help me about the software I'll glad to take this help!!






 Thanks!!


----------



## BrianDonegan

We are about to release a simple volume control for controlling the volume of our DACs (Volumite). You could probably edit our source to make it work for the AD1955. It will use an Atmel ATiny, but all the tools are free. It will also use a pot instead of an RE, but you should be able to tweak the code for that as well if you want.

 Source should be available in a couple weeks.


----------



## error401

You could probably use the MiniVol code with only minor changes. To set the volume in AD1955 you send two 16-bit words, with the 2 LSB used to select if it is left or right. The PGA2320 uses one 16-bit word with one byte for left and one byte for right. You'd need to modify the code so that the output word is correct, but other than that it'd be the same.

 I dislike the PIC architecture, and the free toolchain is not nearly as good as the free tools for AVR. Using a pot as Brian suggests isn't a bad idea either, it gets rid of issues like storing the startup state and provides a more pot-like feel. Just make sure you build in some hysteresis somehow.


----------



## fabiodord

Thanks guy!!

 this week A.S.A.P. I'll try to modify your code for the minivol.... I hope to be able 
	

	
	
		
		

		
		
	


	




 .....

 I know AVR Studio and Win AVR for code development... is it what I need?
 I have AVR usb programmer and if required AVR JTAGICE mkII.... We use this in my company for the boards development...

 Thanks in advance

 Fabio


----------



## error401

Yes, I used AVRStudio and WinAVR with an AVRISP. I don't have the JTAG dongle.


----------



## fabiodord

Hi guys,

 I tried to modify your PGA software for my application with AD1955....

 I understand the main part of the software but it's too difficult for me to modify....
 I mean, I saw in your software a very nice feature about eeprom, save data about the level and so on but for my programming level it's out of my know...

 Could you advise me about somehow to read for understand the SPI control?

 Thanks in advance!


----------



## error401

Quote:


  Originally Posted by *fabiodord* /img/forum/go_quote.gif 
_Could you advise me about somehow to read for understand the SPI control?

 Thanks in advance!




_

 

Try reading around at the avrfreaks forums, there is lots of good info and helpful members there.


----------



## carpin

Nice board error401.

 I am going to try to build the minivol.
 I download the latest version demo from Altium, and i get a lot of DRC error's.
 So first i have learn, how to work with Altium 





_Rule Violations
 Width Constraint (Min=10mil) (Max=100mil) (Preferred=25mil) (All)_


----------



## paulb

Dredging up an old thread...hoping error401 is still monitoring...
  Keenan,
  How did this all end up? Are you happy with the sound? Did anyone else build it?
  I'm thinking of making a 6-channel version. Saw your source code, seems quite sophisticated (event queue!) but thanks for making it available.
   
  Cheers
  Paulb


----------



## wakibaki

If you don't get any response to this, have a look at my audio page where you'll find an 8-channel touch sense/remote volume control http://wakibaki.com/audio.php#t5 and further on down, a couple of amps using PGA volume controls. There are sections with circuit diagrams and working code for Microchip PIC to drive 7-segment displays and control digital pots or PGA chips by bit-banging out SPI or other serial protocols.
   
  If you can't get your head round it all you can PM me to ask questions. Maybe I'll start a thread to explain how to develop these kind of devices.
   
  w


----------



## Avro_Arrow

I'd be up for that...I'm clueless at programming...
   
   
  Quote: 





wakibaki said:


> "snip" Maybe I'll start a thread to explain how to develop these kind of devices.
> 
> w


----------



## paulb

Quote: 





wakibaki said:


> ... 8-channel touch sense/remote volume control http://wakibaki.com/audio.php#t5


 
  Nice. Great display. Do you post schematics at all? Did you do anything special with the pga2320?


----------



## wakibaki

I generally post schematics of what I do, I just didn't get around to it in the case of the 8-channel volume control. It has some complications anyway because it incorporates the touch-sense functionality. 
   
  Towards the end of this thread:- http://www.head-fi.org/t/586042/what-i-did-next-with-texas-headamp-chip-a-digital-control-desktop-portable
   
  ...you will find a schematic for the amplifier using the 7-segment displays, TPA6120 headphone amplifier chip and PGA2320 volume control. There's a link to a high resolution copy of the schematic. The processor is a PIC 16F887 and regular push-switches are used..
   
  There's also a copy of the code for the same processor to drive the PGA2310 in the parallel NE5532 amp on the webpage. The only difference is that the NE5532 amp has 2 displays for left and right channels, where the TPA amp just uses the decimal points to indicate left, right or both channels controlled.
   
  You should be able to figure out the principles from these, your design will not be identical in detail to either of mine. You'll have to think about whether you want to have independent control of each channel, and how you'll deal with displaying the status of each if you do. I just produced a technology demonstrator for the touch sense screen and drove all 8 channels in unison. I posted pictures on diyaudio but it didn't get a lot of interest so I moved on to building something new. It's a shame in a way because the touch-sense screen is cheap to implement and makes an attractive fascia. I abandoned it for the TPA amplifier because it needs the processor to be running all the time and I wanted to be able to put the processor to sleep to save battery capacity.
   
  The real issue with the PGA volume control chips is the PCB layout. You have to get it right or you can end up with digital noise on the audio, particularly when changing volume. I had to redesign the TPA6120 PCB to get rid of it, although there were no problems with the NE5532 amp. Somebody on diyaudio was complaining about problems with regular audio noise too (hiss), but I didn't have any problems with that.
   
  w


----------



## paulb

Thanks, I had a look, very impressive. Wish I had the time to take on something like that. My ambitions are more like that of the originator of this thread: simple. I'm going to build a separate analog board and use a prototype microcontroller board of some sort to test it with. I'll probably use an AVR of some sort because dev tools are so cheap and I'm not very familiar with PICs.


----------



## wakibaki

Good luck. Let us know how you get on...
   
  w


----------



## mtoc

Hi folks, how is PGA2311? I mean, 2311 has better thd, but it's +/-5V, what's the disadvantage of it compared to +/-15V?


----------

