Fall, Rise and Staircase up/down waveform generator?

Started by strungout, November 01, 2021, 03:25:04 PM

Previous topic - Next topic

anotherjim

QuoteJim: That circuit you posted with a diode OR gate, I assume it could just be repeated for every step? Using a rotary 1P8T.
Not really. It only works if the switch has an OFF state. As the most common multi-way switch type has a maximum 1P12T form, the need doesn't arise anyway. Any step length you can have has its own switch contact for the reset. For the maximum 10th step, it doesn't need an external reset, so a switch set for 10T simply has no wire from the 10 step contact.




strungout

Took a break.


Jim: ok, I get it. Thanks.


I had to use a 2nd order low pass, but it helped. I still need to fiddle with it... I have an extra op-amp, maybe I should use it for the filter...

Am I right in thinking more voltage, i.e. 12V instead of 9V, will give me more dramatic stepping? Because of the longer rise (given the same settings on the pots).

There was talk about it, but should I be using a regulator at all? I never put one in.


"Displaying my ignorance for the whole world to teach".

"Taste can be acquired, like knowledge. What you find bitter, or can't understand, now, you might appreciate later. If you keep trying".

anotherjim

You will need to scale the output voltage to suit whatever it's controlling. Any control range can be made to suit but we need to know the target. A regulated supply for the sequencer might help - but is the target also regulated? If not, repeatability still may not be guaranteed. Modulation doesn't usually need much precision so long as you can tweak it how you want but sometimes it does.
As to step smoothing, an opamp integrator might do a better job than an RC lowpass (it will draw a straight line between steps) but it inverts so needs to be followed by an inverter (or you turn the sequence pots upside down!). Anyway, your RC filter might be being loaded by whatever follows it and can't do what you hope without a buffer.


Rob Strand

#43
QuoteAs to step smoothing, an opamp integrator might do a better job than an RC lowpass (it will draw a straight line between steps) but it inverts so needs to be followed by an inverter (or you turn the sequence pots upside down!). Anyway, your RC filter might be being loaded by whatever follows it and can't do what you hope without a buffer.
Actually the second order filter is better than the integrator.

The integrator turns the edges into kinks  but the second order filter will also remove/smooth the kinks.

It's easier to see how the filter is better by thinking of the (unwanted) harmonics.   The stepped waveform has a lot of higher harmonics.  The harmonics are the glitches you don't want to hear.    The filter removes the harmonics.   The higher the order of the filter and the lower the cut-off the more harmonics are removed.   However if the cut-off is too low it starts to attenuate the fundamental at the highest frequency settings.

You can see this article uses a third-order filter.   

https://www.tinaja.com/glib/rad_elec/digital_sinewaves_11_76.pdf
(IIRC some of the formulas have errors. They are written as resistances but should conductances (=1/resistance).)

FYI these filters work by taking the output of a shift-register and passing it through a resistor network.   The resistor network acts like a *digital* filter (an FIR filter) but you can also think of it a D to A conversion process similar to the methods using counters early on in this thread.     The clock frequency on these can be much higher than the sine frequency and that makes it easier to filter without the filter affecting the sine level when set at the highest frequency.   With third or fourth order filters you can get quite clean sine outputs with shift register lengths of 15 or 16 steps.


My understanding is you want to hear the staircase but not the glitches?
The best solution to remove the glitches without losing the staircase effect is a higher order filter.

The thing to tweak  or perhaps trade off is if you want a gradual transisition on the staircase or you simply don't want to the glitches.

A lower order filter with a carefully chosen cut-off frequency will give you slower transition by the simple fact that in order to remove the glitches the cut-off needs to be lower and that causes a slower transition.   A higher order filter will allow the highest cut-off without blurring the steps.  The variable sine frequency complicates things because deliberate transitions might not sound right at all speed settings.    The simple answer is to keep upping the filter order until it sounds right.

Higher order filters let you select the slope of the cut-off.  With a simple a first order filter the slope is fixed.   Without getting caught-up in filter design details a Butterworth filter is a very good starting point for this type of thing.   Cascading RC filter trends to produce a very slow roll-off and while they might be higher order they sometimes don't work that much better than single RC filter.

The time it takes for a filter to complete a step, ie. the ramp up time on the edges of the step, is approximately
tr = 0.35 / f3   where f3 is the cut-off of the filter.  Low cut-off filters are slower to rise.
Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

