Switching between two control voltages...

Started by earthtonesaudio, November 18, 2008, 04:06:40 PM

Previous topic - Next topic

earthtonesaudio

I have a tricky little problem with a project I've been working on for a while, perhaps some of the wise minds here can help...

I have a project that generates an positive ramp voltage when you hold down the button, and when you release the button it holds at that voltage (it's a ramp-and-hold circuit, actually).  The next time you press the button the circuit quickly ramps down to zero.

The tricky part is I actually have two of these circuits, arranged so that when one ramps up and holds, the other ramps down and holds.  The output of both is used for a single control voltage input.

So my question is: what are the pros and cons of using a diode OR to mix versus a summing amp?  (the whole thing being DC coupled)

Thanks,
Alex

frequencycentral

Can't you just use one ramp and hold, and feed it through a single opamp inverter, that way you can have a switch to choose between ramp up (the original signal) and ramp down (the inverted signal).
http://www.frequencycentral.co.uk/

Questo è il fiore del partigiano morto per la libertà!

earthtonesaudio

That's a good idea, but I don't think it would work for me.  My circuit really requires me to ramp up and hold, then each subsequent time requires first a reset, then ramp and hold of the same polarity.

R.G.

Not knowing what the final result is intended to be, it's quite hard to say what's better for what. You say  "... the output of both is used for a single control voltage" but not how they're either selected or combined.

Diode ORing will select the largest of the two voltages, not add them. Summing adds, of course. You could subtract each from the maximum control voltage and get much the same thing, but you still need to select or combine them somehow.  Diode ORing loses the diode drop on each voltage, so you have to precompensate for that or use active-diode circuits, which winds up being as much circuitry or more than summing.

It's approaching the point where a PIC microcontroller is both cheaper and more capable.
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.

frequencycentral

I guess I'm not understanding your application, or why the second ramp and hold. If you mix them equally they will cancel. A nice trick is to feed the normal into one side of a 100k Lin pot, the inverted into the other side, and take the CV from the wiper. That way you have +ve and one end of the pot, -ve at the other, cancellation in the middle, and all the graduations in between.
http://www.frequencycentral.co.uk/

Questo è il fiore del partigiano morto per la libertà!

earthtonesaudio

I'll see if I can post a schematic sometime soon.

earthtonesaudio

Was able to make a rough sketch quicker than I thought.  Op-amps are LM3900 Norton amps.


So the concept is this:
A Schmitt trigger at the input is normally in the LOW state.  When the switch is closed, the R/C network debounces the closure and the Schmitt trigger goes HIGH.  From there, the output is split three ways: to Ramp UP (1), Ramp UP (2), and the flip-flop circuit.
Ignoring the flip-flop for a moment, if the output goes high, there will be a small current delivered through the resistor and diode to each of the Ramp UP inputs.  However, only one Ramp UP voltage is needed, so that's where the flip-flop comes in.
The flip flop receives the trigger input and changes state, and the output feeds a large current into the Ramp DN input of one of the ramp/hold circuits.  Since the Ramp DN current is much larger than the Ramp UP current, one of the ramp/hold circuits is effectively held at zero while the other is free to ramp up.

Anyway, all this is happening while you're holding the switch closed.  Once you've reached the desired voltage level, you release the switch and it stays there.  The next time you press the switch, all this starts over again.


The output will be going into (maybe you already guessed...) pin 6 of a PT2399 chip.  Normally this pin would have a resistor to ground, but a current sink works equally well.  I'm guessing that nearly any op-amp I use (including the LM3900 shown) will easily sink 3mA, so I haven't included the voltage-variable current sink in the circuit.  Simply varying the output of the op-amp from 0 to 2.5V (the quiescent voltage of pin 6 of the PT2399) will result in an effective change from zero to infinite resistance.


Anyway, that's the idea.  Thanks for the input about the diode OR gate.  I was hoping it would work for simplicity, but ah well.


R.G.

Interesting approach - a dual half-tap.

Maybe we can work a bit with this.

First, are you sure that putting a voltage on the control voltage output is OK? I have not messed with this on the 2399, and don't know, but many oscillator timing inputs want a real resistor or current source to control oscillator speed. It might be good to try that out with just the output of an opamp (i.e. low impedance voltage source) and a pot to set the voltage for the opamp to see if 0-2.5V gives you what you want first. If not, you may have to do an active controlled current sink, which sounds like more of a pain than it really is, since you can use a current mirror.

To avoid issues with diode drop in the ramping, you could use a CMOS switch (4066 or 4053) to switch the up/down inputs to a appropriate ramp control voltage instead of putting the switch and flopflop outputs directly onto the ramp inputs. I think this would let you have more flexibility in setting the ramp constants.

As I said, I have not dug deeply enough to know these are what you need. But maybe they're useful pointers.
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.

earthtonesaudio

Quote from: R.G. on November 19, 2008, 10:06:02 AM
Interesting approach - a dual half-tap.

Maybe we can work a bit with this.

First, are you sure that putting a voltage on the control voltage output is OK? I have not messed with this on the 2399, and don't know, but many oscillator timing inputs want a real resistor or current source to control oscillator speed. It might be good to try that out with just the output of an opamp (i.e. low impedance voltage source) and a pot to set the voltage for the opamp to see if 0-2.5V gives you what you want first. If not, you may have to do an active controlled current sink, which sounds like more of a pain than it really is, since you can use a current mirror.

Nope, I'm not sure if the PT2399 would like a voltage input.  This is something I would try if I had a few spare 2399's, in case it is fatal to the chip.  ;)   A current sink is probably the better choice, but if the op-amp output works, it would reduce complexity a bit.

