78
8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990 http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 1/78

Circuit.cellar.012.Dec.1989 Jan.1990

Embed Size (px)

Citation preview

Page 1: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 1/78

Page 2: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 2/78

EDITOR’SINK 

First Things First Cu rtis Fran klin , Jr 

F irst things first: The cover is different. Part ofthe reason is aesthetic-after a couple of years of look-ing at the same logo we felt that it was time for a freshlook for the cover. More than the matter of looks,however, was trying to let folks know exactly what

CIRCUIT CELLAR INK is all about. We wanted to make itplain to even the most casual observer that this is TheComputer Applications Journal. I think the new logogoes a long way toward making that clear.

Now, I want to make something clear: we haven’tchanged the parts of the magazine that make it uniquelyCIRCUIT CELLAR INK. You’ll still find projects, tutorials,technology, and techniques in our pages. We still stresspractical, hands-on experience. We are still making thismagazine for you, our readers, and for no one else. (OK,maybe for us, too, but we read the thing as well as writeit.1

IT’S BEEN ONE OF THOSE YEARS...

In the first issue of C IRCUIT CELLAR INK there was aproject on building a home satellite weather center. Itcontinued through our first seven issues, and was sup-posed to go for several more. As with many projects inthis world, “circumstances beyond our control” in-truded. We finally decided that there would be a singlewrap-up article in this issue. More circumstances, andeven that didn’t work out. I regret to say that there willnot be a concluding article. The author, Mark Voorhees,

would like to continue supporting those readers whoare now caught in the middle of this project. If you needmore information write to him directly at:

Mark VoorheesP.O. Box 27476

Phoenix, AZ 85061-7476

ence   all of our classic art forms (graphic arts, music,theater, and dance). I’ve been watching the confluenceof computer and art for a number of years, and I’m evermore impressed at the results from both the artistic andcomputer sides of the issue.

On the artistic side, a welcome maturity is develop-ing in the way many artists deal with the computer. Re-member the early days of microcomputers? You wouldget the computer kit, build the machine, and bore yourfamily and friends by making them watch the front-panel LEDs  blink as the computer added a series of num-bers. Eventually, the computer had to do more thansimply be a computer: it had to do something useful toearn its keep. A similar change in attitudes is movingcomputer art. Attitudes about computers have pro-gressed to the the point where computers are moreimportant as tools than as symbols.

The developments on the computer side are, if any-thing, more impressive. Where “computer art” wasonce accorded all the serious respect owed a dot-matrixrendition of Snoopy, the techniquesexplored by graphicartists are now used by imaging experts in many scien-tific and technical fields. Computer music which onceresembled nothing so much as spinning a radio tuningdial has now broadened to include support for moretraditional forms of expression (as well as experimentalpieces). Through it all, art has become just another fieldin which computers are used, and the new uses ofcomputers explored.

Curtis Franklin, Jr.

ON WITH THE ART

It’s hard to get any two artists to agree on anything.That said, I choose to believe that many artists wouldagree that computers have the potential to greatly influ-

Dec em be r ‘BP/Janua ry 90 1

Page 3: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 3/78

FOUNDER/EDITORIAL DIRECTORSteve Cia rc ia 

PUBLISHERDaniel Rodrigues 

EDITOR-in-CHIEFCurtis Franklin, Jr.

ASSOCIATEPUBLISHERJohn Haye s 

ENGINEERING STAFFKen Da vid son Jeff BachiochiEdw a rd Nisle y 

CONTRIBUTINGEDITORSThom a s C a ntrell 

Jac k G a nssle 

CONSULTINGEDITORSMa rk Dahm ke La rry Loe b 

CIRCULATIONCOORDINATORRose Manse l la

CIRCULATIONCONSULTANT

Gregory Spitzfaden 

ART& PRODUCTIONDIRECTORTricia  Dzied zinski 

PRODUCTIONARTIST/ILLUSTRATORLisa Fe rry 

BUSINESSMANAGERJeannette Walters 

STAFF RESEARCHERS

NortheastEric A lbe rt Wil liam Cure w Richard Sawyer Robert Stek

Midwest J on E/son

Tim McDonou g h

West CoastFrank KuechmannMark Voorhees 

Cover Illustrationby Robert Tinney

CIRCUIT CELLAR;@;aim

THE COMPUTERAPPLICATIONS

 J OURNAL

Image Synthesis: A TutorialTools for Drawing a New Universeby ChrisCiarcia

 The day has long since

passed when “computerart’ meant outlining a fa-mous beagle on a dot-matrix printer.  Today’scomputer artists can ac-curately render a stan-dard living room, or anunseen world. This high-level tutorial introducesray-tracing, shadowing,textures, and reflections,as well as other concepts

important for creating im-ages from digital data.

Editor’s INK First Things First   1

b y Cur t is Fran klin , Jr.

Reader’s INK-Lef-fers to the Editor    5

NEW Product News 8

Visible INK- Let te rs to the INK Resea rc h Sta ff    12 

Firmware FurnaceSimulated RealitySimula ting Syste m s fo r 805 I Deb ugg ing 

53

b y Ed Nisley

From the BenchGentlemen, Start Your Engines 62b y Jeff Bac hioc hi 

Advertiser’s Index 73

2 C IRCUIT CELLAR INK 

Page 4: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 4/78

Page 5: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 5/78

letters to the Editor

READER’SINK 

A BEllER WAY TO BOOT

Recently I received CIRCUU  CELLAR INK’s First Year interrupt routine, they have a direct jump to the booteprint. It contains many invaluable ideas which inspire routine which bypasses the POST. A reset routine which

me in my own designs. Your publication is almost error begins at FFFF:OOOO simply overwrites the contents of theree but I found something that-in my opinion-should   0040:0072 address, so for these computers, WARMBOOTe corrected.

need only contain one instruction:In CIRCUIT CELLAR INK 6, in Visible  INK,  you describedhe program WARMBOOT.COM. I have four commentsoncerning this program:

jmp ffff:OOOO

or a jump to a specific BIOS location. In other words, for anill-behaved BIOS, use an ill-behaved WARMBOOT.) I cannot understand why you use the ES seg-

ment register to modify BIOS variables-I thinkusing DS is more straightforward.

2)  You don’t have to end the program with RET-it will never be executed.

3)  You don’t have to write 112h bytes to disk-12his enough.

4)Whenyouenterthe”u  100

llZ<enter>“com-mand, you can also see an instruction whichbegins at xxxx:O112 (in this case, its content isundetermined).

Here is my version of WARMBOOT.COM. It isesigned to be entered using DEBUG.

C>debug warxnboot.comFile not found

-alOOXXXX:OlOO  mov ax,40

XXXX:O103  mov ds,axXXXX:O105 mov word ptr [72],1234

XXXX:OlOB jmp ffff:OOOO

XxXx  : 0 110 <enter>- r c xcx 0000:lO w

Writing 0010 bytes

Isn’t it better?Some PC/XT-compatible computers ignore the con-

ents of the 0040:0072  BIOS variable. In the keyboard

Krzysztof WysockiWarsaw, Poland

Thanks forsendingus yoursolution to theproblem of warmboots under MS-DOS. One of the best parts of putting together 

a magazine like C  IRCUIT CELLAR INK is the chance to learn fromyour readers. Editor 

WIRE-WRAP, CONTINUED

In CIRCUIT CELLAR INK 9,there  was a group of mes-

sagesconcemingwire-wrapconstructionin ConnecTime.  Ihave an additional suggestion for building projects usingwire-wrap.

Use a board that provides Vcc and GND foil buses on0.3” centers between IC socket pin rows. This allows Vccand GND wires to be wrapped to pins and lap-soldered tothe buses, minimizing the ground jump typical of high-performance CMOS chips.

The dead-bug method is not dead. In my technique,the circuit is built on a copper-clad sheet. Chips are super-glued, pins up, to the main foil (GND).  Vcc islands are cutin the foil to match up with the Vcc pins. Vcc and GND pinsare bent over to match up with the foil and islands, andsoldered into place. Bypass capacitors are installed asrequired. The simplest $2.95 wire-wrap tool is used tointerconnect IC pins with 30 wire-wrap wire. I find that

December ‘BP/ Janua ry ‘90    5

Page 6: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 6/78

Page 7: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 7/78

Turbo XT on a 4” by 5” BoardThe 8810 board from Tempustech is the equivalent of an IBM-

compatible Turbo XT motherboard on a 4.2” by 5.4” board. The board,which fits an industry-standard &bit PC bus passive backplane, offersthe capability of an embedded computer in a space as small as 180cubic inches (5”~  6”~  6”),  about 1 /lOth  the size of an IBM PC/XT.

Applications for the U.S.-designed and manufactured boardinclude a diskless workstation, an embedded controller for industrialapplications, as well as the CPU board in a PC. The Clayer  board usessurface mount technology, features dual-speed (10 MHz and 4.77MHz) operation, up to 2 megabytes of SIMM DRAM, NEC V20-10processor, optional 8087 coprocessor, and an auto-configuration BIOSwith no switches to set. The board is compatible with MSDOS 2.0 to3.x,  thousands of industry-standard PC bus accessories, and indudesan Expanded Memory Manager (LIM  V4.0).

A plug-in CPU offers advantages in serviceability and upgradecapability. A defective unit can be repaired in minutes by replacing

only one plug-in board. The passive backplane eliminates the needfor a motherboard and provides an upgrade path.

The size of the 8810 gives the designer a great deal of flexibility.Since most 8-bit accessory functions are available on half-size boards,a complete XT clone with 2 megabytes of DRAM, a 3.5-inch floppy

disk, a 3cmegabyte hard drive, a video card, an I/O card, and apower supply could be assembled in a case about 5”~7”x9”.

The 8810 board costs $160 (quantity 10)   without memory.Tempustech also offers g-bit  and l&bit  passive backplanes. IBM PC/AT and “386 board” equivalents are also available.

Tempustech, Inc.295 Airport Road

Naples, FL 33942

(8 13) 643-2424

C Users’ Group Library Directory

Volume II of the C Users’Group   Directory of User-SupportedC Source Code has been released by R&D Publications Inc. TheDirectory contains fileby-file descriptions of the code in the C Users’

Group Library, the world’s largest repository of public domain anduser-supported C source code. Volume II of the directory describesLibrary disk volumes 200-249,  and includes a comprehensive indexplus detailed articles describing some of the most significant volumesin the library. The 208-page paperback was edited by Robert Wardand Kenji Hino.

a C IRCUIT CELLAR INK 

Some of the programs cataloged in Volume II of the Directoryinclude a 68000 C compiler, an inference engine and rule-basedcompiler, portable utilities, MS-DOS implementations of some popu-lar UNIX utilities, Small C utilities, and several graphics packages.

The C Users’ Group is a service of R&D Publications Inc., and

facilitates the exchange of code and information among C program-mers. Unlike machine-centered users groups, the Group focuses onsource code useful to experienced programmers rather than tested,end-user applications. Among other services, the Group maintains alibrary of over 180 volumes of public domain C source code.

Volume I of the Directory, a separate publication, contains file-

by-file descriptions and an index covering disk volumes 100-199, thefirst 99 Library volumes. Both Volumes I and II are available from TheC Users’ Group for $10 each.

The C Users’ Group2120 W. 25th St., Ste. BLawrence, KS 66047(913) 841-1631

Servo System forPC Control of Machinery

Owners of hand-

operated machinery cannow adapt their tools to acomputer-based automa-tion system with Retro-Fit-Kit from Computer Contin-uum. A two-axis kit

consists of a dual controller, dualpower amplifier, two DC servomotors with incrementalencoders (2ooO  counts/rev), an

interface card for the IBM PC,CNC/teaching software, and allcables. One cable is speciallyshielded for use in electricallynoisy industrial environments.The controller and amplifiermodules are contained instackable plastic boxes andinterface to the PC through a

ribbon cable bus called LAB 40(Local Applications Bus). Up toeight analog, I/O, and relay

modules may interface to thisbus with up to 40 feet of ribboncable.

Each power amplifierdelivers continuous currents of10 amps at up to 90 volts, withpeak currents of 50 amps for fastmotor stops.

Protection is provided forover-current, over-voltage,under-voltage, short circuit, and

over-temperature. Optional heatsinks, fans, and power upgrades,using larger or parallelMOSFETs are available. Signals

between the controller and

power amplifier are opticallyisolated.

MotionSoft, the included

automation software, supportsup to four axes of synchronizedmotion with linear and circularinterpolation on either pair ofaxes. Parameter set-up andmotor-testing menus allowadjustment for a wide variety ofmotor/encoder/gearboxes foreach axis. After limit switch ini-tialization, CNC files may beused from a standard CADsystem. Motor positions can betaught with PC cursor keys as

 jog keys or by turning the motorshaft and recording the positionsfrom its attached encoder.

Velocities between eachpoint are settable, and themotion playback can be eithercontinuous or trapezoidalprofile. Trajectories andautomation steps are stored inCNC code format. The packageincludes routines in C andQuickBASIC for custom

development.A two-axis Retro-Fit-Kit

starts at $2000 each. System re-quirements include an IBM-

compatible PC, XT, or AT with

Page 8: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 8/78

 of RAM and eitherHercules or CGA graphics. An

0x87 math coprocessor chip isequired.

Computer Continuun75 Southgate Avenue

Daly City, CA 940 15415) 755-1978

Computer-BasedHDTV Framestore

Real-time storage, retrieval,nd manipulation of high-efinition images for the

Macintosh II computer isossible with Restore, a com-

puter-based high definition dual-

rame store from Rebo Researcha subsidiary of Rebo High-

Definition Studio Inc.). Using theMac II as its host/controller, theRestore chassis plugs into theMac’s NuBus slot and allows

ccess to all Macintosh masstorage devices and third-partyoftware. Captured images cane viewed on a high-definition

monitor or displayed on the Macolor screen.

Restore stores images inone of two buffers. The two

rames can be captured live fromhe camera source or from high-

definition videodisc or tape.Either the live video or thebuffer’s contents can be viewed.Restore can reposition the imagerom buffer A or B on the screen.

A live image may be reposi-ioned and stored in its altered

orm. The product features alsonclude 1920x1035 pixels, 24bit

olor, and color correction.

Images generated entirelywithin the computer can be

displayed or recorded in thehigh-definition format andprocessed through Restore. Anyorm of communicationupported by the Mac may be

utilized, including serial, or medium exchange

optical disc and tape). Imageranslation software is availablehrough Rebo Research.

Rebo Research, Inc.530 West 25th StreetNew York, NY 10001(212) 627-9083(415) 755-1978

PC-Compatible STD Bus Module

The CPU-XT module from Computer Dynamics is the first STDBus module to offer 100% PC/XT compatibility.  It incorporates an8088 or NEC V20  microprocessor, memory, and speaker andkeyboard interfaces. In addition, the CPU-XT includes: interfaces tofloppy and hard disk drives; monochrome/CGA/LCD display adapt-ers; a watchdog timer; battery-backed clock/calendar; 128K ofEPROM; up to 640K of RAM; two serial ports; and a printer port. Theunit is an STD Bus module, measuring 6.5” x 4.5” x 1’: and featureslow power consumption so it can easily be placed into embedded sys-tems. It is also keyboard switchable to operate at a 9.54MHz clockspeed.

The on-board IDE hard disk controller accommodates up to twoWinchester drives and makes possible an XT-compatible hard diskinterface. The CPU-XT can be used in disk- or ROM-based environ-ments, and its bidirectional printer port makes the module compat-ible with security keys. It directly addresses all STD Bus I/O and upto 64K of memory on the STD Bus.

The CPU-XT is $995 in single quantities.

Computer Dynamics107 S. Main StreetGreer, SC 29650(803) 877-8700

Transceiver LinksPortable Systems toPCS

Linking hand-heldequipment to personal comput-ers without consuming batteryenergy is possible with theDallas Semiconductor DS1275Line-Powered Transceiver. TheDS1275, a low-power CMOSdevice, has a unique circuit thatsteals current from the host com-puter’s RS232  signal when thatsignal is in a negative state. Sincemost serial communication portsremain in a negative state stati-cally, battery current is reducedby an order of magnitude.

During an actual communi-cations session, the DS1275’s

transmitter will use systempower (5-12 volts) for positivetransitions while still employingthe receive signal for negativetransitions. When the system isin the static state, with no databeing passed, the DS1275 drawsno battery current at all. Thispermits the portable device to gointo a power sleep mode untilactivity on the RS232  port issensed by the transceiver.

The B-pin DIP or surface-mount package is compatiblewith RS232 signals and operatesover a simple 3-wire  cable.Applications include remotesensors, portable instruments,hand-held bar code readers, or

