## DIY logic module

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

Moderators: luketeaford, lisa, Kent, Joe.

nickajeglin
Learning to Wiggle
Posts: 20
Joined: Thu Mar 07, 2019 7:41 pm
Location: Omaha

### DIY logic module

Hello Everyone,

I'm looking for some help with a circuit design. It's a logic module inspired by the center portion of maths. I cobbled it together from various sources (a kassutronics blog post, mutable schematics).

Here's my understanding of how it works just in case I made a really bad mistake:

CV or audio is applied to J1-J3. These go into attenuverters, which then go to output jacks J4-J6. These are normalled to send the signal to the logic stages.

OR will ouput the maximum voltage level at J9, AND will output the minimum voltage level at J8, and AVG. MIX will output a non-inverted average of the 3 signals at J7. I think I prefer the average mix configuration to straight summing the signals. It's pretty easy to unintentionally overdrive the op-amp with 3x 5Vpp signals. Dual red/green LED's give a loose visual indication of signal strength and polarity. Inserting a cable into J4-6 will remove it from the logic stages.

J3 is special in that it is normalled to +10v. This means J6 can provide +/-10v for stuff like controlling o_C etc. Patching nothing to J6 will cause the 10v attenuverter to act like a "floor" or "ceiling" voltage control for the OR and AND outputs respectively.

Here are my questions:

1) +10v normalled to a jack: 10v will be briefly connected to any cable that gets plugged in here. Things this might touch: op-amp input pins through big resistors (33-100k), opamp output pins directly (eg. J5) or through small resistors (J9).
Will this hurt either of those things? Should I add output resistors to J4,5,6? What about other modules that don't have protected outputs?

2) Choosing input resistor for 10v reference: The datasheet formulas are a function of supply voltage (+12v with some tolerance) and max/min load current. +10v goes to the attenuverter. When RV3 is at one extreme, wiper voltage is zero, so voltage drop across R8 is 10v for a max load current of about 0.2mV. At the other extreme, the 10v is applied directly to the noninverting input of U1B, and to the inverting input via R12. I think in this case current flow is nominally zero. Using formulas in the datasheet of the LM4040, I get a range of 2.5k to 15k for R29. I choose 10k because I have it laying around and to reduce waste current consumption, but maybe 3.3k is better in practice because it's already being used elsewhere in the BOM. This seems like a wide range, so I'm worried I'm making a bad assumption here. Can anyone confirm I'm doing this right? What about a hypothetical scenario where it accidentally gets shorted to the negative rail of my power supply? Does this just blow a fuse in the supply? Burn up R29?

3) LED's: Is this a bad idea? I've used this configuration before so I know it will roughly have the desired function. I also know that it will throw off 1v/oct tracking as it causes a voltage drop at the output (but so do the protection resistors). Since I'm mostly planning on using this for non-pitch related CV, tracking isn't a major concern. I could add another opamp to drive LED's but I don't want another IC for cost/space reasons.

4) Any cool ideas for the spare op-amp? My current thought is inverting one of the logic outputs, but maybe someone with more experience has a better idea.
You do not have the required permissions to view the files attached to this post.

mskala
Super Deluxe Wiggler
Posts: 2640
Joined: Thu Mar 27, 2014 7:33 am
Location: Toronto
Contact:
Point 1 - momentary 10V is harmless on the op amp inputs, and on resistor-protected outputs, but it could possibly be undesirable if connected directly to an op amp output. The module susceptible to that would be foolishly designed, but such modules do exist. I'd throw on a 1k protective resistor. This will result in a slight voltage drop into the 100k input impedance of your attenuverter so that you end up getting a 9.9V reference instead of a 10.00V reference. But you probably lose more precision in the tolerances of the op amp's gain-setting resistors anyway.

2 - I'm not sure what formulas you're looking at, nor how you compute a current in "mV", but the way it looks to me is that with the wiper of RV3 at ground, you have two 100k and one 47k resistor between the reference voltage and ground. That works out to about 25k (100k parallel with 100k is 50k, then 50k parallel with 47k is about half of 50k). It'll be drawing 400uA from the reference. In any other case you have less current drawn from the reference. So the ballast resistor R29 has to supply at least 400uA plus whatever the LM4040 requires, which is going to be a minimum of about 115uA. A resistor to supply at least 515uA across 2V should be at most 3.9k. I'd choose no more than 3.3k to be safe, and if you already have that value on the BOM, great. Using 10k would not work: it will only supply 200uA , which leaves only 85uA for the circuit if the LM4040 eats 115uA.

