Latching relay driver with CMOS - difference between these two circuits?

Started by aion, June 28, 2017, 07:34:31 PM

Previous topic - Next topic

aion

So I've not had the opportunity to dig into CMOS much before the past few weeks, but decided it was time. I'm trying to put together a latching relay driver, with the goals being:

- Use a "bouncy" momentary switch to reliably drive a latching relay
- Revert to bypass on power loss
- Start in bypass mode when first powered
- Ensure relay is in sync with the logic when first powered

I've been cooking out of Don Lancaster's wonderful CMOS Cookbook and using Art of Electronics as a reference, as well as studying Mictester's fantastic latching relay driver on FSB (topic "A Switching Scheme").

Here are two different schematics I've ended up with. I haven't tested either of them, I'm still just in the world of theory here. I understand the core relay driver portion (the half on the right) but it's the logic part that I'm trying to work through.





(note: C1 should be 1uF in circuit B)

And here are my questions.

1. Can circuit "A" be modified so it is in bypass state when first powered on? (i.e. logic-low, relay is off)

2. Is the "power-on reset" hooked up properly in circuit "A"? The IC1C stuff on the far-left is supposed to send a positive pulse on initial power-up. This is a cobbling-together of two different circuit fragments so I'm trying to make sure I understand how it's supposed to be connected to the bistable portion.

3. Would circuit "B" have any trouble driving the relay? Would a transistor buffer be helpful here? (I added one to circuit "A" out of caution, but it's an inverting type that replaces a Schmitt inverter, so won't work in the "B" circuit)

4. Is there anything that circuit "A" does that circuit "B" doesn't do? ("B" being a whole lot simpler and obviously preferable) - or any other weaknesses of "B"?

5. Is there any risk of the relay pulse "misfiring" and getting out of sync with the LED status? If so, this would be fixed by the next switch press, correct?

6. Would it be prudent to put a small resistor (e.g. 10R) between +V and this sub-circuit to help suppress any voltage spikes from the relay that could get into the main supply and be audible?

7. Assuming the momentary switch is wired off-board, is anything needed to protect the CMOS inputs from static or other unexpected voltage spikes?

Sorry for all the questions, but this will be hugely helpful. I'm a programmer by day, so my job is to think through how everything could possibly go wrong and guard against those things. So when I experiment with new and unfamiliar things like this, I immediately think defensively and want to understand how to make it as bulletproof as possible!

dschwartz

I do a simple trick to get bypass when powering up.
Just connect a capacitor (1n to 10n)  between V+ and the flip flop input.
This way when powering up, the flip flop starts and microseconds later it gets the capacitor positive discharge into the side that should be positive when bypassed ..in circuit A it should go between trigger 2 and 3, and in circuit B it should go to the triggers input.  Works like a charm

I don't really get how does the 220uF cap generates the negative voltage needed to switch the relay reliably..??
Do you mind to explain?
----------------------------------------------------------
Tubes are overrated!!

http://www.simplifieramp.com

Groovenut

I have used the same cap trick dschwartz mentioned to cause the flip flop to power up in a specific state. However, that will do nothing to set the relay state on power loss. One of the issues with the latching relay driver in circuit A is that if there is a main DC filter cap on the circuit, the cap C3 discharges too slowly to reset the relay. So you need a way to reset the relay at power off if you want to revert to bypass on power off.

@dschwartz - cap C3 provides a current pulse that is driven directionally by Q2 and Q3. When the cap charges the inrush current pulses the relay in one direction, when the cap discharges it pulses the relay in the other direction. The voltage of the pulse is less than VCC, about 63% hence the use of a 5 volt relay in a 9 volt system.

You've got to love obsolete technology.....

anotherjim

Left of circuit A is a standard active-low power-on reset scheme. The diode is to try to speed up discharge of the cap on power-off to catch the situation when the supply volts is lost momentarily (brown out). To make it active-high, reverse the order of the R, C and diode.

To apply the power-on reset to circuit B, I would do as already said, but I would also add the diode.

