## Sunday, 10 April 2016

### Surround Sound Switch #4: Group Theory (toggle switches)

 These little toggle switches seem worried about something
Previously:
Mother Of all Relay Boxes
Bulgaria (rotary switches)
To avoid excess mechanical wear caused by sliding contacts, we can switch our switch variety, from rotary to toggle. But then we hit another problem. Ever tried to source an affordable, five amp, 7 or 8 pole toggle switch with good contact resistance linearity?

Let's just see if we really need all those ganged circuits. When switching the sound stage orientation through 45°, say clockwise from North to North East, each pole has to hand off its input signal to the next sequential output contact along the wall. All eight outputs have to work together in harmony to achieve this. But when switching through 90°, say from North to East, the 8-way permutation can be decomposed into two independent 4-way ones. Think of it this way: when rotating through 90°, every corner signal goes to the next corner along, and similarly for every wall-centred signal. Beginning to sense some wiggle room here?

Here Comes The Science

Mathematically, we can represent the original 45° turn by the permutation
1 → 2 → 3 → 4 → 5 → 6 → 7 → 8 → 1
where the numbers 1 through 8 represent the speaker signals, numbered as usual starting from "1" behind your left ear, then counting round from left to right in front of you, and ending with "8" directly behind your head. The permutation moves each signal to the next position along in the list, while 8 completes the circular trip by moving into position 1. This is conventionally expressed in a more succinct "cycle" notation:
(12345678)
The cycle can't be broken down into two or more shorter sub-cycles, which is why a full 8 pole switch (well okay, 7 pole with an additional "null" signal) is required to implement it. Yeah, we could use two 4-pole switches, but there'd be potential for a transient error, when one switch is temporarily up while the other is down; then one of two bad things can happen. Either (a) an amplifier output signal connects simultaneously to two separate speakers; suddenly, that one particular 8Ω amplifier output is staring down a 4Ω load, and likely none too pleased about it. Or (b) two separate amplifier outputs get shorted together. That can be still worse news.

I'll talk about wiring layouts later. For now, I'll just note that the convention I follow in these prototypes (basically, inputs go to switch commons) leads to the more dangerous of these two possibilities, if we use a 45° turn. Also remember that in this context, common refers to the pole of a switch or relay, and not to the common negatives on the amplifier output or loudspeaker connecting wires - all of which are assumed to be permanently connected together, and otherwise go unmentioned in this series.

 90° clockwise twist from two 4PDT switches
Now contrast the 45° case with the permutation for a 90° turn,
1 → 3 → 5 → 7 → 1
2 → 4 → 6 → 8 → 2
or again in the more succinct conventional notation of mathematical permutations,
(1357) (2468)
Here, the corner speakers - the odd numbered ones - are permuted among themselves, and similarly for the even numbered, wall-centred ones. The two groups don't interact. This means the two-switch solution described above can work safely here, if we're willing to sacrifice 45° rotations and use only multiples of 90°. And to be honest, the steadily increasing size of display surfaces these days, both monitors and projector screens, has pushed the milieu of the corner TV unit firmly into the past. I'm fine with 90° increments for now (though I will be returning to 45° before the end of this series).

On the subject of having to flick two independent toggle switches to achieve a particular rotation, and the fact that intermediate, one-up-one-down configurations have no useful purpose, I say meh. We've all seen cases in the field where toggle switches have been physically ganged together with mechanical clamps; go ahead and do that, if the two-switch-operation thing bugs you. I'll be happy with a line joining the two switches notionally, engraved on top of the grey ABS box lid, filled in with my favourite black crayon.

Are You Cereal? (a short diversion)
Shut up.
I did not design and build a binary clock in the 1970s.
You designed and built a binary clock in the 1970s.

