Resistor value when using a PNP to switch 24v from 5v NPN and Schmitt trigger

Thread Starter

greycells

Joined Feb 7, 2016
41
Hi

This is my first attempt at using transistors in a circuit, so confidence is not high. The circuit is powered by 24vDC, regulated down to 5v for the debounce and logic but has to switch the 24v via a PNP (not an NPN).

The mechanical switch SW1 is normally closed (so the debounce is 'tuned' for opening) and the PNP transistor Q2 should behave as normally closed, opening the 24v circuit when SW1 is opened (when also the green LED (D2) goes out, the red LED (D2) lights and the buzzer sounds).

I've test built this on a breadboard (excluding the voltage regulator circuit) using 3.3v to represent the 5v and 5v to represent the 24v so my question is: when I connect the voltage regulator circuit and push 24v through Q2, will this circuit release the magic smoke and/or do I need to change the value of the resistor R6?

The circuit appears to do what I need but any advice on what I could do better/differently/right would also be much appreciated.

PS, once I'm confident I have this right the main part of the circuit will be duplicated to provide a second switch.
 

Attachments

dl324

Joined Mar 30, 2015
16,839
Welcome to AAC!

Schematic with some unnecessary whitespace and colors removed.
1674421626332.png

I'd put a pull up resistor on the base of Q2, draw Q3 right side up, make ground symbols point down, and positive supplies point up. And change the flow to be left to right.
 

Irving

Joined Jan 30, 2016
3,843
I'd replace the PNP switch transistor with a P-channel MOSFET as this will be marginally more energy efficient. You don't say what current the switched 24v has to supply but the 10k base resistor is probably too large.

What is the purpose of D3/R3?
 

AnalogKid

Joined Aug 1, 2013
10,986
For Q2 to be firmly saturated as a switch, its base current should be at least 5% of the max. current it is switching. Many people recommend 10%, but that rule-of-thumb dates back to the 1950's, when transistor performance was ... less. Assume a 0.1 V drop across Q3, a 0.6 V drop across the Q2 base-emitter junction, use Ohm's law to calculate the value of R6, and round the result to the nearest commercial value.

AND - Ground symbols *always* point downward. Unlike a resistor or capacitor, orientation is a fixed part of each of the various ground symbols.

ak
 
Last edited:

Thread Starter

greycells

Joined Feb 7, 2016
41
Welcome to AAC!

Schematic with some unnecessary whitespace and colors removed.
View attachment 285814

I'd put a pull up resistor on the base of Q2, draw Q3 right side up, make ground symbols point down, and positive supplies point up. And change the flow to be left to right.
Thank you - I'll re-draw the schematic tomorrow (I was kinda flowing it around clockwise in my head) and post a crop. The pull up would be from pin 2 to +5v on Q2? Can you recommend a value?
 

dl324

Joined Mar 30, 2015
16,839
The pull up would be from pin 2 to +5v on Q2? Can you recommend a value?
What is Q2 driving? As previously mentioned, a 10k base resistor is probably too large.

The datasheets for 2N2222 and 2N3904 still call for base current to be 10% of the collector current for saturation mode.

How much current does the buzzer require? HC14 can't sink or source much current.
 

Thread Starter

greycells

Joined Feb 7, 2016
41
I'd replace the PNP switch transistor with a P-channel MOSFET as this will be marginally more energy efficient. You don't say what current the switched 24v has to supply but the 10k base resistor is probably too large.

