Circuit.cellar.029.Oct Nov.1992

88
8/13/2019 Circuit.cellar.029.Oct Nov.1992 http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 1/88

Transcript of Circuit.cellar.029.Oct Nov.1992

Page 1: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 1/88

Page 2: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 2/88

Page 3: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 3/88

12 Planting Geraniums by Robot/Build an MC68HCll -based 2-D Sensor 

by Brian Farmer 

22 The Design of a Time Domain Reflectometer by Brian Kenner and John Wettroth

34 Serial l/O on the IBM PCby Jim Schimpf 

q Add Text Overlay to Any Video Displayby Bill Houghton

qThe Virtues of the Hue, Lightness, Saturation Color Modelby James R. Furlong

Driving Multiple VGA Monitors

by Michael Swartzendruber 

I Editor’s INK/Ken  Davidson

A Look at Next Year 

New Product News

edited by Harv Weiner 

Firmware Furnace/Ed Nisley

Extending Your Control: The HCS II MCIR-Llnk

From the Bench/Jeff Bachiochi

X-10 Interfacing with PUX

Slllcon  Update/Tom Cantrell

I’m 18.432-and I Like It

Practical  Algorithms/John Dybowski

The Middle Ground/Negotiating a Keyboard Interface

ConnecTlme-Excerpts  from the Circuit Cellar BBS

conducted by Ken Davidson

Steve’s Own INK/Steve Ciarcia

Let Me Tell You About Yourself 

Advertiser’s Index

The Computer Applications Journal Issue 29  October/November, 1992   3

Page 4: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 4/88

UNIVERSAL DEVICEPROGRAMMER

The first device

programmer in produc-tion offering a singleuniversal PLCC sockethas been announced byB&C Microsystems Inc.The new socket technol-ogy of the Proteus104accommodates anyPLCC device from 20 to84 pins, reducing PCboard traces and capaci-tance on the programmerheader. A 48-pin ZIFsocket is mountedalongside for program-ming 300-  and 600-milDIP devices.

The ProtCuslO4

features fully overvolt-age- and overcurrent-protected pin drivers, fulldigital and analogcapabilities for all pin drivers, true system self-calibra- Communication with any PC, XT, or AT is via a

tion of all voltage sources and full diagnostics of all pin parallel printer port, which has been optimized for the

drivers, a built-in controller and timer with 250-ns fastest and most reliable performance. The speed limita

resolution, and state machine testing with rise and skew tions exhibited by PC bus-based programmers are absenttime of less than 10 ns. The parallel port is searched by the programmer and the

The ProtCuslO4  also features expandable pin driver connection made automatically. All device library

boards, allowing upgrades to any level within its 24-  to software is available through a Bulletin Board System or

1OCpin   range. An entry-level version with 24-pin drivers by floppy diskettes.

and a 40-pin ZIF  socket is the base configuration. For The ProtCuslO4  is priced from $745 to $4995.

production environments when programming MOSdevices, gang (parallel) modules replace the universal B&C Microsystems, Inc.module and provide higher throughput to meet manufac- 750 N. Pastoria Ave.turing needs by providing eight or sixteen ZIF  sockets. Sunnyvale, CA 94086Also available is a memory card gang module (supporting (408) 730-5511

PCMCIA 2.0 Standard] with sixteen sockets. Fax: (408) 730-5521

The programming and algorithm developmentenvironment is based on a single executable file with a   500

built-in editor and compiler for fast software develop-ment and ease of use. Semiconductor manufacturers usea powerful Algorithm DEvelopment  Language (ADEL) inthe creation of new device algorithms. ADEL can alsomake changes to existing algorithms, when revisions arerequired, and can drastically reduce turn-around time forthe user of the devices. An extension of ADEL allows thecreation of special test algorithms independent of thoseofficially published ones embedded in the Prottusl04system.

6   Issue W29,October/Movembr,   1992 The Computer Applications Journal

Page 5: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 5/88

LOW-COST master or a slave onNETWORKED the network, andMICROCONTROLLER code can be down-

The GCBll an g-bit loaded and debuggednetworked microcontrol- across the network.ler hardware and software The GCBl  1package, has been an - Package comes with

 by Coactive a complete set ofAesthetics Inc. The 3” x development tools4” board, based on the and network andpopular Motorola MC68- application libraries.HC 11 F 1 chip, includes The GNU C cross-

32K of static RAM, 32K of compiler operatesROM and requires only a under PC-DOS and

  supply. includes support for

TheGCBl 1

includes C++ and Objective C.  digital I/O lines and The GNU Linker iseight channels of g-bit also included. TheA/D conversion. Commu- ROM Monitor-Debugger provides rapid development background task Source

nication is provided by a allows program downloads of distributed control code for all software is

standard RS-232 port and in S-record format. Break applications at various baud provided (C and assembler]

an RS-485 port for a points can be set and single rates up to 115.2 kbps. The complete GCBl  1

multidrop network with step/step over execution is Application utilities include package sells for $179.up to 32 nodes. Additional provided. Read and modify a PWM motor driver library485 drivers are on board features are provided for for transparent support of up   f&active Aesthetics, Inc.for connecting a PC using  memory, CPU registers, I/O to four DC motors, encoder P.O. Box if425967

the RS-232 to the RS-485 registers, EEPROMS, and feedback for speed and San Francisco, CA 94142network, without the ports. An assembler and position control of up to (415) 626-5152need for additional disassembler are also three motors, input signal Fax: (415) 626-6320

circuitry or boards. The included.   debounce   library, andboards can be jumper Master-slave packet support for ADC sampling    so1

configured as either a communications software at regular intervals as a

LOW-COST 8051 C PACKAGEFranklin Software’s new Engineer’s Evaluation Kit,

Release I, is a complete C programming package for 805 1development at the price of a standard 805 1 assembler.The kit targets engineers and students who have triedearlier C products and found them either too weak andslow or too expensive. The kit allows you to experiencethe power and efficiency of an advanced C for 805 1software development and maintenance.

Based on technology developed for Franklin’s Profes-

sional Developer’s Kit, the Evaluation Kit includes a Ccompiler, a macro assembler, a linker, a powerful sym-

  debugger-simulator, C libraries, and utilities. Theki t features fast compilation and highly optimized objectcode. Execution speed is comparable to the best in theindustry, and performance is equal to a tightly codedassembler.

The Engineer’s Evaluation Kit is an entry-levelcompanion to, and fully upgradable to, Franklin’sProfessional Development Kit for the 805 1. Priced during introduction at $299 plus an optional support contract,the C kit is an affordable way for engineers to discoverthe advantages of a complete C environment for 8051development.

Franklin Software, Inc.888  Saratoga Ave., 2

San Jose, CA 95129(800) 2834080  Ext. 896Fax: (468) 296-8061

  502

The Computer Applications Journal   leeur  29 OctobedNovember, 1992 7

Page 6: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 6/88

PROGRAMMABLE RELAY CONTROLLERPROVIDES ANALOG AND DIGITAL SUPPORT

A family of programmable relay controllers with

both analog and digital I/O capabilities for low-end

control and sensor interface applications has been

introduced by DIP Inc. The Pica  PLC units provide

digital, analog, PWM, RS-232 I/O, and an auxiliary

sensor power supply. Integrated programming and

debugging support allow the PPLC to be programmed

using a standard data terminal or PC. No specialized PC-BASED MOTIONprogramming software is required. CONTROLLER

Extending the control language typically found in   MicroKinetics  Corpora- programmable address

low-end PLC units with a full set of arithmetic and tion has introduced selection to allow coexist-

comparison operators, the PPLC products allow the user Quickstep, a new stepper   ence  with other cards that

to intermix analog and digital operations using ladder- motor controller containing may otherwise cause

logic-formatted command strings. The unit may be put on-board translators and address conflicts.

into a single step or display mode for interactive debug- power drivers for up to three The software is very

ging. File transfers are supported to and from a PC axes all on one card. It is easy to incorporate into

programming unit using standard PC-based communica- designed for cost-sensitive any application. The

tions packages. EEPROM program storage provides for applications that do not included subroutine

256 program elements with an average execution time of require very high stepping  libraries support C and

50 ps per element. speeds and where the   QuickBasic,  and feature

The PPLC will replace combinations of discrete convenience of having the linear and circular

relays, counters, timers, and comparators in applications indexers and drivers on one interpolation, ramping,

such as production monitoring, intelligent sensor card is important. The keyboard interactive jog,

interfaces, front-end preprocessing for larger program- Quickstep plugs directly and electronic gearing.

mable controllers, sequence control, and low-end motion into any 8-  or 16-bit ISA bus The QuickStep  motor

control systems requiring peripheral interfaces. A IBM PC or compatible, controller sells for $389

comprehensive programming guide cuts the learning eliminating the need for an for a three-axes system.time to less than two hours. external enclosure. One-axis and two-axes

The base unit (PPLC) provides four inputs (120 Features include systems are available for

VAC), four outputs 120  VAC, 2 amps), two analog programmable acceleration less.

channels (O-IO VDC), a PWM output (open collector), an and deceleration, automatic

RS-232 serial channel, and a sensor supply voltage of 12 overtemperature protection,   MicroKinetics  Corp.VDC at 200  mA. The entire unit is packaged in a 2.75” x end-of-travel detection on 1220 Kennestone Cir., Ste. J3” DIN-rail-compatible case with captive screw termi- all axes, two auxiliary Marietta, GA 30066nals. A board-level version (PPLC-BRD) extends the I/O outputs per card, and a (404) 422-7845to eight inputs, eight outputs, and four analog inputs. shield-open interrupt. The Fax: (404) 422-7854Both units sell for $239 in single quantities. Quickstep operates interac-

tively; no uploading or   604

DIP Industrial Products downloading of programs isP.O. Box 9550 required. It provides

Moreno  Valley, CA 92552 keyboard control of such

(714) 924.1730 functions as Jog, Pause,

Fax: (714) 924-3359 Abort, and so forth, and

drives motors requiring up

 503 to 0.9 amps at 12 VDC. A

built-in timer assures motor

speed consistency regardless

of computer speed. The

Quickstep requires only one

g-bit  slot and features

8   Issue   2 Octokr/November 1992 The Computer Applications Journal

Page 7: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 7/88

Page 8: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 8/88

SOLID-STATE DISK SYSTEM FEATURESREMOVABLE MEMORY CARD

The MNC 1150 with a 16-bit   datahigh-speed solid-state path. In addition,“disk” system features a eight 32-pin   JEDECremovable PCMCIA 2.0 sockets for SRAM,

memory card slot for ISA EPROM, EEPROM,and FJSA  computers. The and flash memoryMS-LXX-compatible chips are providedsystem  stores files in fast (for a total storage capacity unloaded while the com- Evaluation units aresemiconductor memory of 72 megabytes]. It has puter system is operating. available for $295 withrather than mechanical been designed with CMOS Dual-battery backup is zero memory.disks to achieve the high technology using a versatile provided for the JEDECspeed without wear. The register-based interface with sockets when SRAM  is MNC International, Inc.on-board BIOS ROM error sensing and selectable used. On-board flash 2817 Anthony La. South

allows instant-on and interrupts to ensure data memory programmer and   Minneapoils,  MN 55418instant-reset capability. integrity in critical environ- support software is pro- (612) 766-1099

The MNC 1150 ments. vided. Power requirements Fax: (612) 766-9365offers complete PCMCIA The PCMCIA 2.0 card are less than 1 amp at 52.0 compatibility, which socket is accessible through volts and up to 250 mA  at   SO6can support memory the card bracket, so memory 12 volts (when program-

cards up to 64 megabytes cards can be loaded and ming flash memory).

2”~ 4” EMBEDDED PC

“Megatel Wildcurds  provide -PC functional& in a fIexi6le,Wihrd   88’” Multi/IOl CPU clock to 10  MHz l On-board SCSI Host Adapterl Replaces full PC motherboard (supports up to 7 devices)l Co-processor and BIOS socket l Floppy Controller (1.44M, l.2M)l DMA, Bus, DRAM, Keyboard l 2 RS-232. I Parallel. I RS-485

controllers multi-protocol serial port

All Wildcards are low power single +5  volt operation.

125   Wendell Ave., Weston, Ont. M9N  3K9  Fax: (416) 245-6505

Vid/Mem:l 640Kb User memoryl Videokolour  LCD controls

CGA, Hercules@, IBM@ Mono;(runs LCD Panels)

For information  on our representatives  pleasecontact our head office  at ‘tie  number  beh

(416) 245 3324Wildcard  88 and Megatel are trademark. of Megatel  Computer Corp. Hercules is a trademark of Hercules Corp IBM is a trademark of IBM Corp

megatel@  IO5

10

Page 9: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 9/88

Planting Geraniumsby Robot

The Design of a TimeDomain Reflectometer 

Serial 110 on theIBM PC

Brian Farmer

I

Planting Geraniums

by Robot

Build anMC 8HCll

based2-D Sensor

pposites attract,”so the saying goes.

Maybe it’s true withpeople, but definitely not

with robots and flowers. Even thoughthe latter are about as opposite as canbe, they don’t attract. Matter of fact,they are about as incompatible as youcan get. Robots are inclined towards

uniformity, and flowers are inherentlydiverse. That’s where my sensor comesin, providing a necessary ingredient fora marriage that would otherwise neverwork, or technically speaking, assist-ing a robotic system to accommodatenonuniformity.

Robotic systems aren’t anythingnew. They’ve been around industry foryears, improving productivity andquality and doing many hazardous oruncomfortable tasks for workers. For

example, the automotive and electron-ics industries use robots to performrepetitive and precise tasks. This formof automation is implemented inpredictable and structured environ-ments [l] with defined spatial configu-rations.

Agricultural robotics venturesbeyond the predictable to the unpre-dictable environment. No formalmethodology exists for designingautomation systems that work with

biological products that are of variable

12   issue 12 9  October/November, 1992 The Computer Applications Journal

Page 10: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 10/88

Page 11: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 11/88

Page 12: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 12/88

Multiplexer Module (Banner), but ithas fairly poor resolution (5-12 mm].Other light curtain devices offered byBanner and Sick Optoelectronicsimply provide presence detection orhe edge measurement of a surface.

A 1-D C-shape sensor is availablerom Frost Controls that measures anbject’s size using an analog signal

proportional to the area blocked, and itlso can be constructed to detect

position. However, this unit is 12.5mm thick, which is the minimumdisplacement between measureddimensions. Due primarily to cost andomplexity, I did not consider the

various types of laser-based positionmeasurement systems (Keyence,

14,400) for this application [4].

Evidently, no commerciallyvailable position measurement device

it the needs of this application, so Ideveloped a sensor and coupled it to an

  microcontroller [5,6,7].

The pairing of the measuring elementnd the inexpensive microcontrollerielded an externally controlled

programmable sensor that reported

Photo l-The sen.wr  uses paits  of LEDs  end pIwto&amisti  b smse  the psitkm  of  a @an1 cvf@ tierled  h  m

ho/e in Ihe mddle

measurement results through aparallel/serial interface.

DESIGN CRITERIAThe primary design goal for my

sensor was that it detect the direction

and magnitude of bend on a geraniumcutting stem’s base relative to therobot’s grasp. To make this determina-

tion, the robot is directed to positiongeranium cuttings in a fixed locationin the workcell, then to measure

FREECALL

HELP lo

PARADIGM LOCATE l PARADIGM TDREMl PARADIGM DEBUG l

Comprehensive software development tools for

all IntelMl86  and NEC V-Series

microprocessors.

l Borland C++ and Microsoft C/C++ support

l Choice of stand-alone or in-circuit emulator

debugging

l Unlimited toll-free technical support

l 30day money-back guarantee

He@ IS Available Call today for complete

product information and embedded system

application solutions. You won’t be disappointed!

PAR/jDlGMProvenSolutihs for Embedded 

C/C++ Developers Paradigm Systems, 3301  Country Club I&ad,

Suite 2214, Endwell,  NV 13760TEL: (607) 748-5966 FAX: (607) 748-5968

Trademarks are property of respective holders.

SeeusafU eEmbeddedSysf emst if t rsncgsaoll x3a5

