How do I scale this relay driver?

Started by Sage, December 10, 2014, 05:07:11 PM

Previous topic - Next topic

Sage

I'm working on a pedal that involves four independent DPDT latching relays (there are actually 5 relays total, but two of them are daisy-chained to effectively provide 4pdt operation; for the purposes of this discussion they can be thought of as a single relay).

I need to build a system to drive these relays with momentary switches, powered by 9V input.  I want to keep current draw as low as possible.  Thanks to this GeoFex article I believe I understand how the relays themselves operate.  However, I do not fully understand how build a circuit that will make them switch back and forth using a momentary switch.

I have found this diagram using a CMOS hex inverter:



While I don't understand it fully, I get the general idea.

My question is: if I wanted to scale this to control four independent relays instead of just this one, how would I go about doing so?  Do I just build four identical circuits, or is there a way to do it that involves less duplication?

R.G.

Quote from: Sage on December 10, 2014, 05:07:11 PM
I'm working on a pedal that involves four independent DPDT latching relays (there are actually 5 relays total, but two of them are daisy-chained to effectively provide 4pdt operation; for the purposes of this discussion they can be thought of as a single relay).

I need to build a system to drive these relays with momentary switches, powered by 9V input.  I want to keep current draw as low as possible.  Thanks to this GeoFex article I believe I understand how the relays themselves operate.  However, I do not fully understand how build a circuit that will make them switch back and forth using a momentary switch.
First, there are two kinds of latching relays: single coil latching and dual coil latching. The dual coil is simple: pulse the "set" coil, and if the relay is not already set, it flips to set; if it's already set, it stays there. Pulse the "reset" coil, and if it's not already reset, it becomes so. Pulse to set, pulse to reset. The single coil is a bit more complex. The coil has a polarity; pulse one side + and the other -, and the relay sets if it is not already set. Reverse the polarity so the coil is - to + and the relay resets. Both kinds need two drivers, one for set and one for reset, but the dual coil needs only a pull in one direction for each of set and reset. The single coil needs both drivers to be active high and active low, because they must be coordinated, one high and the other low for every action. That being said, there is a trick with a cap pulled either high or low with a toggle switch that works if you get the time constants right. I personally prefer the dual coil versions.

The reason for using latching relays is almost entirely to avoid the current needed to hold them in one state, set or reset, without spending the DC current to hold them that way. Latching relays let you pulse the coils for a fraction of a second and the relay stays that way, saving the continuous coil current needed for a non-latching relay. Notice that this only really matters if you're using only batteries. If you intend to use a power adapter all the time, you can just power a non-latching relay. You pay for getting low average power spent on the relay with additional circuit complexity. Very few, and fewer all the time, guitarists use only batteries.

I designed in relays to the V3 series of pedals because it appears to be impossible to train people about the issues that "true bypass" causes and buffered bypass solves. I used dual coils, but as I already had a processor on the board for other things, it was easy to just sense a momentary switch and then pulse the coils in software. But unless you're able to code and program a $1.00 microcontroller, you're stuck with doing the pulse timing in hardware, which is what that circuit does.

Decomposing the necessary functions for a momentary switch to relay circuit, you have to
(1) have a one-bit memory to remember what state the switch is in now; in that circuit, it's done with the momentary driving  what amounts to a flip-flop that alternates each time the switch is pressed. This is identical in *function* to the two-transistor flipflop in every Boss and Ibanez pedal, and you could use the Boss/Ibanez flipflop as a front end, one per momentary switch.
(2) decide and implement what pulse timing you want your relay to use; many of the miniature PCB style relays work on a 50mS to 100mS pulse for set/reset. So you have to have some circuit that turns on the driver(s) for the coils each time the flip-flop changes state, then turns them off again a fraction of a second later to save the DC power that is the only reason to use a latching relay.