That diode can only discharge the reset cap as fast as the supply volts decays, and the cap is itself delaying that as it would be charged to the supply volts. The answer is to connect the diode discharge to a point on the power supply input that is isolated from the filtered power supply. If the supply has a series diode in series with the +input, then the discharge diode can go to the input side of the supply diode with a low value pull-down resistor to ground to provide a faster discharge path. The discharge diode won't see the supply filter caps when power goes off as the series diode will back block the stored supply volts.
The supply filter cap ought to be twice the value of the relay pulse cap = 470uF.
That input pull-down resistor will waste supply current if it's value is low enough to give it a fast reset while the supply filter caps still have enough charge to pulse the relay. An improvement might be some kind of transistor instead of the diode, whose control current is small enough to waste less power, but will snap on to rapidly discharge the reset cap when input power is lost.

At the relay, the way I see it, C3 if fed positive will charge up across its plates, passing current through the relay until C3 is fully charged. When Q3 switches on, it grounds the positive plate forcing the negative plate to go negative (it still has charge) with respect to ground and pulsing the relay current in the opposite direction until C3 is discharged.

electrosonic

I have made a few variations of that circuit and they work well. The 220uF cap can be smaller (100uF works fine). It is simple enough to redesign it with one less transistor if you are willing to have a little more current draw when engaged.

I was looking at the mute circuit used in the VFE effects circuits (that was recently posted), it could easily be added to this circuit.

Andrew.
  • SUPPORTER

aion

Quote from: anotherjim on June 29, 2017, 02:17:46 AM
Left of circuit A is a standard active-low power-on reset scheme. The diode is to try to speed up discharge of the cap on power-off to catch the situation when the supply volts is lost momentarily (brown out). To make it active-high, reverse the order of the R, C and diode.

Do you mean D2 and R8 to ground, C5 to +V?

Quote from: anotherjim on June 29, 2017, 02:17:46 AM
To apply the power-on reset to circuit B, I would do as already said, but I would also add the diode.

So cut & paste the exact reset circuit onto B, going into pin 1 of IC1? Or is it hooked up differently for this circuit?

Quote from: anotherjim on June 29, 2017, 02:17:46 AM
The answer is to connect the diode discharge to a point on the power supply input that is isolated from the filtered power supply. If the supply has a series diode in series with the +input, then the discharge diode can go to the input side of the supply diode with a low value pull-down resistor to ground to provide a faster discharge path. The discharge diode won't see the supply filter caps when power goes off as the series diode will back block the stored supply volts.

So you'd recommend maybe a 1N5817 Schottky in series with the input to prevent the main supply filter cap from pushing its charge up-river to this part of the circuit? Those are typically about 0.2V drop

Quote from: anotherjim on June 29, 2017, 02:17:46 AM
The supply filter cap ought to be twice the value of the relay pulse cap = 470uF.

Does this matter if using the series diode mentioned above?

Thanks for your help - this will go a long way!

anotherjim

In reverse order...
The supply cap may need to supply power for as long as the relay latch driver needs it after input power is lost. Therefore it needs a bit more capacitor to source supply current for long enough.
It all depends on your requirements. If the relay cap is expected to charged charged when power goes off, then it already has the charge needed to reset the relay in this event -  if that's what you want it to do.

Yes a Schottky diode if your circuit can't tolerate the extra 0.5v drop from a 1N400x type.

QuoteDo you mean D2 and R8 to ground, C5 to +V?
Yes, and keep their polarities in the same direction.

QuoteSo cut & paste the exact reset circuit onto B, going into pin 1 of IC1? Or is it hooked up differently for this circuit?
Yes, the extra resistor R1 means the inverter input only rises to half supply volts after initial seeing 0v (cap connected to 0v) . With the reset cap added, it will alter the rate that R3&C1 charges/discharges when the switch operates, but hopefully not significantly.