If the reference voltage is shorted to ground, then R29 sees 12V across it. If it's 3.3k, that works out to 3.6mA, which multiplied by 12V gives 44mW power dissipation. The smallest commonly available resistors are 100mW, so this should be no problem. If it were shorted to -12V the power consumption would be four times greater, so you should probably specify at least a 200mW resistor if you think that's a concern.

3 - that's safe. The LED will not throw off the tracking because it is inside the op amp feedback loop. The op amp just has to supply a little more current to maintain its output voltage. However, your outside-the-loop protection resistor WILL throw off the tracking; if that's a concern, then you should put it inside the loop too, and probably add a stability capacitor.

I would use lower resistance values for R17 and R18. Having them so high is not good for noise; in Eurorack you are basically stuck with high values like that on op amps that take input from outside, because of the desire to keep input impedance at 100k, but U2D is being fed by the very low-impedance output of U2A and doesn't need to maintain a high input impedance of its own.

4 - a comparator might be fun; just something that takes the mix output and turns it into a sharp-edged gate signal suitable for use with envelopes, oscillator sync, and so on. Many of those modules can't trigger on a relatively slowly-changing level.
North Coast Synthesis Ltd.
Latest Web log posting: Genome Jazz

nickajeglin
Learning to Wiggle
Posts: 20
Joined: Thu Mar 07, 2019 7:41 pm
Location: Omaha
Thanks so much for the advice mskala! This is incredibly helpful.

I especially appreciate the help with setting up the LM4040. I did do some op-amp calculations in a basic electronics class, but I forgot about the idea that the voltage at the inverting and non-inverting terminals are essentially the same. That made me look at the resistor network wrong, so I definitely had the current requirement off.

I mostly compute current in mV by writing to fast

The module susceptible to that would be foolishly designed, but such modules do exist.
I resemble that statement. Depending on where I cribbed schematics from, lots of my earlier DIY stuff is missing resistors on the outputs. What mechanism would actually cause the damage in this case? I went through the TL07xx datasheet and didn't see anything that seemed to address applying voltage to the output. Concerning output protection+tracking: when you say to add a stability cap, where should it go? Ie. what is it meant to stabilize?

Thanks again, you've given me a lot of great advice that I can apply to other modules as well.

cygmu
Super Deluxe Wiggler
Posts: 1544
Joined: Mon Feb 15, 2016 3:33 pm
Location: UK
nickajeglin wrote:I went through the TL07xx datasheet and didn't see anything that seemed to address applying voltage to the output.
Under "Absolute maximum ratings" the datasheet says
Duration of output short circuit Unlimited
and there is a note which says
the output may be shorted to ground or to either supply
So with a TL072 there is nothing to worry about, but other op amps may be less forgiving.

mskala
Super Deluxe Wiggler
Posts: 2640
Joined: Thu Mar 27, 2014 7:33 am
Location: Toronto
Contact:
nickajeglin wrote:
The module susceptible to that would be foolishly designed, but such modules do exist.
I resemble that statement. :bang: Depending on where I cribbed schematics from, lots of my earlier DIY stuff is missing resistors on the outputs. What mechanism would actually cause the damage in this case? I went through the TL07xx datasheet and didn't see anything that seemed to address applying voltage to the output. Concerning output protection+tracking: when you say to add a stability cap, where should it go? Ie. what is it meant to stabilize?
I'm not sure a TL072 would have a problem with being shorted into +10V at all. They're quite rugged chips, and as cygmu said, they're rated for unlimited-duration shorts into ground. A short into +10V when the op amp is trying to drive its output to let's say -10V might possibly put more stress on it than a short into ground, but I've done some pretty bad things to TL072s and never actually seen one blow up from this sort of thing. The resistors we see on the outputs are more to prevent oscillation and to protect the other thing when the TL072 is mis-patched to some other module's output, than to protect the TL072 itself.

However, other op amps exist that may be more sensitive, and a module can be badly designed in other ways than by having an op amp output exposed to the outside world. For instance, some people may expose microcontroller logic outputs designed only to produce 0 to +5V. If you shorted one of those into a low-impedance +10V supply it might overload the protection diodes built into the microcontroller. In your specific design, though, your +10V reference is limited in its current capability by R29 and that's probably going to prevent it from damaging other things.