any portable device that needs tosend information to a PC.

The DS1275 costs $1.73 in5000-piece  quantities.

Dallas Semiconductor4350Beltwoad  ParkwayDallas, TX 75244(214) 450-0400

Decembe r ‘ 89/January  ‘9 0  9 

Page 9: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 9/78

 AHhl’RODUCTNEWSNE~RODUCTNEWS

Multiline Voice

CommunicationsBoard

Integration of a PC/XT/AT/386 computer with CentralOffice, Centrex, and/or PBXlines is achieved with thePowerline II board from TalkingTechnology Inc. Applicationsinclude voice messaging, callprocessing, audiotex, telemarket-ing, order processing, calldistribution, PBX integration,auto dialing. and alarm systems.

Powerline II supports high-fidelity digital recording andplayback with or withoutcompression. Five software-controlled compression ratesranging from 14 to 56 kbik/

second give flexible control oversound quality and data storagerates.

Two on-board microprocessors control the functions ofPowerline II. An Intel 8098handles data compression anddecompression, and an Intel 8032

communicates directly with the8098  and handles housekeepingfunctions. The 8098 has a built-inl&bit  A/D converter, sampleand hold, and multiplexer.During voice recording, the 8098samples the filtered audio input,compresses the data through theuse of a proprietary algorithm,and sends it to the 8032.  Duringplayback, the 8098 accepts

