Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Bailey O.H.Embedded systems.Desktop integration.2005

.pdf
Скачиваний:
70
Добавлен:
23.08.2013
Размер:
9.53 Mб
Скачать

240

Chapter 7 / Hardware Development

 

 

Four crimp type pins for the above connector (Jameco PN: 114921)

Next, we have two LEDs on the I/O board to connect. The first is a power LED used to simply indicate external power present. This requires only two components. Figure 7-34 illustrates how this circuit is connected.

Figure 7-34

This circuit contains only two components. They are:

One 5-volt green LED

One 470 ohm resistor (Radio Shack 271-1115)

The next LED will be attached to the general-purpose I/O pins on the LCD display (see Figure 7-28). This circuit is illustrated in Figure 7-35 and again uses only two components.

Figure 7-35

The following parts are required for the alarm LED circuit:

One 5-volt red LED

One 470 ohm resistor (Radio Shack 271-1115)

Chapter 7 / Hardware Development

241

 

 

The last component we will install on the I/O board is the temperature alarm buzzer. The alarm is connected to I/O pin 1 on the LK202-25. Figure 7-36 illustrates how the circuit works.

Chapter 7

Figure 7-36

This circuit again requires only minimal parts, in this case a piezo buzzer. I used the Radio Shack part number 273-065. This is a small buzzer rated at 70 dB and is rated for 3 to 16 volts.

While I put all of these circuits on a single board, you may wish to instead put them on separate boards. Keeping everything on a single board is easy and convenient, and once working and tested frees us to concentrate on the communications in upcoming chapters.

The final addition to this board is the power supply. This consists of an LM7805 voltage regulator. This device is rated at 1 amp, which will provide plenty of power for our circuit. Until now we have used the power from the regulator on the BASIC Stamp, but since that component is surface mounted the current rating is about half of this component’s current rating. The smaller the package the less current the component can handle, so we will add the supply to avoid any problems. Once we attach the Ethernet controller our current usage will go up and probably exceed the regulator on the Stamp. Our completed schematic for this board is shown in Figure 7-37.

242

Chapter 7 / Hardware Development

 

 

 

 

 

 

 

 

 

 

 

 

Figure 7-37

The first thing you will notice is that this board has three separate sections that do not share a ground wire — or at least it appears that way. In truth, the circuits do share common voltage and ground but in a different way than our previous boards. Let’s start with the upper-left circuit, which is our power supply. That circuit uses a 9- to 12-volt input and provides a 5-volt output at the connector PWR_OUT. Connector JP6 is a four-pin connector that provide the power, ground, data, and clock for the LCD display. JP5 is the I2C interface to a microcontroller. You will notice that both the clock and data lines get connected to the +5 volt supply through a resistor. There is also an LED connected through a 470 ohm (R1) resistor. This is the power indicator.

As we move clockwise, the next circuit is the alarm circuit. This circuit is connected to output pin 2 on the LCD display. Both the power and ground are provided by the LCD, but the power and ground originate from our power circuit.

The final circuit is our keyboard interface. This interface gets connected to the keyboard input on the LCD as we discussed earlier. Again, the original power was provided by our power circuit.

Chapter 7 / Hardware Development

243

 

 

Testing the LCD and I/O Board

Once all the functions have been added, the program in Listing 7-4 will run the board through its paces. Once completely wired you can test the functionality of the LK202-25 with this program.

Listing 7-4

//{$STAMP BS2p}

//This program will test the Matrix Orbital LCD Display

//It is a very simple program to use.

//The Matrix Orbital LCD contains a 2 x 20 LCD display

//6 general-purpose I/O lines, and keyboard support for up to 25 keys.

//The keyboard scan routine is interrupt driven so keystrokes are captured

//when they are pressed.

//

 

KeyChar VAR Byte

// Holder for Keystrokes

LastKey VAR Byte

 

PAUSE 1000

// Wait for System Start

Main:

// Main Program

GOSUB StartMsg

// Show StartMessage

GOSUB SoundBuzzer

// Sound Buzzer

PAUSE 1000

// Wait a Second

DEBUG CLS

// Clear Debug Screen

I2COUT 8, 80, [254, 88]

// Clear LCD Display

KeyLoop:

// Start Keyboard Polling

I2CIN 8, 81, [KeyChar]

// Read Key Character

IF (KeyChar = 0) THEN KeyLoop

// If 0 No Key Pressed

IF (LastKey = 0) AND (KeyChar = 0) THEN KeyLoop

 

 

