top of page

CD4046 fun: the PLLedal and the Hacksaw

Updated: Aug 22, 2022

Originally posted on the Freestompboxes forum

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.


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.


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.


The 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, altough 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 in http://www.geofex.com/Article_Folders/Freq%20Mult-Div.pdf

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:

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.

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:

Conclusion

I've only included the most interesting findings of my experiments, but here's a 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:

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.


Build update

I've finally built the effect in a permanent box, specifically a Teko B3 sheet metal box, with dimensions comparable to a 1590B. Here's some pictures of it:

It was a snug fit, but the extra depth helped with fitting all the switches under the board. Not posting the PCB layout yet because there are some revisions to make, especially regarding the rotary switch wiring, which I ended up doing by hand, using the pads just for mechanical support. Thanks anyway to Lani for showing enough interest in the circuit to make a layout for it.

406 views0 comments

If you want to leave a comment, try to be logged in, even with a throw-away account, so that I get notified.

bottom of page