CD4049/CD4050: 7400 V 7400 Inputs 7400 Output CD4050 V CD4050 in CD4050 Out
CD4049/CD4050: 7400 V 7400 Inputs 7400 Output CD4050 V CD4050 in CD4050 Out
CD4049/CD4050
You might use the CD4049 or CD4050 CMOS devices if you don’t need high switching
speed (these have a worst-case rise/fall time as high as 120ns). The CD4049 is a hex
inverter, while the CD4050 has six noninverting buffers. These CMOS devices can be
supplied with VDD=+3.3V to match the Raspberry Pi yet accept an input signal as high
as +18 volts. When operating at +3.3 V, the VIL maximum is approximately 1.0 volts (30
percent VDD), and the VIH minimum is +2.3 volts (70 percent VDD). Given that the 7400
datasheet lists a VOH minimum of +2.7 volts, this meets the CMOS input requirements (the
VOL/VIL parameters are also met).
Repeating the experiment using the 7400 quad NAND gate to drive a CD4050, you
get the DC readings shown in Table 2-11. The schematic is the same as Figure 2-5, except
that IC1 is the CD4050 and IC2A is one of the 7400 NAND gate outputs (with inputs wired
together, to behave as an inverter).
7400 VCC 7400 Inputs 7400 Output CD4050 VDD CD4050 In CD4050 Out
+5.01 volts Gnd +4.65 volts +3.30 volts +4.65 volts +3.30 volts
+5.00 volts +0.036 volts +0.036 volts +0.012 volts
Once again, you can see that the CD4050 happily accepts a high input voltage of
+4.65 volts. Had a protection (clamping) diode been involved, this voltage would be
lowered to about +3.9 volts or a little more. Because the CD4050, however, does not do
this kind of limiting, it works well as a level converter. Its main disadvantages are lower
speed and the fact that you get only six buffers instead of eight.
16
Chapter 2 ■ 3V/5V Signal interfaCing
VDD
D2
Q2
R1
Input Output
D1
Q1
GND
Figure 2-8. Inverter equivalent circuit
The inverter circuit shown has the FET transistors Q1 and Q2 arranged in the typical
CMOS configuration. When one transistor is on, the complementary transistor is off. The
input is usually guarded by a low-valued resistance R1 to limit the current flow when a
static discharge occurs. Since the metal-oxide gates do not conduct electricity, the diodes
D1 or D2 are designed to bleed the static charge away. By bleeding the charge away, the
voltage levels are kept low enough to prevent gate puncture damage.
For the student, schematic diagrams are drawn so that diodes form an arrow of
conventional current flow. That is, the current is shown flowing from plus to minus even
though physicists have long ago proven that electrons flow from minus to plus. If you
pretend conventional flow is correct while we look at the diagram, you can visualize
the fact that no current flows from plus to minus through the diodes because they are
reversed in polarity.
If you pet a cat and then come in contact with (or close to) this gate’s input, static
electric current will flow from the input through D2 or D1, depending upon whether the
electric charge is positive or negative. I have not been able to determine which charge it
is though I have regularly snapped sparks to our cat’s ears. If you shuffle your feet on a
carpet, the generated charge may be positive or negative depending upon the materials
involved.
The protection diodes work rather well for static charges under normal handling
conditions. The problem occurs when you want to do something like feed a 5V signal
into a CMOS input when the device is operating at a supply voltage of +3.3 volts. Examine
Figure 2-9, which is rearranged slightly to illustrate the high voltage flowing into a lower-
voltage device’s input.
17
Chapter 2 ■ 3V/5V Signal interfaCing
+5V Input
R1
D2
VDD
+3.3 V
Figure 2-9. Current through protection diode D2
If the input pin of the inverter is raised to +5 volts, then the input voltage is above the
chip’s own supply VDD=+3.3 volts. This difference is as follows:
The voltage that develops across a silicon diode is usually about 0.6 volts, so you
need to subtract that to arrive at the voltage across R1.
The resistance value isn’t normally provided in the datasheets but may be near 200
ohms [4]. This means that when the input signal is provided at +5 volts, the current flow
through R1 is as follows:
1.1volts
I R1 = 5.5mA
200W
The difficulty is that you have no guarantee that the protection diode can sustain
5.5mA of current. The protection diodes are designed to discharge weak currents for brief
periods of time. For this reason, you shouldn’t design a circuit to rely on its use. A similar
problem exists when the input is made less than -0.6 volts (negative), causing current to
conduct through D1 instead.
The special feature that permits you to provide a higher-than VDD input voltage is a
protection circuit that depends upon a Zener diode for D1, as shown in Figure 2-10.
18
Chapter 2 ■ 3V/5V Signal interfaCing
VDD
Q2
R1
Input Output
BV=30V Q1
D1
GND
Figure 2-10. Inverter with Zener input protection
19
Chapter 2 ■ 3V/5V Signal interfaCing
The main reason for this is that you must power the device from 5 volts in order for
it to have an output swing from 0 to 5 volts. Its outputs must match the receiving TTL
input levels (VIL of 0.8 volts maximum and VIH of 2.0 volts minimum). Let’s first review the
74HCT245 device.
74HCT245
The main trick, however, is that the 74HCT245 device itself must accommodate a low
enough input VIH for the driving Raspberry Pi. Normally the CMOS high level (70 percent
of 5 volts) would mean a VIH of 3.5 volts. This is higher than the Pi can produce! But
because the HCT family is designed to accept TTL input levels, you can count on its VIH to
be 2.0 volts instead. This is the special talent of the HCT family.
To make this easier to visualize, examine Figure 2-11. Notice that the 74HCT245 is
being supplied by 5 volts this time, allowing its output to range from 0 to 5 volts. Even
though the input to the 74HCT245 can go as high as 5 volts, the Pi will never deliver more
than +3.3 volts. This is why it is important that the VIH of the 74HCT245 is as low as 2 volts.
Notice from the CMOS device on the left, sending to the '245 in the center and driving
the TTL device at the right, the signal parameters are exceeded at every turn. By having
this “noise margin,” a small noise blip on the signal won’t push it out of spec and cause
erroneous readings.
74HCT245 TTL
+5.0V
Raspberry
3.2-3.3V
Pi
(CD4001)
2.7 – 5V
2.0-5.0V
+3.3V
VOH VOH
2.0-3.3V
VIH VIH
0 - .5V
VIL VIL
0-.03V
0-.8V
0-.8V
VOL VOL
Gnd Gnd
Figure 2-11. 3V CMOS to 5V TTL conversion
20
Chapter 2 ■ 3V/5V Signal interfaCing
GND
Figure 2-12. 3V to 5V conversion circuit
21
Chapter 2 ■ 3V/5V Signal interfaCing
+3.30 volts Gnd +3.30 volts +5.03 volts +3.30 volts +5.03 volts
+5.03 volts +0.0010 volts +0.0010 volts +0.004 volts
74HCT244
The 74HCT244 is a simpler part because it is unidirectional and may be lower in cost.
Again, this part must operate from +5 volts like the 74HCT245 discussed earlier. If you’re
squeezing the last few microamps out in power savings, the '244 device is feeding fewer
transistors internally.
The pinout is the same as the LVC part shown earlier in Figure 2-7. Simply supply
your Pi inputs to the 75HCT244 inputs, and the 5V logic outputs will appear at the device
outputs. Make sure that the OE pin is grounded to enable the outputs.
Switching Speed
One parameter that I have avoided discussing is the switching speed of various devices.
For driving LEDs and motors, speed may not be critical. You might desire higher data
rates for SPI interfaces, on the other hand. The question naturally arises, how fast can my
device go?
The datasheets won’t answer this directly. They do, however, provide the following
parameters:
• tPHL: Propagation delay time, high to low
• tPLH: Propagation delay time, low to high
The Fairchild CD4001 datasheet lists these values, as shown in Table 2-13.
For this device, both parameters have the same times, but they need not be identical
(these are the values listed for 5V operation). So, the absolute maximum speed these
devices can signal from low to high and low again can be calculated as follows:
1 1
F= = = 2 MHz
t PHL + t PLH 250 ns + 250 ns
22
Chapter 2 ■ 3V/5V Signal interfaCing
But this is not all there is to it because the signal must usually hold for a time in one
state or the other. The actual rate could easily be half or less. If, for example, the high state
hold time is 50ns, the rate reduces to the following:
1
F= = 1.82 MHz
250 ns + 50 ns + 250 ns
The NXP 74LVC244 datasheet specifies in a small print note that “tpd is the same as
tPHL and tPLH.” They list tpd with a maximum of 7.5ns for this device at 3.3 volts. So, what is
the absolute maximum frequency for this device?
1
F= = 66.7 MHz
7.5ns + 7.5ns
Notice the difference in signal rate. Again, this does not take hold times into account,
but knowing the absolute limit is helpful in planning. As Clint Eastwood said (as Harry
Callahan), “A man’s got to know his limitations.”
Summary
This chapter has been a little intense about signals, levels, voltages, and parameters.
This was designed to help you understand the critical issues involved. If you don’t yet
have a mastery of digital electronics, then you’d still be well served with the following
simple advice:
• When converting from 5 volts down to 3 volts, use the 74LVC244
device (or 74LVC245), powered by +3.3 volts.
• When converting from a 3V signal up to 5 volts, use the 74HCT244
device (or 74HCT245), powered by the 5V supply.
• When considering alternative devices, don’t forget to evaluate
their switching speeds. Many older devices are much slower than
today’s devices.
• Never connect a 5V device directly to a 3V device.
The knowledgeable electronics practitioner will know some other alternatives. But
the LVC and HCT family solutions presented are simple, economical, and reliable for the
Raspberry Pi enthusiast. For each '244 you get eight level shifters in one chip.
23
Chapter 2 ■ 3V/5V Signal interfaCing
Bibliography
[1] “Logic Voltage Levels.” Wikipedia. Wikimedia Foundation,
n.d. Web. 17 Apr. 2016. <https://en.wikipedia.org/wiki/
Logic_level>.
[2] Lancaster, Don, and Howard M. Berlin. CMOS Cookbook. 2nd
ed. Indianapolis, IN: Sams, 1988. Print. p19.
[3] “7400 Series.” Wikipedia. Wikimedia Foundation, n.d. Web. 02
Apr. 2016. <https://en.wikipedia.org/wiki/7400_series>.
[4] Lancaster, Don, and Howard M. Berlin. CMOS Cookbook. 2nd
ed. Indianapolis, IN: Sams, 1988. Print. p21.
[5] “CD4049UBC – CD4050BC Hex Inverting Buffer – Hex
Non-Inverting Buffer.” Fairchild Semiconductor, n.d. Web. 18
Apr. 2016. <https://www.fairchildsemi.com/datasheets/
CD/CD4049UBC.pdf>.
24
CHAPTER 3
Most Raspberry Pi projects need a display of some kind, unless it is being used as an
embedded system. These days there are nice HDMI monitors and nice touch screens
available. But these displays still command a fair investment. This chapter will explore
inexpensive, used VGA monitors. With the correct type of adapter and Pi configuration,
you can repurpose some used VGA LCD screens. VGA monitors will eventually become
scarce, but while they last, they are a boon to the maker.
VGA Converters
One of the great things about the Raspberry Pi Zero is that you get a video interface for
free (or split the Zero’s price of $5 in two: $2.50 for the Broadcom video core and $2.50 for
the CPU). This is a spectacular feature that cannot be matched in the Arduino world.
Using the Pi’s video interface naturally requires a monitor. This chapter explores how
to use a VGA monitor on a Raspberry Pi using a VGA converter. VGA monitors can be a bit
finicky, however, so I’ll also discuss video settings to allow you tune your Pi to match the
monitor.
I purchased an HDMI to VGA converter on eBay for the unbelievable price of $2.80.
My own experience with it so far has been very good. There doesn’t seem to be any
manufacturer information on the outside. It is possible that it has not been tested against
the North American and European radio emissions standards, so buyer beware.
■ Warning When shopping on eBay, be careful not to buy a simple cable adapter. You
need more than a cable/adapter to make this work, so check the description carefully.
Usually the cable/adapter auction information will include a warning that “converter is
needed when connected to the PC and TV.”
The unit I purchased includes an electronic converter circuit, which obtains its
power from the HDMI cable. The only suitable unit that I am aware of looks like the one
in Figure 3-1.
I already owned several VGA monitors, but I wondered about general VGA monitor
availability. They are bound to be more plentiful presently given that everyone is
switching to HDMI monitors. A search on Kijiji quickly confirmed that they can be had
for as little as $20 (and probably less by the time you read this). For example, one $20
monitor I found being sold was a Samsung SyncMaster 193V 19-inch LCD monitor. The
native resolution was 1280×1024. Such a deal!
With a VGA converter and a cheap VGA monitor, you can strap the Pi on the back of
the monitor and have a cheap self-contained display terminal. With the Pi 3, you could
have a self-contained Linux terminal with WiFi and Bluetooth.
If your monitor supports 1024×768 or greater resolution, you may find that you can
use the default Pi settings. Install the adapter and boot up the Pi to see whether it works.
If not, don’t give up yet—you may be able to reconfigure the Pi for a lower resolution.
The flexibility of Broadcom VideoCore is amazing when you consider the price of the $5
Raspberry Pi Zero or other Pi model.
26