// If LastKey and ThisKey are Zero

 

// then no key was pressed

IF (LastKey <> KeyChar) THEN ClearKeyDisp

 

 

// If they are not equal then

 

// clear the display and show the keys

IF (LastKey = KeyChar) THEN ShowKeyState

 

 

// If they are equal display then

Chapter 7

244

Chapter 7 / Hardware Development

 

 

 

 

GOTO KeyLoop

// Scan for another key

ClearKeyDisp:

// Clear the Debug Display

DEBUG CLS

 

//

ShowKeyState:

//

LastKey = KeyChar

// Assign OldKey = Current Key Character

DEBUG BIN8 KeyChar, " ", DEC2 KeyChar, CR

 

I2COUT 8, $50, [DEC KeyChar]

// Print 1st Text line

GOTO KeyLoop

// Loop again

// Display Message

 

StartMsg:

 

 

I2COUT 8, $50, [254, 88]

// Clear Display

I2COUT 8, $50, ["Embedded Systems"]

// Print 1st Text Line

I2COUT 8, $50, [$A]

// Carriage Return

I2COUT 8, $50, ["Desktop Integration"]

// Print 2nd Text Line

PAUSE 5000

 

// Display for 5 seconds

I2COUT 8, $50, [254, 88]

// Clear Display again

I2COUT 8, $50, ["Copyright 2004"]

// 1st Text Line

I2COUT 8, $50, [$0A]

// Line Feed

I2COUT 8, $50, ["Oliver H. Bailey"]

// 2nd Text Line

PAUSE 5000

 

// Display for another 5 seconds

RETURN

 

 

// First Test the Piezo Electric Buzzer

 

SoundBuzzer:

 

I2COUT 8, 80, [254, 88]

// Clear Display

I2COUT 8, 80, ["Alarm Start"]

// Print 1st Line of Text

DEBUG CLS, "Alarm Start", CR

// Show Debug Message

I2COUT 8, 80, [254, 87, 1]

// Turn on Alarm

PAUSE 5000

 

// Wait 5 seconds

I2COUT 8, 80, [254, 86, 1]

// Turn off Alarm

I2COUT 8, 80, [$0A]

// Send Linefeed to display

I2COUT 8, 80, ["Alarm Stop"]

// Print Line Feed

DEBUG "Alarm Stopped", CR

// Debug Display End Message

RETURN

 

// Return to caller

Forever:

GOTO Forever

Chapter 7 / Hardware Development

245

 

 

There are a couple of items to keep in mind when using this design. First, the BASIC Stamp 2p allows only pin combinations of 0 and 1, or 8 and 9 for I2C communications. By default, the lower numbered pin of the pair is the data pin and the higher numbered pin of each pair is the data clock. Listing 7-4 uses pins 8 and 9 for I2C communications. Addressing the LK202-25 is not difficult. By default, the I2C device address is 50 hex (80 decimal). While this can be changed, the default address is suitable for our needs.

Unlike RS-232, I2C supports multiple devices on the same address and clock pins. As you can see from Listing 7-4, addressing the LK202 is very simple. We will use some of the additional features of this device in later chapters.

Design Considerations

Using an intelligent LCD display like the LK202 shifts some of the processing burden from the embedded processor to the LCD display processor. This makes the LCD much more expensive than its non-intelligent counterparts. The fact that this display can perform many other tasks needs to be considered when designing a device of this type and expense. Even though the LK202 is a more expensive device, it offers features and expansion capabilities that may more than justify the additional cost. By using this device in our design we have effectively moved the tasks of managing alarm functions (LED and buzzer), keyboard input, and display output to this device and with the logic to control all of these functions squeezed into a very small space.

Chapter 7

246

Chapter 7 / Hardware Development

 

 

How to Make Your Own Printed Circuit Boards

The last topic we will cover in this chapter is how to make printed circuit boards and avoid the expense of using photosensitive boards. Recently I began using the toner transfer system and have found that I can make a board in under 20 minutes and with resolution good enough to allow pads for surface mount components. Let me cover this process because we will be making a few circuit boards as we continue. To make your own boards using this process you will need the following items:

Laser printer or photocopier

Toner transfer paper

Blank circuit board material

Clothes iron

Small tray of water (at room temperature)

Pint size bottle of ferric chloride (board etchant)

Sponge

Disposable rubber gloves

Acetone or nail polish remover

Full-scale board image in printable format

Now let’s cover the process.

1.Print a mirror image (or “flipped” image) of your full-scale (1:1) PCB layout on regular paper. (This will be your “carrier” sheet to hold a small piece of TTS paper that will be run through your printer a second time.)