What is the purpose of D3/R3?
I did consider (read: buy) mofsets but the current to be switched is only about 25mA. D3/R3 are part of the debounce circuit (from here: https://www.digikey.co.uk/en/articles/how-to-implement-hardware-debounce-for-switches-and-relays 'Hardware debouncing an SPST switch with an RC network') - I played with the values to (hopefully) optimise the open action.
 

Thread Starter

greycells

Joined Feb 7, 2016
41
What is Q2 driving? As previously mentioned, a 10k base resistor is probably too large.

The datasheets for 2N2222 and 2N3904 still call for base current to be 10% of the collector current for saturation mode.

How much current does the buzzer require? HC14 can't sink or source much current.
Q2 is driving a 24v input on a PCB - about 25mA and the buzzer (more of a 'beeper' but KiCAD doesn't have a beeper) is about 10mA.

I have put 10k resistors on all the transistor bases because that's what I had and they worked - I thought (with no actual evidence) the Q2 transistor might have to be bigger rather than smaller to stop the 24v 'going back up the pipe'... Can you tell I'm new to this?
 
Last edited:

Thread Starter

greycells

Joined Feb 7, 2016
41
For Q2 to be firmly saturated as a switch, its base current should be at least 5% of the max. current it is switching. Many people recommend 10%, but that rule-of-thumb dates back to the 1950's, when transistor performance was ... less. Assume a 0.1 V drop across Q3, a 0.6 V drop across the Q2 base-emitter junction, use Ohm's law to calculate the value of R6, and round the result to the nearest commercial value.

AND - Ground symbols *always* point downward. Unlike a resistor or capacitor, orientation is a fixed part of the various ground symbols.

ak
I feel suitably chastised on my layout - I'll re-do the drawing tomorrow. And I'll try to do the maths too - eek!
 

Thread Starter

greycells

Joined Feb 7, 2016
41
Can I just say a big thank you for all the rapid replies - I only left to eat my dinner! Probably the best 'first forum post' experience I've had.
 

Thread Starter

greycells

Joined Feb 7, 2016
41
You should plan on 3mA of base current. Q3 will need 0.3mA.
74HC at 5V are spec'ed for about 4mA sink or source.
We'll take care of that.
Thank you again - I just tried a resistor between Q2 base (pin 2) and it stops Q2 from opening - am I not understanding something? (highly likely) Is it because of the 10k resistor on the base - so do I need to have the pull up and base resistor to work together?
 

dl324

Joined Mar 30, 2015
16,839
so do I need to have the pull up and base resistor to work together?
1674427896257.png
You could probably get away with not having R1, but it makes me fill better with it there. It increases the collector current in Q3, but R3 takes that into consideration.
 

Thread Starter

greycells

Joined Feb 7, 2016
41
View attachment 285824
You could probably get away with not having R1, but it makes me fill better with it there. It increases the collector current in Q3, but R3 takes that into consideration.
Thank you so much Dennis - I was pulling up to the +5v, so this helps a lot. I don't have any 6.8 k or 820 resistors atm (a selection box is on its way). Should I apply the same logic to Q1?
 

dl324

Joined Mar 30, 2015
16,839
I don't have any 6.8 k or 820 resistors atm (a selection box is on its way). Should I apply the same logic to Q1?
The values aren't super critical. You can go smaller. Just make sure that base current is 10% of the collector current and don't go crazy with too much base current.

Q1 base resistor is okay. Pull-up on the base is optional. You could omit it on Q2 too.
 

Thread Starter

greycells

Joined Feb 7, 2016
41
The values aren't super critical. You can go smaller. Just make sure that base current is 10% of the collector current and don't go crazy with too much base current.

Q1 base resistor is okay. Pull-up on the base is optional. You could omit it on Q2 too.
Thank you - I will have a play tomorrow with the resistors I have.
 

dl324

Joined Mar 30, 2015
16,839
I will have a play tomorrow with the resistors I have
Do you know how to calculate values for resistors in parallel? What resistor values do you have?

10k in parallel with 20k will give you 6.67k
1k in parallel with 6.2k will give 860 ohms
 

Thread Starter

greycells

Joined Feb 7, 2016
41
Do you know how to calculate values for resistors in parallel? What resistor values do you have?

10k in parallel with 20k will give you 6.67k
1k in parallel with 6.2k will give 860 ohms
I understand that resistors in parallel offer less resistance (and in series, more) but I'd have to google the maths!

I'm currently still testing with 3.3v and 5v as I don't have a 24v power source with me but I used a 1k (for the 820) and a 4.7k for the 6.8k and the logic works as I need it to. The selection box should arrive tomorrow and I'll be in the same place as the 24v power...

Attached is the new version of the schematic - hopefully I haven't introduced any errors (Narrator: I did) and have all the GND's pointing in the right direction! It's a little cramped but that's because I'll be doubling it up soon.

Edit: I did introduce errors but in the very first schematic! I had the red/green LEDs wrong which meant I had the buzzer wrong (which explains @dl324's concern about HC14...).
My original question was about the 24v switching but I don't want to add confusion by keeping the incorrect schematic here, so I've now recreated the schematic as per my breadboard (again but hopefully correctly this time) and used the original component IDs (lesson learned) - I'll post it below @Irving's comments as I've added in the pull up resistors too.
 
Last edited:

Irving

Joined Jan 30, 2016
3,843
Q1 base resistor is okay. Pull-up on the base is optional. You could omit it on Q2 too.
Redrawing it has re-allocated all the component IDs - the following references your original drawing.

Simulation in LTSpice shows the base pull-up is needed on Q2 to turn the 24v off completely otherwise the leakage current in Q3 can partially turn on Q2, though it is only a few tens of nA.

R7 at 820ohm gives an Ib for Q3 of 4mA,>than its Ic @3.4mA for turning Q2 on! 10k for R7 was fine.

R1 and R2 limit LED current to around 1 - 2mA which might be too low, however with a 10k base resistor the minimum high output voltage of the HC14 will not turn off Q1 fully and the green LED may still be on after the R3/C5 delay (which is only 50uS with the values given, are you sure thats correct - what is the purpose of the delay given it only affects the LEDs, red on and green off). A pull-up to 5v is needed, 10k is fine.

1674482337588.png
 

Thread Starter

greycells

Joined Feb 7, 2016
41
Redrawing it has re-allocated all the component IDs - the following references your original drawing.

Simulation in LTSpice shows the base pull-up is needed on Q2 to turn the 24v off completely otherwise the leakage current in Q3 can partially turn on Q2, though it is only a few tens of nA.

R7 at 820ohm gives an Ib for Q3 of 4mA,>than its Ic @3.4mA for turning Q2 on! 10k for R7 was fine.

R1 and R2 limit LED current to around 1 - 2mA which might be too low, however with a 10k base resistor the minimum high output voltage of the HC14 will not turn off Q1 fully and the green LED may still be on after the R3/C5 delay (which is only 50uS with the values given, are you sure thats correct - what is the purpose of the delay given it only affects the LEDs, red on and green off). A pull-up to 5v is needed, 10k is fine.

View attachment 285871
Thank you for this - it may take me a while to translate your schematic in my head! My apologies on the re-numbering. The R3/C5 is a debounce circuit 'tuned' for when the normally closed remote switch opens. My ever understanding wife bought me an oscilloscope for Christmas but I know as much about using it as I do about designing circuits but those value provide a sharp fall.
In the later drawing Q2 has the pull up in place but I haven't (yet?) for Q1.
R1 and R2 were the most suitable resistors I had in my posession - I'll probably change them when my resistor selection pack arrives.
 
Top