Make your microcontroller I/O tasks smoother or easier with these buffers.
These simple but often overlooked ICs can make life easier when working with inputs which are not exactly the voltage that your microcontroller is running at. Maybe you have a 3.3V micro and want to use the more extensive range of 5V sensors. Perhaps you want to use a 5V micro with a range of 12V inputs from a non-micro system or circuit. The CD4049 and CD4050 are a pair of integrated circuits (ICs) which contain six buffers with single inputs and outputs each. The difference between them is that the CD4049 has inverted outputs, while the CD4050 does not.
The use of a buffer means that, as long as the voltage on the buffer’s input is high enough, the output of that buffer is high, but at the supply voltage of the IC. They have the advantage of smoothing ripply or noisy inputs too, provided there are no lows in that noise. In other words, they certainly won’t turn an AC signal into a DC signal! But, they will happily strip the alternator voltage spikes off the nominally 14.4V car electrical system and feed a smooth 12V signal to, say, a monitoring circuit checking for blown globes. In addition, the CD4049 and CD4050 can take input voltages above the chosen supply voltage. In other words, they level convert.
Despite the myriad of applications for these ICs, we’ll focus mainly on their use with microcontrollers. With a little thought, the information will adapt easily enough to higher voltages, like the car monitoring idea we just mentioned. We would fill volumes otherwise, because the use of buffers like this is often very specific and needs-based, and therefore comes with a huge variety.
WHAT IS A BUFFER?
Put simply, the word ‘buffer’ in electronics just means a device where the output follows the input. If the input is high, the output is high. Or, in the case of the inverted version, the output is low when the input is high. While this can be done with operational amplifiers (Op-amps), the buffer is specifically designed so that no amplification takes place. They are used to filter noisy inputs or give a stable output when input voltage might fluctuate. They are not isolators like an optocoupler is, because electrical connections are still shared. However, they do provide a way to connect mildly different voltages, or noisy inputs. They are not a safety device and cannot isolate high voltages.
GETTING TO KNOW THE ICs
The CD4049 and CD4050 are available on the domestic retail market in 16 pin PDIP (Plastic Dual Inline Package). Note in the connection diagrams that two pins are marked ‘NC’. Why not use a 14 pin package? Not only are the two devices pin-for-pin compatible so they can be interchanged, but they are also drop-in replacements for older devices that used separate supply and ground connections for the input and output sides of the device. Because the CD4049 and CD4050 are designed to run from a single supply, these pins are redundant but deleting them would mean the devices are not drop-in compatible with the old ones.
The other thing to note is that the input and output of each buffer are next to each other, not opposite each other. Inputs are labelled ‘A’ to ‘F’, while outputs are ‘G’ to ‘L’. This means that input 1 is 'A' and output 1 is 'G'. While this may be unfamiliar to makers used to numbered outputs, it isn't so confusing so long as you remember how many inputs and outputs there are, and can count down the alphabet. That's not sarcastic - conditions such as dyslexia make this genuinely hard for people with them.
The internal schematics show the input clamping diodes and the fact that there is no way of scaling the state change threshold. It will be around half Vcc regardless of the input voltage, visible from the connections of the gates of the MOSFETs inside. Notice also the fact that the CD4050 has two additional MOSFETs in its arrangement, which is necessary for the output to not be inverted.
Importantly, 4000-series ICs are CMOS (Complementary Metal Oxide Semiconductor) devices, which are generally considered static-sensitive. These devices should always be handled with electrostatic discharge (ESD) precautions in mind. We have seen many online ‘experts’ and some who should know better who say that you do not need to observe ESD precautions, and that ‘I’ve never had one fail’. The trouble is, there is always a first time. It may only be one buffer of the six affected, or it may simply change behaviour in hard-to-notice ways. Additionally, while it is true that some manufacturers build ESD protection into modern production versions of 4000-series ICs, not always reflected in the schematics, this is not true across the board. As a general rule, if it contains silicon, treat it like it is ESD-sensitive.
Finally, a word on input pins. If the input is left floating, we found experimentally that state change will not always occur when the input voltage is removed. This is particularly true when we were fiddling with our input voltage connected to a jumper lead and plugged into and unplugged from the board. This is why 10kΩ resistors appear connected to the used inputs in our test circuits. This ensures that the input does not float, and is low if there is no applied voltage. These are good practice to include anyway, but if your input device will ground the connection when it is not high, or in some other way provide a ground path, they will not be necessary. If in doubt, include them. In fact, include them unless you have a good reason not to.
Codes and electrical details differ between manufacturers. Throughout this article, we note sometimes which datasheet we got our information from, or which maximum Vcc we are talking about at that point. This is because all manufacturers do things just a little differently. The input voltage threshold to cause output state change varies between manufacturers, albeit slightly in most cases. The maximum supply voltage and current characteristics also change. Sometimes, even the label changes. While most manufacturers have different letter prefixes and suffixes, we found an anomaly from On Semiconductor.
This device is stamped as ‘MC14049BCP’ but it is definitely a CD4049. The addition of the ‘1’ is an On Semiconductor thing. As always, consult the datasheet for your specific device example’s manufacturer, but browse others as well. Sometimes other manufacturers have additional information in their datasheets, or easier to read documents.
For the record, we used both the Texas Instruments and Fairchild datasheets for this article, with the Fairchild one having clearer graphs. We used On Semi's for that particular IC.
There is possibly some confusion to be found in the datasheet, depending on how the reader interprets the language. The ICs are described as logic level converters, and are specifically stated to convert CMOS (generally above 5V to around 15V or 18V) to TTL (5V). However, toward the end of the Texas Instruments datasheet, in the ‘Detailed Design Procedure’ section, there is a line which states: “Inputs are not overvoltage tolerant and must be below Vcc level because of the presence of input clamp diodes to Vcc.” At first thought, particularly when this line is taken in isolation, that might imply that the voltage at the inputs cannot exceed the supply voltage. It’s even easier to think so at 11PM at night when things are a little foggy.
The answer is stated clearly in the ‘Description’ paragraph of the Texas Instruments datasheet, but by the time you get to the other end of the datasheet where the above line of text resides, the opening page is a distant memory swamped by information from tables and graphs. You can drive the inputs of the ICs higher than Vcc, but you cannot exceed the limits of Vcc. In other words, the input voltage cannot exceed the maximum Vcc for the IC you have. This figure varies between 15V and 20V depending on the manufacturer, but is commonly 18V.
This limitation occurs because there are diodes connected to the inputs and to Vcc, visible in the schematic near the beginning of the datasheet, and these diodes are not rated beyond the Vcc of the IC. In some other CMOS ICs, inputs are not so connected and can be taken well above Vcc limits. We have used devices in the past where the inputs could handle 40V or more, while the IC was supplied with 5V. This is definitely not the case with the CD4049 and CD4050. The inputs must be below whatever the Vcc maximum limit is for the IC you have. For the Texas Instruments ICs we used, this is 18V, but check the datasheets from the manufacturer stamped on your device when you have it in your possession.
The upshot of it all is that you could not, say, connect the output of a 12V solar panel to the IC in a system to remotely monitor whether the panels are outputting, because some solar panels can pass 20V when they’re open circuit. This often happens when a charger has disconnected them from a full battery and they are left floating. The same can be said of anything where voltage spikes exceeding Vcc limits are present. However, the CD4049 and CD4050 can most certainly be used with input voltages higher than the chosen supply voltage, within those maximum Vcc limits. If the IC you have is only rated to 15V, you would be wise to not even use it in an automotive situation, as alternator spikes can often pass 16V or so. While it would be a long time before 1V over killed the device, and it may not happen at all, it is still possible.
You can have a 12V input while running the IC on 5V. We verified this experimentally and let the smoke out, so you don’t have to!
Something else we verified experimentally was the input switching threshold. The information in the datasheets, including the schematics, made it very clear that there was no comparison between input voltages and supply voltages. There are entries in the electrical characteristics tables for ‘input high voltage’, and a graph, figure 6.2 (in the Texas Instruments datasheet at least) which show what the input voltage needs to be to cause the output to change. The table states that for a 5V Vcc, input voltage to achieve an output is a minimum of 3.5V. The graph shows it can be anywhere from 1.5V to 3.5V, at 25°C. This is effectively a tolerance across batches and cannot be chosen or controlled by the user. The Fairchild datasheet further shows in its tables a typical threshold of 2.75V for the CD4050 and 3.5V for the CD4049.
So, we tested it. We used a Texas Instruments CD4050BE, and connected it with its ‘A’ input grounded by a 10kΩ resistor. We connected 0V to the ground pin, 5V to the supply pin, and the ‘G’ output via a 470Ω resistor to an LED. For input voltage, we connected 12V across a 5KΩ linear potentiometer and linked the wiper to the input of the CD4050. Finally, a multimeter was set to voltage, and the positive lead connected to the wiper and the negative lead to the ground rail. With the potentiometer fully rotated clockwise (which corresponded to the wiper connected to ground in our configuration), we turned on our power supply.
As the potentiometer was slowly rotated, we watched the voltage climb. We first saw a flicker of light from the LED around 2.4V, so we backed off and went more slowly. We saw first light from the LED, very faintly, at 2.297V, and full brightness at 2.338V. This showed that the threshold was indeed around half Vcc for our IC, not half the input voltage.
It also showed that the figure 6.2 graph depicting a straight-line graph is not correct, and that in fact there is some slope to the switch-on voltage and its transfer into output.
A different, grainy, scanned data sheet seemed to show a sloped graph but wasn't clear enough to tell. Bear in mind that while LEDs have their own sloped response to rising voltage, the numbers quoted were for the input, while the LED was connected only to the output with its limiting resistor.
For the sake of the exercise, and to be thorough, we swapped the CD4050BE out for a CD4049. We found the LED to still be lit at 2.627V, and begin to flicker (largely due to the poor contacts of solderless breadboards) above that. This IC did not have any visible slope, the change of states being abrupt at an input voltage of 2.76V.
As stated earlier, there are differences between manufacturers and between devices from the same manufacturer. If your application demands a precise voltage threshold, we recommend a test like this. For many people, however, the precise switching voltage will not matter.
You can’t supply the IC with 5V, connect the inputs to 12V sources and expect output change to occur at the 6V point on the input, but most applications for this IC are not for monitoring dynamic signals. In most cases, the input voltage will either be fully on or fully off anyway. Even so, the test circuit that we used here and below is this month’s build. See ahead if you want to build it and follow along with your hands.
WHY USE IT?
As with many building blocks, these hex buffers will have uses that really only scream out at you when you suddenly need them. They are not a ‘one obvious job’ IC, like the motor control ICs we have looked at in the past. In those cases, you need them when you need to drive a motor. No rocket science there. Buffer/level converters like this are a bit different.
The biggest use we can see in such a device is to safely monitor for the presence or lack of a voltage on a digital pin, to avoid the need to use the analogue pins and lines of code to actually measure the voltage. In older aircraft, lamps and indicator globes often had monitoring circuits so that when a globe failed, an alert would be issued so the crew knew they could not rely on that indication. In many modern cars, headlight, indicator, brake, and taillight globes are monitored via the onboard computers so the driver is informed of a failed globe.
This kind of application is perfect for the CD4049 or CD4050, higher voltage electrical systems up to 15V or 18V can be monitored by a dedicated circuit and fed to digital I/O pins with a 5V input limit. The only other simple way to do this is to use the analogue inputs, and a small sensing resistor to drop a few millivolts across it when current is flowing.
The main use for microcontroller users, however, will be to use sensors that operate on higher voltages than your microcontroller. You could supply the CD4049 or CD4050 with 3.3V and access the range of digital sensors available for 5V Arduino and similar.
Logic level shifters exist for this purpose, and some are based on the CD4050 and CD4049. Being able to use a discrete IC has advantages at times, however, with the cost being one of the factors. Additionally, if you have digital sensors which are not 5V, such as many of the wireless alarm system outputs which use 12V or sensors designed for non-microcontroller applications, then these ICs are the solution.
The other use for the CD4049 and CD4050 is also one of its more valuable points. They are called buffers, and that means they provide a degree of separation between inputs and your micro.
There are times when you want to use a buffer without its level conversion abilities, just to avoid voltage spikes or noise arriving at your microcontroller inputs. Additionally, the inverting nature of the CD4049 can be useful too. You may have a sensor outputting a series of negative pulses and your coding situation is easier if they are positive.
You can see above diagram that the buffers will not compensate for gaps in the signal, just spikes. These spikes need to be within the input voltage limits for each specific IC. Some different devices (i.e., not the CD4049 or CD4050) have input limits much higher than supply, but these two will still suit most maker needs.
LOW TO HIGH CONVERSION
For microcontroller users, some people will want to know if the device can convert 3.3V sensor signals (or even the outputs from 3.3V micros) to 5V outputs. The answer, unfortunately, is ‘maybe’.
Officially, the devices when powered from 5V may need as much as 3.5V to cause an output state change. However, the ‘typical’ value listed hovers around 2.7V, and our bench test backed that up. In reality, you probably can use a CD4050 or CD4049 to utilise specialised 3.3V sensors (or just sensors you have bought in the past for a 3.3V micro and want to make use of with a 5V micro).
It certainly worked on our test bench, but be prepared to find that your specific IC from a different batch or manufacturer may not, or may not reliably. Give it a go, but you will have to bench test like we did above, and purchase a few chips if the first or second does not have such a low threshold.
However, the same cannot be said of a situation in which a 3.3V or 5V micro is required to give, say, 12V outputs.
With a CD4049 or CD4050 supplied by 12V, a 5V input may not reach the threshold required for output state change. Because of the tolerance given in the datasheets, you may pick up a device which happens to switch at this threshold, but there is no guarantee.
Having said that, most situations that we can think of where a microcontroller is required to control 12V involves load driving where currents exceed the ICs’ capabilities anyway, in which case, MOSFET motor drivers, relays, or other load controllers are required anyway.
Just for the sake of thoroughness, we tested the theory anyway. We used the same set-up as above, but with the 12V connected to the supply rails and the 5V connected to the potentiometer, and a resistor change to 1kΩ for the LED resistor. We dialled around the pot until we had reached 5V on the meter, and as expected, we had no state change in the IC.
Following this, we altered the circuit as shown here. This just involved the deletion of the 5V power connection entirely, and the wire linking of the potentiometer to the 12V power rails. This would enable us to find the state change threshold for the device when Vcc is 12V.
Sadly, it’s very close to useful but not quite. We had first light at 5.6V and full state change at 5.72V for our CD4050, and 5.49V at state change for the CD4049. As before, we also saw a slight slope to the change of state for the CD4050, but not was observed for the CD4049.
|1 x Solderless Breadboard
|1 x Pack of Breadboard Wire Links
|2 x Plug-to-socket Jumper Wires *
|1 x 470Ω Resistor *
|1 x 1kΩ Resistor *
|1 x 10kΩ Resistor *
|1 x 5kΩ 16mm Potentiometer
|1 x LED
|1 x CD4049
|1 x CD4050
|2 x 5.1kΩ Resistors
|1 x 5kΩ 25-turn Trimpot
* Quantity required, may only be sold in packs. Prototyping hardware is also required, along with a multimeter with alligator clip probes to connect to jumper leads, or separate clip-to-clip leads to join ordinary probes to jumper leads.
Because the CD4049 and CD4050 are small parts of a much bigger circuit in any practical application, we have foregone the usual build. We always try to have a circuit that at least functions in some practical way for Classroom, but with these hex buffers, the circuit really depends on the need, and we could not think of anything terribly interesting besides just turning LEDs on and off. Any further creativity will be situational and not nearly as adaptable as the building-block or demonstration circuits we try to present.
Because of this, we feel it is far more useful to present the test circuits we used above. As discussed, there will be people who want to find the state change threshold of their specific device, or simply familiarise themselves with it. We have the high-to-low level (or same level) circuit first, followed by the arrangement we used to test the low-to-high functionality.
For a power supply, we used our benchtop supply made from a computer PSU that we featured in Issue 7. This makes it easy to have 5V and 12V available easily and consistently, and has 3.3V as well for those who want to experiment with it.
HIGH TO LOW test circuit
Assembly is self-explanatory from the diagrams. We connected our multimeter by using alligator-clip probe tips, and pin-to-pin jumper leads, then set it to voltage. If yours is not autoranging, set it to the 20V scale. Double check that you have the power supplies in the correct place: The 5V to the supply rails and the 12V to the potentiometer. Then you can adjust the potentiometer to find the specific threshold of your device.
LOW TO HIGH TEST CIRCUIT
Again, assembly is straightforward, but this time note the connections from the potentiometer which are hard to see under the pot on the Fritzing. On our initial low-to-high test above, we just used the circuit from test 1 and swapped the power supply connections, but the 5V was not enough to trigger state change when the IC is supplied from 12V. The circuit here will allow you to find exactly where the threshold is for your device.
OPTIONS AND ALTERATIONS
If you are having trouble finding the exact spot on the potentiometer’s rotation, consider padding it out with two fixed resistors. Adding a 5kΩ fixed resistor on either side of the potentiometer alters the voltage divider arrangement so that, while the middle of the pot's travel is still the half the supply voltage (or the simulated input voltage in our case), the whole travel of the pot only covers a third of the voltage range, and thus it will be easier to dial down to a specific voltage. For want of better words, there will be less millivolts covered per degree of rotation.
Alternatively, you could substitute the 5kΩ 16mm pot for a 25-turn top-adjust type, where the resistance is spread across twenty-five turns of 360°. These need a screwdriver to adjust.
Further, while the information above is good for the CD4050 depicted, it is just as valid for the CD4049, and you can swap that IC directly into the circuits above.
While the CD4049 and CD4050 will only appeal to people with certain needs, they do their job very well with appreciable versatility. They are a good thing to keep in mind even if you have never needed one before, because one day, they may just be a simple solution to an otherwise perplexing problem.