To avoid issues with diode drop in the ramping, you could use a CMOS switch (4066 or 4053) to switch the up/down inputs to a appropriate ramp control voltage instead of putting the switch and flopflop outputs directly onto the ramp inputs. I think this would let you have more flexibility in setting the ramp constants.

That's a nice idea, thanks!

As I said, I have not dug deeply enough to know these are what you need. But maybe they're useful pointers.

Yep, useful pointers, thanks.  I'm hoping that pin 6 will work well with a voltage input, because that could really help to simplify things.  But that's probably something I can only find out by experimenting or perhaps by asking Princeton Technologies. 

R.G.

If the current is always one direction (e.g. toward ground, out of the pin) then you can fake this by putting a resistance equal to the smallest pin-6 resistor (highest current value) from the opamp output to pin 6. Now only the difference in the two voltages exists across the resistor, and it sinks current and controls things. This won't work unless the output from pin 6 is always a current and doesn't matter what voltage it's returned to.
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.

slacker

I think that pin 6 of the pt2399 wants to see a resistance to ground or at least current flowing out of it. I'm not sure exactly how it works, and the datasheet doesn't help, but I'm pretty certain I've connected it directly to ground with no ill effects and it's perfectly happy with a 100ohm resistor to ground off it.
It also works fine with a completely turned on PNP transistor connected between it and ground, that's what I used for the Echo Base.

There's some info on this page about using it with a current sink if that might shed some light on how it works http://www.homebuilthardware.com/index.php/projects/pt239x-delay/.

earthtonesaudio

Quote from: slacker on November 19, 2008, 04:18:51 PM
I think that pin 6 of the pt2399 wants to see a resistance to ground or at least current flowing out of it. I'm not sure exactly how it works, and the datasheet doesn't help, but I'm pretty certain I've connected it directly to ground with no ill effects and it's perfectly happy with a 100ohm resistor to ground off it.
It also works fine with a completely turned on PNP transistor connected between it and ground, that's what I used for the Echo Base.

There's some info on this page about using it with a current sink if that might shed some light on how it works http://www.homebuilthardware.com/index.php/projects/pt239x-delay/.

Thanks, Ian.  That page is pretty helpful, and there are some interesting pages linked to from there as well.  That's where I got the idea to try a current sink.

Quote from: R.G. on November 19, 2008, 03:21:09 PM
If the current is always one direction (e.g. toward ground, out of the pin) then you can fake this by putting a resistance equal to the smallest pin-6 resistor (highest current value) from the opamp output to pin 6. Now only the difference in the two voltages exists across the resistor, and it sinks current and controls things. This won't work unless the output from pin 6 is always a current and doesn't matter what voltage it's returned to.

Right.  And I figure if the voltage at the op-amp output goes from 0 to 2.5V, then that should give max (limited) current all the way up to zero current.

Now should I bite the bullet and order some through-hole chips, or crack open my Fab Echo (yet again) and see if it can handle even more of my meddling...?    :icon_twisted:

R.G.

Quote from: earthtonesaudio on November 20, 2008, 08:33:55 AM
I figure if the voltage at the op-amp output goes from 0 to 2.5V, then that should give max (limited) current all the way up to zero current.
It will. What is different is the distribution of the current over that range. Let's look at some cases.

Case 1: Output of opamp tied directly to pin 6
The output impedance of the opamp with feedback is, say, one ohm. There is an internal current limit on how much current can come from pin 6, although the datasheet never says what that is. With a 1K resistor on pin 6, the delay time is already down to 40mS. We can guess that the 2.5V on pin 6 sags only a little with a 1K load, so the current might be about 2.5ma. Up at 342mS, the current is 2.5V/27.6K = 91uA. The datasheet is mum about what happens under 1K, which is why I don't speculate there.

The opamp pulls current from pin 6 equal to the difference in the voltages divided by the resistance from opamp output to pin 6. With the raw opamp, that's one ohm, or one amp per volt. So at an opamp output of 2.5V, the current is in fact zero. The chip is probably not working at all. As the voltage from the opamp drops, it gets into fractions of a volt and the VCO starts up, running quickly through the audio range and making some ugly squarks unless the chip has blocked audio out below X frequency. It might be best to put a 100K or so resistor from pin 6 to ground to keep that from happening, providing a minimum current drain.

