Another less familiar but very useful IC that even we didn't know we needed, until we discovered it recently while solving a real-world problem.
This Classroom installment comes courtesy of another project we were working on, which led to us investigating an IC we had never given much thought to. The CD4060 is a 14-stage counter, with its own in-built oscillator ability set by three external components, and ten of its fourteen stages accessible as output pins. It counts in binary rather than sequentially like the venerable CD4017. It ended up solving a real-world need for us, and now we think other people will find it a good problem-solver too.
Whenever a maker, experienced or not, has a need to time, sense, or control anything, we often reach straight for a microcontroller. This thinking is largely justified by the capabilities and often simplicity of using a micro, but sometimes it becomes a habit, the box of which we don't think outside of. There are situations where a discrete circuit (discrete meaning separate and referring to the components the circuit is made from) is cheaper, smaller, or even more reliable or rugged than one based on a microcontroller.
One of the reasons we don't reach for discrete components so easily anymore is that, with the prevalence of microcontrollers, we are simply not as familiar with what's out there. When individual ICs were all there was besides the older micros that took a lot of knowledge to use, the range of discrete ICs was more front-of-mind. Even for professionals, however, the number of available devices is bewildering, and this has also contributed to the 'do it with a micro' mentality.
Sometimes, even though a micro may not be the best option, it's the best after you consider the time spent looking for and researching the available discretes. Add to that the fact that many of the sellers are large-quantity commercial operations, and micros start making lots of sense.
This is why we've included many non-micro discrete components in our Classroom articles over recent issues, alongside some discrete components ideally suited to use with microcontrollers. Both categories of components solve real needs, and can have advantages in certain situations over micros, but the available range is just not so well known anymore.
It wasn't in the front of our minds either, when we decided to make the soldering iron timer that features in this issue. For reasons we discussed in that article, we rejected a microcontroller and instead looked for discrete options. That's when we discovered the CD4060 14-stage counter.
On the subject of discovering discrete components, our first avenue is to look at the catalogues and listings from the major retailers. The section of the catalogue dealing with, say, 4000 series CMOS ICs may be something many glance straight past, but it's always worth reading over. If you go straight to some of the commercial suppliers like Element 14, even though they are a maker-friendly seller, there are simply thousands of listings and it is easily overwhelming.
Whenever we're making anything, from Kids' Basics to our most complex projects, we research the way other people have done the same or similar things. This is partly to make sure we don't end up with almost the same thing even though we developed it independently, which can happen surprisingly easily in electronics.
However, the process also yields information for other areas or projects, including components people have used for different jobs, or the way in which they are used. We find it useful to deliberately look at circuits from before microcontrollers were commonplace as well.
Engineers work this way too. No one reinvents the wheel if they don't have to, and no one uses an IC just from the pinout. Other designs are always consulted, examples examined, and simulations often run.
That's a lot of non-CD4060-specific information, but hopefully it helps you share our thought process and apply the logic involved to other situations and find discrete components more easily.
GETTING TO KNOW THE CD4060
The CD4060 is sold on the retail market in a 16-pin Dual Inline Plastic (DIP) package, though others are available commercially. Markings also vary by manufacturer. Our batch of ICs, bought in one sale from one supplier, was a mix of Fairchild old stock and more recent STMicroelectronics examples. Fairchild devices are stamped CD4060BCN while STMicroelectronics use the code HCF4060BE. On the subject of datasheets, we used those two plus Texas Instruments' datasheet for our information, but it is always good practice to find a copy of the datasheet for your specific device, both brand and version. Sometimes manufacturers make small design changes, and sometimes they do not. The datasheets also explain what each manufacturer's extra letters mean, and how their batch and date codes work.
Because of the complex internal layout, the outputs are not sequential. There is a clock pin which can be fed from an external source, or connected to the internal oscillator via a resistor and capacitor from adjacent pins. Strictly speaking, the capacitor and two resistors are part of the oscillator, so it's not entirely internal, but it's easier to speak of it this way, and those external components would not be alterable if the whole oscillator was internal.
Besides that, the voltage supply and ground pins are in the usual places, and there is an external reset pin. A high signal on this pin resets all outputs to zero, and stops the oscillator. That's very useful, because in an external oscillator situation, the counter would start again on the next transition after the high was removed. This means the external timer's cycle and removing the high are not synchronised and so timing is less predictable. If the high is removed half-way through the low on an external clock signal, there is still half a low and a high to elapse before the trigger. That's three quarters of a timing period assuming a square wave, and this can be hard to factor in. Using the internal oscillator, the timer starts when the high is removed, therefore counting is predictable relative to the reset signal. One more thing: When the IC powers up, the outputs are not in any one state and can be all over the place. They will not function until the reset pin has been pulsed high, every time the IC is powered up.
Electrically, the CD4060 aligns with the rest of the 4000 series having a wide supply range of 3-15V DC, and being officially static sensitive. While we treat ours as though they are susceptible to Electro-Static Discharge (ESD), the datasheets for both Texas Instruments and STMicroelectronics both state and show that the inputs have clamping diodes. The Fairchild datasheet does not state this, nor show a diagram. It is possible that some manufacturers include diodes and others do not, so use ESD precautions as a matter of course. It's best practice and the only way to provide certainty that damage will not occur.
One quirk with the CD4060 comes from the way the oscillator connection pics are labelled. The symbols chosen are derived from the internal structure of the IC, which contains many flip flops, among other things. This means that the symbols used may be confusing to people who are not familiar with them already, as they relate to the internal function of the pin rather than the external. To confuse the issue further, we saw datasheets which use the Greek letter Theta (Θ), Greek letter Phi (Φ), or even the Latin Script (as used in the English Alphabet) Q. Accordingly, we've shown here what the symbols are on the datasheets, what that pin does, and what we will call that pin in this article.
CLOCKING AND TIMING CIRCUITS
The count is advanced on the negative edge of the clock waveform. Because the clock input is Schmitt triggered, the rise and fall times do not affect the clock: It is triggered suddenly at the half-supply voltage point. This contrasts with some timers and flip flops which need the clock to go almost high or almost low in order for a trigger to happen.
However, clocking with a slow rise and fall time will still affect the maximum speed you can clock the device at, by virtue of the time taken by those sloped transitions.
There are three ways to clock a CD4060: Externally, with an RC network, or with a crystal. External clocking is the simplest to describe, as it requires feeding a clock ›› waveform to pin 11, the Clock pin. This is where most of the previous paragraph becomes relevant. In these cases, however, you're more likely to be concerned about the actual count rather than the time taken for a clock pulse, but it's worth thinking about. Note that because timing occurs on the negative, or high-to-low, transition, care will need to be taken if your clock comes from a non-oscillating source, such as the input from a sensor.
The signal from that sensor may require inverting, such as the pulses from a tachometer going high when the reference point passes the sensor. You can make a simple inverter from NPN and PNP transistors, as we have done in the Soldering Iron Alarm elsewhere in this issue.
The CD4060 can also be clocked with a crystal. Crystals follow their own rules and their operation is not specific to the CD4060. Diagrams are provided in the datasheets showing connections. Crystals resonate at a set frequency, and are available in a range of values. However, with a maximum clock rate of 12MHz at 15 volts supply, and as little as 1.5MHz at 5V, not so many of the available crystals will be useful.
The Fairchild datasheet provides a connection diagram with values, while the Texas Instruments document provides one with formulas. In either case, the use of crystals, in general, will need to be understood, and the data of each crystal obtained including its capacitance. For the purpose of an introductory article such as this, it's best to keep the use of crystals for the future and stick with the third timing option for now.
The third way to clock the CD4060 is the one most likely to be used by makers. It involves connecting two resistors and a capacitor to pins 9, 10, and 11. The capacitor can be non-polarised or polarised, but we recommend sticking to non-polarised types. This is because electrolytic capacitors, the most common polarised types, have voltage curve characteristics that change with applied voltage. This means that the ideal charging curve often does not apply until reasonably close to the rated voltage.
Using a 63V electrolytic on a 5V supply may not give the calculated results. Additionally, most of the time those values are really too large, as you'll see soon. If you do need to use a polarised capacitor by virtue of needing a large value, try a more consistent Tantalum type and make sure the positive side goes to pin 9.
There is a formula given in the datasheets which states that RS should be between two and ten times the value of RT. This might mean you have to calculate a few times if, say, your chosen capacitor value in the formula states you need an RT of 10MΩ. Good luck getting an off-the-shelf 20MΩ resistor from a retail supplier! Sometimes the whole process is a bit of a guessing game because of the available capacitor and resistor values. However, because there are many more resistor values available, we suggest starting your calculations with a chosen CT value rather than RT.
CALCULATING TIME PERIODS
When using the internal oscillator with an RC network, there is a formula for calculating the time period. This period is the time at the end of which a count occurs. To calculate the time period t, use the formula
t = 2.2 x RT x CT
Most of the time, you'll already have a desired value for t in mind, so you can transpose into either of these equations:
To find RT for chosen CT
RT = t(2.2CT)
To find CT for chosen RT
CT = t(2.2RT)
Remember to have all values in base units. See breakout box for more on that, or last month's Classroom for more still.
All of the outputs on the CD4060 are buffered, but at 5V, they can only source or sink around 1mA at room temperature. Even at 15V, the total is less than 7mA. While we got around this by using high-efficiency LEDs for our test circuit and just accepted a lower brightness, any application that does not feed the output to another logic input or similar will have to drive a transistor if you want the IC to live longer than a few hours or days at most. There aren't that many applications, however, where the outputs of the CD4060 will directly drive a load. The outputs are almost always going to be signals for another circuit.
While the CD4060 is a fourteen-stage counter, only ten of the stages have externally accessible outputs. The first three are not connected to pins, nor is the eleventh. Curiously, while many counters start from output '0', the first output is '1', and the first accessible output is output '4'. Some manufacturers do use the 0 start though, so your outputs may be labelled 1-14 (including the internal ones) or 0-13. There is also one in toward the end of the sequence that is unconnected, which is the 11th output. That's 11 in the 1-14 system or 10 in the 0-13 system.
The most crucial thing to understand is that the counter is binary, so each output will be high after twice as many counts as the one before. This means that the first three outputs, the internal ones, will go high after one clock transition, two, and then four transitions respectively. The first pinned output 4, will go high after eight clock transitions. Remember also that the negative high-to-low edge of the time period is the trigger, so on long, visible periods from half a second or so onwards, the outputs may not trigger when you expect. The first oscillation of the oscillator will have to occur then go low before you see anything, as there will be no trigger on the first internal stage until the clock has first gone high, then low again.
The formula for this is t = t2n, where t is the total time, t is the time period; we use the number '2' because each output is high after twice the number of counts as the previous one and is therefore doubled; and n is the number of outputs, or the number of times we're doubling the number. However, our first output goes high on the first transition, and is not doubled. Therefore, we need to take one power of two away. In other words, the fourth output will be t23 and the last, or fourteenth output, will be t213. For example, if the time period was 0.25 seconds, output 14 would have finished its time cycle after:
T = 0.25 x 213 = 2048 seconds.
Yes, that's thirty four minutes and eight seconds. That leans an LED connected to output 14 would light after 2048 seconds, stay on for another 2048 seconds, then turn off again for another 2048 seconds.
Remember also that n is 'to the power of', and not a factor of ten, or exponent. In other words, it is not 2 x 10n. So, t was 1 second and n was 4, the formula would be:
1 x 24,
1 x 2 x 2 x 2 x 2
= 16 seconds.
It is not:
1 x 2x104, which would be:
1 x (2 x 10 x 10 x 10 x 10)
= 20 000
This is a common mix-up for anyone not mathematically minded or who doesn't do these calculations often. If you get those functions mixed up on your calculator, you'll get some crazy results. Something else to note is that 214 is 16 384, but because the first internal stage triggers on the first clock, the first stage does not double, and we're actually one short as far as doubling numbers are concerned. See the output timings table.
Rather than trying to convey all this in words, our test bench build this month is a set-up of the CD4060 with LEDs attached to its outputs, and both an RC network to drive it or, alternately, a pushbutton switch driving an NE555 in monostable mode. We chose to do this because even a capacitor was not enough to debounce the switch adequately, so sensitive is the CD4060's input. While the right RC network would do the job, we absentmindedly forgot to try that. At the same time, we did end up needing an inverter circuit so that makers can use the more common normally open pushbutton switches, without having to search for or buy a normally closed type to give the low-going clock signal on the button press.
The first is standard package considerations. Fourteen and sixteen pin packages are the standard for the whole 4000 series, and though microcontrollers often have eighteen, twenty, twenty-four, or more pins, not many other ICs do. In the days prior to modern PCB design and manufacturing processes, sticking to standard footprints was a more important consideration. These ICs date from then.
In addition, in many counter and divider applications, the results from the first three outputs are simply too small or too fast to be useful. Other, cheaper options exist if you need that. We suspect that these are the reasons that not all the stages are connected to pins. If sixteen pins is the limit, then something has to go. We're also thinking that this is why pin 11 is unconnected: one more pin had to go, and pin 11 was it. Of course, there could be much more to it than this, and if you're curious enough to spend hours finding the answer, please let us know!
MANUAL OR AUTOMATIC RESET
As mentioned earlier, the reset pin must be taken high at power-up for the IC to function properly. Because the CD4060 will often be used as part of a bigger circuit, this high signal may come from there. In many cases, it will be a control signal from an external source. However, this will not always be the case. Sometimes the CD4060 will be set up as an oscillator to just do its own thing. That would be particularly the case in a duration timer or noise maker. In these cases, an automatic reset is needed.
The solution we came up with is to use a 10μF capacitor in conjunction with the 10kΩ resistor we already had in place to stop the reset pin floating. This allows current to flow as it charges, just long enough for the reset pin to do its thing. When it is charged, the reset pin goes low again and the circuit functions as normal. A manual reset button can still be used with this configuration and is recommended for test-bench applications.
Hands On: Test Build
This month's test build is a two-stage arrangement, whereby a pushbutton switch can be used to gain a tangible understanding of the workings of the binary counter. However, you'll get sick of pressing the button and are unlikely to want to push it 8192 times, so the second stage is to unplug the button and add the three timing components to use the internal oscillator. We're using diffused LEDs and running them at 1mA, so they'll be far from bright. This is the trade-off to avoid having a transistor for each output.
We're building the NE555-based monostable and the CD4060 heart on one standard breadboard, and the LED array on another. Not only will the whole lot not fit on one, but the pin order from the outputs of the CD4060 needs to be rearranged so the outputs can be seen in sequential order, albeit truncated (starting at output 4) and with one missing from the sequence (output 11). We show two pushbutton switches here, and two of the plug-to-plug jumpers in the bill of materials are for cutting in half and soldering to these switches so they plug into the board.
|Parts Required:||Schematic Id||Jaycar||Altronics||CORE ELECTRONICS|
|1 x Solderless Breadboard||PB8820||P1002||CE05102|
|1 x Pack of Breadboard Wire Links||PB8850||P1014A||CE05631|
|13 x Plug to Plug Jumper Leads||2 for switches||WC6024||P1022||PRT-12795|
|2 x 150Ω Resistors *||R2, R6||RR0552||R7538||COM-05091|
|2 x 1kΩ Resistors *||R3, R4||RR0572||R7558||COM-05091|
|10 x 2.7kΩ Resistors *||R10 to R19||RR0582||R7568||COM-05091|
|2 x 10kΩ Resistors *||R1, R9||RR0596||R7582||COM-05091|
|1 x 20kΩ Resistor *||R7||RR0603||R7589||COM-05091|
|1 x 200kΩ Resistor *||R8||RR0627||R7613||COM-05091|
|1 x 470kΩ Resistor *||R5||RR0636||R7622||COM-05091|
|1 x 100nF MKT Capacitor||C1||RM7125||R3025B||CE05188|
|1 x 390nF MKT Capacitor||C2||RM7159||R3032B||-|
|1 x 1μF MKT Capacitor||C4||RM7170||R3037B||CE07450|
|1 x 10μF Electrolytic Capacitor||C3||RE6066||R5065||CE05274|
|1 x NE555 Timer IC||IC1||ZL3555||Z2755||002-512-LM555CN|
|1 x CD4060 Counter IC||IC2||ZC4060||Z4060||-|
|2 x BC557 PNP Transistors #||Q1, Q2||ZT2164||Z1055||-|
|12 x 3mm Red Diffused LEDs||LED1 to LED12||ZD0100||Z0700||CE09856|
|2 x Pushbutton Switches||S1, S2||SP0710||S1060B||CE05249|
* Quantity shown, may be sold in packs. You’ll also need a breadboard and prototyping hardware.
# BC557 used in project, but any other transistor with the same specifications and pin-out can be used.
Start by constructing the monostable 555 circuit, with its inverting transistors. The component values chosen give a pulse close to 0.2 seconds. If your button push is longer than this the output continues, but does so consistently.
This system provides effective buffering and more debouncing than we were able to achieve with a capacitor across the switch. It also allows inverting of our switch signal. We have added LEDs for visual reference of what's going on. You may omit these but they help in fault-finding.
Plug in the CD4060 and add its power supply connections and the oscillator components. This section also needs a 10kΩ resistor between the reset pin 12 and ground. The same pin connects to one end of a pushbutton switch, the other end of which connects to Vcc. This reset switch will be useful during testing even if your final build never uses it.
There are wire links to connect the capacitor to pin 12 and the 555 circuit to the pin 11 clock input.
On a separate breadboard, add ten 2.7kΩ resistors. This value is high for an LED on 5V but limits the current to 1mA to protect the CD4060. Space them equally across the gap in the centre of the breadboard. Also, add ten wire links to connect each LED to ground. You can also install the LEDs now, or later if you prefer to make the wire connections between the two boards first. We left the legs of our LEDs long, both for later reuse and because this particular LED has no rim with flat section, and the leg length is the only viable identifier of polarity.
Sadly, the last step is messy. Because the outputs of the CD4060 are not sequential and come from both sides of the IC, plug-to-plug wires are needed rather than wire links to join the LEDs to the outputs. While this allows reordering of the outputs, it's never neat. Start from output 4 of the IC and connect it to the first LED, then work forwards until all ten outputs are connected. Also needed is one jumper wire between the ground rail the LEDs connect to, and the ground rail of the IC breadboard. The positive voltage comes from each output so there is no supply rail on this board.
Now you can apply power and start testing. First, remove one of the two wire links connecting the 555 monostable to the clock pin of the CD4060. We took out the small yellow one near the LED. You should be able to observe binary counting in action, as each LED from left to right is incremented at half the rate of the one before.
To get a better feel for exactly how the IC works, replace the wire link and remove the 1μF capacitor. This will stop the internal oscillator. Now, the CD4060 responds to button pushes from the NE555 circuit's pushbutton. Count how many button presses you need to light the first LED, then the second, then the third. At any time, a push of the button connected to pin 12 resets the counter to its zero state.
WHERE TO FROM HERE?
How you use a CD4060 is up to you. We have used it in a project this month as a medium-duration timer. We have also seen designs of music makers for kids, where the oscillator components are chosen so that the ten outputs produce audible frequencies. These are not going to be real music notes, however, as the doubling of the frequencies does not correspond to the difference between real notes even if you get one right.
We hope the CD4060 is another tool to keep in mind, whether as a timer or counter. Without our NE555-based addition, the part count to get a functioning circuit is very low indeed. This may just be the IC you need to sit there dividing, counting, or timing, either stand-alone or to feed a micro or other circuit.