Hey, if it's good enough for Wil Wheaton... listen, having to set up your sound stage rotator by encoding binary numbers into toggle switches is a perfectly respectable thing for any nerd to do. In fact imma aggravate your disapproval, by labelling the switches with abstract symbols. Let's see, we'll use a square for the one that cycles the four corner speakers through 90°, and a diamond for the four wall-centric ones. Also, that was a BCD clock, not a binary one. Sheesh.
And, we're back in the room. Two of those 4-pole switch pairs wired in cascade give us a 180° rotation, and three pairs 270°. But we can be more economical. Consider implementing the 180° case on its own. We can rotate the room through 180° by four independent but simultaneous pairwise swaps. The associated permutation can be written as:
(15) (37) (26) (48)
 180° twist from two 4PDT switches (or four DPDTs)
These 2-cycles could be implemented with just four DPDT toggles. But since we already assume the availability of 4PDT switches, we might be better off with another couple of those instead. So now we have one pair of switches capable of providing a 90° rotation, and another pair providing 180°. We need new symbols for the two new switches. How about a big plus sign for the one that swaps North with South and East with West, and an X to swap NE with SW and NW with SE.

Now for The Big Reveal: we can cascade these two solutions. When both switch pairs are operated, the 90° and the 180°, then voila, hey presto and alta vista, the composite permutation yields the missing 270° rotation!

 A reminder of Mode 5

So far we have been splicing together our emerging 4- and 2-cycles in arbitrary order, without a care in the world. That's okay, because these permutations represent rotations in a 2D plane, and such transformations are commutative (the same can't be said about 3D rotations - try rotating your teacup 90º about a horizontal and then a vertical axis (careful!), noting its final orientation; then, return to the starting position and apply the two rotations in the opposite order - the results are different).

Taking this idea further, suppose we decide to ignore the crossed-signals danger, and implement a 45° turn using two 4PDT toggle switches after all. This is something I'll actually be doing in a later prototype, but using 4PDT electromechanical relays instead of manual toggle switches, so the danger of damage can mitigated (for example by wiring the two ganged relay coils in series, so if either one fails open-circuit, neither will operate on its own). With this new stage in place, we now have three switch pairs, implementing their respective 180°, 90° and 45° rotations, which can be cascaded in any order to provide all eight compass points.

 Mode 5 switch
A Prepended Bend

There's one last twist I'd like to add to this prototype, and this one's not a 2D rotation. It's the "Pure 5.x" mod mentioned at the end of the previous article, whereby the (in this case silent) SBL/SBR signals are dropped, and replaced by the SL/SR signals, in order to stretch the five channel mix across the whole available room space. We can see this isn't a rotation, because signal #2 moves counterclockwise by 45°, while signal #6 moves clockwise by the same angle. In fact, it's not even a permutation; the dropped SBL/SBR signals aren't rerouted to anywhere (though since they're presumed silent, it could in fact be implemented using two partially redundant swaps).

