Shop OBEX P1 Docs P2 Docs Learn Events
Momentary Power Button Circuit/ Single D flip flop question — Parallax Forums

Momentary Power Button Circuit/ Single D flip flop question

groggorygroggory Posts: 205
edited 2010-10-07 14:59 in Propeller 1
Could you guys verify that this circuit makes sense? I don't have time to proto it up first and will be committing it to PCB.

http://www.discovercircuits.com/H-Corner/on-off-switch.htm

I don't have a very good understanding of how the Single D positive edge flip flop works. :-/

If anyone could explain how that chip (sn74lvc1g79) works that would be even better! It looks neat but I need a teacher here.

Thank you.

Comments

  • WBA ConsultingWBA Consulting Posts: 2,935
    edited 2010-10-06 17:13
    I don't know the simple way to explain this completely, but if i recall correctly from my digital class in 1998......
    The flip flop output (Q) is being changed by the button push since the input (D) will be in the opposite state of that output. So, when off, Q will be low which is inverted by Q1 making the input D high. Pushing the button will drive the output (D) high to match the input and will turn on Q2. With the output high, the input is low, so the next button push will cause the output to go low, turning off Q2.

    Check out the function table on page 2 of the datasheet:
    http://focus.ti.com/general/docs/lit/getliterature.tsp?genericPartNumber=sn74lvc1g79&fileType=pdf
    You can see that if D is the opposite of Q (output) it will change states with each clock cycle (in this design, a button push/release is the "clock cycle")

    Before making your own, have you seen the equivalent from Pololu? I don't know how they claim it to be "patented" but it's a nice one.
    http://www.pololu.com/catalog/product/751
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-10-06 17:16
    I see one potential source of trouble. The chip's datasheet specs:

    Δt/ΔV input transition rise and fall rate @VCC = 2.7 V to 5.5 V = 10 ns/V maximum.

    The clock input is being pulled up with a 1M resistor to discharge a 0.1uF cap. With its 100 ms time constant, that rise rate is well above 10ns/V.

    Obviously, you need some debouncing on an edge-triggered input. The preferred method of doing this would interpose a Schmitt trigger between the RC circuit and the clock input, thus guaranteeing a snap action rise on the clock signal.

    -Phil
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-10-06 22:32
    Phil,

    first post for quite a while....

    The rise time is only a problem with metastability and possible noise on the outputs but for this application it doesn't matter. A simpler way would be to just have the button turn on the MOSFET directly and then have the Prop lock it on. There is a minimum amount of time that the button needs to be pressed though until the Prop has booted. That way the Prop can turn the power back off when it's ready or else it can sense the state of the button for manual turnoff.

    A small SOT-23 PIC is also a clean and foolproof way to do it.
    (I don't know what could be possibly "patented" about the simple Pololu circuit though, just looks like a regular PIC micro programmed to debounce and toggle, duh.)
  • jmgjmg Posts: 15,185
    edited 2010-10-07 02:27
    groggory wrote: »
    Could you guys verify that this circuit makes sense? I don't have time to proto it up first and will be committing it to PCB.

    http://www.discovercircuits.com/H-Corner/on-off-switch.htm

    I don't have a very good understanding of how the Single D positive edge flip flop works. :-/

    If anyone could explain how that chip (sn74lvc1g79) works that would be even better! It looks neat but I need a teacher here.

    Thank you.

    It's a start, but you should flip to this similar device

    http://ics.nxp.com/products/lvc/datasheet/74lvc1g74.pdf

    Why ?

    It Eliminates R2,R3,C2,Q1 as it has a /Q pin, and the NXP data says

    "Schmitt trigger action at all inputs makes the circuit highly tolerant of slower input rise and
    fall times."

    so that means it will tolerate the slow clock rise.

    It is also good practice to add a series R to the switch, so you do not short the cap C1 - that can corrode the switch faster.
  • rokickirokicki Posts: 1,000
    edited 2010-10-07 09:57
    I swear one of my devices (a dry and store for a cochlear implant) uses this circuit for on/off. The reason I suspect this is, every time I press the power button, it's a random coin flip as to whether the device turns on or off. No debouncing of the switch!

    It's very instructive to wire something like this up, grab a scope, figure out what's wrong, and then try different fixes. (Eventually you realize this is only a small part of a much larger circuit, and then you finally end up replacing the whole circuit with a single propeller chip with the switch feeding an input pin and do all the debouncing, etc. in software.)
  • groggorygroggory Posts: 205
    edited 2010-10-07 13:20
    rokicki wrote: »
    I swear one of my devices (a dry and store for a cochlear implant) uses this circuit for on/off. The reason I suspect this is, every time I press the power button, it's a random coin flip as to whether the device turns on or off. No debouncing of the switch!

    It's very instructive to wire something like this up, grab a scope, figure out what's wrong, and then try different fixes. (Eventually you realize this is only a small part of a much larger circuit, and then you finally end up replacing the whole circuit with a single propeller chip with the switch feeding an input pin and do all the debouncing, etc. in software.)

    I think I'll program up a pic to do some switch functions like this for me then have the pic control some mosfets and indicator LEDs. That's probably the real way to go. Discreet logic is just so set in stone compared to software.
  • rokickirokicki Posts: 1,000
    edited 2010-10-07 13:46
    Eh, it's not that hard actually. A simple bistable multivibrator two-transistor circuit
    with the right caps does this handily. Try and figure it out yourself first; it's not
    too hard and can be gratifying.

    If you don't know about the standard cross-coupled transistor multivibrator circuits,
    do a simple google search to see what you can do.
  • groggorygroggory Posts: 205
    edited 2010-10-07 14:59
    rokicki wrote: »
    Eh, it's not that hard actually. A simple bistable multivibrator two-transistor circuit
    with the right caps does this handily. Try and figure it out yourself first; it's not
    too hard and can be gratifying.

    If you don't know about the standard cross-coupled transistor multivibrator circuits,
    do a simple google search to see what you can do.

    Got it.

    http://www.electronics-tutorials.ws/waveforms/bistable.html

    http://www.electronics-tutorials.ws/waveforms/tim17.gif
Sign In or Register to comment.