anotherjim

At any rate (pun intended), I'd like to see a schematic of the connections.

strungout

This is what I'm working with right now:



I can't seem to make a simple one pole RC lowpass work... it basically kills the steps (or maybe it's just so low in the mix vs the dry signal) or rounds them out too much and it doesn't sound stepped. Can't sem to find a sweet spot...

I need to try that butterworth filter.

The regulator didn't seem to do much.
"Displaying my ignorance for the whole world to teach".

"Taste can be acquired, like knowledge. What you find bitter, or can't understand, now, you might appreciate later. If you keep trying".

Rob Strand

#46
QuoteI can't seem to make a simple one pole RC lowpass work... it basically kills the steps (or maybe it's just so low in the mix vs the dry signal) or rounds them out too much and it doesn't sound stepped. Can't sem to find a sweet spot...

I need to try that butterworth filter.
If the RC filter cut-off needs to be low to remove the ticks but that stuffs up the steps then yes a higher order filter like a second or third order butterworth is the next step.  You will need to move the cut-off up so the ramp time tr = 0.35/f3 is less than the smallest step.  If that means f3 is over 20Hz you might need to trade off clicks for some blurring of the steps at the highest LFO frequency.

I don't know where you put the filter but if you put the filter between the diodes and the opamp buffer you are going to get problems.    There is no resistive path to Vref/ground after the diodes.     So what happens is the diodes can charge the filter but there is no path to Vref  to "discharge" the filter.  That's going to give you some undesirable behaviour.    The way you have the level settings going to ground means the "middle" of the stepped waveform doesn't have well defined DC point.  The DC middle depends on the pot settings.  That means there's no easy way to put a resistor after the diodes.   However, if you wired the pots to Vref and instead of ground the diodes won't work properly.   So to make things easy at this point the best place for the filter is after the opamp *and* LED.  What that does is it feeds the filter with a low impedance.


This might save you some grief with the 3rd order,



You can also try setting R2 to anything down to about 120k so see if you can hear any difference.  This reduces the overshoots on the steps making it more Bessel like but without changing the cut-off or rise time.

Here's a 4th order but the same ideas apply,

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

strungout



Btw, I suck at calculating stuff...


Rob: I wasn't sure which input to use, since your example doesn't show, but I used the same values. It blurred the steps, but lowering R2 to 120k works well. The thump is gone. There is still some ticking, at high volume. Or high gain, rather. The clean sound on my amp is noiseless, even at max volume.


Jim: By target, do you mean the range of voltage that's expected to move the phaser's filters?

"Displaying my ignorance for the whole world to teach".

"Taste can be acquired, like knowledge. What you find bitter, or can't understand, now, you might appreciate later. If you keep trying".

anotherjim

Yeh, I wanted to see the circuit your sequencer is modulating.
Haven't people used the square wave out from LFO's as an optional modulation elsewhere? The same step-change problem that needs something to slow the edges.

To my mind, you don't want any of these results as they all have sudden transitions, even C (which would be useless anyway) does.
This is why I like Vactrols for the job - the LDR cannot step change too quickly and it electrically isolates the target from the source - they can be in different boxes.





anotherjim

For an active filter, here's a calculator...
http://sim.okawa-denshi.jp/en/OPstool.php
There's one that gives values for a target frequency. In audio work, smoothing over a period of 20ms is usually needed which equates to 50Hz. Lower f gives longer smoothing. 20Hz takes 50ms. Enter whatever f into fc and the results appear.


Rob Strand

#50
QuoteRob: I wasn't sure which input to use, since your example doesn't show, but I used the same values. It blurred the steps, but lowering R2 to 120k works well. The thump is gone. There is still some ticking, at high volume. Or high gain, rather. The clean sound on my amp is noiseless, even at max volume.
I'm not sure if you worked it out yet but the gain stage K is wired as a buffer.  (So input to opamp + input and opamp - input to the (same) opamp output.)  The feedback resistors you have add gain and will mess with the response - make it more peaky which seems undesirable.  (In fact you might be able to increase R2 after removing the gain.   That could help reduce the ticking.  You need to find a balance by playing with R2.)

Well it seems like you are on the right track.  Just some tweaking is required.

