2

I have this basic darkness detection circuit. I want to connect this circuit with a 8-bit PISO shift register and want this to output a high or low value.
I am not sure where to get the output from.
I tried playing around with it in tinkercad and falstad.com but I haven't been able to figure this out yet

schematic

simulate this circuit – Schematic created using CircuitLab

If I try to take the voltage from output 1, it stays on because it still has a pathway even without the base current. enter image description here

As seen here, I was expecting the voltage in the multimeter measurement to go to zero when the LED on the left is off. But it doesn't.

If I take it from output 2, it is always off. I am trying to learn electronics as a hobby so I am not sure if there is something simple I am missing here. This is what my test circuit looks like when the output should be off.

enter image description here

The only thing I can think of right now is connecting two transistors together like a Darlington pair but I am not sure if that will work

Russell McMahon
  • 150,303
  • 18
  • 213
  • 391
  • 3
    "Output" 2 is just ground. Output 1 should should change from a couple hundred mV to nearly 5 V if the transistor is turning off properly and you're not loading it. Can you show a schematic of what you are hooking it up to and how? – John D Jul 10 '23 at 20:15
  • Do you mean the tinkercad schematic? – Yuki.kuroshita Jul 10 '23 at 20:20
  • There is only one output, 1 and 2 is terminals to connect wires or connector pins. – user263983 Jul 10 '23 at 20:24
  • Whatever schematic isn't working the way you think it is. Show the schematic, the voltages present and what you think they should be. – John D Jul 10 '23 at 20:24
  • That's not a schematic, but what's the voltage on the base of your transistor when you expect it to be off? – John D Jul 10 '23 at 20:33
  • 49.4mV. I added another schematic. I hope that is what you mean? I am sorry I am not understanding the instructions well enough. – Yuki.kuroshita Jul 10 '23 at 20:51
  • OK, thanks for adding the schematic. If the model for the LDR has it at a resistance of what looks like 100 Mohm, the transistor will never turn off. You can substitute a 100 ohm resistor for the LDR to model the device when the light is on, or if there's some kind of parameterization in the model, you should use that to look at the situation where the sensor is illuminated. – John D Jul 10 '23 at 21:23
  • If the base voltage is really 49.4 mV you should see something close to 5 V on the collector of the transistor. – John D Jul 10 '23 at 21:29
  • @johnd it is letter R, not M. LDRi is 100 Ohm – user263983 Jul 10 '23 at 22:32
  • OK, then what's the red circle connecting the collector and ground in the second schematic? – John D Jul 10 '23 at 22:37
  • That is an LED. Red means it is lit up – Yuki.kuroshita Jul 11 '23 at 00:58
  • By putting the LED there you're not allowing the transistor to interrupt the current to the other LED. – John D Jul 11 '23 at 01:16
  • What should the PISO do with signal from light sensor? – Michal Podmanický Jul 11 '23 at 01:37
  • @Yuki You will require hysteresis and positive feedback to create a digital signal. You may also have some difficulty with a potentiometer to set the light level (assuming you want one) such that it's knob ranges comfortably against human brightness sensation. If you don't need a potentiometer for this and will just be selecting things out of a variety of resistors until you get it right, then you can do that too. Probably will need two transistors. Maybe one more. – periblepsis Jul 11 '23 at 04:04
  • @periblepsis I did actually solve the problem with 2 transistors, like I mentioned in my question in a Darlington pair configuration. I will actually be shining a laser on these LDRs and if something blocks the light, I want it to output high. I have been testing with potentiometers such that this ignores ambient light and I think the pair I have right now works really well with my LDRs – Yuki.kuroshita Jul 11 '23 at 05:37
  • @JohnD thank you! I did remove the LED. It wasn't enough. I had to add another transistor, but even with two transistors, if I put the first LED in, the output wasn't good, so I removed it like you said and it worked. – Yuki.kuroshita Jul 11 '23 at 05:38
  • @MichalPodmanický there will be a bunch of these circuits which I will send to a raspberry pi which will then based on which circuits are outputting high do some stuff. – Yuki.kuroshita Jul 11 '23 at 05:40
  • @Yuki My mistake, then. I did not read far enough and spoke too quickly. It's an irradiation question and not an illumination one, I am now gathering. So does this really require much? LDRs are highly non-linear resistance devices that span over several orders of magnitude. Being more hesitant to reach too far yet, my question is this: How many magnitudes of difference is it between the highest levels of dark and the lowest levels of laser irradiation? Or you could just tell me in terms of the two values in Ohms at the LDR, I suppose (and some idea of device variations.) – periblepsis Jul 11 '23 at 05:47
  • @Yuki I don't mean to pry too much. And a simple BJT circuit certainly may work fine. I ask only because an even simpler circuit may be possible to consider depending on what you know and can say about the situation. – periblepsis Jul 11 '23 at 05:54
  • @periblepsis not a problem but I haven't really checked what the resistances are. I know that at the highest levels of dark, the resistance is close to 2M Ohms. I am using BJTs because that is the only kind of transistor I know how to use as of right now. – Yuki.kuroshita Jul 11 '23 at 06:07
  • @Yuki I'll suggest a circuit. – periblepsis Jul 11 '23 at 06:40