2.Cut a piece of toner transfer paper equal to the size of the circuit image with about a 1/2" border all around.

 

Chapter 7 / Hardware Development

247

 

 

 

 

 

3.

Position the blank TTS paper directly over the printed circuit

 

 

 

image shiny side up. Using a laser-type label (e.g., Avery

 

7

 

brand), secure the TTS paper to the “carrier” at the leading

 

Chapter

 

edge (the edge that will be heading into the printer).

 

 

 

 

4.

Place the sheet into the manual-feed tray and print. You will

 

 

now have a perfectly printed image on the small piece of TTS

 

 

 

 

paper.

 

 

5.

Perform the simple iron-calibration procedure as outlined in

 

 

the TTS paper instructions to be able to apply the proper

 

 

 

pressure and temperature to get a perfect transfer.

 

 

6.

Prepare the copper surface of the blank PCB using a Scotch-

 

 

Brite or similar scrubbing pad and a drop of dishwashing

 

 

 

soap. The copper surface will have a layer of oxidation and

 

 

fingerprint oils that must be removed. Wet the board and

 

 

 

scrub the surface well with a circular motion. Wash under

 

 

 

running water and dry.

 

 

7.

Place the TTS paper over the circuit board image-side down.

 

8.

Place the TTS paper over the board and cover both with a

 

 

 

clean sheet of white paper. Carefully apply the iron so as not

 

 

to move the paper. Apply heat evenly to the entire image for

 

 

20 to 25 seconds, then remove the iron. Wait another 30 sec-

 

 

onds or so for the toner to dry to avoid any smearing. Discard

 

 

the white paper covering the assembly.

 

 

9.

Put the circuit board with the attached TTS paper into the

 

 

water bath until you see the paper start to float away (about 2

 

 

minutes). Do not “help” the paper to separate.

 

 

10.

Lift the board and paper out of the bath and slide the slippery

 

 

side of the paper over the circuit image. This will break the

 

 

surface tension where some of the dissolved glue will sit

 

 

 

inside doughnut holes and between tightly spaced traces.

 

 

 

Now wash in a sink to remove all glue residue. Discard the

 

 

paper.

 

 

248Chapter 7 / Hardware Development

11.Inspect the board for missing areas of black toner. If there are small gaps, you can use any waterproof permanent marker to fill in voids.

12.Dry the PCB by gently patting the board with paper towels to absorb the water.

13.Cut a piece of green TTF paper the same size as the toner transfer paper in Step 2.

14.When the board is completely dry, place the TTF paper over the board and repeat Steps 8 through 12.

15.Again pat the board dry with a paper towel.

16.Put on the rubber gloves and soak the sponge in ferric chloride until wet.

17.Evenly rub the circuit board with the wet sponge. Immediately you will see the etchant over the copper turn very dark. That is the copper ions being removed. Depending on the amount of copper on your board (0.5, 1, or 2 oz.), your etch times will vary greatly. The thin layer (0.5 oz.) should etch completely in 45 seconds to 1 minute and proportionally longer for thicker copper boards. Your aggressiveness of rubbing over the copper has a direct effect on total time to etch.

18.Flush the board with fresh water to neutralize the etchant and dry with paper towel. The board must be COMPLETELY dry before the next step. (Dispose of the ferric chloride soaked sponge in an EPA approved manner.)

19.Wet a dry piece of paper towel with acetone and rub over the board. Both the green TRF and black toner will liquefy on contact; however, if there is any water present, this will not work. A second fresh wiping will remove all residue.

20.Rinse the board under water and pat dry.

21.Tin plate the copper surface if desired.

22.Solder components and assemble the board.

Chapter 7 / Hardware Development

249

 

 

Circuit Board Artwork

This chapter concludes with the artwork for each of the boards made thus far. The artwork for each board contains two images. Only image titles appear on the page as the details were covered earlier. If you are making boards using the methods outlined earlier in this chapter, then use the inverted images. This will be correct after it has been printed and transferred to the board. If you are using a photo-sensitive method, use the normal image.

The artwork for the boards in this section do not have ground planes. The reason for this is due to the number of colors available when exporting the original circuit. When the colors are reduced to black and white some of the traces disappear. If you wish to use a ground plane, see the artwork in the downloadable files.

Chapter 7

Figure 7-38: Inverted TTL-RS-232

Figure 7-39: Normal TTL-RS-232

Соседние файлы в предмете Электротехника