# Arduino based passive analogue input selection & volume control



## _atari_

Hi,

 originating form the simple question (see below) of how to have a silent, high quality volume control & input selection I have decided to build an passive µController based, arduino compatible preamp input selection & volume control. Stay tuned! PCBs will come in the near future (I really need it).

 To give you an image of the whole system I have drawn an image:




 An Arduino compatible CPU is driving the whole system. It will have plenty of outputs for LEDs and plenty of inputs for buttons, rotary encoders or even analog potentiometers. The decision to base it on Arduino is to make programming as easy as possible. There is plenty of help out there to programm it to the specific needs.

 The basic input selection can switch between a number of balanced or single ended inputs. For each input it is configurable if it is balanced or single ended.
 The output can be balanced or single ended – according to your needs.

 To convert between single ended and balanced there will be an an single ended to balanced converter. This module will be plugable in some way so that you can choose the technolgy you like (opamps, discrete or whatever).

 The volume control will be an plugable module too - since currently there is a hot debate if LDR/chips or stepped attenuators are the way to go.

 If needed a balanced to single ended converter can be attached after the volume control. But most probably this be not part of this design.

*The beginning*:

 everybody seems to agree in this forum that using relays for analog input switching and volume control is the absolute best way to achieve the best signal quality.
 Ok, sometimes potentiometers are better or have other advantages or disadvantages than relay based attenuators.
 But in the end if you do not want to reduce the singal quality as minimal as possible it is the way to go.

 But I am looking for digital (CMOS based) chips which do a comparable job. Does anybody now any analog switches and volume controls which achieve and extraordinary signal quality. Since there is no reason to introduce parts which have a higher distortion or THD level than your actual amp.

 Any suggestions?


----------



## DKJones96

TI isn't letting me log in, but there is a digital volume control they offer that works great. Linuxworks might be able to chime in with that part number. 

 Are you talking about switching an analog signal or a digital one?


----------



## Nisbeth

PGA23xx from TI is more or less the standard answer for your volume section based purely on specs, but why would you want electonic switches for input switching? As you say, almost everyone agree that relays are the best choice? If you are really anal you can find mil-spec, small signal, HF relays which will be even better than the ones used in standard hi-fi gear and they will be miles better than any IC-based switch I have ever heard of.

 /U.


----------



## PJPro

It terms of volume control, have you consider the Lightspeed Attenuator? This is basically a volume control implemented using light dependent resistors (LDRs). I've ordered a matched set of LDRs from a guy over on diyaudio and intend to use them to build a passive preamp. The approach seems to be generating a big fuss over on that forum so I thought I'd give it a whirl.


----------



## linuxworks

yeah, I've done a little bit of work with the burr-brown PGA2310 (etc) series chips.

 perfboard version:







 pcb version (from error401's board, hacked by me):





















 highly recommended! I love this chip. its dead silent, has no distortion to speak of and works like a charm. I love having smooth fades (like, when I press MUTE on my remote and it slowly sinks to zero and then rises back on unmute).

 as for input switching, the analog cmos switches may work ok but relays WILL be better (lower resistance and no capacitance issues to care about).

 I've also played around with motor pots and those can be fun, too:






 but I like the 'speed' of the PGA solution. you can do neat thinks like assign memories to vol levels and when you change inputs, it can set the vol level to the last-set value for 'that' input, etc.


----------



## PJPro

Quote:


  Originally Posted by *linuxworks* /img/forum/go_quote.gif 
_{snip}.......
 as for input switching, the analog cmos switches may work ok but relays WILL be better (lower resistance and no capacitance issues to care about).
 ...{snip}_

 

Can you point me towards a good schematic for this or, ideally, a PCB source.


----------



## linuxworks

I used an analog cmos switch for spdif switching! works just fine at the 'mhz level' but it IS digital and I'm not sure that analog will pass thru as well.

 I don't have a schematic (yet); just these photos showing the board wiring:

DIY: SPDIFmaster v2.0 is complete on Flickr - Photo Sharing!

DIY: spdif digital audio switch 'fabric' board on Flickr - Photo Sharing!

DIY: spdif digital audio switch 'fabric' board on Flickr - Photo Sharing!


----------



## PJPro

Without wanting to hijack the thread, what I'm looking for is a schematic for switching analogue inputs in a preamp (I'm building one of those lightspeed passive preamps).


----------



## linuxworks

pj: do you just need something that has remote control (like IR) and selects '1 of n' relays to be on?


----------



## PJPro

No. Nothing fancy. Say 4 analogue inputs into 1 via a switch.


----------



## _atari_

Thanks for the massive answers.
 I have the need to build a digital DAC/preamp. But this parts are for the pasive analogue section only. So expect some volume/input select PCB solution in the very near future. But I have not decided if it will be SMT or traditional through the hole, yet.

  Quote:


  Originally Posted by *PJPro* /img/forum/go_quote.gif 
_It terms of volume control, have you consider the Lightspeed Attenuator? This is basically a volume control implemented using light dependent resistors (LDRs). I've ordered a matched set of LDRs from a guy over on diyaudio and intend to use them to build a passive preamp. The approach seems to be generating a big fuss over on that forum so I thought I'd give it a whirl._

 

Do you have a link for that?
 Sounds interesting – though it will be hard to get a clear voltage from an µController (without an ADC) – but perhaps worth a try.

  Quote:


  Originally Posted by *linuxworks* /img/forum/go_quote.gif 
_yeah, I've done a little bit of work with the burr-brown PGA2310 (etc) series chips.

 […]

 highly recommended! I love this chip. its dead silent, has no distortion to speak of and works like a charm. I love having smooth fades (like, when I press MUTE on my remote and it slowly sinks to zero and then rises back on unmute).

 […]

 but I like the 'speed' of the PGA solution. you can do neat thinks like assign memories to vol levels and when you change inputs, it can set the vol level to the last-set value for 'that' input, etc._

 

Do you know how it compares to the MAX4580-4600 series spec and impression wise?

  Quote:


  Originally Posted by *Nisbeth* /img/forum/go_quote.gif 
_PGA23xx from TI is more or less the standard answer for your volume section based purely on specs, but why would you want electonic switches for input switching? As you say, almost everyone agree that relays are the best choice? If you are really anal you can find mil-spec, small signal, HF relays which will be even better than the ones used in standard hi-fi gear and they will be miles better than any IC-based switch I have ever heard of.

 /U._

 

Do you get any part numbers or series as starter?

 Since I definitively need an solution it would be no problem to build something that just does not only fit my needs. Any wishes for an analogue, passive input selection & volume control?

 I will have some thing like 3-4 analogue inputs, I2C input.
 The software will most definitively be arduino compatible (what else currently).
 It will have connections for buttons & rotary encoders.

 Anything else?


----------



## _atari_

Some ideas for the inputs/outputs:
 It should work balanced or single ended.
 With three balanced inputs or 6 single ended inputs – or anything in between.
 I have no idea how single input to balanced conversion will happen – but there WILL be a solution


----------



## _atari_

OK
 PGA 2311 seems to be better than the comparable DS1881 (from the datasheets)
 THD 0.0002 vs 0.005
 Crosstalk -130dB vs -110dB
 Noise 2.5µV vs 2.2µV
 Interchannel Matching 0.05 vs 0.5dB

 So it is decided: PGA2311 with relays.


----------



## PJPro

Quote:


  Originally Posted by *_atari_* /img/forum/go_quote.gif 
_...snip.....
 Do you have a link for that?
 Sounds interesting – though it will be hard to get a clear voltage from an µController (without an ADC) – but perhaps worth a try.
 ......snip...._

 

Take a look here. This is the (second) group buy thread and contains links to the original discussion thread.

 But, please note my comments on page 4 of the group buy thread. It has been brought to my attention that a complete kit for something called the OptiVol module (from SKA Audio) can be purchased for less than the cost of the LDRs on the group buy. There may be a good reason for this (different quality LDRs?) so I have asked if anyone would care to comment on the SKA Audio offering.


----------



## linuxworks

Quote:


  Originally Posted by *_atari_* /img/forum/go_quote.gif 
_I have no idea how single input to balanced conversion will happen – but there WILL be a solution 
	

	
	
		
		

		
		
	


	


_

 

I have heard great things about the THAT1646 chip