To reduce the ticking you might need to lower the filter cut-off frequency.  That will reduce the harmonics (the ticks).  It will also blur the edges more but with the 120k maybe the way it does it is OK now.   The resistors are pretty large already so to decrewase the cut-off you will have to increase all the caps by the same factor.   Try a factor of 2, that will drop the cut-off to 17Hz/2 = 8.5Hz, so caps 2x39n=82n, 2x100n = 220n, 2x5n6=10n or 12n.    You could literally use two of the existing values in parallel.  If a factor of 2 is too much try a factor of 1.4 or 1.5.

As for the ticking we as assuming it's coming from the edges and LFO path but maybe it's coming from the power supply.   The way you would work that out is to get the circuit working with the filter then disconnect the 100k between the filter output and the rest of the circuit and wire the 100k resistor to a 100k trimpot (or pot) across the supply.  Place a 10uF cap from the trimpot wiper to ground.  Then adjust to DC level on the pot so the circuit is in its operating range.   If you still hear tics, the ticks are coming from the power or grounding.   That's a whole different world of stuff to debug and the filter LFO filter won't help.    Not an uncommon problem for these circuits either - plenty of posts about it.
Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

Rob Strand

QuoteFor an active filter, here's a calculator...
http://sim.okawa-denshi.jp/en/OPstool.php
There's one that gives values for a target frequency. In audio work, smoothing over a period of 20ms is usually needed which equates to 50Hz. Lower f gives longer smoothing. 20Hz takes 50ms. Enter whatever f into fc and the results appear.
That calculator is only for the second order filter.  The third order is more complex and given we might need a Bessel filter only a few of the calculators will do Bessel *and* a third order filter with a single opamp.
Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

strungout

Rob: I tried what you suggested about the 100k trim and it ticks. So, then, the remaining ticking must be from the power supply.

I'll check the power supply.
"Displaying my ignorance for the whole world to teach".

"Taste can be acquired, like knowledge. What you find bitter, or can't understand, now, you might appreciate later. If you keep trying".

Rob Strand

#53
QuoteRob: I tried what you suggested about the 100k trim and it ticks. So, then, the remaining ticking must be from the power supply.

I'll check the power supply
It's a fairly common problem.  It often turns out to be related to the opamp oscillator (IC1 and IC2 in your diagram).

Some common fixes,
- put an RC filter on the power going to the opamp oscillator and the 4017.
  (maybe 100 ohm and 100uF).
- re-route the power and ground directly back to the incoming DC supply.
  The main thing this does is prevent the power glitches on the audio grounds.
  You don't want audio and the oscillator to share any grounds.
- you can also add an RC network to IC1
  The Boss BF-2 does this,
  https://www.hobby-hour.com/electronics/s/boss-bf2-flanger.php
  Added parts are C26 and R38.  You might need C29 as well.
  The parts slow down the sharp transitions.

You can look up some old posts, titles often mention ticks - there's a lot.

FWIW,  if you want after you solve that one you might be able to use a simpler filter.   No guarantees.   Typically the third order filters will work for sure but there's a lot more parts (and harder to design).
Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

Rob Strand

FWIW, since you now have an active filter you could move the LED to after the filter.  It should still look OK.   This can help  stop glitches.   The LED ground should not share grounds with any audio.  So wire it back to DC in, like the oscillator.
Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

ElectricDruid

Quote from: Rob Strand on November 17, 2021, 11:06:42 AM
QuoteFor an active filter, here's a calculator...
http://sim.okawa-denshi.jp/en/OPstool.php
There's one that gives values for a target frequency. In audio work, smoothing over a period of 20ms is usually needed which equates to 50Hz. Lower f gives longer smoothing. 20Hz takes 50ms. Enter whatever f into fc and the results appear.
That calculator is only for the second order filter.  The third order is more complex and given we might need a Bessel filter only a few of the calculators will do Bessel *and* a third order filter with a single opamp.

Okawa-Denshi is one of the ones that does:

http://sim.okawa-denshi.jp/en/Sallenkey3Lowkeisan.htm

3rd order Bessel for something like this seems like overkill though, if I'm honest. Maybe I'm wrong and it's great.


+1 agree with Rob's comments about the Clock LFO being a possible cause of the ticking. The Schmitt-Integrator LFO is notorious. Whether other simple square wave clocks would be quieter is an open question. 7555? 4047?

