CD4046 fun: the PLLedal harmonizer and Hacksaw  [documentation]

Original effects with schematics, layouts and instructions, freely contributed by members or found in publications. Cannot be used for commercial purposes without the consent of the owners of the copyright.
Post Reply
User avatar
dylan159
Resistor Ronker
Information
Posts: 268
Joined: 18 Jul 2018, 14:02
my favorite amplifier: Chempion!
Completed builds: Oh boy...
Has thanked: 97 times
Been thanked: 536 times
Contact:

Post by dylan159 »

INTRO
Among the CD family of chips, the 4046 surely stands out. It's not a simple, but still cool, logic gate or switch, it's a whole system under the name of “phase locked loop”! Of course, seen this way it doesn't make it any more clear how and why it's used in pedals, but after reading this app report it's easier to identify the building blocks and how they interact in what they do. In brief:
  • We have two inputs to be compared, of which one is inverted. These get routed to not one but two phase comparators. Those compare both frequency and phase of the inputs and output a voltage proportional to how off they are. The two are different both in the way they are built and in how well they work in certain situations. Usually, PC2 is preferred for our use, although PC1 is still usable if unreliably, like in the Raygun youth fuzz. The issue, or the fun part, of PC1 is that little note about locking on to harmonics of the center frequency. Once that happens, good luck getting away from that arbitrary frequency.
  • This voltage is then used to control a VCO, but first it needs to be smoothed just right. Usually this is done with an RC filter, but I want to highlight this document which recommends using an actual active integrator here, with design equations. I've tried it and it works, but I didn't like it as much. It's probably a good idea in other applications, but alas we only care about how it sounds here. Notice that since the integrator is inverting, the two inputs get swapped.
  • You heard that right, VCO. This thing has an actual VCO inside, and you wouldn't be the first to think it can be exploited by itself. The most notable example is the X-4046, an incredibly usable voltage controlled synth which actually skips a step and controls the oscillator current, but some parasit pedals also offer a way to control this voltage and so the output frequency.
    Normally though, this is where the voltage from the phase comparator gets fed, and if you only wanted a square wave following the frequency of the input, you'd feed the output of the VCO to the “comparator” input of the PC. You now have a negative feedback loop, and by the might of feedback, it means that the VCO frequency will be adjusted as to be the same as the input and minimize the “error voltage” produced by the phase comparator.
  • There are other usually neglected pins. The demodulator output is a source follower connected to the VCO input. The phase pulses goes low whenever the phase comparator 2 detects a phase difference (if you were to probe this pin you'd hear some buzz until the two signals lock together). You also have a zener to use for voltage regulation if you want.
THE PLLEDAL
After this introduction, I wanted to make my own 4046 based circuit with the expressed goals of simplicity and usability. I've looked at previous circuits using this chip for this kind of purpose, like the Data Corrupter or the many ones by parasit studio. I didn't like the sprawling circuit board of the Data Corrupter for example. About the latter, PLL pedals are usually described as wild, unruly, glitchy. But what if they aren't? There are intrinsic limitations in the fundamental detection and tracking notes with a PLL, but that doesn't mean one can't give their best attempt.
I don't claim this is the best circuit, just that it's something I find to be very good, and I'm explaining the major points so that people can build upon it or make something more like what they want. Still, these are functional base PLL circuits as they are, even without the added benefits of envelope/LFO controlled filters and VCA that can make it into a more full-fledged guitar synthesizer.
The attachment PLL1.1.png is no longer available
INPUT STAGE
This is the first departure from existing designs. I've settled on this arrangement for U1A and U2A after many variations. At first I've tried a CMOS based input stage as seen in the Data Corrupter and the parasit circuits, but I was already thinking that op-amps can do a better job both for the amplification stages (a single op amp stage has more open-loop gain that a number of stacked inverters) and for the Schmitt trigger. Anyway, I've found that unsurprisingly, a 40106 works better as Schmitt trigger than two inverters with positive feedback. Still, an op-amp Schmitt trigger is more adjustable, and it's easy to spare one section from the existing chips instead of having a 14 pin chip just for this purpose.
This explains U2A and U2B, the Schmitt triggers, with hysteresis set as to gate string noises from reaching the rest for U2A, and for cutting most of the noise (mostly low frequency) made by the 4046 output as it glides up and back down with U2B. I've chosen the LM358 for this simply because the large common mode voltages caused the TL07x to misbehave, a well known behavior. In this case it manifested as some seconds of popping before it could settle after a signal. The 358 is cheap and an often used op amp for faking an actual comparator. Also, we can ignore the noise and crossover distortion this time, since we're dealing with loud square waves. You can also see this refreshing change of perspective in the choice of some unusually (for me) large resistors as to keep the cap sizes down.
As for U1A, I've tried lower and higher gain, different filtering, even low input impedance thinking that it might help by dulling the guitar input. In the end this is what worked best for me. The input impedance is high, low only triggered less reliably unless I compensated the gain. The gain is 100x which isn't as high as I could go but isn't as low as in some Boss designs (more on this later). The LEDs are just there to keep the op-amp from saturating, something which is again catastrophic in this case, especially with a 072, but any reduction in headroom is inconsequential and compesated with gain. This combination of gain and headroom works well for me, giving some consistency in triggering the effect without ruining the S/N ratio so much that any string noise gets through even if well gated.
Since we're only interested in the fundamental frequency going through, the high frequencies are attenuated first by C3 (1.59k fc), then by a second order low-pass filter, tuned again at 1.59kHz. This is because at first I intended this as a lead guitar effect and based the cutoffs on the highest fundamental a guitar can produce, which in practice worked very well for those high notes. I found out that for lower notes and bass guitar this left a bit too much harmonic content and it was easy to throw off the effect by picking too strong. Thankfully, lowering the cutoff to 480Hz fixed this problem. I've shown this on a switch because the lower cutoff makes the highest notes less reliable, but you can easily have only one of them.
One strength of this stage is that it's easy to tweak. You can fine-tune your preferred balance of noise rejection and consistency both with the gain and the hysteresis, also without the need of very precise values. Another level of adjustability is given by the instrument volume, which for once you can turn down without ill effects, if the circuit starts misbehaving, especially on low notes. That's another reason I might have erred on the side of “too hot” with the gain, instead of going too low and force you to hit the string very hard to register.
This is the time to mention another kind of fundamental detection stage, featured in Boss pedals such as the OC-2 and the sadly underrated DF-2, but also by the impressive MFOS Sub-Commander. This works quite differently, with a lower gain before rectifying each signal half and comparing each with the peak voltage to control a flip-flop. This might or might not work better, as the end result is still a square wave with the same frequency as the fundamental, but I don't have a CD4013 to test it with at the moment. Still, two things are sure: the parts count is much higher, requiring at least 4 op-amps and a 4013 even for the streamlined MFOS version, and that while the OC-2 is very usable, its tracking isn't considered perfect by anyone. Since the intent is to keep the circuit simple, I wouldn't choose it anyway. Feel free to try both and let me know though.
In case you're wondering, the PC input sensitivity kills any thought of going directly into the 4046 right away.
THE 4046
Let's take a look at the 4046 itself now. The signal comes in on pin 14, while pin 3 is the other input of the phase comparators. There are some passive components with critical values around it. Let's start with “R2”, which is absent! The only purpose of having a resistor here is to shift the minimum frequency the VCO operates at. It might be useful in some applications where you want to limit the lock range, but not here! All this does it make the VCO output a very low frequency with no input, which if you're lucky won't hear, if you're not comes out as popping!
Next comes “R1”, which I chose as 10k, as the application report recommends not going lower than this (this isn't always respected). Following the figure in the same document, it means a 10nF capacitor is chosen between pin 6 and 7 for a center frequency of 1kHz (the lock range extends 1k above and below that then). I didn't just assume this is the best value and tried both smaller and bigger, but ended up on 10n again.
Now here's the thing: actually for both this capacitor and the loop filter (R14, R15, C9) the value choice is an art of compromise, depending on the input frequency and especially the ratio set by the decade counter in the phase comparator loop, as that effectively makes the VCO operate at a much higher frequency. It's easy enough to get something that works, but performing the best for a certain input range and division ratio might make another setting unusable. The values I've chosen work well enough for all settings I'm interested in, but if you're particularly interested in a certain one there can be optimization.
For this reason I'll describe what happens when you go too far off the target with each:
  • C7 or R14 too big: the oscillator takes its sweet time ramping up and down. You might like it, I won't judge (a pot in the Data corrupter).
  • C7 or R14 too small, R15 too big: buzzy note attack which might or might not settle down. The VCO just isn't able to lock onto the signal.
  • R15 too small: “vibrato” or “pew pew” effects. I think the underdamped filter makes the VCO continuously overshoot and undershoot the target. This again has been exploited in existing circuits.
DIVIDERS
Between the input stage and the 4046 there's a CD4024 binary counter which shifts the fundamental frequency 0, 1 or 2 octaves down. It can go much lower if you want. This isn't the only way to achieve this, but it's the simplest and most effective, requiring no external components either. Somewhat similarly, a CD4017 decade counter is put between the VCO output and the pin 3 input. Since this is the phase comparator loop, dividing the frequency fed to the PC input by those integer numbers actually means the VCO output gets multiplied by the same amount with respect to the original signal. This, together with the binary counter shifting them down into an usable range, gives an host of just intervals to play with. I take little credit for this part, as it's been featured in the mentioned circuits, but no need to change what works well and is simple.
But what are those intervals? You can see my notes near each of them, with my favorites in the bigger text. Digits which are twice another one will have the same intervals but shifted an octave higher, which can still be useful if you want them an octave higher than otherwise possible. In practice either an ON/ON/ON DPDT as for the octave switch for up to three choices or a rotary will be present here, but I leave it to you to decide which intervals are worth keeping. You just have to connect the respective output to pin 3 of the 4046.
MIXER
This is a pretty straightforward mixer of the one knob kind, which I've chosen given the number of outputs. You can just as well have individual volumes for each signal and even add another octave down output like in the Data. Simple as it is, I've made a spreadsheet for it to have the right amount of gain, a smooth sweep and a somewhat constant output level (with about 2dB of variation) all by using common values. The gain is about -12 to -14 dB which means the volume knob should sit nicely at noon, it won't be obnoxiously loud and the mixer doesn't get overdriven, although this can change with R22.
DEMOS
Finally here's demos of it with guitar, bass and synth:


THE HACKSAW
As a bonus and part of the 4046 journey, I've made a similar circuit, which is a working example of an idea illustrated by RG Keen.
The article is very much conceptual, showing no values or input stage, so I did the figuring out and ended up with an interesting circuit that works quite nicely:
PLL1.1.png
You can see here an older version of the input stages, which works almost as well. I left it here so you can see it, but both circuits can use one or the other.
The main attraction is the way different outputs from the CD4024, which is in the PC loop, are mixed together to form a stepped sawtooth waveform. Since the VCO is effectively operating three octaves higher than the input frequency, I had to tweak what is here C5. I then adjusted the resistor values until I got something that looked like a sawtooth on scope. I've chosen to mix four outputs, which seems like a point of diminishing returns. This, together with using the lowest outputs of the counter unlike in the concept, make the VCO work at a frequency which isn't reasonably high and make the value selection easier.
You can choose to have a low pass filter or not at the output to smooth it even further, and you can even mix those outputs in different ratios to get other interesting sounds.
This one works as it is, but I sure don't like the odd number of op-amps for example. Maybe a common emitter can work as first stage, since it only needs to provide gain not even cleanly.
As it is, the output waveform doesn't look bad at all for what it is. Here's what it looks and what it sounds like:
hacksaw.PNG
CONCLUSION
I've only included the most interesting findings of my experiments, but here's an annotated clip with some others and examples of what I've described so you know what I meant:

One last interesting thing to do is to buffer an output from the VCO capacitor. This is done in the X-4046 to generate a sawtooth wave. If you only take the output from one side of the capacitor though, what you get is half ramp, half just flat:
stepsaw.png
stepsaw.png (5.01 KiB) Viewed 3183 times
Which sounds like this:

What can be done is shown in the X-4046: you can either buffer then sum both sides of the cap, getting a double frequency saw, or differentially amplify and offset them to “piece together” a triangle. All in all this might be a simpler way to achieve what the hacksaw does, but I wanted to give the step-wise approach a proof of concept anyway.
As always, thanks to aotmr for the support and the observations. I hope that even if you don't try these circuits, this can be helpful to someone.
Last edited by dylan159 on 15 Mar 2022, 16:32, edited 3 times in total.
Personal blog/archive: https://bentfishbowl.wixsite.com/electronics
Find me at https://discord.gg/bMuhX4TkZM Audio Electronics discord server.

User avatar
uncleboko
Cap Cooler
Information
Posts: 509
Joined: 25 Mar 2008, 20:19
Has thanked: 58 times
Been thanked: 41 times

Post by uncleboko »

Very interesting

User avatar
Serge75
Information
Posts: 26
Joined: 06 Sep 2012, 10:12
Has thanked: 13 times
Been thanked: 6 times

Post by Serge75 »

Impressive! Love that bass demo. Well made!

User avatar
UncappedOptics
Information
Posts: 8
Joined: 08 Sep 2019, 13:17
Has thanked: 6 times
Been thanked: 20 times

Post by UncappedOptics »

Great work! I can tell a lot of effort went into the design.

I'm not typically one for synthy PLL pedals but this is an exception, it sounds much nicer than other pedals since it's not as chaotic or "sputtery"

User avatar
dylan159
Resistor Ronker
Information
Posts: 268
Joined: 18 Jul 2018, 14:02
my favorite amplifier: Chempion!
Completed builds: Oh boy...
Has thanked: 97 times
Been thanked: 536 times
Contact:

Post by dylan159 »

UncappedOptics wrote: 14 Mar 2022, 19:18 Great work! I can tell a lot of effort went into the design.

I'm not typically one for synthy PLL pedals but this is an exception, it sounds much nicer than other pedals since it's not as chaotic or "sputtery"
It's not perfect but I've tried! Some version of this has been sitting on breadboard for almost two months.
Personal blog/archive: https://bentfishbowl.wixsite.com/electronics
Find me at https://discord.gg/bMuhX4TkZM Audio Electronics discord server.

User avatar
Lani
Solder Soldier
Information
Posts: 200
Joined: 22 May 2017, 11:57
my favorite amplifier: Bassman 5f6a
Completed builds: .....ummmm yeah. Too many to list.....
Location: Ithaca, New York
Has thanked: 135 times
Been thanked: 93 times

Post by Lani »

Nice work Dylan, thanks for the explanation of how you went about designing this. I feel a PCB layout is in order. I'll upload it here once I finish it, unless you oppose.
This one works as it is, but I sure don't like the odd number of op-amps for example
Couldn't you use the other half of the TL072 in the "Hacksaw" to buffer the Vr rail?

User avatar
dylan159
Resistor Ronker
Information
Posts: 268
Joined: 18 Jul 2018, 14:02
my favorite amplifier: Chempion!
Completed builds: Oh boy...
Has thanked: 97 times
Been thanked: 536 times
Contact:

Post by dylan159 »

Lani wrote: 15 Mar 2022, 10:28 Nice work Dylan, thanks for the explanation of how you went about designing this. I feel a PCB layout is in order. I'll upload it here once I finish it, unless you oppose.
This one works as it is, but I sure don't like the odd number of op-amps for example
Couldn't you use the other half of the TL072 in the "Hacksaw" to buffer the Vr rail?
Lani! I didn't ask for it but I was hoping for this. The PLLedal can definitely use a layout, maybe with a patch point from the second stage for rectification.
For the Hacksaw, you can but there's not much point to it. If one wants to blend with the square you can use the mixer already there. Maybe a resonant filter, a rectifier, I don't know :D
Using the capacitor as output doesn't fix this issue because it requires two buffers and a differential amplifier.
Personal blog/archive: https://bentfishbowl.wixsite.com/electronics
Find me at https://discord.gg/bMuhX4TkZM Audio Electronics discord server.

User avatar
MGaburriJazzDude
Information
Posts: 12
Joined: 23 Feb 2015, 20:25
Location: Buenos Aires, Argentina.
Has thanked: 6 times
Been thanked: 4 times

Post by MGaburriJazzDude »

AMAZING!

User avatar
Serge75
Information
Posts: 26
Joined: 06 Sep 2012, 10:12
Has thanked: 13 times
Been thanked: 6 times

Post by Serge75 »

Excuse me, does U2b pin6 really connects to volt reference? Or should I exchange pins 5 and 6? Im trying to veroboard this and i got this doubt. By the way which optio n was usted for first bass sample? Thanks a lot

User avatar
dylan159
Resistor Ronker
Information
Posts: 268
Joined: 18 Jul 2018, 14:02
my favorite amplifier: Chempion!
Completed builds: Oh boy...
Has thanked: 97 times
Been thanked: 536 times
Contact:

Post by dylan159 »

Serge75 wrote: 28 Mar 2022, 18:00 Excuse me, does U2b pin6 really connects to volt reference? Or should I exchange pins 5 and 6? Im trying to veroboard this and i got this doubt. By the way which optio n was usted for first bass sample? Thanks a lot
Sorry for the very late reply, I hope it's ok to answer anyway and maybe help others too. The schematic is correct, that's a comparator with positive feedback giving hysteresis. As from the notes, the first clip is just the comparator: you can get that sound without most of the circuit! Then I blend towards the PLL which is a sloppier square wave but a square nonetheless. I guess you like square waves! :lol:
Personal blog/archive: https://bentfishbowl.wixsite.com/electronics
Find me at https://discord.gg/bMuhX4TkZM Audio Electronics discord server.

User avatar
Serge75
Information
Posts: 26
Joined: 06 Sep 2012, 10:12
Has thanked: 13 times
Been thanked: 6 times

Post by Serge75 »

Thanks a lot, this one sounds great for dure, well most of your projects as If can Hear from your demos, btw wonder how your barbershop version sounds with bass. And that last vca It is very interesting but something I had to learn more about, Before I can use use It properly. A Big thank you for all your projects.

Post Reply