All the above said, lets try not to complicate it. I don't know what behaviour you actually want. In many cases, enforcing a default state on power-up is all that's needed -  we don't care what it does when power goes off, we ain't using it then.
Me myself, I'd be happy if it replicated a mechanical latch switch and keeps the state I last selected before power went off. Consider a power supply glitch in a gig situation. Loss of sound would be bad enough without having to go around stomping on things to get back where you were!
Digital gear that don't come back on set just as I last used it is a pet hate of mine ;)


dschwartz

I spent a lot of time tinkering with switching schemes like this. Relays are not as reliable as one may think and no circuit i came up were truly free of problems..mostly the all just worked. But after evaluating many switching options, the old trusty flip flop with 4049s and 4053 worked the best and never failed..also a 3pdt stomp with pins to pcb have worked very well for me...the ones with wire pads sucks.
----------------------------------------------------------
Tubes are overrated!!

http://www.simplifieramp.com

Transmogrifox

Here are some more ways to skin this cat.  Something to mull on anyway.
http://cackleberrypines.net/transmogrifox/Momentary_Switches/

One example, which always starts up in bypass state if power comes on reasonably quickly (like plugging in the barrel jack, or plugging your guitar cable into it).  May or may not if it's in your pedalboard and your DC supply ramps up slowly when you apply power.


Sometimes these can have some switch pop feed into your effects circuitry, so here is one way to address it:
trans·mog·ri·fy
tr.v. trans·mog·ri·fied, trans·mog·ri·fy·ing, trans·mog·ri·fies To change into a different shape or form, especially one that is fantastic or bizarre.

matt_garman

Reviving this old thread.  Has anyone built/tested circuit "A" from the original post?  I did, and when power is applied, it immediately goes into the active state.  When power is removed, it does go back to bypass.  But the switch doesn't work.  In other words, once power is applied, it's permanently on, and stays on until power is removed.

Now looking more closely at the schematic, it seems like that first inverter (IC1C) will always see positive potential, i.e. a "1", right?  And therefore, cause the last inverter (IC1B) to output a "0", which will turn on the PNP (Q1).  How does the momentary switching "overcome" the always-0 output of IC1C?

Thanks!

anotherjim

I don't know what IC1c is for, to be honest. It should already have a power-on state outputting 0 since C1 will start discharged to 0v. However, if C1 is charged it must discharge when power is switched off by leaking via the protection diodes of the CMOS ins and outs via the +supply which needs time to drop to 0v. A quick off-on of the power could fool it.
A spare inverter could provide 2 delays. An initial power on-delay that gives the flip-flop time to settle as it may followed by a short pulse from a series cap to set the flip-flop in the desired state which should lead to the relay flipping if it isn't already set right. This series cap is perhaps missing from circuit A? It would come immediately after pin6. Also, the cap will always be attached to the low output of IC1c so added in parallel to C1. This might reduce the voltage transferred from C2 when the bypass switch is pressed by too much. Values of R2, C2 and the new cap can be adjusted to compensate.


matt_garman

Thanks for the quick feedback!

Quote from: anotherjim on March 08, 2023, 10:43:22 AM
I don't know what IC1c is for, to be honest. It should already have a power-on state outputting 0 since C1 will start discharged to 0v. However, if C1 is charged it must discharge when power is switched off by leaking via the protection diodes of the CMOS ins and outs via the +supply which needs time to drop to 0v. A quick off-on of the power could fool it.

My understanding, is that the intent of the first inverter (IC1C) and circuitry to the left(*), is to enforce deterministic states at power-on and when power is lost.  And part of the enforcing of a known power-on state is ensuring that the LED and bistable relay are in sync.

Quote from: anotherjim on March 08, 2023, 10:43:22 AMA spare inverter could provide 2 delays. An initial power on-delay that gives the flip-flop time to settle as it may followed by a short pulse from a series cap to set the flip-flop in the desired state which should lead to the relay flipping if it isn't already set right. This series cap is perhaps missing from circuit A? It would come immediately after pin6. Also, the cap will always be attached to the low output of IC1c so added in parallel to C1. This might reduce the voltage transferred from C2 when the bypass switch is pressed by too much. Values of R2, C2 and the new cap can be adjusted to compensate.

