I set out to design an SPDIF signal detector/selector using an analog mux as the switching element. Little did I know that the project was going to morph into an audio signal detector/selector using relays.
The unique feature of this project is that I've utilised a small microcontroller to detect whether a signal is present on each of the 4 inputs. It works by using the builtin ADC to sample each channel at the maximum rate for a short time (100ms) and determining how many samples are above a threshold given in the firmware. If the number of samples is high enough, the signal is deemed to be on. Otherwise, this is similar to many of the other source selector projects out there.
I've breadboarded the detection part of the circuit and written the detection firmware, and it works well, reliably detecting when a source is playing. I'll build in some delay so that e.g. track changes don't cause the indicators to go out. The status of the inputs will not affect the selected input, so when a signal goes away that input will stay latched until it's changed. I'll need to do some tweaking to figure out how sensitive it will be to quiet passages, and EMI for floating inputs.
Output uses an 8-bit I2C expander to drive 4 sets of two LEDs (or 4 bipolar dual colour LEDs, which is my preference) to show signal presence and signal selected status, a 2-bit address (for the relay board interface) and an enable (active LOW) signal. The I2C signals are also available for a possible future slave mode to be read/written by a master controller.
Input is a single pushbutton that switches to the next active source. If all signal sources go away, the previously selected one will remain selected until the button is pressed again, which will disable all inputs. Unfortunately this state will leave the output floating with my relay board, but I don't have a better solution without putting junk in the signal path.
I would appreciate any comments. Please take a look at the board layout/schematic PDFs:
http://www.gotroot.ca/~ktims/dump/auto spdif selector.pdf
http://www.gotroot.ca/~ktims/dump/relay board.pdf
And the BOM:
http://spreadsheets.google.com/pub?key=pO3ofQox_j8i98ZqCAN4qbw
The unique feature of this project is that I've utilised a small microcontroller to detect whether a signal is present on each of the 4 inputs. It works by using the builtin ADC to sample each channel at the maximum rate for a short time (100ms) and determining how many samples are above a threshold given in the firmware. If the number of samples is high enough, the signal is deemed to be on. Otherwise, this is similar to many of the other source selector projects out there.
I've breadboarded the detection part of the circuit and written the detection firmware, and it works well, reliably detecting when a source is playing. I'll build in some delay so that e.g. track changes don't cause the indicators to go out. The status of the inputs will not affect the selected input, so when a signal goes away that input will stay latched until it's changed. I'll need to do some tweaking to figure out how sensitive it will be to quiet passages, and EMI for floating inputs.
Output uses an 8-bit I2C expander to drive 4 sets of two LEDs (or 4 bipolar dual colour LEDs, which is my preference) to show signal presence and signal selected status, a 2-bit address (for the relay board interface) and an enable (active LOW) signal. The I2C signals are also available for a possible future slave mode to be read/written by a master controller.
Input is a single pushbutton that switches to the next active source. If all signal sources go away, the previously selected one will remain selected until the button is pressed again, which will disable all inputs. Unfortunately this state will leave the output floating with my relay board, but I don't have a better solution without putting junk in the signal path.
I would appreciate any comments. Please take a look at the board layout/schematic PDFs:
http://www.gotroot.ca/~ktims/dump/auto spdif selector.pdf
http://www.gotroot.ca/~ktims/dump/relay board.pdf
And the BOM:
http://spreadsheets.google.com/pub?key=pO3ofQox_j8i98ZqCAN4qbw
I changed the scope of the project from switching digital to analog signals. It's just intended for switching line outs for now. Maybe this belongs in the analog forum? There's not really a good category for this type of project...most of the meat of it is in the digital domain so that's where I put it.rossl said:What are the inputs you are switching? Toslink receivers? Coax or AES?
I may build a module that would replace the relay board with an analog mux and the hardware to switch SPDIF/AES signals, but for now I don't need this and would be able to make more use of the analog switching. This system *should* work with SPDIF as well when I have a need for it, at least the detection side should be fine. The relay board isn't the best approach for the SPDIF signals, but I think the layout and relays are good enough that it will work.
OK, your schematic makes more sense now. I am still concerned that your relays ground the input signals when the channel is off.
It would be better to terminate the "off" inputs with resistors instead of grounding. If the analog source drivers see a 600 ohm resistor switched in by the relay, they will not drive very much current if there is an output voltage.
For digital, you would want to terminate coax with 75 ohm and AES with 110 ohm. Shorting to ground could damage the output circuit of the source.
It would be better to terminate the "off" inputs with resistors instead of grounding. If the analog source drivers see a 600 ohm resistor switched in by the relay, they will not drive very much current if there is an output voltage.
For digital, you would want to terminate coax with 75 ohm and AES with 110 ohm. Shorting to ground could damage the output circuit of the source.
You're right of course, thanks for the heads up. Originally I had planned to leave the unused inputs floating, but I didn't really like the idea. I made some updates late last night and at the time I was playing with grounding them instead - I don't like that idea either, but it made it into the PDFs I uploaded...oops. I've added the terminating resistors in my working copy.rossl said:OK, your schematic makes more sense now. I am still concerned that your relays ground the input signals when the channel is off.
It would be better to terminate the "off" inputs with resistors instead of grounding. If the analog source drivers see a 600 ohm resistor switched in by the relay, they will not drive very much current if there is an output voltage.
For digital, you would want to terminate coax with 75 ohm and AES with 110 ohm. Shorting to ground could damage the output circuit of the source.
The terminating resistor seems to solve both problems. 10K seems to be an average input impedance, why would I want to use something smaller? Wouldn't this potentially increase crosstalk by increasing the current flowing in the unused circuits? Or is the goal to force the signal as close to ground as possible without causing damage...
I've updated the relay board PDF to include my changes. Some parts shuffling was required to fit the resistors, but nothing too serious, and I've still managed to keep active analog signals from crossing or being so close there's no ground between them. I made another minor change as well; the unused side of the decoder no longer has enable asserted - not that it matters much. The digital signals are all static so there shouldn't be any interference from there; and I've kept them away from the analog where possible anyway.
The one thing I'm not happy with is the position of R1, but the only solution I can find is to move all the components except U4 north, but I like that idea even less than having this one part hanging off to the side because of what it does to the input connectors (or symmetry, take your pick).
The one thing I'm not happy with is the position of R1, but the only solution I can find is to move all the components except U4 north, but I like that idea even less than having this one part hanging off to the side because of what it does to the input connectors (or symmetry, take your pick).
I think you only need 4 resistors on the relay board...
On an "off channel", the signal path from pin 3 of a connector goes through a relay contact, through a single resistor to the other relay contact, and back to pin 1 of the connector.
With the 2 resistors to ground in each channel, you will get current in the ground traces.
With one resistor terminating, all the current returns back to the source. This way, there is no crosstalk or current in the ground trace.
On an "off channel", the signal path from pin 3 of a connector goes through a relay contact, through a single resistor to the other relay contact, and back to pin 1 of the connector.
With the 2 resistors to ground in each channel, you will get current in the ground traces.
With one resistor terminating, all the current returns back to the source. This way, there is no crosstalk or current in the ground trace.
I'm not sure what you mean. If I were switching ground and keeping it isolated from the control circuit I see how that'd work (connect the signal to the source's ground), but the two poles on the relays are L and R signal, so I don't think that will work - but I could be wrong, I can see how it might work, but I'd be confused as to the benefit of connecting it so that the larger (L-R) is, the larger the current flow is. As it is in the current layout, each signal is terminated to its ground (since they're all connected together, this is just local ground). Am I missing something?rossl said:I think you only need 4 resistors on the relay board...
On an "off channel", the signal path from pin 3 of a connector goes through a relay contact, through a single resistor to the other relay contact, and back to pin 1 of the connector.
With the 2 resistors to ground in each channel, you will get current in the ground traces.
With one resistor terminating, all the current returns back to the source. This way, there is no crosstalk or current in the ground trace.
The grounds on all sources are necessarily connected together so that the detection circuit can work. I tried to come up with a scheme to isolate them and alleviate potential grounding issues, but I wasn't successful. All the schemes I came up with were a fairly difficult load for the source, and I don't want to load the source appreciably more than if it were directly connected to the amp. I made the concession of spec'ing 1M input resistors for this reason (though I will probably try 100K, and even lower should be okay with all of my gear), which hurts the ADC performance pretty seriously due to the sample and hold input.
OK I get it now. You aren't switching the grounds.
I wouldn't do it that way, I think you will get unwanted currents in the ground traces.
I wouldn't do it that way, I think you will get unwanted currents in the ground traces.
I think it's necessary if I want to try out this signal detecting circuit, which is the main point of building this for me. Unfortunately all the grounds must be connected so the ADC can sample the signals. If it's a problem, I can always build a more conventional design.rossl said:OK I get it now. You aren't switching the grounds.
I wouldn't do it that way, I think you will get unwanted currents in the ground traces.
Do you think it's better to let the unused signal float, or terminate it to ground through the resistor in this case? Is there anything I can do to minimize unwanted ground currents (maybe split up the ground plane strategically) between sources?
Thinking sideways a bit, maybe it would be better to connect the signal grounds to the local ground through a fairly large value resistor, and switch the ground. Essentially no current will flow in these returns with the 100M input impedance of ADC, the only time any current should flow is when the ADC must clamp the input, which is still through 1M input resistor. I think it would be possible to do some filtering in the firmware to compensate for any small DC offset if necessary (resolution is as small as 53uV; this could actually be a factor), so maybe this is an option?
It sounds to me like you're on the right track. Experiment with it a bit and see what sounds best.
Thanks very much for your advice, my design is improved by it and it is appreciated!rossl said:It sounds to me like you're on the right track. Experiment with it a bit and see what sounds best.
I will try and add 4PDT relays and switch the ground. If it doesn't work out, I will still have the option of a common ground available; it's easy to jumper resistors but hard to add them if there's no space!
Now, to redesign the PCBs so I can still fit them both on a single eurocard 😉
- Status
- Not open for further replies.
- Home
- Source & Line
- Digital Source
- Signal Detecting Source Selector