Make BJT FF remember its state?

Discussion in 'General Electronics Chat' started by Mike33, Jan 24, 2014.

  1. Mike33

    Thread Starter AAC Fanatic!

    Feb 4, 2005
    349
    25
    Here's one for the transistor gurus!

    I've got a BJT flip flop circuit I've been playing with....2 NPNs, and 2 PNPs. The PNPs are driving 2 LEDs. Nothing fancy.

    This is so my father in law (the railroad buff!) can switch tracks using a DPDT toggle (center off), and have an indicator light for which way the tracks are now set.

    Ok, doing this is easy. BUT - REMEMBERING which light should start "ON' - that is not so easy! There is no electrical connection between the switch machine or tracks and this circuit. I'm thinking I may HAVE to provide one or this may prove impossible.

    Any suggestions on how to force one LED to be high at power-up? :confused:

    Thanks!
     
  2. k7elp60

    Senior Member

    Nov 4, 2008
    478
    69
    You can do a power up reset. If you post a schematic of your f/f circuit I am sure someone can help youl
     
  3. crutschow

    Expert

    Mar 14, 2008
    13,003
    3,232
    You have to provide continuous power for such a FF to remember its state. This requires a fair amount of current with BJTs but only leakage current if you do it with CMOS, thus a battery will retain the memory state typically for well more than a year if there's no other load. You could use a CMOS FF such as a CD4013. But you must do the circuit such that the LED does not draw power from the battery when the train circuit is off.

    If you have no electrical connection between this circuit and the switch or track then how do you trigger the state of the FF. There has to be some connection. :confused:
     
  4. Brownout

    Well-Known Member

    Jan 10, 2012
    2,375
    998
    It's possible to create a mechanical flip-flop that should remember its state. I don't know all the details, but I've seen them created with Lego mindstrom. Goolge might help here.
     
  5. Mike33

    Thread Starter AAC Fanatic!

    Feb 4, 2005
    349
    25
    Ok, here is a schematic of what I have so far. It works wonderfully by using a switch to take either base H momentarily, and thus flip the flop, so to speak.

    The FIL (father in law) wants to use DPDT toggle switches, spring return to center off, for this application (since he went out and bought them already :( ) One pole will provide power to the switch machine for a moment (470u cap there will make it do its whole travel). Leaving one pole for indicator lights.

    Since it's a return to center-off switch, I am left with the dilemma of using a FF to keep a light on (call it "Left" and "right" indicator) to show which position the switch machine is in. There is no connection between the 2 circuits....the switch will control 2 separate circuits. I CAN probably 'inject' the voltage from the switch machine to various places in my FF, though...the polarity will reverse if switching L > R, or R> L, offering at least SOMETHING to retain the FF state.

    I just don't know where to 'inject' that voltage to hold it there.....

    [​IMG]
     
  6. inwo

    Well-Known Member

    Nov 7, 2013
    2,433
    315
    I'm not seeing how Q2 turns on.

    Are you just using switch as a DPST?

    One pole to send a pulse to track control. (toggles)?

    One pole to send pulse to indicator circuit. (switches red to green)?

    Or are you trying to do a set-reset with one base connection not shown?
     
  7. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,361
    You need to somehow make a connection from the switch or track to your flip/flop.
    Any ideas how you propose to do this?
    Can you make use of optocouplers?
     
  8. inwo

    Well-Known Member

    Nov 7, 2013
    2,433
    315
    I agree at this point.

    Except, a connection would make the ff not necessary.

    Any switch bounce would get it out of sequence.

    Still not sure I follow the scheme.:confused:
     
  9. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,797
    1,103
    How about this?
    Cross-coupled NAND gates of the 4093 form a latch which is set or reset according to which direction the centre-off switch (half of the DPDT) is moved. The gates are parallelled to boost their output current source capability. Only if track volts are present does Q1 turn on to enable one or other LED to light, thus ensuring virtually zero current draw from the 9V battery when there is no track power.
     
  10. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,387
    1,605
    Switch bounce is not an issue with this circuit; essentially the circuit IS a switch debouncer already.

    Schematic in post #5 looks fine, assuming the FF side of the switch is center connected to V1, and each pole drives a transistor.

    As far as the initial state, what is going on with the tracks themselves when the points move? Does one (or more) rail change voltage or get connected when the points move? That can either provide the starting state... or possibly eliminate the need for the FF altogether.
     
  11. John P

    AAC Fanatic!

    Oct 14, 2008
    1,634
    224
    The idea of a CMOS chip with battery backup is a good one, or you could use a microcontroller with internal EEPROM and store the state there. Or rig up contacts on the turnout motor (if it doesn't already have them) and do the wiring to bring the information back to the control logic.
     
  12. Alec_t

    AAC Fanatic!

    Sep 17, 2013
    5,797
    1,103
    Here's a mod of the post #5 circuit, enabling higher LED current. The LEDs draw power from the track supply, thus prolonging the 9V battery life.
     
  13. inwo

    Well-Known Member

    Nov 7, 2013
    2,433
    315
    The most puzzling to me is:
    There is no connection from switch/ff to track.
     
  14. Mike33

    Thread Starter AAC Fanatic!

    Feb 4, 2005
    349
    25
    Great ideas! Thanks a lot. I think it's either going to be the NAND setup above, or he's going to have to run some wiring back to his control panels (the simpler, mechanical route). The FF works, and does its job well, but to give it memory is simply the same as running a wire out to the switch machine....it's pretty cheap and time-saving to make it two wires, and do the LEDs the old fashioned way!

    The switch machines have switch terminals as well as a mechanical function to move the tracks, so there is a golden opportunity to just use them, run some light phone wire, and call it good! He'll balk, but after I show him what the deal is, I think he might 'get it'...to do all the 'fun stuff' costs money, for latching relays and things like that. Sometimes, KISS is much easier!!


    >>>PS - the connection to the other base is ASSUMED...can't have 'em both in LT Spice if you want to see an output! So I only made one H to assure myself that the schematic works. Then built it, and it is 100% functional and reliable. That is why I made the notation about making either base H....
     
  15. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    It certainly would be easier to use a latching relay with dual coils, as that's basically what the switch machine is; the latching relay would maintain it's state indefinitely without any power whatsoever.

    Here's a suitable candidate:
    http://www.mouser.com/search/Produc...=655-V23079B1203B301&utm_term=V23079B1203B301
    Datasheet: http://www.mouser.com/ds/2/418/NG_SS_108-98002_W_P2-196265.pdf

    This is assuming that your supply voltage is >9v, and < 26v; as the relay's coils are rated for 12v, and nominally around 1k Ohm in resistance. You could add a series limiting resistor if desired to limit the supply voltage to 12v, but the switching time would normally be very short. You should also use either a diode, a resistor or both in series across each coil to take care of the reverse EMF when the switch is opened, otherwise the switch contacts will burn up much more quickly.

    [edit]
    It would be even more simple to use the switch contacts on the switch machine itself, however you're getting into running LOTS of wire everywhere, which could lead to maintenance problems - not to mention just getting everything working in the first place. The cost of wire has skyrocketed in the past few years.
     
  16. crutschow

    Expert

    Mar 14, 2008
    13,003
    3,232
    You can put as many switches as you want in LTspice (or other Spice programs).
     
  17. inwo

    Well-Known Member

    Nov 7, 2013
    2,433
    315
    Can you post a diagram of the connection from DPDT switch to "track switch"?

    That will clear things up.

    If there are connections, 2 or 3 wires, then there should be a simple way for a dc telemetry system to send back information to an led.

    Sorry for being slow. The others seem to get it.:p
     
  18. Mike33

    Thread Starter AAC Fanatic!

    Feb 4, 2005
    349
    25
    ...and thanks again! Drawing of the idea...I am not sure how he connects his sw.machine, so the center pole of the switch is to be determined (+ or - ). You can see what I mean, they are 2 separate switch functions, which is why the trouble with making sure the FF can remember where the switch machine is.

    [​IMG]

    I did look into latching relays...at $3 each, and we need 10, ouch! Altho they would eliminate the transistors and allow one to use only the LEDs...worth considering...

    No clue how to make a switch operate in LT Spice, ha ha...I usually just hard wire something and pretend 'the switch is closed'. Generally I'm doing audio electronics where that's not a factor...
     
  19. ian field

    Distinguished Member

    Oct 27, 2012
    4,415
    783
    IIRC - you just need an imbalance in the base bias resistor, one of the transistors will turn on just that little bit quicker than the other at power up, with symmetrical component values that will be determined by a combination of component tolerances and transistor gain spreads. A gross imbalance will determine which transistor saturates at power up.
     
  20. inwo

    Well-Known Member

    Nov 7, 2013
    2,433
    315
    Thanks a lot.

    That was not the way I understood it.

    I'll bet you will get some good suggestions now.

    Very interesting project.

    So there are 3 wires to "switch machine", and three to ff . Counting the common.

    Makes it much simpler to understand.
     
Loading...