Pages: [1] 2   Go Down
Author Topic: Digital Pin as an on/off switch for Audio Signal  (Read 2362 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have a somewhat odd question that I can kind of see an answer to but thought maybe someone else has considered this and tried it out/knows that this is an obviously stupid idea.

I know that I can use a transistor and arduino to flip a switch on another circuit board (I used transistors and an arduino to bridge a push button on a remote control), but I'm wondering if there is a way to use arduino and a transistor to connect/disconnect an audio signal from elsewhere (say from my turntables or a what have you).

Any thoughts on this? Bad idea? Feasible? Bad Audio compromising inevitable?

In any case, curiousity is killing this cat and I keep thinking about this as I work on other arduino programming, any insight would be awesome!
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

let me be a bit more clear.  I was thinking of having the transistor positioned within the audio cable/signal itself, so i could flip it on and off by sending a signal out of the digital pin.  Does that make any sense?
Logged

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9549
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've used commom NPN transistors to swith audio and analog video on/off. Should be simple enough to try using an NPN transistor and a 5k resistor on the transistor base.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the fast reply zoomkat. Do I just run the digital pin of the arduino to the base through the 5k resistor?  And I know this sounds somewhat stupid, but am I just running the signal (+) of the audio into the collector and out the emitter of the NPN and just leaving the audio's ground alone?  

Is the only part of the arduino connected to the audio the digital pin that is sending the on/off to the base?  

Sorry for the twenty questions, I think I may have messed some basic things up when I started thinking about this more last night.
Logged

Taylors, SC
Offline Offline
Newbie
*
Karma: 1
Posts: 21
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You may want to think about driving a small relay with the NPN circuit you're talking about.

You mention using the collector as the "in" and the emitter as the "out" for your audio path with the base driven by the Arduino.  If there's no conduction path for the base current back to the Arduino I don't think much of anything will happen.

The other problem I see is that your audio signal is AC and so even if conduction were occurring between C and E on the transistor, half the time the potential will be negative.

There are also digital switches like the CD4066 that conduct in both directions.  I've often thought about trying them out on an audio signal but I haven't tried it.  It'll add something like 150 ohms to the signal path.  I can't say whether or not you'd find any zero crossing distortion.  I've also used a surface mount digital switch that had much lower on resistance but the P/N escapes me right now.  

http://www.fairchildsemi.com/ds/CD%2FCD4066BC.pdf

good luck!

Mike
Logged

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9549
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In my limited audio experience, it seems audio in on components is basically "mic in" and "line in". The mic in seems to have a current flow path for operation of the microphone. The line in seems  to have a capacitor coupled setup to extract the audio signal. In the setups I've made think I had a common ground between the devices. I had the transistor base connected to a parallel port pin for on/off switching, the transistor collector connected to the audio source (dish tv receiver), and the emitter connected to the audio in on my computer capture card. I used this with a webcam program that supported audio so I could watch the US invasion of Iraq on my computer at work. The emitter can't be directly connected to the ground as this will also ground the audio signal.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks zoomkat and mike, I'm going to go ahead tonight and actually give both ideas a whirl and see what can or can't work.  We will see what emerges. I know exactly what you mean mike, and I definitely started looking at relay switches as an alternate option because of this.  

It would be nice if I could find somebody else who's done work with arduino, relays and audio, but I haven't really come across anything on the forum (yet) that goes into this topic and which could provide a bit of light on the topic.

Thanks again to both and I'll report back with what I find tonight.
Logged

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9549
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A search for audio relay will probably provide a lot of info. Mechanical relays may introduce an ugly pop into the audio stream. Any switching probably needs to be solid state.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 619
Posts: 33966
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You will find a transistor will not work as it is a current switching device. You need a FET or analogue switch. However you have to make sure that the audio signal is biased in the middle of the voltage range of the arduino or you will get half the wave chopped off. This requires that the signal is AC coupled going in and out of the switch with a biasing potential divider at the switch.
Logged

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9549
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
You will find a transistor will not work as it is a current switching device.
My transistor setup worked for several years. , so I'm calling BS on that one.  smiley-wink
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay, so... here's the deal... I've wired up the reed switch to arduino and it's working perfectly.  I followed the general wiring diagram that's provided for hooking an arduino up to a relay, though I've skipped putting the 2n2222 transistor in the circuit that the digital pin from the arduino is supposed to connect to the relay.  At the moment the digital pin runs straight into the relay and there aren't any apparent issues, so I'm wondering if the 2n2222 is actually necessary.  I've included the diode in the circuit to make sure that accidental voltage spikes don't occur.

There aren't any problems in the performance (aside from the obvious popping that happens when the switch is flipped on and off, which I'll need to fix by using a solid state in the real circuit).  So it looks like a relay will be the way that I go since the performance is so clean and efficient aside from the pops that come from the current iteration.  Thanks for the help and the insight everyone.
Logged

Taylors, SC
Offline Offline
Newbie
*
Karma: 1
Posts: 21
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Nicodemus,

I found this link that may be helpful to you.  The first idea uses a p channel FET to accomplish what you want.  The second shows how to implement a digital switch like the CD4066 that I mentioned earlier.

http://neatcircuits.com/audiosw/index.html

Mike
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Mike!

I actually ran across that today and it's super interesting... I'm going to hunt down and sort out this switch as a solid state relay switch solution and then look at the work that they're doing since they've actually got a great set of different circuits that are really interesting.  Thanks again for the help today, it's nice to have things fall into place without some of the more extended histrionics that I've performed in the recent past with this project.

nico
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh, duh... two last things I'm thinking of this evening.... Does the relay output need to be AC or DC specifically?  aaaand.... while considering my intended behavior of this circuit, any solid state relay recommendations that pair with arduino well?
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17293
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
At the moment the digital pin runs straight into the relay and there aren't any apparent issues, so I'm wondering if the 2n2222 is actually necessary.

That all depends on the resistance of the relay coil. If it such that it draws less then 40ma max (20ma max recommended) then you can drive it directly from an output pin, otherwise a switching transistor is required.

Lefty
Logged

Pages: [1] 2   Go Up
Jump to: