Circuit Interfaces :Address and Data Decoders and Multi-Segment LEDs

Circuit Interfaces

For a sequential digital electronic circuit to be effective, it has to interface with something. This something could be a person or it could be other digital electronic circuits. If you were to look at different interfaces for either case (human or machine), you will discover that as the function of the circuit increases in sophistication, so does the interface. The reasons for this increase in interface complexity can be attributed to an increased amount of data to present as well as an increased number of operating parameters to choose from and select. The challenge is to come up with a way of adding these user and device interfaces simply, effectively and not affect the operation of the central sequential circuit.

Simple logic level switches and individual LEDs for each bit are perfect examples of the types of interfaces that I am talking about; to add these devices to your application, you generally don’t require any types of busses nor do you need to have any special communications protocols for communicating with the devices. These interfaces are simple to add and modify to an application.

The problem with simple logic level switches and LEDs connected to each bit is that they cannot be very descriptive; nor are they very efficient methods of transferring data. An eight bit system is quite manageable, but it becomes

very difficult when there are tens, hundreds or even thousands of bits to control and monitor. Early computers started out using simple switches and lights for input and output, respectively, but quickly outgrew them and began using printers, teletypes and punch cards to get state information from the computer. Today’s computer systems have very sophisticated input and output capabilities, requiring the power of a processor that would have been identified as a ‘‘supercomputer’’ 10 years ago or less.

An example of a complex interface that you would be hard pressed (if it were possible at all) to create digital electronics for is the Hitachi 44780 based LCD module (Fig. 10-1). The controller hardware is fairly complex and must be accurately timed. The LCD module works like a ‘‘teletype’’ or a single line TV display – as you write characters to it, a ‘‘cursor’’ will move to the right, to prepare for the next character. The character interface consists of the eight data bits and three I/O pins listed in Table 10-1.

clip_image003

Fig. 10-1. Sample LCD output.

image

image

I typically attach a series of pins to the 14 connector pins so that the LCD can be easily mounted on a breadboard. In some LCDs, you may discover that there are 16 connector holes with the extra two holes used for backlighting. Some other LCD modules have two rows of seven or eight pins. For the ease of creating the experiments in this book and wiring them to the breadboard you should just use LCD modules that have a single row of pins.

Wiring the LCD to the hardware is quite straightforward as you will see in the waveform diagram (Fig. 10-2). The only unexpected aspect of the interface circuit is a potentiometer used to set the ‘‘contrast voltage’’ used by the LCD. The potentiometer is wired as a voltage divider, with the contrast voltage pin connected to the wiper of the potentiometer. Depending on the type of LCD that you are using, you will find that the voltage producing the best contrast will either be high or low, depending on the technology used in the LCD.

To communicate with the LCD, you will have to send the data word slisted in Table 10-2 via the LCD interface. These bytes are commands that set the operating mode of the LCD or command it to perform some other operation. In Table 10-2, I have listed the different commands, along with the ‘‘RS’’ and ‘‘RW’’ lines that are used to control them. To clock in the command, the ‘‘E’’ bit must have a high value (‘‘1’’) written to it and then a low value (‘‘0’’).

Data displayed on the LCD is, for the most part, ASCII and you can pass ASCII characters directly from the hardware to the LCD. I say that the LCD can display ASCII ‘‘for the most part’’ because you will find that some characters are not supported (such as the backslash, ‘‘’’) and if you go outside the normal ASCII character limits, you will see Japanese characters on the display. If you were to send a carriage return, line feed or any of the other ASCII terminal command characters, you would discover that they Table 10-2 Hitachi 44780 based LCD command set.

image

result in a strange character being displayed. If you want to provide more ‘‘terminal’’-like functions to the 44780 based LCD you will have to write them yourself and add them to your application.

Most commands execute in 160 ms or less with the display clear and move cursor to home commands can take up to 5 ms. The initialization process for the LCD is:

1. Wait more than 15 ms after power is applied.

2. Write 0x030 to LCD and wait 5 ms for the instruction to complete.

3. Write 0x030 to LCD and wait 160 ms for instruction to complete.

4. Write 0x030 AGAIN to LCD and wait 160 ms or Poll the Busy Flag.

5. Set the Operating Characteristics of the LCD:

● Write ‘‘Set Interface Length’’

● Write 0x010 to disable display shifting

● Write 0x001 to clear the display

● Write ‘‘Set Cursor Move Direction’’ setting cursor behavior bits

● Write ‘‘Enable Display/Cursor’’ & ‘‘Enable display and optional cursor’’.

The LCD could be controlled by a state machine, but there would be a significant amount of work to do this (and the state machine would be quite large). Along with the eight bit interface, the LCD can also be controlled by a four bit interface; each character and eight bit instruction is passed in four bit blocks through the D7:4 pins, but this interface would probably be even more difficult to create for the LCD module.

Address and Data Decoders

When you have decided upon the interfaces to your application, you will probably have to determine the best method of selecting which device is active at any time. The method that would make the most sense is to use the same method that a microprocessor uses: output a bit value, selecting the device and one control bit to activate the interface device. Depending on the resources available, the section bits may consist of a number of bits, each one passed to a different interface device, or a binary value, which is decoded into a specific control bit.

image

Ideally, the signal being passed to the interface device would look something like Fig. 10-3 – an ‘‘Address’’ value is passed to the device and after a data ‘‘set up’’ time, a Read (‘‘_RD’’) or Write (‘‘_WR’’) line becomes active. A ‘‘Read’’ action polls the interface device and returns the value to the sequential circuit. A ‘‘Write’’ action does the exact opposite: it sends a value from the sequential circuit to the interface device.

You should notice that the timing of the read and write operations are quite a bit different. The short ‘‘Read’’ pulse is indicative of the expected operation of the device being accessed; once it receives the ‘‘Read Address’’ which selects the device, it takes some time to prepare the data before it can be read out. Similarly, when writing data, the _WR line is active for a surprisingly long period of time to allow the interface device to pass the data internally and prepare the interface circuitry to correctly store the data.

The interface read and write operations are good examples of situations where the latches rather than registers are used. When the _RD and _WR signals become active, data should be passed through them as quickly as possible rather than being held on a rising or falling value of the signal edge. For most applications, this need for taking advantage of every possible picosecond of time for data transfer is not needed, but you will find that it’s a good idea to work with a standard design interface that will work in all

situations.

Following this philosophy, rather than providing an individual bit to each interface device, how about a binary ‘‘address’’ that can be decoded to an individual address using a ‘‘decoder’’ like the 74139 (Fig. 10-4) that converts a two bit value into four individual active low outputs. The 74139 contains

image

two ‘‘two to four’’ decoders like the ones shown in Fig. 10-5. Decoders (also known as ‘‘demultiplexors’’) convert binary values into individual output lines and are primarily used to decode memory addresses to individual chips.

The resulting ‘‘interface’’ is essentially a computer ‘‘bus’’ and will allow you to add standard computer interfaces to your circuit, probably with no modification. You might have been wondering why I went through the effort of providing an interface select function along with the _RD and _WR signals – you may be thinking that a single pin that both selects the device as well as initiate the read or write would be enough; the philosophy of interfacing like in a computer is only so useful. This is true if you are going to only work with custom-designed interfaces, but there are a lot of standard interfaces (including the various ones presented in this chapter) designed for being accessed by computer systems that you will want to take advantage of.

Multi-Segment LEDs

I think you would be hard pressed to find somebody in the industrialized world that has never seen a ‘‘seven-segment’’ LED display (Fig. 10-6) before. It first became popular in the 1970s and is used in almost literally everything from digital clocks to car instruments. Seven-segment LEDs can be found virtually everywhere, being used not only in digital watches but also in kitchen appliances, cars, instruments and, of course, in videocassette recorders (VCRs). The flashing ‘‘12:00’’ on a clock or VCR created using seven-segment LEDs is the symbol of a person’s inability to handle the latest in technology.