The ComputerAppliitii  Journal   Issue  29 Cktokr/Nove~r, 1982 15

Page 13: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 13/88

w me DufK  01  me  sensor  s maUe  UD  of  me LtD@wkWansimrpairs. One at a time, each LED is /it  and its   companion photoft-mS r  is chedwd  to find  out if tte  lightpiti is tehg  bbcked.

quickly the stem’s position with a

sensor. The bend of the stem is

referenced from the robot’s grasp point

to the bottom of the stem, and the

information is used when inserting the

cutting into the plug. Geranium

cutting stems are frequently 5-10 mm

in diameter with bends of O-O.6

radians. Before a stem has been

inserted into the plug, it generally

extends below the robot’s fingers 15-20 mm.

Thus, the design criteria for the

sensor included a l- to 2-mm resolu-

tion, a 25mm  range in two dimen-

sions, a l-mm maximum displacement

between measured dimensions, and a

lOO-ms   maximum response time.

Object size was assumed to be within

the range of 4-12 mm. Also, I needed

to keep component cost under $500. I

pursued a small, noncontact sensing 

method because of the infrequent need

for cleaning and the absence of any

force applied to the plant stem, which

could affect the measurement or

disturb the cutting within the gripper.

THE SENSORIn 1989, I developed the first

sensor for this application [4].  It was

based on two lo-element infrared LED

emitter and phototransistor receiver

pairs (Siemens LD260/  BPXSO)  [8]physically aligned as a 25-mm  x 25-

mm square. Emitter-receiver pairs

were not multiplexed. The entire first

dimension was activated and latched,

and the same was repeated for the

second dimension. Both dimensions

were read by a 6809 microprocessor

through a parallel PIA  interface.

The minimum object size mea-

sured was 5 mm in diameter or width,

and average position measurement

errors in the x and y dimensions were

2.4 mm and 2.0 mm, respectively

(these values are within the range of

expected accuracy due to the 2.5-mm

resolution). Response time was 115

ms, repeatability was excellent, and

the unit insertion operation increased

in performance from 80% to 98% for

204 cuttings. The sensor was con-

nected to a single-board computer, the

 Wintek 6809 Control Module.

 While the position sensor per-formed well, I needed to improve

resolution and range to achieve the

design goal for a minimum object size

measurement of 4 mm and to over-

come the occasional shortcomings of

the 25-mm range. The resulting project

won first place in the General Cat-

egory of the third annual Circuit

Cellar Design Contest (see Photo 1). It

uses multiplexed emitter-receiver pairs

(Siemens SFH405-2/SFH305-3)  with a

smaller component width, a smaller

1 6 Issue X29 October/November, 1992 The Computer Applications Journal

Page 14: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 14/88

Page 15: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 15/88

Page 16: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 16/88

List i ng l -conti nued

I NCB* Loop through scan

Record data count

LPl

LP2

LP3

CLR J SRLDAASTAAI NCB

CMPBBNECLRLDAABPLLDAASTAA

 J SRLDABDEXCPX

BNELDAASTAA

 J MP

** Subrouti ne*

WAI T1 LDAAWAI Tl A  SUBA

BNERTS

PORTBWAI T1 SO2PORTB

 aLPl

PORTBSPSRLP3SPDR

0. XWAI T1

 SO0

 sooooLP2

 SOCSPCRWARMST

%530 Counter

a1 Count downWAI Tl A Fi ni shed?

Next pai r acti vatedWai t a whi l eNext pai r' s condi ti on xf ered

Record data countOne byte yet?No, go back f or more

 Yes, acti vate next pai rSPDR f ul l wi th 1 byte?Keep l ooki ng f or f l agLoad i nto on- board RAM

Wai t a whi l eReset data counterCount downAl l data i n?No, go back f or more

 Yes, SPI off . Resets/ endstr ansfer. And. . .go back to Buffal o prompt ' >

debugging and development with

Motorola’s BUFFALO program. Listing 

1 provides a demonstration program

used to acquire and store data.

The code is implemented in the

MCU’s  on-board RAM as a subroutine

while under control of the BUFFALO

program, with a warm start back into

BUFFALO after program executionoccurs. Again, acquired emitter-

receiver pair data is displayed on a

PC’s screen from on-board RAM with

a BUFFALO command. The most

important software detail involves the

SCK  and DATA timing. SCK   CLK)

speed is dependent on the

phototransistors’ rise and fall time.

Although SPI rates as high as 2.1

megabits per second are possible,

Siemens specifies the receiver with a 6

ps maximum rise and fall time. Stillyet, testing yielded 129 ps  due to the

effect of coupling with the multi-

plexer, resulting in an optimum period

of 135 ps   (7.41 kHz,  which isn’t one of

the four selections in master mode).

SPI polarity and phase were initialized

for stepping on the falling edge of the

clock, and data latching on the rising 

edge.

Calculating position requires

determining the nature of the data

from the arrays. Data is classified asreliable or unreliable. Unreliable data

refers to noise (any pattern other than

one consecutive group of blocked

elements) or signal absence (all

elements unblocked or all elements

blocked), with appropriate codes

transmitted for each type of condition.

Reliable data is processed by a simple

algorithm to locate the object center.

As I noted earlier, the microcon-

troller uses six parallel bits per

dimension to code the calculatedobject position within the array of the

sensor. In addition, raw position,

position codes, and error codes are sent

to the optional terminal for user

verification if desired. The 26-pin dual-

row header on the circuit board

provides RS-232 interfacing when a 25

to 9-pin adapter is used. Nine of the 25

pins are used to avoid circuit conten-

tion with the parallel output on the

same header.

Eventually I will want robustness:the ability to handle unreliable data. I

x113

Issue   29  October/November, 1992   TheComputer ApplicationsJournal

Page 17: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 17/88

hope to implement a form of fuzzylogic in the future to deal with thetendency of the data rather than rigidrules of traditional logic [lo].

PERFORMANCE OF THE SENSORI conducted several tests to

determine operational limits of

accuracy, repeatability, and speed.Tests showed a minimum of 0.22 mmfor object size measurements. Averageposition measurement errors in the xand y dimensions were 0.07 mm and 0mm, respectively. Measurement timewas 11 ms (demonstration program).Finally, the sensor had excellentrepeatability and a greatly reducedpower drain (including a single +5-volt

supply] compared to the first circuit.The component cost was $476.76.

An insertion performance of over 98%of cuttings is projected. The sensor hasadded some other benefits as well. Itcan detect the proper grasp of a cuttingby the robot before attempting inser-tion into the plug. Also, it has thecapability to abort a particular cuttingcycle if no object is detected. [51

1. W. I,. Whittaker,  G. Turkiyya,  M.Herbert, “An architecture and twocases in range-based modeling andplanning,” IEEE, 1987.

2. W. Simonton, “Automatic planthandling and processing in arobotic workcell,” Transactions of 

the ASAE, 1990.3. W. Simonton, “Issues in robotic

system design for transplantproduction systems,” Inteznational Symposium on Transplant production Systems, Yokohama,

 Japan, 1992.

4. W. Simonton, B. Farmer, “Sensorfor two-dimensional positionmeasurement of small objects,”Transactions of the ASAE, 992.

Brian Farmer was formerly an Elec- 

tronics Engineer with the Universi ty of Georgia Experi ment St at ion and 

occasionall y does consult ing t hrough 

Pow er Tech Inc. He is now a ful l- t ime 

student i n the Uni versit y of 

Arkansas’s Electrical Engineering 

Graduate program w it h a t eaching 

assistantship.

5. S. Ciarcia, “Why microcontrol-lers?“, BYTE, August 1988.

6. S. Ciarcia, B. Brown, “Using theMotorola MC68HCll”,   CircuitCellar INK, Issue 18, December/ 

 January 1991.

7.M68HCll  Reference Manual,Motorola Inc., 1989.

8. Optoelectroni cs Data Book,Siemens Components, Optoelec-tronics Division, 1990.

9. S. Ciarcia, “Let your fingers do the

talking”, August 1978, BYTE.

10. M. AbdelRahman,   “ArtificialIntelligence expands sensorapplications”, Electrical Con- struction eJ Maintenance,December 1991.

My thanks to the clear th ink ing and 

w ise supervi sion of Dr. Ward 

Simonton.

401 Very Useful402  Moderately Useful403 Not Useful

Tw5

Power Line InterfaceDevelopers Kit

Interface Your Computer To Transmit AndReceive X-10 Codes Over Your AC Power Line.

Two-Way Communication.Real   Time Environment Control.

Kit Includes‘IW523,  Cable, Interface Connector (S/P)Documentation. Source Code Supplied in

“c”,   Pascal, BASIC   or Run Time.Disks 5.25in  & 3.5in   Format.

Baran-Harper Group Inc.

Voice (416) 294-6473 BBS   (416) 471-6776Fax (416) 471-3730

114

DEAL brings together all of the tools used to develop software fol

jingle Board Computers (SBC) and blends them into a menu-driver windowed  environment that speeds your development process.

l Automates the Compile-Assemble-Link-Download Cyclel Works with any Compiler, Assembler, Linker, etc.l Use the built-in Editor or link to your own Editor, it’s easyl Great for BASIC and FORTH interpreters tool Interrupt driven serial communications to the SBCl Swaps memory to make room for the largest toolsl Resizable, Zoomable  Windows for Editing, Browsing and

Target Communicationsl Fully integrated mouse and keyboard controll In use for 2 years at Major Universities and Corporations

Requires  pc’xT’AT  w’5’2KDemo Available on BBS

30 day Money-Back Guarantee

;_ _   c r e a t i v e;  applications

Phone (415) 494-2363

  engineering,inc.

Compuserve: 74 156 1207

- - - BIX: ecarryer‘.0. Box 9524, Stanford, CA 94309 BBS (415) 494-8463

Wl

The Computer Appiications  Journal Issue 29   October/November, 1992

Page 18: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 18/88

Brian Kenner & John Wettroth

I he Ueslgn 0T a 1 Ime

Domain Reflectometer 

few years ago, afriend of mine

needed a portablenetwork cable tester. He

does LAN  management and found thatcable problems were the cause of avery large number of network insta-bilities. I wasn’t surprised, having alsomanaged several large networks at onepoint in my life. I had grown weary ofhaving a system fail whenever some-one decided to rearrange the office andinadvertently disconnected thenetwork while moving a computer.

Certainly, no replacement existsfor building networks with some levelof faul t tolerance, but doing so is notalways physically possible or economi-

cally viable. The type of cable testermy friend suggested was not going tosolve network errors originating fromthe “designer office worker” anyway.

Nevertheless, my friend reasonedthat if a truly fault-tolerant networkwasn’t possible, providing the meansto quickly locate the cable fault wasthe next best thing. He proposed Ibuild a network cable tester: a TimeDomain Reflectometer (TDR).

Our portable TDR is based on the

Intel 87C51   microcontroller. Wedesigned it primarily to measure the

length and termination impedance ofcoaxial cables commonly used incomputer networks, such as Ethernet,Arcnet,  and so forth.

The TDR uses time domainreflectometry techniques to measurelength and calculates the actualtermination impedance based on the

amplitude of the reflected waveform. Ithas a measurement range of approxi-mately 1800 feet and handles 50-  and75ohm  characteristic impedancecables (primarily RG-58 and RG-59used in thin-wire networks).

The hardware combines an 87C5 1microcontroller with a 4-line 20-

character LCD display, an infraredthree-key touch-screen interface, alow-power PAL, a dual g-bit  DAC, avery high-speed comparator, and a

handful of digital and analog “jelly-beans” to bring it all together.The software consists of approxi-

mately 3K of 805 1 assembly language,which includes a flexible menusystem, a custom integer mathpackage, and the actual measurementcode. A 9-volt  battery powers the unit,which features automatic shutoff, andit is packaged in a 2” x 4” x 6” plasticenclosure. We also kept the bill ofmaterials below $200.

THEORY OF TDRSThe TDR capitalizes on the

traveling waveform’s characteristic ofreflecting some portion of its power asit passes through the interface of twodissimilar materials. A detailedunderstanding of why these reflectionsoccur requires more space than I have.However, I will cover the theorynecessary to build the TDR, whichcenters on how electromagnetic waves

propagate down a transmission line.

V   v+dv

I   dVd I+dl

r

Flgun   l-Some V&D/S and differenfial calculus  helpshow how the time domain rekctcmeter  woks.

22   Issue  29  OctobedNovomber,   1992 The Computer Applications Journal

Page 19: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 19/88

Transmission lines result from thenteraction of wire sections that makep any circuit. In most cases, the

nteraction between the wire in theignal and return paths is insignificantelative to the effect of the physicalomponents that form the system.

However, in the case of network

abling, the distributed reactance (bothnductive and capacitive) is substantialwith respect to the data rates involved.

igure 1 and some differential calculuselp show how these reactive ele-

ments sum.In an infinitesimally small

lement of the transmission line, dz,

oltage and current are defined by

V-(V+dV)=-dV=(Ldz)( )

nd

-dI=(Cdz) g)

where L is the series inductance and Cthe parallel capacitance of the cable

onductors measured in inductancend capacitance per unit foot. If Issume a lossless   transmission line, Ian combine the above equations toorm a pair of linear differentialquations representing the variation ofoltage and current in the conductorst position z. These equations are

-WL(~)

w-w

hey have a solution of

V = F, (z, -  vt) + Fz  (z,  + vt)

where v and z,  must be

V

zc.=   c I

and v play very important roles inhe TDR’s   capability to make its

measurements. z,  is the characteristicmpedance of the cable and is used toetermine the magnitude of the wave-

orm (and possibly phase) reflected athe interface of the two conductors.he parameter v, defined as

Photo l-The time domain rebctometer uses a 4-line  by 2o-thracter  display for ail operator  input and ou@vL Sotfkeys and buch  screen circuiby  make for a vety lexible  inkdce.

is the velocity of the electromagneticwave in the cable and is used tocompute the physical distance to thediscontinuity.

In a vacuum, the dielectric con-stant (E) and permeability (p)   are equal

to 8.854 x lo-l2  F/m and 4~ x lO-‘H/m,respectively, so the speed of propaga-tion becomes c, or the speed of light.

Defining the equations forcapacitance and inductance per unitlength of the two most commonlyused types of cable is also helpful. Forcoaxial conductors

For parallel conductors

Using these equations, I can defineZ,  in terms of the physical and elec-trical properties of the cable: param-eter a, the diameter of the innerconductor; b, the diameter of the outerconductor in coaxial cables; and d, thedistance between conductors inparallel wire cables. The equationfor acoaxial conductor is

and for a parallel conductor is

ZO-&   ~)“ln ~)

The TDR makes its basic mea-

surement by injecting a pulse into thecable and subsequently measuring theamplitude and phase of any reflectedpulse. The reflected pulse’s amplitudeand phase indicate the impedance ofthe new material. The time elapsedbetween pulse injection and thedetection of the return pulse is thenused to compute the round-tripdistance to the cable discontinuity.

What may be obvious at this pointis if the pulse is not reflected, no

discontinuity exists in the cable. Themystery is why any portion of thewave reflects at all, and upon beingreflected, why the electromagneticwave may undergo a phase change.

Though the TDR’s   injected pulseis by no means sinusoidal, Fourieranalysis shows it is composed ofsinusoids. For the following discus-sion, it is easier to assume the travel-ing wave is purely sinusoidal and ofsome particular frequency. If thetransmission line is terminated andassumed to be lossless, then the load,

The Computer Applications Journal Issue W29  OctobedNovember,  1992 2 3

Page 20: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 20/88

Page 21: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 21/88

_

4 x   28

L C D D i s p l a y

rlgun s-usermpur IO me run I a ~IJC I screen nferiace.  Three  pairs of LEDs and pho tmsislotx

de t  a ingw  poiht ing  at one ol  three choices displayed on the LCD display.

dielectrics have resistance. This

resistance not only affects the trans-

mitted wave amplitude, but also

influences the phase relationships ofthe frequency components in the

transmitted waveform. The TDR is

forced to consider this fact when

computating   termination resistance.