At what opamp voltage do we hit 2.5ma out of pin 6, that being almost the full range of the VCO? It's (2.5V-Vopamp)/(one ohm), one ohm being the raw output impedance of the opamp. It's easy to see that 2.5ma happens 2.5millivolts below 2.5V (if everything is perfect, which of course it's not). So the entire range of delays is covered in the first few millivolts of the opamp range. That's going to be hard to manage.

Case 2. Opamp has a 1K resistor between it and Pin 6.
Now the 1K resistor acts as a current limiter between the opamp and pin 6. In fact, we don't hit 2.5ma until the voltage difference between the opamp output and pin 6 is 2.5V, which is full range. So the range of delays is now spread over the whole 2.5V range of the opamp output. Much easier to control.

I like a diode between the opamp and pin6 so that the opamp can't feed current back into pin 6, and so that cuts the available voltage range on the opamp from 0-2.5V to 0-1.9V. A resistor less than 1K, but still as big as possible to get the delay range you want is needed. 750? 820?

I'd still use a 100K to 1M pulldown on pin 6 to keep the VCO running at some long delay and keep clocks out of the audio range.
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.

earthtonesaudio

Alright, you've convinced me! 

Seriously though, thanks for that explanation.  I feel like this concept is getting a lot closer to reality now.  I'll try and breadboard it soon.  Hopefully I'll be able to resist the urge to make a new fuzz long enough to work out some of the details.

earthtonesaudio

Thought of a new way of doing the reset part that might be more practical, since it won't require matching caps or anything esoteric like that.
Also added the precision current sink output with adjustable upper and lower current limits.

!!!UNVERIFIED!!!


The only thing is that now there's a delay, set by the 1-shot, between the time you push the button and when it starts to ramp up the voltage.  But I was thinking that it could be shorter than the minimum "delay time" you'd use on the PT2399, and the minimum ramp voltage would just add to that.

gez

Quote from: earthtonesaudio on December 12, 2008, 08:22:10 AM
The only thing is that now there's a delay, set by the 1-shot, between the time you push the button and when it starts to ramp up the voltage.  But I was thinking that it could be shorter than the minimum "delay time" you'd use on the PT2399, and the minimum ramp voltage would just add to that.

Apologies if I've got this wrong as I've only skimmed through this post and haven't looked at the details of your circuit.  When an integrator clips, negative feedback is lost, as is the 'virtual earth' effect on the -ve input.  With a +ve pulse on the input the cap is still being charged once the output hits the negative rail, so the input gets pulled up towards the +ve rail.  When you change states, the cap has to ramp down until negative feedback is restored and the integrator can start to integrate again.  This causes a delay.

I got round the delay by making the input resistor to the integrator as large as possible and making the cap in the feedback loop smaller.  I then stuck a relatively small value resistor between the + and - inputs of the op-amp.  This prevents the inputs being pulled up/down too far from half supply.  This, however, assumes that the +ve input is biased to said half-supply (and that it's firm), but I see no bias on your schematic.  Might be your problem, who knows.  If it is, then don't make the resistor between the inputs too small otherwise it puts strain on the amp (you're running the amp at a much higher gain) and it can affect timing.

Just a thought.
"They always say there's nothing new under the sun.  I think that that's a big copout..."  Wayne Shorter

earthtonesaudio

#16
Quote from: earthtonesaudio on December 12, 2008, 08:22:10 AM
The only thing is that now there's a delay, set by the 1-shot, between the time you push the button and when it starts to ramp up the voltage.  But I was thinking that it could be shorter than the minimum "delay time" you'd use on the PT2399, and the minimum ramp voltage would just add to that.

A small correction: The bit in bold there should say "ramp down" instead.  I switched the polarity of the thing and forgot to mention it.

Gez, this is similar, but it's not an integrator circuit, it's a ramp and hold.  The op-amps are LM3900 or equivalent "Norton" amps, and the one with the capacitor from output to (-) input is biased by the amp below it.  Power supply is +5V and ground.  Check out National Semi's AN-72 for more info on this peculiar type of op-amp.  This circuit is basically taken from a couple appnotes out of that document.


Theory of operation for this revised drawing:

Input is the same, RC+Schmitt trigger debounced switch produces a positive voltage when switch is closed.
From the Schmitt trigger output, the positive-going edge activates the 1-shot, which produces a positive pulse of some short duration, which resets the ramp circuit (reset means the output goes high).  Both (+) and (-) inputs are getting the same voltage, so the resistor between the 1-shot and the (+) input is much smaller than the one going into the (-) input.  This way, when the 1-shot is active, the much larger current at the (+) terminal dominates and forces the op-amp output high.
As soon as the 1-shot times out, the current going into the (-) terminal dominates, and the ramp voltage slowly drops down. 
The output voltage of the ramp circuit causes the current sink to sink more for a large voltage, less for a small voltage.  So the longer you hold the switch closed, the less current can flow out pin 6 of the PT2399, and through the NPN transistor to ground, creating a longer delay time. 
I've drawn the resistors in the current sink section as trimpots, suggesting that they can be used to set the min and max collector currents.

One thing I haven't dealt with yet is that if you use this while playing, the delay time will quickly jump to a short delay time and then slowly creep to a longer delay time.  Might not matter in practice though.