The 4069 circuit uses (IIRC, it's been a while) two inverters to make an always-toggles flipflop driven by the momentary switch, then two more inverters to sense the change of state and have a sloppy timeout so that the power to the coils turns off. This is then applied to the actual transistors that drive the heavier current for the relay coils. I'd have to go back through the circuit and refresh myself, but I don't see any unused pins on the inverter, so it looks like all sections are used. That means that you could count on using one replica of that circuit for every relay.

And this illustrates the screaming advantage that going to the next level and using a uC has. That 4069 will cost you on the order of $0.35 to $0.50 each. A $1.00 to $1.50 uC in a similar sized package will replace five or six of the 4069s if you use external transistors and three of them if you use the uC pins directly on a 5V relay.


I have found this diagram using a CMOS hex inverter:



While I don't understand it fully, I get the general idea.

My question is: if I wanted to scale this to control four independent relays instead of just this one, how would I go about doing so?  Do I just build four identical circuits, or is there a way to do it that involves less duplication?
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

PeterPan

Since you said you wanted to understand, I'm going to try to help you see the underlying principal involved, rather than analyze your specific circuit.

What you're after is basically a "D" flip Flop, and based on what you wrote I'd strongly suggest you learn a bit about them. This forum is not the easiest for quickly cut/pasting circuits and images, but take a look at this short article on wikibooks, and specifically the "D" flip flop.

http://en.wikibooks.org/wiki/Digital_Circuits/Flip-Flops

If you look at the truth table for the D flip flop,  you can see that every time the clock input goes from "low to high", The "Q" output will change to whatever The "D" (data)  input was. By the same token, the /Q  (called Q-NOT) output will always be the opposite of the Q output. So to get the magic you're looking for, you would take a D flip flop and connect the /Q output to the "D" input.  Now, every time the clock input goes from 0V to +V, the outputs will toggle  because the /Q output ( which is being fed back to the Data D input), will cause the Q output to reverse. You have now created a "T" flip flop, or "Toggle" flip flop. Make sure you understand this before the proceeding.

Next, you'd connect the clock input to 0V through a resistor (say 10K), so that its always at the "0" state when nothing is going on. Theoretically you could then tie that D input to your momentary button with the other end connected to +V. Now, and every time you press the button, the "Flip Flop" would change state. Butt there's a problem because when you press (or release) your momentary button, the change from 0 to +V (or visa versa) is never very clean. So if you tried this you'd likely find that the state change is almost random when you press the button. Certainly not reliable.

So the next step would be to insert a small capacitor (say .01uF) between the momentary switch/button and the clock input (which still has that 10K resistor to 0V). What you've created here is a crude "de-bounce" circuit. When you press the button, only a short pulse is applied to the clock input as the capacitor quickly charges. That pulse will have a timing that is based on the time constant of the resistor and the capacitor. The math is simply T=1/RC, but its not critical here... the important thing is that the pulse is so short, it will work to filter out the "noisy" switch contact. When you release the button, the capacitor will naturally discharge through its own leakage resistance, and you'll be able to hit the button again to change states, probably within a second or two (you can speed up the discharge with a much larger resistor in parallel with the capacitor( 100K to 1Meg should work).

next, now that you have a state that changes reliable with a momentary button push, you'll need to boost the current (and possibly voltage) from the flip flop to drive your relays. This can be done with a transistor or FET, with just a few resistors and a diode across the relay coil (to block the inductive kickback from the coil).

learning the above will be very instructive for you, and happily you'll find that when you get to the question of scaling, there are plenty of ICs with multiple D flip Flops. And old standby is the CMOS 4013, which has two flip flops. And for the transistor relay driver, a favorite of mine is the ULN2803, which is an 8 channel darlington transistor buffer, perfect for driving small relays, that even has the built in protection diodes.  

Of course there are other approaches here, but understanding fully is SO much better in the long run. Especially when you're trying to scale a circuit to go beyond what its original limitations.




--Randy (PeterPan)
*         *                                              *
   *                             *
... Second Star to the Right, and Straight on Till Morning!
       *                  *                  *

Transmogrifox

You want to scale it to avoid duplication...can't be done, but I did conceive of a way to use half as many CMOS inverters:
A) Needs to be something beefy like this so you can drive the relay directly from the inverter:  http://www.onsemi.com/pub/Collateral/MC74LCX14-D.PDF
B) Using a latching relay, you can drive each end from a different inverter.  Inverter A, direct connect on/off signal to input while inverter B input goes through an RC to create time delay.

As long as inverter B lags inverter A by 10ms, then on the rising input,
A goes low
Current B to A in latching coil
B goes low
Current stops.

Then falling input
A goes high
Current A to B in latching coil
B goes high
current stops

Hang the LED off the A or B output and that indication is built-in

Then you make the same momentary flip-flop circuit from RG's latching driver between inverter A and a 3rd inverter...we'll call it C.