Ultimately, this real-life effect limits

the length of cable the TDR can test.

HUMAN INTERFACE We imagined how the TDR would

be used and attempted to build the

instrument around those purposes.

The TDR had to have a simple inter-face and a small package. Simply

stated, the number of basic actions

required to operate any instrument or

appliance should be as few as possible.

Because nearly anyone can memorize

three or four operations to perform

some function, we restricted the

number of keys on the TDR to three

and let the software handle the rest.

 With the above goals in mind, we

decided to make a touch screen

interface. That would allow us to

present three “buttons” on the display

and let the operator select one with

the point of a finger. It also allows us

to add features later by simply chang-

ing the firmware.

For our design, the best combina-

tion of keys was two for moving 

through menus and one for selecting 

an option. We ensured that any func-

tion or operation in the TDR would be

compatible with the three-key inter-

face, which unfortunately meant we

would have to anticipate any param-

eter that eventual users may wish to

enter and incorporate into the menu.

CABLE TYPESComputer networks can and do

use a variety of cable types. Most of

them fall into two categories: coaxial

and twisted pair. Each category has its

own characteristic impedance. The

problem is TDR has its own intrinsic

characteristic impedance, which may

or may not match the cable under test,

so there may be reflections generated

at the interface of the TDR and the

cable under test.

Rejecting this reflection with

software is possible, but the noise

margin will be affected. Unfortunately,

some portion of the waveform’s power

also will return before it reaches the

cable fault, further reducing the

instrument’s usable range. Initially, we

thought this problem meant a reduc-

tion in supported cable types becausesome form of internal termination was

required to perform the measurement.

In the end, we decided to cover the

two most common types of coaxial

cables with a very small relay, which

toggles the TDR’s  internal termination

resistance between 50 and 75 ohms.

HARDWARE DESIGNThe electronics for the system

consist of two major parts: microcon-

troller and measurement. The micro-

controller electronics include the LCD

display, DAC, and IR touch-screen

circuits. The measurement electronics

consist of a high-speed comparator, a

low-power latching relay, and a

discrete cable interface circuit.

The microcontroller is an 87C5  1

operating at 12 MHz (see Figure 2).

The microcontroller’s oscillator also

clocks the measurement PAL., U9. The

clock to the PAL is enabled and

disabled to save power when actual

measurements are not in progress.

The three data inputs for the PAL,

the LCD display, and dual DAC data

inputs populate the microprocessor’s

port 0. The DAC is the only device

actually addressed as a memory device

(i.e., using the MOVX instruction).

A single 9-volt battery powers the

TDR. Automatic power down is

accomplished with the aid of PMOS

FET Q3 and NPN transistor Q 12.

 When the operator presses the

“on” switch Sl, the gate of Q3 is

pulled low, applying power to the

LM3 17 and subsequently tBe  micro-

controller. At power-up, all processor

port pins go high including Pl 7,

which keeps Q3 and Q12 turned on.

To power down, the processor simply

drops PI. 7. The sum of the leakages of

Q3 and Q 12, which are extremely low

and comparable to the self-discharge

rate of the 9-volt battery, equals the

amount of standby current when the

system is off.

26   Issue  W 9   October/November, 1992 The Computer Applications Journal

Page 22: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 22/88

Page 23: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 23/88

Page 24: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 24/88

Page 25: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 25/88

imited common mode range of 1.25-

.5 volts when run on 5 volts.

To push the signal into this range,

he positive input is biased to 2.5 volts

y doubling the voltage reference,

which brings it to the approximate

enter of the common mode range.

DAC B  and amplifier U4d provide the

egative input to the comparator. The

ange of this input is O-3.95 volts. The

DAC resolution is about 16 mV for

measuring the height of the returned

waveform.

The comparator has complemen-

ary outputs connected to the clock

nputs of U7a  and U7b. Two flip-flops

liminate the pulse-width uncertainty

ssociated with measuring negative

eturning pulses. The microprocessor

amples the flip-flops’ outputs at the

nd of a trial measurement at P2.0 and

2.1.

The PAL’s LDTL input clears the

lip-flops at the beginning of a trial

measurement. They are set after the

eturn of a pulse if the D input

rovided by DL _OUT   is present before

he comparator senses the pulse.

The measurement circuit operates

by injecting an extremely brief pulse

[about 10 ns) onto the cable under test.

This pulse travels down the cable and

reflects from any discontinuities

(changes in impedance) in the cable.

These reflections return to the TDR

and are captured by a very fast com-

parator, which clocks a D flip-flop.

A precisely delayed signal derivedfrom the original output provides the

D flip-flop’s input. The PAL generates

the delay, and a microprocessor can

vary the delay line from 0 to 5.5 ps in

2O-ns  steps. This time resolution leads

to a distance resolution of 6 feet for

typical cable types and a maximum

cable length of 1700 feet.

TERMINATION RESISTANCEPulse amplitude measurements

are made by adjusting the threshold of

the comparator using a DAC until

return pulses are no longer seen. The

reflection coefficient is calculated by

comparing the transmitted pulse

height with the returned pulse height.

If you assume the cable is lossless,

then calculate the termination

resistance using the previously derived

formula

z,==zc.~I-VJv.)/~I  +VJv.)

Assuming a cable is lossless does

simplify matters, but it leads to large

errors in the calculation of termination

resistance for long cables. The actual

attenuation coefficient per 100 feet

depends on cable type and quality.

Several standard nomographs are

typically used by engineers for correct-

ing reflection coefficient for line loss.

The TDR handles this problem by

first determining the cable’s length

and the uncorrected reflection coeffi-

cient using the algorithm I’ve de-

scribed. It then corrects the reflection

coefficient for line loss based on the

measured length before using the

injected pulse amplitude in the

previgus  equation.

The voltage attenuation constants

for RG-58 and RG-59 are stored in

firmware. They are approximately 3%

per 100 feet of length for both RG-58

DOS Where You Want It-Runs on Disk, ROM , FLASH Develop your programs on a standard PC and run them inROM with ROM-DOS, the flexible, affordable operatingsystem that was designed for embedded applications. Compat-ible with MS-DOS 3.3 1, ROM-DOS boots and runs fromROM, disk, or FLASH memory. Features include: small size(low as 36K); runs executable files from ROM; FLASH disk support; remote disk and multimedia support; and a powerful

utility suite. Confirmed compatible by VeriTest, an independ-ent evaluator, ROM-DOS is already in widespread use onmultiple system types. Developers Kit-which contains all thetools and utilities needed to configure ROM-DOS to your system, and includes license for 20 copies-costs only $495.

‘II@  r Mlidespread  use on a variety  of pl tfkm

 ROM-DOS has prm’en  its deperrdahilityROM-DOS royalty fees depend on quantity purchased, andrange from $3 to $25 per copy.

Free Demo Disk! Call Today Toll-Free l-800-221-6630

17455 68th Ave NE, Suite 304, Bothell,  WA 98011, USA l 206-486-8086 l fax 206-486-0253

The Computer Applications Journal Issue X29 October/November, 1992 3 1

Page 26: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 26/88

Page 27: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 27/88

Listi ng 2 cofltiued

MOV A. BI NC AMOVC A, @A+DPTR  MOV   DPL. APOP DPH

  Once a new tabl e has been;  to be repai nted.

SETB DI SPFLAG :SETB TTLEFLAG :MOV   OPPTR. OH I NC DPTRI NC DPTRPOP OHPOP   OFOHPOP ACCRET

l oaded, schedul e the screen

Set "pri nt opti on' f l agSet "pri nt ti tl e' fl agReset poi nter to top of menuPoi nt t o the f i rst i tem

i n the tabl e.

splay with the currently selected THE COMPLEAT TDR

enu. Listing 2 is an excerpt from the The instrument we’ve described code. works in its most basic form, but weA small collection of functions think there is plenty of room for

at operate on 32-bit variables improvement before any reasonableerforms all math on the TDR. The production could be considered. ItDR needed only an addition, subtrac- would be fun to extend the number of

n, multiplication, and division cable types supported and maybe evennction. add optical cable support. The biggest

leap in functionality would be to makethe TDR, or something like it, a moreintegrated part of a network. It couldbe a device that resides semipassivelyon the network and is occasionallypolled by a PC via an RS-232 connec-tion. Use your imagination.q

Br ian Kennez is a project engineer at 

Science Appl icati ons in San Diego,

Cal i f . He has developed several f ixed 

and hand-held microcontrol ler-based 

instruments used in vibration and 

radiati on monitori ng and analysis.

John Wettzoth is employed as the 

Chief Engineer of Science Appli ca- 

tions’ Military Products Di vision in 

San Diego, Cal i f . He also owns 

Tzavtech, a sole proprietorship 

involved in electroni c instrumentation 

development and HP-48 calculator data acquisiti on.

404 Very Useful405 Moderately Useful406 Not Useful

ROM Borland or Microsoft CComplete 80x86ROM development kit! 

Whether you use Borland C or Microsoft C to develop forROM, C_thru ROM will help speed your projects tocompletion This complete ROM development package is theonly product that gives you all the tools you need for easydevelopment of 80x86 ROM code on your PC. C_thru_ROMincludes: ROMable startup code; floating point support; aROMable library that includes p intf malloc @ee etc.; and a

full 80x86 locator that outputs binary, Intel OMF, and hexformats. You can debug with your Turbo debugger or useDatalight’s remote debugger. Either debugger will work through an available UART or ROM socket UARTs.  Thiscomprehensive ROM development package is available for only $495. Call, write or fax today for your free demo disk and full details about C thru ROM. 

The Computer Applications J ournal   l ssueX29Oct ober / November, 1992   3 3

Free Demo Disk! Call Today Toll-Free l-800-221-6630

1745.5 68th Ave NE, Suite 304, Bothell WA 98011, USA l 206-486-8086 l fax 206-486-0253

Page 28: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 28/88

Serial l/Oon the

IBM PCJim Schimpf 

various devices toan IBM PC or compat-

very common, and done so witheverything from a manufacturer’s

microprocessor development board toyour latest widget. The serial interfaceis extremely convenient, requiringonly a few wires and usually stretchingfar enough to make “remote control”mean something. The PC has thehardware to make this task easy, butthe standard BIOS for IBM and clonePCs does not support anything butpolling-type I/O, which means you areguaranteed to drop characters unlessyou use low data rates.

A large number of software I/Olibraries are available that can makethe PC serial I/O live up to its hard-ware. These libraries are all very good,but if you are like me and have moretime than money, the simple full-

duplex serial I/O package I describehere is all you need to make yourproject hum.

The code for SERCOM is written inMicrosoft Quick C and can be easilyadded to your program. It can openmultiple serial channels [your hard-

ware limits the number] and eachchannel supports full duplex with ringbuffers on both input and output.Various status checkers are present, soyour program can monitor the arrivalof each character or only be notifiedwhen a complete line is received. Thisway, even a program running on a slow8088 can monitor two 9600-bpschannels. Also included is a sampleterminal emulator designed to talk to apopular microprocessor development

board.

THE SERCOM SERIAL I/OPACKAGE

S ERCOM has ring buffers on bothinput and output, which means theprogram using the serial input does nothave to monitor the serial I/O lineconstantly. This arrangement is a

major failing of the polling BIOS serialI/O. If your program is busy doingsomething else when a burst ofcharacters arrives, you will get only afew characters and the rest will bedropped. The solution to this pollingproblem is to lower the data rate so theprogram will be able to check the linebefore another character can arrive.

Using SERCOM routines is likeusing the file operations of s t d i o . h.In this case, you include the header file

SERCOM   . H in all the modules of yourprogram that you want to use theserial I/O routines. Listing 1 shows askeleton for serial I/O.

Again like file operations, theseroutines let you have more than oneopen at a time. The supplied version ofS ERCOM limits you to two becausestandard PCs only support two ports. Ifyou want to open more than two portsat a time, you will have to add theirregister and interrupt locations. Youmay open as many ports as you havehardware.

Table 1 shows the functionsavailable when the port is opened.What each function does is obvious,but the comments in the S ERCOM . C

program source code provide descrip-tions of them.

Table 1 also shows a number offunctions used a little less often. If youstart your serial I/O program on thePC, then connect it to your remotesystem; plugging in the cables will

probably generate a few garbagecharacters. In a case like this example,a call to cl ean_ser(  1 ensures theinput buffer is empty.

MTERM: A DEMONSTRATIONPROGRAM

Included with the source code is asimple terminal emulator programcalled MT E RM. I developed this programto talk to the Motorola EVM board andalso included the capability to down-

load S19 files to it.

34 Issue 129  OctokdNovmber,  1992 The Computer Applications Journal

Page 29: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 29/88

Page 30: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 30/88

Page 31: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 31/88

Page 32: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 32/88

 Add Text

Overlay to

 Any VideoDisplay

Bill Houghton

moment, you’vebuilt and installed the

system described primarily in issues25 and 26 (February/March and April/

May ‘92) of the Computer Appl ica- t i ons Journal . In issue 27 (June/July‘92),  Ed Nisley described an add-onLCD output device as a way to obtaininformation about the status of thesystem and its various nodes. It’s anice addition to the network, butuseful only when you’re near to thedisplay module. What do you do ifyou’re across the room watching TVsettled into your favorite armchair?You could get up and venture across

the room. Or, if you build the interfacedescribed in this article, you could hita button on your HCS II IR remote and

see network information displayed onyour TV set overlaid onto the programyou are watching.

This article describes an On-

Screen Display (OSD) terminal forHCS II (we’ll calI   it “TV-Link” tomatch the other HCS II modules) thatallows color text characters to be

displayed on top of a background colorvideo signal. The terminal is builtaround the Philips/Signetics  87CO54

OSD microcontroller.

FEATURES OF 87CO54The 87CO54  is an 80C51-based

microcontroller designed to provide anadvanced OSD for TV and video appli-cations. It can produce characters ineight foreground and eight backgroundcolors. In addition, the background

color can be removed, showingthrough the original video. It also hasnine pulse-width modulator outputsfor controlling analog functions.Similar to a standard 8OC5  1, it has 28digital I/O pins, two external inter-rupts, and two timer/counters. RAMand ROM spaces on the 87CO54  arelarger than the 8OC5  1: 192 bytes ofRAM and 16K bytes of EPROM. (TheOSD has a d d i t i o n a l RAM and EPROMareas that are not part of the normal

8OC5   1 memory map.)One unique feature of the 87CO54

is what Signetics describes as a “soft-

Photo l--The W-Link can be used by yoorcompuler  to overlay messages on any video  signal.

40 Issue 29   October/November, 1992 The Computer Applications Journal

Page 33: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 33/88

  t0

PewShift

t, ~Video

outputChromaosc.

 l-Converting km RGB  b NTSC invo/ves  modulating and addingfference s ?ls.

ware ADC.” This ADC consists of annternal 4-bit DAC that feeds onenput of a comparator. The other

omparator input can be connected tone of four I/O pins. The output of theomparator is tied to a status bit in aegister that is testable by software. A

 set often uses this logic for measur-ng the AGC voltage during tuning. Aeal-time clock and other low-preci-ion analog measurements can also use

as a zero-crossing detector.The OSD of the 87CO54  consists

f a lag-character  RAM array (OSD-RAM), a 64-character font EPROM, a

ideo clock oscillator, and the OSDogic. The OSD logic accepts horizon-al sync (HSYNC)   and vertical syncVSYNC) signals and provides threeigital video outputs for character

nformation. In the datasheet for thisart, these outputs are called VZDO

and VID2, but they can alsoand perhaps better) be thought of as

RED, GREEN, and BLUE. A multi-lexer control output is also present to

ndicate when to display character datar original video information.

The video clock oscillator pro-ides timing for the character dots. In

most applications, this oscillator isimply an LC tank circuit connectedo the VCLK pins. The frequencyontrols the character width. One niceeature is that the video clock is killedt the leading edge of HSYNC andestarted at the trailing edge of

HSYNC, which causes the video clocko start in the same phase on everyne, ensuring the dots align verticallyrom one scan line to the next.

The characterfont stores thebinary pattern forthe individualcharacters. Charac-ters are 14 dots wideand 18 scan lineshigh.

