Logic Toggle Latch

From circuitbending to homebrew stompboxes & synths, keep the DIY spirit alive!

Moderators: lisa, luketeaford, Kent, Joe.

tardishead
Wiggling with Experience
Posts: 311
Joined: Sat Aug 03, 2013 3:00 pm
Location: London

Logic Toggle Latch

Post by tardishead » Thu Mar 26, 2020 12:59 pm

I need to build a simple toggle latch
What is the easiest way?
I thought use a 4027 JK Flip flop - short J and K inputs and connect clk to V+ if I don’t need it clocked?

User avatar
EATyourGUITAR
has no life
Posts: 4867
Joined: Tue Aug 31, 2010 12:24 am
Location: Providence, RI, USA

Re: Logic Toggle Latch

Post by EATyourGUITAR » Thu Mar 26, 2020 3:51 pm

CD4013 with the not Q connected to data input. clock input is your button or your input. Q OUT is your output. use the Set and Reset pins if you need a reset button in a specific state.
WWW.EATYOURGUITAR.COM <---- MY DIY STUFF

tardishead
Wiggling with Experience
Posts: 311
Joined: Sat Aug 03, 2013 3:00 pm
Location: London

Re: Logic Toggle Latch

Post by tardishead » Thu Mar 26, 2020 4:24 pm

EATyourGUITAR wrote:
Thu Mar 26, 2020 3:51 pm
CD4013 with the not Q connected to data input. clock input is your button or your input. Q OUT is your output. use the Set and Reset pins if you need a reset button in a specific state.
Great thanks
So I presume I should buffer the output with a transistor?

User avatar
EATyourGUITAR
has no life
Posts: 4867
Joined: Tue Aug 31, 2010 12:24 am
Location: Providence, RI, USA

Re: Logic Toggle Latch

Post by EATyourGUITAR » Thu Mar 26, 2020 9:40 pm

I left out all the details. you should definitely make all the buffers, protections, level shifters that you need for your specific application. I would rather point you in the right direction. there is more than one way to do it correctly. I use opamp comparators on the output because I desire a +/-5v signal always. this is a standard I use in my personal system and also the modules that I sell. sometimes I use +12/0v for the power supply to the 4013. but sometimes I use +5v/-5v single supply. the reference voltage on the comparator is different for each version even though it is basically the same. if you want +12v/0v logic output levels then you only need to protect against someone patching a -12v DC offset (any negative DC offeset actually) to your output that is low impedance, you should have a reverse shunt diode + resistor or a series diode. the transistor buffer prevents the CD4013 from getting hot or damaged by a load. the diode protects from some things but the resistor is needed to protect the schottky diode when it is shunt. the single transistor buffer also inverts the logic so Q becomes NOT Q and NOT Q becomes Q.
WWW.EATYOURGUITAR.COM <---- MY DIY STUFF

KSS
Super Deluxe Wiggler
Posts: 2482
Joined: Mon Jan 25, 2016 7:28 am

Re: Logic Toggle Latch

Post by KSS » Fri Mar 27, 2020 12:25 am

tardishead wrote:
Thu Mar 26, 2020 12:59 pm
I need to build a simple toggle latch
What is the easiest way?
I thought use a 4027 JK Flip flop - short J and K inputs and connect clk to V+ if I don’t need it clocked?
Search for transistor flip flop or multivibrator. 2 trannys and a few resistors. You'll want a mono or bistable type multivibrator. AKA F-F

ARP2600 or TTSH schematic for the electronic switch. Leave off the FETs if you only need logic levels.

There's also one in most discrete ADSR EGs.

tardishead
Wiggling with Experience
Posts: 311
Joined: Sat Aug 03, 2013 3:00 pm
Location: London

Re: Logic Toggle Latch

Post by tardishead » Fri Mar 27, 2020 5:32 am

I found this circuit. Forgive my ignorance - it will turn on with a trigger but will it turn off with the next trigger?
Image

User avatar
Graham Hinton
Super Deluxe Wiggler
Posts: 3245
Joined: Fri Jul 02, 2010 6:28 pm
Location: England
Contact:

Re: Logic Toggle Latch

Post by Graham Hinton » Fri Mar 27, 2020 7:26 am

tardishead wrote:
Fri Mar 27, 2020 5:32 am
I found this circuit. Forgive my ignorance - it will turn on with a trigger but will it turn off with the next trigger?
No, its two inverting switches in a loop so it latches the input state. It will be turned on with a high and off with a low and holds its state if the input is open. Actually the low is <0V, rather than 0V, as the 10k/22k potential divider will have +12V when the output is on and you have to get the base of the first transistor <0.7V.

Are you trying to toggle a signal or a switchbutton? There are differences.

User avatar
msboude
Wiggling with Experience
Posts: 298
Joined: Mon Nov 21, 2016 6:22 pm

Re: Logic Toggle Latch

Post by msboude » Fri Mar 27, 2020 11:35 am

Fire up the ol' breadboard!

You will want to google switch debounce/trigger. Once you get the switch/trigger going, you will send that I to your 4013 clock input. Ground set and reset. Connect Q/ out to data. Q is your output.

If you want the 4013 to start up in a known state, you can throw a power-on-reset capacitor and resistor on the set or reset input. A 1uf cap with + on the 12v and - on either set or reset will do this. You will need a resistor from that pin to ground.. 10k works.

User avatar
EATyourGUITAR
has no life
Posts: 4867
Joined: Tue Aug 31, 2010 12:24 am
Location: Providence, RI, USA

Re: Logic Toggle Latch

Post by EATyourGUITAR » Fri Mar 27, 2020 11:40 am

msboude wrote:
Fri Mar 27, 2020 11:35 am
If you want the 4013 to start up in a known state
I never had that problem. just test it. it should be the same result every time.I believe it powers on in the reset state. you only need to add a cap if you want it to turn on in SET state. that would be pointless however since you can use Q or NOT Q outputs. you can swap them around for the other pseudo state.
WWW.EATYOURGUITAR.COM <---- MY DIY STUFF

User avatar
msboude
Wiggling with Experience
Posts: 298
Joined: Mon Nov 21, 2016 6:22 pm

Re: Logic Toggle Latch

Post by msboude » Fri Mar 27, 2020 11:53 am

It's a race condition at startup on 4013.

User avatar
msboude
Wiggling with Experience
Posts: 298
Joined: Mon Nov 21, 2016 6:22 pm

Re: Logic Toggle Latch

Post by msboude » Fri Mar 27, 2020 11:59 am

Maybe I'm wrong because of Q/ to data.. but...

tardishead
Wiggling with Experience
Posts: 311
Joined: Sat Aug 03, 2013 3:00 pm
Location: London

Re: Logic Toggle Latch

Post by tardishead » Fri Mar 27, 2020 1:09 pm

Graham Hinton wrote:
Fri Mar 27, 2020 7:26 am
Are you trying to toggle a signal or a switchbutton? There are differences.
I want to use a trigger to toggle between 2 states, a continuous high and continuous low.
4017 is another way of doing it right? Just reset on the 3rd count so it toggles between 2 positions, take the output from one position.

User avatar
msboude
Wiggling with Experience
Posts: 298
Joined: Mon Nov 21, 2016 6:22 pm

Re: Logic Toggle Latch

Post by msboude » Fri Mar 27, 2020 1:18 pm

Yep

User avatar
msboude
Wiggling with Experience
Posts: 298
Joined: Mon Nov 21, 2016 6:22 pm

Re: Logic Toggle Latch

Post by msboude » Fri Mar 27, 2020 2:40 pm

never mind.. the more I thought about it, the more I realized what I posted won't work.

User avatar
Graham Hinton
Super Deluxe Wiggler
Posts: 3245
Joined: Fri Jul 02, 2010 6:28 pm
Location: England
Contact:

Re: Logic Toggle Latch

Post by Graham Hinton » Fri Mar 27, 2020 3:40 pm

tardishead wrote:
Fri Mar 27, 2020 1:09 pm
I want to use a trigger to toggle between 2 states, a continuous high and continuous low.
4017 is another way of doing it right?
4017 is another bad way of doing it. Either a D-type or J-K flip flop will toggle, but if you are driving it from triggers they will need cleaning up to prevent multiple toggles. If you want it to power up in a known state you need a power up reset circuit to the set or reset pins.

You need to define what constitutes a trigger to distinguish from spurious pulses. How long should it be as a minimum and maximum? Should it be the leading edge of a Gate?

There are an awful lot of comments here from people who don't know the basics of good logic design.
EATYOURGUITAR wrote:it should be the same result every time.I believe it powers on in the reset state.
File that with belief in the Tooth Fairy. Any single instance will probably behave the same under the same conditions, but that is no guarantee that any other one will or one that you buy years hence will. If the data sheet doesn't say that it powers up a certain way then it doesn't. A glance at the data sheet will reveal that it doesn't. Another glance will reveal a truth table that shows what happens when both Set and Reset are active at the same time and that using complimentary outputs is not the same as using one and inverting it.

Never base any design on any undocumented features of an IC. I know people who have lost their shirts from doing that. One day the wind will change direction and your circuit won't work. You will just be staring at a little black lump of epoxy and there will be nothing you can do to make it conform to your belief system. That's tough when you have 100 circuits ready to ship.
msboude wrote:Here is a debounced trigger circuit.. I don't have an oscilloscope in front of me..
No, it's a tone burst oscillator. If you had your oscilloscope you would see a burst of oscillation as the capacitor charges through the switching point.

A Schmitt trigger is required, discrete or integrated, to prevent this.

KSS
Super Deluxe Wiggler
Posts: 2482
Joined: Mon Jan 25, 2016 7:28 am

Re: Logic Toggle Latch

Post by KSS » Fri Mar 27, 2020 4:12 pm

tardishead wrote:
Thu Mar 26, 2020 12:59 pm
I need to build a simple toggle latch
What is the easiest way?
Better questions get better answers. What are you actually trying to do?

In the meantime, Chapters 4 and 5 of Lancaster's "CMOS Cookbook", available online as a free PDF, goes into many details and considerations.

User avatar
msboude
Wiggling with Experience
Posts: 298
Joined: Mon Nov 21, 2016 6:22 pm

Re: Logic Toggle Latch

Post by msboude » Fri Mar 27, 2020 4:33 pm

msboude wrote:Here is a debounced trigger circuit.. I don't have an oscilloscope in front of me..
No, it's a tone burst oscillator. If you had your oscilloscope you would see a burst of oscillation as the capacitor charges through the switching point.

A Schmitt trigger is required, discrete or integrated, to prevent this.




Yeah, I just got home and tried it out... sounded good in my head. Haha! Thanks Hinton.

User avatar
msboude
Wiggling with Experience
Posts: 298
Joined: Mon Nov 21, 2016 6:22 pm

Re: Logic Toggle Latch

Post by msboude » Fri Mar 27, 2020 5:30 pm

Capture.JPG
You do not have the required permissions to view the files attached to this post.

User avatar
msboude
Wiggling with Experience
Posts: 298
Joined: Mon Nov 21, 2016 6:22 pm

Re: Logic Toggle Latch

Post by msboude » Fri Mar 27, 2020 5:58 pm

Here you go!

This will have your output low at startup.

4013.png
You do not have the required permissions to view the files attached to this post.

User avatar
msboude
Wiggling with Experience
Posts: 298
Joined: Mon Nov 21, 2016 6:22 pm

Re: Logic Toggle Latch

Post by msboude » Fri Mar 27, 2020 6:18 pm

Gunna want an output..

This will give you a 10v gate/trigger

Trying to work and post.. ns7 should be ground obviously.

[attachment=0]40132.png[/attachment
You do not have the required permissions to view the files attached to this post.

User avatar
cackland
Super Deluxe Wiggler
Posts: 2069
Joined: Thu Dec 28, 2017 5:42 pm
Location: Los Angeles, California

Re: Logic Toggle Latch

Post by cackland » Fri Mar 27, 2020 7:01 pm

Is this what you're after?

http://tinyurl.com/u2huwmp

User avatar
Flounderguts
Wiggling with Experience
Posts: 472
Joined: Thu Dec 07, 2017 5:56 pm
Location: SLC

Re: Logic Toggle Latch

Post by Flounderguts » Fri Mar 27, 2020 9:32 pm

cackland wrote:
Fri Mar 27, 2020 7:01 pm
Is this what you're after?

http://tinyurl.com/u2huwmp
Oh! I had fun clicking that on and off for a few minutes.
----------------------

Flounderguts

tardishead
Wiggling with Experience
Posts: 311
Joined: Sat Aug 03, 2013 3:00 pm
Location: London

Re: Logic Toggle Latch

Post by tardishead » Sat Mar 28, 2020 3:47 am

KSS wrote:
Fri Mar 27, 2020 4:12 pm
Better questions get better answers. What are you actually trying to do
Ok sorry I thought I had explained this.
tardishead wrote:
Fri Mar 27, 2020 1:09 pm

I want to use a trigger to toggle between 2 states, a continuous high and continuous low.
Certain functions require a continuous high voltage to turn on
Reverse function on a sequencer
Activate serge bi directional switch
A few others can't remember
At the moment I only have long envelopes to do this - not ideal because they end and switch reverts
I want a circuit where you can send it a gate or trigger and it will toggle between high and low continuous outputs.

I hope that's clear now. I have a selection of CGS logic modules - maybe this can be done with a combination of what I already have!

User avatar
msboude
Wiggling with Experience
Posts: 298
Joined: Mon Nov 21, 2016 6:22 pm

Re: Logic Toggle Latch

Post by msboude » Sat Mar 28, 2020 9:48 am

I see where you get your name.. you address someone giving you shit... but dont address the people that are actually helping you and drawing out circuits you dick.
Last edited by msboude on Sat Mar 28, 2020 10:44 am, edited 2 times in total.

User avatar
Graham Hinton
Super Deluxe Wiggler
Posts: 3245
Joined: Fri Jul 02, 2010 6:28 pm
Location: England
Contact:

Re: Logic Toggle Latch

Post by Graham Hinton » Sat Mar 28, 2020 9:50 am

msboude wrote:
Fri Mar 27, 2020 5:58 pm
This will have your output low at startup.
Here's a better way of doing a power reset:
powerup.png
The diode discharges the capacitor as the Vcc goes down to ensure a reset when the circuit is powered down and up again quickly.
Substitute any Schmitt trigger.

As a general rule, don't mix analogue signals and components in digital logic circuits unless you have a Schmitt trigger or it is a special timing function, e.g. a monostable. I know a lot of amateur designs do this, but it is regarded as MML (Mickey Mouse Logic).
tardishead wrote:I want a circuit where you can send it a gate or trigger and it will toggle between high and low continuous outputs.
You would get a lot more mileage out of a simple PIC12F508 with suitable buffering, then you could play around with all sorts of logical operations on one or more signals and change them easily. Depends how you feel about writing a little software...
You do not have the required permissions to view the files attached to this post.

Post Reply

Return to “Music Tech DIY”