1 Answers1

8

Appropriate for your goal is a Schmitt trigger, providing hysteresis and a clean on/off indication. The following is a BJT version, based upon a long-tailed pair differential amplifier with added positive feedback. Feel free to ask questions if you want details.

schematic

This is a pretty standard diff-pair wired up with positive feedback and driving an output BJT into saturation to give a clean signal. (Known as a schmitt trigger.) I chose \$R_2=1\:\text{k}\Omega\$ because that's a reasonably low output impedance that should drive inputs okay. (Not sure, guessing there too. But the 74165 is the sterotype for 8-bit PISO.) Set it up so that draws about \$6\:\text{mA}\$ worst case (mostly to get the output impedance down.) Could lighten things up a bit (larger resistors) if a \$10\:\text{k}\Omega\$ output impedance is acceptable to you.

I split the difference evenly between what I computed for the sum of \$R_3\$ and \$R_4\$. But you can make some adjustments one way or another there.

\$R_6\$ is a little iffy to me. I'd tend to want to make it a bit larger. Maybe twice as much, or so. But experiment.

You can make a little picture of how it works. Think about the base for \$Q_1\$ and for \$Q_2\$ as the two teeter-totter seats with \$R_1\$ being the stand it rests on. Usually, this is operated as a very delicate balance. But in this case, just the opposite. Here, see \$R_4\$ as a bunch of weights that slide along its horizontal wire there. When the wire tilts one way, the weights slide along it towards the declining seat making it fall all the faster for it. Then it hits bottom and stops. The LDR, because of that added weight, has to pull still harder, one way or another, to upset things and start a reversal. The weights then shift back to the other side. And so it goes. Back and forth.

Here's a run in LTspice for the above, but using a larger value for \$R_6\$ so that it shows off the hysteresis better without needing a log-scale to do it:

enter image description here

Okay. I had to do it -- plot it in log-scale. I'll add it just because it shows what I'm doing with the LDR control voltage to get the results I wanted:

enter image description here

References

Since comments below suggest this might be uncovered in searches, I figure I should add the more important papers on the topic of bipolar transistors used in a similar (not exactly the same way) Schmitt topology. They are, in the order needed to follow them well:

  1. C. Ridders, "Accurate determination of threshold voltage levels of Schmitt trigger," in IEEE Transactions on Circuits and Systems, vol. 32, no. 9, pp. 969-970, September 1985, doi: 10.1109/TCS.1985.1085805
  2. S. D. Roy, "Comments on "Accurate Determination of Threshold Voltage Levels of a Schmitt Trigger," in IEEE Transactions on Circuits and Systems, vol. 33, no. 7, pp. 734-735, July 1986, doi: 10.1109/TCS.1986.1085979
  3. H. . -U. Lauer, "Comments on "Accurate Determination of Threshold Voltage levels of a Schmitt Trigger," in IEEE Transactions on Circuits and Systems, vol. 34, no. 10, pp. 1252-1253, October 1987, doi: 10.1109/TCS.1987.1086044
  4. M. J. S. Smith, "On the circuit analysis of the Schmitt trigger," in IEEE Journal of Solid-State Circuits, vol. 23, no. 1, pp. 292-294, Feb. 1988, doi: 10.1109/4.293