The OSDRAMstores the charactersto be displayed onthe screen alongwith certain at-tribute data pertain-ing to those charac-ters. Once a charac-ter has been written

to the OSD, no further CPU interven-tion is required to “refresh” the screen.

Many OSD architectures have

been developed over the years for usein the consumer television market.Almost all of them have required fixedcharacter row formats, limiting thedesigner’s flexibility in designing videomenus and screens.

Now that you understand theconcepts of an OSD operation and thecapabilities of the 87CO54,   focus your

attention on the details required tooverlay characters onto live video.

The 87CO54  was designed to avoidsuch constraints, and there are noarchitectural limits on the number ofcharacters in a row of text or thenumber of rows of text to a screen.[There are physical limits imposed bythe dot clock frequency and the scanrate, of course.)

The 87CO54  OSD has a multi-plexer output for switching videosources. Simply switching between theinput video signal and the OSD charac-ter data would be nice. Unfortunately,you can’t because the input video(from our home entertainment center)is in NTSC format and the characterdata is in RGB format. (Keep in mindthat the goal is to input live video, addon-screen text, and present the resultas a video signal at the output of ourcircuit.)The HSTART and VSTART pa-

rameters in the OSORG (on-screenorigin) register define the intial posi-tion of the start of the OSD. Once theinitial vertical and horizontal positionshave been found, the 87CO54  will“fetch” characters from the OSDRAM character data in RGB format. Theand place them sequentially on the resultant signals could then be en-

screen. In order to have multiple rows coded back into baseband video. If

One solution is to decode theinput video into separate red, green,blue, HSYNC, and VSYNC signals.Then you could perform the multi-plexing between video information and

of text, a special character has beendefined and is referred to as NEWLZNE.

The NE WLINE   character is much likea carriage return/line feed sequence ona computer in that it terminates thecurrent row of characters and starts anew row of text. One advantage of thisarchitecture is that it eliminates the

need to pad display memory withspace characters. The fetching andpainting of rows of text will continueuntil either a new vertical sync pulseis detected or until an END attribute isfetched along with a NEWLZNE char-acter.

NOW FOR THE DETAILS...

Picture Information

HorizontalSync

Figure 2-A @ice/ ine of NTSC video consi of an nitial  /torizorM  sync p&e, fo l lowed  by a short  color burstsignal, hen he Mual  picture flfonnation.

The Computer Applications Journal   leeur W29  October/November, 1992 41

Page 34: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 34/88

V i i 0

Switch

Flgun  3-At  the core oltb  N-Link  b tYte  Sign s  87C054 micmcantm//~,  The unit sum  boh RS-232 andRS-485 cummunkath   with a host computer.

there were other reasons for the con- sources. Sound simple? The situationversion into RGB, such a conversion gets a little more complex when youwould be the way to go. However, the consider the issues of making the

process of converting to RGB and then characters appear with the proper colorconverting back to video introduces in NTSC. Reviewing how color issome distortion that could be visible encoded in NTSC is in order.on the screen.

Another solution is to find a way COLOR TELEVISIONto encode the RGB data from the OSD When you first look at video, youmicrocontroller into video. Then you often wonder why in the world it wascan simply switch between the two done the way it was. A long time ago,

before Americans had ever heard thenames of Japanese TV makers, RCAresearch labs were developing colorteleveision. One of the requirementsimposed on designers by the FCC wasthat the broadcast signal needed to becompatible with existing black-and-white TV sets and had to be contained

within the same bandwidth as a B/Wsignal. Such requirements meant thatsome component of the signal had tocontain overall brightness informa-tion, which is the main reason whythey could not simply transmit sepa-rate R, G, and B channels within thevideo bandwidth allowed. To make avery long story short, the engineersinvolved decided that the scene bright-ness (which they called 7”  or lumi-nance) could be described by the

relationship

Y = 0.59G  + 0.3R  + 0.1 1B

Someone observed that if theytook two copies of the luminancesignal and subtracted one copy fromone of the colors (say, RED) and didthe same with a different color (say,BLUR), the result would be two signalsthat contained all of the informationneeded to represent color. Theseresultant signals, R-Y and B-Y, are the

color difference signals.Now that you have two signals,

how can they be transmitted on oneRF carrier? The answer they came upwith was to modulate one of thesignals (B-Y] with an RF carrier. Theother signal (R-Y) was to be modulatedwith the same RF carrier, but thecarrier would be shifted by 90”. Whenthe outputs of the two modulato?s  areadded together, the result is the vectorsum of the two signals, containing

both an amplitude and a direction(phase angle). See Figure 1.

We now have a single signal thatcontains all of the color information.The TV receiver needs just one morepiece of information to demodulatethis signal. It needs a reference for thecarrier used for the modulation, thatis, the receiver needs to know where 0”

of the color carrier is (in video, thiscolor carrier is referred to as thecbromo  subcarrier). In order to give

this reference to the receiver, a small

See us at the Embedded S)Mems  Confwerw4ooth 71942   Issue  29  OctoberIN0~6mber,  1992 The Computer Applications Journal

Page 35: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 35/88

Page 36: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 36/88

:lgun Qb-The TDA48MTsync separalbrptvvides  the pnxessor  with hodzonti and verdcalsync signals 

phase as the color burst on the original

video input signal.Once you get the OSD informa-tion in the form just described, youcan switch between this “OSD video”and the original input video to producethe final output.

THE TV-LINK HARDWARESOLUTION

Figure 3 shows a block diagram ofthe TV-Link, while Figure 4 shows theschematic.

Referring to the schematic, theoriginal input video connects to J2  andis AC coupled into buffer amplifier,Ql. This amplifier provides loadisolation between the video signalsource and the circuits on the TV-Linkboard. JP4  is a jumper allowing for a75ohm   termination resistor to beconnected to J2.  The output of the Qlbuffer amplifier feeds the sync separa-tor, the video switch, and the chromasubcarrier regenerator circuits.

SYNC SEPARATIONThe sync separator consists of U6,

a TDA482OT   Philips sync separator.The video signal is coupled into theTDA482OT  through capacitor C 14,where it is amplified with a gain of 15.The black level clamping voltage isstored in capacitor C14. From thestored black level voltage and the peaksync voltage, the 50% value of thepeak sync voltage is generated and

stored in capacitor Cl5  A slicing level

control circuit ensures a constant 50%

peak sync value regardless of the

picture content amplitude providedthe sync pulse amplitude is between50 mV  and 500 mV.  A comparator inthe composite sync slicing stagecompares the amplified video signalwith the DC voltage derived from the50% peak sync voltage, producing thecomposite sync output. Vertical slicingcircuits compare the composite syncsignal with a DC level equal to 40% ofthe peak sync signal, producing thevertical sync output. The reducedvertical slicing level ensures moreenergy for the vertical pulse integra-tion. The slope is double integrated toeliminate the effects of interferencecaused by noise or line reflections. Thevalue of resistor RlO  sets the verticalintegration delay time.

The outputs of the sync separatorare positive-going signals with peakamplitudes exceeding 10 V. Resistorpairs Rl l/R12  and R13/R14  serve asvoltage dividers for the VSYNC andCSYNC outputs, respectively. An

LM339 comparator, U5, serves as aninverter for the sync signals becausethe modulator circuits require activelow sync signals.

There is a great tendency withvideo circuits to make the couplingcapacitors very large to pass the low-

frequency sync components (60/50  Hz,typically) into low-impedance nodes.The TDA4820T  has a moderately highinput impedance on pin 2. Because theblack level is stored in C14, the value

of Cl4 should be kept close to 0.22 l.tF.

THE 87CO54  MCU WITH OSD

The 87CO54   microcontroller, U3,accepts composite sync and verticalsync signals from the sync separatorand provides RGB digital outputs forcharacter data. The multiplexer con-trol output, VCTRL, connects to thevideo switch, U2, a JRC2244.

Inductor Ll and capacitors C8 and~9  form a video clock oscillator thatdetermines the width of a characterfont dot. The values of these compo-nents are not critical but are typicallychosen such that a video dot width is

equal to the spacing between scanlines. This oscillator is killed at theleading edge of the  HSYNC signal andallowed to startup at the trailing edge.Such synchronization causes theoscillator to start at exactly the samepoint from one scan line to the next,causing character dots to appear inexactly the same spot on each line.

In addition to the OSD functions,the 87CO54   also performs networkinterfacing and protocol tasks. This

microcontroller has plenty of perfor-mance bandwidth because the OSDlogic is self-refreshing and independentof the MCU core.

VIDEO SIGNAL SWITCHINGThe  JRC2244 video switch, U2,

contains three video inputs, two ofwhich are used in this application.One of these inputs, VZNI is capaci-tively coupled to the OSD video signal.This signal is the 87CO54’s   RGB data

after encoding into baseband video.

44 Issue 129 Octo ber/November, 1992 The Computer Applications Journal

Page 37: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 37/88

Page 38: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 38/88

R292.2k C30

OUERLOAD  

R30c39 __C38

S80P0.0luF   0 0luF

““T i

VI1

LM7812

Figure  4d--The CA31  26 TV chroma processor   is designed specikal~  br  regenerating   chrwna subcat?ets

The other input, VIN3, is capacitivelycoupled to the original video inputsignal. The JRC2244 provides internalbias sources to provide DC restorationto its video inputs. The JRC2244accepts a switching control signal fromthe 87CO54   and switches its outputbetween the original video input andthe OSD video signal. The videoswitch also has an internal 75-ohmline driver in its output stage.

The JRC2244 has a moderateinput impedance of about 1 Sk  ohms,allowing lo-uF   coupling capacitors tobe used. The output coupling capacitoris large because this signal can be usedto drive 75ohm  loads.

RGB ENCODINGThe LM1886, U13, and the

LM1889, U14, encode the RGB datafrom the 87CO54   into baseband video.The LM1886 has three DACs,  one foreach color. Each of these DACs  has 3-

bit inputs, but because the 87CO54

data is digital, the inputs to theLM1886 DACs  are tied together yield-

ing an output for each DAC that is

Y amplitudes. The LM1889 accepts the

either full-scale or zero. The outputs of

regenerated chroma subcarrier, modu-lates the R-Y and B-Y signals, and

the three DACs   are internally summed

produces baseband video on pin 13.Transistor Q5  is used as a buffer

to produce the luminance, R-Y, and B-

amplifier with voltage dividers R49and R50 producing proper levels forthe video switch. Note that theLM1889 accepts an external subcarriersignal at the junction of R46 and C52,but this subcarrier undergoes a phaseshift caused by the resistor and capaci-tor networks associated with pins 1and 18 of the LM1889.   This phase shiftwill need to be considered when thesubcarrier is regenerated.

C27. The filter starts passing signals atabout 3.2 MHz, allowing the chroma

The passive high-pass filter con-

subcarrier to pass through to theCA3126, U15.

sists of inductors L4 and L5,   resistorR28, and capacitors C25, C26, and

The CA3126 is a TV ChromaProcessor IC designed specifically forregenerating chroma subcarriers. ThisIC contains a VCO and a PLL withsample-and-hold circuits in the errorcorrection loop. As a result, the VCO-generated carrier is compared with thechroma signal from the high-pass filterduring the time that color b ispresent, indicated by the burst gatepulse (which I will describe later].

The regenerated carrier output ispresent on pin 8 of the CA3 126. Eventhough this carrier is phase locked tothe color burst, it is not at exactly thesame phase as the color burst. Thenature of a PLL is such that the outputwill be locked but will always havesome constant fixed phase delayrelative to the input. Also, recall that

the input circuits of the LM1889 added

CHROMA SUBCARRIERREGENERATION

The circuits that reproduce achroma subcarrier   in the same fre-quency and phase as the color burstconsist of a high-pass filter, a sample-

and-hold phase-locked loop (PLL), and

a phase shift network and amplifier.

46   Issue  W October/November, 1992 The Computer Applications Journal

Page 39: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 39/88

Page 40: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 40/88

 A = string Set HCS II network address to string

Fx Execute special function0 Initialize screen1 Display on

f

Display off Display color bars

:

Wipe onWipe off 

Nxy Set Px.y  high

Lx Y

Nn

Clear Px.y  low

Network response modeNO = normal network interface, no auto error or acknowledge responsesNl  = auto error and acknowledge response

Px Query port xO=PortO

1 = Port 12=Port23=Port3

Px= nn Write to port x where nn=  two-digit hex valueO=PortO

1 = Port 12=Port23=Port3

R X Query register x; returns two-digit hex number 0 = OSDT (contents undefined)1 =OSAT ’2 = OSCON3 = OSORG4 = OSMOD5 = Default char. attribute6 = Default background space attr 7 = Default NEWLINE   attribute

Rx = nn Write to register x; for use from outside of a string of text; writes to theseregisters from within a string; should use the \Wxnn command

0 = OSDT1 =OSAT2 = OSCON3 = OSORG4 = OSMOD5 = Default char. attribute6 = Default background space attr 7 = Default NEWLINE   attribute

S= string String for OSD display; can include escape sequences for text formating,color, selection, etc.

\Wxnn Write to register x; for use within a string; functionally equiv. to the Rx = nncommand

Special characterss  for use within a string of text

\E\B

:

End of Display at current positionBackground SpaceSplit Background SpaceNEWLINE

7 able l - The set of supported commands rasembks that of  most  of the  other  HCS  II nehwrk  modules.

87CO54  and the part does not have atransmitter pin or receiver pin.

In this application, the serial datatransmission and reception has beenperformed in software. The routine

that handles serial transmission and

reception was taken from the SigneticsBBS ([800]   45 l-6644). It was originallydesigned for the 87C75  1 and had to beslightly modified to operate with oneof the 87CO54’s   timer/counters. Thetechnique is often called “bit banging”

48 Issue 29   October/November, 1992 The Computer Applications Journal

and has the advantage of saving somehardware if you can afford the neces-sary time required of the software.

NETWORK PROTOCOLPROCESSING

As I indicated earlier, in additionto the serial interface software, you

need code that handles networkmessage formats. The code starts bywaiting until either a “ ”  or an “ ”  isreceived, either of which indicates thestart of a network message, then theentire message is stored in a buffer.

Once the carriage return has beenstored, the beginning character of themessage is checked to see whether themessage includes a checksum. If themessage does not contain a checksum,the packet is assumed to be valid and

the contents of the packet are pro-cessed. If a checksum is included, thenthe V ER I FY routine is called to per-form a checksum calculation on thepacket. If the checksum matches, thepacket is processed; otherwise, it isignored and I return to waiting for thenext network message.

My original plans for handlingnetwork checksums included achecksum generator for sendingnetwork responses and a checksumchecker for received messages. How-ever, when I flowcharted the needs ofboth routines, I found that an awfullot of the logic was common to both. Iwent back and looked at the sugges-tions that Ed Nisley had provided forhandling the checksums and under-stand now why he made those sugges-tions. My V ER I FY routine’s logic isbased on Ed’s previous work.

The V ER I F Y routine performs twofunctions. First, it takes the checksumdigits in the packet, converts them tobinary numbers, and stores them intemporary variables. Next, thechecksum digits are replaced withASCII zeros and the checksum of thestring is calculated. If the checksummatches, the error flag, C H K ER R, is

cleared; otherwise, it is set. Thechecksum that was calculated isconverted to ASCII and stuffed intothe checksum digits position, replac-ing the ASCII zeros.

To prepare a string for transmis-sion, all that is necessary is to stuff the

Page 41: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 41/88

ssage in the buffer with the check-m digits set to ASCII zeros and callV ER I FY routine. To check a mes-e for correct checksum, simply callV ER I FY routine and check theKERR flag on return.

Once the checksum verification (ifuired) has been performed, you still

ed to process the packet to see if itongs to this terminal, and if it does,n you need to determine whation the network controller is askingu to take.

The PROCESS routine first scanspacket, converting characters into

per case until the end of the packet been reached. Next, the first

aracter is examined to determine ifpacket has checksums or not and a

nter is set to the NODE1 D position ofpacket. The NODE I D in the packet

