# Help using a operational amplifer as a 2 position latch circuit

#### sornjs

Joined Dec 29, 2017
29

I created a circuit about 30 years ago based on Forrest Mims's radio shack mini-notebook on operational amplifiers.
The circuit produced positive voltage when momentary switch "1" was pressed and a negative voltage when momentary switch "2" was pressed.
Power supply was 12 volt and might have been a dual supply of +12 volt and -12 volt.
I found this "simplified" circuit when I searched for a "2 position operational amplifier latch circuit".
I do recall the circuit was very simple with few components and as I recall one op amp.
I think this is close.
Would someone please fill in the details so I can build and use this again.
My 30 year old memory; well, isn't.

Joined Feb 20, 2016
3,913
Instead of using an OpAmp, if you put 2 x 7404 (or other logic families) inverter sections in series you will probably get it to work ok.

#### Ramussons

Joined May 3, 2013
1,061
I would think this should work:

In the schematic shown, the Resistor, say 47 K, is from Output to NonInverting Input.
Loop the Inverting Input to the Output.
The Power Supply to the Op Amp will Be Gnd and Vdd

Last edited:

#### WBahn

Joined Mar 31, 2012
26,398
I would think this should work:

In the schematic shown, the Resistor, say 47 K, is from Output to NonInverting Input.
Loop the Inverting Input to the Output.
The Power Supply to the Op Amp will Be Gnd and Vdd
Isn't that relying on some assumptions about the relative magnitudes and directions of both the input bias currents and the input offset voltages?

#### ebeowulf17

Joined Aug 12, 2014
3,282
Should something be done to prevent the short circuit that would happen if both buttons were pressed at once?

#### WBahn

Joined Mar 31, 2012
26,398
Should something be done to prevent the short circuit that would happen if both buttons were pressed at once?
If it's just a toy circuit for playing with, probably doesn't matter. But if it is being used for anything meaningful, then IF there is a possibility of both buttons being pressed at the same time (the mechanics might make it impossible) then some sort of short circuit protection should be employed.

#### Ramussons

Joined May 3, 2013
1,061
Isn't that relying on some assumptions about the relative magnitudes and directions of both the input bias currents and the input offset voltages?
Yes WBahn, you are Right - that did'nt strike me.

#### WBahn

Joined Mar 31, 2012
26,398
I'd recommend a Schmidt Trigger circuit formed by using a voltage divider on the output to the negative supply. Make the resistor tied to the output considerably smaller (2x to 10x, say) than the one tied to the supply. Tie the output of the divider to the noninverting input of the opamp.

Then form a voltage divider between the supplies using equal value resistors and take its output to the inverting input. Put the two switches across these two resistors.

xox

#### AnalogKid

Joined Aug 1, 2013
9,356
Isn't that relying on some assumptions about the relative magnitudes and directions of both the input bias currents and the input offset voltages?
My first thought was no, the low impedance rail or rail input overrides everything. But, maybe, if the output voltage range is greater than the input common voltage range AND closer in value to the input voltage than the magnitude of the input offset voltage, then:

Circuit is sitting latched low
Button press - Input goes to Vcc
Output snaps up to *very* close to Vcc in 1 ms or less, probably more like a few us
Input offset voltage is so large that the input stage diff amp now sees the external input voltage as being *less* than the opamp output voltage
Output snaps low in less than 1 ms from the original button press
External input still is high (button still is pressed)
Oscillate

Virtually impossible, but maybe.

The solution is to disconnect the inv input from the output (leave the non-inv connected through the resistor), and connect the inv input to Vcc and GND through two equal resistors to create a trip point of Vcc/2.

ak

Last edited:

#### sornjs

Joined Dec 29, 2017
29
the purpose of the circuit is to select the "direction" of a model railroad turnout. A turnout is a "switch" to select the direction of the train from straight ahead to the other direction (right or left depending on turnout construction). The device that does the work is an electronic stall motor that requires constant voltage (a relay might be easier but the club wants slow prototypical movement). Positive voltage one direction, negative voltage other direction. Thus the need for a latch.
Thanks all. As I implied at the start this circuit was only meant as a starting point.
My background is USAF electronic tech maintaining equipment at the component level before integrated circuits. Have BS in electrical engineering 1973 and work experience in electric power distribution from substations to customers. I really have little if any component training.

In conclusion, if someone sees a suggestion that might or should work, a circuit diagram would be most appreciated. I do not have the knowledge to understand what, for example, "The solution is to disconnect the inv input from the output (leave the non-inv connected through the resistor), and connect the inv input to Vcc and GND through two equal resistors to create a trip point of Vcc/2" and other statements above actually means.
I have used breadboards to test designs I "picked up" ands created (etching) printed circuit boards and constructed and/or maintained many circuits over the years.
Thanks again