The effect can be achieved with the help of just one more 4PDT switch, but to get the desired results, this new circuit must be the first transformation applied to the amplifier outputs (it doesn't commute with the 2D rotations). After that, we're free once more to apply the rotation stages in any order, and the net room rotation will be applied correctly to the new 5.x configuration. Can't think of a suitable abstract symbol for this operation, so I'll maybe just label the two switch positions 5 (normally open) and 7 (normally closed).

Another example of a non-commutative transformation is the permutation that swaps left and right:
(35) (26) (17)
Harder to make a case for this one, as any permutation that swaps your left and right ears, while leaving you facing the same direction, also has the unfortunate side effect of turning you upside down. But if your particular school of yoga demands it, you may note that this swap does commute with the 5.x, so these two can be performed in either order, prior to the rotations.

 Full cascade wiring diagram with nerd-appropriate switch function indicator symbols
Altogether Now

So here's the full cascade in a single composite circuit diagram. Seven correctly colour coded amplifier signals come in along the top row. These are fed successively through (1) a Mode 5 switch; (2) a 180° rotator (notice the optimization of the + branch, which has freed one whole SPDT stage); and finally (3) a 90° clockwise rotator. Eight speaker driver signals emerge at the bottom, where the illustrated colour coding assumes that all switches are left in their default positions.

With all the switch contacts in their default positions, note that no two wires of different colours ever touch. This is electrically obvious; it's only when one or more switches get operated, that the interchanging of signal paths can begin. For example, there is a complete, isolated path of brown wire running all the way from input 1 to output 1, blue wire from 2 to 2, and so on. But when the 7/5 switch is operated, input 1 gets disconnected, and input 2 (blue) joins the remainder of input 1's previous path (brown).

I mentioned wiring layout practices earlier. This diagram follows the convention, started with the 7P8T rotary switch built last time, that incoming signals go to switch commons, and outputs are taken from other contacts. Note however that all three component diagrams above have the same colour sequence top and bottom. Any/all of these could be rewired to move the switch commons from top to bottom, obtaining an alternative convention, such as external wiring, whether carrying inputs or outputs, always connects to switch commons. This might be done to tidy up the cable harnessing, or as mentioned above, to mitigate the consequences of certain failure modes.

Elephant Number One

At this point, let's try to look ahead a wee bit, and address that fat elephant standing over there between the coffee table and the lava lamp. Yes, our "final" prototype might squeeze every amplifier output signal through two or more series pairs of switch contacts - losing a bit of power and linearity at every junction, on its way to its designated speaker. Worse still, it might use crimp (cold weld) spade contacts for tidiness and maintainability, so right there we'll have another four dry metal connections per contact pair.

Update: Every prototype switch construction in this series is undertaken as a learning experience. What this one taught me is that crimping is an underrated skill. It's also exactly like riding a bike, in the sense that I can't do it.

Should excess contact impedance stop us? No! Our switch / relay contacts will always be beefy enough (5A minimum, remember?) to withstand a little local heating, and there will always be more juice in the tank without tilting the volume control to anything within sight of 11.

As for linearity: any decent AV receiver has an automatic setup procedure using audio frequency sweeps and blasts of pink noise to analyse the acoustic properties of a room. This process will interpret any switch contact non-linearity that it finds as being just another boring old acoustic imperfection in the architecture, and will make the necessary adjustments to the sound processing profile. Of course, this means repeating that setup procedure once for every available sound stage orientation. If we're lucky, our receiver will have enough memory slots to store eight (or however many we need) such independent profiles.

Elephant Number Two

In the prototype version using those quite large screw-terminal toggle switches, there was just enough room in my 185x115mm project box to fit the four main switches in one horizontal row, with the Mode 5 switch offset vertically at one end. This meant some of the contacts from adjacent switches were quite close together, and could conceivably cause a short circuit, were the switch fitting nuts to work loose and allow rotation.

The solution I chose was a bit of elephant hide, cut to the pattern shown, then folded to form insulating fins when mounted between the switches and the back of the box lid. If you want to use this approach, but find your elephant hide supplied in smaller sheets, by all means use two pieces, but do ensure that each piece incorporates at least two switch mounting holes, again to prevent rotation.

 Nothing to see here. Seriously, go back and have another look at the circuit diagram. It's a lot nicer.
Lessons Learned

Maybe I should have learned to crimp. Then there'd have been an incentive to harness up all these wires properly, all neat and tidy. But hey, it's just a prototype. And anyway, isn't tidy wire harnessing bad for crosstalk?

 Toggle switch prototypes 2a & 2b.
I don't think I'd use Daier 4PDT screw terminal toggle switches again - or any of their switches actually, When I tried tightening these on the project box lid, even quite gently, about half of the fixing nuts would jump threads. That's some poor mechanical construction, and there's no reason to think it won't be the same with any other design of theirs.

The second toggle-based prototype "2b" (b for blue) worked out a lot better, using the smaller but sturdier Maplin 4PDT switch with solder terminals. These have a chrome plated brass dolly, and silver plated contacts rated 6A at 125Vac. Had to change back from multi strand to the more brittle single core wire, due to terminal space restriction and the danger of loose strand shorts (which are so last season), but it's all good.

 Get an octoroom.
Finishing Off

Here's prototype 2a, in a rather romantic pose, ready for installation. The in/out connections are fed through rubber grommets and terminated in a cable mounted plug/socket pair, as befits a prototype (production units by contrast would use panel mounted connectors, which are fussier to drill and fit).

Next time: Relayer.