ompared with the N 0 D E I D variable.here is no match, the packet isored and you wait for the nextwork message. If it does belong dos terminal, you can process thedy of the network message.

TWORK COMMANDS ANDNTAXThe real essence of a network

ssage is to carry a command fromnetwork controller to the terminal

carry a response from the terminalk to the network controller. Tablehows the syntax of the commands

ailable for operating the TV-Linkminal. These commands allow the

CS II Supervisory Controller tonipulate ports on the 87CO54,

mat text for display, implementecial built-in display functions suchcolor bars, and to read and writeD registers directly, giving full

ntrol of the OSD to the HCS II.

ONCLUSIONSDeveloping this application was

eresting and enjoyable. It alsosented some challenges.The 87CO54  proved well suited to

s application in large part because of8OC51  core and that the OSD is

dependent of the CPU. Once charac-s have been written to the OSD, youn forget the OSD until you want toange the display, and the CPU is freepursue other tasks.

The on-screen display and themicrocontroller operations are prima-rily digital functions. The question ofhow to combine this technology withan analog video signal can be perplex-ing to most system designers whoseprofessional experiences have beenmostly digital circuits. One of the

most perplexing issues during thisproject was how to recreate thechroma  subcarrier.   I knew that everycolor TV  set had to perform thisfunction, but finding out solutionstook some searching before I discov-ered the CA3 126. I’m hopeful you canprofit from my experiences on thisproject.q

My t hanks t o Herb K niess and George 

Ell is of Signet ics for t heir hel p. Thanks 

also t o Greg Goodhue from Signet i cs,

w ho w rote the softw are-based UA RT code for t he 87C75 that I modif ied 

for t his project.

Bi l l Houghton is an Appl icat i ons 

Engineer at Signet i cs special i zi ng in 

BO CSl based   microcontrollers.

Software for this article is avail-able from the Circuit Cellar BBS

and on Software On Disk for thisissue. Please see the end of“ConnecTime”  in this issue fordownloading and ordering infor-mation.

Requests for literature on Signe-

tics/Philips microcontrollersincluding the “8OC5  1 -Based g-Bit

Microcontroller Data Handbook”may be directed to Sharon Bakerat (408) 991-3518.

Contact Bill Houghton at (408)991-3560 with technical questionsspecific to the 87CO54  and forinformation on the availability ofa PC board and components forthis project.

410VeryUsef ul

411 Moderatel y Usef ul

412NotUsef ul

DIPS  - SlMMs  - SIPS

RAMSTAR7Ins. RESOLUTION 

ACCESS SPEED VERIFICATION80 ns. thru 180 ns. (Std.) $249.0

45 ns. thru 110 ns. (Fast) $349 0

4MEG Optlon  A d d $ 89 .0

AUTO-LOOP

Continuous Test 6.25 MBitsisec.

 A DA P TE R S :

COMPUTERDOCTORS9204-B Baltimore Boulevard

College Park, Maryland 20740IADEINUSA U.S. PATENT No. 4.965.79

“A,._

FAST COMPLETE 

ACCURATE 

DRAM TEST 

SlMMlSlPADAPTER $189.0

Tests 64K, 256K,  1 M & 4M Devices8 or 9 Bit versions.

  N T i

NTX ADAPTER $149.0

Tests 64 Pin Dual-EdgeLaserWriter Type SIMM’s.

4 X ADAPTER $ 89.0Tests 64K & 256K By 4 Bit Devices

AC ADAPTER $ 18.0

Regulated +5V  @ 1 Amp.

FREE RAMFACTSDRAM NEWSLETTER 

1The Computer Applications Journal   ltsue  29 DctokdNovmber,  182 49

Page 42: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 42/88

The Virtues

of the Hue,

Lightness, James R. Furlong

Saturation

Color Modelave you ever

graphics that use thedefault EGA/VGA color

palette lobk  as lousy as they do? Didyou think your boss was kidding when

he told you to mix equal levels of redand green to create yellow on yourcomputer? My Crayolas never did that.Have you ever wanted to portray theshock heating of a piece of orbitaldebris impacting a satellite bumpershield at 6.5 kilometers per zas

continuous tones of red, but gave upafter trial-and-error guessing of RGBcombinations made you surmise youwere color blind? If you answered yesto any of the above, let me assure youthat a) you are not alone and b) a well-

established but little-publicized colormodel named HLS (for Hue, Lightness,and Saturation) is the cure for yourpalette woes.

Hue is perceived as the azimuthcoordinate on the model. This designa-tion isn’t arbitrary, but rather it is aconsequence of a special additive

nature of the RGB system itself. InFigure 1, notice that if blue is arbi-trarily taken as the starting point, youcan smoothly scroll through the cyans,greens, yellows, reds, magentas, andfinally wind up back at the beginning,namely blue, without any loss ofcontinuity. You will have the sensethat you passed through all the basiccolors in the visible spectrum.

Designed by people who thoughtabout what color means to peoplebefore how color is described for amachine, the HLS model takes theguesswork out of making colors likeshocking pink or pastel green. Simpleanalytic functions and a handful oflines of computer code create a paletteof continuous tones of red, or peri-winkle, or they can bridge dark bluewith bright orange because the model’scoordinates are dimensionless.

Saturation-Saturation defines thepureness of a hue for a given level oflightness. Conceptually, saturation isthe radial coordinate in the model. Thelarger the radial coordinate, the purerthe color. Colors of low saturationtend to be soft, or pastel, and fullysaturated colors can be harsh, depend-ing upon their lightness.

A lack of saturation defines thegrayness of a hue. Note that graynesscovers all levels of gray, from totalblack to pure white. Any hue at zerosaturation will be pure gray. Whetherthe gray is black, white, or somewherein between will depend on the light-ness. A good example of an unsatur-ated color is pink, which is somewherebetween pure red and white.

The following description is of the Lightness-Lightness is howtransformation equations between the bright or dark a color is, as the nameI-KS  and RGB color models and the implies. It is the vertical axis of theBIOS interrupts necessary to load IBM model. Due to the model’s double coneVGA hardware with RGB values, so structure, the maximum saturationyou can think in terms of HLS but level depends on lightness. This levelspeak to your computer in RGB. I also varies from 1 at the equator to 0 at the

introduce an extension to the I-ILSpoles. A lightness of 0 or 1 will have a

model that allows more color possibili- maximum saturation of 0 because

ties and unlocks the 262,144 colors ofwhich the VGA is capable.

MODEL COORDINATESFigure 1 illustrates the conceptual