I don't quite follow... you're suggesting an extra cap that goes from the output of IC1C (pin6) to ground?

Personally, I'm not terribly concerned with deterministic power-on or power-off states.  Based on this thread (which I suspect was the inspiration for Circuit A above), if I did away with that first inverter and everything to the left of it, it should result in a simple momentary SPST-based relay bypass scheme (though perhaps with non-deterministic power on/off states).  But there was at least one comment in that thread talking about the initial state having the LED and relay out-of-sync.  And the suggestion was to add the extra inverter (IC1C) and it's supporting components.

(*) Edit: I originally wrote "right" when I meant to write "left", now fixed.

Rob Strand

QuoteMy understanding, is that the intent of the first inverter (IC1C) and circuitry to the right, is to enforce deterministic states at power-on and when power is lost.  And part of the enforcing of a known power-on state is ensuring that the LED and bistable relay are in sync.
That's definitely the case *but* the circuit appears to have an error.  The output of IC1C completely overrides what is going on at the input of IC1A.

I haven't checked the fine details but the circuit of IC1A and IC1B should work.  You check by comparing this to say one of the DOD pedal circuits.  IIRC the Pearl pedals used a similar circuit.  That should give you the basic toggle on/off function.

If you want to force the state on power up a common scheme is to use a circuit like IC1A, however, after the initial power-up pulse to set the desired state the circuit need to disconnect itself form the main workings of the circuit.

At power-up the cap C5 is at 0V and that forces the output of IC1C high for a short period.  When the cap charges IC1C will go low.   The normal way to shoe-horn this into another circuit would be to put a diode on the output of IC1C (cathode to the output of IC1C) so that only the positive start pulse has an effect.   When the cap charges and the IC1C output goes low the start-up circuit is disconnected by the added diode.  When the output of IC1C is high the LED is off and Q1 is off, so the reset circuit is forcing the circuit off, as desired.

But the problems aren't over.  If you have a latching relay it will stay in the state present before power down, regardless of what the driving circuit does.

The original circuit appears to be this one,
http://moosapotamus.net/images/mom-relay-sch-by-mmolteratx%28800x410%29.png

So the circuit at the top of this thread is this circuit with an incorrectly implemented reset circuit added on.  However, I think even after fixing the reset circuit it's not going to work as expected due to the "memory" of the latching relay.
Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

matt_garman

Quote from: Rob Strand on March 08, 2023, 07:49:14 PM
That's definitely the case *but* the circuit appears to have an error.  The output of IC1C completely overrides what is going on at the input of IC1A.

That's exactly what I was thinking!  Good to know I have at least some idea of what's going on.  :)

Quote from: Rob Strand on March 08, 2023, 07:49:14 PMI haven't checked the fine details but the circuit of IC1A and IC1B should work.  You check by comparing this to say one of the DOD pedal circuits.  IIRC the Pearl pedals used a similar circuit.  That should give you the basic toggle on/off function.

Confirmed, I just removed that first inverter (IC1C) and the on-off toggle works as expected.


Quote from: Rob Strand on March 08, 2023, 07:49:14 PMIf you want to force the state on power up a common scheme is to use a circuit like IC1A, however, after the initial power-up pulse to set the desired state the circuit need to disconnect itself form the main workings of the circuit.

At power-up the cap C5 is at 0V and that forces the output of IC1C high for a short period.  When the cap charges IC1C will go low.   The normal way to shoe-horn this into another circuit would be to put a diode on the output of IC1C (cathode to the output of IC1C) so that only the positive start pulse has an effect.   When the cap charges and the IC1C output goes low the start-up circuit is disconnected by the added diode.  When the output of IC1C is high the LED is off and Q1 is off, so the reset circuit is forcing the circuit off, as desired.

But the problems aren't over.  If you have a latching relay it will stay in the state present before power down, regardless of what the driving circuit does.