RCA to XLR? It's THAT (1646) easy! - AVS Forum

 it seems pretty well respected in the pro audio community. yes, its 'a glorified op amp' (sort of) and so the discrete folks will turn up their noses to it. but the rest of us won't be bothered 
	

	
	
		
		

		
		
	


	




 there's also matching bal->unbal converter chips from THAT corp, I think. (the THATcorp guys used to be the old dbx company, I believe).


----------



## PJPro

Quote:


  Originally Posted by *PJPro* /img/forum/go_quote.gif 
_..... a complete kit for something called the OptiVol module (from SKA Audio) can be purchased for less than the cost of the LDRs on the group buy. There may be a good reason for this (different quality LDRs?) so I have asked if anyone would care to comment on the SKA Audio offering._

 

The SKA module only uses LDRs as signal resistors i.e. two. The Lightspeed design uses four (series-shunt).


----------



## linuxworks

an idea I've been thinking of (way in the background) is to try some of these LDR things but have a CPU controller and a non-audio DAC (binary-to-voltage converter) drive the ldr's. the 'thing' about the ldr's, as I understand it, is that they need matching and calibrating. that's a natural thing for a CPU and some lookup tables to do! the trick is, then, to run some calibration on a completed circuit and generate the 'value tables' for the CPU to use. 

 in theory, that totally eliminates the matching hassles or non-linearity of the devices.

 but I have yet to try this, myself. too many other projects still pending.


----------



## PJPro

The guy organising the group buy also offers a matching service, which the vast majority of builders seem to go for.


----------



## linuxworks

my point is that the matching service is a liability. why? suppose one part goes bad. now the whole matched set needs to be junked.

 you also are dependant on 'that guy' to do the matching. not very DIYish if you ask me.

 finally, you can match BETTER if you have computer lookup tables to help do the offsets. you can get better matching than hoping for parts to 'line up' in tolerance.


----------



## PJPro

Quote:


  Originally Posted by *linuxworks* /img/forum/go_quote.gif 
_my point is that the matching service is a liability. why? suppose one part goes bad. now the whole matched set needs to be junked.

 you also are dependant on 'that guy' to do the matching. not very DIYish if you ask me.

 finally, you can match BETTER if you have computer lookup tables to help do the offsets. you can get better matching than hoping for parts to 'line up' in tolerance._

 

OK. Take your point. But aren't builders buying matched sets of stuff all the time e.g. transistors, tubes, etc. Otherwise, you have to buy a rake of stuff to get your one single matched pair? OK, if the lookup tables can do something to reduce/remove "waste", that can only be a good thing.


----------



## linuxworks

anyone at home can easily match transistors. and they're cheap and plentiful.

 the lightspeed thingies are not. that makes all the diff (to me).

 also, matching transistors are usually single value matches (gain or beta levels). no one really matches 'curves' on transistors.

 but that's exactly what is needed with the lightspeed things. they might be slightly non linear in some regions and getting CHANNELS to match is very important as you ride up and down the vol level range.

 a lookup table is THE elegant way to do this. the reason they didn't use them is - they might not know how to design or program the controllers (my guess).

 they certainly are doing things the hard way, if you ask me


----------



## Lifthanger

this idea is awesome. I already loved the SPDIFmaster (no time to do it though 
	

	
	
		
		

		
		
	


	




 ), and this would yield awesome attenuators for little money. 
 Hope you can do it 
	

	
	
		
		

		
		
	


	




.


----------



## DKJones96

All you have to do is set the analog output to 0, sample, write to serial, increase to 1, ect to 255 and just log the results from the serial port and adjust the curve to match what you want and write it to a couple of volume arrays. It isn't that much code.

 MAYBE an hour of work on breadboard and no reason at all you couldn't go from start to finish in one day.

 I'd do it but even though I can hear stuff most people can't I'm still not able to hear the noise everyone seems to complain about in volume pots now so I'm a little unmotivated to say the least. I'm pretty sure they are talking about noise from when you move the volume control but since I don't sit around changing the volume while I listen to music I don't think I will gain much.


----------



## linuxworks

analog out is PWM!

 (doh!)

 analog-in is nice and clean. analog-out is a hack. nice try, though.

 that's why I was planning on some kind of d/a converter so that I could send some 0..1023 (or 0..255) code and get a REAL analog constant voltage out from that. even an R/2R ladder would be fine. something that gives steady clean dc from it (important!).

 then that DC would 'bias' the LDR thingies.

 you'd need 4 dac entities since you need a series and shunt LDR, and double that for stereo. double that for balanced (lol).


----------



## linuxworks

its not the noise in volume pots (there is no noise that I'm aware of) but its channel separation that suffers as you rotate the control away from 0db point.

 the concentric rings on pots creates a capacitive effect and the more you go toward full atten, the more you muffle the stereo. a triangle graph effect is seen in RMAA's on pot-based amps and usually not seen on non-pot versions.

 also, pots are slow to move (even motor ones). sometimes I like to quickly get to a volume level or even use memorized volume levels on a remote.


----------



## DKJones96

PWM shouldn't be an issue. The opto isolators most commonly used have a rise time of .005 seconds and a fall time of .080 seconds. Setting the PWM on the Arduino to 32khz gives you an on-off cycle time of .000031 seconds. That's 161 cycles before the unit can even go from full off to full on. Plenty fast! If you want to smooth it a 1uf cap should be more than adequate.


----------



## linuxworks

I did consider using a cap to create some kind of smoother dc. but think of this: ANY modulation that the variable R sees will directly affect the attenuation. the modulation will come thru, I'm afraid (just a guess).

 what I'm thinking of is a digital pot like the MCP41010 series. control that via the arduino and simply have the ends of the pot be + and ground and the wiper goes to either a buffer (maybe) or directly feeds the LDR.

 that, to me, seems like a much more stable and clean solution. not too many extra parts, either.

 what I don't know, yet, is the linear pot to log mapping that you'd want for vol control. and if the range gets too squeezed due to the log nature and only have 255 slots on the digital pot to select from. maybe 2 pots in a gang, to get more res? don't know. have not tried any of this yet 
	

	
	
		
		

		
		
	


	




 not saying the pwm smoothing won't work at all; but it would not be my first choice.


----------



## DKJones96

Well, I've got a few MCP4261 pots I could play with(256 step, dual wiper, 100k). Wouldn't stop you from having to log all the positions and make a map for an unmatched set but I'm pretty sure that worst case you'll get 100 steps out of it. Maxim even gives you what you need to make a log taper from a linear taper digital pot. Take your readings in the log configuration and make your adjustments accordingly. Not bad for a couple of bucks! Off to make a set with some CDS cells, LEDs, and old metal jack sleeves.

http://ww1.microchip.com/downloads/e...Doc/22059b.pdf


----------



## _atari_

I hope I will find some time next week to get some schematics started.
 I do not think that it is easy to find a solution that is good for anybody.
 So I think my way will got to an modular, stackable approach.
 Currently I have identified some variables that people want to choose or play with:
Single ended vs. balanced
SE<->BAL conversion
Volume control
Buffer?
I think you will have some space on top (so in Z-Direction) - so a stackable approach could give nice effects.

 First thing I will concentrate on is the whole switching thingy. Other things will follow - lets see how it works.

 But to come back to some of your questions:

  Quote:


  Originally Posted by *linuxworks* /img/forum/go_quote.gif 
_I have heard great things about the THAT1646 chip

RCA to XLR? It's THAT (1646) easy! - AVS Forum

 it seems pretty well respected in the pro audio community. yes, its 'a glorified op amp' (sort of) and so the discrete folks will turn up their noses to it. but the rest of us won't be bothered 
	

	
	
		
		

		
		
	


	




 there's also matching bal->unbal converter chips from THAT corp, I think. (the THATcorp guys used to be the old dbx company, I believe)._

 

I will check that out. I have also seen some good reviews about the exotic (for me) SSM2142.

 It will be modular anyway 
	

	
	
		
		

		
		
	


	




  Quote:


  Originally Posted by *linuxworks* /img/forum/go_quote.gif 
_an idea I've been thinking of (way in the background) is to try some of these LDR things but have a CPU controller and a non-audio DAC (binary-to-voltage converter) drive the ldr's. the 'thing' about the ldr's, as I understand it, is that they need matching and calibrating. that's a natural thing for a CPU and some lookup tables to do! the trick is, then, to run some calibration on a completed circuit and generate the 'value tables' for the CPU to use. 

 in theory, that totally eliminates the matching hassles or non-linearity of the devices.

 […]_

 

That is an marvelous idea. You can include this in a boot sequence and have never to bother about this anymore.
 The idea of combining two ADCs or digital resistors is a good idea.

  Quote:


  Originally Posted by *linuxworks* /img/forum/go_quote.gif 
_analog out is PWM!

 (doh!)

 analog-in is nice and clean. analog-out is a hack. nice try, though.

 […]
 you'd need 4 dac entities since you need a series and shunt LDR, and double that for stereo. double that for balanced (lol)._

 

 Quote:


  Originally Posted by *linuxworks* /img/forum/go_quote.gif 
_I did consider using a cap to create some kind of smoother dc. but think of this: ANY modulation that the variable R sees will directly affect the attenuation. the modulation will come thru, I'm afraid (just a guess).

 what I'm thinking of is a digital pot like the MCP41010 series. control that via the arduino and simply have the ends of the pot be + and ground and the wiper goes to either a buffer (maybe) or directly feeds the LDR.

 that, to me, seems like a much more stable and clean solution. not too many extra parts, either.

 what I don't know, yet, is the linear pot to log mapping that you'd want for vol control. and if the range gets too squeezed due to the log nature and only have 255 slots on the digital pot to select from. maybe 2 pots in a gang, to get more res? don't know. have not tried any of this yet 
	

	
	
		
		

		
		
	


	




 not saying the pwm smoothing won't work at all; but it would not be my first choice._

 

I have playing around with getting some steady signal from PWM lately. The only way to get something some real clean signal from PWM is using some kind of butterworth filter. Any RC,RCRC combination still have significant noise.
 I think getting a clean signal from PWM will be very hard. And despite the LDR are perhaps some kind of slow – I suspect it WILL induce noise.

 If you create some kind of circuit to deal with any irregularities – why not use anything cheaper than LDR - like optocouplers or opto transistors or diodes?
 BTW: How about non linearity of LEDs?

 I think a self calibrating solution is positively the best way to go.


----------



## _atari_

To give you an image of the whole system I have drawn an image:




 An Arduino compatible CPU is driving the whole system. It will have plenty of outputs for LEDs and plenty of inputs for buttons, rotary encoders or even analog potentiometers. The decision to base it on Arduino is to make programming as easy as possible. There is plenty of help out there to program it to the specific needs.

 The basic input selection can switch between a number of balanced or single ended inputs. For each input it is configurable if it is balanced or single ended.
 The output can be balanced or single ended – according to your needs.

 To convert between single ended and balanced there will be an an single ended to balanced converter. This module will be plugable in some way so that you can choose the technolgy you like (opamps, discrete or whatever).

 The volume control will be an plugable module too. To enable the use of an chip or LDR.

 If needed a balanced to single ended converter can be attached after the volume control. But most probably this be not part of this design.

 Next step will be to design the switching - which should be easy. Currently I am thinkig about a fixed number of inputs or some bus like approach. The later wuold have the sweet advantage to be more extensible. Any wishes?


----------



## DoYouRight

id love one of these working specially


----------



## _atari_

The basic switching between inputs is most probably the easiest part:





 B1L and B1R is balanced input 1
 S1L and S1R is single ended input 1

 B2L and B2R is balanced input 2
 S2L and S2R is single ended input 2

 OBL & OBR is the balanced output.

 CIS is the single ended input of the single ended to balanced converter
 COBL and COBR are the outputs of the single ended converters

 With the relays K1-K4 you can switch between the two inputs (you need a lot of relays though)

 With the relays K5 & K6 you can choose if the input is going through the Single ended to balanced converter.

 It is of course easy (and will consume a massive amount of relays to enhance this schematics to 4 input channels.

 Next is the control circuit. Since this will be the most interesting part.


----------



## linuxworks

I wonder if some R's (like 10k) would make sense on the relays? that way there is no such thing as a fully 'open' circuit.

 or, I suppose you could engage a mute relay, do an input selection and then unmute.

 then again, if the switching is fast enough, maybe the 'open circuit' problem is not a real life problem. on manual rotary switches, where a user could be 'slow' to turn it, you don't want any open circuits during state transitions; but maybe the relay bank won't need it.


----------



## _atari_

Quote:


  Originally Posted by *linuxworks* /img/forum/go_quote.gif 
_I wonder if some R's (like 10k) would make sense on the relays? that way there is no such thing as a fully 'open' circuit.

 or, I suppose you could engage a mute relay, do an input selection and then unmute.

 then again, if the switching is fast enough, maybe the 'open circuit' problem is not a real life problem. on manual rotary switches, where a user could be 'slow' to turn it, you don't want any open circuits during state transitions; but maybe the relay bank won't need it._

 

You are more than completely right. This is just the basic of switching.
 The 10K resistors are an very import ant & interesting idea to prevent 'open circuits'.

 The relay control is completely out of scope for this phase. I do not know (and will test out) if the chip (cpu or some interface chip) is capable of doing all the switching all by itself or if it needs some kind of H-bridge.

 There will be no muting in the switching circuit. This will be done by the volume control. It will go to mute during switching.


----------



## linuxworks

one thing to think about is the timing on 'make before break' or 'break before make' on the relay switching.

 that's one nice thing about having a cpu there; you can play around with that and not be stuck by some hardware chip that only works 1 way.


----------



## _atari_

Quote:


  Originally Posted by *linuxworks* /img/forum/go_quote.gif 
_one thing to think about is the timing on 'make before break' or 'break before make' on the relay switching.

 that's one nice thing about having a cpu there; you can play around with that and not be stuck by some hardware chip that only works 1 way._

 

You are right.

 I think an bus-like approach is much more promising, easier to control and design. At the expense of some relays.

 So next step will be redoing it in bus style.

 But I am still unsure about the SE->Balanced conversion. But a a very good solution, with the possibility to omit it and hook in your own favorite implementation is a good thing.

 Give me some days and I will come up with an design.


----------



## DKJones96

At the most you just need a simple transistor, diode, resistor setup for the switching of the relays.

 I think the idea of a mute relay is great. With the sensitivity behind some amps and the fact that switching is going to create at least some noise depending on the relays chosen you could end up with some nasty pops. It also keeps as much out of the signal path as possible.

 If, however, you go with some reed relays they could be driven directly by the MCU.


----------



## linuxworks

one of the initial (I think) decisions is: latching vs non-latching relays.

 pros and cons of each approach; but you have to pick this early on and have good reasons for why you went with it.


----------



## _atari_

Quote:


  Originally Posted by *DKJones96* /img/forum/go_quote.gif 
_At the most you just need a simple transistor, diode, resistor setup for the switching of the relays.

 I think the idea of a mute relay is great. With the sensitivity behind some amps and the fact that switching is going to create at least some noise depending on the relays chosen you could end up with some nasty pops. It also keeps as much out of the signal path as possible.

 If, however, you go with some reed relays they could be driven directly by the MCU._

 

I will re do it bus like. So you can hook up (or off) any input from the bus. By that you do not need a muting relay. But you will use more relays anyway 
	

	
	
		
		

		
			




 But the whole thing will go easier.

 The driving circuit is not included yet.

  Quote:


  Originally Posted by *linuxworks* /img/forum/go_quote.gif 
_one of the initial (I think) decisions is: latching vs non-latching relays.

 pros and cons of each approach; but you have to pick this early on and have good reasons for why you went with it._

 

I am planning for using latching relay. You will have only short current pulses and by that you do not have to fear that the digital circuit can affect the analogue circuit that much. Perhaps I will throw in some RC delay to avoid sharp square waves.

 To go better safe than sorry I am planning to implement one super easy H-bridge: Steve Bolt's H-Bridge

 Linuxworks, you have experimented with latching relays - did you encounter some situations that must be taking care of?


----------



## linuxworks

that's a nice little h-bridge 
	

	
	
		
		

		
		
	


	




 that works; or the standard go-to part, l293d. the chip is affordable enough, for me; and a simple drop-in for when you need 2 h-bridges. I use that chip more for motor pot controls (one h-bridge for the main spkrs and one for the subwoofer level, say).

 re: latchers; I tried one approach with an 'enable line' (global to the whole bank of relays) and then a toggle-A and toggle-B line for each. you'd hit the toggle line AND the global enable, hold enable for a short bit and then let it go. that sort of worked the first way I configured it; with 1 8bit port expander and an inverter to keep the 'other side' of the relay always opposite of the single control bit for that relay. it had voltage surge issues that could be solved but I gave up and am now going to try 2 controllers; one bit for each side of the latching relay and no global enable 'line'. it also gives more control over each bit of timing.

 another hint: port expanders and arduinos can put their pins in high-z mode, so you can EITHER keep both relay pins at the same potential (both bits 0 or both bits 1); OR you can do a combo of 01 or 10 to toggle them; then bring one of the lines into high-z (set it as pinMode(input)) and you break the circuit, leaving the relay in the desired state but not drawing any current at all.

 for a better executed solution, you -may- need (or want) to opto-isolate. maybe.

 or use ULN2003 style driver chips.


----------



## glt

Nice project!, may I suggest a straight pass through option bypassing the PGA? Needed if one you of your sources is a DAC with s/w volume control.


----------



## linuxworks

(seems all the aardvarks are coming out of the woodwork for this thread, lol!)

 perhaps an 'extended mute' function would either mute, pass-thru or bypass the vol control element.

 the bypass can be a nice a/b compare switch, as well; in case you want to see the effect of the PGA chip at unity gain.


----------



## _atari_

Quote:


  Originally Posted by *glt* /img/forum/go_quote.gif 
_Nice project!, may I suggest a straight pass through option bypassing the PGA? Needed if one you of your sources is a DAC with s/w volume control._

 

good point - will be included.

  Quote:


  Originally Posted by *linuxworks* /img/forum/go_quote.gif 
_[...]
 perhaps an 'extended mute' function would either mute, pass-thru or bypass the vol control element.

 the bypass can be a nice a/b compare switch, as well; in case you want to see the effect of the PGA chip at unity gain._

 

will be included 
	

	
	
		
		

		
		
	


	




 I think all this is possible. I will schoose some kind of bus/filter approach (as defined in computer sciences). 

 So that you can connect any input to the bus and can send the signal from the bus through a number of filters (e.g. single to balanced or volume control or what ever 
	

	
	
		
		

		
		
	


	




 Will cost a number of relays - but will give better flexibility.

  Quote:


  Originally Posted by *linuxworks* /img/forum/go_quote.gif 
_that's a nice little h-bridge 
	

	
	
		
		

		
		
	


	



 re: latchers; I tried one approach with an 'enable line' (global to the whole bank of relays) and then a toggle-A and toggle-B line for each. you'd hit the toggle line AND the global enable, hold enable for a short bit and then let it go. that sort of worked the first way I configured it; with 1 8bit port expander and an inverter to keep the 'other side' of the relay always opposite of the single control bit for that relay. it had voltage surge issues that could be solved but I gave up and am now going to try 2 controllers; one bit for each side of the latching relay and no global enable 'line'. it also gives more control over each bit of timing.

 another hint: port expanders and arduinos can put their pins in high-z mode, so you can EITHER keep both relay pins at the same potential (both bits 0 or both bits 1); OR you can do a combo of 01 or 10 to toggle them; then bring one of the lines into high-z (set it as pinMode(input)) and you break the circuit, leaving the relay in the desired state but not drawing any current at all.

 for a better executed solution, you -may- need (or want) to opto-isolate. maybe.

 or use ULN2003 style driver chips._

 

I think the H-Bridge is nice - since the number of components are small and easily available.

 Regarding driving the relays I have to come up with an solution - since you do not want to waste too many pins - even with port expanders.


----------



## nullstring

Interesting discussion on LDR's

 I had not heard of those before. 
 I am definitely going to be looking into using one of these for any high profile amps I make down the road. Hopefully linuxworks will have that project in motion by then. If not, I might have to take it on.

 Anyway, why would you be using an audrino to control it?
 I really don't understand the appeal of the device.

 Maybe microcontroller programming is harder than I understand... I've only done a slight bit of PIC programming... and didn't do anything useful.

 I plan on designing an AVR based alarm clock as practice during this year. It seems like the perfect project to get you into the swing of using microcontrollers.


----------



## linuxworks

I played around with the 'basic stamps' as my semi-recent intro to microcontrollers. they were fun and well supported but expensive! I did a BS1 and BS2 program and then lost interest in that system (again, mostly due to cost).

 if the arduino was not 'the thing' to use, I would be using PICs. I never got into PIC and went straight into arduino land. the tools seem nicer (C language as a standard, which I prefer anyway) and there was gcc support as well (for when I wanted to break out of the gui shell). lots of current hardware talk and lots of neat functionality that people prototyped *rapidly*. I was able to get useful things done in less than 1 week and that was due to having a lot of already-done examples that you simply had to integrate. its mostly about integration, really; and then some custom 'glue' code. but a lot of routines and frameworks are already out there and so its a rich library, overall.

 arduino is also a bit more on the 'open source attitude'. I'm not aware of anyone selling arduinos that don't also include the source code, as well. that way you are in charge of your own system and you can over-ride any defaults you don't like. with the PIC culture, I don't quite see that, and 'locked down' chips seem to be the norm.


----------



## nullstring

I was not trying to suggest using PICs or BS's
 In fact, I would very much dislike that....


 I wanted to know why you don't just program the atmel AVR chips directly using GCC-avr, etc.
 there is a very large atmel AVR community, and lots of documentation.

 Maybe I am being ignorant. Maybe the wiring/audrino stuff is more valuable than I know.


----------



## linuxworks

Quote:


  Originally Posted by *nullstring* /img/forum/go_quote.gif 
_I wanted to know why you don't just program the atmel AVR chips directly using GCC-avr, etc.
 there is a very large atmel AVR community, and lots of documentation._

 

but its still not as beginner-friendly as the arduino 'sketch' idea. a lot of grunt work is done for you in the arduino world. and a lot of user programs at the arduino level, too; so the integration aspect again enters into it.


----------



## nullstring

ok, so, basically for the sake of convenience and rapid development the arduino environment is key.
 In the end, you don't really care if you spend extra money to save time, and can get that device in use quicker.

 However, if your arguments hold up (I haven't done much more research than what I've read in this thread), then it seems like this project could become very popular.
 Popular to the point where you might be selling PCB's with a presoldered and preprogrammed chips
 In this case, I hope that you wouldn't still be using arduino =p

 But, maybe the difference is less than I realize. /me shrugs


 I am the type of person who prefers to understand how everything works than to use a frameworks that does everything for me. Therefore, I am going to try to use the AVR directly, but who knows how thats gonna turn out =)


----------



## PJPro

Hmmmm. As a former coder (now manager) I'd be keen to pitch in and help where I can. Wow! DIY Hifi and coding.....this can only be good!


----------



## linuxworks

arduino is source based. cd into the library routine area, edit the file, 'touch' rebuild button in the gui and now you have user edited library code integrated.

 it really is nicely abstracted and MUCH less scary than any other kind of microcontroller (imho).

 one of my goals was to have the source be friendly enough that people who have zero programming background can still make some level of source-code changes, rebuild and redownload and have *their* code run. even basic stamps were not *that* easy.

 there's also a bootloader that's part of the arduino env. it makes development only cost $20 (for a magic usb cable). that's it. quite a low barrier to entry. PIC programmers tend to be $35 and up (casual search). and with arduino, there is really ONE flash programmer (the magic ftdi usb cable). with PIC, they seem to need a variety (sometimes) of flashers.

 PIC is perhaps a good choice for a fully commercial project. but I'm quite convinced that arduino is the right choice for this kind of market (DIY for non-controller people who want to get into controllers).


----------



## linuxworks

Quote:


  Originally Posted by *PJPro* /img/forum/go_quote.gif 
_Hmmmm. As a former coder (now manager) I'd be keen to pitch in and help where I can._

 

we had an inside joke at a previous software company I was at: our boss (who stayed away from coding) would 'threaten' us that if we were getting late on our milestones, he'd *join in* on the coding. that usually scared us enough that we'd make our milestones


----------



## _atari_

Quote:


  Originally Posted by *nullstring* /img/forum/go_quote.gif 
_ok, so, basically for the sake of convenience and rapid development the arduino environment is key.
 In the end, you don't really care if you spend extra money to save time, and can get that device in use quicker.

 [...]

 I am the type of person who prefers to understand how everything works than to use a frameworks that does everything for me. Therefore, I am going to try to use the AVR directly, but who knows how thats gonna turn out =)_

 

That is exactly the point.
 A lot of people on this board have never done micro controller programming before.
 For them arduino is the easiest way to enter the world of microcontrollers and do not fear the complexity. Arduinos are easy and there is a lot of help out there if you get stuck.
 The whole project will be mordular and standardized enough that you can use it with the platform of your choice. No matter if you want to go atmel, PIC, ARM7 or whatever.
 So, the tag 'Arduino' is just to signal the beginners: 'There is no complex stuff here to fear 
	

	
	
		
		

		
		
	


	




 And please. Do not compare the advantages or disadvantages of different platforms here: Use what you want and if you dont have a clue try the Arduino way


----------



## PJPro

Quote:


  Originally Posted by *linuxworks* /img/forum/go_quote.gif 
_we had an inside joke at a previous software company I was at: our boss (who stayed away from coding) would 'threaten' us that if we were getting late on our milestones, he'd *join in* on the coding. that usually scared us enough that we'd make our milestones 
	

	
	
		
		

		
		
	


	


_

 

Oh. 
	

	
	
		
		

		
		
	


	




 So when's your 90% date?


----------



## _atari_

Ok,

 designing the basic switching & filter section was easier than I thought.
 Ok, it is just a bunch of relays. The rest of the circuit will follow:




 (click for larger resolutions)

 B1R/B1L, S1R, S1L is Input 1 (left, right, balanced, single ended)
 B2.. is input 2
 FI1L/R is the input of filter 1
 FO1L/R is the output of filter 1

 K1-K8 are the relay coils. Coils organized in one row will be switched on or of at the same time.

 All input will be hooked on or off from the bus (the blue line). The bus contains all the balanced signals (BL+,BL-,BR+,BR-).

 Between the output and the bus several filters can be switched – here we show only one filter.

 I incorporated some resistors, so that all inputs, not hooked on the bus will be grounded by a 10k resistor to avoid open loop circuits. (thanks for the hint linuxworks). 

 The final version will include 4 inputs and 3 filters.

 The filters (which all will be separate boards) could be:
 - Volume control
 - Single ended Balanced conversion
 - Whatever

 So next to the I2C driver section (the interface to the arduino).


----------



## linuxworks

Quote:


  Originally Posted by *PJPro* /img/forum/go_quote.gif 
_Oh. 
	

	
	
		
		

		
		
	


	




 So when's your 90% date? 
	

	
	
		
		

		
		
	


	


_

 

actually, the source will be released so anyone can jump on it and extend or modify it.

 some early snapshots of source code are here:

http://www.netstuff.org/audio/

 code needs cleaning up (I've created too many ways of doing a lot of the same things) but its how things 'evolved' on their own, sort of


----------



## _atari_

There are updates on this project.

 Thanks to the encouraging help of linuxworks I was able to design the first complete microcontroller oriented input selector:




 This board is intended as an extension for linuxwork's LCDuino.

 The features:
 I2C based control via MCP23008
 all inputs are switched by relays
 all inputs can be either single ended or balanced (singe ended to balanced conversion will come as a different board)
 several board can be combined to get more inputs

 What changed regarding to the prototype:
 usage of non latching relays (easier to source)
 filter selection is gone (will be a different board)

 A first draft of the board is also available. No PCB traces drawn until now. Check the thin yellow lines what goes where (click for high res versions)





 The analog section is on the top part of the board. With some nice ground plane on top and bottom of the board.
 The digital section is completely on the bottom part of the board. Ground plane on bottom, VCC plane on top.

 What do you think?
 Is there anything I have done wrong or I can do better?
 What do you think?


----------



## linuxworks

nice work, atari.

 I see you allow for onboard power supply, for 5v. do you need to allow for a heatsink, maybe? the relays (or one of them) will be always on, so it will have constant current drain. also, for those that already have 5v inside their box, maybe provide a molex header or something where people can bypass the onboard power supply (not install those parts, either) and just run the 'box' 5v into this board?

 similarly, maybe a 5v passthru jack, so that if this board IS the 5v supply 'for the box' then maybe some other circuit needs 5v and can get it from this board?

 I like s1, letting you pick the i2c address of the board 
	

	
	
		
		

		
		
	


	




 I wonder if a chip of transistor-array (uln2003 style) would get rid of all the transistors, diodes and resistors? maybe it makes the layout easier? certainly would make the build go faster and also, the chip would be socketed and if anyone blows the chip, its 10 seconds to replace it. if you blow a transistor, you have to unsolder it. so, a slight serviceability gain if you use the dip chip for relay drive.


----------



## DKJones96

Why so many audio input/output sockets? One 4 pin can take care of the balanced and a 3 pin can do single ended. That would take you from 12 sockets down to only 6 and would make the board easier to work with along with knocking a couple bucks off the build cost.

 I don't see volume control?

 I like the ULN2003 idea. It does get rid of a lot on there. Those have built in diodes and everything making it cheaper yet again.

 What voltage are the relays running?


----------



## linuxworks

his board is relay selection; I don't believe its intended to do volume control.

 other boards and (sub)systems are planned for that (lol).


----------



## DKJones96

Title of the thread threw me off.


----------



## _atari_

linuxworks;6038724 said:
			
		

> nice work, atari.
> 
> Quote:
> 
> ...


----------



## linuxworks

I wonder, if the uln chip is used, can the relays be run from a 12v source (with 12v relays) while the logic is left at 5v?

 I have a LOT of 12v relays from a surplus throw-away (seriously, a few boxes) and while they are not latching, they were free 
	

	
	
		
		

		
		
	


	




 but 12v. so if its possible to allow a 'relay voltage' diff from the logic voltage, that gives a LOT of install flexibility.


----------



## _atari_

Quote:


  Originally Posted by *linuxworks* /img/forum/go_quote.gif 
_I wonder, if the uln chip is used, can the relays be run from a 12v source (with 12v relays) while the logic is left at 5v?

 I have a LOT of 12v relays from a surplus throw-away (seriously, a few boxes) and while they are not latching, they were free 
	

	
	
		
		

		
		
	


	




 but 12v. so if its possible to allow a 'relay voltage' diff from the logic voltage, that gives a LOT of install flexibility._

 

Will give you that option (and yes, I think thats what ULNs are designed for – at least what I understand).

 Yeehaw - more connectors!


----------



## DKJones96

Yes they can be run on 12v. I used ULN2801 chips(same thing as a 2003 but it has 8 I/O instead of 7) for the steppers on my lathe which run 48v@450ma while the control board runs 5v.

 Just remember that GND on the 2003 is common ground for both the relays and the control, the common freewheel(pin 9) goes to the input voltage for the relay coils, and the relays ground through the array.

 You don't really need the connectorr. Just have the relays always run input voltage and put a jumper to bypass the regulator if they decide to run 5v. 2.54mm jumper holes means any header strip can be put there and standard computer jumpers can be used.

 Not sure about others that put together systems like this but I try to design all mine to run either the same voltage throughout or locally regulate the oddball. The input control for my car runs the switching relays straight from the 14v input and I just regulate for the cell charger and the Arduino control. For this I'd probably run 5v throughout since I normally have to order my relays and the LCD, Arduino, volume control chips, and relays can all operate on it and 1 amp 5v cell charger wall warts are a dime a dozen.


----------



## linuxworks

the only reason I mention allowing for non-5v relays is that sometimes you can find deals on those telco relays but at whatever happens to be available at the time, for voltage.

 if the flexibility to allow for a relay-voltage and a cpu-voltage being possibly different isn't too hard to accomplish, then that's useful build-ability for the real-world and its worth it


----------



## DKJones96

I don't disagree at all and that was pretty much what I was getting at. Were you thinking two voltage inputs? If that's the case it works too and you wouldn't need the regulator at all. Especially with stuff like this around.

12V+5V AC Adapter Power Supply HDD HARD DISK DRIVE IDE - eBay (item 280397197519 end time Oct-13-09 19:51:46 PDT)

 Hack the end off and put a 3-pin xlr connector on it.


----------



## _atari_

The input selection section is mainly finished:
 Schematics:



 Board:




 Changes to the early version:
Usage of ULN2003 to drive the relays
Using latching relays - since they are easily available
Optimized board layout
External connector for power – either 5V output or relay power (see EXT connector)

 What is still open:
Usage of combined headers for balanced input and output (probably not for the inputs - since they are more or less directly from the input connectors)
Grounding strategy (star like vs separate grounds)
The board is still a bit too big - perhaps it can be done a bit smaller
avoiding open circuit problem.

 So I have two questions:
 Is the analog grounding OK? Or should I remove all grounds from the analog connectors and have a single ground connector for a star like grounding scheme?
 How should the open circuit problem. Put some resistors to AGND in the audio bus? Switch some resistors to AGND when no input is selected?
 Currently I am planning to solve this problem with the volume control.


----------



## DKJones96

Isn't latched vs normal relay a software change and not a hardware change? 

 You either pulse the output or have a constant on/off.


----------



## linuxworks

latching relays need both sw and hw help.

 background for those that have not used these before: latching relays (single coil type) need a short pulse of current in one direction to latch them one way; then you remove the current. keeping the current won't help and only heats up the part.

 to change to the other relay position, reverse + and - supply to the relay, pulse it and then remove power.

 or, equiv to 'remove power' is to bias both leads at the same level. if you have a logic '1' going to one wire and a logic '0' to another, that creates a voltage diff (hopefully enough to latch) and then you can either send both 'wires' a 0 or both wires a 1. that will cause 0 voltage to flow across the coil, a good thing.

 even better, some controllers can go into 'high z' state and remove themselves from the connection, entirely. in that case, you only need to 'high z' one of the wires to fully break the circuit.

 hardware wise, the diodes are more tricky since its dual polarity to toggle the relay. 2 'outputs' of buffers go to the 2 relay wires and one buffer should be at opposite voltage from the other.

 also, a software thing about timing: you MAY want to have control over the 2 legs of the relay and how much time is spent in writing the 1 to the first wire, keep holding it, then write a 0 to the other wire, keep it for a 'hold time' to let it latch' and then undo one of the wires (break its connection) after some more delay. all those delays should be software configurable (on a multibank relay system). on simple systems, you may not need all those timing details settable.

 latched relays are a PITA to deal with, but they have memory (so that once you set them, they hold their state until told to change; even across reboots) and they also need no 'holding' power once latched. this saves a LOT on power supply heat.


----------



## _atari_

And latching relays are harder to get locally 
	

	
	
		
		

		
		
	


	



 What is a pitty.

 As linuxworks states (very well explained – better than I could do) they are a bit trickier software wise but consume less power. Less danger of interference and so on.


----------



## DKJones96

It saves a lot of power but I don't think we need to worry about that since these will likely be used with B22s and tube hybrids. Not exactly the most efficient of amplifiers.

 Holding across reboots isn't going to help much unless you write the current mode to something other than ram in the MCU. Otherwise it'll have to reset all the latched relays to a programmed default when power is applied since it'll have no idea where the relays are otherwise.


----------



## luvdunhill

Quote:


  Originally Posted by *DKJones96* /img/forum/go_quote.gif 
_It saves a lot of power but I don't think we need to worry about that since these will likely be used with B22s and tube hybrids. Not exactly the most efficient of amplifiers_

 

If it means you can use a PCB mount transformer, I'd say it's worth it. I doubt people will run this off the main amplifier PSU, so some sort of auxiliary transformer winding will be needed. Given some of the space constrained builds I see around here, I think it's a good idea.


----------



## linuxworks

Quote:


  Originally Posted by *DKJones96* /img/forum/go_quote.gif 
_It saves a lot of power but I don't think we need to worry about that since these will likely be used with B22s and tube hybrids. Not exactly the most efficient of amplifiers._

 

why assume any kind of amp? this could be in a preamp box on its own.

 regardless of how heat-generating the amp is, that's still not a good reason to waste heat in a relay. it makes the 5v supply need to be stronger than it should be.


  Quote:


 Holding across reboots isn't going to help much unless you write the current mode to something other than ram in the MCU. 
 

huh? the mcu has eeprom and I've saved settings there before (last volume setting for the various inputs, the input last selected, power on/off status, etc.)

 but regardless, the relays will hold the last setting and so when you power on again, even the cpu does not have to engage unless you want to CHANGE something.

  Quote:


 Otherwise it'll have to reset all the latched relays to a programmed default when power is applied since it'll have no idea where the relays are otherwise. 
 

true that you can't sense the current position of the relays; but they won't change on their own and so the last 'management change' IS the last change status of the relays.


----------



## _atari_

Regarding the relay power:

 I am a big fan of latching relays (linuxworks has explained the advantages very good). But in comparison to the fact that they are really hard to get (mouser has some) and that we are talking about 40mA of current in total (2 relays are on and each consumes 20mA) – I think it is bearable to use the less efficient relays.


----------



## luvdunhill

what about using Vactrol or Silonex LDRs as switches? Also, there are a few commercial attenuators that use reed relays.


----------



## _atari_

Quote:


  Originally Posted by *luvdunhill* /img/forum/go_quote.gif 
_what about using Vactrol or Silonex LDRs as switches? Also, there are a few commercial attenuators that use reed relays._

 

The relays are just for switching. For attenuation a PGA4311 will be used. But that is on a different board, so that you can use anything you want.


----------



## luvdunhill

Quote:


  Originally Posted by *_atari_* /img/forum/go_quote.gif 
_The relays are just for switching._

 

sure, the question still stands though


----------



## _atari_

Ok,

 now I got it right. Hmm - that is an interesting idea. Are those LDRs in light proof cases? Because you will have a lot of them in parallel. How high is the off-resistance and is it enough to not influence other input signals?
 I think LDR-base attenuators are a good idea. But I am lacking expereince with them. And there could potentially arise a lot of problems due to heat, input signal strength and so on.
 It is enough work to get the whole setup up and working. I will concentrate on this first.
 If this is done I could think about an LDR based attenuator.
 That is the whole idea of making it modular - you can change any of the components of the preamp for the component you like most.
 My budget on time/money/knowledge or personal taste is perhaps not enough for anybody. So I want to leave it open how to implement better methods.
 Your idea is very interesting - I do not want to say it is bad. But I do not think I will - currently - find time tinker around with that too.
 Or did I get you completely wrong?


----------



## luvdunhill

Quote:


  Originally Posted by *_atari_* /img/forum/go_quote.gif 
_Ok,

 now I got it right. Hmm - that is an interesting idea. Are those LDRs in light proof cases?_

 

I'm assuming we're talking about using them as switches now?

 Here's one part:

http://www.alliedelec.com/Images/Pro...es_6993010.pdf


----------



## _atari_

I am still concerned about their switch off voltage. according to datasheet this is 2K
 If we assume something like 1k for input impedance of the amp - this enhances the inut impedance for one signal from 1 to 3k.
 I am concerned about crosstalk between channels
 I do not want to ground one channel - is this nice to the input stage??
 Lot of questions


----------



## linuxworks

my gut feeling is that ldr's wont be high enough resistance to offer true isolation between input selector channels.

 I tested one that I got at a local surplus store. this is the plot I saw:


 25ohms @12v
 .
 .
 .
 130 @5v
 200 @4v
 460 @3v
 1.7k @2v
 100k @1v
 inf at 0v

 I'd have to check what exactly 'inf' means (very high; but how high, really?).

 also, the 'closure' resistance isn't nearly close enough to zero to be a good input switch part (at 5v, though).

 and the ldrs aren't that small. you could fit several relays (omron latchers) in the same size as a single sealed ldr module.

 but its possibly worth TRYING, at least 
	

	
	
		
		

		
		
	


	




 who knows, maybe this is good enough for input switching. and its solid state, too, so no parts to bounce or wear out.


----------



## _atari_

But real solid state multiplexers & switches are so darn tempting.

 Anyway.

 I did some reconsideration:
TO220 regulators are real overkills for 100mA - going back to TO92 (should be enough for the 60mA or so.
Pansonic TQ relay are easily availlaible via mouser and smaller and come in latching and they are smaller.

 So back to square one - expects updates at the weekend. This time with PGA4311 volume control (except above points) nearly finished.


----------



## luvdunhill

Well, I'm just throwing some ideas for you guys to think about out there. I've done my own circuits and research and come to my own conclusions. In this case, I've used LDRs as switches.

 Also, I've had my nose in enough commercial gear that making some recommendations puts me in a strange position. For example, what about using CMOS FET switches, both Analog Devices and Siliconix make suitable parts, and there are at least two high end audio vendors doing this.


----------



## luvdunhill

Quote:


  Originally Posted by *linuxworks* /img/forum/go_quote.gif 
_and the ldrs aren't that small. you could fit several relays (omron latchers) in the same size as a single sealed ldr module_

 

huh? They are around 6mm x 6mm, see above datasheet.


----------



## _atari_

As stated above - I have been tempted doing this. Since they are used for test and measurement equipment - so why should the be bad for audio?
 Do you have any recommendation.
 Thanks for your ideas.
 I am really thinking about doing an LDR base attenuator later - after this project. It sounds interesting.
 But exactly the personal opinion and preferences are the reason why I want to make it modular.
 Its all about choices


----------



## _atari_

Over the weekend I had some time to tinker with the layouts again.
 The input selector was too big for me, so I change some things:
Using Panasonic TQ4Y latching relays – they are smaller than the Omrons and latching (so less power consumption)
removing the possibility to externally power the Relays or get power from the voltage regulator.
Changing the voltage regulator 7805L in TO92 package - should be able to provide something like 100mA of power. The circuit will need a constant power of something like 10-20mA.
Complete redesign of the board
Without further ado, here it is:
 Schematics



 Board




 I also found some time to start the PGA4311 based volume control:




 Very straight forward:
 One Input & Output (balanced), an SPI connector for programming of the PGA 4311, some capacitors & regulators for power.

 A preliminary board design looks like:




 Still some beauty work to do:
Checking & optimizing the ground & power planes
checking the wiring (especially wire paths & crosses)

 Both designs will not draw very much power - so I think it is bearable to use solely film capacitors (with capacitance under 10µF) - what do you think?


----------



## jtostenr

Very nice design 
	

	
	
		
		

		
		
	


	




 How difficult would it be to include a switchable input attenuator on the selector board? Shouldn't add very many components or increase size much.


 Also, what are the dimensions of the board? Max component height?

 Jeff


----------



## _atari_

Quote:


  Originally Posted by *jtostenr* /img/forum/go_quote.gif 
_Very nice design 
	

	
	
		
		

		
		
	


	




 How difficult would it be to include a switchable input attenuator on the selector board? Shouldn't add very many components or increase size much._

 

The input attenuator is designed as a separate board, since some people will not like the PGA4311. It would add a lot of hassle to add it to the board (due to layout) - so I think a separate board is ok (for me).
 If you look for a stepped attenuator check Twisted Pear's Joshua Tree attenuator.

  Quote:


  Originally Posted by *jtostenr* /img/forum/go_quote.gif 
_Also, what are the dimensions of the board? Max component height?

 Jeff_

 

The height of the boards is about 2.2 inch. The width of the input selector is roughly 4.2 inch.
 The maximum component height is defined by the plugs & capacitors. I think something like 1cm (~0,4 inch) - perhaps a bit more. You should be able to use horizontal connectors if you have more space horizontally than vertically.

 Did this answer your questions?


----------



## luvdunhill

I personally prefer putting the input connectors on the board itself. Yes, it increases cost of the board and limits the connectors that can be used (though you could always wire the connectors), but I think it's a huge convenience.


----------



## _atari_

Quote:


  Originally Posted by *luvdunhill* /img/forum/go_quote.gif 
_I personally prefer putting the input connectors on the board itself. Yes, it increases cost of the board and limits the connectors that can be used (though you could always wire the connectors), but I think it's a huge convenience._

 

You are right.

 But I prefer to mount the connectors to the chassis (gives a much more sturdy look) and it gives a bit more flexibility and makes the board size smaller.






 If anything is finished I will post the eagle files anyway - so if you do not like any of my design decision (or should iI say compromises) feel free to change it.

 Hope that it is OK for you.


----------



## jtostenr

Quote:


  Originally Posted by *_atari_* /img/forum/go_quote.gif 
_The input attenuator is designed as a separate board, since some people will not like the PGA4311. It would add a lot of hassle to add it to the board (due to layout) - so I think a separate board is ok (for me).
 If you look for a stepped attenuator check Twisted Pear's Joshua Tree attenuator.


 The height of the boards is about 2.2 inch. The width of the input selector is roughly 4.2 inch.
 The maximum component height is defined by the plugs & capacitors. I think something like 1cm (~0,4 inch) - perhaps a bit more. You should be able to use horizontal connectors if you have more space horizontally than vertically.

 Did this answer your questions?_

 


 Yep, thanks!


----------



## glt

Now that the attenuator is in a different board, it seems the passthrough connectors are the same as the other connectors. Now, how do we bypass the attenuator? (some inputs have built in volume control and others would require the attenuator)

 Nice design!


----------



## _atari_

Quote:


  Originally Posted by *glt* /img/forum/go_quote.gif 
_Now that the attenuator is in a different board, it seems the passthrough connectors are the same as the other connectors. Now, how do we bypass the attenuator? (some inputs have built in volume control and others would require the attenuator)

 Nice design!_

 

The design is becoming to be nice - it is not as nice yet, as I want it to be.

 I have rethought the bypass problem several times. I think the easiest approach would be either a protection board (which acts as bypass) and has input protection capacitors on it. Or a single bypass board.

 I have left it out for the attenuator to make the design even more flexible.

 What do you think?


----------



## glt

Here is a simple way to configure:

 All inputs are the same in the input selector board (ISB)

 ISB1 is used to connect all the sources with no volume control
 The output of ISB1 connects to attenuator board. The output of attenuator board connects to ISB2, other sources with volume control also connect to ISB2. Output of ISB2 connect to amp

 Thus no changes to your design


----------



## glt

I couldn't figure out how many I2C addresses will the board support, but 2 minimum for the "ladder" configuration I proposed


----------



## _atari_

The 3 address pins enable the use of 8 devices on one I2C line. That should be enough before you have to get 'creative'.


----------



## glt

Yeah 3 bits is plenty for addresses. Another observation to the attenuator board is that other designs use optoisolators for the digital control (not sure if it makes any real difference, but it is a cheap addition)


----------



## _atari_

No problem if all digital components share the same ground and are driven by 5 volt. Opto isolators are definitvely protecting the inputs.
 On the other hand - it is a very controlled environment.
 I will consider this - but dont be astonished if I reject it. Never had problems that called for opto isolators.
 It has its points if you are using switches
 Dont know yet


----------



## glt

I think some people worry about noise from the micro processor noise leaking into the volume attenuator, not so much level translation or input protection. The PGA chips have special gnd plane layout recommendations in order to avoid digital noise in the digital gnd contaminating analog gnd


----------



## linuxworks

it would be nice to have a nice 'same vs same' compare of using opto isolators vs leaving them out.

 the protos I've built never had the optos and I'd love to know if they help and under what situations they help.

 they seem like a good design choice but are they strictly *necessary* ?

 perhaps if you totally (really really) isolate the 5v digital and analog grounds, then optos would be mandatory. but on common ground configs, I'm not sure optos help, to be honest. experimental data is needed, I think, to prove it one way or another.

 another question: does anyone know if digital ground HAS to be tied to analog ground? I have not tried it (yet) but its on my TODO list.


----------



## _atari_

I do not think it is necessary to use opto isolators. 
 You could use independent digital voltage supplies for the micro and the switching circuit. But I do not see the point in this. Since you will most probably have only on digital supply anyway - else you would need several transformers and I do not see any improvement in that.

 But I suggest tie analog and digital ground together. You could omit it. The relays isolate it well enough. But there was recently a very interesting blog posting about floating grounds and their misbehavement:

My 2ÂµF » Floating voltages and bad GND connections — getting zapped and worse


----------



## _atari_

As prelimnary last board I present the single ended to balanced converter.
 It is based on the DRV134 chip by TI. The schematic is very simple and more or less directly from the datasheet. Add a relay to circumvent the conversion for balanced signals, add an ATiny13 to control the relays (it will have a special firmware which does nothing else than ensuring that the relays are set to bypass the converter if the SE pin is low.



 The board is again 2.2 inches high and as straight forward as the schematics:




 This time I really need your help - since I am more familiar with digital circuits than analog ones. Is there anything I can do better (probably much)?
 Are there big mistakes?

 Thanks


----------



## jtostenr

Any updates atari?


----------



## linuxworks

fwiw, I've been using a PGA23xx chip 'behind' an i2c port expander chip for the past few weeks. seems to work and does not do bad things to the bus (lcd and other things still work).

 so, I do suggest having whatever vol control chip you are using be behind a PE chip of some kind. I'm using a philips style PCF8574 and that seems to be cheap, easy to use and fast enough to do volume ramp/fades. I'm just bit-banging the SPI lines over i2c protocol. very very inefficient but its so simple and it works just fine.

Index of /arduino_libs/pga23xx is where a snapshot of my code is.

 you can run the PGA chip directly from the arduino:

 #ifdef USE_PGA_SPI
 ...

 or you can run it from 'behind' an i2c chip:

 #ifdef USE_PGA_I2C
 ...

 the code is a bit rough but it does seem to work in both local and remote configs.


----------



## jtostenr

Can't wait till all these Arduino based projects are ready for the masses 
	

	
	
		
		

		
		
	


	




 Definitely lots of cool stuff going on.

 Jeff


----------



## _atari_

To keep you updated:

 The boards are ordered (change some little details). So expect some nice action shots next week or one week later.

 LCDuino is laying at home, waiting for a task. I need my preamp, missing my music.

 Case is designed and planned but not ordered yet.

 So in the next future there will be a bunch of updates.


----------



## luvdunhill

Quote:


  Originally Posted by *linuxworks* /img/forum/go_quote.gif 
_so, I do suggest having whatever vol control chip you are using be behind a PE chip of some kind._

 

heh, a little comment happy 
	

	
	
		
		

		
		
	


	




 SPI_write(left /*<< 1*/); // left value (0..255)

 I've never been a fan of K&R style formatting.. just too inconsistant for me... thus, much more of a 1TBS guy myself. 
	

	
	
		
		

		
		
	


	




 Ah, the joys of _tidy_ though, one second it's K&R and the next second its beautiful.


----------



## linuxworks

just to explain: I first was saving the volume in 'full db' steps (which ends up being 0..127 as a range and then shifting over to the left 1-bit to make it 0..255 before sending out to the pga chip).

 last week I added a new feature to let users pick if they wanted half or full db steps. and so until I was sure things worked, I commented out various parts and left them that way (reminder) should I need to undo this fix.

 anyway, that's why there was a left shift there. if you count in half db, each up-vol event adds 1 and each full db event increments by 2. no shifting is done (anymore) at the final output stages.

 fwiw


----------



## amb

Quote:


  Originally Posted by *luvdunhill* /img/forum/go_quote.gif 
_I've never been a fan of K&R style formatting.._

 

lol, for me it's the other way around.
 I am actually quite pedantic about this. If it's C code, I use _only_ K&R stylc commenting. If it's C++, then I use the double slash. gcc doesn't care, but years of cross-platform code development has taught me that not all compilers are so tolerant, so I don't mix things.


----------



## luvdunhill

Quote:


  Originally Posted by *amb* /img/forum/go_quote.gif 
_lol, for me it's the other way around.
 I am actually quite pedantic about this. If it's C code, I use only K&R stylc commenting. If it's C++, then I use the double slash. gcc doesn't care, but years of cross-platform code development has taught me that not all compilers are so tolerant, so I don't mix things._

 

I wasn't referring as much to the commenting (which I agree 100% with you on), as the brace convention


----------



## linuxworks

the brace style is also FORCED by the arduino ide/guii ;(

 if you do a reformat inside the gui, it doesn't just fix indents, it changes other things! which I don't agree with..

 I have .emacs settings that I've used for years. when I need to clean up the formating (mostly spacing) I exit the gui, pull all the files into emacs, do an indent there, save and then re-start the main IDE again. I only do that when things change a lot (not very often).

 someday I'll setup a command line build environ; but most users will use the gui and so I should also do the same thing they do, for better testing if nothing else.


----------



## linuxworks

as for KR vs ansi, I do prefer ansi style indenting.

 when I try things like:

 if (a) {
 a1();
 } else {
 a2();
 }

 which I consider nice and concise, the IDE gui messes it up and breaks my single-line else into 2 lines!

 so there is no KR or ansi about it; its an arduino thing. sadly, the arduino guys felt that some reformating should be part of their re-indent command.


----------



## luvdunhill

Quote:


  Originally Posted by *linuxworks* /img/forum/go_quote.gif 
_someday I'll setup a command line build environ; but most users will use the gui and so I should also do the same thing they do, for better testing if nothing else._

 

in fact, I just did that last night.. Agreed, the Java Arduino IDE is pretty pseudo. Anyways, not really all that painful of a process really, just sorta worked.


----------



## linuxworks

did you setup a windows or linux environ?

 and so, you can now just type make and get a .hex file?


----------



## amb

Hmm, ok, here were no braces in the code snippet above... Anyway, I used to work on Unix kernel source code which (from Bell Labs/AT&T/USL) were strictly K&R style and with one tabstop per indentation level, and it stuck with me for my own work. OTOH, when I work on someone else's code I use whatever convention is aleady there. My peeve is when there is _no_ convention. Such as mix use of tabs and spaces for indentations, inconsistent indentation spacing, mixed use of braces styles, etc... argh!


----------



## luvdunhill

Quote:


  Originally Posted by *amb* /img/forum/go_quote.gif 
_ mixed use of braces styles, etc... argh! 
	

	
	
		
		

		
		
	


	


_

 

K&R is a mixed brace style. 1TBS is the true religion 
	

	
	
		
		

		
		
	


	




Indent style - Wikipedia, the free encyclopedia

 I set it up in cygwin. Here's the make file I modified:

http://www.arduino.cc/en/uploads/Hacking/Makefile

 There's even a "upload" target.

 Also, check this one out:

http://arkku.com/misc/arduino_make.sh


----------



## amb

Quote:


  Originally Posted by *luvdunhill* /img/forum/go_quote.gif 
_K&R is a mixed brace style. 1TBS is the true religion 
	

	
	
		
		

		
		
	


	




Indent style - Wikipedia, the free encyclopedia_

 

Point well taken!


----------



## srserl

Quote:


  Originally Posted by *linuxworks* /img/forum/go_quote.gif 
_...so until I was sure things worked, I commented out various parts and left them that way (reminder) should I need to undo this fix.
 fwiw 
	

	
	
		
		

		
		
	


	



 ..._

 

They have this new-fangled software out now that takes care of this for you...I think it is called source code control software 
	

	
	
		
		

		
		
	


	




. I have all of your web-available versions in Subversion so I can keep track of the changes you are making.

 As for style, I abandoned the arduino sketch environment almost immediately because I can't stand K&R formatting. Even though K&R was the way I learned C back in 1982, I branch volumaster and reformat to ANSI for my working copy. I am currently using kdevelop for editing.


----------



## MaxW

Sorry to bump an old thread but did anything become of this?
  Just curious as I've designed pretty much the same thing, got PCBs and just waiting for some components to test it out....I'll use an Arduino too.


----------



## _atari_

Yes and no.
   
  All PCBs are finished and ready to run. I still have not begun to program the whole thing - but that should not be the problem.
   
  Unfortunately I have managed to totally, really totally mess up the power supply. This hinders any real advantage. I think I will come back to this project in fall.
   
  If anybody is interested to test the outcome, feel free to send me a message.


----------



## MaxW

Well for what its worth here is my design, still waiting for some DIP switches to arrive (for setting the I2C addresses) but I've tested it and it works really well! I'll have a few spare PCBs if anyone is interested.


----------



## ua100k

hi,
   
  Did you get everything working? Do you still have some PCB and the design. There is another thread in the DIY starting with from scratch with this project. 
   
  I am new to DIY. Where do you order the boards from? If you have some extra, I would like to build this. Thanks.


----------



## MaxW

Quote: 





ua100k said:


> hi,
> 
> Did you get everything working? Do you still have some PCB and the design. There is another thread in the DIY starting with from scratch with this project.
> 
> I am new to DIY. Where do you order the boards from? If you have some extra, I would like to build this. Thanks.


 

 Yep it all works, I'm just waiting to finish some case work. Yes I have PCBs if you would like some or parts, just PM me. I ordered the boards from seeedstudio.


----------