framework for the HLS model [ 11. Thefigure is three-dimensional because themodel has three coordinates. They are

defined as follows:Hue-Hue is what many of uswould commonly refer to as color.Red, green, and purple all are hues, butin the context of the HLS system theyare colors absent of a definition forlightness (dark red or bright red), andsaturation (pure red or pink).

50   Issue W2 9  OctobedNovember, 1992 The Computer Applications Journal

Page 43: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 43/88

HUE

100%

0%

un l-The HLS mode/ can be conceptualized   in three dimensions as  a paiiof  cones.  Hu e  proceeds  anwnd the Lightness NIX in the vertka/ dkection, and Safurafbn extends radial& kin  Ute  c w  and depsnb L,   some

gree 4  lYle Lightness. (@Tektronix  Inc.)

ose values correspond to black orhite, while a hue can be fullyturated at the equator.

The intuitiveness and elegance ofe HLS model become apparent whenis compared to RGB. Take pasteleen, for example. Under RGB youould first set the lightness of greenith GREEN intensity, but to softene green you would have to add equal

levels of BLUE and RED. That doesn’treally make sense, does it? Under HLSyou would first set HUE to green, thenmake the green as bright or dark asyou want with LIGHTNESS, and aspastel as you want with SATURA-TION.

Furthermore, pastel green happensto be one of the easier colors to makeunder RGB because equal levels of

BLUE and RED are an exact comple-ment of GREEN. If you shift the colorfrom pastel green to say pastel cyan(cyan is equidistant from BLUE andGREEN), then the ratio between BLUEand RED would no longer be unity,and you would need an ambiguouscombination of BLUE and RED to

soften the cyan.

TRANSFORMATION EQUATIONSThe process of creating the HLS

transformation equations begins byrecognizing the relationship betweenRGB and the hue coordinate. Figure 2lays out HUE in one dimension.Although HUE is the azimuth coordi-nate and should be referred to by angle,I have normalized its value to 1,maintaining consistency with theother coordinates. You can make thestarting point any value you wantbecause the hue coordinate is circular.In my system, HUE = 0 is defined asblue.

With a little imagination, you cansee that if trapezoidal-like functionsfor BLUE, GREEN, and RED are used(which only differ from each other bytheir starting hue point) the entire huecoordinate can be traversed to mimicthe color transitions shown in Figure1. For example, starting from HUE = 0and tracing through the functions inFigure 2, BLUE is the only functionwith a positive value. Advancing toHUE = l/6 BLUE remains constantwhile GREEN begins to increase,eventually equaling BLUE. The equallevels of BLUE and GREEN create thefamiliar cyan hue.

If you continue to trace throughthe functions, for l/6  < HUE l/3

GREEN remains constant while BLUEis brought to 0, resulting in the greenhue at HUE = l/3 A subsequenttracing through the functions willshow that the growth and attenuationexperienced by GREEN repeats for theother two colors, first for RED at HUE= l/3  and then for BLUE at HUE = 213At HUE =  1, you have come full circleand are back at blue.

Defining the trapezoidal-likefunctions for RED, GREEN, and BLUErequires nothing more than superpos-ing linear functions with differentamplitude offsets. For example, the

The Computer Applications Journal   Issue W2 9  Octokr/November,  1992 51

Page 44: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 44/88

Page 45: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 45/88

Page 46: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 46/88

Page 47: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 47/88

Page 48: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 48/88

Page 49: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 49/88

m canon. An inexpensive, thin-lled sacrificial plate, or bumper, isd to intercept the particle. The

ock wave stress caused by thelision is high enough to vaporizeparticle so the debris carried

wnstream cannot harm the vehicle.The palette definition begins with

UE set to blue (a subjectively coolor) and ends at orange (a subjec-ely hot color). SATURATION andGHTNESS vary linearly at differentes as HUE goes from blue to orange.s feature emphasizes the change in

ensity. When you apply HIS  to theblem, a tapestry of science and art

ows a magnificent visualization of.event.Other analytic functions produce

ferent effects. Part of the fun with

HLS model is just experimentingh different functions. Creativections lead eventually to a libraryfunction definitions that mightly be called color effects. With ae practice, you will find that goingm periwinkle to thistle is both easy

fun. q

fames R. Fur long is a research scien- 

tist wi th a defense-related organi za- 

tion in Ar li ngton, VA. He develops 

constitutive  models for materi als 

undergoing shock used in l arge-scale 

hydrodynamic computer codes. He is 

also head of softwar e development for 

Eclectic Systems in Springfi eld, VA .

Tektronix 4107/4109

Programmer’s Manual,Appendix E, 1982.

I BM  Personal System/Z  Display Adapter Technical Reference,International Business Ma-chines Corporation, 1987.

Zeus: Technical Description and User’ s Manual, Computa-

tional Mechanics ConsultantsInc., Baltimore, MD, 1990.

F. Whipple, Meteori c Phenom- ena and Meteor i te: The Physics and Medicine of the Upper Atmosphere, University ofNew Mexico Press, Albuquer-que, NM, 1952.

Readers interested in experiment-ing with the HLS model maycontact Eclectic Systems for a freecopy of the utility “MYPAL.”MYPAL   is an interactive programused to define palettes in HLS

space. HLS coordinates are savedin ASCII files. Programs that readthese files can use the source codegiven in this article to set theirown palettes. MYPAL   is availablein DOS and Windows formats. Anominal fee to cover shipping andhandling will be requested.

Eclectic Systems8 106 St. David CourtSpringfield, VA 22 153

413 Very Useful

414 Moderately Useful

415 Not Useful

An add-on board, with re-created 68HC705Klinterrupt logic and 64 bit PEPROM in hardware,converts the 68HC05P8  EVS into a complete68HC05  K family real time ICE, not a simulator.Comes with user friendly PC driver software, 16pin emulator cable and plug. (Demo disk: $5.00)Part number: EVSKl-ICE Price: $68.05

l PC based user friendly real time 6t3HCll   ICE.00

 New 64K memory module supports different probes.

0Active probe reduces propagation delay to target system.

0Full speed up to 20 MHz, single chip and expanded modes.On-board 64K emulation R4M  maps to 4K blocks.

0   64K real time hardware breakpoints.00

Breaks on address, address range and memory RD/WR

0Full symbohc  debugging. Supports all A,D,E, and Fl  parts.40 pin logic analyzer connector.

0   64K memory module $295.000   Probe (with PC driver) S450.000 44 PLCC to 40 DIP adapter $55.00

lWytec[

0 52 PLCC to 48 DIP adapter $SS.oO Suite 23g360 W. Schick Road

FRANCE distributor: Bloomingdale, IL 60108

I.S.I.T. CO. Tel: 33 6185 57 67 (708) 894-1440 

WICE 28   emulator $99586CO8  adapter  w/an&g  comparators  $55

We feature a series of single board computers forprocess control applications. Each is available as a

bare printed circuit board, or fully assembled andtested. Optional development software is also

available. Please contact us to discuss your

requirements and receive a literature packagecovering technical specs and pricing.

 The Computer Applications Journal Issue 129   October/November, 1992 5 9

Page 50: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 50/88

Driving

Multiple

VGAMonitors

Michael Swartzendruber

more than onemonitor from a single

or necessary. Software demonstrationsor other kinds of group demonstrationsare examples of one type of occasion.Side-by-side comparisons of differentbrands of monitors are another. Also,certain artistic displays work bestwhen more than one monitor displaysan image.

Multiple-monitor drivers thatdrive from two to sixteen monitorssimultaneously are currently available.These devices start at about $300 andgo up in price depending on thenumber of monitors the device candrive. However, the simple circuit Idescribe here is an alternative thataddresses these problems at a muchlower cost. I built the “core” of thiscircuit with three low-cost transistorchip arrays and a handful of resistors.

Moreover, you can duplicate the coread infinitum to drive as many moni-tors as demanded by the task at hand.

THE CIRCUITFigure 1 shows my multiple-

monitor driver. This simple deviceimplements any number of parallel

emitter-follower amplifiers, whichserve three essential purposes. Thefirst is to provide a properly termi-nated load to the video card in thecomputer. Second, these amplifiersserve as isolation amplifiers betweenthe PC video card and the multiplemonitors being driven from the videosource. The third purpose of theseamplifiers is to provide drive currentto the inputs of the monitors con-nected to the circuit.

Notice that the base of the drivercircuits’ transistors connect to groundthrough a 75ohm  resistor. As Imentioned before, this resistance isprovides the proper amount of loadresistance to the PC video card. Thebase of each monitor’s driver-amplifierconnects to this point. The multiplebases connected to this resistor do notalter the 75ohm   termination resis-tance appreciably, allowing multipleemitter-followers to be driven from thevideo card. In turn, this feature is whatallows the PC video card to drivemultiple monitors.

The amplifiers serve as isolationamplifiers between the video card andthe monitors by the isolatable charac-

Photo l -Driving  mu/tip/e mo n i rs  horn  a s ing/e  VGA &flay  adapter  doesnY  have b be  expensive

The Computer Applications Journal Issue 9  October/November, 1992 61

Page 51: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 51/88

teristics of an emitter-followeramplifier. As mentioned above, the PCvideo card only “sees” 75 ohms of loadresistance no matter how many basesconnect in parallel at this point. Theemitter of each transistor follows thevoltage level of its base, which makesthe emitter circuit the signal source to

the monitor connected to it. At thispoint, the signals are directly derivedfrom the video card.

The emitter-follower circuitprovides load current that drives themonitor inputs. This drive current isprovided by the collector emittercircuit and does not require anysignificant level of load current fromthe base circuit. Therefore, you canuse this circuit to connect multiplemonitors without affecting the load

current the video card must supply.The combination of all of thesesimple factors allows this circuit tooperate. If you need more monitors,simply connect more transistors’ baseleads to the 75ohm   resistors. Then just build the same “core” over againfor each monitor.

UGFl

Input

III ( M a s t e r )

Figure l--The TPO2907quad  baneisfor  peck is the key o he multiple monitor driver  circuit.

rnal

Cross-l 6Meta-Assembler: US 99  / CN 119

XDASM Cross-Disassembler:US 249/CN 299

High PerformanceMultimegabyte Disk Emulators

NEW MODELS / LOWER PRICESl Floppy Drive and multimegabyte

emulators for ISA bus computers

l 180K to 14 MB capacities

l EPROM, Flash or SRAM technologies

l  Autobooting, Single or Dual diskemulation under PC or MS DOS

l List prices from $195

CURTIS, INC.418 W. Country Road D l St. Paul, MN 55112

6121631-9512   FAX 612/631-9508PC DOS IS  a trademark of IBM; MS DOS 1s  a trademark of Mlcroscoft

Both MS-DOS products include support for ALL

of the above processor families.

EPROM emulators and Forth compilers too!

Request our catalog.

Credit cards are billed in Canadian dollars (CN$).

Canadian residents please add 7% G.S.T.

62 Issue 29 OctokdNovember,  1992 The Computer Applications,

Page 52: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 52/88

I designed this particular version

the circuit to work with the stan-

rd VGA D-type E-pin  connector.

u can easily change the circuit to

ve it work with any other color

deo monitor standard as long as the

d, Green, Blue, H-Sync, and V-Sync

gnals can be identified. These signals

ould be input into the core circuit inactly the same manner. The outputs

the circuit could then be connected

the appropriate pins of the connec-

for that color monitor standard.

Note the signals are identified as

Dl and 102.   The VGA monitor

ovides these signals to the video

ard for input. They identify a

onitor’s type to the VGA board, and

e video board uses this information

ring its power-up automatic mode-

ting operation.

In order for this operation to finish

rrectly and without conflicts, only

e monitor should provide these

gnals. Therefore, if you use multiple

res, only one port should pass these

gnals to the VGA board. The one port

at has these signals connected

through it will be named the master 

monitor port because the monitor

connected to it will be used to set the

power-up mode of the video card.

Connect the lowest-performing 

monitor to the master monitor port to

ensure all monitors connected to the

other ports are capable of operating. If

you use the highest-performing monitor as the master, some monitors

may be incapable of performing at the

master’s mode. Another way to

operate this circuit with monitors that

support different resolution levels or

capabilities is to leave IDO, D l ,  and

ID2 on all ports disconnected and

issue manual video mode-setting 

commands to the video board.

CIRCUIT USE

This circuit is very easily installedand used. Connect the PC video port

to the input port of the circuit assem-

bly, then the monitors to its video

output ports. The only restriction is

connecting the lowest-performing 

monitor to the master monitor port,

although even this recommendation is

not absolute and depends on your

application or your ability to issue

video mode-setting commands.

CONCLUSIONThis easily built and usable circuit

is a great help on those occasions

where driving multiple monitors is

necessary. A very low cost makes itthe most sensible option when

compared with similar devices, most

of which are offered for sale at about

500 times the cost to build this device.

This card has many more applications

than the small number I’ve suggested.

 Just having a device like this one on

hand reveals a whole new world of

computing possibilities. q

Michael Swartzendruber  is curr ently 

employed at System Integrator s Inc.,

where he works with LAN design and Macintosh programming.

416 Very Useful417 Moderately Useful418 Not Useful

We offer a full line of low cost 8OC32  embeddedcontrollers and software tools. They are ideal for developing products, test fixtures and prototypes.

Features include: 

l Low power CMOS design

l RS-232 and RS-485 ports

l Up to 60K of code space

l Up to 60K of data spacel 5 to 1.5  volt operation

l Small form factor (3.5” * 6

l

System diskette includesapplication notes and an

assembler.

l Start at $100

Avai lable Options : 

l Real Time Clock

.5”

l Watch Dog Timer 

l Multifunction Board adds LCD, Keypad, UART, A/D and 24 I/O lines.

l BASIC-52 or Monitor/Debugger in EPROM

l C Compiler, $100

Iota Systems, Inc.POB 8987 l Incline Village, NV 89452

PH: 702-831-6302 l FAX: 702 831-4629

l 24 hr. d.s./72 hr. m.1.* Prototype to Production

FR-4, Plated-Thru Teflon, PolyimideUL Recognized

I i@@‘ ]  I.M.p.A.C.@   mCall us for an instant quote

24 -hr.modem  for easy transfer of Drill CAD files.

Free Tooling On First Order! (up to $200) 

Superior Quality at Competitive Prices!

CAPITAL ELECTRO-CIRCUITS7845-J Airpark Road

Gaithersburg, MD 20879(301) 977-0303

Fax: (301) 990-6715

The Computer Applications Journal   Iawe  29  OctobedNovmber,  1992 6 3

Page 53: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 53/88

DEPARTMENTS

Firmware Furnace

From the Bench

Silicon Update

Practical Algorithms

ConnecTime

Ed Nisley

Extending Your Control:The HCS II MCIR-LINK

come true” is anaphorism often attrib-

uted to the Walt Disney School ofEngineering. But at least in thewonderful, malleable world of firm-ware, wishes sometimes do come true!

Back in issue 25  of the ComputerApplications Journal, Steve, Ken, and I

introduced the Home Control SystemII (HCS II). The system is based on aSupervisory Controller, which handlesall the grisly scheduling and overseesthe whole system, and networkable“Link” modules, which expand thesystem I/O by adding digital I/O ports,LCD display, X-10 power-line control,and more. I’ve been steadily coveringall those network modules in the lastfew issues.

Back in issue #26’s “Firmware

Furnace,” entitled “Infrared HomeControl Gateway,” Steve and Ipresented the IR-Link module as acommand and control gateway intoHCS II. It received and transmittedinfrared signals in the 9-bit MotorolaMC145030 format and includedenough features to implement IRbadges, people tracking, and so forthand so on. Refer to that issue for acomplete IR-Link schematic anddiscussion of the hardware and

firmware.

64    lr5ur 829  Octo ber/November, 1992 The Computer Applications Journal

Page 54: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 54/88

Page 55: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 55/88

Page 56: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 56/88

Page 57: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 57/88

Page 58: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 58/88

Page 59: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 59/88

Page 60: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 60/88

Page 61: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 61/88

serve as both address and counter witha DJ N Z instruction.

Figure 5 shows the first few linesof a 38-kHz  signal dump. Each group often vertical tics represents one byte ofsamples, with the two blank sampleperiods indicating the dead timerequired to store the eight data bits in

RAM. The first IR burst is long enoughthat all 255 bytes are filled withcarrier, but that is precisely the levelof detail I RSAM P L E is intended topresent.

Many remotes need a few cyclesto “get up to speed,” so you mightwant to skip the pulses in the first lineor two when you calculate the fre-

You can calculate the modulationfrequency by finding the elapsed timefor 10 or 20 cycles, dividing to get theperiod of one cycle, then taking thereciprocal to get the frequency.I RSAM P L E enumerates the rising edgesto simplify this process: the elapsed

time for pulses 10 through 22 is 544 -252 = 292 cycles = 3 17 ps.   Dividing by22 - 10 = 12 gives 26.4 ps per cycle or37.9 kI-Iz.

quency.  You should also avoid usingedges immediately after the timinggaps, such as edge 2 in Figure 5,because the firmware was busy storingthe previous byte and could notsample the input bit. That transitionmay have actually occurred any timein the previous two sample times, so

precise timing isn’t possible.Unmodulated IR signals will

appear to be straight lines, low whilethe LED  is ON and high for the OFFtimes. Remember that the MCIR-Linkhardware and firmware can’t handlethose signals.

ON THE AIR

You may also download the

The MCIR-Link EPROM hex file(MCIRB.HEX)isavailableonthe

complete I RSAMPLE.C source code

Circuit Cellar BBS for your noncom-

mercial use. The source code is notavailable, but it may be licensed from

and I RSAMPLE. HEX for your IR-Link

Circuit Cellar Inc. (not INK). Contact

board to check your remotes for

them for details.

MCIR-Link compatibility. You willneed the current version of Dunfield’sMicro-C compiler to recompile thecode.

Pure Unobtainium has most of theodd parts you need to build the IR-

Link and MCIR-Link projects, includ-ing the IR photodiode and LM3 11 for

the 1RSAMPLE.Cprogram.m

Ed Ni sley is a Regist ered Professional 

Engineer and a member of t he Com- 

puter A ppli cati ons Journal’ s engineer- 

ing staff . He speciali zes in fi nding 

innovat iv e solut ions to demanding 

and unusual t echnical pr oblems.

Pure Unobtainium

89 Burbank RoadTolland, CT 06084-2416Fax/Voice (203) 870-9304

419 Very Useful420 Moderately Useful421 Not Useful

MICROWAVESENSORSFor non-contact detection of:l Motion

l Velocity 

l Direction

l Point level 

l Presence

Our microwave sensors see up to

150 feet through foam, buildup,

glass, and non-metallic substances,and are unaffected by environmental

conditions. These proven, low cost

solutions are available off-the-shelf,

or custom made for OEM use.

Call For Your FreeSelection Guide

I -800- 289-261 1

 AM Sensors, Inc.26 Keewaydin Drive

Salem, NH 03079-2839Phone: 603-898-l 543

Fax: 603-898-I 638

  iRcuir   d R

PRoj cT F ib , VOLUME   1

The Circuit Cellar Pro’ect File, Volume 1 has over 200 pagesof new and expanded hands-an projects and tutorials.The Computer Applications Journal’s editors have chosen a dozenof the toppendent su 

rojeck from  the Circuit Cellar Design Contest, inde-missions, and topresponse articles to make a book

with something for   every interest1

now on ly 17.952 (mcluder   domestic delivery’)

Order your copy   today!

Th   iRcuiT   ULR  hojrcr  Fik Vol.4   Park Street, Vernon,   CT 06066 l Tel: (203) 875-2 199   l Fax: (203) 872.2204

H46

72 Issue 9 OctobedNovember, 1992 The Computer Applications Journal

Page 62: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 62/88

x-10

Interfacing

with PLIX Jeff Bachiochi

0 et me see the

hands of all the

engineers out there

who still enjoy getting

down on the floor and building forts

and castles out of blocks or Legos with

the “kids.” For some of us, doing suchan activity with young children is a

successful enough smoke screen to

save us from the label “eccentric.”

Call me what you like, but building a

fantasy empire out of wood is just as

rewarding as designing a product.

I enjoy using the rules of gravity

and balance with good old wooden

blocks, and building with Legos has its

own reward even though working with

them is a bit different. Every task has

its own set of rules. An understandingof these rules and a bit of imagination

is all you need to do well. The   same

concept used in castle construction

applies to product design. I guess that’s

why I enjoy being an engineer. If you

choose the correct mix of components,

your design will withstand the test of

time (or gravity). If not, well that’s

how we got the term “smoke test.”

One of the most widely discussed

topics here in the Computer Applica- 

t ions Journal (and on the Circuit

Cellar BBS) is home control. X-10

control is a favorite subject within this

topic. Let me show you how the new

PLIX (Power Line Control for X-10)

chip can ease you into X- 10 control

without even breaking a sweat, and

why you should consider using a chip

to handle X- 10 communication in your

next design. I think you’ll find this

blend a perfect one.

WHERE WE’VE BEENMany of us have been using X-10

modules for appliance control for over

ten years. X-10 Powerhouse remains

unchallenged as the leader in power-

line carrier transmission control

systems. CEBus’s  PLBus may render X-

10’s code transmission format obso-

lete, but its large, installed user base

will prevent that from happening any

time soon. (For more information see

the assorted CEBus  articles by KenDavidson in issues lo,   15, and 21

of Circuit Cell ar INK .) 

Photo 1--PL/Xsimp/iries  ti e  task o/X-l0  i n fe r fackg  by handling a the compli cated lim ing.

74 Issue 29   October/November, 1992 The Computer Applications Journal

Page 63: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 63/88

Page 64: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 64/88

Page 65: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 65/88

Page 66: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 66/88

Page 67: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 67/88

 2-m to the PLIX  &p’s  bw power wnsumpkm the  demo board canbefwt ofla9 Vbaftey

portant functions without having toddle its thumbs [or bits) during ae-intensive X-10 serial transmis-n or reception. If I didn’t knower, I’d have guessed it was X- 10o came up with this missing link.

me companies just can’t wait for theure; they have to invent it.

 DEMO BOARDI’ve put together a little board that

l allow you to experiment with thisp [Photo 2). Even though PLIX onlyds five external components andbe handwired easily, immediate

tification can be a worthy attribute.modular phone jack permits directnection to either the PL513 or the523. A short piece of ribbon cableof the square-pin header simplifiesrconnections between PLIX and

ur port bits. Finally, power isplied by a 9-volt battery.If you don’t have a controller

ject in the works and can’t directlynect to PLM, but still want toeriment, you are in luck. The PLIX

mo board will also interface to yours parallel printer port. Because theprinter port is not a true bidirec-

nal port, the data must be read inough the status port as nybbles,ich adds a bit more complexity tocircuit. The low power of the PLIX

p allows battery operation.The routines written for the PC’s

allel port are written in BASIC, but

are adaptable to any language, includ-ing straight assembly language. Thequick evaluation of PLJX is this demoboard’s purpose. Once you see thebenefits of using PLIX, you will likelywant to include it in your future X-10designs. ( I

Jeff Bachiochi (pronounced “BAH key

AH -key”) is an electrical engineer on 

the Computer Appli cations Journal’ s 

engineeri ng staff . H is background 

includes product design and manufac- 

turing.

Micromint Inc.4 Park St.Vernon, CT 06066(203) 871-6170

1. PLIX Chip and Data Sheet. . . .  $20

2. PLIX-EKit   Evaluation Board.Includes PLIX chip, data sheet, PCBwith all components, applicationnote, and PC-compatible software ondisk. . . . . . . . . . . . . . . . . . . . . . . . $29

Add $20 for TW5W  X-10 transceivermodule (sold with PLIX-EKit   only).Shipping extra.

422 Very Useful423 Moderately Useful424 Not Useful

The Computer Applications Journal issue 129  OctoberlNovember,  1992 79

Page 68: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 68/88

I’m 18.432-and I Like It

Tom Cantrell

Cooper paid homage to

hormones by making his classic

statement, “I’m 18 and I like it.”

Today, many of us yearn for a return tothe days of our youth when we were

strong and good looking.

Meanwhile Alice, who still wears

tights and makeup 20 years later,

barely made it out of adolescence

before jumping directly into mid-life

crisis. Come on Alice, update our

generation’s anthem-how about “I’m

middle-aged and it stinks.”

Baby-boomers and the like aren’t

the only ones having mid-life crises.

ICs  are having them, too. Chips thatonce were the darlings of industry

have ended up feeble “commodities.”

Now a chip, unlike the typical

burnt-out Silicon Valley executive,

can’t turn to Grecian formula, a Nehru

 jacket, and singles bars for a mid-life

“kicker.” However, as I will show, old

chips and systems can also be rejuve-

nated.

DANCING AS FAST AS I CAN

The280,

 and its follow-on theZ80  180 (a slightly modified I-ID64 180),

certainly qualify as some of the most

popular chips of all time. Neverthe-

less, these parts are starting to show

their age.

Now, Zilog has come to the rescue

with the new Z8S180.  Though fully

plug compatible with the existing ‘180,

the 3180  has a number of new

features.

The S stands for the static design

of the chip. The primary benefit ofstatic [as opposed to dynamic) designs

is you can arbitrarily run the clock

slowly and, indeed, stop it altogether.

This ability to stop the clock is

exploited with the new power-down

modes IDLE and STANDBY, which

supplement the SLEEP, O  STOP, and

SYSTEM STOP modes of the original

‘180 (Figure 1). The STANDBY mode

(10 uA)   cuts power consumptiondramatically when compared to the

previous lowest power mode, SYSTEM 

STOP (17.5 mA),  making the ‘S 180 far

more suitable for battery-powered

applications.

A neat addition, but nobody is

going to rave about a new chip that

runs slower than ever. However, the

new static CMOS design offers another

benefit: the ‘S180 runs at up to 20

MHz, twice as fast as the regular ‘180

Longtime readers know I’m a bigbeliever in clock rate when boosting

CPU performance. Let others dabble

with the complexities of superscalar,

superpipeline, and various other super-

duper tricks. I’d rather just crank the

clock. So, I grabbed a ‘180 board and

headed for Zilog. Mission (Possible, I

hope): double the performance or bust!

NO FREE LUNCHIn my view, the performance of

general-purpose computers boils downto bus bandwidth. Yes, architecture,

compilers, and system design have an

impact, but in today’s competitive

environment-“religious wars” to the

contrary-gaining a significant

advantage in these areas is difficult.

However, the performance gains of a

faster clock come at a price: the need

for a corresponding faster memory.

Without it, any improvement will be

lost to the dreaded wait state.

In fact, boosting the CPU speedwithout facing up to memory bottle-

necks can lead to a somewhat patho-

logical decrease in performance. The

reduction happens when the “granular-

ity” of a wait state exceeds the

percentage speed-up in the clock.

This scenario is most easily

illustrated with RISCs  that call for l-

clock bus cycles. In this case, the

granularity of adding the first wait

state is 100% (i.e., a l-   to a 2-clock bus

cycle). Now, what happens if the clockis boosted without faster memory?

80    lssur  X29 October/November, 1992 The Computer Applications Journal

Page 69: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 69/88

Page 70: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 70/88

Page 71: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 71/88

Figure 3-A sample  HD64180  Z80180) circuit shows the critical timing paths in he  memory section.

Oops-oh y eah, it ’s i n regist er 

1FH. :

The bits I was setting in register

3FH  happened to have the interesting 

property of relocating the ‘180 on-chip

I/O addresses. Thus, after the OUT

instruction, the softyare was trying to

talk to I/O ports (including the console

port) that weren’t .there  anymore!

Changing the, OUT instruction

from 3PH to lPH, I skipped the

dramatics and hit’it.

I experienced’an apprehensive

moment when garbage appeared on the

screen, but it was only a reflex because

I’d already anticipated the doubling of

all the chip’s baud rates, timer con-

stants, and so forth.‘1   calmly switched

my terminal software from 9600 to

19200 baud and-voilh!

Exercising my test program, I

discovered the board worked pretty

much as expected [i.e., it would work

with a single memory wait state). I

tried zero wait states knowing that

chips are often faster than specified,

especially at room temperature, but

the EPROM couldn’t hack it.

8052 development svstemIntroducing the BD52, h complete 8052

development system providing allhardware and software needed to develop

8032/8052-based  products. A flexible

embedded controller with pseudo-EPROM

apabilities allows you to download and teat your code for easy software

 evelopment.  Memory and interface extensions enhance the BD52’s

apabilities. A PC-based windowed interface gives you complete control

sf  software and hardware functions. The powerful development tools

nclude  a fully featured assembler, C-compiler and debug monitor.

:oftware  and hardware are closely integrated for greater productivity at

n extremely competitive price.

Hardware

5032 microcontroller and EPROM loaded with debug monitor 

ability to address 64K of code space and 64K of data space

 pseudo-EPROM capacity: 30K with 32K SRAM (included)

RS232 serial interface, 11 parallel I/O lines

120V AC power supply; documentation and schematics

sockets for extensions: watchdog & power monitor, 4 A/D & 1 D/A

converters, 512 byte EEPROM for non-volatile data storage, 7-line relay

driver, 32K SRAM for up to 62K pseudo-EPROM capacity

Developmertt  Software

MICRO-C/52 ‘c’compiler  featuring 5 memory models and a standard

library with extensions to control BD52’s   hardware features

ASM52 cross assembler 

PC-hosted control/debug software with easy-to-use windowed interface

that provides access to all of the BD52’s   featuresOrder a BD52  at the inlwductory  price of 199.95* US from:

*plume   add 610.C0  for  liming

Dunfield   Development SystemsP.O. Box 31044, Nepean, Ont. Canada K2 B  ES6

Phone: 613-256-5620

T&e ItM

Take it easy on your cargo with a custom ‘Cabbage Casebuilt to the exact dimensions of pour equipment.Take it easy on your back

with our extension handle

and tilt wheels options.Take it easy on your 

wallet. Let Cabbage Cases

show you how easy it is to

save money on quality, custom-built roadcases:;that make

shipping and traveling with your valuable cargo, safer and

easier.Prices quoted over the phone.Call 8004884495 today.

  ‘ I

The Computer Applications Journal Issue X29 October/November, 1992 83

Page 72: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 72/88

I left Zilog happy that despite

human error (the cause of most

“computer problems”), I had suc-

ceeded. However, even as I was driving 

away, that one remaining wait state

started to gnaw at me. . . .

CHIPS IN THE FAST LANE

Zipping down the freeway, Ipondered the problem. Yes, state-of-

the-art memories exist, but where can

I get one? Those puppies aren’t exactly

a stock item at the local “Ye Old Chip

Shoppe.”

On autopilot, I registered the red

lights stacking up ahead and dove for

the off-ramp, planning to take one of

the secret short cuts that harried

Silicon Valley commuters seek out

like rats in a maze.

Though I am skeptical of psychicphenomenon, I wonder if it was just

coincidence that my roundabout path

took me right by WaferScale Integra-

tion!

Hey, didn’t I just get somethi ng in 

the mail from t hese fol ks about fast 

EPROM s! 

I must have made quite a sight,

first careening into their parking lot,

then dashing into the lobby waving my

‘180 board and demanding to speak to

the marketing manager. However, the

receptionist remained calm, called the

appropriate authorities [not the police),

and it wasn’t long before I was back on

the road, this time clutching some realgems, 55ns  EPROMs!

Back at my lab, I programmed a

55ns chip and plugged it in. I success-

fully got into high-speed mode and

started exercising my test program

first with three wait states, then two,

then one. Then for the big test: zero

wait states!

Crashola-darn!

WaferScale has 45-ns  EPROMs

(and they’ll even be offering 35-ns

soon). Therefore, I knew the simplestfix would be to continue plugging in

ever faster memories until it worked.

But now my curiosity was piqued (and

I knew I wouldn’t sleep until I snuffed

that wait state). Zilog said 60 ns

should do the trick, and I wondered

why it wasn’t working. Knowing I

didn’t have a lot of time for a full-

blown engineering exercise, I neverthe-

less reached for the schematic and data

sheets.

The relevant portion of the board

design is shown in Figure 3, while the

timing diagrams are shown in Figure 4.

Identifying the likely critical path

didn’t take me long. Highlighted inFigure 3, this path is described in

words as follows:

The CPU outputs addresses and

l MREQ (Memory REQuest)  at the

start of the cycle. The addresses are

guaranteed to be valid before l MREQ,

and furthermore l MREQ passes

through a ‘LS245. Thus, ‘MREQ  is the

last signal to reach the ‘LS138. After it

arrives, the ‘LS138 will drive the

EPROM l CS (Chip Select). After l CS

assertion, the EPROM will output datawithin the specified 55 ns, but the

circle isn’t completed until that data

passes through another ‘LS245 before

finally reaching the CPU.

Time for a little calculation. First

of all, at 18.432 MHz, the clock cycle

is roughly 55 ns, so a zero-wait bus

MOVE OVER INTELMICROMINT SOURCES

8OC52  CMOS BASIC CHIP

Micromint has a more efficient software-compatiblesuccessor to the power-hungry Intel 8052AH-BASIC

chip. The 80C52-BASIC chip  was designed for indus-trial use and operates beyond the limits of standardcommercial-grade chips. Micromint’s 80C52-BASIC

chip is guaranteed to operate flawlessly at DC to12 MHz over the entire industrial temperature range(-40°C to t85’C). Available in 40-pin DIP or PLCC

80C52-BASIC  chip $25.00

OEM 100~Qty.  Price $14.50

BASIC-52 Prog. manual $15.00

MICROMINT, INC.

 F

4 PARK ST., VERNON, CT 06066

0  TO ORDER CALL

+ 1~8004353355

See us at   the Embedded Systems Conferenc.+Booth   9198 4 Issue 129  October/November, 1992 The Computer Applications Journal

Page 73: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 73/88

ADDRESSES

 bM

cc

i3E

-16 MHz -20 MHz

Min. Max. Min. Max.

6 tMED1 Clock fail to /MREQ  fall delay 25 25 ns15   tDRS Data read setup time 15 10 ns

Fi gure 4- Usi ng the timing diagrams along with  typica/   discrete-gate delays (not shown), the minimum aaxss   lime

necessary for memory components can be calcuiafed.

  16(

In Circuit EmulatorsThe DrylCE Plus is a modular emulator 

designed so you can get maximumflexibility from your emulator purchase.The base unit contains all the hardwarenecessary to support pods containing

many of the most popular members of the8051 family of embedded control

microprocessors. Buy one base unit, andselect one or all of the pods you need todo the job at a much reduced cost. Youget the same great functionality found inour popular DrylCE 8031 emulator plus

real-time Execute-to-Breakpoint,Line-by-Line Assembler, and much more. And the price is (almost) unbelievable!

(Yes, it works with the Mac, too!)

Base Unit (w/W232  IF) -- 299 Avai labl e Pods : 149  each

8031/32,80C31/32,80C154,80C451,80(;535,8OC552/562,8OC652,8OC51  FA,

8751152, 87C51152.Call about 876751/752  support

16K Trace Buffer option: Avail. 2nd Qtr ‘92Standard 8031 DrylCE -- Still only 199

Enhanced 8031 DrylCE -- $269

The 8051SIM software package speedsthe development of 8051 family

programs by allowing execution anddebug without a target system. The8051 SlMulator   is a screen oriented,

menu command driven programdoubling as a great learning tool. 99.

8031SBC   A fast and inexpensive way toimplement an embedded controller.

8031/32  processor, 8+  parallel I/O, up to2 RS232 serial ports, +5  volt operation.The development board option allowssimple debugging of 8031151 family

programs. ggea

8OC552SBC  10 bit 8 ch. A/D, 2 PWM,1  RS232 & 2RS232/422/485  serial ports,sockets for 64k ROM, 64k RAM, +5 voltoperation; optional RT Clock w/  battery,2k EEPROM.Development   board version

available. Call for pricing!

( 619)566-1892

The Computer Applications Journal Issue 29  October/November, 1992 85

Page 74: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 74/88

Page 75: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 75/88

The

Middle

GroundNegotiating aKeyboardInterface

John Dybowski

0 irmware, themiddle ground

between hardware andsoftware, has the disposi-

tion at times to take on the attributesof both. That this type of code has the

capacity to perform tasks normallyassigned to hardware may explain whyits design often resembles a mecha-nism more so than the workingsusually associated with programming.Firmware tricks can impersonatemany hardware functions, but as usualyou must take into account thestrengths and limitations of themethods you choose.

SOFT HARDWARE

Generally speaking, either usingICs  dedicated to serving the desiredpurpose or emulating these functionsin firmware can achieve the peripheralfunctions required by an embeddedsystem. The choice is usually based onthe need to strike a balance amongoverall system necessities, complexity,and cost. As an example, you can use aUART to fulfill asynchronous serialcommunications or, alternatively, youcan take a firmware-only approach.

Furthermore, depending on systemrequirements, the firmware-basedapproach can perform as a dedicatedloop that basically shuts down allother operations and bangs the bitsusing embedded timing loops. You canrefine this approach by referencing thetiming to a timer interrupt whereother system functions can continueto be serviced as well. As usual, anychoice you make is relative, and thedemands of the system under consider-

ation dictate what’s appropriate andeffective.

A system that simply uploadscollected data to the host computerwhen in a dedicated dump mode hasno penalty regarding the suspension ofother system functions. This lack ofrestriction exists to perform thecommunications chores entirely infirmware using simple bit-banging.

When performing communica-tions on an intermittent basis with asystem that has to remain live,running the communications infirmware while off-loading the timingburden to a timer interrupt may beappropriate because some processingpower is available for other functions.Of course, if the system in questionmust be on-line in a networkedenvironment with heavy communica-tions traffic while performing its

routine functions, then keeping it on-line without the use of a hardwareUART makes no sense.

When considering functions suchas serial communications, the choiceof using a hardware or firmwareapproach is usually clear cut, based onthe prevailing needs. Some decisionsmay not be quite as apparent, andtaking the wrong approach can causesignificant problems down the road.Although much can be done using a

firmware-only approach, there comes apoint of diminishing return where alittle hardware can save you muchheartache.

One function that I’ve never feltcompelled to use a purely hardwareapproach on is keyboard scanning.Although special cases exist where astrictly hardware approach makes agreat deal of sense, I’ve had goodresults using firmware-based scanning,particularly because the process load is

extremely minuscule.Before I show you several differentarrangements for scanning a keyboard,I’ll familiarize you with the commonrequirements of a keyboard driver.

THE FUNCTIONS OF AKEYBOARD DRIVER

The basic functions of a keyboarddriver consist of doing a contact scan[checking the state of all the keycontacts), debouncing   a key closure,

implementing the keyboard style, andperforming the key code translation.

88 Issue X29 October/November, 1992 The Computer Applications Journal

Page 76: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 76/88

KEY Nf ER-KE~CWNl’ER

4

lncromlKEY-HIT

IrnOmOnlKEY_CCWTER

ContactScanning

to the user. A few examplesof this function are two-keyrollover, n-key rollover, andmultikey   lockout. Some ofthese styles are the result ofkeyboard operation stream-lining to accommodate theneeds of touch typists. My

intention is to show how todevelop a simple driversuitable for embeddedapplications that are mostoften served by simpleswitch-type or membrane

Sol   LAST-KEY.nokey   DEBO&ED.O

keyboards. For this applica-tion multikey   lockout is

I most appropriate. Multikeylockout refers to the

Sol   LAST KEY.KEY_NLf&ER w rejection of multiple

closures at the keypad and

the recognition of a singlekey hit as the only validc condition for processing.

Key ProcessingFor solid response and

I Iproper debounce  operation,

DEB ED.1

have the entire keyboard

I II I scanned once about every 20

ms either piecemeal or all atone time. My preference is

 just to go ahead and scan theentire keyboard, which isnot a problem because I

don’t do the actual scan

Debouncing   is the rejectionof the switch chatter thatusually accompanies a keyhit. It includes the properdeglitching of the occur-rence to prevent indicating afalse closure in the event oftransient noise pickup at the

interface.The keyboard style

describes the type of actionthat the keyboard presents

from an interrupt serviceroutine. You could do thescan from an interrupt, butif you weren’t careful youmight end up hogging the

ure l--The  gene keyboani  dtivw routine can be broken into 

 sections: en y, contact scanning, and processing.

system for perhaps 100 us ormore at a shot. If interruptlevel processing is desirable,

S far as the contact scan goes, it may then the piecemeal approach makesnsist of doing a row-column matrix more sense, but you will have toan using a variety of methods or maintain state information on wheremply reading the key switches ifey connect in a parallel fashion. you are in the scanning process, addingto the overhead load.

THE GENERIC KEYBOARDDRIVER

The idea behind the way I imple-ment key scanning consists of invok-ing a callable routine at 20-ms   inter-vals, which is usually referenced to aninterrupt-driven timebase. A minimalamount of state information must be

retained so the process can progress ina seemingly unbroken fashion becausethe operation is discontinuous. Fun-damentally, the routine checks all thekeys, then determines whether a validkey is available using local and globalvariables. On completion, an exit codeindicates if a key code is being re-turned to the caller.

Although uncomplicated enoughin principal to begin with, you canfurther simplify the keyboard scan

algorithm by breaking it up into threesections. As I’ll show, viewing theprocess thus allows adapting thegeneral concept for use with varioushardware schemes.

I describe the three components ofthe key-scanning procedure as theentry, the contact-scanning, and theprocessing sections. Additionally, youmust provide a separate initializationroutine to set up the global variables totheir default state on power up before

key scanning can begin.Local working storage is allocatedfor the elements called KEY- COUNTER,

KEY- NUMBER, and KEY_HI T. The entrycode simply consists of clearing KEY_ 

COUNTER and KEY- HI T tozero;   KEY_ NUMB E R may be left indeterminate.

The contact-scanning procedureconsists of a repetitive loop thatchecks the state of each key. You willbest understand the function of theloop from a quick definition of the

local variables: KEY- COUNTER, acounter that increments each time akey is checked; KEY _H IT, a counterthat is incremented each time a keyclosure is detected; and KEY- NUMBER, aregister to which the KEY- COUNTER iscopied when a key closure is detected.The loop terminates when KEY_ COUNTER reaches its terminal value,indicating all keys have been checked.

At the conclusion of the contact-scanning loop, control is passed to the

process code where a decision is madeas to whether a valid key was been

The Computer Applications Journal Issue 29  October/November, 1992 8 9

Page 77: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 77/88

Page 78: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 78/88

Flgun 3-When  pal lines are scarce, a iMe  morehardware dnp  the inlatface down to just three   lines. A

4-M axmfer  is  used b cyde hrough he mvs and

cdumns  aubmatkal .

criminate at least two simultaneouskey closures at a time, although thealgorithm does not make use of thiscapability. In any case, this arrange-ment prevents the jamming of two

outputs together if someone pressesthe wrong two keys at the same time.

The benefit of this organization isthe reduction in the number of portpins required for the interface. Forexample, if you scan 16 keys, fouroutputs and four inputs will beconsumed. To proceed, turn on a

single-drive line and then read thecolumns. Repeat by driving each rowin sequence. Figure 2 shows how thisprocess is done.

Port pins are often in short supply.Similarly, a congested PCB layout maymean you need to conserve linesbecause the keyboard is on anothercard or even located remotely to thecontroller. With a little extra hard-ware, you can get by using just threeport pins: two outputs and one input.As shown in Figure 3, a decoder (inthis case using active-high output) anda multiplexer operate under control ofa binary counter to perform thefunctions done previously in firmware.Here, the hardware performs thesequencing. The counter’s reset pininitially resets the matrix, which is

C h a r t Y o u r C o u r se

T o I m p r o v ed

R e a l - T i m e D e si g n ,

P r o c es so r S e l e c t i o n ,

 ncl   S y s t e m rototyping

Find the shortest route through your next embedded

system project with ViewTask from US Software.

With ViewTask ,   you can design an operating task set

on your PC-complete with timing parameters and

your cl~oirc  ofprocessor-to   run a series of “what if 

scenarios. Then use your monitor to evaluate worst-

case timings and verify task set viability-you can

even generate executable tasking code all   for only

$495. Chart a course to success with ViewTask

800-358-7087 USA503641.8446   F A X 5 0 3 - 6 4 4 2 4 1 3

1 4 2 1 5 N W Science   Park Orwe

Port land, OR 97229

See us  at the Embedded Systems Conferenc~ooth  6736

The Computer Applications Journal Issue129 Octob er/November, 1992 9 1

Page 79: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 79/88

Page 80: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 80/88

duce current usage and run it off the

AM backup power. The active key

n be used as a power button, provid-

g the stimulus to the power control

cuitry to return the system to a

wered state. Just make sure you

operly isolate the data line so as not

 the unpowered key input

rt pin.The nice thing about this three-

re interface is, in principal, it can be

tended to service fairly large key-

ards. (I’ve gone as high as a hundredys.) You may have to use larger

coder and multiplexer chips, but as

as the firmware is concerned, all

u do is increase the terminal value

r KEY- COUNT in the contact scan

p and provide a larger lookup table.

At the other extreme, you may be

ed with interfacing a keyboard thats connections to each contact with a

ngle common. The electrical inter-

e of course is trivial; you just bring 

the keys in on individual port pins.

u’re all hooked up, and at first a

y-scanning algorithm may seem

necessary, but you’re still faced

with performing the fundamental

keyboard functions. Figure 4 shows

that the basic algorithm still holds.

The algorithm I’ve presented is

intentionally rudimentary, keeping 

with the concept of the soft machine I

alluded to earlier. If you require

additional functionality, consider

adding a layer of code between theapplication and driver levels rather

than tweaking the driver itself. For

instance, if you want to remap the

keys in response to the changing needs

of the application, place these func-

tions in this stub code.

You can place shift functions in

the stub code also, but with the driver

I’ve described, these would have the

shift key operate in an alternating 

fashion rather than in the conven-

tional sense, because the driver onlyreturns single key hits. Actually, I find

this action desirable usually for the

types of embedded instruments that

have small front-panel keyboards,

which aren’t all that easy to use

anyway. If you want a traditional shift

key arrangement, you can run the shift

key outside the matrix.. . or I suppose

you can tweak the driver.

I’ll let you in on a little secret.

Over the years, I’ve developed equip-

ment that’s run under control of

various processors and controllers, and

interfaced to dozens of strange and

wonderful keyboards, but I’ve only had

the need to develop one keyboarddriver algorithm. When developing soft

hardware, always make sure you

understand the magnitude of the task

and the needs of the system, make the

right decisions, and work smart. Being 

wasteful is foolish; there is no virtue

in drudgery.q

John Dy bow ski has been inv olv ed in 

the design and manufacture of 

hardware and soft w are for i ndustr ial 

data coll ect ion and communications equipment.

428 Very Useful429 Moderately Useful430 Not Useful

Affordable state-of-the-art in-circuit emulation for 280   family

processors. Increase your productivity with features like:

l Symbolic and C Source Level Debugging

l Pull-Down Menus and Command Line interface

l Complete Context-Sensitive Help

l Real Time Emulation up to 12 MHz

l Serial Interface works on any PC, even on laptops.

2 1 8 0

Z84C13

Z84C15

ss=

HD64180

HD647180

TMP84C015

Satisfaction guaranteed with a risk free 15 day trial. Rentals

also available. Call or w ri te today for more in form at ion/ 

  Memory mapped variables

n In-line assembly languageoption

n Compile time switch to select 

805 l 803  1 or 8052 8032  CPUs

  Compatible with any RAM 

or ROM memory mapping 

n Runs up to 50 times faster than

the MCS BASIC-52 interpreter.

n Includes Binary Technology’s

SXA51 cross-assembler 

  hex file manip util

w  Extensive documentation

n Tutorial included w Runs on IBM-PC/XT or 

compatibile

  Compatible with all 8051 variants

w BXC51 295.

508-369-9556FAX 508-369-9549

qBinarv Technoloav, Inc.P.O. Box 541 l Carlisle, MA 01741

WJ

8169

The Computer Applications Journal Issue 29  October/November, 1992 93

168

Page 81: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 81/88

he Circuit Cellar BBS

 bps, 24 hours/7 days a week03) 87%1988-Four  incoming linesernon, Connecticut

’re going to cover  a few new topics in this installment of  The first thread deals with sensing engine knock in a

ng motorcycle. Next,  we move into high-speed data collection.ally, we’// make some noise-white noise, that is.

m: KELLY DRESSER To: ALL USERSHas anyone out there worked with pressure sensing in

ernal combustion engines? What I’m looking for is

entially a poor man’s Kistler. I don’t need absolute

uracy as much as low cost and ease of use. I want to

nse the pressure peak and have enough frequency re-

onse to detect uncontrolled combustion [“knock”) in a

gle-cylinder four-stroke 6OOcc  racing motorcycle engine.

air cooled, which adds even more of a heat problem to

already messy sensing environment. Has anyone used

y unconventional or clever techniques to measure [or

er] the pressure profile [with respect to crank angle]?

m: MIKE RAPP To: KELLY DRESSERIf you -really_ need to get cylinder pressure data then I

nk there are no cheap and dirty solutions. In your

plication, you might be able to avoid the instrumented

ark plug by drilling the head and directly mounting a

essure sensor [no need to worry about water jackets]. Your

ta sampling and storage will be nontrivial (1” rotational

olution at 6000 RPM will need 36,000 samples/set.).

On the other hand, if what you actually need to do is

tect detonation (knock), then there is a much simpler and

eaper approach. All you need to do is to detect the audio

quency sound (pinging) produced by the detonation. It’s

uch more commonly heard in a car than on a bike, but

ll be produced by any engine that is driven into detona-

n.

The standard approach is to mount a vibration sensor

or near the head and use the filtered output to indicate

tonation. This is already being done in production of

tain cars and trucks (particularly with turbo charging).

e frequency of interest is somewhere around 6 kHz  in the

tomotive application. Your aluminum air-cooled engine

ght be different. You can find out by mounting up ansor and smacking the head area with a hammer. The

predominant frequency produced by the sensor should be

usable for detecting detonation. (Hammering on the engine

is how the automotive sensors are tested!)

Best source for a sensor might be the parts department

at a GM dealer. This technique is even used in laboratory

(dyno) testing since the vibration sensor will detect detona-

tion well before even the best operator can hear it.

Msg :58492

From: KELLY DRESSER To: MIKE RAPPThank you, Mike, for your reply. You confirm my

general hunches about how I’m going to get the info I want.

I’m still hoping for some unorthodox manner in which to

skin this cat. Already, with a water-cooled two-stroke I’ve

had much better than beginner’s luck at sensing the

cylinder pressure by epoxying the sounding disc from a

piezo squeaker on a flat spot next to the spark plug. Got an

incredibly clean and strong signal. The piezo even survived

the temperature, but did display a whopping DC signal that

varied with the rise and fall of the head temperature.

However, an air-cooled four-stroke is a lot hotter, a lot

noisier (mechanically), and there’s no place to stick the

thingumy.

Mr. Kistler makes good stuff, but it’s out of reach in

cost. Maybe someone has found another rugged sensor that

will work in this application. Your suggestion about using a

resonating piezo sensor from an automobile engine is a

technique I want to try last, since I really do want a pres-

sure trace (for some combustion phasing fiddles) plus be

able to detect knock, and doing both with the same sensor

still attracts me.

I’ve been though all the recent SAE papers, but without

anything looking really good, except maybe an under-the-

spark plug washer (piezo again) that Nissan (I think] has

used in the past. Any experience by anyone out there with

such a sensor?

As far as having a fire hydrant of data pointed at me,

I’m not yet worried-some combination of digital and

analog techniques can minimize that. In any case, these

bikes are running on an inertial dyno that a friend and I

constructed (it’s just like Dynojet’s) and there’s a PC

already in the vicinity ready to swallow more data.

I’ll keep on plugging, looking for an elegant and/orcheap (especially) solution to this problem.

The Computer Applications Journal Issue 29 Octob er/November, 1992   95

Page 82: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 82/88

Page 83: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 83/88

use repetitive sampling) although I now must use ECL allthe way till the DSP accesses the data (I hoped to leave thehigh frequencies on the other side of the ADC).  Well, if

anyone knows who I can contact about high-speed RAM,drop me a line, any help received is always greatly appreci-ated, including that already received.

MS@:59491From: JOE PIERSON To: TERRY NORRIS

I too am working on a high-speed data acquisitionsystem (I am using the Analog Devices AD9038 300.MHZ

ADC) and have the following comments/suggestionsconcerning your problems:

1) Fast ECL/CMOS/BiCMOS  memories can be obtainedfrom Cypress Semiconductor, IDT, Mosel, and Motorola.

2) You can latch the data coming out of the ADC witha ECL latch and then use an ECL-to-TTL converter so thateverything after the converter is TTL/CMOS   logic (inter-leave the slower CMOS memory to achieve the desiredsampling rate). You will find that CMOS memory is muchcheaper if you require deep memory.

3) If you only need 100 MHZ, consider using the

Analog Devices AD9058.  It has two matched 8-bit 50-MHZ

ADCs  on one chip with TTL   outputs. Simply send youranalog input into both of the ADCs   and clock them out of

phase, you will have your 100~MHZ  system without anyECL logic. Cypress has CMOS memories that will storedata at 50 MHz so you won’t have to mess with interleay-

ing. The AD9058 is about $55 in 100s.

4) If you don’t want to bother with repetitive sampling,you might want to check out some of Sony’s ADCs.  Theymake some very fast 8-bit ADCs  ($300 will get you a 500-

MHz ADC).

5) You mentioned that you want to measure 50-MHz

signals; are these periodic or one-time events? If they areperiodic then don’t bother using the high-speed ADCs;  theywon’t buy you anything. HP uses 20-MHz  ADCs  in their

20-GHz   ‘scopes. Just remember to put a sample-and-hold infront of the ADC since most of the ADCs  in the 2OMHz

range have lousy full-power bandwidth.

Msg :59549

From: TERRY NORRIS To: JOE PIERSONYou have closed the link on a difficult path for me. I

98H71

laws   29 OctobedNovembsr 1992 The Computer Applications  JOUI

Are you looking for a 6%~ or 386/486 ANSI Ccross compiler for DOS OR UNIX? Is com-

 plete source code to your compiler important toyou? How about a complete Standard C libraryimplementation, including floating point emula-tion?

