What is the purpose of the resistors in this schematic? - Page 1
Forum section: electronics / beginners

author: jj5
author_rank: Unknown
timestamp: January 31, 2023, 11:05:21 am
content: Hi there. I'm working through an experiment in my 300 in 1 electronics lab and doing project 155 which is a DTL OR Gate, so just a logical OR gate made from diodes and transistors. I've attached a photo of the schematic. I understand the function of the diodes and transistors well enough, but I don't understand why the resistors are necessary. And given that they are necessary, I don't know how I would go about computing their values, why 1K and 22K and so on, and not any other value? Would really appreciate it if someone could explain the purpose of the resistors in this circuit to me. Thanks!

author: jpanhalt
author_rank: Super Contributor
timestamp: January 31, 2023, 11:52:40 am
content: Look at R1 and R2 first. What would happen if those were short circuits? What if they were omitted to give open circuits?

author: pcprogrammer
author_rank: Super Contributor
timestamp: January 31, 2023, 11:57:17 am
content: I'm no expert, and there are quite a few resistors used, but here we go:R1 and R2 are pull down resistors and keep the inputs low while the switches are open. Without these the inputs would float and could be seen as high or low depending on noise. In this case not to much an issue due to R3. The value is also not to critical. Mostly used in digital circuits for pull up or downs is a range between 470 and 10K ohms.R3 has similar working. It keeps the base of Q1 at ground when the switches are open.R4 is there to limit the current into the transistor base. It depends on the transistor parameters and wanted currents how big this resistor needs to be. For R5 the same applies.R7 is to set the current flowing through the LED, and 470 ohm is quite often used in this case. I think R6 is not really needed because R7 with the LED is already a load for Q2.To calculate R7 one checks the LED's forward voltage and current needed to get a good light. The forward voltage is subtracted from the battery voltage together with the transistor collector emitter voltage drop and divided by the wanted current.

author: jj5
author_rank: Unknown
timestamp: January 31, 2023, 11:57:54 am
content: So if R1 was a short, that would be a problem for the circuit, it would short the battery pretty much directly. But if it were open, i.e. not there at all, wouldn't current just flow through the diode attached to S1? Indeed I tried the experiment of removing R1, and the circuit seemed to continue working correctly. Not sure what's up with that.

author: pcprogrammer
author_rank: Super Contributor
timestamp: January 31, 2023, 12:03:24 pm
content: Digital logic can have sensitive inputs and when left unconnected pick up noise that can cause what I described, random seeing low or high causing oscillations. That is why pull ups or downs are used.Try the experiment with R1, R2 and R3 removed and both switches open. It might show the mentioned behavior.

author: shapirus
author_rank: Super Contributor
timestamp: January 31, 2023, 12:13:39 pm
content: Quote from: jj5 on January 31, 2023, 11:57:54 amIndeed, it doesn't look like both (R1+R2) and (R3) are needed to be present at the same time. It should be fine to keep only R3, since it pulls the transistor base low if both of the diodes inputs are floating, thus excluding the possibility of having an undefined state. Even the R3 is most likely not required: it's very unlikely that you'll ever have a sufficient input noise levels to have sufficient current flowing into the base of Q1 with both input switches open.Besides, R1 and R2 will drain significant current from the battery for no good reason. If they are used, their values can be much higher (I'd say 50k-100k).However, you should always remember the principle of setting logic inputs to a definite low or high, even though it may be ignored in certain specific practical applications. This will come in handy when you encounter strange glitches when trying to simulate circuits in software -- they sometimes happen exactly because of this. And in practical applications this is important when you deal with high-impedance inputs.

author: jj5
author_rank: Unknown
timestamp: January 31, 2023, 12:13:51 pm
content: I tried the experiment of removing R{1,2,3} and the circuit continued to work correctly. I guess that's due to the absence of noise in this case. I've heard of pull up and pull down resistors before, but I think now I actually understand what they do. Thanks very much for the explanations.

author: jj5
author_rank: Unknown
timestamp: January 31, 2023, 12:25:41 pm
content: If I remove R{1,2}, do I need to recompute the value of R{4,5}? If I remove R6, do I need to recompute the value of R7?

author: shapirus
author_rank: Super Contributor
timestamp: January 31, 2023, 12:44:47 pm
content: Quote from: jj5 on January 31, 2023, 12:25:41 pmIn practice, most likely, no. But it will be a good idea to look up the max base current in the respective transistors datasheets to make sure it doesn't get higher than allowed.Besides, the values shown seem to be very low, especially given that this pair of transistors acts as a gain-multiplying pair. My guesstimate would be something like 20k for R4 and 5k for R5, and it will still work.Quote from: jj5 on January 31, 2023, 12:25:41 pmNot necessarily, if Q2 is fully open, but it isn't a bad idea anyway. You want to begin with what current you want to flow through the LED and calculate the value of R7 from there. How it's done was mentioned in one of the previous posts.p.s. I'm not even sure why they used two transistors here. A single Q1 would do the job just as well. However, it may have some meaning in the context of what circuits are described before and after this one.

author: jj5
author_rank: Unknown
timestamp: January 31, 2023, 12:54:11 pm
content: Quote from: shapirus on January 31, 2023, 12:44:47 pmI was confused about the necessity of the two transistors too. Thanks for clarifying for me.

