Maker Pro
Maker Pro

BJT NPN + PNP to switch channel.

codetale

Feb 26, 2023
9
Joined
Feb 26, 2023
Messages
9
Hi, I'm new to electric and circuit design, wish I'm posting in right forum.

I have 2 speaker playing same source, :
- they will not sound simultaneously
- able to flip/switch the active speaker

My idea is connect one speaker to NPN (SpeakerA) and another to PNP (SpeakerB),
then put 1 pin of microcontroller to HIGH or LOW to flip/switch the active speaker.
I had tested the circuit in below Thinkercad, although it work but i believe something is incorrect,
because if I remove the resistor from the SpeakerA, when its turn, it will also play to SpeakerB
tinkercad - SwitchChannel

are my circuit correct? or any idea why the SpeakerB sound as well when the resistor is removed.

thanks
 

Alec_t

Jul 7, 2015
3,587
Joined
Jul 7, 2015
Messages
3,587
Welcome to maker.pro.
Please post a schematic of your setup.
 

Alec_t

Jul 7, 2015
3,587
Joined
Jul 7, 2015
Messages
3,587
What is the specification of the speakers? Are they powered or passive?
 

codetale

Feb 26, 2023
9
Joined
Feb 26, 2023
Messages
9
its passive, it powered by the microcontroller analog pin when signal generated.
0.5w 8ohm
thanks
 

Alec_t

Jul 7, 2015
3,587
Joined
Jul 7, 2015
Messages
3,587
The Arduino's rated maximum output current is only 40mA per analog/digital pin. An 8 Ohm speaker will draw as much as 625mA from a 5V supply, so will kill (or at least stress) the Arduino.
A speaker is inductive and can generate damaging voltage spikes if switched off quickly.
A speaker if used as shown will have a large DC current component which will bias its voice-coil one way and result in high distortion of any audio signal.
You need to re-design your circuit to have two audio amplifier stages which can be enabled/disabled by the Arduino.
 

codetale

Feb 26, 2023
9
Joined
Feb 26, 2023
Messages
9
did you mean that if the current draw is small enough, then my circuit are "correct"?
lets said change to LED?

A speaker if used as shown will have a large DC current component which will bias its voice-coil one way and result in high distortion of any audio signal.
You need to re-design your circuit to have two audio amplifier stages which can be enabled/disabled by the Arduino.
I have no idea about the audio amplifier, need to do some research...

thanks
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
my circuit are "correct"?
No.
T3 with the emitter connected to GND will not work.

Alternative suggestion: Instead of using one pin to generate the audio, second pin toswitch between speakers, use one pin for each speaker to output audio. Then you can use eiterh or even both speakers by mere software control.
Plus you'll need the audio amplifiers. An inexpensive stereo module should do the job (example). Use one channel per speaker.
 

codetale

Feb 26, 2023
9
Joined
Feb 26, 2023
Messages
9
No.
T3 with the emitter connected to GND will not work.
you mean i should connect the "connector" to GND?

Alternative suggestion: Instead of using one pin to generate the audio, second pin toswitch between speakers, use one pin for each speaker to output audio. Then you can use eiterh or even both speakers by mere software control.
Plus you'll need the audio amplifiers. An inexpensive stereo module should do the job (example). Use one channel per speaker.
another audio pin is plan to use same setup, so that can have 4 speakers.

thanks for the reference, i found a similar but with volume potentiometer.
once i use the amplifier module, it will eliminate the issue where "speaker generate damaging voltage spikes if switched off quickly", right?

thanks
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
you mean i should connect the "connector" to GND?
No. It means that you'd have to use an NPN for T3, then connect itthe same way as T4, but use a separate control pin to turn on either T3 or T4.
What you want to achieve is obviously control of both speakers by a single signal by using an NPN and a PNP transistor. This will not workin the way you connected the elements.
Here's how it can work in principle:
1677821222938.png
However, you need to be aware of the limited output power of an Arduino. Re-read @Alec_t 's post #6.
 

crutschow

May 7, 2021
839
Joined
May 7, 2021
Messages
839
Here's how it can work in principle:
Don't see how, as the PNP is connecting the speaker to Vcc.

You could use two MOSFETs connected source-to-source in series with each speaker to act as a transmission gate.
Example circuit below:

1677874205430.png
 
Last edited:

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
Don't see how, as the PNP is connecting the speaker to Vcc.
Of course the circuit is based on teh assumption that the "audio" signal as shown in post #3 is a digital signal 0 V ... 5 V from the Arduino's pin D9.
With control = High, Q1 is on, Q2 is off and the "audio" plays through the right speaker (right in my schematic).
With control = Low, Q1 is off, Q2 is on and the "audio" plays through the left speaker (left in my schematic).
Seen from the Arduino's pin D9 it drives the reight speaker as a load vs. gnd, the left speaker as a load vs. Vcc. Both is perfectly possible.
 

dragon

Oct 31, 2022
248
Joined
Oct 31, 2022
Messages
248
Your schematic isnt the same as the breadboard. even i didnt read the breadboard much clearly as schematic. the schematic has both transistors and both speakers in series with no power. the breadboard has 5v connected (i couldnt read topology because i dont use breadboards much), and thats probably why its working.

This raw use of transistors sometimes gives odd results, probably need to warm up your switches to get them full power.

Im not sure what u mean by simultaneous/not simultaneous do you want them out of phase and in phase with a switch?
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
Your schematic isnt the same as the breadboard.
Which breadboard are you talking about? The only mentioning of a breadboard in this thread is by you.
the schematic has both transistors and both speakers in series with no power.
Assuming you reference the schematic in post #3: The speakers are not in series. Nor are they in my schematic in post #11. In both cases check carefully the connections and the conditions under which the transistors are on or off.

This raw use of transistors sometimes gives odd results, probably need to warm up your switches to get them full power.
That is, excuse me, complete nonsense.

Im not sure what u mean by simultaneous/not simultaneous do you want them out of phase and in phase with a switch?
That is not a matter of phase. The op has made it fully clear in post #1 that he wants the sound to come from either of the speakers, but not from both at the same time. So "not simultaneously".

@dragon ; I asked you before in another thread to consider when and what to post. If you continue postig nonsense you risk being banned.
 

codetale

Feb 26, 2023
9
Joined
Feb 26, 2023
Messages
9
No. It means that you'd have to use an NPN for T3, then connect itthe same way as T4, but use a separate control pin to turn on either T3 or T4.
What you want to achieve is obviously control of both speakers by a single signal by using an NPN and a PNP transistor. This will not workin the way you connected the elements.
Here's how it can work in principle:
View attachment 58297
However, you need to be aware of the limited output power of an Arduino. Re-read @Alec_t 's post #6.
will try when i received my amplifier module.
btw the PNP(Q2), NPN(Q1) should connect in between audio (pin9) and amplifier module L-IN/R-IN, right?
thanks
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
btw the PNP(Q2), NPN(Q1) should connect in between audio (pin9) and amplifier module L-IN/R-IN, right?
Do you refer to the circuit shown in post #11? Then you don't need a stereo amplifier module. You connect the output of the µC to the input of the amplifier, then the output of the amplifier to the "audio" input of the transistor circuit shown in my post.

The reference to the stereo amplifier in post #8 uses two audio output pins of the µC. one for each speaker. You would then connect one pin to the L-in, the other pin tio R-in of the amplifier. Istead of switching between the speakers by transistors, you would output the "audio" on either pin of the µC.
 

codetale

Feb 26, 2023
9
Joined
Feb 26, 2023
Messages
9
Do you refer to the circuit shown in post #11? Then you don't need a stereo amplifier module. You connect the output of the µC to the input of the amplifier, then the output of the amplifier to the "audio" input of the transistor circuit shown in my post.

The reference to the stereo amplifier in post #8 uses two audio output pins of the µC. one for each speaker. You would then connect one pin to the L-in, the other pin tio R-in of the amplifier. Istead of switching between the speakers by transistors, you would output the "audio" on either pin of the µC.
yes, im refer to the circuit on post #11
what is the "µC" you mentioned? is it the "control" line?

my final output required 4 speakers, so the solution in post #8 will not fit my need,
i need to use both pin with same setup.

thanks a lot
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
µC = microcontroller, the Arduino in this case.
my final output required 4 speakers
That's a different requrement than originally posted. 2 Transistors wouldn't suffice for 4 different speakers anyway.
i need to use both pin with same setup.
Why? Please explain in detail what you want to achieve.
 

codetale

Feb 26, 2023
9
Joined
Feb 26, 2023
Messages
9
µC = microcontroller, the Arduino in this case.

That's a different requrement than originally posted. 2 Transistors wouldn't suffice for 4 different speakers anyway.

Why? Please explain in detail what you want to achieve.
it should able to work fine if it work with 1 pin 2 speakers. I just have to duplicate it to another audio pin

a toys for kids "chases the voice", they have to complete some tasks at specified location where the sound on.
 
Top