#### WBahn

Joined Mar 31, 2012
26,398
If you need positive and negative voltages to reverse your motor, then your circuit needs to provide that. There are a number of ways to do this and which might be good or horrible depends mostly on the motors. What is their voltage and what is the current they require, both when they are moving and when they are stalled?

If the current is low enough, then your opamp might be able to supply it just fine. Otherwise, you will want to be able to switch the output using a device that can. A simple transistor circuit could do this easily.

For the latch part of the circuit, you might consider using a latch. A simple RS flip flop made from two NAND gates could do this, or a JK or D-type flip flop. All of these are in single chip packages and are quite cheap.

What power supplies are available to you for this circuit?

#### sornjs

Joined Dec 29, 2017
29
according do mfg documentation
applied voltage. 8 - 12 vdc. (AC voltage to 12v will not hurt. won't operate though)
draw moving 4ma
draw stall 15 - 16 ma
power supply is needed. I live in Jacksonville Fla and there is an EXCELLENT electronics salvage(?) store in Orlando, about 2 hours one way. I'm not sure I could buy a new resistor in Jacksonville, fla.

#### sornjs

Joined Dec 29, 2017
29
Just found a box of small ho dc throtles. can use these for a while. at least till i get going well

#### xox

Joined Sep 8, 2017
579
View attachment 142721
I created a circuit about 30 years ago based on Forrest Mims's radio shack mini-notebook on operational amplifiers.
The circuit produced positive voltage when momentary switch "1" was pressed and a negative voltage when momentary switch "2" was pressed.
Power supply was 12 volt and might have been a dual supply of +12 volt and -12 volt.
Interesting!

I've got a digital copy of pretty much every single Mims book so maybe I'll do some digging and see what I can find. Until then, you might try something like this:

Should work fine with any old op amp, and dual or single supply. Op amp A3 is optional but highly recommended (and mandatory if the output of A1 is used instead of A2). The capacitor just ensures that the circuit powers on in a predictable state and can be any "lowish" value really.

Last edited:

#### AnalogKid

Joined Aug 1, 2013
9,356
First pass at what I described in post #9. Needs decoupling, maybe a power-on reset capacitor, and treatment of the unused opamp (the LM358 is a dual opamp IC).

ak

xox

#### xox

Joined Sep 8, 2017
579
First pass at what I described in post #9. Needs decoupling, maybe a power-on reset capacitor, and treatment of the unused opamp (the LM358 is a dual opamp IC).
View attachment 143000
Works great!

Does need a resistor from SW2 to ground to prevent the possibility of a short circuit though (in case both switches are pressed simultaneously).

#### AnalogKid

Joined Aug 1, 2013
9,356
Does need a resistor from SW2 to ground to prevent the possibility of a short circuit though (in case both switches are pressed simultaneously).
That was covered in posts #5 and #6, and not addressed by the TS.

Given the asymmetry in the LM358 (and most other opamps') input common mode voltage range, I'd put the resistor between SW1 and Vcc. 1 K will work; it must be less than 10 K.

ak

#### xox

Joined Sep 8, 2017
579
Given the asymmetry in the LM358 (and most other opamps') input common mode voltage range, I'd put the resistor between SW1 and Vcc.
Sorry, but could you elaborate on the rationale there?

it must be less than 10 K.
Why so?

#### AnalogKid

Joined Aug 1, 2013
9,356
1. Overdriving the input stage of an opamp does not start when the input voltage exceeds one of the power rails; it starts when the input voltage exceeds the input common mode voltage range, which could be several volts less than the rails. The LM358 input voltage range is asymmetrical - the low end extends below the low rail (*incorrectly* marked GND on the datasheet), while the high end is almost 2 volts less than the high rail. So while pulling the input down to GND is within the input stage's range of linear operation, pulling it up to Vcc exceeds the linear operation range and can cause various results depending on the specific opamp involved, including having the output completely change state. With the resistor on the high side, it limits the current into the input stage during overdrive; without the resistor, that current could be excessive and cause damage to the device.

2. If the output is low and the current limiting resistor is a pullup to Vcc and is equal to the feedback resistor, then the non-inverting input voltage is approx. Vcc/2, same as the inverting input. This will cause ambiguous operation or oscillation. This also is possible if the output is high and the input resistor is to GND, but less likely because the output voltage range does not swing as close to Vcc as it does to GND, so in this case the non-inverting input always is less than Vcc/2.

ak

Last edited:
xox

#### xox

Joined Sep 8, 2017
579
Got it! Thanks for the clarification.

Last edited: