audio switching with teensy 4.0

elgiano

Member
Hi,
as part of a bigger project, I need to "switch" a stereo audio signal. I'm using the Audio shield, and here is the schematic I envisioned:
1702728672134.png


In words: teensy audio gets analog stereo line ins (analogL and analogR), and does some DSP outputting dspL and dspR. I want to be able to switch digitally sampled signal in and out completely, so I'm going through a DPDT relay. I chose a double coil latching type so that I can control it more easily with two teensy digital out pins. I added two mosfets to match the relay's current requirements.

I have a few questions:
1. Do you think this circuit would work? And do you think is it a good idea or can you suggest better or simpler alternatives?
2. Is it ok not to have a gate resistor on mosfets, or should I put one?
3. Is it ok not to have a pulldown resistor between teensy pins and mosfets' gates? Or is there any way I can use teensy's built in ones even if I want to use the pins as outputs?

In case you need to know, line level signals here are max 3.12Vpp.

Thanks!
 
1. Do you think this circuit would work? And do you think is it a good idea or can you suggest better or simpler alternatives?
2. Is it ok not to have a gate resistor on mosfets, or should I put one?
3. Is it ok not to have a pulldown resistor between teensy pins and mosfets' gates? Or is there any way I can use teensy's built in ones even if I want to use the pins as outputs?
This circuit would work.
Suggest to add 2 external resistors like so:
1702759876539.png


Paul
 
Thanks a lot for the super quick reply!
Can I ask why isn't there something like an OUTPUT_PULLDOWN pinMode? But maybe I didn't understand how INPUT_PULLDOWN works... my thought is that if teensy has built-in pull-downs for inputs, we could use them for outputs as well to replace R2 in your drawing.
 
why isn't there something like an OUTPUT_PULLDOWN pinMode?
Probably for the same reason that there is no INPUT_PULLDOWN pinMode: there is just no switchable pull-down resistor present in the chip.
Although I read here, the Arduino Zero has one.

Paul
 
Probably for the same reason that there is no INPUT_PULLDOWN pinMode: there is just no switchable pull-down resistor present in the chip.
Although I read here, the Arduino Zero has one.

Paul
INPUT_PULLDOWN is a pinMode...

OUTPUT_PULLDOWN doesn't make sense. If a pin is in output mode it drives either high or low.
 
Indeed Teensy 4.x has INPUT_PULLDOWN. But that's not the right question here. You would certainly use normal OUTPUT mode with either of the circuits shown.

The better question to ask is what happens when Teensy powers up, before your code runs pinMode(). If you want to be assured of the transistor being switched on or off, you would include the resistor so you get a well defined behavior.

If you're willing to accept (for the cost savings of 1 resistor) the transistor could be on or off, or even worse partially on, you would probably want to minimize the time it spends in that condition. You would probably use startup_middle_hook() to configure pinMode() and digitalWrite() as soon as possible.
 
Since we are here, I'm wondering:
I chose a latching type relay because I thought it would be best for this application, where I don't typically need to switch fast back and forth and I might need to keep the relay on for tens of minutes. And I chose a double coil latching type because it looked easier to control with two separate pins. But what's your opinion about it? Would you rather use a non-latching or single coil relay?
 
I thought you had chosen a latching relay for power consumption reasons. A latching relay does not need to be powered once it's in a certain state.
For this particular relay, the datasheet states under Recommended Relay Drive Conditions that the pulse width should be >10ms. Once you satisfy that condition you can stop powering the relay. The relay will switch in ~2ms.
 
Yeah, actually more than straight power consumption, the reason why I chose a latching type are sentences from the datasheet like:
If a current is applied to the coil over a long period of time, the coil temperature rises, promoting generation of organic
gas inside the relay, which may result in faulty contacts. In this case, use of a latching relay is recommended.
and I thought that a use case where the relay can be required to stay on for anything from minutes to hours could be considered a long period of time...
But since is my first time using relays I thought I could double check my choice with the community <3
 
Back
Top