author: jj5
author_rank: Unknown
timestamp: January 31, 2023, 12:57:57 pm
content: Quote from: shapirus on January 31, 2023, 12:44:47 pmAs a general rule, would it be best to find the *minimum* base current for the transistor in the datasheet and then optimize around that? i.e. to limit current draw and extend battery life?

author: shapirus
author_rank: Super Contributor
timestamp: January 31, 2023, 01:10:08 pm
content: Quote from: jj5 on January 31, 2023, 12:54:11 pmBe it a single transistor or a pair, you will want to make sure that the output transistor opens sufficiently to allow at least the desired current to flow through the LED. Check the datasheet, see the hFE curves, calculate the required base current for a given collector current and pick the base resistor to provide that plus some (or even a lot of -- maybe 2x..3x) headroom to allow for transistor parameters deviation, replacing the transistor with a different model etc.

author: shapirus
author_rank: Super Contributor
timestamp: January 31, 2023, 01:17:00 pm
content: Quote from: jj5 on January 31, 2023, 12:57:57 pmThe post above answers that partially, but concerning the battery life, in this particular case, if we take LED current of 5 V / 500 Ohm = 10 mA and a typical hFE = 100, it means base current of 100 uA, which is low enough not to care about the extra battery drain caused by the base current, and still be low enough even when increased, say, 10 times, i.e., to 1 mA which will be more than enough to power your typical indicator LED (1s to 10s of mA) with pretty much any transistor, and still be pretty light on the battery.

author: pcprogrammer
author_rank: Super Contributor
timestamp: January 31, 2023, 01:58:54 pm
content: Quote from: jj5 on January 31, 2023, 12:54:11 pmThe second transistor is to make the circuit non inverting level wise. For the LED it does not make a difference if it is between Q1 collector and V+ or where it is now, but looking at logic levels, a high at the input of Q1 means a low at the output of Q1. With Q2 in the mix the signal is inverted again to be high at the output. (Collector of Q2 is high when one or both of the inputs is high)

author: shapirus
author_rank: Super Contributor
timestamp: January 31, 2023, 02:16:44 pm
content: Quote from: pcprogrammer on January 31, 2023, 01:58:54 pmAre you sure? Note that Q2 is PNP. From what I see, unless I haven't yet fully waken up, it's a non-inverting gate from the LED's perspective, with or without Q2, where Q2 only serves as an additional amplifier.p.s. yes I see what you mean talking about the level at the output (collector) of Q1. Remove the LED, replace Q2 with a resistor, and you get an inverting OR gate with the output at the Q1's collector. Makes sense.p.p.s. not the best circuit, in my opinion, to teach transistor logic.I would recommend the OP to see the following:http://codeperspectives.com/computer-design/npn-pnp-logic-gates/https://www.homemade-circuits.com/how-to-make-logic-gates-using-transistors/

author: jj5
author_rank: Unknown
timestamp: January 31, 2023, 02:24:34 pm
content: So can we create a non-inverting OR gate with only one transistor? If so, what would that look like?

author: pcprogrammer
author_rank: Super Contributor
timestamp: January 31, 2023, 02:26:10 pm
content: Quote from: shapirus on January 31, 2023, 02:16:44 pmI see you woke upThat is why I wrote level wise. For the LED it does not make a difference in this case, but measuring the voltage at the collectors will show a difference.Q1 pulls the base of Q2 low to allow it to make its collector high.

author: pcprogrammer
author_rank: Super Contributor
timestamp: January 31, 2023, 02:35:56 pm
content: Quote from: jj5 on January 31, 2023, 02:24:34 pmYou can set it as an emitter follower. Then it won't invert, but the input voltage to make it high will be higher.https://www.electronics-notes.com/articles/analogue_circuits/transistor/transistor-common-collector-emitter-follower.php

author: shapirus
author_rank: Super Contributor
timestamp: January 31, 2023, 02:36:37 pm
content: Quote from: jj5 on January 31, 2023, 02:24:34 pmIf we're talking about pure logic levels without much load driving capability, it's as easy as two diodes whose cathodes are connected together and anodes serving as logic inputs (with pull-down resistors to GND to set default logic level low). The cathodes are the output.Then feed this output, via a resistor, into the base of an NPN transistor or the gate of an N-channel MOSFET with load in its collector or drain, respectively, and you get a non-inverting behavior towards the load: if either of the inputs is high, load will be powered on.Replace the transistors with PNP or P-channel, and you have this inverted (but there's a caveat concerning the potential after the diodes which has to be high enough to hold the transistors closed).EDIT: the above won't work with PNP, unless you reverse the diodes too (consider the current flow direction). Then their input logic is also reversed. In other words, mixing polarity may be tricky. It is often easier and more manageable to add another inverting step with a transistor of the same polarity.

author: Zero999
author_rank: Super Contributor
timestamp: January 31, 2023, 02:45:41 pm
content: I wouldn't worry about R1 & R2. The value of R4 is already low enough and R3 acts as a pull-down. If you're worried about noise, add a resistor between Q2's base and emitter: try 22k.