A stability or compensation capacitor would normally go directly between the op amp's output and inverting input, like C1 in your mixer. The idea is to prevent the op amp from being able to go into parasitic oscillation at high frequencies. I'm not sure you really need C1 - this kind of thing is more necessary at module outputs where people might plug in long cables. The current-limiting resistors on outputs serve a similar purpose when they are outside the feedback loop, by separating the cable capacitance from the op amp's feedback; but if you put the resistor into the loop in an effort to improve voltage accuracy, it'll no longer have this effect and you may want to add a capacitor to replace it. I wrote a Web log article on this topic here: https://northcoastsynthesis.com/news/un ... apacitors/
North Coast Synthesis Ltd.
Latest Web log posting: Genome Jazz

nickajeglin
Learning to Wiggle
Posts: 20
Joined: Thu Mar 07, 2019 7:41 pm
Location: Omaha
Thanks both, you guys rock! Having experienced people explain my mistakes really helps me get better faster.

I did see the "output short circuit duration" section in the datasheet, but I guess I didn't have enough context realize it was what I was looking for.

And thanks for the article mskala, the way you're explaining things clicks nicely with the way I understand them. I'm trying to get a solid understanding of how and why these things work so that I can progress from copying schematics to actually assessing performance requirements / component constraints and designing circuits to fit.

I really like the idea of using the spare op-amp for a comparator to get interesting gate/trigger patterns, so now I'm trying to design that section from scratch. I hope you won't mind glancing at it when I'm done.

MikeDB
Common Wiggler
Posts: 124
Joined: Fri Feb 08, 2019 8:28 am
Location: UK
I would use the spare opamp to buffer U20 from the LEDs - i.e. drive the output jack from U20 and also the input of the spare opamp, then output of the spare opamp to the LEDs. Although the LEDs won't distort the signal significantly, it reduces the effect to zero.

euromorcego
Super Deluxe Wiggler
Posts: 2758
Joined: Sat Jan 18, 2014 6:22 am
nickajeglin wrote: I really like the idea of using the spare op-amp for a comparator to get interesting gate/trigger patterns, ...
indeed, a comparator is a good idea. With a comparator after a three input attenuverting mixer, you can all kinds of interesting logic operations.

You could also add an inverted output to the mixer, no op-amp needed, you just need the signal after the first op-amp.

nickajeglin
Learning to Wiggle
Posts: 20
Joined: Thu Mar 07, 2019 7:41 pm
Location: Omaha
This is now COMPLETE!

If you are interested, you can download Gerbers, get a mouser project, etc from https://github.com/nickajeglin/Eurorack ... c%20module

It consists of 2 stages. The attenuverters, and the logic section. All three inputs are fed to attenuverters. Input 3 is normalled to a 10v source, so plugging nothing into that jack gives you a constant voltage output anywhere +/-10V. These attenuverted signals can be tapped directly out of the second row of jacks, which also will prevent them from being fed into the logic section.

The logic section has 4 outputs: MAX, MIN, AVG, and TRIG.

MAX gives the highest voltage output by any of the three signals. MIN obviously does the opposite. AVG is simply a 1/3 gain mixer on the three signals, averaging them together. TRIG is a schmitt trigger that uses AVG as the input, and uses the third signal as the cutoff voltage. The trigger has 1.5V of hysteresis to prevent noisy stuff from randomly triggering it.

Since input 3 is normalled to 10V, you can use it as a cutoff for the logic section: ie. keeping it centered (0V) will limit the MAX output to positive values and the MIN output to negative values.

There are also bicolor red/green LED's above each output to show you wtf is going on, as it can get confusing if you don't have a scope.

Here's an album that shows the finished module, as well as some oscilloscope screenshots showing how the outputs work.
https://imgur.com/a/F72EJEL

I have some spare PCB's. Mskala and cygmu get first dibs if they're interested, otherwise they're up for grabs if anyone wants one.

KSS
Super Deluxe Wiggler
Posts: 3292
Joined: Mon Jan 25, 2016 7:28 am
WELL DONE!

Very nice set of features.

Personally would prefer the pots for one and three were closer to the midline of pot two, to give just a bit more room to their jacks. And am using small diamonds on panels to signify normalled connections instead of your schematic switch. Diamond is filled and sits on the line with its point just touching the colored circles you have around the jacks. Or the jack nut circle itself if colored circles aren't used. Will make those changes if-when I end up making this.

But again, NICE WORK.

microfauna
Super Deluxe Wiggler
Posts: 1032
Joined: Mon Jul 11, 2011 10:58 am
Location: Edinburgh, fUcKed
Is it correct to say that the MAX circuit is +ve voltages only (like MATHS). ie 3 -ve voltages to the inputs would give 0v MAX out? And the opposite for MIN

cygmu
Super Deluxe Wiggler
Posts: 1544
Joined: Mon Feb 15, 2016 3:33 pm
Location: UK
microfauna wrote:Is it correct to say that the MAX circuit is +ve voltages only (like MATHS). ie 3 -ve voltages to the inputs would give 0v MAX out? And the opposite for MIN
No, the MAX should be able to get down to about -8V without issue.

The inputs are connected by diodes to the non-inverting input of the op amp, not to a virtual ground, and that connection is biased to -12V via the 220k resistor. Similarly the MIN should be able to reach up to about 10V.

Something I didn't spot before which could be an issue is that this configuration does expose the terminals of the op-amp to quite low voltages. A TL07x op amp will misbehave if the voltage at the terminals gets closer than about 4V to the negative supply, so here about -8V or so. The normalisation on the inputs means that this won't easily happen by accident, but if you send -10V to every inputs, you might find that odd things happen.

Specifically, with the input that low, the op amp can go into "phase reversal" and output a high voltage instead of a low one. The MIN circuit would be particularly susceptible because you could achieve the unwanted voltage at the inputs by disconnecting everything and turning the Input 3 knob all the way anticlockwise. I'd be interested to know if it does indeed misbehave like this or if I am perhaps talking rubbish.

Dcramer
Super Deluxe Wiggler
Posts: 5426
Joined: Fri Mar 29, 2013 12:11 pm
This is cool, wish I could get a built one

nickajeglin
Learning to Wiggle
Posts: 20
Joined: Thu Mar 07, 2019 7:41 pm
Location: Omaha
Dcramer, I'd be happy to send you a PCB, but I know myself too well to get involved in making finished modules for people...

Cygmu, thanks for pointing out the potential phase reversal problem. The datasheet says that the the lower common mode input limit is Vcc(-) - 0.3V, so I might be ok. I'll try to force the input as low as I can with the modules in my rack and see what it does.

KSS, someone in Reddit made similar comments about the pot layout. I was trying to make sure my fat fingers could turn the pot knobs, but I didn't notice I got them too close to the jacks. I released V2 of the PCB on my GitHub that tightens up the spacing and centers the 3 pots between the rows of jacks.

cygmu
Super Deluxe Wiggler
Posts: 1544
Joined: Mon Feb 15, 2016 3:33 pm
Location: UK
nickajeglin wrote: Cygmu, thanks for pointing out the potential phase reversal problem. The datasheet says that the the lower common mode input limit is Vcc(-) - 0.3V, so I might be ok. I'll try to force the input as low as I can with the modules in my rack and see what it does.
Oh, are you using something other than TL074? Sorry if I missed that somewhere.

I can't find a really good common mode input range spec for TL074 but the ST and TI datasheets say -12V to 15V, on +/-15V supplies. I have interpreted this as indicating that you want to stay 3 or 4V above the negative supply.

But this is particular to these op amps, so if you have a different part in there, then the range will be different and phase reversal may not be an issue at all.

nickajeglin
Learning to Wiggle
Posts: 20
Joined: Thu Mar 07, 2019 7:41 pm
Location: Omaha
cygmu wrote: Oh, are you using something other than TL074?
Nope just the TL074. I may have misread the datasheet. That sounds like something I would do. Unfortunately my job has gotten crazy the past month, so I haven't been able to get back to this yet.

I also don't have a dedicated work space right now, so I need to pull the modular case + power supply + scope onto the kitchen table with an extension cord to run any tests. I've been too lazy to do that lately

Once I get some breathing room I want to make sure there isn't any phase reversal issue in the physical module and dig into it a little more. If the module doesn't have the problem I'd like to breadboard the relavent sections and see what it does take to get it to flop over.