anotherjim

I just tried the 3rd order Bessel in that calculator. It does give an "S" curve step response.

strungout

I tried the suggestions to reduce noise, and it worked to some extent. But there's still something annoying. Rather than describe it, here's a clip:
https://soundcloud.com/user-165425177/arbitrarysequencernoise/s-5Y6E6dIeirc?si=aa6ce2357fd24604941b112ddcbb06ba

That is what I have right now. My amp volume is at 12 o'clock, pretty loud, guitar volume turned all the way down. You won't hear the cyclic noise when you're playing.

I read that that a 555 timer would easily cause ticking, but maybe another configuration would help. Suggestions?
"Displaying my ignorance for the whole world to teach".

"Taste can be acquired, like knowledge. What you find bitter, or can't understand, now, you might appreciate later. If you keep trying".

ElectricDruid

Quote from: anotherjim on November 20, 2021, 11:16:46 AM
I just tried the 3rd order Bessel in that calculator. It does give an "S" curve step response.

I've just been to check, and that *is* nice, I agree! And no overshoot like the Butterworth.

Quote from: strungout on November 20, 2021, 12:57:48 PM
I tried the suggestions to reduce noise, and it worked to some extent. But there's still something annoying. Rather than describe it, here's a clip:
https://soundcloud.com/user-165425177/arbitrarysequencernoise/s-5Y6E6dIeirc?si=aa6ce2357fd24604941b112ddcbb06ba

That is what I have right now. My amp volume is at 12 o'clock, pretty loud, guitar volume turned all the way down. You won't hear the cyclic noise when you're playing.
I can hear some ticking in there, and some weird phasey noise that sounds like background hiss run through the effect, plus a bit of hum. We might be able to fix two out of three?!?

Quote
I read that that a 555 timer would easily cause ticking, but maybe another configuration would help. Suggestions?
The basic 555 is *terrible* for ticking. The CMOS version, the 7555, is much better, but might not be silent either, I don't know.
Since you've already got the op-amp LFO in place, trying a few of the tricks to stop that ticking would be a good start. Are you using a low power op-amp? Many pedals use TL022 for that job, or TL062 would be good too. Anything that reduces the current drawn helps, since it prevents the LFO from yanking the power supply voltage around when it switches from full-on to full-off.


Rob Strand

#59
QuoteI tried the suggestions to reduce noise, and it worked to some extent. But there's still something annoying. Rather than describe it, here's a clip:
https://soundcloud.com/user-165425177/arbitrarysequencernoise/s-5Y6E6dIeirc?si=aa6ce2357fd24604941b112ddcbb06ba
There's two sounds ticks and a sweeping background noise.

The weird thing is the ticks aren't a constant period.    I'm suspecting something related to the 4017.  In fact you could disconnect the 4017 clock input from the oscillator and connect the 4017 clock input to ground and see what happens to the noise.   You need to wire the grounds for the 4017 and pots back to the DC input you don't want audio passing through these grounds either.

I'm not sure about the sweeping background noise.   Check you have all unused input of the 4017 grounded (or to +Vdd if they need to be that way for logic reasons.

Quote3rd order Bessel for something like this seems like overkill though, if I'm honest. Maybe I'm wrong and it's great.
Normally I would think the same.   However it looked like we got to the point where there was no way to trade-off the blurring of the steps and the ticks.   At the time we assumed the ticks came from modulation.  The 3rd order filter is a good choice here to reduce the ticks and control blurring.   Now after putting in the 3rd order we still have ticks.  So the bells go off and the ticks are from the power/grounds and (maybe) not the modulation.  The confidence in the 3rd order filter made it easy to separate the problem.

As for Butterworth vs Bessel, I was thinking later the overshoots of the Butterworth might do something weird so I offered the Bessel tweak as a fall-back (in fact the tweak can go between the two filter types).   strungout talks about from thumps from the Butterworth so maybe we do need the Bessel to keep the overshoots down.   The Bessels aren't overshoot free but the overshoot is pretty darn small.

If we removed the ticks by fixing up the oscillator then maybe we can address throttling back the filter order later.    At this point third order filter is already in there and it's probably doing more good than bad - they do have good responses.   I would leave it in for now until the oscillator issue is sorted.
Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.