encoded data from the 8(132  anddecodes it, making it available

for playback into the telephoneline, local telephone, and/or an

external speaker.

The Powerline II hardwareinterfaces with the host com-puter through dual-ported staticRAM, and all communications ischanneled through this memory.A variety of jacks on the boardprovides interface to telephonelines, PBX systems, audio inputand output, and digital externaldevices. Powerline II is priced at$599.

The Commando Develop-ers’ Package provides all of thetools necessary to custom tailorinbound and outbound voiceapplications supporting as manyas 16 lines (eight Powerline IIcards). Commando includes afunction library which supportsconcurrent voice messaging andcall processing applications. TheCommando kit includes a soft-ware applications interface forthe MS-DOS environment, agraphics-based installation

program for Powerline II cards, amicrophone for high-qualityrecording, and a speaker.Commando is priced at a one-time fee of $139.

Talking Technology, Inc.4383 Piedmont AvenueOakland, CA 94611 415 652-9600

ROMable Disk Operating System

A new ROM-resident or

disk-based operating system for

embedded systems using the

Intel 80x86 family and the NECV20 through V50  series has beenannounced by Datalight. ROM-

DOS is fully compatible withMSDOS 2.x and will boot on astandard PC, operate fromwithin ROM, and run MSDOSexecutable programs such asLotus 123, Turbo-C, andMicrosoft Word.

The ROM-DOS operating

system enables a disklessembedded system to run an MSDOS application upon power-

up. Any MS-DOS service can beaccessed, provided the necessaryhardware is available. ROM-

DOS supports memory manage-ment, a standard file system,time functions, and DOS charac-ter and block device drivers. Adevice driver may be installed atlink time or load time (usingCONFIG.SYS). A device driverinstalled at link time becomes

part of the operating systemkernel and is burned into ROMwith ROM-DOS.

A standard setup places the

code for ROM-DOS and Mini-BIOS in the top 32K of ROM, andthe user application (EXE file)

and associated files in ROM on aROM-disk. The ROM-disk filescan be placed anywhere abovesystem RAM, and by designatingthe ROM-disk as the “A” drive,ROM-DOS will search it for theinitializing program upon boot-ing.

The booting process startswhen power is applied to thesystem. The BIOS initializes thehardware and transfers controlto ROM-DOS which, after itsown initialization, loads and

runs the user application. Thisapplication remains operationaluntil power down.

The ROM-DOS kernel uses29K bytes and resides in andexecutes out of ROM. The Mlni-

BIOS uses less than 3K bytes, soit will easily fit into a 32K ROMpackage. A minimum RAMspace of 5K bytes is needed, but

a command processor(COMMAND.COM)  is notrequired.

A Developer’s Kit providesthe tools, modules, source code,

and instructions to port ROM-DOS to a new environment. TheMini-BIOS in assembly sourceform contains all of the hardwaredependent code and providesthe minimum hardware support

required by ROM-DOS.The ROM-DOS Developer’s

Kit is available for $495 and

comes with 20 duplicationlicenses. The license cost is theroyalty paid to Datalight for theright to duplicate the softwareand varies from $Z%lO  perlicense for 50 units to $3.00 per

license for 25,000 units. Thelicense to the full source code forROM-DOS is available for $5000.

Datalight17505 68th AvenueNortheast, Suite 304Bothell, WA 98011(206) 486-8086(800) 22 l-6630

Attention Manufacturers!

Circuit Cellar INK provides its readers with newsabout significant product developments inhardware, software, and development tools.If your company has a new product that ourreaders should know about, please send yourproduct announcements to:

Circuit Cellar INK New Products Editor

4 Park Street, Suite 20Vernon, CT 06066

10   ClRCUlT CELLAR INK 

Page 10: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 10/78

Letters to theVISIBLE

INK INK Research Staff  answers;

clear and simple

OH, FOR A SIMPLE GAME PORT...

I need a multiple-channel temperature logging anddata reduction system similar to the one Tom Riley pre-sented in March/April of 1988. [See “PersonalComputer-Based Instrumentation” by Tom Riley, CKLJIT

CELLAR INK 2.1  However, I have a laptop computer withonly RS-232-C and parallel ports. Will you modify thiscircuit’s software to allow the parallel port to receiveinput? The Toshiba 3100 has no game port. It would also

 be helpful to allow more thermistors, if possible.I know now that I can’t live without a modem to access

your BBS. I live aboard a boat and most everything mustoperate off the 12.6V   system batteries. Can you suggest amodem in kit form that is available for my use? If not a kit,any lower-priced unit will be acceptable.

Jack H. Peterson

Ft. Lauderdale, FL

The project described in the article fakes advantage of the Apple B-series game port and embedded software in the BASIC interpreter. While this could beeasilyduplicated by an IBM PC or compatible with a game port, your laptop is missing this

 feature.There is a method of adapting this circuit to a PC with a

 parallel port, but if doesgef  complicafeda requires somesoftwaretricks. Normally, the data lines on a parallel port only go “oneway” to   the printer. There are eight of them, so theoreticallyyou could get  eight thermistors. In reality, you have to read the

status offhe  eight data lines. Not all parallel port hardware willlet you do this. In addition, theAppleIlgameport  is actually anA/D  converter ofsorts,so  thevoltageat thegameporf connectorsis what’s actually being measured. You can’t do that with a

 parallel port, since it only receives a logic signal. Therefore, theapproach you take must deliver a signal to charge the capacitorsand measure the time for each line to change state (because of theRC timeconstant of the thermistor and thecapacitor). You coulduse thedatastrobelineof theparallelport tocontrol thecharging.

 Actuallydoing this will requireassembly languageroutinestoaccess theparallel port in fhemannerdescribed. Thereare lotsof books out there on low-level manipulations of the PC hard-ware,

and if’s difficultto recommend just one since we don’t

know your background or temperament.

12   C IRC lJll  CELLAR INK 

 As far as your modem purchase is concerned, just fakea  lookat all of the SV-battery-powered  “pocket modems” now on themarket. Most recent consumer-oriented computer magazinesarefilled with ads for them. At current prices, if’s impossible tojusti& going to a kit. Another option is to find an externalmodem designed to be powered by 11 VAC. Most of these have

transformers which convert the IIOV wall current to 9-15Vforthe modem itself. Find one with a 22V  or lower DC input,fit  itwith a cord, and away you go.

RESETTING AN AT

Can you help me by supplying a circuit for a resetswitch for an AT clone, or telling me how I would go about

installing one? I have a switch that produces an NM1interrupt, but it is frequently insufficient. I don’t want toturn the power switch off and on too often because it cyclesthe hard disk as well, but I do need to be able to reset the80286 (and the bus, if possible).

David S. BakinSan Francisco, CA

 Adding a reset switch to your AT clone is not ve y difficult,and thereareacoupleofwaysif might bedone.   Themostobviousway, driving the RESET DRV pin on the expansion bus, is not

the way to do it. This is an output signal used to reset other  fhings. We only mention this because we have seen others makereference to grounding this pin to reset the system.

The system will reset if the POWER GOOD line from the power supply is pulled down for a short time. This is the normalway that the system begins ifs boot process on startup. ThePOWER GOOD line stays low until the power supply outputvoltages are within spec,  then goes high. In a True Blue AT, thislinegoes  directly to the RES\ pin on the 82284 clockgenerator.When fhispingoes high,itgeneratesa resetsignalat its reset pin.ThisisfhesignalfhafactuallyresetsfheCPUandbegins  theboot

 process.

ThePOWERGOODlinecomesoutoffhepowersupplyand goes to pin of one of the main power supply connectors. The

Page 11: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 11/78

connector you want is labeled PS on PC power supplies, and P3inATs.  Znanycase, fherearefwomainpowersupplyconnecfors,one with the @on  pin 1, and one with a key on pin 4. The oneyou want is the connector with the key on pin 4. Ground is pins5 and 6 on this connector.

To add the switch, all you need is a normally open momen-tay-contact push-button switch and a few feet of hook-up wire.Oneside  of the switch is to be connected to the POWER GOOD

line, and the other side will be connected to ground. If willprobably be convenient to make both connections to the leadscoming out of the power supply, or to the pins in the connector itself. The easiest way to make these connections is to splice theswitch leads onto the power supply leads with crimped-on,solderless, splice connectors, but you could strip in a shortsection of insulation on each lead and solder the switch leads in,or insert the switch lead wires into the connector from the rear.

WORKING WITH THE FCC  All letters and photos become the property  of CCINK  and cannot be returned.

I am working on starting up my own business andplanondesigningacomputerasoneofmyproducts. Whatwill I need to do to get the required FCC certification?According to an article I read, the paperwork, delays, andmoney required for certification are prohibitive for a start-up company. Is this true? If so, something needs to be doneabout it!

This brings up another question. I read in the June 12,1989 issue of ComputerWorld   that IBM has urged the FCCto close the ‘loophole” allowing user-assembled personalcomputers to be sold without certification. How can weurge the FCC not to create the same problems in this are asthey have with factory-assembled computers? Will theylisten if individuals write to them?

Dan BarrNapa, CA

FCC certification is, at present, an expensive process for asmallcompany.  Wesuggestyougetacopyof fheFCC  RulesandRegulations, Part 15. This is available from the GovernmentPrinting Ofice,  Washington, D.C. The last time wechecked, theprice for this particular publication was around $15. The ruleswill tell you the engineering requirements for certification, aswell as the administrative details you’ll have to take care of.There are a lot of rules, but there are also a lot of wrong publicimpressions about what the rules say. Your device or productshould be compared to the rules relating to its particular productcategory.

TheFCCdoeswelcomepubliccomment,andyouasacitizenhave the right and duty to inform them of your position onmatters relating to their administration. Zf you follow the

comment procedure, they must consider your input. Thisdoesn’t mean that theywill   necessarilyproducearule thatfavorsyou, but if there are aspects of rulemaking that are incongruous

or unduly burdensome to a small business such as yours, youhave a good chance of getting at least some attention. To have areal impact, though, you must become informed of exactly whatthe FCC is doing, and that is rarely reported with any accuracyin the news media. A local library might have the FederalRegister as a periodical. By law, all proposed rules and admin-istrutivechanges must be   reported within the registerso that the

 public may comment.

 A good source for help in obtaining information from gov-ernment agencies is the book “Information U.S.S.” by

 Matthew L so. You can find this in most national chainbookstores.

In Visible INK, the Circuit Cellar INK Research Staff answersmicrocomputingquestions from the readership. The representative questions are published eachissue as space permik. Send your inquiries to:

INK Research Staff c/o Circuit Cellar INK

Box 772Vernon, CT 06066

1IRS201 Very Useful202 Moderately Useful203 Not Usefu!

.

The Ultimate in Embedded

Systems Programming.Remote DSD87 is the most ad-vanced source debugger for em-bedded systems. This packageand your compiler form a com-plete solution for embedded de-velopment. Supports Microsoftand Turbo C. Includes a FREEcopy of Native DSD8

ROM-Link is the fastest linkmd locate utility for use with

Remote debuggers, In CircuitEmulators, and EPROM Pro-grammers.   Supports Microsoftdebugging information.

Call Our Bulletin BoardSystem at (213) 559-1449 for

FREE Demonstrations!

December ‘89Llanuary  ‘90    13

Page 12: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 12/78

Writing Network Applications   1Ed Msley

INKnetPart 3

The Sub t le Art of Pro g ra mm ing for INKnet

The first two artic les

in this series covered the

“how and why” of net-

works With that under

your belt, I  can now

explore programming

techniques for applica-

tions that exchange

control and status infor-

mation using INKnet.Rather than an aca-

demic discussion, I will

describe four programs

that cooperatively man-

age a single control prob-

lem.

The sample project is a 100-litermixing tank. While this is typical of many process control problems, I’vemade some simplifying assumptionsto keep the programs manageable.

Despite the fact that INK’s read-ers are hands-on types, it is unreason-able to expect you to tackle a major 

 plumbing project just to see howINKnet works. Ordinarily, one of theRTC52 boards would monitor thesensors and drive the valves and mixer 

motors, but I added some BASIC codeto simulate the temperaturemeasure-

14   ClRCUl7  C ELLAR INK 

Id  I t Va/ve

OV S OW

Madmum

bWmum

Mxer Moto r    AnyWu i d

Cwflet Tem pwa t ire

?3

Outlet  Valve

Figure 1 -The  hypotheti-c a l tank ha s inlets for hot and c old, an out le t , sen- sors for c on ten t leve l, a m ix ing m otor , and tem - p era ture senso rs. it is d e- 

signe d to m imic a r e e dwo rld ’ tank ap p l ica t ion .

ments and produce fake switch val-ues. You can thus run the whole showon your desktop without the faintestrisk of drowning your keyboard.

SIZING THE PROBLEM

Figure 1 shows our mixing tank,which has both “upstream” and

“downstream” connections to other  parts of the manufacturing processthat we’ll ignore here. There are twoinlet valves that provide hot and coldfluid and one outlet valve that drainsfluid. We control the inlet valves, butthe outlet is opened and closed by themachine drawing fluid from the tank.Our job is to maintain enough fluid atthe correct temperature to keep thedownstream machine contentedwhenever it needs juice.

There are four fluid level switchesalong the side of the tank, so we can

determine how much fluid is present,albeit with limited precision. A pair of temperature sensors report on tank and outlet temperature, which may be different if the tank wasn’t stirredwhile adding fluid. The mixer motor is under our control and should beturned off whenever it isn’t needed.

Figure 2 diagrams the network 

nodes and I/O connections neededfor the project. The Tank Simulator (Node 2) and Control (Node 1)   RTC52

 boardsare theonlytrulyessentialones, because you can control the outletvalve manually using the Tank Simu-lator’s console interface.

The RTCIO expansion boards areused mainly as outputs, so you canomit them and read the results fromthe AT’s display. The Control nodereads Time-of-Day information from

the Real-Time Clock on its I/O expan-sion board, but the code will continue

Page 13: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 13/78

to work with bogus values if the chipis missing.

TIMING IS EVERYTHING

As you should know by now, thereis an intimate relation between thedata rate required by your programs,

the network bandwidth, and the suc-cess of your project. For much thesame reasons you can’t win the Indy500 in a Yugo, you can’t commute towork in an Indy racer: you must makesure that you’re using the right toolfor the job. In this case, we must matchthe network’s data rate against the

 problem’s control requirements.Our tank holds up to 100 liters of 

fluid; the Minimum and Maximumlevel sensors change state at 40 and 75

liters, respectively. The Overflow andAnyfluid   sensors inform you that thefloor is getting wet or the tank has rundry, but under normal conditionsOverflow is OFF and Anyfluid  is ON.

The Outlet valve drains 0.3 liters/second from the tank. The Cold inletcan also supply 0.3 l/s, but the Hotinlet is limited to 0.2 l/s. While thesesoundliketrickles,0.3I/sisabout4.75

gallons/minute.The Outlet temperature must be

maintained between 55” and 65” C, but the Hot fluid arrives at 200” andthe Cold fluid at 0”. Obviously, thefluid isn’t water; think of lubricant or feedstock chemical. The Mixer stirs 5liters/second of tank contents, al-though the simulation simply adjuststhe Outlet temperature toward theTank temperature by the ratio of theMixer flow duringonesimulation stepto the total tank contents.

The Control node must maintain

the temperature without overfillingor emptying the tank. Because theonly level information comes from thefour sensors, the control algorithmmust shut the inlets off when theMaximum sensor goes on and turnthem off when Minimum shuts off.

Adding 0.5 liters per second to atank that is about half full results in a1% volume change per second. TheHot and Cold flows and temperaturescombine to add 133-degree fluid to

the 60-degree tank contents; the corre-sponding temperature change is,

again, about 1% per second. The al-lowable temperature variation is lo%,so the network has on the order of 10seconds to respond to any changes.

Although I have not described themessage format yet, most of the net-work traffic will be polls and shortresponses. As you saw in the last

article, a short INKnet   message re-quires about 15 milliseconds, so eachnodeina5-nodenetworkwillbepolled

6 or 7 times per second. Because theControl node must exchange severalmessages with the Tank Simulator 

 0

Figure 2-The network nodes and I/ O  c on -  

nections needed for this project. The Tank Sim ulato r (Nod e 2 and Co nt ro l (Node I)RJC52  boards are the on t y  truly esse ntia l ones, bec ause you c an c ontro l the out le t valve m anua lly using the Ta nk Simulat or’s co nsole interfac e.

node, the response time will be abouta second and the control system willhave time to stabilize the system.

If your system changes by 10% inhalf a second, a controller respondingin a second will not be able to hold the

system within 10% of the setpoint.INKnet   is suited for industrial prob-lems that change relatively slowly; itis not the backbone network for a fly-

 by-wire system!

PASSING MESSAGES

Figure 3 shows the message flow between the four RTC52 nodes. In

Because the programs must re-

effect, there are four simultaneouspro-spond to network messages at anytime, they have a different structure

gram loops working on four different

 problems, each one swapping data

than you may have used for your 

with the others as needed. All four BASIC applications. Figure 5 shows ageneric flowchart that applies to each

BASIC programs are also updatingtheir console outputs and scanningfor keyboard input, so there is a lotgoing on under the covers.

Each network message includesan opcode that indicates the purposeof the message and the format of anydata following the header bytes. Thefirmware handles all of the console I/0, polling, and network status mes-sages; the application programs canconcentrateon their own information.

Figure 4 shows the opcodes asso-ciated with each network message.Opcodes between 10 and 1F  hex arecommands sent to a node to elicit aspecific action. That action will trig-ger a response message with an op-code 10 hex greater than the com-mand opcode. The response does not

directly trigger any network traffic.For example, the Control node

sends opcode 11 hex with a single“zero” data byte to the Tank Simula-tor to close the Cold inlet valve. TheTank Simulator responds withopcode21 hex and “zero” data to acknowl-edge that the valve is shut, or “one” toindicate that it isn’t. The Control nodethus is assured that the commandedaction has actually taken place.

The INKnet   firmware does not

guarantee that messages will reachtheir destination, so your programsmust handle this function. The sample

 programs retransmit the most recentmessage if the acknowledgement hasnot arrived within two seconds.

The Control node must send andreceive three messages to collect thecurrent valve, switch, and tempera-ture status from the Tank Simulator node. I chose this rather chatty proto-col to provide an excuse to discuss

 building a state machine to managenetwork traffic. In your applicationsyou should minimize network traffic

 by combining asmuch information as possible into a single message.

RUNNING IN LOOPS

December ‘89/J anuary  ‘90   15

Page 14: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 14/78

Page 15: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 15/78

Page 16: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 16/78

Page 17: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 17/78

Page 18: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 18/78

Page 19: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 19/7822 C lRC Ull CELLAR  INK 

Page 20: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 20/78

FEATUREARTICLE

IMAGE SYNTHESIS:A TUTORIALToo ls fo r Dra w ing a New Unive rse 

by Chris Ciarc ia 

Whether programmer or painter, the

modern artist can stimulate the imagina-

tioncreate  a message, or passon a thought

within the world of computerized image

synthesis, Instead of a palette of paints, he

uses a high-resolution computer graphics

screen, lighting colored pixel arrays instead

of layering paintbrush strokes. Using image

synthesis techniques to enhance the me-

dia, he can visualize a design, study a struc-

ture, or visually test a theory in a most real-

istic fashion.

 The goal is using computer graphics

drawing techjniques to produce realistic

pictures, indistiinguishable from photographs

D e c e m b e r ‘ 8 9 / Janua r yW  23 

Page 21: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 21/78

of real “or imagined” objects. Theartist simulates the optical processesof the real world by modeling thephysics of light propagation and itsinteraction with matter. Effects suchasmirrorreflections,fuzzyreflections,glossy reflections, transparency, re-

fraction, indirect lighting, color bleed-ing, caustics, directional light sources,smooth shadows with umbrasand pe-numbras, motion blur, depth of field,surface textures, and fog and haze arefair game for “realistic” visualization.

Anyone who’s been to the moviesin the last five years knows how farcomputerized image simulation cantake us. The question is, how does itget us from here to there?

the incident light and the optical prop-erties of the surface.

Incorporating all of these “lightmanipulations” into one single image

LIGHTIN THE REAL WORLD

Image synthesis is the simulationof the optical processes at work in thereal world-the physics of how lightpropagates and interacts with nature.Based on these processes, creating a“realistic-looking image” is achievedin three stages: image formation, ob-

 ject illumination, and shading. Imageformation is the determination ofwhat’sinthepictureandhowit’stobeseen. Such operations as “the hiddensurface” problem are addressed here

as well as the calculationof reflectionsfrom mirrored surfaces and the re-fractions through transparent objects.Illumination is the determination ofimage components that are depend-ent solely on the propagation of lightthroughout the screen,while being in-dependent of the viewpoint. Sucheffects as shadows or internal reflec-tionstbothdiffuseand specular)from objects andlight passing

through transpar-ent or translucentobjects are incor-porated here.And finally, shad-ing is the processof determiningthedistributionoflight leaving asurface, deter-mined by specify-ing the nature of

various degrees of image-realism ef-fectiveness. The possibilities rangefrom single-viewpoint models toelaborate statistical algorithms suchas Monte Carlo techniques to solvetruly intractable modeling problems.

Before we can start to create syn-

thesized images, we have to under-stand the relationships between light,the viewed objects, the monitor onwhich we wish to display our image,and the device, be it our eyes or someoptical recorder, that views the im-age. Then we must make the bestmodeling assumptions that give themost ideal image in our quest forrealism. From the start, the very useof a CRT immediately places us at adisadvantage. It imposes a 2-D for-mat, limited image size, limited color

selection, fixed spatial resolution, anda limited intensity range on our statedgoal. Are we defeated? No! If mydaughter can model the family car onthe bedroom wall, can I do less on my‘386?

SYNTHESIS

Figure 1 -There are three main steps in im-age synthesis: Image formation. which isdep ende nt on v iewe r po in t of view; Ulumi-

nat ion, which is point of view independent;

and Shad ing, t i ic h  c onside rs the surfac e prop ert ies of the ima ge .

synthesis system is an elaborate un-dertaking. At present I know of noone integrated image synthesis sys-tem on the market that does a trulygreat job in all areas. There are just somany effects that can be modeled to

Generating imagery on a com-puter involves creating data repre-sentations, planning scene environ-ments,computingvisibility,shadows,

shades, texture, and color, and thendisplaying the results. The basic algo-rithmic components of this artisticintent are: the determination of visi-bility, shadowing, shading, aliasing,texturing, and modeling, and then(finally) synthesis!

In our current format we can, ofcourse,only consider the simplest and

most idealizedform of each ofthese synthesisareas, but these

simplified de-scriptions ofconcepts and al-gorithms trulydemonstrate thek n o wn , a c -cepted, and fun-damental strate-gies for creatingrealistic imageswith your com-puter.

The  co iorpho to sin this art ic lei l lustrat e  the co nc ep ts discussed . Eac h ma kes use o f the ray-

tracing, shad ow ing, and surfac e texture technique s to give we ight to o bjec ts co mp osed of va rying slices of stand ard ge om etric shap es.

24 C RCVt l  CELL.4 R INK 

Page 22: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 22/78

Page 23: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 23/78

pixel within your image field. Thentest eachrayagainst eachobject withinyour database and find the closestsurfaceintersectionpointwithrespectto your point of view. Then assign arelative color and/or intensity valueto that pixel location on your screen.

These days, however, nobody

keeps things simple. The general trendwithin the ray-tracing community isto incorporate shadows, reflection, andrefraction 111  into the ray-trace model.This is accomplished by generating asecondary set of rays whenever a pri-maryrayintersectsa surface,and trac-ing each ray within the secondary setfrom the intersection point, out to-ward each specified point-light source.

If the secondary ray encountersan object between surface and light

source, that intersection point can beconsidered within its shadow. Theassociated pixel value is then dimin-ished according to a specified illumi-nation model. Each time a reflectedray intersects a surface, it generates aset of secondary rays, thus cascadingthroughout our scene. And a ray canalso be traced in the direction of re-fraction, depending on the surfaceoptical characteristics. As a result,this level of recursion in the algorithm

indicatesthatanindividuallyreflectedor refracted ray can generate addi-tional shadow rays, and so on.

A basic outline form for such analgorithm is:

DO FOR *each pixel*generate a ray R from the point of

view, through the object space to theimage plane

DO FOR *each object 0 within the scene talc.  the intersections of 0 and R

IF*the ray R hits no object

THEN*set the intensity to background*go get the next pixel ray

ELSE*find 0 with the closest intersection

generate a secondary ray S fromthe intersection point to the lightsource

IF*the S intersects another surface

on the way to the source, it is inshadow

-diminish pixel accordingly-go get the next pixel ray

ENDIFl the point is not in a shadow*calculate the appropriate intensity

value*go get the next pixel ray

ENDIFENDDO

ENDDO

Such algorithms which considershadows, reflections, and refractions

are fairly easy to implement. How-ever, they tend to suffer from two pri-mary difficulties: aliasing and com-putational speed. Aliasing occursbecause of the inherent point sam-pling nature of the algorithm. And,thecomputationalproblemisblatantlyobvious. The large number of ray-surface intersections can easily form abottleneck in terms of actual run time.

The world of ray tracing seems tohave an infinite dimensionality, and I

don’t have the space here for all thedetails. I suggest you read references[ll-[9]  for more information. Aftermuddling through theabove,and afterbecoming totally confused, you willhave noticed that the ray-trace algo-rithm is similar to the Z-buffer algo-rithm, and that, in turn, each is of theflavor of the other. The differencebetween the ray-trace and Z-buffertechniques only lies in the nestingorder of their main loops. Where the

ray-trace form handles one pixel at atime and then compares each object’sdepth, theZ-buffer   algorithm handles

object  I

Figure 2 -Shadows ,  reflections, and re t i a c -t ions are incorpo rated into the ray - t rac e mo de l by g enera t ing a sec onda ry se t o f rays wheneve r a p rim ary ray Intersec ts a surfac e. Eac h ray w ithin the seco nda ry setis raced  from theintersectionpoint to each spe c ified p oint-l ight sourc e.

each object at a time and studies eachpixel that an object covers. The differ-ence between the Z-buffer andpainter’s algorithms lies only in howdepth comparisons are made. The Z-buffer makes comparisons through-out the inner loop calculation cycle,while the painter’s algorithm makesall of its depth comparisons in a pre-liminary sorting phase. In turn, thescan-line algorithm only differs from

the Z-buffer because it first dividesthe 2-D image into a sequence of 1-D“scan lines” and then applies a simpli-

Dece m be r ‘BP/ January ‘90  27

Page 24: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 24/78

fied 1-D Z-buffer vis-ible-surfacealgorithmto each line [2,9].

SHADOWING

Within the world

of Image Synthesis,shadowing is oftenreferred to as the prob-lem of direct illumina-tion. The ultimate goalhere is to determinewhat portions of your image are illu-minated either directly or indirectlyby light sources and what parts areobstructed, or in shadow. As I de-scribed in the previous section, oneway to attack the problem is to incor-porate shadow rays within your visi-

bility point-sampling code. But youcan also approach the problem fromanother perspective.

One technique I have tested andfound to work effectively is called the“depth map” procedure. It was firstproposed by Lance Williams, in apaper he gave at the 1978 SIGGRAPHconvention [lo]. It involves thecalcu-lation of a depth map, the Z-bufferimage computed from the viewpointof the light source. Then, for each

pixel, the distance to the light sourcefrom the visible object is calculatedand compared to the correspondinglocation within the depth map. If thedepth map contains a lesser value,

thenanobjectintervenesbetweenthatpixel of the visible object and the lightsource. The object is therefore in ashadow.

Depth mapping is a straightfor-ward approach and can be appliedredundantly to the image for each light

source. It has been improved, as allolder and proven techniques are, bythe addition of stochastic supersam-pling and the storage of floating-pointvalues within its depth buffer. If youwish to learn more of this techniqueand others, I refer you to references

121,  (91, and 1111.

The shadow patterns generatedby any hidden-surface (source view-point visibility) technique are validfor any selected “actual” viewing po-

sition, as long as the light source posi-tions are not changed. Surfaces thatare visible from the view position areshaded according to the intensitymodel, with surface patterns and

shadow patternsadded. Visible sur-faces that are not il-luminated by a lightsource have onlyambient light inten-sity applied. Visible

surfaces that are il-luminated by a lightsource are shaded bycombining the inten-sity model and thepattern arrays. Pro-

 jected shadow areas are shaded withthe ambient light intensity only.

 Just remember, as withal1 shadowalgorithms, multiple light sources canbe treated with independent applica-tions of the same algorithm for eachlight source. However, too many light

sources can easilybogdown your illu-mination processing time.

SHADING

The process of determining thelight intensity leaving an object iscalled shading. The goal is to modelthe interaction of light with surfacereflection properties so that we canspecify an appropriate color and im-age intensity. As such, it is dependent

on the incoming light intensity anddistribution as well as the opticalproperties of the object. Indirect illu-mination can be handled by repeatedapplication of local shading techniques

I 1

Diffuse an d Spe c ular Reflect ions 

 i g ht Re di v e

s o r c e

Specular Reflection Superimposed on Diffuse Reflections 

Figure J - lhe in tens i t y o f l i gh t  tha t we view  f rom an imag e d epe nds on b o th the d i rec t i on of the  l igh tsourc e and t h e  reflect ion p r ope r t i e s  

of the surfac e. At ce rtain an gles, shiny surfaces re f lec t a ll of the inc ide nt l ight .ang le w ill be c om bined wi th other , mo re d if fuse reflections.

In a rea l objec t , the spe c ular ref lec t ion w i t h i n this na rrow 

28   C lRC UlT  CELLAR  INK 

Page 25: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 25/78

Page 26: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 26/78

Page 27: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 27/78

Page 28: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 28/78

strobing-causing a fast-movingobject to seem to jump in dis-crete steps

scintillation-small particles thatdrift between samples blink-ing on and off

“crawling ants effect”-the spatialaliasing “jaggies” slowly

“moving” between framesstretching and shrinking-a slowly

moving small object (a fewpixels in size) will seem tostretch and shrink in one-pixelsteps as it crawls across thescreen

beating-verticallymovingobjectsbeating with the interlace ofbroadcast TV

In order to reduce the effects of

aliasing within an image, we mustfilter the image to remove or reducethe high-frequency components be.-fore sampling [2,13,141.  In effect, wewill reconstruct an image “as nearexactly as possible” from its samples,provided our input image is bandlim-ited   to some maximum frequencywhich is less than one half the sam-pling rate; with this spatial samplingrateforoursyntheticimagebeingfixedby our final image resolution.

For this purpose, let’s define thefollowing entities:

i(x,y)= an input imagef(x,y)=   a kernel or point spread

functions(i,jl=  sample antialiased filtered-

sampled image, with i j  beingintegers

where, the most standard form of the“antialiasing integral” is defined as,

s(i,j)  =I

li(x+i,y+i)f(x,y)dxdy

and for temporal antialiasing,

s i,b  7) = J ./J i(x+i,y+i,t+ z)f(x,y,t)dxdydt

All antialiasing algorithms solveor approximate this integral for eachpixel contained in the synthesizedimage. Usually they vary only in the

32   ClRClJlT  CELLAR INK 

type of numerical technique used andin the form of the point-spreadfunction ffx,y).  My experience hasshown that the best spread function isa low-pass filter with a smooth, all-positive, and nearly finite frequencyresponse of the form, e-x2, the stan-dard Gaussian. It easily removes all

thehigh-frequencydetailswithoutdis-torting the low-frequency regime.And, unlike other low-pass filters, itminimizes the effects of sharp transi-tions which cause noticeable ringingwithin the filtered image (the Gibbsphenomenon).

If you plan to incorporate antiali-asing   into your image synthesis, Isuggest you read Joy’s book [91,“Computer Graphics: Image Synthe-sis.” He discusses many variations

andapplicationsofantialiasingbackedby a good reference section. In gen-eral, however, I find myself extremelylazy. Although I have tried severalaliasingcorrectionschemesinthepast,I usually end up passing over this “re-quired” step. I like to develop myimages at a higher resolution than thefinal output. I then create the finaloutput pixels by combining severalpixels which overlap the output pixelusing a weighted averaging scheme.

It works quite well and provides goodresults.

Figure The  amount of energy exchangedbe twee n two bo d ies is f igured through a re la t i ve ly c om p lex set of sim ultan eo us equations. Worse yet, evaluating the formf uc tors requ ires solving a sep arate hidden-

su rface p rob lem be tw een ea c h pa ir o f surface areas within the environment.

TEXTURING

Texture is the surface detail of adisplayed object. It is dependent onthe optical properties of the objectmaterial and is easily modeled byadjusting the intensity values fur-nished by a shading model. This is

achieved by altering the surface nor-mal so that it is a function of positionover the surface. If the surface normalis allowed to randomly vary, an ir-regularly textured surface reminiscentof a raisin is obtained. Irregular sur-faces can be generated by dividingeach surface area into a collection ofsmall randomly oriented surfaces.And, as in both cases, we could allowthe coefficient of reflection to varywith position and thereby obtain quite

a bit wider variation in overall inten-sity.It is also possible to use what’s

called a texture-mapping method.Thisinvolves theapplication of storedpatterns to surfaces of 3-D objects,much like applying patterns to 2-Dobjects. Each array pattern is treatedas a plane surface with the positionand orientation of the pattern speci-fied relative to the object. The artistsets a pattern reference point and

defines two vectors that specify theorientation of the array plane. Theseobject-linked pattern planes are thenstored and referenced by a hidden-surface utility. Intensity values storedin pattern arrays are used to modify  orreplace intensity values calculated inthe shading model.

MODELING

The creation and manipulation ofthe objects within our image environ-ment according to some “defined”system representation is called“modeling.” Models for a system canbe graphical or purely descriptive,such as a set of equations that definethe relationships between systemparameters. This process includes thedefinition of shape, location, and ori-entation of each object, and the loca-tion, spectral wavelength band, angu-lar distribution, and intensity of eachlight source.

Page 29: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 29/78

Page 30: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 30/78

Page 31: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 31/78

Page 32: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 32/78

An Intel 80386SX-basedPC/AT-CompatibleMotherboard

Tim ing is a lm o st e ve ryth ing 

Part 2 Lby Daryl Rinaldi

I npart 1 of thisarticle, welookedat the basic logic of an 80386SX  ISABus computer. I also described someimportant components and PC/ATsystemcharacteristics. Torefreshyourmemory of how the components re-

late to one another, look at the firsttwo figures for this article. Figure 1shows the bus structure of the stan-dard 80286-based  AT computer; Fig-ure 2 is a diagram of the 80386SXcomputer described in this article.Now that we know what the keydevices are, let’s look at how theywork together in this design.

One of the best ways to study theworkings of a system is to look at thebus cycles. We will look at eight bus

cycle types: RESET, Local Memorycycles, Numeric Coprocessor cycles,Expansion Bus Cycles, X Bus cycles,ROM cycles, HOLD/HLDA cycles,and INTR/INTA cycles.

RESET

There are two types of reset in aPC/AT: CPU reset and system reset.Depending upon certain system con-ditions, the 82230 will initiate one of

the two types of reset. The 82335interacts with the major system com-ponents to ensure these resets pro-duce predictable results.

A system reset occurs on power-up to force the system into its initialstate. When the system is first pow-ered up, the 82230 activates RESETand RESCPU. Once PGOOD\  (powergood) becomes active, the 82230 willdeactivate RESET and RESCPU. Both

the 82230 and 82231 reset themselvesinternally upon activation of RESET.

Figure 1 -A stan da rd80286 ba sed AT c om pa t ib le  ha s seve ra l sep a ra te b uses forpa ssing 

a dd resses an d d a ta through the system .

Upon receiving RESET andRESCPU, the82335activatesRESETSXto the processor and RESETNPX tothe numeric coprocessor. These de-vices go through their respective ini-tialization routines. The 82335 alsoresets itself. In addition, the 82335’sREFRESH counter is reset and all theinternal registers go to their initialstates.

Clock synchronization also occursduring power-up. Most timing in thesystem is derived from one of fourclocks: CLK2, PCLK\, PROCCLK, orSYSCLK. CLK2 is a 33-MHz output ofthe 82335, generated from its 32-MHzEFI input, and is an input to the 386SXand the 387SX. PCLK\  is a 16-MHzoutput of the 82335. It is half the

frequency of EFI and feeds the 82230’sX3 input. The 82230 inverts X3 and

buffers it to generate the 16-MHzPROCCLK output. The 82230 alsodivides PROCCLK by two to generatethe ~-MHZ  SYSCLK output.

All four of these clocks must besynchronized for the system to oper-ate. This important process may notbe immediately obvious from the

component data sheets and could usesome explanation.

The 82335 synchronizes PCLK\with CLK2 after the falling edge ofSYSRESET. Thismeans that PCLK\  islow in phase 2 and high in phase 1 ofCLK2 and that PCLK\   edges corre-spond to rising CLK2 edges. Thesynchronization sequence is shown inFigure 3.

After the deactivation of RE-

SETSX, the second risingedge

of CLK2is the start of a phase 2 clock cycle.

D e c e m b e r ‘ 8 9 / J a n u a r y ’ 9U   37

Page 33: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 33/78

Page 34: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 34/78

a RESCPU pulse of approximately 1.5

s.The 82335 passes RESCPU on to

the processor as RESETSX but doesnot reset itself internally nor does itactivate RESETNPX. All 82335 regis-ter information remains valid and the82335 REFRESH counter is not reset.

Only the CPU initializes itself. Allclockscontinuerunningnormallyandno clock synchronization takes place.The 82335 deactivates RESCPU at theappropriate time to ensure that PCLK\stays in phase with CLK2.

The 80286 must be reset in orderto switch from protected to real mode.The 386SX does not require a reset togo from protected to real mode, but86based software sometimes resets

the CPU in order to accomplish the

switch.

LOCAL

The most frequent bus cycle gen-erated by most applications is localmemory access. The 82335 uses pag-ing to allow most local memory ac-cesses to be done without any waitstates.

The 82335 can operate in Turbo orNon-Turbo mode. Non-Turbo modeaccessesalways takesix 16MHz386SXT-states, equivalent to three ~-MHZ

PC/AT T-states. The equivalence isimportant for software with timingloops based on l-wait-state PC/ATbus cycles. Local memory accesses inan IBM PC/AT use one (286) waitstate.

Turbo mode accesses don’t havethe timing constraints of Non-Turbomode accesses. Therefore, Turbo

mode accesses are faster, though theirspeed varies depending on DRAMspeed, page hits/misses, and bankhits/misses. The TURBO\ inputswitches the 82335 into and out ofTurbo mode.

A O-wait-state (Turbo mode) pipe-lined local memory read is shown inFigure 4. Address pipelining simplymeans that the address and bus cycledefinitioninformation for the next buscycle becomes active before the cur-

rent bus cycle is over.This memory access starts with

the assertion of the CPU’s NA\   signal.

Figure 4-Address  p ip l in ing ma kes the t iming fo r loc a l me mo ry rea ds more c om pl ica ted .

NA\   asserted causes the next address Since this is a read cycle, DIR will be

to come out in the next bus state, or in low, causing data to flow from the MDother words, initiates address pipelin- bus to the local data bus.ing. (A note about address pipelining: Since this is a page hit, the 82335Although address pipelining cannot outputs only the column address onimprove upon O-wait-state perform- MAO-MA9 and activates CASHO\

ante,  it will provide more address (high-byte bank) and CASLO\  (low-setup time for the local DRAM S. What byte bank). If this were not a page hit,this means is that with address pipe- then the 82335 would have output thelining, you may be able to use slower row address and RAS before output-DRAMS and still get the same per- ting the column address and CAS.formance as you would using faster After outputting CAS, the 82335

DRAMS

without the address pipelin- will activate DEN\ to enable the MD -ing.) to-Local Data Bus buffers. The 82335As the next address is output, so is will then output READYSX\  to the

the next bus cycle definition. ADS\ CPU to indicate it has valid data on thegoes low to signal that the outputs are local data bus. The CPU will latch thisvalid. The 82335 decodes the incom- data and end this bus cycle.ing address and bus cycle definition. A local memory write is basicallyOBMEM is then activated to signal an the same as a local memory read. Theon-board memory access. In an on- only difference is that DIR will beboard memory access, the 82335 will high, WE\ will be active (low), and, ofnot activate the status outputs-SO\ course, READYSX\ will signal to theand Sl\-to   the 82230/82231.   This processor that the DRAM is ready to

basically disables the 82230/82231. input data and not output data.

PCLK\  

ADS\

B USY N P X \ j  p  cer

PEREQNPX

PEREQSX x  J L

ERROR\

READYNPX\

READYSX\

Figure 5 -A t y p i c a l  

NPX bus cycle usesfour key si g n a l s:  

READY\ , BUSY\ ,

PEREQ , and ERROR\ .

De cembe r ‘ 8 9 / J a n u a r y  ‘ 90    39

Page 35: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 35/78

Page 36: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 36/78

Page 37: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 37/78

Page 38: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 38/78

Page 39: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 39/78

Page 40: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 40/78

Bus Master cycles are essentially thesame as DMA cycles except that theBus Master takes control of the sys-tem.

INTR/INTA

Some time after INTR is received,

the CPU will save its current state onthe stack and acknowledge the inter-rupt request. The 386SX signifies anInterrupt Acknowledge (INTA)  cyclebydrivingM/IO\,D/C\,W/R\,andADS\ low. All the address lines willalso be low with the exception of A2.The 386SX does two INTA cycles withfour idle states in between. LOCK isasserted from the beginning of thefirst cycle until the end of the secondcycle. A2 is low in the first cycle and

high in the second. Each cycle endswith the assertion of READY to the

The 82230 then outputs INTA\  tosignal an interrupt acknowledge cycle.The 82230 asserts READY to end eachINTA cycle, and at the end of thesecond cycle places the interrupt vec-tor onto the lower data bus. This vec-tor points to an entry in the InterruptVector Table that contains the starting

address of the Interrupt Service Rou-tine (ISR)   for that interrupt. The CPUthen begins executing the ISR.

Acknowledgement of INTR willnot occur if interrupts aren’t enabled.A NMI, on the other hand, by its verynature cannot be masked out. Whenthe CPU receives a NMI, it will notperform an INTA cycle. It will always

 jump directly to interrupt vector 2.

A HIGH-INTEGRATION PLATFORM

The kernel of this system contains IRS

of 100-ns   fast-page-mode DRAMScontrolled by the 82335 InterfaceDevice. The 82335 also connects thekernel to the PC/AT part of the sys-tem. The PC/AT part of the systemcontains the 82230/82231,   8042 key-board controller, and a fully compat-ible ISA expansion bus.

I segmented the articles in such away that the kernel could be used asthe basis of an embedded control sys-tem or dedicated single-purposecomputer. The 80386SX  is a processorwith many possibilities. Drop us aline to let us know how you’re using itin your applications.

Day1   Rinaldi is an application engineer at

Intel Corporation and works on the386SXandassociated products. In his spare time, he likesto explore California.

CPU. a 386SX CPU, a 387SX numeric 2 10 Very UsefulThe INTA cycle translates to M/ 2 11 Moderately Useful

10286\ ,  SO\ , and Sl\  low to the 82230.coprocessor, and the local memorysystem. The memory systemis  1 MB 212 Not Useful

Figure 9 The VGA p ort ion o f the 386SX boa rd inc lude s a pa lette DAC , 32k of BIOS supp ort. an d a c ustom PAL.

46    CIRCfJ/T  CELLAR INK 

Page 41: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 41/78

Figure 11 -Any tim e the re are num erous chips c onn ec ted to a n a dd ress or da ta b us, series resistors shouldbe  used on th e b us to m inimize ref lec t ion s a nd no ise.

D e c e m b e r ‘ BP / Janua r y ’ 90  47

Page 42: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 42/78

FEATUREARTICLE

A Low-Cost MIDI Sequencer

Build a n 803 7-Ba se d Sta nd -A lo ne M IDI Seq uenc e r  

MID1 (Musical InstrumentDigital Interface) is a serial communi-cations standard that provides a stan-dardized way to connect electronic in-struments, computers, and peripher-als. A MIDI sequencer is a device that

records sequences of MIDI instruc-tions and transmits them on demand.Since MIDI information can includepitch, attack, duration, volume, andinstrumentation (among many othercategories), a MIDI sequencer canrecord the complete data for an elec-tronic performance and reproduce it.Many musicians use the capabilitiesof a sequencer to provide “back up”for live performances or recordingsessions.

MIDISeq is a stand-alone micro-processor-based four-track MIDI se-quencer. With MID&q,   you canrecord up to four tracks of MIDI data,play them back, and save your com-positions to an ordinary cassette taperecorder. MIDISeq doesn’t require aPC or a MIDI adapter card. All youneed is MIDISeq and a source of MIDIinstructions (a synthesizer or MIDI in-strument controller). It cost me around$60 dollars, not including a few scrap

parts (resistors, capacitors, etc.), tobuild the original MID&q.

EINE KLEINE HARDWARE

MIDISeqconsistsof   8Kof EPROM,32K of static RAM, an LCD panel, aMIDI communications port, a switchmatrix, and a simple cassette inter-face. The schematic is shown in Fig-ure 1.

The LCD panel and switch matrix

are connected to the 8031’s peripheralport with the LCD operating in four-

bit interface mode. The LCD’s datalines and the switch matrix‘s row linesshare the same wires. When the 8031

is scanning the switch matrix, the LCDcontrol lines are deasserted to ensurethe LCD ignores the changes on thedata lines.

The MIDI port is a 31.25-kbpsserial interface. MIDI data is transmit-ted as one start bit, eight data bits, andone stop bit, a format which is com-patible with the 8031’s internal serialport. The 31.25-kbps  rate is derivedby dividing the 1-MHzprocessor  clockby 32. The optocoupler is a general-c se   one obtained from Radio

The cassette interface is tied toseveral spare peripheral lines. The8031 toggles the cassette out line at theproper frequency to save the databytes. The data transmission format issimilar to RS-232: one start bit, eightdata bits, and two stop bits. A “1” bitis represented by eight cycles of 2400Hz, while a “0” bit is represented byfour cycles of 1200 Hz. When loading

data, the 8031 measures the width ofthe pulses to determine the data bits.

I

Iby

Winefred  Washington 

THE SOUND OF SOFTWARE

The software for MIDISeq is par-tially written in BASIC and is com-piled by BAS051, a BASIC compilerwhich I wrote. [Editor ’s Note: Soft-ware for this article is available for down-loadingfrom the Circuit Cellar BBS or onC I RCU I T C EL LAR INK On Disk 22.  See

page 86 for downloading and ordering in- formation.] I used BASIC to developthe user interface since BASIC codecan be written and changed quickly.

Several MIDI-specific functions weretiming critical, so are in assembler.

December ‘dP/January ‘90 49

Page 43: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 43/78

Page 44: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 44/78

runs. The 8031’s  internal timer is usedas the time reference when recordingand playing MIDI data.

The Set Truck O n O f f   commandenables or disables playing a MIDItrack. Only tracks containing validMIDI data should be enabled.

The Record O n O f f  function is a

switch which enables or disables re-cording. This is necessary when allthe data is recorded and you are readyto review your composition.

The Record Truck command isused to select the track for MIDI datastorage. Playing of this track must bedisabled during recording.

The Play  Trucks function startsMIDISeq recording and playing MIDIdata contained in its memory. Press-ing any key on the keypad stops the

sequencer.The Save Trucks function saves the

MIDI data in RAM to cassette tape.The tape interface saves data at onlyabout 25 bytes per second, so it takesaround 20 minutes to save the entirememory space.

The Loud Trucks command re-trieves MIDI data from cassette tape.Since data is saved at about 25 bytesper second, the 8031  can only loaddata at the same rate.

The Dump M emo y function dis-plays the contents of memory used tostore MIDI note on and note off data,along with a time stamp of when thedata was received. When a key ispressed or released, a music keyboardtransmits the event out its MIDI port.MIDISeq receives the data and storesit in memory. The storage format is asfollows:

N+O-LSB of time stampN+Z-MSB  of time stampN+2-Note On/Off Command

ByteN+3-No te ValueN+4-Note  Velocity

where N represents the event num-ber.

MIDISeq maintains the timethroughaclockinterrupt. Whentracksare played, the events’ time stamps

are compared, and the notes are playedwhen the proper time is reached.

MAKE YOUR OWN MUSIC

I enjoyed designing and buildingMID&q.  It was planned not as acompetitor to the expensive profes-sional MIDI sequencers, but as asimple, low-cost way to experimentwith MIDI. The hardware works well

for these criteria, and I can’t think ofsignificant enhancements thatwouldn’t add greatly to the cost orcomplexity of the project. On theotherhand, the firmware has some seriouspotential for upgrades. An editor of

most obvious starting point for firm-wareupgrades. Regardlessof whetheryou build the MIDISeq as given or usethe design as the basis for bigger andbetter things, I hope you enjoy work-ing with MIDI as much as I have. @

Winefred   is currently an engineer   s u b s y s -

tems for CAD workstations. He has a BSEE fromthe University of Tennessee.

IRS2 13Very Useful2 14 Moderately Useful

the MIDI data-stored in RAM is the 215 Not Useful

GET TO WORK!

A New ProjectOur line of macro Cross-assemblers are easy to use and full featured,including conditional assembly and unlimited include files.

Get It To Market--FASTDon’t wait until the hardware is finished to debug your software. Our Simulators can test your program logic before the hardware is built.

No Source! A minor glitch has shown up in the firmware, and you can’t find theoriginal source program. Our line of disassemblers can help yourecreate the original assembly language source.

Set To GoBuy our developer package and the next time your boss says “get towork”, you’ll be ready for anything.

Quality SolutionsPseudoCorp has been providing quality solutions for microprocessor Problems since 1985.

BROAD RANGE OF SUPPORT. Currently we support the following microprocessor families (with more in

development):

Intel 8048 RCA 1802,05 Intel 8051 Intel 8096Motorola 6800 Motorola 6801 Motorola 68HCll Motorola 6805Hitachi 6301 Motorola 6809 MOS Tech 6502 WDC 65CO2Rockwell 65CO2 Intel 8080,85 Zilog 280 NSC 800Hitachi HD64180 Motorola 68000,8 Motorola 68010

l  All products require an IBM PC or compatible.

Cross-Assemblers as l ow as $50. 00Simulators as low as $100. 00

Cross-Disassemblers as l ow as $100. 00Developer Packages as low  as 200. 00

(a $50.00 Savi ngs)

So What Are :  Waiting For?

PseudoCorpProfessional Development Products Group 

716 Thimble Shoals Blvd, Suite E

Newport News, VA 23606(804) 873-1947

December ‘89/Januaty  ‘90    51

Page 45: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 45/78

WHY BOTHER WITH MIDI?

If you are an experienced key-board player, the attraction of MIDIhas long been obvious: A singlekeyboard can control a number ofdifferent instruments. Furthermore,peripheral equipment lets you set

up a cornagainst wKlicated   accompaniment,ich you can improvise toyour heart's  content. More recently,MIDI controllers based on guitars,violins, woodwinds, and even thehuman voice have gven   the powerof multi-instrument control to awhole new group of musicians.

Computer users with musical inter-ests but little musical experience areyet another group to have benefitedfrom MIDI.

MIDI is an asdata protocol simiY

nchronous serialar, in many ways,

to RS-232 and RS-423. Initially speci-fied to run at 19.2 kbps, MIDI’s rate

was finally set at 31.25 kbps for rea-sons of speed and electrical simplic-ity. MIDI uses a standard protocol of8 data bits, 1 stop bit, and no parity.Each MIDI event re uires that leastthree bytes be sent. 97or example, tosend the command to play a singlenote to a synthesizer, byte one carries

BRR  KF V N   E l e c t r o n i c s

7 Fairchild Ave. Plainview, NY 11803 1  516)   349-7620

19v   Battery Snap &  Holder Snap   $ .15 ea. $ .10 /100+

I Holder .20   ea $ .lO/lOO+

p zFgr>>1 lb Roll Resin Core   Stock   NO. 580005 Additional Discounts Given to Substantial Quantity Purchases.FAX your requirements - 1 (516) 349-7830 (FAX Number)

CALL OR WRITE FOR OUR FREE CATALOG.

CREATIVITY WANTEDKELVIN ELECTRONICS IS A SUPPLIER OF EDUCATIONAL

TECHNOLOGY KITS (ROBOTIC, MOTION CONTROL,

COMMUNICATION, TRAINERS, HARDWARE AND SOFTWARE)WITH AND WITHOUT COMPUTER INTERFACES. YOIJR  DESIGNS

COULD QUALIFY FOR PUBLICATION IN OUR CATALOG.

NOTRESPONSlBLEFORTYPOGRAPHlCALERRORS

L

a channel identifier and commandidentifier, byte two is thenote   value,and byte three is the velocity value.Commands to change voices (in-struments) or alter other playingparameters would be sent in simi-lar form.

In addition to synthesizers and

controllers, computers and MIDIperipherals may be used to com-plete a MIDI system. Personalcomputers are most often used ashighly capable sequencers (moreon these in a moment), music edi-tors, or composition/transpositionaids, where computer softwarecaptures MIDI signals and recordsthe note values in standard musicalnotation. MIDIperipheralsincludepatch boxes, routers, special effectsboxes, and devices for adding andsynchronizing SMPTE timing

tracks for motion picture or videowork. One of the most common pe-ripherals is the sequencer, whichacts as a performance recorder bycapturing the sequence of MIDIcommands rather than actualsounds.

Simple sequencers, such as theone presented in this article, aremost often used to record a “track”or portion of a composition that istoo complex to be played in itsentirety by a single player. In a

popular song, the sequencer willoften be used to record the percus-sion, bass, and rhythm tracks, whichare then played back to accompanythe lead instrumentals and vocals.This is a common techni ue formusicians who want to ma4, e pro-fessional-soundingdemo tapes,butwho don’t have access to a multi-track tape recorder (or large band).

More complex sequencers, ofthe type frequently executed in soft-ware on a persona1 computer, addthe function of editing.   Editin

adds the possibility of going bat  to perfect a recorded track by ad- justing one parameter at a time(“That note tig/zt there needs to bejusfaZittlelouder”),orchangingthetempo without altering the pitch orvoicing of the notes. (This is thefeature that can let you record atstudent practice tempo and playback sounding like Horowitz.) Justas a word processor can’t make youanother Hemingway, a state-of-the-art MIDI setup is no substitute for

talent. It is, however, a way to takethe talent you have and do morewith it than before.

52   ClRCUlT CELLAR NK Reader  Serbwe  X 128

Page 46: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 46/78

Simulated Reality

Sim ula ting Syste m s fo r 8057

 Deb ugg ing 

Writingfirmwareor softwareis much the same: both are a series ofinstructions that the CPU executes insequence. Debugging firmware isunique because the target system

generally does not have the full key-board, display, hard disk, or otherniceties we demand on our PCs andworkstations.

Adventure game: “you are alone in a

The software world has vapor-ware, which is mythical code for realhardware. Firmware goes this onebetter, because you often write codefor a machine that doesn’t exist. Evenwhen the target hardware is available,it usually has behavioral quirks thatturn firmware debugging into an

maze of twisty, tumy instructions, anyof which may do unpredictablethings.. .”

tions. -

As a result, no firmware de-velopment shop is complete without a

software simulator. Although thedetails vary, a simulator is basicallyan interpreter that runson your PC (orworkstation,mainframe,orwhatever),accepts executable code for the targetCPU, and simulates the effects of thatcode on the target CPU’s hardware.You can single step through the firm-ware instructions, observe CPU regis-ters and I/O ports on the PC’s screen,and change code and data on the fly tofix bugs or check boundary condi- 

; Delay for number of ticks in A

WaitTicks  PROC

PUBLIC WaitTicks

MOV   B,A ; save tick count

GetVar NETTIME ; get current time value

ADD   A,B ; tack on delay value

MOV B,A ; save for loop testing

JB   SimMode,L?dlydone   ; bypass if simulating

L?dlyrun GetVar   NETTIME ; decide if we're done

CJNE A,B,L?dlyrun

L?dlydone RET

WaitTicks  ENDPROC

Listing 1--Tim ing  loo ps c an b e b ypa ssed w hen simu lat ing. The  ‘SimMode’  b it is set only

wh en the c od e is running in the Av oc et simulator.   ‘Ge tVa r ’  is a m ac ro tha t fetches a va riab le from external RAM ; the ‘ NElTlM E’  loc at ion is inc reme nted by th e 5-millisec ond 

network t imer t ick.

FIRMWARE

FURNACE

Ed Nisley

A good simulator will maintain arecord of the CPU’s state prior to thecurrent instruction, so you can backup to discover how the system got intoits current predicament. This lets you

track down obscure bugs long aftertheir dirty work is done, because youcan stop when you see something oddand “undo” until you catch the bug inaction.

However, most simulators modelonly the CPU state and pay scant at-tention to the rest of the target sys-tem’s hardware. Some simulatorsaccept input data from a disk file andapply it to a parallel or serial input,but there are often Procrustean re-

strictions on timing and data format.More complex simulators allow youto write programs (albeit in a bizarremodeling language) to simulate tar-get hardware chips and devices, butprice tags are near the stratosphere inthis league.

So what can you do if you really,desperately, need a target hardwaresimulator onaCPUsimulatorbudget?In some cases, you can replace themissing hardware with firmware and

save a bundle. Thus the title of thiscolumn: you are simulating reality foryour code. Who’s in charge, anyway?

Depending on the missing hard-ware’s function, the requisite firm-ware can range from trivial to impos-sible. The simplest cases occur whenthe hardware generates data that canbe faked with a trivial algorithm. Themost difficult hardware to simulateproduces complex data that must beabsolutely letter perfect in both time

and content.

December ‘89/January  ‘90  53 

Page 47: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 47/78

Page 48: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 48/78

An P3.1

Byte fromtirmwae

Rn P3.0

SBUF  (write only) c_

SBUF

(read only)

Start &Stop BitIoglC

t l85Netwak

Berttthterrupt

Figure 1 -J he neiwork transceiver echoes charac ters from the 8052 serial o u tp u t b a c k  to the inpu t .   The  SWF spe c ia l func t i on reg i ster has bo th outp ut a nd inpu t uc t ion s.

it will take four minutes, which ismore than enough to demand a betterway.

Most delay loops interface withexternal hardware that isn’t present inthe simulator, so there is little value insitting out the whole loop. Listing 1shows a timing subroutine that ordi-narily delays for multiples of the 5-msnetwork timer tick, but is bypassedwhen the code runs under the simula-tor.

ThekeyisSimMode,asinglebitin

the 8051’s internal data memory. Thestartup routine clears SimMode toensure that it is OFF during normaloperation. When I run the code under

the simulator, however, it is a simplemattertosingle-steppasttheCLR   Sim-

Mode instruction and turn the bit ON.From that point the firmware bypassesall timing loops with no further atten-tion.

Using this method   has two disad-vantages: it requires a bit in the 8051’s(very limited) internal memory and aline of code wherever the bit is tested.Listing 2 shows how to use condi-tional assembly to “snip out” the de-lay loop; the code simply disappearsfromtheprogramwhentheNORMALr+ODE symbol is not true.

Butremovingchunksofyourfirm-wareshiftstheremainingcodearound

in memory; the program you are simu-lating is not the same as the programon the target system. This may haveunexpected side effects. For example,because8051 AJMP and ACALL   instruc-tions cannot cross 2K-byte   pageboundaries, other sectionsof codemaycause changes in ways you don‘t ex-pect. Indeed,if theexcisedcodemovesan AJMP to the other side of a 2Kboundary, the program simply willnot work, although the assembler orlinker should catch this problem andissue a diagnostic message.

With that in mind, I have settledon adding the s mMode  bit and a fewinstructions to my programs ratherthan deleting blocks of code withconditional assembly. Regardless ofhow you do it, make sure that youdon’t cause more problems than youcure!

TWEAKING CODES

Although EEPROM is gaining inpopularity, most firmware reads itsinitial settings from a DIP switch or

 jumper block during the startup rou-tine. Your simulator will certainlyallow you to force that input port to aparticular value, but the SimMode bitcan come in handy here, too.

For example, MC-Net firmwareon an RTC52 reads the bits of port I’1

to determine the network node ad-dress, decide if the node is a net mas-ter, and pick thenetwork bit rate. S im-Mode forces each of those decisions toa particular value so the initial set-tings are correct (or at least conven-

First byte Second byte  Tenth byte

 Trans h’Int

Send 1st byte

I  I

Send 2nd byte

I  I

Send 3rd byte

I  I

Send 10th byte

I  IDlsa  bletransmitter

Ret

Int

Note order of these interrupts!

Figure P-Althou gh the RS-485 t ra nsc eiver ec hoe s byte s sent f rom the ser ial p or t , the t ransmi t ter send s two byte s b efore the rec eiver returns the irst  one .

Decembe r 89 / J anua r y  ‘90    55

Page 49: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 49/78

Page 50: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 50/78

Page 51: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 51/78

tervalues without wasting timeon  theactual tests.

Youmightalsobypassanylengthysign-on or status messages that takeminutes to trickle out the serial port.SimMode  can bypass the code thatdisplays the messages, or you cansubstitute a shorter message to exer-

cise the code but not spend much timedoing it.Of course, you must verify the

code skipped by s imMode  at least onceduring development! The only timeyou can successfully bypass code iswhen you know it works; shooting a

bug that crops up only when you’renotsimulatingcanbeexceedinglyfxus-trating.

FIXING THE MISSING

So far, the Simbfode  bit has justskipped code or made a slight modifi-

cation of the normal data values. Youmust do more when the firmware mustmake up for missing hardware. De-pending on what’s not there, you mayneed a considerable amount of code.The MC-Net firmware for RTC52boards is a good example of this, be-

 uit Cellarwork for

Put’ INKyou.

Circuit Cellar INK readers are engineers, program-mers, consultants, and serious computer tech-nologists. Bring them into your store by selling

Circuit Cellar INK.

Circuit Cellar INK’s Direct Dealer Sales Programlets you increase your store traffic-increase yoursales-increase

 your profits withminimal risk andup-front invest-ment.

For information onhow your businesscan become part of the growing CircuitCellar INK success

story write or call: Circuit Cellar  INKDealer Sales Program4 Park StreetVernon, CT 06066

(203) 875-2199

cause it simulates the network RS485transceiver hardware and networkwiring.

The 75176 transceiver echoes alltransmitted bytes back to the receiveras well as sending them out over thenetwork. When the board is acting asthe network master, the firmware

dependson those echoed bytes to trig-ger outgoing messages. In simula-tion, of course, there is no 75176 trans-ceiver, no connection between theserial pins, and no data echo fromoutput to input.

To help you understand what isgoingon,Imustexplain how the8052’sserial ports work. Unlike IBM PCserial ports, everything happens onone chip and has relatively simplecontrol and status flags. If you’re

familiar with how the PC hardwareworks, pay close attention to the dif-ferences!

Figure 1 sketches the on-chip se-rial port hardware and the off-chip75176 network transceiver that pro-duces the echoes. This is a “big pic-ture” block diagram, so you’ll have torefer to the chip and board documen-tation for gate-level details. The 8051serial ports have a myriad of modes,options, switches, and features that

don’t apply to this discussion and thusdon’t show up in the figures.Transmission starts when the

firmwarewritesabyteintotheleftmostSBUF  special function register shownin Figure 1. The hardware shifts astart bit, eight data bits, and a trailingstopbitouttheserialoutputpin(P3.1).At the junction between the final databit and the stop bit, the TransmitterInterrupt flag goes active to signal thefirmware that the hardware can ac-

cept a new byte in SBUF. If serialinterrupts are enabled, the TI flag willgenerate an interrupt and vector theprocessor to the serial interrupt han-dler.

The firmware can set the 7’1  flagdirectly to force an initial transmitterinterrupt. While thislevel of control isforeign to PC-class machines, it pro-vides a convenient way to “kick start”the transmitterinterrupt handler. TheMC-Net firmware takes advantage of

this feature to simplify the code thatcomposes and sends messages, be-

58   C lRCUiTC ElLAR  INK 

Page 52: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 52/78

Page 53: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 53/78

to run immediately after the TI  han-dler.

The code shown will work cor-rectly as long as the transmitter isrunning, but after the last byte of amessage there will be no Tls   to triggertheRlsneededtodraintheringbuffer.

The code that disables the transmitter

after the last outgoing byte also setsthe RI flag to get that final byte out ofthe queue.

WHY A RING?

If you work through the code andfigures, you may conclude that a ringbuffer is really overkill for a two-bytequeue. True enough, but there is alesson to be learned here.

Thereisalwaysa tradeoffbetween

“quick-and-dirty“ code and a moreelegant solution. Theformermayleaveyou with several obscure lines of codethat do something that made sense atthe time, while the latter is easier tounderstand after a few weeks (days?)because it isn’t quite so tricky.

I’ve used ring buffers in severalapplications on a variety of proces-sors, so I don’t have to puzzle out howto make one work anymore. There areonly four rituals: add one byte, re-

move one byte, check for underflow,and check for overflow. In this case,the last check isn’t needed because “itcan’t happen here.” This beats havingto figure out and debug a special solu-tion for every situation.

Also, you can modify the ringbuffer to handle longer queues andmultiple sources and sinks very eas-ily. While those problems didn’t cropup here, they have in other projects!

Moral of the story: don’t always

go for the shortest solution if you valueyour time. Check your toolkit fortried and true tools before you createa new one from scratch. Then makesure it works before you make itshorter, faster, or more obscure!

One word of warning if you areadapting this code to the PC. Becauseboth the transmitter and receiver inthe 8250chip (and its successors in theAT and PS/2   machines) are double-buffered, there can be three bytes

stored in the hardware: one in the

transmitter holding register, one splitbetween the two shift registers, andthe third in the receiver holding regis-ter. You must set a flag in the trans-mitter termination routine to tell thereceiver to drain the remaining byteson its own, because there will be morethan one byte left in the ring.

THE LITTLE BUG THAT WASN’T THERE

Dependingonyourproject’shard-ware development schedule, you mayfind another use for the firmware thatgot your code running in the simula-tor: substituting for defective or miss-ing hardware in the first few “real”boards.

If you dedicate separate bits (orbytes, depending on your processor)

to control separate functions, ratherthan using a single variable as I didwith the SimMode   bit, you can turnindividual features on and off at will.Because the code really doesn’t carewhether it’s running on the hardwareor in the simulator, you can flip thebits on to bypass real hardware that ishaving a bad day.

You may need to add a simpleuser interface to twiddle the bits whilethe code is running or you can com-

pile a special version that forces aspecific bit on during the setup rou-tine. Remember to keep thingsstraight,becausethereisnothingmoreembarrassing than asking the hard-ware guys to shoot a bug when yourcode bypasses it completely!

In any event, you won’t have theexcuse “But the hardware isn’t readyyet” anymore.

Sorry’bout that...+

Ed Nisky   is a member of the Circuit Cellar INK engineering staff and enjoys making gizmos do

strangeandmndrous   things. He is, by turns a  bee-keeper, bicyclist, Registered Professional Engineer,and amateur raconteur.

IRS2 16Very Useful2 17 Moderately Useful218 Not Useful

A

M  ESSAGE   TO

su bscni bms

Circuit Cellar INK

occasionally allowscompanies which

have products or 

services of interest to

our readers to

conduct a mailing toour subscriber list. If 

you do not wish toreceive information

from these compa-

nies, your name can

be removed from the

list which we supply

to them.

To have your name

removed from the

outside mailing list,send a written

request to:

CIRCUIT CELLAR INK

SubscRibER   SEwicE

P. 0. Box 2099

Mnhopnc,   NY 

01541

6 0   CIl?CUIJ   CELLAR INK

Page 54: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 54/78

The VersatileLight-Emitting Diode

THEBENCH

Jeff Bach i o ch i

Take a look

around your envi-

ronment today andnotice the many

uses for LEDs that we

all take for granted.

The  first thing that we

see in the morning,upon being startled

out of a sound sleep,

is the face of our at-

tacker,

Four seven-segment digits daring opposition to our all-too-mechanical daily routine. Out of bed and into theshower. Feeling a bit renewed, it’s a quick pause at thescale. “Oh no, those segments can’t be right! Must be the

 battery.” Off to the kitchen now for some, “Ah, smellsgood,” coffee. An LED tattles its readiness. “Where‘s theTV remote? Here it is. Let’s see what’s on CNN thismorning.” The LED blinks wildly on the remote control asthe TV bursts into life. The rechargeable phone, themicrowave, the VCR, and almost every appliance todayhas an LED to indicate something. Power on, alarm, time,channel-the LED is our link to the electrical world.

LEDs  offer a distinct advantage over incandescentlamps and neon bulbs. They are small in size and weight,

mechanically rugged, and operate at low voltages andcurrents. They have the same projected operating life asother solid-state devices: about 100,000 hours. Improve-ments in intensity over the years have made LEDs suitablefor backlighting displays and push buttons. Status indica-tion, whether a single LED, a row, a column, or a matrix(e.g., 5x7 array> is the largest use for LEDs. Your stereoreceiver is a good example of the many configurationsLEDs   are used in. A single LED shows “power on” andtwin bar graphs (two rows of LED9 indicate the loudnessof each channel. A digital display (seven LED-segmentdigits) announces the station’s operating frequency and a

 position indicator (a column of LEDs)  shows the signalstrength.

62 CIRCUIT CELLAR INK 

Page 55: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 55/78

Page 56: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 56/78

Page 57: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 57/78

tlgures A variation on the c i rc ui tshown in FigureA  The 74HCT374s

have be en rem oved a nd rep laced w i th a ded ica ted dr iver fo r 

each row . The result is de signated ei ther a c olumn- ano de ma trix 

or a c o lumn-ca thode m at ri x , dep end ing on the or ien ta t ion o f the 

dr iver conne ct ions.

the matrix is produced with columns connecting the cath-odes, it is a column-cathode device.

The above arrangement can be multiplexed by row, bycolumn, or by both.

Figure 6-An e xpa nsion of the d esign shown in Figure 5. As ea c h 

row is seq uent ia l ly ena bled , column d ata is display ed .

When multiplexed by row, 5-bit data applied to thecolumns will create source current for any row enabled(see Figure 6).  More than one row should not be enabledat the same time or multiple rows of LEDs will light withthe same data. By enabling the rows sequentially while thecorresponding data is applied to the columns, all 40 LEDswill be addressed. If all seven rows can be sequentiallyscanned fast enough, our persistence of vision will createthe illusion that all the rows are on at the same time, whilein reality only one row is on at any given time. Current-limitingresistorsmust be placed between the five columns

Circuit Cellar  INK Gift Subscriotions areavailable for the technologically  inquisi-tive people in your life. You don’t have to

fumble with wrapping paper or fightholiday crowds, just give us a call. We’llmake sure your lucky gift recipient has afull one (or two) year subscription toCircuit Cellar INK, along with a gift cardannouncing the giver’s name and start-ing issue.To make sure the gift card arrives beforethe holidays, call 203/875-2199  beforeDecem  btir  15.

CiRCUiT C RThE Gif-r of kchNo[o iY

Cross-16 V2 0Meta   Assembler

Table based absolute cross-assembler using themanufacturer’s assembly mnemonics.

:

Check, Money Order  or P.O. US 99 00VISA, Mastercard a;iid  Canada CN 119 00

Universal Cross-AssemblersPOB 6158, Saint John, NBCanada E2L  4R6

Voice/Fax: (506)847-0681

Decembe r 89/January ‘90   65

Page 58: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 58/78

Figure 7-Still m ore b a sed on Fig ure 5. As the c olumn s a re seq uential ly ena b led , row d a ta is displaye d .

and the source drivers so that current through each LEDcan be individually controlled. If the resistors were placed

between the rows and the sink drivers, the current wouldbe divided up between all the column LEDs which areenabled. The more LEDs enabled, the lower the intensityof light from each will be.

When multiplexed by column, 8-bit  data applied tothe rows creates a current sink for any column enabled bythe column source drivers (Figure 7). No more than onecolumn should be enabled in this sequential form. Cur-rent-limiting resistorsare placed between therows   and thesink drivers.

When multiplexed by both row and column, the rowsare sequentially enabled. During the time each row is

enabled, the columns are sequentially enabled. With this

Flgure 8- rhckmcy  g oes up in relat ion to the current. This is show n a s the relative eff icienc y no rm a lized to 1.0 @ 10 mA.

form, only one LED can be enabled at a time, so the cur-rent-limiting resistors can go on either the columns or therows.

In the multiplexed row and column modes, the dutycycle for any row or column will be 1 /N , where N is thenumber of rows or columns multiplexed (l/8  for rowsand l/5  for columns). In the combination of rows and col-umns, the duty cycle for any one LED will be 1 /(R*C)  or

l/40.  Assuming an LED’s intensity is linearly propor-tional to the current flowing throughit (though, in reality,it isn’t), the current driving an LED that is on 12% of thetime must be eight times that driving an LED which is on100% of the time. In the combination multiplexed systemwhere the duty cycle is l/40, an LED would need 40 timesthe current required for a single, 100% duty-cycle LED.Maximum peak currents are roughly five times the maxi-mum average current, so without exceeding the maxi-mum peak current the device, short duty cycles will

produce dimly lit LEDs.

THE MATH

LEDs made from the same junction materials can bepackaged to produce different output effects. Dependingon the lens arrangement, the light emitted can be focusedto a rather narrow viewing angle or diffused for a wideviewing angle. The total light output from each device isthe same, yet the nondiffused LED will appear to bebrighter since its light is concentrated into a smaller view-ing angle.

In an application where the LED is indicating a statusin a latched (100% duty cycle) mode, the current-limitingresistor is figured as simply:

R = VCC-V   F

IF

where Vc,  is the supply voltage, V, is the LED forwardvoltage drop, and Iris  the LED forward current and is lessthan IFmax.

A standard T13/4 red LED operating at a typical cur-rent of 10 mA  has a light output (luminous intensity) ofabout 1.1 mcd (millicandelas). The series resistor required

with a 5-volt Vc,  would be calculated as (5-1.7)/0.01 =33OQ.   In this case, I,,, equals I,.When used in a multiplexed application the formula

is a bit more complicated:

R  =  VCC-VF

IPEAK

It is the peak current that is the mystery. If we try tomaintain the l.l-mcd output of the nonmultiplexed ex-ample, we use the following formula to find I,,:

IF*qFIPEAK*qPEAK  = TCYC

66   ClRC UlTC ELLAR  INK 

Page 59: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 59/78

Page 60: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 60/78

This simple matrix uses two 5x8 LED display modulesto create a 10x8 display. This arrangement could be usedto indicate time or temperature as an alphanumeric dis-play; as status indication of 80 individual processes; or asbar graphs displaying A/D inputs in either column or rowformat. By placing anoverlay of your home on the display,LEDs   can indicate open windows or doors or even thepresence of moving objects in each room.

Next time, I’ll discuss a bit of software used to activatethe rows and columns. Also, how the hardware might beexpanded to drive more modules using the same 8255.G

REFERENCES

Optoelectronics Applications ManualHewlett-PackardMcGraw-Hill

Opto Electronic SemiconductorsToshiba America, Inc.

Opto Electronic ComponentsGLOITE Sales Ltd.

Interface Circuits Data BookJeff  Bachiochi  Ipronounced  “BAH-key-AH-key”) is a member of the Circuit Texas InstrumentsCellar INK engineering staff. His background includes work in both theelectronic engineering and manufacturing fields. In his spare time, Jeff enjoyshis family, windsurfing, and pizza. IRS

2 19 Very Useful220 Moderately Useful221 Not Useful

 

GND   4 G ND

Two 5x8 LED Arrays

Glolite Sales (ELM-2081)__   --

RTC I/O’s I  I I I‘ . l . . . . .

__rr   B-v   F Itxbb  rrl   rot-T

 . . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

. . . . . . . .

Figure 9-LED arra ys a re straightfo rwa rd to use in mo st ap p lic at ions tha t hav e seve ra l p aral le l po rts a nd a bit of p roc essing p ow er.

68   C IRC UIT  CELLAR INK 

Page 61: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 61/78

Page 62: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 62/78

Page 63: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 63/78

Page 64: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 64/78

Page 65: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 65/78

CIRCUIT CELLAR INK’s

ADVERTISER’S INDEX

Reader ServiceNumber

101102103

104105106107108109110

l

111112113114115116

117118119120121122123124125126127128129130131

132133134135136137138139140141142143144145

146147148

l

149150151152153154

l

155156157158159

Adverti ser

Al pha ProductsAndratechAvocet

Berry ComputersBG AssociatesBig Bang SoftwareBinary TechnologiesCabbage CasesCalifornia Network ControlsCatenary SystemsCiarcia Design WorksCircuit Cellar Circuit Cellar Circuit Cellar ComputerwiseCottage ResourcesCovox Inc.DYcar  IndustrialE ectronic Energy Control

Engineers CollaborativeExpress CircuitsF&W CommunicationsG-TekGott  ElectronicsGrammar EngineHazelwoodlnnotecIntro1  CorpKelvinKolod Research, Inc.Laboratory MicrosystemsLear Corn   Company

Logical SystemsLS ElectronicsLTS/C  CarpMeredith InstrumentsMicro ResourcesMicromintMicromintMicromintMicromintMing EngineeringNOHAU CorpParadigm Systemst%r&%q c.

PseudoCorpR  & D ElectronicsReal Time DevicesRyle DesignSilicon AlleySkunk CreekSoft AdvancesTardis SystemsThinking ToolsTimelineTinneyTraxel Laboratories Inc.Universal Cross-AssemblersUnkel SoftwareWitts  AssociatesWytech Co.

HAJAR   ASSOCIATES

NATIONAL ADVERTISING SALESREPRESENTATIVES

NORTHEASTLisa D’AmbrosiaTel: (617)  769-8950Fax: (617)   769-8982

MID-ATLANTICBarbara Best

Tel: (201)   741-7744Fax: (201)  741-6823

SOUTHEASTChrista   Collins

Tel: 305)   966-3939Fax: (305)  985-8457 

MIDWESTNanette TraetowTel: (708)   789-3080

Fax:(708)

  789-3082WEST COAST

Barbara  J ones Shelley RaineyTel: (714)  540-3554Fax: (714)  540-7203

SUBSCRIPTIONPROBLEMS?

If you have problems with yoursubscription (delayed or miss-ing issues, change of address,or questions on renewals), callthe Circuit Cellar INK Sub-scriber Service Line at (914)628-0885 or write:

Circuit Cellar INKSubscriber Service Dept.

P.O. Box 2 99

Mahopac NY 10541

Page 66: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 66/78

Least-SquaresCurve Fitting

SOFTWAREby DESIGN

Juck   Gums/e

I n the August/September issue, I discussed usingconvolutions to smooth noisy real-world raw data. Judg-ing by the amount of mail I’ve received, this subject seemsto be of considerable interest to INK readers.

The method I presented was based on using convolu-tions over very small intervals to smooth and/or differen-

tiate an input waveform. The technique of Least Squareswas used to force the noisy signal to match a reasonablepolynomial curve over the interval.

The technique of least squares is often used to fitexperimental data to a polynomial. If you don’t know theformula  that relates a measured value to a desired output,it is often possible to “calibrate” the instrument by meas-uring many different samples of known values and thencomputing a polynomial that represents the relation be-tween the input and output. Confusing? Perhaps, but thistechnique forms the basis of many instruments.

I once worked at a company that used different wave-

lengths of infrared light to measure the amount of proteinin wheat. No “magic” formula exists to compute proteinin this manner, but it turned out that over a small range(say, 11 to 19% protein), a linear relation exists between themeasured light and percent protein. In other words, if fl,f2, and f3  are responses at each of three frequencies:

Protein= kO  + kl*fl + k2*f2  + k3*f3

Unfortunately, the coefficients k0 to k3  are not known,and tend to vary from instrument to instrument. Byrunning dozens of wheat samples with known proteinconcentrations and measuring thefl,f2,  andf3   values, wecould compute the k coefficients by doing a least-squaresfit of thefdata to the known protein levels.

The empirical data obtained during the instrument’scalibration is used as a predictor for future measurements;the calibration determines the k coefficients, and then theinstrument uses these coefficients and the equation tomeasure unknown samples.

Another, similar application is precision temperaturemonitors. The response of some thermistors is not linear-temperature may not bedirectly related to the thermistor’s

resistance. Some electronic thermometers operate by forc-ing the user to present known temperatures (typicallythrough a specific chemical state change) to the instrument

and letting the unit calibrate itself using a least-squaresprocess.

In effect, this self-calibration procedure is heuristic-the instrument learns from its mistakes. On initial power-up, the device is a blank slate, with the potential of meas-uring some parameter, but without the detailed “knowl-

edge” of the world (represented by coefficients of anequation) needed to do the job. Calibration to knownsamples provides these coefficients. In situations where itis impossible (or not practical) to know an absolute trans-fer function between a signal’s raw output and the valuebeing computed, using a least-squares predictor is often agood approach.

Of course, this concept of calibrating an instrumentand then using the calibration to predict new data is not themost common use of least squares. Scientists use it to fitcurves through noisy data, computing a polynomial to fitthe data and then plotting the polynomial itself (which

must be smooth), rather than the raw data points. This letsthem describe their data in a dramatic graph that is easy tointerpret.

LEAST SQUARES

All curve fitting techniques attempt to find a formulathat relates one or more inputs to a single output. In otherwords, a function f is found such that:

g=f(vl,v2,v3,...)

where g is the output and vl to vn   are input signals.The form of the function must be assumed; generally,

a polynomial is selected since practically any function canbe approximated (at least over some interval) by  a polyno-mial.

Note that this is quite different than the polynomialapproximations to trigonometric functions I presented inthe last issue. Those formulas were derivations from seriesexpansions that ultimately, if carried on to infinity, wouldyield exact solutions. Least squares is used when fittingnoisy, inexact, real-world sampled data to a value. The

noisy input data precludes an exact solution.By definition, least squares constructs a function thatminimizes the sum-square error between the measured

Page 67: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 67/78

Page 68: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 68/78

Page 69: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 69/78

don’t try to use the equation to solve for 30 picofarads. The Least squares can be a bit complicated to apply, espe-fit is often quite poor outside of the calibration range of the   cially  for the non-mathematically inclined. It is worth theinstrument. trouble, especially since the results are easy to test. If the

Finally, be careful of the number of terms used in the same calibration sample set is run through the instrumentequation. More terms yield a set of Normal equations that with the computed k values, and crazy results are ob-is harder to solve. Small errors due to noise or even the tained, there is a flaw in the code or in the selection ofresolution of the computer’s floating-point package can terms.give wildly incorrect values. (The Standard Deviation will

flag these problems). The Hilbert determinant gives arelative idea of the difficulty of getting a good solution asa function of the number of coefficients. Figure 1 lists the REFERENCES

Hilbert determinant for one to nine terms-with nineterms the equation is about lw  times more difficult to   NumericalMethods   for Scientists andEngineers,

solve than with one term. If you need a lot of terms, then R.W. Hamming, McGraw-Hill.

the use of orthogonal functions will often yield a solution Digital Computation and Numerical Methods,

that is easier to solve, and thus more accurate and depend-Southworth and Deleeuw, McGraw-Hill.

able. Orthogonal functions are beyond the scope of thisarticle, but are described in the references.

MORE OF AN ART...

 Jack Ganssle is president of Softaid a vendor of microprocessor developmnt tools. When not busypushingelectronsaround hesails upand

down the East Coast on his 35foot  sloop.

Sometimes using least squares is more of an art than ascience. Picking the right number of terms requires knowl-edge of the physics of the measurement and some experi- IRSmentation. The form of the equation (linear, polynomial,or even a combination of complex functions) must also beselected, generally using some a priori knowledge of thesystem.

225 Very Useful226 Moderately Useful227 Not Useful

68HC05 IN-CIRCUIT EMULATORTheTECICE-HC05   is a low-cost real time emula-tor for the Motorola 68HC05  family of single chipmicrocomputers. Any host computer with serialport and terminal emulation software can be usedwith TECICE-HCOS.  Base price is 1,195.00.Complete development system software is avail-able for MS-DOS computers including the ByteCraft Limited C6805   Code Development Systemwhich includes a 6805 C compiler with IntegratedDevelopment Environment.

RRb3, BOX 8C l Barton, V&mont   05822 977 South Meredian Ave.. Alhambra, CA 91903

Phone (802)  525-3458  l Fax (802) 525-3451   Tel:  (818) 57ooO58.   Fax: (818) 578-8748

PROTOTWNG  SOLUTIONWe offer the best qualitySYNTAX FR-4 prototyping PCB at the best price!

 All from the stock

. Sl   00-BUS

. TRANS   ’   Please Call Today for CatalogBOARD ‘Custom Design are Available

l UNI BOARD ‘Dealer program Offered

ReGdersewice   I41

December ‘89 January  ‘90

Page 70: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 70/78

New X- 1 O-Compatible Domestic

Products Hit the MarketAutomation

Ken Davidson A

LL

0 pen the pod bay doors, please, HAL.” Iknow. It’s a worn out cliche too often used to describe theultimate in home (or environment) control, but I couldn’tresist. I does show, however, man’s long-time fascinationwith automating his environment, making more time forleisure and devoting less time to work and toil.

As members of the forefront of computing technology,we’ve found that the typical R U T  CELLAR INK reader hasa great deal of interest in home and building automation.Many of you have automated your homes to some degree,whether through the purchase of an off-the-shelf controlsystem or, more likely, through the design and implemen-tation of a system from the ground up. Domestic Automa-tion is a new column that will appear regularly in CIRCUS

CELLAR INK and will be devoted to keeping you at theforefront of new home automation technologies and tech-niques.

CEBus

Of course, the big news in the home automation arenathese days is CEBus, the Consumer Electronics Bus. I dida complete technical overview of CEBus in the August/September ‘89 issue ( lo) of Grzurr  CELLAR INK, but let mequickly fill in those who may have missed that article.

CEBus is actually a complete home network descrip-tion based on the OSI/ISO   seven-layer network model.Devices-which can include TVs, dishwashers, lamps,door locks, draperies, hot water heaters, and so on-areconnected to the network via one of several availablemedia. Currently proposed media include power line(PLBus),  twisted pair (TPBus),  coax (CXBus),   infrared(SRBus),  radio (RFBus),  and fiber optic (FOBus).

As you go up through the layers of the network model,you slowly work from the specifics of how a message getsfrom one device to another to more general terms concem-ing just what the message means. Each layer is responsiblefor just one aspect of the network communication; it relieson the other layers to fill in the gaps. For example, the datalink layer only cares about getting a packet from one nodeto another without errors. It doesn’t care what the infor-mation in the packet means (a higher layer takes care ofthat) or how it physically gets from here to there (a lowerlevel takes care of that).

78 C IRCUIT CELLAR INK 

At the top network layer is CAL, or Common Applica-tion Language. CAL is based on tables maintained by EIAand contains commands for stereos, TVs, lamps, clocks,dishwashers, washing machines, telephones, and the listgoes on. Presumably, all lamp controllers will respond tothesameon,off,dim, and bright commandsnomatter whothe manufacturer is, making universal control possible.Similarly, all stereos will respond to the same volume ortuning commands, all VCRs to the same tape controlcommands, and so on. Of course, each device will have aunique unit number, so individual control is possible, buthaving universal commands available makes it easy to puttogether a very powerful and flexible home control systemwith separate components from a whole host of manufac-turers.

By using a layered network model, it’s possible tomake the upper layers in all devices identical, with onlyminor differences depending on which physical mediumis being used. For example, the TV and VCR may commu-nicate over coax, but the lights are on the power line.Bridges make it possible for devices on different media tocommunicate without ever knowing that they are on dif-ferent media. A very common example of a bridge EIAexpects to see isinside  the television. A hand-held infrared

Speaking of official re-leases, EIA is scheduled

to release the first work-ing specifications as wego to press (mid-Novem-her .

remote will send CEBus commands to the TV. The TV willthen retransmit those commands over coax to VCRs andother devices on the CXBus,  while it also retransmits themonto the power line for any devices connected to thePLBus.

Page 71: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 71/78

CEBus also makes two-way communication betweendevices possible. Instead of sending a command to thedoor lock to secure the door and just hope that it gets there,we can wait for a confirmation from the lock that it actuallywas successful in getting the job done. If there is a problemgetting the door closed, or the network connection to thelock has somehow been disrupted, we’ll get an error message and can go investigate further.

Enough about how CEBus works. If you want all thedetails, I’d suggest digging out issue lO  and curling upnext to the fireplace. Let’s get into CEBus’ current status.

First of all, “CEBus”  is really just a working name for the standard. EIA expects to have a new name for it whenit is officially released, but nobody has a clue as to whatthat name will be yet. After five years of calling it CEBus,I would think members would have a difficult time refer-ring to as something else, but we’ll have to see.

Speaking of official releases, EIA is scheduled to re-lease the first working specifications as we go to press(mid-November). While these won’t be the cast-in-stone

final specifications, they will be final enough for interestedparties to begin product development and are intended tobe the subject of debate among those in the industry whomight have differing opinions about how things “should”be done. After an initial “comment period,” the finalspecification will be released.

Expected to be released are the PLBus physical layer,all the higher layers (data link, network, presentation, andapplication layers), and CAL. The other physical layerswill be released in the future oneat a time as they are ready.I plan to be at that meeting and will have a full report in thenext issue. In the meantime, there will likely be some

discussion on the Circuit Cellar BBS (203/871-1988)   aboutwhat happened at the meeting, so give us a call and jumpright in.

I did make it to the August meeting of the CEBuscommittee in Boston and was both pleased and disillu-sioned by what I saw. After having worked on the CEBusspec  for almost five years now, and with the expectation of releasing PLBus and CAL in November, I had expectedcommittee discussions to focus around last-minute minor details and finishing touches related to those two areas of the specification. Instead, I was greeted with presenta-tions by committee members proposing entirely new

methods and concepts for both the high-level languagelayer and the physical layer. Fortunately, common senseprevailed and some useful work was done toward havingsomething ready for the November release based primar-ily on past work, but somemajor issues still needed resolv-ing, especially in the PLBus camp. Things should beinteresting in the next few months.

x-10

The folks at X-10 haven’t exactly been sitting around,either. Veteran INK readers will remember the articles I’ve

done in past issues about computer interface modules andan IRgateway fromX-10  (Issues 3,   5,  and 9).  The latest

Radio Shack and Heathkit  catalogs yield some interestingnew products.

Radio Shack will be carrying the infamous momentarycontact module. Those who closely follow X-lo’s productswill remember hearing about the momentary contactmodule quite a while ago. X-lo didn’t seem tobe able to gettheir act together enough to get the thing made. Now itmay actually become reality. Judging from pictures and

descriptions (no, I haven’t been able to get one, either), theunit will close a pair of dry contacts and/or sound a built-

The most interesting ad-dition to both Heath andRadio Shack’s productlines is a complete home

security system based onX-10 modules and RFtransmitters and receiv-ers.

in speaker when addressed, depending on how a switchon the module is set. Another switch controls whether theclosure is momentary or latched. We’ve heard from a

number of people on the BBS who have modified appli-ance modules for similar operation, but we’ll finally havea unit that does it for real. One real-world use for such amodule that many people have suggested is in triggeringa garage door opener, where a momentary push of a button is what’s needed.

Along these same lines, Heath lists a “Sensor Chime”module that does nothing but sound a “pleasant chime”when activated. Might be nice to use in conjunction witha home control system that also functions as an alarmsystem. When the system has been armed, it could sounda chime to signal that you have sixty seconds to vacate the

area. By the same token, upon returning home, the chimecould signal a warning that you only have thirty secondsto get the alarm disabled before the big guns are broughtto bear.

Another unit that Radio Shack is selling for the firsttime this year (which Heath started selling several monthsago) is a pair of flood lights with a built-in motion detector.Before you say, “Big deal, those are all over the place,”realize that this one also transmits X-10 commands over the power line so lights inside the house can also be turnedon in response to outside motion. Used in conjunctionwith the two-way computer interface module I discussed

in issue 5  (the TW523),  your home control computer canalso be made aware +ha+  there is motion outside and that it

Decembe r ‘ 89 /January  90 79 

Page 72: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 72/78

should be alert for possible trouble (or can trigger someother response such as a voice from a speaker).

A unit similar to the IR gateway mini controller Idiscussed in issue 9 is being sold by Heath that has aphotosensor in it. When it gets dark out, the controller sends an “on” command onto the power line (presumablyto a lamp module). When it gets light out, the controller

sends an off command. Like above, this controller could beused with the TW523 module and a home control com-puter to tell the computer when it’s darkout  and when it’slight again.

The most interesting addition to both Heathand  RadioShack’s product lines is a complete home security systembased on X-10 modules and RF transmitters and receivers.There is a master unit that has an X-10 transceiver, RFreceiver, speaker, and indicator lights on it. Attached todoors and windows are sensors that send signals onto thepower line when they are tripped. Finally, there is a hand-held RF transmitter used to enable and disable the alarmsystem. With the system disabled, a soft chime sounds

when one of the sensors is tripped and the LEDs  on themaster unit show the sensors’ status. When the alarm isenabled and is tripped, a loud siren sounds and lights areflashed for four minutes. Let’s just hope those powerglitches that like to occasionally wreak havoc with X-10modules don’t wake your neighbors (and you) in themiddle of the night some time.

And the future...

That about does it for this issue. Future plans includecomplete coverage of the November release of the CEBusworking specification, any new CEBus-based   productsthat may be slated for release to coincide with the releaseof the spec,  a nifty hand-held infrared remote control that

should have a good deal of appeal to the home automationexperimenter, and anything else   you want to see. Drop mea letter or send me a message on the Circuit Cellar BBS withideas, suggestions, or pointers to new products that havecaught your eye. Plus, if you’ve implemented some formof automation in your home that you think others wouldenjoy reading about, tell me about that too.+

Ken Daoidson  i s the managing editor and a member of t he Circuit Cellar INK

engineering stufi  He hol ds a B.S. in comput er engin eeri ng and an M .S. in 

computer science from Rensselaer Polytechnic Institute.

IRS228 Very Useful229 Moderately Useful230 Not Useful

ID160 161

*lo0  MHzm o d e l f o r $749l 50 MHz Sampling Speedl 8K   trace buffer 

l Multi-level triggeringl 32-channel capability

l Event Timer/Counter l Performance Histogramsl Hardcopy output l Disassembles B-bit microsl and much more l Satisfaction Guaranteed

INNOTEC DESIGN, INC.P.O.Box   3304Cerritos, CA 90703-3304Tel: 714-527-8540 FAX:714-527-1812

Reader%wice  x1:

  Create Professional Oualitv  Circuit Diaarams  with

MarSchematic  is a libraryof over 800 Electrical andElectronics symbols for professional quality circuitdiagrams on the Mac.

Symbols are in bothPICTformat for MacDraw,

MacDrafl,  or other CAD/Draw programs and inMacDraw II libraries,

MacSchematic  symbolsare object oriented for superior printer, plotter and laser output. Theycan be resealed without

losing their high resolution.MacSchematic  symbolsare designed to snap togrid so their externalconnections fall on gridpoints and lines connectto symbols “on the dot”.

Includes symbols from ANSI Standard Y32.2:

   Analog Components  Gates/Digital Devices*  Industrial Wiring*  Ladder Diagrams

Not O V   Protected

 6

Thinking

Symbols shown at 50% Reducbon. Baltimore, MD 21217

8 0 CIRCUIT CELLAR INK 

Page 73: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 73/78

CONNEC-TIME

Exc e rp ts from fhe Ci rcu i f Ce l l a r BBS 

The Circuit Cellar BBS300/  1200/2400  bps24 hours/7 days a week

 203)   871-1988Four Incoming Lines

Vernon, Connecticut

Conduc t ed by 

Topics that we’ll be covering in this issue’s ConnecTimeinclude emergency cut-off switches, waveform conver-sion, and switched-capacitorfilter design. In this first dis-cussion, wefind  that hardware isn’t always the basis for all

message threads on the Circuit Cellar BBS; software rearsits ugly (?) head at times, too.

Msg :22701From: MARVIN GOLDBERG To: ALL USERS

I have written a program to display a large graphic file (230K).

This program is written using Turbo C v 2.0 and is being used onI’S/2   Model 50 with VGA. The following function receives a lineof data at time from the file and then displays the image on thescreen, one line at a time. It performs as expected except that itis very slow. I have the feeling that this function will performfaster if written in assembler language. Is it possible to replaceany or all of this function with in-line assembler code using theTurbo Assembler? If so, I would be grateful to see what this codelooks like since I am not too handy with programming assembler code.

void put_line(line_no,but)   int line-no;char *buf;

1register int i;unsigned int offset;   /” x coordinate of data in line */i=512; /* size of buffer */offset=O;

while(&)

( putpixel(offset++,line_no,*buf++);

1

Msg :22702From: STEVE SAMPSON To: MARVIN GOLDBERG

You might try using the _read()  function, and also setvbuff) and  Anyone who has ever worked with an alarm system knows

make the buffers larger, say 1024 for a start. Before you go off into that there is afine line between a system that is so sensitiveassembler. The problem as I see it is that the disk access is going that false alarms become a problem and one that isn’tto be the slowest item. It might be better to drink in a compressed sensitive enough to pick up trouble. The same applies for

file completely and then uncompress and display the result. Idon’t think assembler will help with disk access speed. remote emergency cut-off switches, as the next messagethread shows.

Msg :227l7From: NATHAN ENGLE To: STEVE SAMPSON

Another thing to do is to use the “++”   construct as a prefix rather than as a postfix (i.e., ++i rather than i++). It wouldn’t necessarilysave that much in CPU time, but it does evaluate faster since the

evaluated value of ++i is the same as the value of i AFTER incrementing (which is already in the primary evaluation regis-ter). When you use i++ you make the compiler backtrack and putthe old value in that register (just because of the way expressionsevaluate in C).

A good optimizer can spot places where you compute somethingand never use it, so a lot of crud like that disappears when youturn the optimization switches on maximum.

Msgt:22754From: ED NISLEY To: MARVIN GOLDBERG

One thing you can do is combine the loop counter and pixel offsetinto a singlevariable. Right now you’re doing two arithmetic op-erations per iteration; cut one out!

 Next, you can use a block move (of the memcpy flavor) to flasha whole line into the buffer given the starting address. That getsrid of the C-level iteration and is really going to be the biggestwin.

 Next, snag a 32K buffer (using malloc)  and suck in huge gulps of the file. If the pels are all contiguous in video memory (whichthey will be if you’re in VGA native mode and not doing win-

dows or some such), use memcpy (or some such) to block movethe whole buffer.

I suspect that’11 give you a 100x speedup.   ..time it and report back!

82 Circuit Cellar INK 

Page 74: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 74/78

rom: ROBERT MEUSHAW To: ALL USERS   MsgX:24142From: JEFF  BACHIOCHI To: ROBERT MEUSHAW

am need of a wireless remote control transmitter and receiverwhich can be used in a factory environment to send an emer-

ency cutoff signal to a machine. The control action must be veryeliable (since it is for emergency use) and it should have a rangef at least 100-150  feet. I have considered the use of RF, infrared,nd ultrasonic. Obviously, they must work in a noisy (electrical

nd sound) environment.

Ken’s suggestion of a constantly transmitted OK is a good one. Itis much easier to shut a transmission off than rely on one gettingthrough! Although it prevents more than one user from stoppinga life-threatening situation.

Msg :24220or simplicity, it seems that infrared has an advantage, but it maye too directional and short range for this application. I am con-idering using a Motorola encoder (MC145026) to provide data tohe transmitter, and using a Motorola decoder (MC145027)  torocess the received data. The transmitter must be small enough

o keep in a pocket. The receiver size is not critical, and it can bemounted almost anywhere, including high above the machine.

or RFcontrols   I would prefer preassembled modules which cane integrated with other machine controls, since RF devicesenerally seem tricky to build and use reliably. However, I

would consider construction articles if they are relatively fool-

roof. I am mainly interested in simplicity of design and in con-truction. Any suggestions would be greatly appreciated.

From: ROBERT MEUSHAW To: JEFF BACHIOCHI

The machine that I’m interested in stopping has several normalcontrols for that purpose. Generally what happens is that themachine gets jammed and must be cleared. The remote shutoffis just a convenience that the operators might use if they are notnext to the machine when it jams. For this reason, I’m not sure I’dwant a loss of carrier to stop the machine. The nuisance factormight keep operators from wanting the system at all.

Msgk24219From: ROBERT MEUSHAW To: DALE NASSAR

rom: DALE NASSAR To: ROBERT MEUSHAW

Thanks for the reply. I tried one of those cheapo   transmittersfrom Radio Shack, and the range was insufficient. Do you knowof any others that might work?

would feel a little shaky using IR for an emergency cut-off at 150eet. You may want to consider using a DTMF signal sent overne of those 49-MHz EM transceivers. The transmitter could beard wired so that the push of a momentary  button sent the signals well as turned on the transmitter. The things are about the sizef a cigarette pack and are about $50 each at Radio Shack.

MS@24233

From: DALE NASSAR To: ROBERT MEUSHAW

You may have tried the “toy” versions. The better ones that I haveused have easily given me a range of >500  feet. When you said

“emergency cutoff,” I may have wrongly assumed that thesituation was not life threatening. Because you were consideringIR,  I assumed that you just wanted a secondary cutoff.

rom: BOB PADDOCK To: ROBERT MEUSHAW

or a fail-safe system, you should look for the loss of a signal,nstead of trying to detect a signal. It is far better to have a fewrroneous shut downs for whatever reason (receiver died, trans-

mitter battery when dead, the service center took the antenna offecause it was in the way of servicing the receiver, etc.) than to hithe *PANIC* button and have nothing at all happen, while

watching the machine grind one of your coworkers to bits.Paranoid, perhaps, but it just might be me standing between the

wall and the machine.)

  vent hemost esot en cr equest  willoftengeta   responseor a pointer to where an answer can be found. Here, a user islooking fo r a waveform output.

Msgk23187

From: MICHAEL CAVANAUGH To: ALL USERS

rom: KEN DAVIDSON To: ROBERT MEUSHAW

don’t think you’re paranoid, Bob. As I was reading the originalmessage and the first reply, I was thinking exactly what youwere. I would try setting up a low-power RF transmitter thatransmitted continuously, with the press of a button cutting offhe transmission. After having worked with a number of IR-ased devices, I wouldn’t trust my life to IR, and certainly not at50 feet. I think the biggest problem to solve at that point is the

ower source. You’d likely have to put the unit on a charger eachight.

I am in need of a chip to convert a DC voltage (either 6 or 18 VDC)to two sinusoidal waveforms as an output. The two outputs mustbe90 degrees out of phase (sin and cos) and 16 volts peak-to-peak(&8 volts). They must also be at 250 Hz. A 6-VDC square waveat 250 Hz is available as an input to clock the output. Any ideaswill be greatly appreciated.

Msg :23290From: DALE NASSAR To: MICHAEL CAVANAUGH

The square wave you have along with the fixed frequency canmake things simple for you. If you filter the square wave with a

December ‘89lJanuary  ‘90 83

Page 75: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 75/78

low-pass filter you can obtain the fundamental component whichis a sine wave of the same frequency. If you pass this through asimple op-amp integrator (inverting), the output will be a cosinewave (same frequency). If this output is then passed throughanother inverting integrator, the output is the negative sine (youcan pass this through an op-amp inverter to get sine). Use a quadop-amp such as the TL084. 1  did a one-page article in Radio-Electronics describing how to filter out the fundamental sine froma square wave (April 1988, page 77). It also described how to

make the frequency and amplitude controlled independently,each with a single pot-a feature I found to be hard to obtain in asimple circuit, which is why I wrote the article.

Msg :23483From: MICHAEL CAVANAUGH To: DALE NASSAR 

Sounds like a good idea. If I run the square wave through a low- pass filter, what should be the cut-off frequencies? I will use thefinal waveform outputs to provide excitation to several resolvers,so I may need to use some type of power op-amp to drive this typeof load. I will play with your idea on the breadboard and see what

shakes out.

Msg :23670From: DALE NASSAR To: MICHAEL CAVANAUGH

The fundamental sinusoidal that you want to filter from thesquare wave (it is SQUARE??) is of the same frequency as the

 A rugged CABGGE  CASE? lined withplenty ot foam for your equipment  canTAKE A LOAD OFF YOUR MIND

when you’ve got to travel.

TAKE A LOAD OFF YOUR BACKwith our exclusive  tilt-wheelsand extension handle option.

UNLOAD ON US!Call or write to tell us about your shipping   or carrying problems

WE HAVE SOLUTIONS!

CABBAGE CASES, INC.

I  166-C STEELWOOD ROADCOLUMBUS, OHIO   43212-1356(614) 486-2495   (600) 888-2495

Readerseme   lo8

64 Circuit Cellar INK

square wave. Op-amp filters will work, but I have foundswitched-capacitor filters less troublesome. For high-input-impedance buffers you can try an op-amp configured as a direct-input voltage follower.

Speaking of switched-capun’torfilters,  the next discussionactually covers two topics.The first deals with switched-capacitor  filter design, while the second addresses a prob-lem most electronics experimenters face at one time or another: where to find hard-to-find parts.

Msg :23175From: MATTHEW TAYLOR To: ALL USERS

I am considering using a switched-capacitor filter (like the MFIO)

as the low-pass filter for a 12-bit   A/D converter. Has anyoneworked with these filters? Is clock noise a problem? Does

anyone know of any higher-order switched-capacitor filters?

Also, as a student, I have never dealt with any parts distributorssuch as Arrow, Hamilton/Avnet, Pioneer, etc. Do they frown ondoing business with individuals? I realize they have minimumorders, but could anyone please elaborate on what I shouldexpect? I am trying to get some parts that Jameco, JDR, and Digi-

Key don‘t carry.

R&D ELECTRONIC SURPLUS, INC.Has been in business since 1946 selling NEWsurplus electronics and electromechanical parts.

Send for our FREE40 page catalogue detailing:

Batteries   LEDs

Cables LugsCapacitors   MOVS

Clocks   Ni Cads

Connectors Power DevicesDigital TimerKontrollers many Power Supplies

Diodes RelaysDisplays   SemiConductors galore

Enclosures Stepper Motors & Driver ICsFans Speakers

Filters Many SwitchesHeat-Shrinkable tubing Telephones and components

Heatsinks TransformersIntegrated Circuits Ultrasonic Transducer Board

Lamps Lights Zeners  many more items

Fij lB  ~: J~: ;;;;

Telephone: (216) 621-1121 l Fax: (216) 6214628

  eader  w ice   +147

Page 76: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 76/78

Msg :23313

rom: PAUL SHUBEL To: MATTHEW TAYLOR From: MATTHEW TAYLOR To: JAMES D STEWART

Arrow puts out a catalog for mail-order electronic parts. Theminimum order is $25.00; they take credit cards. I have orderedrom them with no problem. The nice thing about buying chipsom them is that you know that they will be factory fresh. Theirrder hot line is l-800-932-7769.

heir catalog contains chips and all different electronic parts andomponents. They will probably send you a catalog if you callnd ask. A while ago they promoted this catalog through theingo cards. To anyone else interested, they actually carry the0% family and most TI chips including the elusive TMWOxx.

Ditto for Allied Electronics, phone l-800-433-5700.

rom: JAMES D STEWART To: MATTHEW TAYLOR

he MFlO  will work great as a low-pass filter on an A/D or D/

A. I’m using them on two of my designs in this way. Just makeure that the sample frequency and the filter clock frequency areerived from the same oscillator. If you use two different oscil-

ators, you will get horrible beat frequencies in the audio. Inerms of dealing with the big parts guys, tell them you are a littletart-up company and that you will pay COD. They will treat you

OK. Also, don’t be afraid to ask them for samples and data sheets.

I was hoping the MFlO   would work. I don’t really like wiring uphigh-order filters: boring and tedious. Not that carrying 16address lines throughout a wire-wrapped project is any joy. :-)

Are your designs digitizing audio? I’ve built several audio

pmcessorsusing 8-bit data converters and asignetics   cornpander(to help with the dynamic range). The results were less thanthrilling, but the designs worked. I’ve since learned a lot aboutreal world designs that NONE of my EE books (or professors)have ever mentioned. This next design will *NOT’  have theanalog and digital portions of the circuit living on the same wire-wrap board!

If you have time, I would love any advice you could offer onkeeping things quiet in an analog/digital system. How do youtest your designs? I am planning on doing the analog section ona breadboard with a ground plane and probably wire-wrappingthe digital section. Sound OK?

Msg :23333From: JAMES D STEWART To: MATTHEW TAYLOR

My designs digitize audio to 10 bits, run the digital data throughan OK1   ADPCM processor chip, and store the resulting four bits

Still BlastROMs? ’

Develop and testROM code in minutewithout leaving yourwith the GE1  ROMemulator

Ask us about faster (than 150ns)ROMemulators   and custom cables for most non-Zlxxx  ROM sizes.

 immm r

 

G~iunmar  Engine, Inc

 

3314 Morse Road

Columbus, Ohio 43231614/471-1113“EA  Wd Mastercard  kcepted In Paafic  and Mountain tmezones:Dealer  1nqumes  Welcome 415/595-2252

  X124

Files Lost in the Z-Environment?

 NSURVEY T is the file name cataloging programfor the Z-System where a file can be in any of 32directories.

 NSURVEY keeps a database of file name, disk iden-tification, directory, length and CRC for every file.

 NSURVEY allows searching the database on anyfield; wild card characters permitted.

 NSURVEY edits the database to allow removing olddisks.

 NSURVEY allows a list of exclusion names to specifywhat files, or class of files, are not added to database.

 NSURVEY can operate from a control fide to allowautomating unique-to-the-directory operations.

 NSURVEY comes with 24k of documentation in both print and .HLP  formats.

 NSURVEY combines all updating, searching, andediting functions into one program that totally man-ages the file name database.

For CP/M 2.2, CP/M 3 ZCPR3 Z-Systems.

$28.95 + $4.00 S+H

December ‘BP/J anuary  ‘90 85

Page 77: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 77/78

Page 78: Circuit.cellar.012.Dec.1989 Jan.1990

8/13/2019 Circuit.cellar.012.Dec.1989 Jan.1990

http://slidepdf.com/reader/full/circuitcellar012dec1989-jan1990 78/78

. ..And Everything in its Place

ertainly I should be the last guy in the world thatwould have any complaints about current technology andinvolvement of computers in our lives. I mean, after all,aren’t I Mr. Embedded Controller?

I didn’t get upset when I found myself “negotiating”proper cooking times with a 4-bit computer-controlledmicrowave oven. My blood pressure doesn’t even go up anotch when the new FM stereo WON’T let me listen to my

favorite station because ITS computer-controlled program-ming has decided that the low signal strength of my stationisn’t worth locking onto! “Having a mind of its own”takes on a new meaning with today’s technology).

For what it’s worth, however, I am coming to a slowburn over the computer control systems in cars. Have youlooked under the hood of a car recently? Surely it is nolonger the province of a grease-covered mechanic but, arewe to substitute a plumber, electrical engineer, physicist,or a computer programmer whenmaintenanceisrequired?

My latest hot rod is high-tech German steel. The car isa wonderful evolution in performance and control but,

like most new cars, it can be a nightmare of pushbuttonsand computers. When you get in it the first time you spendabout 2 hours programming the “central computer” withthe time, mileage alert thresholds, seat positions, radiostations, wiper speeds, mirror positions, and assortedother electrical stuff. The oneitem  I dared not program wasa multi-digit alarm code which enabled the ignition sys-tem when you entered the car. Entering the wrong codeput the car out of commission for a half hour. (I  had alreadylost the argument with my home stereo so I was gun shy).

Coexistence with this marvel of technology was fineuntil I decide to take the car for a spin and the battery wasdead.Thecarhadbeensittingin thegaragefor3 weeksandthe battery was dead! I charged the battery, reprogram-med everything and then shut the car off Just for curiosity

STEVE’S

OWN

INK Steve Ciufciu

L

The landing was hard but my German steel survivedwith flying colors (quite exhilarating actually). Unfortu-nately, the engine started missing and I started loosingpower. Thinking the worst, I limped into the dealershipand pulled into one of the service bays. Three technicians,responding to the emergency,dragged  sophisticated diag-nostic equipment and electronic probes to the car. My carsoon looked like an octopus of electronic cabling.

I related the travel incident to the technician monitor-ing the central diagnostic console. He shook his head andpointed at the display, “Ze computa   is ded! Four cylinda isverking! Four cylinda is capute ”   The parts manager pipedin, “I can get you a new ignition control computer in abouta week.. . Cost about $3000 Are you gonna need a rental?”

As I was about to fall on the floor in grief, the servicemanager showed up. He silently walked around the sput-tering car, looked at the diagnostic displays, and lookedunder the hood at the badly vibrating engine. Next hepicked up a piece of scrap wood and walked back to thecar. To our amazement he took the wood and hit under the

passenger-side dashboard. The engine jumped RPM for aninstant and then sputtered. The service manager bentdown under the dash, took the piece of wood and jammedit up behind the glovebox. Instantly the engine roared tolife and the red flashing lights on the diagnostic panelswent to green. He just smiled and said, “Loose connector.”I just felt like hugging the car.

Even though I made it home safely, I was left with adilemma. Does living with a high-tech car mean having anextension cord hanging out of the engine block and a 2x4braced against the computer? Is all this computer stuffnow so complicated that service personnel think only toreplace the whole system rather than understand and fix aproblem?

The success of microprocessors in toasters and appli-