In Fig. 10-6, I have shown the appearance of the seven-segment LED display – it can be put in the same ‘‘footprint’’ as a 0.300 inch’’ wide 14 pin DIP package, but some of the pins (‘‘N/C’’ for ‘‘no connect’’) are not present. The ‘‘DP’’ LED stands for the ‘‘decimal point’’.

The seven-segment LED display can be wired as either a ‘‘common anode’’ or ‘‘common ‘‘cathode’’; in this experiment we will be using ‘‘common anode’’, wired as shown in Fig. 10-7. For this part, the two ‘‘common’’ pins are connected to all (and occasionally some) of the anodes of the eight LEDs built into the display. This simplifies the wiring you will have to do somewhat and makes working with multiple displays a bit easier, as I will show in a later experiment.

Despite its commonality, the seven-segment LED display is not trivial to work with. There are a number of chips on the market that make the component easier to work with in some applications, but when you are working with your own sequential circuits, you will find that these ‘‘canned’’ functions never quite do what you hope for.

image

image

As you are probably aware, by turning on each of the different LEDs with their unique values individually, you can create a multiple-digit display. Figure 10.8 shows how by turning on different LED segments, the display can be used to display the 10 numeric characters. Along with the 10 numbers, there are a number of letters that can be displayed, although only a few of them look exactly like the characters they are supposed to represent. If you want to display letters as well as numbers, then you will have to use a LED with more segments – these are available as either 16-segment displays or as matrixes of LEDs that display the character as a multi-dot ‘‘font’’ like on your computer screen.

Each LED in the display can be wired conventionally to control whether or not they are turned on or off. Controlling individual LEDs in a single display is quite easy. It gets quite a bit more difficult when you have to display different values on multiple LED displays. To convert incoming bits to meaningful characters on the display, you will have to pass the bit values through a combinatorial circuit, like the one shown in Table 10-3 for the first four decimal digits.

In Table 10-3 in the ‘‘Comments’’ column, you can see that I have noted any commonalities between different equations and noted that segment ‘‘B’’

is always active for all four digits. I should point out that coming up with the equations for each of the segments is good practice for working with Boolean arithmetic equations, but it is much easier and simpler to buy a seven- segment LED driver. The 7447 chip is commonly used for decoding the incoming bits and driving the LEDs and is an excellent solution when there is

image

only one seven-segment LED display outputting information from the application.When multiple LED displays are required, instead of providing multiple- digit drivers, a single-digit driver is used and different values are passed to it for different displays very quickly. Figure 10-9 shows a four-digit LED display with each digit having a different value. Each digit is turned on momentarily to display its value and then switched off for the next digit. The eye’s visual persistence ignores the flickering if the sequencing is done fast

image

enough and it appears that all the digits are on simultaneously, even though they are displaying different values.

As a rule of thumb, each display should be active 50 or more times per second. The slower each display is flashed on and off, the more likely the human eye will pick up the flashing. A flashing multi-character display is not attractive and could cause headaches in some people (especially if the displays are very bright). The time each display is turned on must be as equal as possible. If one display is on for a longer period of time than the others, then it will appear brighter and, conversely, a display active for a shorter period of time will appear dimmer. When working with multiple displays, in order to meet the 50 times per second guideline, you are actually going to have to loop through your individual display action 50 times per second multiplied by the number of displays. So, for a four-digit display, you will have to loop 200 times per second and each digit will be on for 5 ms at a time. There are some chips, such as the very popular Maxim MAX7219 (Fig. 10-10), which can control multiple seven-segment LED displays. This chip takes care of all the driving and timing requirements for the displays; the only catch is that you must shift in the desired value for the display.

Leave a comment

Your email address will not be published. Required fields are marked *