That way, 3 inverters = 1 latching relay driver,
1 hex package == 2 latching relay drivers

I'll post a schematic when I have time if interested.  The logic is something I implemented in a microcontroller driver (the two outputs in which B always lags A).  The hardware logic is just as simple ;)
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.

Transmogrifox

Here is a schematic for the 3-inverter version taking advantage of the single coil latching relay:


Looks like this one:
http://www.mouser.com/ds/2/302/74ABT04_2-62316.pdf

Or this one (schmitt trigger, which is probably better for timing delay):
http://www.mouser.com/ds/2/302/74HC_HCT14_Q100-269269.pdf

In either case it's a little less board space since you have half as many 14-pin chips and you don't have the transistors and other wiring connections to think about.

I haven't actually built and tested this.  I have  driven latching relays like this using similar logic, so it seems like it should be good.
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.

Sage

Quote from: R.G. on December 10, 2014, 07:28:13 PM
If you intend to use a power adapter all the time, you can just power a non-latching relay. You pay for getting low average power spent on the relay with additional circuit complexity.

That's a very good point.  I was focused on latching relays because I wanted to keep power draw low, but I will be using a power adapter 100% of the time, so if using non-latching relays reduces the complexity of the circuit, that may be worth the tradeoff.  Is there an example diagram for a non-latching relay driver circuit that I could study?

Quote from: R.G. on December 10, 2014, 07:28:13 PM
I don't see any unused pins on the inverter, so it looks like all sections are used. That means that you could count on using one replica of that circuit for every relay.

Thanks, I suspected that would be the case.  Not a problem; component cost isn't an issue for me, I just didn't want to waste the physical space if I didn't need to.

Quote from: R.G. on December 10, 2014, 07:28:13 PM
unless you're able to code and program a $1.00 microcontroller, you're stuck with doing the pulse timing in hardware, which is what that circuit does.

That's why I was looking at it.  I'm not opposed to using a uC but I have no experience with them and didn't want to bite off more than I could chew.  I'm more familiar with the 4069 since our last discussion about adapting the millennium C to drive a bi-color LED.

Quote from: PeterPan on December 10, 2014, 07:50:02 PM
What you're after is basically a "D" flip Flop, and based on what you wrote I'd strongly suggest you learn a bit about them. This forum is not the easiest for quickly cut/pasting circuits and images, but take a look at this short article on wikibooks, and specifically the "D" flip flop.

http://en.wikibooks.org/wiki/Digital_Circuits/Flip-Flops

Thanks, this is a good primer!  I have a little knowledge of these types of circuits thanks to adapting RG's millennium C to drive a bi-color LED a couple months ago, but it'll help to understand the fundamentals better.

Would you happen to have a resource that better explains the "clock"?  It's referenced a lot here and I don't understand why timing is an issue.

Quote from: PeterPan on December 10, 2014, 07:50:02 PM
you'll find that when you get to the question of scaling, there are plenty of ICs with multiple D flip Flops. And old standby is the CMOS 4013, which has two flip flops. And for the transistor relay driver, a favorite of mine is the ULN2803, which is an 8 channel darlington transistor buffer, perfect for driving small relays, that even has the built in protection diodes.  

Definitely intrigued by those chips.  Do you have any example diagrams using the ULN2803 for this purpose?

Quote from: Transmogrifox on December 11, 2014, 12:47:53 AM
Here is a schematic for the 3-inverter version taking advantage of the single coil latching relay:

Awesome, thank you.  Does that work with a 9V power supply?

samhay

Quote from: Sage on December 11, 2014, 02:34:37 PM
Quote from: R.G. on December 10, 2014, 07:28:13 PM
If you intend to use a power adapter all the time, you can just power a non-latching relay. You pay for getting low average power spent on the relay with additional circuit complexity.

That's a very good point.  I was focused on latching relays because I wanted to keep power draw low, but I will be using a power adapter 100% of the time, so if using non-latching relays reduces the complexity of the circuit, that may be worth the tradeoff.  Is there an example diagram for a non-latching relay driver circuit that I could study?

If you want to use momentary switches, I'm not sure using non-latching relays will reduce the complexity of the circuit much.
I'm a refugee of the great dropbox purge of '17.
Project details (schematics, layouts, etc) are slowly being added here: http://samdump.wordpress.com

Sage