But I believe it's actually the last one from Smith that is most important and also the easiest to follow.

Like the others, Smith uses the variable definitions first created by Ridders. So it helps to at minimum have Ridders' paper at hand when reading Smith.

All of the papers find the two thresholds using a quadratic equation.

Smith's paper also shows how the same procedures he illustrates work across a variety of devices, including the BJT and CMOS. (The basic idea he points out is that switching thresholds occur when the loop gain is 1 -- though he doesn't explicitly say so, this is the so-called Barkhausen criterion.)

There are other papers that came over just a few following years. (Filanovsky and Piskarev come to mind.) But the above are the key ones I know about.

I suppose the above would not be complete without including a reference to Schmitt's paper:

  1. Otto H Schmitt, "A Thermionic Trigger," in Journal of Scientific Instruments, vol. 15, no. 1, pp. 24-26, 1938, doi: 10.1088/0950-7671/15/1/305

Note to AnalogKid

The Schmitt Trigger was adapted to solid state devices in the 1950's. Did it really take 30 years to realize that a transistor's beta affects how a circuit operates?

Here's an example of a BJT Schmitt trigger being used at SLAC circa 1964:

enter image description here

The above can be found in R. S. Larsen, "A Photomultiplier Phase-Sensitive Detector for the Optical Alignment System", TN-64-42, May 1964.

Earlier in the paper the author writes, "The Schmitt trigger and its phase splitter are conventional (Figure 5)." So the idea was already, by then, conventional.

Synopsis of Smith

Just a quick overview from the first page of Smith:

schematic

$$\begin{align*} v_r&=\frac1{K}\cdot\mathscr{F}\left(v_{id}\right), \text{where }v_{id}=v_i-v_r\tag{1} \\\\ \text{d}\:v_r&=\frac1{K}\cdot\text{d}\:\mathscr{F}\left(v_{id}\right) =\frac1{K}\cdot\frac{\text{d}}{\text{d}\: v_{id}}\:\mathscr{F}\left(v_{id}\right)\cdot\text{d}\: v_{id} \\\\ \therefore \frac{\text{d}}{\text{d}\:v_i}\:v_r&=\frac1{K}\cdot\frac{\text{d}\: v_{id}}{\text{d}\:v_i}\cdot\frac{\text{d}}{\text{d}\: v_{id}}\:\mathscr{F}\left(v_{id}\right) \\\\ &=\frac1{K}\cdot\left(1-\frac{\text{d}}{\text{d}\:v_i}v_r\right)\cdot\frac{\text{d}}{\text{d}\: v_{id}}\:\mathscr{F}\left(v_{id}\right)\tag{2}\label{eq2} \end{align*}$$

The point here is that switching occurs as \$\frac{\text{d}}{\text{d}\:v_i}\:v_r\to\infty\$. Direct re-arrangement of \$\ref{eq2}\$ yields the requirement: \$1+\frac1{K}\cdot\frac{\text{d}}{\text{d}\: v_{id}}\:\mathscr{F}\left(v_{id}\right)=0\$. (Note that when \$\frac{\text{d}}{\text{d}\: v_{id}}\:\mathscr{F}\left(v_{id}\right)=A\$ then it follows that \$K=-A\$ and if you follow that around the loop it's clear that the loop gain is +1 then, after taking into account the (-) terminal's 180-degrees.)

The above says that:

$$v_{id\pm}=\left(\frac{\text{d}}{\text{d}\: v_{id}}\:\mathscr{F}\right)_\pm^{-1}\left(-K\right)$$

This is a robust, generalized approach to analyzing a Schmitt trigger, regardless of its implementation (vacuum tubes, BJTs, CMOS, opamp, etc.) And it doesn't take much to get here.

So I have to assume those who've looked at and analyzed this question (certainly geniuses such as Schmitt and others since) must have reached this point on their own. I've just not found anything earlier than Smith. (And, it appears, neither did Smith nor the earlier three authors I've listed.)

periblepsis
  • 8,575
  • 1
  • 4
  • 18
  • 3
    +1 For adding the LTspice simulation, and for giving a suggestion for what transistors to use. As someone who has learned a lot of theory but is limited in practical experience it is very helpful when posts like these include actual existing components model numbers like 2N3906 and 2N2222. – Carl Jul 11 '23 at 07:36
  • 2
    @Carl I wanted to write about how to do the design itself, from scratch. But I am not sure the questioner cares enough to want to read it. So I just dove in, instead. And I'll take your point about providing part numbers more to heart. When and where possible it takes only a little effort and is worth a moment. – periblepsis Jul 11 '23 at 07:50
  • 4
    This particular question is very difficult, because OP doesn't have the necessary foundation for anything shorter than 1000 words to be useful to them. I for one am happy to see answers like this, regardless of whether OP appreciates or can even understand it, because I often find little gems that just didn't occur to me. R4/R5 for hysteresis, and the collector resistor replaced by a BE junction, very interesting little touches that I wouldn't otherwise have considered. Thanks! – Simon Fitch Jul 12 '23 at 00:29
  • It may be useful to use a trimpot at R6 to adjust for LDR on/off resistances. – Russell McMahon Jul 12 '23 at 00:46
  • 3
    Long long ago a site originator (Jeff I think) posted a statement of the main objectives of Q&A. Non verbatim - "Post quality question and answer sets that have a long lifetime and that drive search engine traffic to the site". That still applies, although I've not seen it stated anywghere since. This does that very well. And also makes the site technically attractive as an information source, which is what I like to see. – Russell McMahon Jul 12 '23 at 00:48
  • @RussellMcMahon I guess I'd appreciate knowing more about what about it makes you think this qualifies very well? (It's easier to do more if one has an idea of what was done right. ;) – periblepsis Jul 12 '23 at 01:00
  • 1
    I had to spend a day learning about feedback loops in circuits and why I want hysteresis. And I finally got time to make this circuit. Your seesaw analogy is cool and helped. thank you for the answer. I wanted to take my time understanding what you did before I came here and said anything. Thank you! Last time I learned about circuits was during my undergrad (almost a decade ago haha) so maybe some of these circuits which should make sense more easily takes a while. – Yuki.kuroshita Jul 12 '23 at 03:30
  • 1
    @periblepsis The comments by Yukki and Simon answer the question :-) . You gave far more than you thought Yukki may want to read. He read it, and appreciates the detail. Simon noted the length needed for a good answer - you exceeded it. I appreciated it. People "out there" wanting deeper knowledge than a brief solution are liable to find this. Pretty much win win win - except for the load on your resources :-) . || I used to post long detailed answers that were much appreciated. Of late as an admin I largely spend more time on attempting to help others. I miss giving my long answers :-). – Russell McMahon Jul 12 '23 at 04:01
  • @RussellMcMahon I should also have added the canonical capacitor across $R_4$ -- 100-200 pF or so. But so far as a trimpot goes, I just figure Yuki can swap around $R_6$ values or work out the trimming. I also like the win win win with the except added. A deeper truth buried in there. – periblepsis Jul 12 '23 at 04:47
  • @RussellM So I just added references that will allow the page to appeal to (and be found by) a still wider audience looking up the Schmidt trigger. I will be expecting a check in the mail. ;) – periblepsis Jul 13 '23 at 07:11
  • @periblepsis Sadly for you, I understand that Jeff Atwood left the company a few years ago. I suspect that nobody else will now own up to supporting that quote :-) – Russell McMahon Jul 13 '23 at 12:40
  • None of the references open without an account. – AnalogKid Jul 13 '23 at 12:58
  • 2
    @AnalogKid Yeah. I can't change that part of the world, unfortunately. At least I've provided the necessary information of the key papers. That alone will save time. And for those without access, use a local library or else whatever works as sci-hub access. The doi's will work fine with sci-hub. And a search engine might also find something at a university. I've not tried to go to that extent. It's sufficient to provide the standard references, I think. – periblepsis Jul 13 '23 at 13:05
  • Thanks for trying. Separate from that, and based solely on the article abstracts, I'm surprised that IEEE was publishing articles analyzing a relatively simple circuit 50 years after its invention. The Schmitt Trigger was adapted to solid state devices in the 1950's. Did it really take 30 years to realize that a transistor's beta affects how a circuit operates? Again, I haven't read the articles and seen the equations. Just wondering . . . – AnalogKid Jul 13 '23 at 15:15
  • @AnalogKid I was also surprised. I started out restricting my literature search to the 1950s and 1960s. Only after widening the period did I find them. I did find many cases, masters degree papers even and various instrumentations, showing their use this way. So not because of lack of awareness. Just interest. Bigger fish to fry, perhaps? – periblepsis Jul 13 '23 at 16:33
  • @AnalogKid The earlier designs did not show a consistency to their topologies. But obviously by the 1980s there was no longer any doubt. Because no one argued for another pattern and as you can see everyone was willing to argue over this pattern. So it had settled into concrete by then. – periblepsis Jul 13 '23 at 16:39
  • @AnalogKid I added something from Smith on the page. Just in case it helps any. – periblepsis Jul 15 '23 at 05:04
  • I there a way to DM on this site? – AnalogKid Jul 15 '23 at 15:03
  • @AnalogKid Do you mean the chat system here? Or email? – periblepsis Jul 15 '23 at 21:58
  • Private conversation. Other forums have a "conversation" feature that is private but within the site so personal emails are not needed. – AnalogKid Jul 16 '23 at 04:10
  • @AnalogKid I see. The EESE chat is public. And email means personal emails are needed. Without exchanging some kind of personal identifier, the only place I can think of right now is IRC chat. One can then just drop into a private channel. Old technique. Maybe dying these days. But it is what comes to mind. – periblepsis Jul 16 '23 at 04:16
  • @periblepsis for such a marvelous answer, you might consider rewriting the opening paragraph, which doesn't do justice to what follows -- positively undersells it, in fact. – jonathanjo Jul 18 '23 at 08:16
  • @jonathanjo Perhaps it undersells. But it's true. I did just quickly 'run around a KVL loop' and calculate parts for it about as fast as I could. I've not subjected it to any of the analysis I later discuss. I even just 'split the difference' with two resistors when I knew darned well I probably could have done better. I'd have to go back and actually do some work if I wanted to make the quality of that schematic better match the rest of what I later added. And if I did that, then I'd need to write about that, as well. So it would just be more work. When the site sends me that check ... ;) – periblepsis Jul 18 '23 at 08:49
  • @periblepsis perhaps just "What you need is a Schmitt trigger circuit." as an opening para. – jonathanjo Jul 18 '23 at 09:08
  • @jonathanjo Since I don't have a strong opinion and as you seem to, I guess I could step it down to something like that. I'll try something along the direction I think you are casting at. I like the fact that you are suggesting giving it the right name at the outset. – periblepsis Jul 18 '23 at 09:12
  • 1
    @jonathanjo See if what I added is less upsetting... :) – periblepsis Jul 18 '23 at 09:18
  • 1
    @periblepsis excellent! I'll see if I can negotiate that cheque for you now. – jonathanjo Jul 18 '23 at 09:19
  • @jonathanjo You too? It's enough that Russel wants the search engines getting hits so that EESE can profit more. Now you? ;0 – periblepsis Jul 18 '23 at 09:19
  • 1
    @periblepsis it's not the hits I was trying to increase, it was the people finding your answer before they find any one of the other descriptions about how these work. – jonathanjo Jul 18 '23 at 09:21
  • @jonathanjo Okay. :) You are just thinking about their mental health. Sweet. – periblepsis Jul 18 '23 at 09:23