Hundred Acre Consulting is now offering GNU C sup- port packages in several cross compiler confignrations.Each Package includes the GNU ANSI C compiler fromthe Free Software Foundation, a complete Standard C li-

brary with hooks for your own file system implementa-tion, several support utilities, and one year of support atno additional charge. Platforms supported includeMS/DOS,  Sun 3 and Sun 4 with SunOS 4.1, and Interac-tive or SC0  UNIX. Call today for more information!

  GNU Support Package: $495

Hundred Acre Consulting1260 Terminal Way Suite 26, Rena.  NV 89662

Phone: +l -702-329-9333  Fax: +l -702-329-9666 ““iI:  infoOpooh.com

#172

Page 84: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 84/88

Page 85: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 85/88

Page 86: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 86/88

Page 87: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 87/88

Page 88: Circuit.cellar.029.Oct Nov.1992

8/13/2019 Circuit.cellar.029.Oct Nov.1992

http://slidepdf.com/reader/full/circuitcellar029oct-nov1992 88/88

INK Let

0Me Tell You About Yourself 

influence.

ive years ago when we started the Computer Applications Journal,   had a specific idea anddirection in mind. Much like the projects that had been presenting for 10 years in BME,  the

magazine I envisioned would appeal to a select group of technically motivated individuals who

appreciated the fundamental application of a computer without speculating that it involved some mystical

Five years is a long time, however, and without constant reassessment, it’s easy to vary from the defined course or 

indeed follow one too closely. In the beginning, when I had no other information, I merely defined the editorial focus of C

tobe what I’d like to read.

While that approach might work for a limited time, I would be overly egocentric to assume that my interests always

satisfy the majority. In fact, I can already sense a narrower focus of my technical interests. Perhaps converting from straighttechnical responsibility to more managerial duties has dulled the wit somewhat.

Instead of relying solely on Ken’s or my personal interests to continue to stimulate the editorial direction of CA/, we

instead resort to asking you that question periidically.  On a regular basis, we send 4-6~page  questionnaires, called

“Editorial Surveys,” to randomly selected groups of readers. The results of these surveys help us fine-tune our editorial

direction as well as identify emerging interests. These surveys have always had an astonishingly high rate of return, and we

are continually encouraged by the comments we receive.

Just in case you don’t know who you are, let me tell you. The CAJ reader is a “doer” with instinctive entrepreneurial

talents. Either as an individual consultant or part of a large company project group, the CA,/ reader views his or her success

as providing real solutions to real-world problems.

The latest survey results show that the average CAJ reader is both technical and professional. About 74% of CAI

readers say they are involved with microcontroller applications in their work, but with two-thirds of the audience evenly

divided between ‘1-50”  and ‘lO,OOO ’  employee companies (nice inverted bell curve distribution), I’d conclude that they

seek out CAlas a pure technical resource. The fact that 92% save every issue supports this conclusion.

One fact, unchanged in five years, is that readers prioritized interfacing, computer control, and home automation and

security as their dominant interests. There is also a broad range of secondary curiosities but these seem to share equal

preference. The truly technical community gains as much relevant resource information from an article on geopositioning as

it does on analog sensor interfacing. No effete snobs around here.

One remarkable statistic, probably attributable to a professional audience with money, is that the average reader has