Definitely need to use momentary switches for this.

PeterPan

Quote from: Sage on December 11, 2014, 02:34:37 PM

Quote from: PeterPan on December 10, 2014, 07:50:02 PM
What you're after is basically a "D" flip Flop, and based on what you wrote I'd strongly suggest you learn a bit about them. This forum is not the easiest for quickly cut/pasting circuits and images, but take a look at this short article on wikibooks, and specifically the "D" flip flop.

http://en.wikibooks.org/wiki/Digital_Circuits/Flip-Flops

Thanks, this is a good primer!  I have a little knowledge of these types of circuits thanks to adapting RG's millennium C to drive a bi-color LED a couple months ago, but it'll help to understand the fundamentals better.

Would you happen to have a resource that better explains the "clock"?  It's referenced a lot here and I don't understand why timing is an issue.

Clock usually refers to a regular periodic state change, like a square wave generator might produce. Its frequency is usually stated. Interesting you should ask, because with the D flip flop, configured as a "T" flip flop I described, it divides the incoming "clock" by 2... so if you connected it to a 2Khz oscillator, you'd get 1Khs out of the Q (or /Q) outputs. BUT... just because its called a clock, doesn't mean it has to be used that way. In the case I described, the clock is being used as a "Latch" input. So the flip flop is "latching" (keeping" whatever data is present on the "D" input, when the CLOCK goes high. Indeed, a lot of ICs that have more than two D flip Flops is often called a "D latch" (Like the 74HCT373). Unfortunately, those don't bring the /Q outputs to a pin, so you're stuck with the DUAL FF's

Quote from: Sage on December 11, 2014, 02:34:37 PM
Quote from: PeterPan on December 10, 2014, 07:50:02 PM
you'll find that when you get to the question of scaling, there are plenty of ICs with multiple D flip Flops. And old standby is the CMOS 4013, which has two flip flops. And for the transistor relay driver, a favorite of mine is the ULN2803, which is an 8 channel darlington transistor buffer, perfect for driving small relays, that even has the built in protection diodes.  

Definitely intrigued by those chips.  Do you have any example diagrams using the ULN2803 for this purpose?

grab the data sheet from TI as a reference. -> www.ti.com/lit/ds/symlink/uln2803a.pdf
There's really not much to it. Here's a circuit I found on google of it being used to drive 8 relays. You couldn't ask for a simpler chip. :-)




--Randy (PeterPan)
*         *                                              *
   *                             *
... Second Star to the Right, and Straight on Till Morning!
       *                  *                  *

Sage

The connection between the uln2803 and the relays looks pretty straightforward, but what needs to drive pins 1-8?  Most the examples I'm finding via Google show a microcontroller connected to those pins.  Is there a way to control the 2803 without a uC?

Seljer

The ULN2803 is a darlington transistor array. It's just 8 transistors in one handy package with the emitter pins tied together and the snubber diodes already included. It'll take your low current digital signal outputs and let them switch up to 500mA per output. It solves driving the relay coils but you still need to implement all the logic in whatever way you choose.

I think the microcontroller is really one of your better options. There hasn't been better time to get into microcontrollers. You can get an Arduino board which easily hooks up to computer's USB for programming for $20. Theres plenty of code examples online as the platform itself was designed to be friendly introduction to uCs and programming to people new to the area. Once you get the code working you don't need to utilize the entire board, you can just program a $3 uC (using the Arduino board itself, but programmers are cheap nowadays too) and put it on your own board with some minimal support circuitry.

Transmogrifox

QuoteQuote from: Transmogrifox on December 10, 2014, 08:47:53 PM
Here is a schematic for the 3-inverter version taking advantage of the single coil latching relay:

Awesome, thank you.  Does that work with a 9V power supply?

It is drawn assuming a 5V supply because the CMOS inverter chips I suggested are rated for 5V supply applications.  Otherwise it would work directly on a 9V supply if you could find an inverter able to supply something >20 mA that has a >9V Vdd rating.

The supply can tolerate being really sloppy.  It would be a 2 resistor divider connected to the base of a BJT.  Emitter goes to CMOS chip Vdd, collector to 9V.  A step up for more reliable regulation when the battery sags would be using a 5.6V zener instead of resistor on the low leg.  Also a 5V regulator IC is a 3-pin chip, so maybe my ideas about BJT aren't really space savers.

If space is an issue, I suggest considering SOIC-8 SMT package as well as surface mounted transistors in a SOT-3 package.  We work with SMT at work and I find it easier to work with than through-hole as long as you have a magnifying lamp (something like a <$15 lamp will do).

I always like to simplify designs as much as possible -- particularly reducing pin count.  Every pin is another point to solder to something.
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.

Sage

So if I understand correctly, the uln2803 would only be replacing the Q1/Q2 and D1/D2 in the layout I posted above.  I'd still need either a microcontroller or the 4069, or potentially a 4013, to actually control it, correct?

Maybe I should be more interested in the 4013; it looks like it may be a little more suited to this task than the 4069.

If anybody has any examples pairing the 4013 with the uln2803, I'd love to see them.

R.G.

Quote from: Sage on December 12, 2014, 11:33:10 AM
So if I understand correctly, the uln2803 would only be replacing the Q1/Q2 and D1/D2 in the layout I posted above.  I'd still need either a microcontroller or the 4069, or potentially a 4013, to actually control it, correct?
Correct.

There are three meta-functions involved here:
(1) remembering which state the switch ought to be in with only a momentary switch; a momentary switch has no memory of what state it's in, it just say "OK, do it now" every time it's pushed. There's no memory of WHAT to do now, or what was done last time. This is what the flipflop or equivalent does, it remembers what the switch did last time, and flips to the new state when the momentary is pushed.
(2) driving the relay coils; relay coils need lots (on a relative basis) of current and volts to make the relay move, and most CMOS ICs can't do this directly. The transistors and/or uln2803 or whatever else are there to convert the logic-voltage change of the flipflop output to a voltage/current level that the relay coil will respond to.
(3) timing of pulsing the relay coil on/off. If you use latching relays and if you want to save power by turning the relay coil current off after the relay flips state, then you need a way to turn the coil current off after enough time for the relay to be moved to the new state.
Quote
Maybe I should be more interested in the 4013; it looks like it may be a little more suited to this task than the 4069.
It's a matter of objectives. The 4013 is a good dual flipflop with a lot of features, and you get two of them in one 14 pin package. It can be tinkered with by adding external parts to be a toggle flipflop. Using a hex inverter, you get two toggle flipflops in one 14 pin package plus two inverters left over. If you're careful, you can use these two inverters to do the timing of turning off the relay current if you are doing latching relays. Both of the approaches, 4013 and hex inverter, need a current buffer in the form of transistors or an integrated circuit buffer to actually drive the relays.

I happen to like the inverter style flipflop. I've designed it into pedals which have been on the commercial market for years, and it is extremely reliable. And it is very flexible in design.

So, diving into designs:

You need four flipflops to hold the state of your relays. There are two flipflops per package in the CD4013, and three flipflops per package if you use the two-inverter style. I looked for CMOS flops with independent clocks and there don't seem to be any with more than two flops per package. So you're signed on for two packages of CMOS logic to hold the four flipflops.

Each relay coil pin you drive needs at least one, perhaps two driver devices. You can get one driver device per discrete transistor, or you can get seven or eight drivers per IC package in the uln2xxx series of drivers. You're going to need four to eight discrete transistors or one IC package of drivers, so the IC package count is now up to three.

If you want to use latching relays, AND you want to turn the current off when the relay has flipped, you need two drivers per relay, and you need some way to turn the current off after the relay has flipped. The simple drivers won't do that I figured out a way to do that with a single PNP transistor for all four relays at a time, making use of the "spare" inverters in the inverters-style flipflops.  Did I mention that the inverters-style flipflop is flexible in design?  :icon_biggrin:

There's too much drawing to do all of this unless I was writing another article for geofex. But I will do one. Tell me which way you want to go and I'll draw that approach up.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

PeterPan

Quote from: Sage on December 12, 2014, 01:02:28 AM
The connection between the uln2803 and the relays looks pretty straightforward, but what needs to drive pins 1-8?  Most the examples I'm finding via Google show a microcontroller connected to those pins.  Is there a way to control the 2803 without a uC?

Sage, based on that question, it sounds like you may be a little over your head trying to do what you are doing. That's OK... do NOT be discouraged... take this as a learning opportunity. BUT... you can't expect everyone to do your thinking and research for you. Please take that in the right spirit, as I mean no offense.

The method I described, where I suggested this chip, had no MCU. The spec sheet for that ULN chip will show you exactly what you need to drive those pins. Its a darlington transistor array with some nice extras built in to save you some parts. It doesn't matter whether you drive it by a micro-controller, a switch, or a D flip flop. But here's the thing... you can keep asking for ready made circuits you can "cut and paste" from, or you can take the time to understand, and design what you need.

I understand well that when trying to just 'get something done", we all want to just find something ready made that works, and save the "learning" for later. If you're in a rush, keep looking and you may indeed find something like that. But trust me... that's a very frustrating approach to electronics. Even for pros, circuits often fail to do what we expect on the first try, and if you're new to circuit design that will happen a LOT. We'll all help you do it, and if its your design it will be easier. But if its all someone else's design, and you never take the time to look at IC spec sheets, you'll always be at the mercy of trying to track down the original author.

--Randy (PeterPan)
*         *                                              *
   *                             *
... Second Star to the Right, and Straight on Till Morning!
       *                  *                  *

PeterPan

Quote from: R.G. on December 12, 2014, 01:26:27 PM

Maybe I should be more interested in the 4013; it looks like it may be a little more suited to this task than the 4069.
It's a matter of objectives. The 4013 is a good dual flipflop with a lot of features, and you get two of them in one 14 pin package. It can be tinkered with by adding external parts to be a toggle flipflop. Using a hex inverter, you get two toggle flipflops in one 14 pin package plus two inverters left over. If you're careful, you can use these two inverters to do the timing of turning off the relay current if you are doing latching relays. Both of the approaches, 4013 and hex inverter, need a current buffer in the form of transistors or an integrated circuit buffer to actually drive the relays.

I happen to like the inverter style flipflop. I've designed it into pedals which have been on the commercial market for years, and it is extremely reliable. And it is very flexible in design.

[/quote]

It occurs to me that if the OP needs to scale more, then he might want to consider combining an octal D flip-flop like the 74HCT373 with an octal inverter (maybe a 74AC540SCX)  to provide the missing /Q output. That way, including the ULN chip, he could have 8 complete "Toggle" relay drivers with a total of only 8 chips. Would you agree?

--Randy (PeterPan)
*         *                                              *
   *                             *
... Second Star to the Right, and Straight on Till Morning!
       *                  *                  *

R.G.

Quote from: PeterPan on December 12, 2014, 01:50:44 PM
It occurs to me that if the OP needs to scale more, then he might want to consider combining an octal D flip-flop like the 74HCT373 with an octal inverter (maybe a 74AC540SCX)  to provide the missing /Q output. That way, including the ULN chip, he could have 8 complete "Toggle" relay drivers with a total of only 8 chips. Would you agree?
Yeah. Maybe.

There is a problem with the quad, hex and octal flops. The OP said he wanted independent action. It gets complicated to arrange for independent action of each flop if there is not one clock pin per flop. All the flip flop packages other than the 4013 (and the hex inverter) solution have one clock per package, so you get into trying to flip only one of them while keeping the others where they were, and pretty soon you have RC delay networks and diode steering of the active clock pulse into the intended flop but not the others - it gets out of hand with MML pretty quickly.

The other issue with the denser packages is that they're mostly all the 5V only versions of CMOS. The 4000 series runs natively up to about 15V, so it can run without level shifting and such on a 9V (or 12V, or 15V) pedal supply. uC packages have the same problem, but they are so very flexible and dense that paying for level shifters is a reasonable compromise.

Yeah, I know that the uln2xxx series mostly runs fine from 5V in, high voltage out.

I have done most of the possible flavor combinations of momentary switch to logic outputs at one time or other, and I remember some of the little quirks as they come back up in my mind.

One thing, the two-inverter flipflop *has* both Q and -Q as well.

So if the OP can stand only to go to six switches-to-relays, he could use two hex inverter packages to get three flops, two uln2003 packages for a total of 14 drivers, and I think I can figure a way to get a big PNP or P-channel MOSFET hooked up to the two unused driver sections to do a master pulse on/off for latching relays.

So four chips for six latching drivers running native on 9v, with pulse timing for latching relays as long as you use dual coil latching. A switch closure flips one relay per, and the coils stay active for maybe 100mS per switch closure. Otherwise, the current consumption's about nil.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

Sage

Quote from: R.G. on December 12, 2014, 01:26:27 PM
There are three meta-functions involved here:
(1) remembering which state the switch ought to be in with only a momentary switch; a momentary switch has no memory of what state it's in, it just say "OK, do it now" every time it's pushed. There's no memory of WHAT to do now, or what was done last time. This is what the flipflop or equivalent does, it remembers what the switch did last time, and flips to the new state when the momentary is pushed.
(2) driving the relay coils; relay coils need lots (on a relative basis) of current and volts to make the relay move, and most CMOS ICs can't do this directly. The transistors and/or uln2803 or whatever else are there to convert the logic-voltage change of the flipflop output to a voltage/current level that the relay coil will respond to.
(3) timing of pulsing the relay coil on/off. If you use latching relays and if you want to save power by turning the relay coil current off after the relay flips state, then you need a way to turn the coil current off after enough time for the relay to be moved to the new state.

Ah, I see.  I hadn't considered that third function.  So if I go with non-latching relays, that part isn't necessary.

Quote from: R.G. on December 12, 2014, 01:26:27 PM
It's a matter of objectives. The 4013 is a good dual flipflop with a lot of features, and you get two of them in one 14 pin package. It can be tinkered with by adding external parts to be a toggle flipflop. Using a hex inverter, you get two toggle flipflops in one 14 pin package plus two inverters left over. If you're careful, you can use these two inverters to do the timing of turning off the relay current if you are doing latching relays. Both of the approaches, 4013 and hex inverter, need a current buffer in the form of transistors or an integrated circuit buffer to actually drive the relays.

I happen to like the inverter style flipflop. I've designed it into pedals which have been on the commercial market for years, and it is extremely reliable. And it is very flexible in design.

Gotcha.  Yeah, that sounds more economical if you're going to be using latching relays.

Quote from: R.G. on December 12, 2014, 01:26:27 PM
There's too much drawing to do all of this unless I was writing another article for geofex. But I will do one. Tell me which way you want to go and I'll draw that approach up.

Thank you very much for the offer, but let me see if I can't bash on this a little bit myself first.  I have an idea, let me draw it up and you can tell me if I'm on the right track or not.

Part of me is leaning toward non-latching relays now, partly for the simplification but also because it would mean the pedal would "reset" when powered down, and that has value in the particular application I'm using it.  I'll try drawing up a schematic using two CD4013 chips and a ULN2803.

Quote from: PeterPan on December 12, 2014, 01:30:16 PM
Sage, based on that question, it sounds like you may be a little over your head trying to do what you are doing. That's OK... do NOT be discouraged... take this as a learning opportunity. BUT... you can't expect everyone to do your thinking and research for you. Please take that in the right spirit, as I mean no offense.

No offense taken; you're not wrong, I am definitely in over my head here.  But now that I understand that these chips are handling two completely different functions, I think I have a better grasp of where to go next.  I should have phrased my question better; I was trying to get at what Seljer made explicit -- that the logic and driver are two separate functions handled by different components.  I was thrown for a loop there because the CD4069 in the original circuit I posted is apparently handling multiple functions.

I think I have a pretty good grasp of how the logic part of the circuit works.  I really don't understand the part that drives the coils, but that's why the ULN2803 is attractive; it seems to reduce that complexity to a series of inputs and outputs.

Sage

First attempt:


Now, I realize this is incomplete.  After searching Google for a few examples, it seems likely that I need some .1uF capacitors between the ground and the /Q and D pins on the 4013, and possibly between the switch and ground as well.  But am I on the right track here?

R.G.

Kind of. The track is right, there are some details you're missing, but that's OK - that's what learning is for.

The uln2xxx is a transistor that pulls current into its output pin and down to ground. In the setup you've shown, the other side of the relay is at ground and there won't be any voltage for it to work on. Connect the (+) side of the relay coils to your V+, not ground. Then when the logic signal tells the driver to be "on", it will pull the (-) pin of the relay coil to nearly ground, and the V+ on the other side will let current flow in the coil.

Something I once got wrong - look up your relays and see if there is a preferred + and - pin on the coil. Some do and some don't, and if they do there is nearly always an internal diode or some such that makes the polarity matter.

And yes, there's a bit missing on the momentary switch side, but you already knew that. The idea there is to provide as good a single pulse to the "clock" pin of the flipflop as you can.

I think you got the important part on the flipflops - tie Q-bar to D, and ground both S and R.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.