The original circuit appears to be this one,
http://moosapotamus.net/images/mom-relay-sch-by-mmolteratx%28800x410%29.png

So the circuit at the top of this thread is this circuit with an incorrectly implemented reset circuit added on.  However, I think even after fixing the reset circuit it's not going to work as expected due to the "memory" of the latching relay.

Or use a microcontroller.  :)  I was trying to avoid going that route, as I was hoping to have momentary-based toggle that is simple, low-power, easy to build, cheap, consistent and reliable.  Is that asking for too much?

Anyway, thank you for the clarification!  I'll just use it without that first inverter for now.

Rob Strand

I'm pretty sure you are right onto it now!

QuoteOr use a microcontroller.  :)  I was trying to avoid going that route, as I was hoping to have momentary-based toggle that is simple, low-power, easy to build, cheap, consistent and reliable.  Is that asking for too much?

If you just remove the start-up reset circuit and accept the fact it remembers the previous state it will work like most latched relay designs - no different to a push on/push off mechanical design.  It's the start-up condition that complicates things.  If you use a microcontroller and a two-coil latching relay the micro can force the unit to a given state at power-up.  It is possible to use gates to do this as well.

FWIW, you can't actually rely on those latching relays remembering the state.  If you belt the unit hard enough it can change the state of the relay, that can occur during transit or by accident.

Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

PRR

> If you belt the unit hard enough it can change the state of the relay, that can occur during transit or by accident.

The "Useless Box" will detect and correct a mis-switch.
https://www.amazon.com/Calary-Useless-Storage-Assembled-Children/dp/B077C3JZQ6
"You turn it on, and out of the box, a little finger pops out and turns the unit back off."
https://www.amazon.com/vdp/9651f98c3ced40af98bb75a5f9bf431e
Note: "earthquake resistance"
  • SUPPORTER

Rob Strand

Quote from: PRR on March 09, 2023, 12:39:36 AM
> If you belt the unit hard enough it can change the state of the relay, that can occur during transit or by accident.

The "Useless Box" will detect and correct a mis-switch.
https://www.amazon.com/Calary-Useless-Storage-Assembled-Children/dp/B077C3JZQ6
"You turn it on, and out of the box, a little finger pops out and turns the unit back off."
https://www.amazon.com/vdp/9651f98c3ced40af98bb75a5f9bf431e
Note: "earthquake resistance"
You might make light of it but I've seen some customer problems which were quite difficult to debug from the office and related to latched relays which changed state in transit.

The short summary:
- Production: does production test, burn-in, and final test - all pass
- Unit is shipped
- Custom receives goods and reports strange behaviour out of the box.
- Problem only shows up on a few random units
   ... which turns out to be units which suffered some sort of heavy handling (and noone knows it occurred.)
- Cause is software bug masked by the fact the production software just happened to leave the relays in a state that the software assumed. (The relay function was no longer used.)

The problem would not be have been solved quickly without knowing that latched relays can be knocked into an alternate state.
Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

anotherjim

QuoteI don't quite follow... you're suggesting an extra cap that goes from the output of IC1C (pin6) to ground?
I mean a series cap out of pin 6 which would be in parallel with C1 when IC1c pin 6 switches to 0v. In fact, C1 can do the job and doesn't need another cap. Break the connection from pin 6 and move the bottom end of C1 from 0v to pin 6. The moment the RC timing on the input pin 5 goes high then pin 6 drops to 0v and fires the flip-flop to the 0v output state (If not already there). After that, it will obey the switch since pin 6 will remain at 0v.


bluelagoon

Okay, since this thread has come alive again, Here's my 2 cents worth, after countless hours of trial and error testing on the CMOS switching scenario. Here are my results, one circuit for Bypass @ Startup, and one circuit for FX on @ Startup, power on.
Both Circuits have a dual Temporary mute function that sends to GND the signal @ switch trigger, to minimize any switching audible clicks, thwacks, thumps, etc.. These circuits are tested and work well, hope this helps for any who are not yet ready for the MCU Switching Bypass scenario.