2
\$\begingroup\$

I built a SR flip-flop circuit according to this schematic with two NPN transistors:

SR Flip-flop with transistors

I read that the initial state of such a flip-flop is undefined. I observed that in my test circuit it's always the green LED that's powered initially, even if I exchange the red and the green LED.

How can the initial state of such a flip-flop be set?

\$\endgroup\$
2
  • 2
    \$\begingroup\$ For such a simple circuit you can set "initial conditions" by adding for example a small capacitor parallel to base-emitter junction. For example if you add a 1nF capacitor across S1 switch. And this change will ensure that Q2 will always turn on first. \$\endgroup\$
    – G36
    Commented Apr 10, 2016 at 8:02
  • \$\begingroup\$ @G36 Indeed. With a capacitor over S1, that switch will appear closed for a while when the power is turned on. This is called setting an initial value. In fact, each switch will act as a small capacitor, when open, anyway, but the largest capacitor will of course 'win', if the remainder of the circuit is symmetric. Here the LED's are different color, so will have a different forward voltage, which explains the current startup preference observed. In case of identical LED's, also consider light shining INTO the LED's :-) \$\endgroup\$
    – Roland
    Commented Dec 27, 2023 at 1:44

3 Answers 3

4
\$\begingroup\$

It's actually non-trivial to ensure you always get the same state, unless you make assumptions about how the power comes up and goes down. Something like an added capacitor across one of the transistors will work most of the time if the power on/off follows rules as to how long it's off before it comes on again and how long it takes to rise (maximum rise time), but that may not be good enough if you care about reliability.

One way to ensure that the power-up state is what you want is to use a supervisory chip that has a comparator, a reference and a timer. For example, for a 5V system you could use an APx803. You should pick the minimum reset voltage threshold to be a voltage at which your circuit is guaranteed to operate, and ensure your circuit won't do anything undesirable below the worst-case validity level (1.0V in this case).

enter image description here

This particular chip I've selected has an open-drain output, so you can simply connect the output to a transistor collector or base to hold the transistor off, and the other transistor on. The timer is 2ms or 200ms nominal depending on the model, so the FF will not respond to switches during that window after the power reaches a valid level.

You could also make something like this from discrete parts or chips, but the requirement that the output be valid at very low supply voltage makes it a bit more challenging.

A crude method, used in some consumer goods, would be a couple transistors (BJTs) and resistors (maybe a diode or zener) that act as the comparator, which eschews the nice timed reset pulse, but is probably good enough in this case (if you had more than one FF that had to be initialized it might not be- because the reset pulse might be a runt that only reset some circuits and not others). Here is an example from Maxim of this kind of circuit (you'd probably want to add another transistor that is off when the power is good):

https://www.maximintegrated.com/en/images/appnotes/279/279Fig02.gif

\$\endgroup\$
0
5
\$\begingroup\$

I suggest you attach an ammeter to each LED leg (one at a time if you only have one) and it might become clear what's happening.

In short, the green LED will have a higher forward voltage, so the red LED will flow more current (resistors are the same value) and turn on the green LED side's transistor first.

If you use the same color (preferably the same part number, from the same lot) it might become more "undefined" (or not, given part-to-part variations.)

\$\endgroup\$
2
  • \$\begingroup\$ Ok, and how can I make sure that I always have a specific initial state? (Assuming I'd use the same LED's) \$\endgroup\$
    – x-ray
    Commented Apr 10, 2016 at 2:59
  • \$\begingroup\$ You already did that, according to your question...you could also use different resistor values, for instance, to favor tuning on one transistor before the other. \$\endgroup\$
    – Ecnerwal
    Commented Apr 10, 2016 at 3:00
0
\$\begingroup\$

Look at this circuit :( flip flop experiment ) It is very easy to do , let's say you allways want X (collector of Q2 ) to be high by default when power is supplied, just add a 0.47uF or 1uF capacitor C1 from base of Q2 to ground. This will ensure that Q1 will always turn on before Q2 thus allowing X to be allways "high" and Y "low" initially by default when power is first supplied.flip flop experiment

\$\endgroup\$
1
  • \$\begingroup\$ They do have a circuit drawing tool when answering \$\endgroup\$
    – Voltage Spike
    Commented Jun 28, 2021 at 1:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.