EDITOR’S English: INK

The Forgotten Language? Ken Davidson

I s the English language really so obscure that people have should have been caught early on. However, since he didn’t seem given up trying to use it correctly altogether? Granted, English is to be able to anything else wrong, I think two bad words out one of the difficult languages to learn due to its endless of the thousands in the issue isn’t half bad. He could have a field exceptions to rules. It’s usually more important to get your idea day with some other publications I see on the newsstand each across than to get all the parts of the language correct. My month. frustration stems from my recent observations of some so-called I don’t expect our authors to be able to write prize-winning “editors” that can’t even catch a spelling mistake let alone bad articles; I certainly can’t. I also don’t want to discourage anyone punctuation or grammar. from submitting an article because they don’t think it’s good Werecently started the search for additional staff editors. All enough; it can be massaged into something we can all be proud that we’re asking of these people is that they be able to read a raw of. What I would like to encourage, though, is that when writing manuscript; fix spelling, punctuation, and grammar; and convert a piece, have someone else look at it to see if it even makes sense. any “engineerese” into readable English. As part of the interview Run it through the spelling checker on your word processor for process, we’ve been giving each applicant a test consisting of two obvious blunders. The more subtle things can be fixed later. of the new product releases being used in this issue, and asking them to fix any mistakes they find. In addition to the problems A FAREWELL already contained in them, I doctored each release with some specific mistakes that I was interested in. The results have been, Why are we hiring new editors? The answer is twofold: we frankly, disappointing. need someone to an already overworked staff, and we Most of the applicants had some form of English degree and recently lost our editor-in-chief, Curt Franklin, to another experience in at least technical writing; many had some editing (noncompeting) publication. Curt came to us three years ago background. Virtually everyone missed one or more blatant when CIRCUIT CELLAR INK looked like something a bunch of spelling mistakes, and the vast majority of them missed many of engineers had thrown together (because that’s what it was). With the planted punctuation, grammar, and usage mistakes. There his guidance, CIRCUIT CELLAR INK has developed into a highly were even typos in some of the resumes and cover letters we regarded journal read and enjoyed both by engineers in some of received (we didn’t call those people back). Luckily, we had a the finest companies all over the world and by those who simply handful of people that did fairly well, so we should be in good have a love of tinkering with computers. Curt will be sorely shape when it comes to make some offers. missed, but life goes on, and we plan to continue to bring you a I learned a long time ago while corresponding on computer- first-class publication destined for the reference shelf after being ized conferencing systems that, regardless of what someone had read cover to cover. to say, if the message looked like hell-full of spelling and punctuation mistakes-that person came across looking less intelligent than he probably was. We see it all the time on the Circuit Cellar BBS, though no one corrects anybody since we are more interested in what people have to say than in how they say it. We also, unfortunately, see it in article manuscripts as well, where it is more important. That’s why we need the editor-one who can fix the things that very few of the applicants have been able to fix-in the first place! I’ll be the first to admit that there are mistakes between the covers of every issue of CIRcurr CELLAR INK. No matter how many pairs of eyes look at each article, something always slips by. We just received a diatribe from an irate reader pointing out two mistakes in a recent issue. One was in usage, the other in capitali- zation. I was, of course, embarrassed when I saw them, since they

October/November 199 1 1 FOUNDER/ EDITORIAL DIRECTOR Steve Ciarcia MANAGING EDITOR THE COMPUTER Ken Davidson ENGINEERING STAFF APPLICATIONS Jeff Bachiochi Ed Nisley JOURNAL CONTRIBUTING EDITORS Tom Can trell Chris Garcia

NEW PRODUCTS EDITOR A Video Editing Control System-Part 1 Harv Weiner 16 The Hardware EDITORIAL ASSISTANT 0 by William J. Kressbach Lucy Tralongo The key to a successful video editing session is coordinating the two tape decks. Part 1 of this controller project describes the hardware end of doing just that. ART DIRECTOR Lisa Ferry Computer Graphics and the World of PRODUCTION MANAGER Scientific Visualization Mark Vereb 026 by Chris Ciarcia The days of wading through reamsof printed data are fading fast. Chris Ciarcia STAFF RESEARCHERS: shows us the basics of putting those stuffy numbers into motion. Northeast John Dybowski Midwest Add a Video Display to Your 8031 Jon E/son Graphics and Color Liven Up Any Output Tim McDonough 40 by Larry Duarie West Coast q Tired of hard-to-read, cryptic LCD displays? Find out how to easily add video to Frank Kuechmann your next controller project. Circun Cellar BBS-24 Hrs. ZOO/ 12W2400 bps, 8 bii. no parity, 1 stop bii. (203) 871-1988; 9600 bps HST (203) 87 1 Gd9 ISDN (S/T) Interface-Part 2 Design Example of a PC Plug-in Board All programs and schematics 46 in CircuR Cellar INK have been 0 by Seven E. Strauss & P.K. Govind corefuliy reviewed to ensure that We finish up our ISDN Interface description with a sample implementation. their performonce is in accor- dancewiththerpe&iiotLLnsde- scribed. and programs are posted on the Circuit Cellar BBS forelectronictromferbywbscrib- ws. Circuti Celbr INK maker no warranties and assumes no re- sponsibility or liabilii of any kind for erron in these programs or schematics or for the conse- quences of any such errors. Fur- OrCAD Schematic Design Tools thermore. because of the pos- sible vatiin in the qualii and A Working Engineer’s Impression condition of rnateriik and work- 60 manship of reader-assembled 0 by Bruce Webb projects. Circuit Cellor INK ds- Schematic capture is quickly becoming a necessity in any design claims any resporwiblii for the engineer’s toolbox. Find out what one engineer thinks of OrCAD as he uses it in safe and proper function of reader-assembled projects his everyday labors. based upon or from plans, de- scriptions, or information pub- lirhed in Circuit Cellor INK. Entire contents copyright Q 1991 by Circuit Cellar Incorpo- Schematic Capture with Schema rated. All rights resewed. Repro- duction of this publication in by Ken Davidson whole or in part without written Schema Is another schematic package that has been around for a number of consent from Circuil Cellor Inc. is prohibited. years. Managing Editor Ken Davidson has been using the software in his own design work and fills us in on his opinions about It. Cover Illustration by Robert Tinney

2 CIRCUIT CELLAR INK PUBLlBHER Daniel Rodrigues Editor’s INK PUBLISHER’S English: The Forgotten language? ABSlSTANl 1 Susan McGill q by Ken Davktson CIRCULANON COORDINATOR Rose Manse/la Reader’s INK-Letters to the Editor ClRCUlATlON ASSlSTANT Barbara Males&i

ClRCUlATlON CONSULTANT Gregory Spitzfaden NEWroductNews BUSINESS MANAGER Jeannette Walters ADVERTlSlNG COORDINATOR Firmware Furnace Dan Go&y 70 (Re-) Starting C cl by Ed Nisley HAJAR ASSOCIATES NANONAL ADVERTlSlNG REPRESENTATIVES

From the Bench NORTHEAST Redefining Remote Control Debra Andersen Now You See ‘em-Beep-Now You Don’t (6 17) 769-8950 Fax: (617) 769-8982 by Jeff Bachiochi MID-ATLANTIC Barbara Best (908) 74 1-7744 Silicon Update Fax: (908) 74 l-6823 86 Nuts About RISC SOUTHEAST cl Go on CY low-Fat Acorn Diet Christa Collins by Tom Cantrell (305) 966-3939 Fax: (305) 985-8457 MIDWEST Nanette Traetow Practical Algorithms (708) 789-3080 Measuring Subjective Sound levels Fax: i708j 789-3082 by Chartes P. Boegli WEST COAST Barbara Jones & Shelley Rainey (7 14) !540-3554 ConnecTime-Excerpts from the Circuit Cellar BBS Fax: (714) 540-7103 Conducted by Ken Davidson CIRCUIICELLARINK0SSNO89~ 8985) ls publkhed bimonthty by CircuBCelbrlncorporated.*Pork Street. Suiie20,Vernon.C1060&5 (203) 875-2751. Second-clos~ Steve’s Own INK posfage paid at Vernon. CT and cddiiinol offiies. One-year (6 The Circuit (Storm) Cellar inues)subscriptionroteU.S.Aand by Steve Ciarcia possessix& 7.95.canodo/Mex- ice $21.95. 011 other countries $32.95. Allsubscrtptiinorderspoy- ableinU.S.fundsonh/.viointemo- tionol postal money order or checkdrcnvnonU.S.bcmk Direct subscription ordento Circuit Cel- lar INK. Subrrtptiora. P.O. 6oX 305&C. Southeastern, PA 19398 Advertiser’s Index 0rco11(215)63&1914. POSTMASTER: Please send 97 cddrerschangesto CircultCelbr l-l INK, Circulotiin Dept.. P.O. Box 305GC. Southeastern, PA 19398.

October/November 199 1 3 1 READER’S 1 INK -1 Letters to the Editor STANDARDS HOTBEDS extension is then called at its entry point just after this signature to perform initialization. The POST can’t mark a I seldom write a letter like this, but Steve’s editorial in ROM, nor change any location in an extension it finds. the August/September (#22) issue of CIRCUIT CELLAR INK In addition, the ROM bootstrap does read in the first is more than I can resist. It says, “Standards happened.. . by sector of a disk. In the case of a floppy, this is the actual committees made up of competitors and large users, each bootstrap code that attempts to locate and read IO. SYS with a particular axe to grind and no strong motivation for and MSDOS . SYS. However, on a hard disk that has mul- real standardization.” Later, you remark (almost ruefully) tiple partitions, this first sector contains the partition table that you have never served on a standards committee. and another small program that finds the active (bootable) You should fall to your knees and thank God that He disk partition and then reads the actual bootstrap code spared you that horrible experience. In my lifetime I’ve from that partition, which is then treated like the first served on two. The most recent was an I.F.A.I. subcommit- sector of a floppy disk. The partition table processing teeof the S.A.E., and I do not exaggerate when I say that the precedes the actual bootstrap process, but it must happen antics of most of the other members almost drove me in order for the real disk bootstrap to occur. insane. Things degenerated to the point where I was In the section “Tablesand Routines,” you reference the actually heckled in technical presentations. All because a device header in Figure 2 as being 18 bytes. However, in small minority wanted the S.A.E. to adopt without modifi- Listing 1, the B-byte device name is only initialized to cation a test procedure issued by I.S.O. that could be shown "DRVR- 0 “, or 7 bytes. by theory and data to be worthless. Conversations with In the section “Assembling the Driver,” you decided others who had served on such committees convinced me to name your handler "DRIVER(. ASM)," which compiles that they are, almost without exception, hotbeds of politi- and links to "DRIVER. SY s", a unique name if I ever heard cal infighting. one! Unfortunately, back in the old days when Microsoft and IBM poured the concrete around MS-DOS, someone Charles Boegli had the brainy idea to name the one and only device driver Blanchester, OH that anyone would ever need to have, for use on hard and floppy disks, as-you guessed it-DRIVER. SYS, and not some more descriptive name like HD. SYS or FD. SYS. Now here you are with your own device driver and what do you call it? Later on you refer to “DRVR” which is at least a little more unique. DEVICE DRIVER NITS A little later, you warn us to “...keep a system disk handy” in case the driver code locks the keyboard out. Of I just received the August/September (#22) issue of course you mean a bootable floppy disk, but some people CIRCXJIT CELLAR INK and read Chris Ciarcia’s “Using De- may not realize this, and this disk needs to have sufficient vice Drivers to Change the Rules.” I enjoyed it very much. files on it (like a text editor) to allow you to edit the hard Based upon my knowledge gained from reading such drive’s CONFIG.SYS and AUTOEXEC.BAT filestotempo- publications as ‘The MS-DOS Encyclopedia,” I think there rarily remove the commands that loaded in the driver and are a few inaccuracies in his article. These are based upon caused the system to lock up. In addition, if you happen to my familiarity with MS-DOS Version 3.3, however. have a hard drive configuration that requires a device In the section “From The Top,” you explain how the driver to access extended partitions, your safety disk must BIOS ROM searches for extensions and “...marks them have this software on it as well. A safer, and more easily with a unique byte sequence which identifies them as recoverable, method is to put your new driver onto a ROM.” I believe that each ROM starts with a unique bootable floppy disk, insert that disk into drive A, and “55AA” signature that is verified by the POST. Each such reboot the computer. This has several benefits, one of which being if the system locks up, you only have to open “The Best 8051 Emulator” thefloppydrivedoorandrebootthesystemtobringitback up. In addition, you can configure the floppy disk such that it never accesses the hard drive, offering some level of protection in case the driver happens to write data some- where. A floppy disk is a lot easier to reconstruct and certainly more disposable in case something goes wrong. Granted, your driver does so little, nothing can go wrong, but someone else may write a more sophisticated driver some day. I may be “picking nits,” but such a fine magazine and PCbased

Dettmann, (Que Corp., Carmel, Indiana) where it says: 302 N. Winchester l Olathe, KS 66062 l 913-829-0600 l 800-255-3739

October/November 199 I 5 “The ROM bootstrap routines now read the diskboot- my mind is not a bad idea. Unlike Mr. Meister, I feel that strap code from the first sector (the boot sector) of the boot most of you are computer literate readers. I believe you all disk. The bootstrap code is a minimal-services routine know what I mean. As to whether or not one uses the hard responsible for getting the system up and running. The disk or a floppy disk environment for driver development, ROM bootstrap routines check all bootable disk drives for that’s entirely up to you. I don’t write drivers on a daily the presence of a boot sector on the disk. On a hard disk basis. I needed to use my Microsoft assembler and its system with a single floppy disk, the ROM routines first debugger. That was installed on my hard disk, not a check drive C and then drive A. If no boot sector is found, floppy* an IBM PC transfers control to ROM BASIC and starts up a diskless system; PC compatibles prompt you to insert a Chris Ciarcia system disk and wait for you to press a key. Los Alamos, NM “When a bootstrap record is located, the ROM boot- strap loads it into high memory, away from where DOS itself is loaded. Control is then transferred to the disk bootstrap routine. “After the bootstrap code has been loaded and has control, it looks back to the disk to locate the files IO. SYS We Want To Hear from You! and the MSDOS.SYS." I felt it was sufficient and appropriate within the Write letters of praise, condemnation, or suggestion article’s goal and context to condense the above descrip- to the editors of Circuit Cellar INK at: tion into two sentences. If Mr. Meister feels that this was inappropriate, I invite him to submit an article detailing Circuit Cellar INK these procedures for us. I personally would enjoy learning Letters to the Editor more about this aspect of the boot phase. 4 Park Street Now as to the rest of Mr. Meister’s comments, I admit Vernon, CT 06066 that I find myself slightly put off. The fact that I used seven of the available eight bytes for my device driver name Circuit Cellar BBS: ‘editor” seems a “nit point.” And “keepinga system disk handy” in 1’ q

EXPRESS CIRCUITS

MANUFACTURERS OF PROTOTYPE PRINTED CIRCUITS FROM YOUR CAD DESIGNS TURN AROUND TIMES AVAILABLE FROM 24 HRS - 2 WEEKS

Special Support For:

l TANGO. PCB l FULL TIME MODEM l TANGO SERIES II

l TANGO PLUS l GERBER PHOTO PLOTTING

l PROTEL \ d l WE CAN NOW WORK FROM l PROTEL EASYTRAX % * YOUR EXISTING ARTWORK BY l smARTWORK SCANNING. CALL FOR

l HiWIRE-Plus DETAILS!

l HiWIRE II

l EE DESIGNER I Exm-ess

l EE DESIGNER III quotes: Circuits - l-800-426-5396 l PADS - PCB 314 Cothren St., PO. Box 58 Phone: (919) 667-2100 l ALL GERBER FORMATS Wilkesboro, NC 28697 Fax: (919) 667-0487

Reader Setie #145 6 CIRCUIT CELLAR /AK NElAPRODUCTNEWSNEl/VPRODUCTNEWS

COLOR CRT CONTROLLER ON STD BUS

A color graphics CRT not CPU controller, based on ’s dependent and HD63484 ACRTC (Advanced can be used CRT Controller) graphics with either &bit processor, has been an- or 16-bit Intel nounced by Cubit. Using and Motorola high-level commands, the microproces- Model 7050 controller sor-based CPU offloads much of the graphics boards that handling load from the main meet the STD system CPU, leaving it free bus specifica- for other tasks. tion. The 7050 supports up to More than three screens with 640 x 480 20 graphic resolution. It includes 4 Mbits drawing commands, includ- in both Borland Turbo C++ Cubit of video RAM and is compat- ing LINE, RECTANGLE, and assembly language, and 340 Pioneer Way ible with VGA, EGA, and POLYLINE, POLYGON, a complete set of alphanu- Mountain View, CA monochrome monitors. CIRCLE, ELLIPSE, ARC, merit characters. The board 94041-1577 Sixteen colors from a range of ELLIPSE ARC, and PAINT does not need a DOS operat- (415) 962-8237 40% may be selected, and 16 are made available by the ing system since Cubit’s Fax: (415) 965-9355 shades of gray can be ACRTC. Memory manage- library provides the neces- displayed on monochrome ment for split screens, sary code. Reader Sercive #501 monitors. Both digital and zooming, and scrolling are The Model 7050 CRT analog monitors are sup- also supported. Controller sells for $490.00 in ported through Brooktree’s Cubit provides a library single quantities. RAMDAC chip. The board is of software routines written

MICROMINIATURE CCD CAMERA

A microminiature solid-state CCD video camera, featur- CCTV Corporation ing a unique Microelectronic Shutter has been introduced by 315 Hudson St. l New York, NY 10013 CCTV Corporation. The “GBC” CCD300 system allows the (212) 989-4433 l Fax: (212) 463-9758 Sensor itself to compensate for all light changes, eliminating the need and cost of the traditional autoiris lens. Unlike a tube- Reader Service #502 camera, there is no lag, burn in, or image retention. Measuring 2.38”H x 1.38”W x 4.38”L, the 0.75-pound unit can utilize both “C”- and “CS”-type lenses. It operates from low voltage (7 to 12 volts DC) and comes standard with a 120-volt AC-to-low-voltage DC power module. Full video can be achieved with light levels as low as 2 lux (0.2 footcandles). Resolution is in excess of 350 lines, both at the center and corners. The CCD300 features adjustable gamma, automatic black level, built-in image enhancer, mirror image reversal, and switchable auto/manual gain. The automatic gain control has a range of 1000 to 1 (four f- stops electronically within the camera). The light compen- sation is a minimum of 10,000 to 1 electronically and there is no geometric distortion. No price was available at press time.

10 ClRClJlT CELLAR INK NElA/PRODUCTNEVVSNEl/VPRODUCTNEWS

TINY CONTROLLER BOARD INCLUDES DESIGN TOOL FEATURES

An 8051-based single-board controller for data collection, embed- ded control, and product design applications has been announced by Blue Earth Research. The Micro-440 uses a 12-MHz Intel 83C51FB, which includes advanced features such as high-speed I/O, three 16-bit timer/counters, multiprocessor communications, a Boolean processor, and a watchdog timer. Measuring 1.89” by 2.25”, the 6-layer board is manufactured using double-sided surface-mount technology. Time- and date-based operations are managed by the real-time clock/calendar module. The module features a 12/24-hour , automatic leap year setting, and interrupt output periods ranging from l/64 second through 1 hour. For measuring analog inputs, the on-board &bit ADC can convert signals ranging from 0 to 5 volts in less than 40 microseconds. The eight input channels can be programmed for single-ended or differential operation. Available I/O includes 14 TTL/CMOS-compatible I/O lines, dual RS-232C serial ports with activity LEDs, and a low-power shutdown feature. CPU bus connections are also available for adding memory or other peripherals. The Micro-440 can be powered from any 6- to 16-volt DC source capable of 75 mA (7 mA in standby). The on-board regulator provides a stable +5 volts (fl%) to internal circuitry and includes a CPU reset feature. An optional 3.6-volt lithium battery maintains RAM data and clock operation for more than 10 years. Available evaluation units include the controller board, back-up battery, and two 25-pin D-shell connectors, assembled and installed in a protective plastic housing. A complete system design package includes the Evaluation Unit; Macro Assembler, Symbolic Debugger, and Utility programs; comprehensive manuals (llOO+ pages), plug-in type DC power supply, applications development module; and serial interface cable. Also available are Intel’s PL/MSl compiler and Franklin Software’s C51 compiler in value-priced packages that include the Micro-440 evaluation unit and accessories. The Micro-440 sells for $99, in quantities of 1000. The Evaluation Unit sells for $199, and the System Design Package is $379.

Blue Earth Research

310 Belle Ave. l Mankato, MN 56001 l (507) 387-4001 l Fax: (507) 387-4008 Reader Service #5@3

HIGH-RESOLUTION video tape, or live broadcast. printed on a laser printer. are easily included in such IMAGE CAPTURE The image is captured with a With the super VGA packages without the expense BOARD resolution of 512 pixels by display, the 256~gray-level and limitations of a desktop 488 lines with 256 shades of picture rivals black-and- or hand-held scanner. Supervision/l6, a video gray. The resulting picture white TV broadcast quality, The Supervision/l6 image capture system for the can be displayed on any VGA as the eye can detect no package includes interface IBM PC/AT family of monitor in the 320 x 200 x 256 digital artifacts at this level. card, software on disk, computers, is available from mode. The picture displays as The of display has no owner’s manual, and one- IDEC Inc. The Supervision/ 256 x 200 with 64 shades of bearing on the quality year warranty. The Supervi- 16 package consists of the gray. since the printed image is sion/16 costs $369.95 in IDEC frame grabber and Many super VGAs are printed directly from the disk single quantity. software for image capture. supported to allow viewing file image, not from the The software and of the images in 640 x 480 x screen as with most screen IDEC, Inc. hardware is fully compatible 256 mode with the image capture utilities. 1195 Doylestown Pike with all IBM-style AT-type displayed as 512 x 480 with The image is captured in Quakertown, PA 18951 machines and allows the user 64 shades of gray. The image l/30 second and is stored in (2 15) 538-2600 to capture video images from can be adjusted for contrast TIFF or PCX format for direct Fax: (2 15) 538-2665 any standard RS-170 video and brightness, stored to and use by many desktop source, such as a camera, retrieved from disk, and publishing packages. Pictures Reader Service #5&l

October/November 199 1 11 lVEVVPRODUCTNEWSNEVVPRODUCTNEWS

graphic adapters are supported, but VGA or super VGA is recommended. The EDC-10OOHR uses a fra(me-transfer CCD image sor configured into 244 lines with 754 elements in each line. The imager can be operated in either interlaced or noninterlaced mode. Features include: computer-controlled exposure time, frame scanning time, and subarray scanning; asynchronous scanning (external triggering of frame reset and scan); and pixel data collection rates of one megapixel/second (3 to 5 frames per second in live mode). Output from the imager is an 8-bit digital signal corresponding to the quantized value of brightness at serially sampled spatial data points. TIFF and PCX file images can be saved for use by image processing and desktop publishing packages. The EDC-10OOHR digital, asynchronous camera and HIGH-RESOLUTION ELECTRONIC IMAGER computer interface card operate entirely under the control of the PC, collecting image data via the PC bus in parallel. Upon Electrim Corporation has announced the availability of a a command from the PC, image exposure takes place and 256 high-resolution version of their EDC-1000 solid-state electronic gray level image data is read directly into the computer’s imager. The EDC-1000HR gives the user the ability to directly RAM. digitize images at up to 754 x 488 pixels. The EDC-1000HR is a The EIX-1OOOHR sells for $850. compact, digitally controlled, digital output television-like monochrome camera. Electrim Corporation

The EDC-10OOHR is fully compatible with an IBM PC XT/ P.O. Box 2074 l Princeton, NJ 08543

AT or equivalent and does not require a frame grabber or (609) 683-5546 l Fax: (609) 683-5882 other third-party hardware or software. All popular IBM PC Reader Service #505

PC-Based Logic Analyzers 8031 CONTROLLER BOARDS

A&T: $129 - Partial kit: $70 - PCB Board kit: $25

l 11.0592 MHz clock l 8/16 K EPROM socket l 8132 K RAM socket l MAX232 serial I/O Sophisticated Logic Analysis l Two 20-pin expansion headers a’, Unsophisticated Prices l Monitor, application notes ID160 (50 MHz) for $695 & support software included *ID161 (100 MHz) for $895 EMC32 Board (3” x 4”) *SO MHz or 100 MHz Sampling l 8K Trace Buffer l 32-channel 9 Accessories available Operation *Multi-Level Triggering *State Pass Counting *Event Timer/Counter *Performance Histograms *Hardcopy A&T: $80 - Full kit: $62 - Partial kit: $36 Futput *Disassembles popular &bit micros *and much more ! 30 Day Money Back Guarantee INNOTEC DESIGN, INC. L.S. ELECTRONIC SYSTEMS DESIGN 6910 Oslo Circle, Suite 207 2280 Camilla Rd., Mississauga, Ont. L5A 2J8 Canada Buena Park, CA 90621 Phone/Fax: (416) 277-4893 Tel: 714-522-1469 FAX:714-527-1812 Terms: Shipping USICanada $6. Check or Money Order please.

12 CIRCUIT CELLAR INK

I NElM’RODUCTNEWSNEM/PRODUCTNEWS

9-BIT EMBEDDED CONTROL NEWORKING SYSTEM

An asynchronous g-bit Hitachi’s HD64180 and microcontroller serial data communications HD641016, and Texas networks. network using the built-in Instruments’ TMS7002/7042. The only modes in many popular The hardware interface is hardware embedded controllers has made possible by the NBS-10 necessary to been announced by Cimetrics asynchronous serial commu- transform an Technology. The system nication card for the IBM PC/ embedded (which consists of the NBS-10 XT/AT or compatible controller into a controller and NSF’ software) machines. The NBS-10 network node is is based on the serial commu- performs g-bit asynchronous a single RS-485 nications modes first used in serial communication in both transceiver and the Intel 8051 embedded full- and half-duplex modes, pull-up resistor. A minimum documentation are included control processor. Industry and allows for the construc- configuration consists of a with the toolkit. support of the g-bit mode has tion of networks using either controller with RS-485 trans- The NBS-10 is priced at continued to expand and two- or four-wire configura- ceiver and no external RAM. $249 and the g-bit Software many companies have tions. It also incorporates Software support is Protocol is priced at $199. introduced embedded several features that aid the provided by Cimetrics controllers with this feature. designer in networking Technology’s g-bit Software Cimetrics Technology Processors capable of applications including Protocol (NSP). This toolkit 120 West State St. supporting this standard flexible output switching and includes source code to run Ithaca, NY 14850 include: Intel 8051 and bias configurations. The NBS- the network, monitor (607) 273-5715 8O%BH, Motorola’s 10 is designed specifically as network activity, and Fax: (607) 273-5712 MC68HC05 and a master, slave, or develop- perform data transfers. MC68HC1621, ’s 2180, ment tool for p-LAN g-bit Complete source code and Reader Service #507 Total control m Designed for Embedded Systems, Byte-BOS Real-Time Multitasking is complete and well tested. With over with LMI FORTH’” 80 robust functions, much of the development is done for you. Ibr Programming Professionals: an expanding family of compatible, high- J Fast Pre-emptive Scheduling performance compilers for microcomputers is enhanced and tested 4 Direct Inter-Task Communication with your favorite “C” J Multiple Event Synchronization For Development: development systems. Just 4 Timer Services t Auto Sampling Interactive Forth-83 Interpreter/Compilers J Resource Management for MS-DOS, OS/2, and the 80386 open the box and start coding your application. J Asynchronous Communication l 16-bit and 32-bit implementations J Fixed Block Memory Management l Full screen editor and assembler 4 Low Power Management l Uses standard operating system files m Written in “C”, l 500 page manual written in plain English BOS has an assembly l Support for graphics,floating point, native code generation kernel tuned to each Intel 8051 8018W86 8096 Hitachi 630113 64180 H8XXX For Applications: Forth-83 Metacompiler supported MCU -- and Mitsubishi 37700 880113 68HCll 683Xx l Unique table-driven multi-pass Forth compiler that includes full Motorola NEC All “V” Series l Compiles compact ROMable or disk-based applications on chip serial I/O TI TMS 320 C2WCF.X l Excellent error handling and timer support. IBM PC 80X86 DOS Compatible l Produces headerless code, compiles from intermediate states, and performs conditional compilation l Cross-compiles to 808O,Z-80,8086,68000,6502,8051,8096, m BOS code written 1802,6303,6809,68HC11,34010, V25, RTX-2000 and tested on the PC transfers l No license fee or royalty for compiled applications directly to any BOS . Just fl Laboratory Microsystems Incorporated recompile, link, load, and go. Post Office Box 10430, Marina de/ Rey CA 90295 Phone Credit Card Orders to: (213) 306-7412 FAX: (213) 301-0761

Reader Service X 117

14 CIRCUIT CELLAR INK NEIAPRODUCTNEWS

INTERACTIVE SCHEMATIC CAPTURE AND DIGITAL SIMULATION SOFTWARE

DesignWorks, from Capilano Computing Systems Ltd., combines the power of Apple Macintosh graphics with a friendly user interface to simplify schematic entry and simulation. DesignWorks can write net list, simulation, and graphics files in a variety of standard and user-definable *TEXT EDITOR, CROSS ASSEMBLER, AND formats to facilitate transfer to other systems. The integrated COMMUNICATIONS FACILITY IN A COMPLETE schematic entry and digital simulation allows detection of INTEGRATED DEVELOPMENT ENVIRONMENT design errors before they are wired into hardware. l MACROS DesignWorks makes full use of the Macintosh l CONDITIONAL ASSY us g4;.95 l LOCAUAUTO LABELS multiwindow environment, allowing any number of circuit * SYMBOL TABLE CROSS REF files open simultaneously and full Cut//Paste editing l S OR HEX FILE OUTPUT DOWNLOADS pLus S’H* operations between circuits. Multipage schematics are fully TO MOST EPROM PROGRAMMERS supported with page connectors and interactive simulation across pages. Device and signal dragging with fully interactive AVAILABLE FOR MOST 8-BIT MICROPROCES- and orthogonal rubberbanding reduce editing time. SORS AND 680001010. CALL OR WRITE FOR Pull-down menus and an on-screen tool palette provide TECHNICAL BULLETIN. 30 DAY MONEY BACK quick access to all program functions. Modeless operation GUARANTEE. MCIVIAE. provides immediate access to any program function at any Micro Dialects, Inc. * PER SHIPMENT: time without moving through hierarchical menus. DEPT. C, PO BOX 30014 Control devices such as switches are active right on the $5 CONTIGUOUS USA $10 CANADA AK, HI CINCINNATI, OH 45230 diagram, and can be changed in state to observe their effect on $20 INTERNATIONAL (513) 271-9100 the simulation in progress. Probes and numeric displays can also be placed directly on the schematic to observe signal ader sewice # 173 value changes. Any selected signals can be displayed in the form of a logic-analyzer-style timing diagram. The diagram is updated continuously to reflect design and parameter changes. DesignWorks has complete symbol drawing and library maintenance capability, allowing the rapid creation of new devices. The “AutoSym” feature will generate a standard rectangular symbol given only a list of input and output pins. For simulation purposes, any circuit can be associated with a symbol to allow the creation of fully functional custom devices. Libraries of these custom devices can be maintained to suit project requirements. The DesignWorks Report module allows full customization of text report formats, eliminating tedious file translation or manual modifications. Report formats include net lists by signal or device, bills of materials, signal lists with simulation event data, and signal and device lists with graphical data. DesignWorks is compatible with any Macintosh with two megabytes or more of memory. The absolute maximum circuit size is 32,767 devices, although drawing and simulation speed limits circuits to 500 to 5000 devices depending on computer model. DesignWorks sells for $995.00.

Capilano Computing Systems ltd. 1168 Hamilton St., Suite 501

Vancouver, B.C. l Canada V6B 2S2

(604) 669-6343 l Fax: (604) 669-9531

Reader Service #508

see us al The Embedded sysfm cmfenmce Boolh x404 October/November 199 1 15 FEATURE ARTICLES A Video Editing Control System

A Video Editlng Control The Hardware System-Part 1

1 I m what’s known in the video and then add on to it with new seg- business as a free lance. I produce ments. You “assemble” by appending videos for people who need them- additional segments onto the end of usually industrial customers. Once in each previous segment. Because you’re Computer Graphics a while I get a call from someone who’s assumed to have started with a blank and the World of interested in getting into the video tape, you have to record both the video production business. I have to tell and the audio tracks when doing an Scientifk Visualization them that off-the-shelf consumer edit. camcorders are fine for recording wed- Although assemble editing re- dings and special events, but if they quires you to add onto the end of a want to get into more professional program, you still can go back and productions, the cost of the equip- change the picture and/or sound by ment they need can be overwhelming. using the second type of edit, called an Professional editing recorders start at “insert” edit. When you do an insert Add a Video Display about $8000 and go up rapidly from edit you have to use a video tape that toYour - - there. Even a small system can ap- already has stable video recorded on Microcontroller proach numbers that can make your it. You then insert new segments onto head spin. But if you can find yourself the tape in the required location. In- some used equipment, a soldering sert editing allows you to choose any iron, and a little imagination, you can combination of audio and/or video. set yourself up with an editing system You can “cut-in” and “cut-out” as that rivals the ones that broadcasters needed. Most editing is done in the use. insert mode. ISDN (S/T) Interface- Before I take you on a tour of my Why can’t you just go ahead and editing controller, let me first fill you use insert editing on a blank tape? Part 2 in on what it takes to edit video tape. Well, the television picture consists of If video editing brings to mind some- a seriesof lines “painted” on the video body with razor blades and scissors, screen from left to right and top to you’re living in the past. We don’t bottom. Each frame of video is di- even do that with audio tape much vided into two fields. One of the fields anymore. Today, editing is basically a consists of the odd scan lines and the copying process. Picture and/or other the even lines. Each of these sound from either a source VCR or a fields is completed in l/60 of a sec- camera is copied onto a destination ond. This makes for a video frame rate VCR in the order needed to produce a of 30 frames per second. The VCR finished program. marks each field by recording a pulse on a separate track called the control BUILDING A PROGRAM (CTL) track. It then uses these pulses as a reference during playback. When There are two types of editing: an insert edit is made, new picture is assemble and insert. With assemble recorded but the old control track is editing, you start with a blank tape left undisturbed. The control track and build a program by copying seg- must be continuous or an unstable ments. You record the first segment, picture will result.

16 CIRCUIT CELLAR INK FEATURE ARTICLE Part 1 , Wllbm J. Kressbach

If the edit is to be “clean” and with the vertical sync from the incom- EXAMPLE EDIT glitch free, it must occur in the short ing signal. time between frames: the vertical in- It’seasytosee thatboth thesource Let’s look at an example. Take the terval. The vertical interval is the time and destination video must be stable simple shot sequence given below of a when the TV picture has completed before a glitch-free edit is possible. striking a nail. one frame but isn’t quite ready to While the record deck is responsible start the next. This means that the for ensuring that the “cut in” and the 1. ms (medium shot) hammer vertical interval of the incoming sig- “cut out” edits are clean, it’s still the poised to strike nail-hammer nal must be in the same place at the user’s responsibility to see that the swings same time as the signal coming from tape is up to speed and in the right 2. cu (close up) nail as hammer the tape. Fortunately, the VCR doing place for the edit. strikes the editing is smart enough to do this While limited editing can be done 3. ms hammer raises for you. It adjusts the speed of the manually, the precision necessary to drive motor until the vertical sync get good edits, every time, where you To keep it simple, let’s assume coming from the tape is synchronous want them, requires careful control. that the source of the picture is a cam-

October/November 199 1 17 era. The scene calls for a medium shot on open-reel recorders, I would often RELAY of a hammer poised to strike a nail, use a yardstick to measure out the INTERFACE takes to a closeup as the nail is struck, length of tape for the preroll. and then back to a medium shot of the Other than avoiding hammers, hammer going back up again. what can we do to help this situation? While the scene calls for three Well, to accomplish editing with any shots, it’s probably best accomplished kind of precision requires some sort of in two. It’s easier to take one complete computerized controller. A number shot of the hammer striking the nail of inexpensive controllers exist that and then going back up. After that use the pulses on the control track of shot has been completed, we’ll go back the VCR as a reference. While this and insert the close-up of the hammer works reasonably well, marking the striking the nail. The source is a cam- edit locations is pretty much hit-and- era so the first shot is easy to do, but miss. Also, shuttling the tape back inserting the close-up can be tricky. and forth causes the CTL head to miss WI-16 RELAY INTERFACE ...... $ 89.95 Hold your finger on the edit button pulses. It doesn’t take very long for and put the tape in play. When the the reading to be off by several frames. tape gets to the right place press the This type of controller works well if edit button, hit the nail, and then press you don’t make any mistakes and can RH-8 RELAY CARD the cut-out button. If you’re lucky, hit the nail on the head every edit. EX-18 EXPANSION you’ll get it on the first take. But, sup- pose you miss the nail or, worse yet, HITTING THE NAIL ON THE HEAD hit your thumb. This means that you’ll DIGITAL have to go back and do it again (if you A better method is to design a hit your thumb, you’ll probably have controller that is locked in some way someaudio to fixas well). When you’re to the frame rate of the video tape. We doing edits manually, it’s impossible can do this by assigning each frame of to hit the edit at exactly the same loca- video a unique number and then re- tion as the previous one. The only cording that number onto one of the thing to do is try to start the edit just a audio tracks of the tape. little before the last one and end just a Let’s see how this is done. The little after. It doesn’t take very many CTL signal is available on the remote retakes for the small insert to grow control jack on the rear panel of the enough in size so that the whole scene VCR. Dividing the CTL pulse by two CONNECTS TO RS-232 will have to be redone. Too much of (remember, one full frame of video for &DC-16 (16 channel) $ 99.95 nput temperature, voltage, amperage. pressure. this and your head will throb as much every two fields) serves as a reference energy usage. energy demand. light levels, joystIck novement and a wide variety of other types of analog as your thumb. for the assignment of time code. jlgnals. Inputs may be expanded to 32 analog or 126 status Inputs usmg the AD-16 or ST-32 expansion Frames of video are assigned time :ards. 112 relays may be controlled usmg EX-16 sxpansion cards Analog Inputs may be confIgured for HITTING A MOVING TARGET codes sequentially from the beginning emperature Input using the TE-6 temperature Input :ard. RS-422 available PS-8 port selector may be used of the tape to the end, with the CTL o connect satellite ADC-16 Interfaces (up lo 4,096 analog inputs/l6,384 status inputsil4.336 relays, use If the source video is tape, it be- pulse marking the start of each frame. 18-232 for satellites up to 50 feet or RS-422 for jatellltes up to 4,000 feet). comes much more difficult. Now not A time code consists of hours, min- [terminal block and cable sold separately) ST-32 STATUS EXPANSION CARD . ..$ 79.95 only do we have two tapes to get up to utes, seconds, and frames, and looks Input on/off status of relays, switches, HVAC equipment. thermostats, secwty devices, smoke speed, but wealso have to see to it that something like “0O:OO:OO-00.” As each %?tectors and other dewes. The ST-32 provides 32 status Inputs. (opt0 Isolators sold separately) each picture is in the right place at the frame of video passes by, its time code TE-8 TEMPERATURE INPUT CARD 5 49.95 Includes 8 solad state temperature sensors. right time for the edit. The only way to is derived, converted to an analog sig- Temperature range IS minus 70 to 145 degrees F do this is to rewind both the source nal, then recorded on a spare audio - FULL TECHNICAL SUPPORT...prowded over the telephone by our staff. EACH ORDER INCLUDES A and destination machines to a point track (note that sometimes time code FREE DISK WITH PROGRAMMING EXAMPLES IN BASIC, C AND ASSEMBLY LANGUAGE. A detalled several seconds before the edit point. is encoded into the vertical interval). technical reference manual IS also Included. - HIGH RELIABILITY...engmeered for continuous 24 This is called a preroll. As each ma- This is called “time coding” or “strip- hour industrial appllcatlons. All IC’s socketed. - Use with IBM and compatibles, Tandy, Apple and chine reaches this location it’s put into ing a tape.” Once a tape is time coded, most other computers wth RS-232 or RS-422 ports All standard baud rates and protocols may be used pause. When both machines have it becomes a simple matter for a con- (50 to 19,200 baud). reached this pause point, they both troller to read it back. This gives you - Use our 800 number to order free mformatlon packet. Techmcal InformatIon (614) 464-4470. are started at exactly the same time. the ability to locate any frame on a 24 HOUR ORDER LINE (800) 842-7714 Then, if you’ve done everything right, video tape with precision. Visa-Mastercard-American Express-COD11 pressing the edit button at exactly the A lot of commercial editing con- ELECTRONIC ENERGY CONTROL, INC. 360 South Fifth Street, Suite 604 right time will give us a good edit. trollers are available, but like most of Columbus, Ohlo 43215

Years ago when I first started editing the equipment in this business, the Reader Service Xl41

October/November 199 1 19 I I I I I I I I I I I I I I The “To Tape” and ‘“From Tape” signals needaddifionalcondi- Coning between the mntrollerandthetape decks. Since such cwditioning depends on the tape deck be- ing used. it is impos- sble lo present a cir- cuit here that would

Figure 1 - Ihe video edtor controller is based on modules that use the venerable Wag ZB m/crocontroller. cost is prohibitive. For that reason, utilize the extended memory feature host as well. There are four lines for and because it was kind of fun, I de- of the 28 giving me extra input ports communication: three for the serial cided to build my own controller. without adding extra decoding logic. I/O, and one for bus arbitration. A My early attempts to build a con- I added a UART for a second serial controller wishing to use thebuspulls trollerusingdiscretecomponentsand port, and, of course, I used the ma- the transistor low, signaling the other a Radio Shack Model III computer chine language version of the 28. modules that the bus is in use (more met with some success but it had lim- The time code is recorded at 2400 about this later). The control modules ited portability and required a lot of bps. It begins with a marker byte (A5h1, are designed to have the capacity of processor time. Often, a VCR would and ends with a checksum. While it’s allowing up to 14 modules on one go into a fast rewind and the com- not compatible with industry stan- serial port, but I’ve never tried more puter, reading the control track on an dard time code, as long as you don’t than two. I did this to allow for pos- interrupt line, would ignore me until need to use your tapes on a profes- sible use in automated systems where I could stop the VCR manually. sional reader, it’s not a problem. several VCRs might be necessary. All I finally solved the problem of The controller does most of the communicationisfrommodule to host processor time by using a dedicated leg work. It time codes the tape and or from host to module. The modules controller for each VCR. I was already thenreadsitbacktoyou.Itkeepstrack cannot talk to each other. on my third computer and was con- ofthecurrent tapeposition,whatmode Each controller is locked to and is templating my fourth. So, portability the VCR is in (rewind, fast forward, in complete control of the deck to also being a factor, communication etc.), and conveys user commands to which it is attached. The parallel ports through a serial port seemed the way the VCR. It can search for and find any of the 28 are able to read the status and to go. The ZilogZS controller answered location on a tape and then either play remotely control all necessary func- most of those needs. While it only had the tape or wait for a user command. It tions of the VCR such as play, rewind, one serial port, it was available, inex- can preview an edit; that is, simulate fast forward, cut-in, cut-out, and so pensive, and I could afford the cross- an edit so that the user can see what it on. In general, the same port on the Z8 assembler I needed to program it. will look like. It will then perform the serves not only to trigger a VCR mode, edit and review it for you. but to read VCR status as well. For NAILING DOWN A DESIGN There is one controller module for instance, configuring port 2 pin 1 for each of the two editing decks. They input reads the status of the VCR’s Figure 1 shows the basic design are daisy-chained through the serial play LED. Configuring the same pin forthecontroller.It’sprettymuchstan- ports. Eachmoduleisaddressed sepa- for output and then strobing it low dard with one exception: I used a 7402 rately and listens in on a party line for puts the VCR into the play mode. Be- for address decoding. While this is a messages designated for it. The mod- cause of this, the controller is able to bit unconventional, it allowed me to ules a common line back to the follow the VCR status even when op-

20 CIRCUIT CELLAR INK erated manually. Figure 2 shows a list reset, and incrementing continues sent, the module will only transmit of the commands to which the module from the control track. information that has changed since will respond. As it’s reading, the module also the last update. Most transmissions The control track pulses are used transmits the current tape location to are short and consist only of frames. to follow the tape location when the the host computer. The module first Serial communication from the tape is in rewind, fast forward, or is sends an ID code (nC hex, where n = module takes place through a ring reading a tape that has not been time module number) so that the host will buffer. It has an “in” and an “out” coded. When the VCR is in the play know what is coming and where it is pointer. The software increments the mode and the module is reading valid coming from. See Figure 3 for a listing in pointer as it moves information in. time code from the tape, the software of module response codes. The mod- As the information is transmitted, it sets a flag telling the counter to ignore ule then starts with frames and increments the out pointer. Transmis- the control pulses from the VCR. If, progresses through seconds, minutes, sion continues until the in and the out however, the module doesn’t get a and hours. It ends the transmission pointers are the same value. The small valid read after three pulses, the mod- with a terminator (ODh). In order to memory capacity of the 28 requires ule assumes it has lost lock, the flag is minimize the amount of information that the buffer size be kept to a mini- mum. Usually there is plenty of buffer space but, when a VCR is in rewind or MODE 1 COMMANDS 4A = Insert Edit FF=fvfode3Off fast forward, so much information is 48 = Insert Review being transmitted that the in pointer no=stop 4C = Assemble Master On=Mode 3 On nl =Play 4D = Assemble Preview of the buffer can actually overtake and n2=Rew 4E = Assemble Edit When any module is pro- pass the out pointer and overwrite the n3=FFwd 4F = Assemble Review grammed for Mode 3, all outgoing data. While with some - n4=Toggle Reverse other modules are locked n5=Cut-In (Edit & Cut-In) 58 = Set Baud 150 out and will not respond to tems this might be a problem, in this r&Cut-Oui 59 = Set Baud 300 any commands other than a casesomuchinformationisbeingsent n7=Set Mode 2 5A = Set Baud 600 Mode3“On”command. This that it’s OK to skip some of it when 56 = Set Baud 1200 is so that any desired char- 5C = Set Baud 2400 acter may be sent to a mod- you’re in a hurry. After all, it’s not MODE 2 COMMANDS 5D = Set Baud 4800 ulewithout the module acci- really too important for the host com- 5E = Set Baud 9600 dentally responding to an puter to know exactly where the VCR 18 = Clear Ret, Cut-In, 5F = Set Baud 19200 undesired command. Trans- cut-out mitting a Mode 3 “Reset is, as long as the module knows. 19 = Pause 68 = Device = 0 command (FFh) will return I had to design a rather complex 1A = Slow 69 = Device = 1 all modules to normal. bus arbitration scheme for two rea- 1 B = Strobe Record 6A = Device = 2 1 C = Hold Record 6B = Device = 3 sons. First, to prevent more than one 1 D = Hold Cut-In 6C = Device = 4 MODE 3 COMMANDS module from grabbing the bus at one 1 E = Record/Play 6D = Device = 5 time and second, to prevent a module 6E = Device = 6 41 =SetTime 1 F = Xmit Hex (BCD) 6F = Device = 7 42 = Set Cut-In from capturing the bus and not allow- 28 = Xmit ASCI‘I 43 = Set Cut-Out ing another to transmit. I wasn’t sur- 29 = Xmit Taoe Time 78 = Xmit Frams Off 44 = Set File Name (Nulls prised that a module tried to monopo- 2A = Xmit Tape Time and 79 = Xmit Set Off = 20h-space) File Name 7A = Xmit Min Off 45 = Set Edit Parameters: lize the bus and that was easy to solve. 28 = Xmit File Name 78 = Xmit Hours Off N+O = Postroll (1 set) The module just has to wait several 2C = File Name On 7C = Xmit Frams On N+l = Preroll Low Limit clock cyclesbefore it’s allowed to trans- 2D = File Name Off 7D = Xmit Set On (10 set) 2E = Tape Time and File 7E = Xmit Min On N+2 = Preroll(5 set) mit again. But I was amazed at how Name On 7F = Xmit Hours On often two modules would grab the 2F = Tape Time and File For Set Time, Set Cut-In, bus at precisely the same time and not Name Off 88 = stop and Set Cut-Out: Transmit 89 = Play frames first, followed by sec- know that the other was there. Listing 38 = (Search) Find & Stop 8A = Rew onds, minutes, and hours. 1 shows the Z8 machine code for the 39 = (Search) Find & Play 8B = FFwd Module will receive until FFh serial I/O. It first checks to see if the 3A = (Edit) Find, Play, 8C = Hold Record received or carriage return Pause, Postroll 8D = Cut-In (ODh). If carriage return re- bus is available and, if so, grabs the 3B = (Edit) Find, Play, 8E = cut-out ceived, module will fill re- bus by setting pin 5 of port 3 high. It Slow, Pause, 8F = Set Mode 2 mainder with nulls (OOh). thenwaitsanassignednumberof clock Postroll 3C = (Edit) Find, Play, E8 = Device = 8 For File Name: Transmit file cycles which is based on its module Postroll E9 = Device = 9 name up to 12 characters number. After it’s waited the required 3D = Cancel Find EA = Device = 10 long. Module will receive time, it drops the bus line and checks 3E = Index On EB = Device = 11 until FFh or carriage return. 3F = Index Off EC = Device = 12 If carriage return received, to see if the bus is still available. If ED = Device = 13 module will fill remainder another module of a higher number 48 = Insert Master EE = Device = 14 with spaces. had grabbed the bus at the same time, 49 = Insert Preview EF = Device = 15 the bus will show occupied. If the bus Figure 2--The list of supported commands is extensive and covers just about any editing is still available, the controller will task necessary. grab it again and send the data.

October/November 199 1 21 no = stop I had to allow for three modes of nl = Play Finding the best way to get to the n2 = Flew operation. In mode one, the default n3 = FFwd pause point is a matter of establishing mode, the module responds only to ISI= a window for the controller to shoot commandsaddressed to it and ignores n5 = Cut-In (Edit) for. Figure 4 shows that the top of the n6 = Record [Edit) those that are not. If the module is put n7 = Reverse‘ On ’ window is just above the pause point. into mode two, it will respond to a n8 = Reverse Off If the VCR has to rewind to get to the second set of global commands. This ng = Pause Toggled window, the VCR’s momentum will nA = Slow Tog&d permits several controllers to respond nB = Cut-Out (Strobe) carry it far enough past the pause to the same command simultaneously. nC = Transmiking Tab Time- point for a valid read. On the other Mode three (On hex) does just the op- Tansmission starts with frames hand, if the VCR has to fast forward, OD-end of transmission posite. All modules with the excep- nD = Cut-In (Strobe) the window’s low limit has to be low tion of the one to which the command nE = Record (Strobe) enough to allow for tape momentum is addressed are locked out. This per- nF = Clear (Clears any issued plus time for a valid read. The soft- commands) mits sending from the host edit and ware allows for changing the limits to other information without inadvert- compensate for differences in VCRs. Figure J-Response codes close the loop ently triggering another controller. between the host and the remote module. To further complicate things, if the The ‘n’ in each code refers to the target VCR is in the play mode when the HOW IT ALL FITS TOGETHER module number. command is received, a second win- dow has to be established. It takes Once you put it all together, here’s they get a little sloppy and the tape several seconds for the VCR to cycle how it works. After the user has se- can sometimes skip over the head that from play to stop to fast forward, then lected the edit points and is ready for reads the control track. When fast for- again from fast forward to stop and the edit, the host computer first trans- warding or rewinding, it’s easy to be a back to play. If the module is only a mits the cut-in and cut-out locations few seconds off, especially if a valid few seconds behind the target point, along with other pertinent informa- read hasn’t occurred recently. Another the module has to determine whether tion to the modules. It then tells each problem the module has to contend it is quicker to fast forward, or just module what task it’s to perform (the with is if the VCR is put into play at a continue on in the play mode. This source module’s task is different from location that the controller thinks is also applies if the VCR is beyond the thedestinationmodule).Thenthehost before the pause point, and the first pause point. Is it faster to go into re- instructs the modules to go ahead and valid read shows that it’s actually af- verse, or stop and rewind? do the task. As I said before, editing ter the pause point, the module has to Once both VCRs have reached the consists of a preroll, edit, and then a recognize that it has missed, and go pause point, the host computer allows postroll. In basic terms, each VCR is back and try again. a few seconds for settling and then instructed to go to a point exactly five seconds before the edit point, go into the pause mode, and tell the host that it is there. When both modules have signaled that they are ready, the host computer puts them both into play simultaneously.When thecut-inpoint isreached, thedestinationmoduleputs the VCR into insert mode. When the cut-out location is reached, the mod- ule releases insert mode. Finally, the controller does a one-second postroll and puts the VCR into stop mode. While all this may seem pretty straightforward, actually doing it is harder than you think. To get to the first pause point, not only do you have to recognize where you are now and where you have to go, you also have to find the best way to get there (play or fast forward, reverse or rewind). You The author’s video editing setup. Note the two controllermodulesmounted on the walljust also have to allow the module a little behindandto theright ofthe twoeditingdecks. They are connectedto thehostcomputer time to establish a valid read from the located nearby with ordinary four-conductor telephone wire. The editing decks are mounted on a heavy-duty lazy Susan and may be rotated for easy access to the tape before it reaches the pause loca- connectionsin the rear. lhemoniforon therightisjust forpicture balance andhasno other tion. As the VCR’s tape handlers age, function.

22 CIRCUIT CELLAR INK 28 Serial I/O Code Segment 4580 ;SERIAL OUT SUB 4585 4590 ;ISOUT PUSH R5 4595 PUSH R6 4600 PUSH R-l 4605 TM XMIT, #OEOH ;CK IF JUST ACCESSED 4610 JR NZ,RSllT ;DISALLOW ACCESS UNTIL TIMEOUT 4615 CALL ERRCH ;READ ERROR CHANNEL 4620 AND R5,#10H ;SEE IF BUS AVAILABLE 4625 JR 2,RSlUT ;GO IF NOT 4630 LD R3.#20H ;GRAB BUS 4635 LD R5;6BH .-READ DEVICE # 4640 RCF ;RESET CY develop Image-basec 4645 RRC R5 ;ROTATE 4650 DJNZ R5,S ;WAIT DEVICE # CYCLES applications with 4655 CLR R3 :RELEASE BUS 4660 LDE R5.QRR6 ;SEE IF STILL AVAILABLE Victor Image Processing 4665 TM R5;#10H 4670 JR Z,RSlUT ;GO IF NOT 4615 LD R3,#20H ;GRAB BUS 4680 RSOlT CP 6FH,6EH :CK IF DONE York with any size images 4685 JR N2,RSOUl applications can support 8-bit co10 4690 AND 251,#6FH ;RESET INTERRUPT MASK low your 4695 CLR R3 ;RELEASE BUS nd gray scale images of any size because Vie 4700 OR XMIT,#OEOH ;SET COUNTER )r gives you complete control over conven 4705 JR RSOUD :DONE onal, expanded, and extended memory. 4710 RSOUl LD 240,@6FH ;XMIT BYTE 4715 INC 6FH ;BUMP POINTER 4720 CP 6FH,#60H ;CK IF AT TOP Iisplay on Super VGA 4725 JR N2,RSOUD hsplay images on EGAI~GA and super VGAU] 4730 LD 6FH.#48H ;START OVER 11024 x 768 256 colors. 4735 RSOUD POP R-l 4740 POP R6 4745 POP R5 .oad & save PCXITIFFIGIF 4750 IRET Iandle images from any source, or create 4755 * -anslation programs between the popular file 4760 k1UT TM 3,#2OH :SEE IF BUS FOR THIS MODULE lrmats. 4765 JR Ni,RSOlT 4770 RSllT OR FLAGZ,#OlH ;SET BUS REQUEST 4175 AND 250,#OEFH ;RESET INTERRUPT REQUEST ;ray scale & color images 4780 JR RSOUD ;TRY LATER owerful image processing for all images - 4785 : 4790 ;SSETRS MOVES DATA INTO RING BUFFER our software can have features like: zoom 4792 ;SETS DATA AND INTERRUPT MODE FOR RSOUT ssize. brighten, contrast, sharpen, outline 4795 ;PASS DATA IN REGISTER 05H nearize, matrix conv, colorize, & more. 4800 : 4805 SETRS LD @6EH,R5 ; DATA 4810 INC ~EH ;BUMP POINTER ScanJet, LaserJet suppotl 4815 CP 6EH,#60H ;CK FOR TOP ‘ou can have device control for gray stall 4820 JR N2,SETRl canning -- AND print halftones at any size. 4825 LD 6EH,#48H ;RESET Victor supports Microsoft C 4830 SETRl TM 251,#10H )uickC, and TurboC, includes demonstra 4835 JR NZ,SETR2 4840 OR 251,#10H ;SET INTERRUPT MASK Ion and prototyping software, and full docu 4845 250,#10H ;SET INTERRUPT REQUEST lentation. Source code available. Victo 4850 SETR2 :;T .ibrary, version 2, $195. 4855 ;

5700 ERRCH CLR R6 ;READ ERROR CHANEL 5705 LD R7,#02H Video Frame Grabbers 5710 LDE R5,QRR6 5715 RET Victor Image Processing Library is also available with 256~level listing 1 --In order to prevent contention, an arbitration scheme is used to seize the bus. gray scale video frame grabbers Victor supports these digitizers puts both modules in mode 2. The called on to do: an insert edit, a pre- with capture, live video on VGA, host then releases the pause on both view, or a review. If the user is calling and frame averaging. machines simultaneously by sending for an edit, when the record VCR VICTOR LIBRARY, v 2 ...... $195 a 19h code. From here on the modules reaches the cut-in point, the module with 256x256 frame grabber $399 are on their own. Both VCRs are free pulls the edit pin low 0’271, strobes with 512x512 frame grabber . . $499 running and no attempt is made to see the cut-in pin (P25), and releases the that the timecodes from the two VCRs edit pin. When the VCR reaches the :all (314) 962-7833 to ordc stay in sync. The built-in ability of the cut-out location the controller strobes VISA/MC/COD record VCR to lock to the incoming the cut-out pin (P26). CATENARY SYSTEMS vertical sync does a pretty good job of If the user has called for a pre- 470 BELLEVIEW keeping the two together. view, the controller simply holds its ST LOUIS MO 63119 After the preroll, there are three electronic finger on the cut-in button (314) 962-7833 options that the controller might be (holds I’25 low) between the cut-in

October/November 199 J 23 The Equipment

The VCRs used in this article are Sony 2860As. I have question, and play it. The time readout should count also used Sony 2850s and tested Sony 5850s with good while the recorded part of the tape is playing, and then results. VCRs from other manufacturers should work as should stop when the blank part of the tape is encoun- long as they are designed to work in an editing system tered. Fast-forward the tape a little. The counter should and are equipped with a parallel port, You should be not move. Now, rewind the tape. The counter should aware there is no compatibility between manufacturers remain unchanged until it encounters the part of the and you’ll have to check the manuals carefully for pin tape that has been recorded. Again put the tape in assignments and voltage requirements before attempt- fast-forward, The counter should count until it reaches ing any interface. Many of the newer VCRs use serial the blank part of the tape, and then stop counting. A interfaces and may have quite different requirements, machine that reacts in this manner indicates that it is Many of you may want to try using VHS, S-VHS, 8mm. probably reading from the control track. This makes it a or other small format VCRs. The crucial factor in a suc- good candidate for computer control. A blank tape cessful editing interface is the ability to access the control has no control track, so if the readout continues to track pulses. The pulses must be available not only during count while blank tape is passing over the heads, then playback, but also while the tape is in fast forward and you can assume that the counter is reading something rewind. The key to recognizing a suitable VCR is to first other than the control track and the machine is prob- check to see if it uses a footage counter or a tape time ably unsuitable for conversion. readout. In the past most consumer VCRs used mechani- Be careful! Each VCR has its own little quirks. For Cal footage counters for displaying elapsed tape time. instance.1 haveaVCRthatwill notgointorecordmode This method is much too inaccurate for editing purposes, from play mode; it has to be in pause first. Be sure that But I have noticed lately that most of the higher end you thoroughly understand the operating characteris- consumer VCR and nearly all industrial VCRs now display tics of a VCR to be certain itwili fit into an editing system. tape time in minutesand seconds. They seem to maintain Easy remote control of VCRs with infrared remotes good accuracy in both rewind and fast forward and it could be achieved through the use of an infrared seems likely that the control track is being used for tape controller similar to the one described by Steve in time display. If the manufacturer is using the control track volume 6 of his “Ciarcia’s Circuit Cellar” books. to display elapsed time, it seems likely that the resource- There are also companies that make computer ful engineer should be able to find a way to use it as well. interface devices for infrared VCRs. You send them your There is a way to determine if a machine is using the VCR and the company returns it to you with an inter- control track. First get yourself a blank tape. It must be a face attached directly to the VCRs infrared sensor. The tape that has never been recorded on. Record about interface is preprogrammed. ready to plug in to your thirty seconds of video on it, load it into the machine in computer. and the cut-out locations. This makes it look like an edit was preformed without actually doing it. If a review has been called for, the controller just lets the tape play. Finally, after a short postroll to let the viewer see how well the edit fit, the controller stops the machine and then transmits the exact edit locations to the host computer. The preroll time, postroll time, and the bottom of the search window are all user selectable. I should say that the preroll time changes to fit certain requirements and VCRs. The preroll time for an edit is five seconds. This allows plenty of time for stable pictures before the edit. That is not quite so important for a preview, and so to save time, the preroll for a pre- Thehost computerandmonitorareconnectedto theeditingdeckslocatednearby. While view is only two seconds. many operators prefer to use two monitors. I normally use just one. Video is switched There are three different editing between the two VCR sources automatically. The editing station is located on a desk patterns that can be selected. Code which is backed by a built-in 130-gallon salt wafer aquarium. This helps to make the sometimes stressful task of video editing a bit more relaxing.

24 ClRCUT CELLAR INK 3Ah selects the “find, play, pause, edit, and postroll” sequence just described. A second similar pattern, 3Bh, adds a slow mode just before the pause. This is the one I use most since it pauses the tape a little more accurately. Finally, 3Ch has no pause at all. No need to pause if the source is a camera. You can also have the module find any location on the tape. One version of this (39h) searches and goes

Figure 4-Finding the best way to get to the pause point is to establish a window for the contfo//er to shoot for. into the play mode when the requested location is found. The other (38h) just stops without going into play. This is in case you’re looking for something at the other end of a long tape and want to refill your Coke while it’s getting there. Until I started getting this article ready, I had no idea that the controller had become so complex. I developed it over the course of the nine years that I’ve been free-lancing. I would usu- ally tinker with it when I had work to do but didn’t feel like doing it. That must have happened a lot over the years. That covers the construction and software for the control modules. In part two, I’ll look at software for the host computer and discuss some op- tions that help simplify the entry and retrieval of editing information. +

Bill Kressbach holds a Master’s degree in In- structional Media and Technology from The University of Toledo. When he’s not shooting videos, he does some computer programming PARqDlGM and is chief engineerfora college radio station. The Model for Programming Productivity

IRS 3301 Country Club Road, Suite 2214 l Endwell, NY 13760 l (607) 746-5966 l 401 Very Useful I 402 Moderately Useful 403 Not Useful

October/November 199 7 Computer Graphics FEATURE ARTICLE and the World of

Chris ciarcia Scientific Visualization

As a result of the advance- and depth. Graphics applications be- But this emphasis on visualiza- ments in data generation and com- came more adept at meeting the re- tion technology is an obvious step for puter technology over the last few quirements of applications needing the computational world. As numeri- decades, methods of managing and realism, visual richness, and motion cal simulation continues to become a analyzing large volumes of complex (animation). Scientific visualization moreaccepted (and cost effective) tool data have been largely responsible for was born. Now it seems to be the new for basic scientific research, the need a strong interest in scientific visual- “catch word” and it has become a of the scientist to understand and “vi- ization as a new computational tech- major focus of computer graphics in sualize” the complex nature of their nology. This visualization technology the 1990s. numerical simulations only increases. has its origins within the realms of Fortunately this process has been en- applied science and engineering where riched by advances within the enter- theuseofcomputerdisplaytechniques tainment world. But regardless of the in computer-aided design and engi- Problem Definition source of advancement, computer neering analysis have provided an graphics technology has grown to be- initial driving force for the develop- come an essential component of this ment of “computer graphics technolo- new field of “computational science.” gies”duringtheearly 1970sand 1980s. As a result, the current rapid develop- Since then the problem of interpret- ment in visualization technology ing, understanding, and processing within the sciences and engineering large complex data sets has grown has been only impeded by the growth considerably. This need has created a in the power and sophistication of strong desire for effective “realistic” computergraphicshardwareandsoft- graphics tools which have in turn ware systems. forced these original display tech- In general, “visualization” can be niques to expand and grow within a defined as the use of computer graph- variety of computational environ- ics imaging technology as a tool for ments. As such, a whole new set of comprehending data obtained by “visualization” methods has evolved simulation, computation, or physical based on the use of computer simula- measurement. As such, it is built on tions and computer graphics. the integration of techniques Originally, entertainment appli- “snatched” from older technologies cations fueled the fires of computer Visualization including computer graphics, image graphics in the middle 1980s while Environment processing, computer vision, com- basic engineering applica tions became puter-aided design, geometric mod- standardized and moved out of the eling, approximation theory, percep- research context into routine practice. tual psychology, and user interface And, the simultaneous development studies. But the most fundamental of PC technology designed to support Scientific definition of the visualization tech- advanced graphics display capabili- Visualization nique lies not in its components but ties served as a foundation and princi- Rendering rather in its intent. It is important to pal support to this evolutionary remember that the purpose of scien- growth process. As a result, the basic tific visualization is to gain “insight” visual vocabulary of computer graph- into the behavior of some complex ics became extended in both breadth Figure 1 -The scientific visualization process. process under scrutiny. Individual

26 ClRCLJlT CELLAR INK numbers (or single components of a We will construct this “scientific and the configuration of the display large database) are not important. In- visualization” along the guidelines vehicle. stead, its effectiveness lies in its ability shown in the flowchart in Figure 1, 4. Creating the Visualization Envi- to rapidly communicate large amounts where ronmenf-The background and each of information in a format that en- 1. Problem Definition-The basic component of the visual display is hances comprehension and insight. problem is defined and the nature of defined in detail and constructed for Historically the concept of visual- the physical system to be visualized is use within the “active” visual mode. ization predates the computer era. If detailed. This process includes the This step involves the actual coding of you think about it, visualization has definition of the type of process under each component and the setup of any been a part of the scientific method study, the limits on its behavior and animation requirements. ever since the Greeks. They employed its environment, and the underlying 5. Rendering-Each component of basic linear graphing techniques in scientific principles involved. the “scientific visualization” applica- their complex architectural designs. 2. Modeling ~mafhemafica&--The tion is combined to create an inte- But now we seem to want to handle system model is chosen. Since this grated environment. As the procedure more than one-dimensional data, and example will involve the application isrun,themathematicalmodelisused this new “complexity” requires that we be more creative in our rendering Ball technique. AY Therefore, in order to explore these visualization concepts on a practical level, I’ve decided to center this article about a detailed description of how to structure and implement a basic “vi- sualization process” like that flowcharted in Figure 1. I propose that we develop a computational “visual- aid” that will utilizenumericallysimu- lated data from the application of Newtonian mechanics to the motion of an object within a gravitational field in order to demonstrate how basic insight into a system’s behavior can be gained from this visualization pro- Ground cess. In doing this, we will be called upon to apply basic tools from nu- merical analysis, computer graphics, and animation. Figure 2-The example used in the article is a simple ball which falls off a wall, bounces, and usually falls into a hole near the right side of the system. THE VISUALIZATION PROCESS of physical laws of motion, the math- to predict the behavior of the system The best example is one that can ematical technique to be used must be in a step-by-step manner. The visual be easily recognized and compared to defined and applied in order to derive display is then upgraded in a continu- one within our own personal experi- appropriate equations of motion. ous fashion to reflect the changes in ence. I have therefore chosen to “visu- These need to be consistent with a the mathematically derived data. alize” a system based on the motion of form that is easily used within the Of course the specific procedure a ball, falling off a wall and bouncing computer graphics display environ- shown above is not “universal” to all into a hole. It’s a simple system that ment. scientific visualization processes. The each of us can visualize from experi- 3. Visualization Mapping-The na- source of our data could have been ence. As such, it will be easy to “see” if ture and extent of the actual “visual” empirical or from a closed-form ana- our numerical modeling and visual- display is defined, that is: What is the lytic solution instead of our chosen ization look and act like the real thing. viewing field? How many objects will numerically simulated data. And the But don’t be fooled. A simpleexample it contain? What form of background nature of the problem itself will obvi- doesn’t guarantee a simple computer is necessary? What video mode and ously change with application. How- model. A true representation of this resolution is necessary? Do you use ever, the techniques and concepts process requires that we numerically black and white or color? Is the scene employed are generic across the spec- solve a secondorder differential equa- animated? In other words, this step in trum of physical science and can be tion, create a visual environment, and the visualization process requires the readily applied to many different animate a time-evolving process. definition of all the basic components fields.

October/November 199 1 27 Our goal within this article is to go PROBLEM DEFINITION we will neglect air drag effects in this through the flowchart in Figure 1 in a problem. But because the ball impacts step-by-step fashion while flushing The first step in the example is the with the ground and loses some en- out each component in order to create definition of the exact nature of the ergy through that interaction and in a practical, working scientific visual- problem we are going to solve. We the elastic deformation process of the ization example. But since this or any will consider the motion of a bounc- ball’s surface, it is known that the other example is highly dependent on ing ball that first rolls along the top of vertical velocity is not conserved after the programming language, graphics a wall and then falls off and bounces each bounce. We can make a good library, and display deviceused, I have several times until it falls into a hole in approximation to our own observed chosen to develop our example in as the ground. A drawing of the appro- real-world action by assuming that “generic” a fashion as approximately 28% of possible. For a program- the total kinetic energy ming language I have is lost during the ball- chosen FORTRAN. This ground interaction. This is not because C is reflected in a vertical wouldn’t be better. It’s velocity damping of because I find FOR- about 15%aftereachcol- TRAN easier for people lision with the ground. to read. They can usu- Theverticalvelocity(Vv1 ally follow the program of the ball after each flow better without be- bounce is therefore ap- coming programming yn +k (9) proximately equal to the experts. Most of the time negative value of 85% of I use C, but this is only the vertical velocity be- because I get better ac- fore the bounce. cess to system-level func- As a “study” vari- tions for enhancing my yn able in the system, we displays. However, in will allow changes in the this application that is input of the magnitude not necessary. of the constant horizon- For a graphics li- tal velocity Vxo. For our brary I have chosen to purposes here, this value use the Microsoft Graph- will range from 0.38 ft/ icsLibrary Routinescon- )l set (when the ball tained in the Microsoft tn+d? bounces and then just FORTRAN V5.0 distri- rolls into the hole) to bution. Microsoft seems Figure 3-The Runge-Kutta procedure uses a weighted average of slopes, about 4.7 ft/sec where to a fairly universal stan- with those in the center receiving twice as much weight as those on the the ball has sufficient ve- dard and available to locity to be “dunked” most programmers. It is not the most priategeometryanditsassignedcoor- into theholewithoutbouncing. Higher ideal graphics set, but it does contain dinate system is shown in Figure 2. velocities will miss the hole entirely. most of the basic graphics utilities The ball will start its motion at the Several choices of Vxo are possible needed for addressing and assigning coordinates (Xo,Yo) = (-1.0, 0.8) and within this range which will cause the values to individual pixels within the roll horizontally at constant velocity ball to land in the hole after a series of display screen. Its most obvious fail- (Vxo) until it reaches the edge of the bounces. If the ball misses the hole, we ing lies in its restriction to the stan- wall f-0.8,0.8). It will then fall off the will continue the computation until it dard VGA modes. The best it can wall and strike the ground 1.3 feet reaches a horizontal coordinate loca- handle with 256 colors is the 320 x 200 below and bounce upward. The tion of 0.85 feet (Xstp>. If it enters the display resolution. Of course you can ground itself is defined to be 0.5 feet hole, we will allow it to slide down- improve the resolution to 640 x 480 if below the coordinate axis (y = -0.5). warduntilitfalls toacoordinatedepth you wish to be restricted to 16 colors, Each time the ball strikes the ground it of Ysfp = -0.8 feet. but I usually find this unacceptable. I will either bounce or, if it falls in the Since we will be studying the like maximum “realism” wherever appropriate place, it will fall into the “motion” of a “dynamic system,” we possible. If you are looking for a more holeandbetrapped.Thisholeisplaced will be solving for the coordinates of comprehensive graphics library to 1.25 feet from the base of the wall. It is the ball in a point-to-point fashion develop your own visualization ap- 0.3 feet deep and 0.10 feet wide. during the time of its motion (flight plication under, I recommend the Ge- The ball is assumed to move hori- path) from the top of the wall until it nus GX Graphics Toolkit. zontally with a constant velocity since stops. The best visual aid for this ex- ample is therefore one that demon- dx= vxo and Equations 1 and 2 may be rewrit- strates that time evolving change in dt ten in the following system of three position. To implement this, we will and first-order equations: “animate” that motion by solving for d2Y the change in the ball’s position every _= -g (2) g=vxo 0.001 seconds (dT). dt2 Equation 1 indicates that the hori- dv = -32.2 (4) MODELING zontal velocity is equal to a constant dt for all times, Vxo. Equation 2 expresses The type of motion defined by the the fact that the ball will be within a z=vv (5) bouncing ball can be described by the gravitational force field and subject to application of basic Newtonian me- a downward accelerationeaual to 32.2 chanics. This results in a second-order ft/sec* throughout the mo;on. The simplest procedure for nu- differential equation. The best proce- If we let merically solving this set of simulta- dure to adopt here is to transform this neous equations is through the appli- equation into a system of simultaneous Vv=dy cation of the Runge-Kutta method first-order equations which can be dt using Euler’s approximation. easily solved. then The governing differential equa- RUNGE-KUTlA METHOD tions are ---dVv Bd2Y dt dt2 To gain some basic insight into how this technique works, consider a basic first-order differential equation of the form,

z = f(t,y) (6)

Now assume that we know the initial condition of the system and it is defined by its starting time and initial x = x0. y = yu. vv = vyo y-coordinate location,

Xold = X 6. And, once we find this new posi- &Ad = y tion, we can then find the next (y,) for Vyold = vv f = f, + 2dt, and so on, in a step-by-step manner. Using this approach, the re- quired y-f relation can then be ob- tained and tabulated. In the Runge-Kutta method, the basic formula for such a process is Yold - Y

Yn+l = Y* + dYn (7) y=y-(16.1 dt-Vv)dt] (Vv - Vyold) @old - Ygnd) vv = &id + where I Yold - Y Vv = V-32.2 dt I I time = time - dt E time = time + dt 0 I and k, are called Runge’s coefficients. Y = ygnd These are defined as, STOP I 1 Vv=-coefb 1 ko = f(t,, yn) kr= tn+$yn+kodt 4 2, 2 k2= t,++,y.+$dt 4 Figure4-F/owchatfforca/cu/ationofposition ofthe bouncingballasafunction offhe time ka = f(t, + dt ,yn + k2dt) using the Euler approximation of the Runge-Kuifa numerical technique.

October/November 199 1 29 a) All of these coefficients can be c The initial velocity, position, time and time step. c _-___-___--______~~~~___~~~_~____~~~____--~______derived from a Taylor expansion of vyo=.o ! initial vertical velocity Equation 7, but that exercise is not x0=-1.0 ! initial x position Yo=.8 ! initial y position necessary for us to follow through dT=.OOl ! the incremental time step here. Instead, it is much more enlight- time=0 ! total time ening to examine the simple geometri- c The boundaries and boundary conditions. cal interpretation of these constants as c --___-_-_---_-______~~~~~~~~~~~_~~-~~~~~_____~~~~_____ coef=.85 ! ball-ground damping constant they are shown in Figure 3. All four k- Ygnd=-.5 ! Y location of around values represent the slopes at various XhL=.45 ! x location of ieft-hand-side of the hole XhR=.55 ! x location of right-hand-side of the hole points of the time-changing spatial Xe=-.8 ! x position where-ball falls off the wall function. k, is the slope at the starting Xin=O.O ! x coordinate of where ball hits the hole point, k3 is the slope at the right-hand Xstp=.85 ! the x stop coordinate of the system point whose coordinate is yn + kndt, Ystp=-.8 ! the y stop coordinate of the system and k2 and k, are the slopes at mid- points whose ordinates are yn + 1/ b) read(*,*)vxo 2k,dt and y,, + 1/2k,,dt, respectively. x=x0 As can be seen from Equation 7 y=yo vv=vyo and Figure 3, the Runge-Kutta proce- i=O dure usesa weighted averageof slopes, time=0 with thosein thecenterreceiving twice Xin=O.O as much weight as those on the ends. C) Formanyproblems, thisextra weight- 100 i=i+l ing scheme is not necessary and they can be approximated with sufficient ERASE LAST DRAWING OF BALL ! not actual FORTRAN coding accuracy by a first-order term of the Xold=x Yold=y Runge-Kutta method. Here, the basic Vyold=Vv formula is simply, x=xtVxo*dT if(x.lt.Xe)goto 200 Yn+, = Y, + Wt (8) y=y-(0.5*32.2*dT-Vv)*dT This is called the Euler approxi- Vv=Vv-32.2*dT mation and it depends only on yn and time=timetdT the slope k, at the point (t,,y,). 1) if(x.ge.Xstp)goto 500 EQUATIONS OF MOTION if(y.le.Ystp)goto 500 if(y.lt.Ygnd)then For our simple bouncing ball, if(Xin.gt.O)x=Xin if(x.gt.XhL .and. x.lt.XhR)then Euler’s approximation contains a suf- Xin=XhL+(XhR_XhL)/2 ficient degree of accuracy for a viable got0 200 endif animated visual display. We will there- x=Xold+((Yold-Ygnd)*(x-Xold))/(Yold-y) fore apply Equation 8 to our differen- Vv=Vyoldt((Vv-Vyold)*(Yold-Ygnd))/(Yold-y) time=time-dT*(Ygnd-y)/(Yold-y) tial Equations 3,4, and 5. As a result y=Ygnd these expressions become: Vv=-coef*Vv endif xi+, = xi + Vxofdt) (9) 200 DRAW THE NEW IMAGE ! not a FORTRAN code statement got0 100

500 read(*,*) ! vvi+l = Vvi - 32.2 (dtl (10) wait for user input to continue

yi+l =yi +I Vvt +Vvi+r) dt (111 2( listing 1 -Before starting anything, (a) theinitialconditions and (b1 initialhorizontal velocity must be set. (c) Before the new position can be drawn, the old ballmust be removed. (~0 If we now substitute the value of VZ)~+~ The new position is calculated and the ball is redrawn. of Equations 10 into Equation 11, we obtain a set of equations of the form: yal = yi - [16.l(dtl- Vv,] dt (12) can be calculated. A sample flowchart of the FORTRAN routine that we will = xi + ‘i+l Vxofdt) These three above equations can employ for this process is shown in now be applied in a simple computer Figure 4. Vvi+, = Vvi - 32.2 (dt) calculation loop from which the time- To implement this process, we dependent coordinate (x,yl of the ball must first define all of our initial con-

30 ClRCUlT CELLAR INK ditionsand decisioncoordinates. Since below it (based on the distanced trav- a high degree of accuracy is not re- eled in one time step dT), then we quired, each of these variables can be must determine if it is falling into the defined as REAL*J in our example. hole or not. This is accomplished by The integer counter i is defined as testing to see if the x-position is within INTEGER* 2 since we expect to exceed the hole’s width between x = 0.45 to x 127 df time steps. See Listing la. = 0.55. If it is, then the position is reset The initial horizontal velocity is to the center of the hole (xin) and the then input and the loop variables (x, ball is drawn at the new position and y, Vv, i, time, Xin) are set to their allowed to fall to the bottom in the initialconditions,showninListinglb. next few cycles. The cycle counter is then Thiscentercoordinatexinisused incremented by 1 and the basic loop for multiple purposes. It centers and procedure is started. Since this is an constrains the motion of the ball as it “animation sequence,” the last draw- slides down the hole so that we can ing of the ball within the display im- simulate the realistic motion of a solid age is erased so that the new image spherical ball sliding down a circular position can be drawn after its new pipe slightly larger than itsown diam- position is determined. However, be- eter. But at the same time it is used as fore this calculation takes place, the a trigger function. It indicates whether current position and velocity corre- or not the ball has entered the hole. If sponding to this last (ith) cycle is Xin = 0 then we know that the ball has stored in temporary storage (Xold, yet to reach the hole. If Xin is greater Yo Id, Vvo Id) and the new x position than zero then we know it has just hit (for cycle i+l) is determined. If the ball the hole or is sliding down it. collides with the ground, these previ- If the ball is not in the hole and the ous (old) values will be used to deter- y coordinate indicates that it has col- mine the ball’s reflection from that lided with the surface, then the ball surface. If the ball is still on top of the must bounce. Under these conditions, wall, that is, for x less than xe, then the the new x-coordinate location and ball is drawn at its new horizontal vertical velocity are calculated using position and the counter is incre- the previously stored values from the mented for the next cycle. Otherwise, last cycle. The velocity is thendamped the i+l cycle y coordinate (y), vertical by 15% and its direction is inverted to velocity WV), and the total elapsed simulate the reflection of the ball off time is calculated. See Listing lc. the ground surface. The new position Once the new position of the ball of the ball is then displayed in the is determined, it is necessary to make animationsequenceand thenextcycle several conditional tests to determine is initiated, as shown in Listing Id. the current status of the calculation Once the total motion sequence is sequence. The position is first tested completed, a new horizontal velocity to determine if the ball has reached its can then be input and a new test of the end-point boundary conditions. In ball’smotioncanbe “visualized.“How other words, has it fallen into the hole this visualization is accomplished us- and reached itsbottom (Ystp = -0.80) ing the simple graphics utilities avail- or has it bounced past the hole to the able within the Microsoft Graphics right-hand side of the display screen Utility Library is the subject of the and reached the x-stopping point next few sections. (xs tp = 0.85)? If either of these condi- tions is met, the calculation and ani- VlSUALlZATlON MAPPING mation sequence is suspended. If the ball has not reached these The next step in creating a work- stopping boundaries, we must deter- able “visual” representation of our mine if it should bounce or continue in scientific model is based on the defini- its upward or downward flight path. tionofthegraphicsenvironment.This This is accomplished by testing the display must be chosen carefully since value of the y coordinate. If the ball’s it is highly dependent on the nature of location is at the surface or slightly the process being visualized. For our

October/November 199 1 3 1 bouncing ball scenario, we need only consider the animated motion of a single object: the ball. But that ball must move within some referenced environment. This environment, or background image, must be laid out to correspond to the system limits and boundary conditions specified in the previous “modeling” section. And since this is an animated visualiza- tion, we must take into account the specific hardware used. This greatly affects the time needed for image modifications. It’sobvious thatdiffer- ent graphics cards, screen memory management, and processor clocks speeds affect the rate at which a pixel on the screen can be changed. There- fore, before selecting the display mode, the following should be considered: Figure 5a-A Iwo-dimensional textured background is used to add some realism to the 1. How much visual detail does simulation. each object or component of the back- ground require? speed exist due to the size and num- 4. What constraints do you have 2. How many colors or shades of ber of colors of each object (the num- placed on your choice of video mode gray are necessary to properly render ber of bytes per pixel and the number resultingfromcompatibilityandtrans- that detail? of total pixels within an object affect portability to other PCs? 3. If you are animating objects, perception of the motion since the I’m sure you can think of other what constraints on the image refresh video refresh rate is not variable)? important questions that you would

. ala warsion SUppOrM dh Turbo C, Microsoft C, QuickC, QuickBASIC and Turbo Pascal.

Readerservice 1103 32 ClRCUlT CELLAR INK contain all the procedure declarations, structure, and symbolic constant dec- larations for each of the called graph- ics functions. These should be the first two lines of code in your program.

SElTlNG THE VIDEO MODE

The display device utilized by the running computer system must first be polled to determine if it is capable of supporting the chosen video mode. If it is, then the mode is set. Otherwise the execution of the example visual- ization is terminated. An example of the FORTRAN code needed to implement this step is shown in Listing 2a. The getvideoconfigprocedureisused Figure 5b-A block-line background is often used due to its simplicity, but fails to add to find the type of video adapter that is any realism to the system. installed. This information is returned in the /videoconf ig/ structure de- ask during a design review, but I think ground using a textured surface for fined in FGRAPH . FD and referenced the four listed above give you an idea the wall and ground. This tended to within our code through the record of the type of thought that goes into make the eye see this ball as bouncing declaration. The actual video mode is choosing the “visualization map.” For on a piece of concrete viewed from set by a call to the setvideomode this article I was highly constrained face-on, as shown in Figure 5a. The utility and passing it the by Question 4. If this example is to be texture lends some 3-D effect to the SMRES 2 5 ~COLOR parameter request- worked with by most of you, I needed surface of the wall and ground. This ing that the video modebe set to VGA to keep my graphics mode to a widely compensates for the “flat-look” expe- 320 x 200 by 256 color. The integer accepted standard. This meant choos- rienced when using the more tradi- variable dummy is used to return er- ing between standard EGA or VGA tional line, solid-fill-rectangle mode ror/success flags. If setvideomode modes. And since all computer sys- of drawing (see Figure 5b). sets dummy to zero, the hardware re- tems with a VGA card support the quested is not available. This condi- basic 320 x 200 by 256-color mode, I CREATING THE VlSUALlZATlON tion is tested. If dummy is set to a chose that for this exercise. My choice ENVIRONMENT nonzero number, this indicates that of the 256-color mode was based on the video mode was successfully set. my desire for some realism. I wanted With the display mode and basic to generate a black-and-white (B/W) components chosen, eachof the visual SElTlNG THE COLOR PALEllE display but I didn’t want to be limited constructs must be coded in our de- to the four shades of gray that the velopment language. This is accom- The selected VGA video mode standard 16-color modes of EGA or plished through the use of a variety of enables us to use up to 256 colors at VGA would allow. By selecting the graphics utilities provided within the any one time within our scientific vi- 256color mode, I could then construct Microsoft run-time library sualization display. This grouping of a B/W table of 64 shades. This would (GRAPHICS.LIB) which are linked allowed colors is defined as the dis- allow me to render the wall and ball together when the executable is cre- play palette. If we had chosen some with some detail. Also, as long as I ated. However, the steps necessary other video mode, we could have pal- kept the size of my ball down, I could for this “environment generation” ettes containing 2, 4, 8, or 16 colors. render it as a 3-D object instead of a l- process must be accomplished in spe- Each of the colors in a palette is refer- D point or a 2-D filled circle. This at cific correlated steps which build on enced by its respective “index num- least would add some realism to the one another to create the desired vi- ber.” In the VGA 256-color mode, we visualization. sual display effect. can mix varying amounts of the base How you choose this background Every program using the graph- colors red (RI, green (G), and blue (B) can make or break the visualization. ics library must explicitly declare any to create up to 262,144 (256K) different Perception is a funny thing. It is highly routine it uses. This means that you color combinations. Two-hundred dependent on context, especially are required to reference the interface fifty-six of these can in turn be as- where motion is concerned. I there- routines provided in the include files signed for use within our application’s fore chose to create our example back- FGFCAPH.FI and FGRAPH.FD which color palette.

October/November 199 1 33 0) integer*2 dummy When you create this color combi- record /videoconfig/ myscreen nation, you specify a level of intensity CALL getvideoconfig( myscreen ) (over a range of (r-63) for each of the R, dummy = setvideomode( SMRES256COLOR ) G, and B bases which is coded into a if (dummy.eq.0) then print *,'Error: cannot set graphics mode' long integer of four bytes (32 bits) for stop interpretation by the video board. endif b) MSB LSB INTEGER*4 FUNCTION RGB( r, g, b 1 INTEGER*4 r, g, b ooooooo0 OOBBBBBB OOGGGGGG CORRRRRR RGB = ISHL( ISHL( b, 8 ) .OR. g, 8 ) .OR. r RETURN END where B, G, and R represent the bit values for blue, green, and red, re- integer*4 dummy4, iblue, ired, igreen spectively. The most-significant bit integer*4 RGB, tmp (MSB) contains all zeros and the two do igreen = 0, 63 higher bits in each of the next three ired = igreen bytes are also set to zero. For example, iblue = igreen tmp = RGB( ired, igreen, iblue ) to make the brightest red, just set all B dummy4 = remappalette( i, tmp 1 andGtoOandsetRto1. i=itl enddo

oooooooOoooooOooooooooOooo111111 Listing 2-(a) The display device being used must support the proper video mode. (b) A function to mix colors and encode the palette’s index number is simple indeed. Cc) Sixty- In hexadecimal notation, this four levels of gray are necessary to add realism. number equals #OOOOOO3F. Each base color, therefore, ranges over the above component colors (O-63), however, the utility, and all of the specifics which defined 0 to 63 range. A simple func- number of gray shades along this di- define the current video mode were tion can be created for mixing colors agonal is restricted to 64. called and loaded into the and encoding the palette’s indexnum- In our example scientific visual- getvideoconf ig structure. The ber. This function has the form shown ization, the 2-D textured background “physical coordinates” of the system in Listing 2b. and the 3-D ball are rendered in shades are returned and set within the vari- Here, three integer values for R, of gray. The actual display would have ables xl, x2, yl, and ~2. They repre- G, and B are passed to the function been faster and simpler to implement sent the number of pixels in the hori- and encoded into a 4-byte variable if a 16-color palette mode had been zontal or x-axis (= x2 - xl + 1 pixels = and then returned to the calling rou- chosen, but this limits your percep- 320) and the vertical or y-axis (= y2 - tine. tion. It’s difficult to distinguish sur- yl + 1= 200). This physical coordinate Thebest way to visualize this RGB face texture using only four shades of system has its origin in the upper left- mixing is to view each color as the axis gray (black, light gray, white, bright hand comer of your video window. of a three-dimensional coordinate sys- white). For that reason, the visualiza- These physical coordinates refer to tem with the coordinates of each point tion example used the code in Listing each pixel directly and, as such, are within that system corresponding to 2c to create a B/W palette with ad- represented by integer values. These some “mixed” color. If you stay on dressable indices ranging from 0 to 63 absolute references to a physical loca- one of the axes, say along R, then G to define the shades of gray directly. tion on the viewing window can be and B will be zero and the intensity of Here, the remappalette graph- used to define the active display area. the defined red will vary from black ics utility was used to load the speci- This is accomplished by calling the (when R = 0) to the brightest red (when fied palette index (i) with the appro- setviewportgraphicswindowrou- R = 63). From this scheme you can priately coded gray shade RGB coor- tine. In our example, I chose to use the easily see that the shades of gray can dinate number. entire screen (defined by xl, x2, yl, be created by combining equal y2). amounts of each color. Therefore, the DEFINING THE COORDINATE Once the physical working area is coordinates for these shades of gray SYSTEMS set, a userdefined coordinate system can be seen to fall along a diagonal line can be defined using the setwindow that passes through the center of the 3- Afterthevideo modeand thecolor utility. This function enables us to D color vector space. Under this con- palette were set, the image display overlay the working area with our di tion, the RGB value of (O,O,O) is black, coordinate systems were defined and own coordinate scales and to select a value of (32,32,32) is gray, and set. This is a two-fold process which the location of the origin. In this spe- (63,63,63) isbright white; thediagonal was coded and implemented as in cific case, I chose to use the same coor- representsthecoordinatesof smoothly Listing 3a. dinate scheme (with theoriginremain- increasing gray shades from black to The current video screen was re- ing in the upper left-hand comer). white. Due to the discreteness of the set (cleared) using the clearscreen This was done so I could input my

34 ClRCUiJ CEI-LAR INK 3) integer*2 dummy,xl,yl,xZ,y2 Video double precision wxl,wyl,wx2,wy2 record /videoconfig/ myscreen VGA, EGA, CGA

call clearscreen (SGCLEARSCREEN) Market Central manufactures video CALL getvideoconfig( myscreen ) products for sharing, extending, and xl = remoting your Computer’s video yl = 1 signal. Our video products are used myscreen.numypixels in classrooms, factories, exhibits; ;; : myscreen.numxpixels also security installations and trade call setviewport( xl, yl, x2, Y2 ) shows. wxl= float(xl) VGA KVM wyl= floatfyl) Our newest product, the VGA KVM wx2= float(x2) enables the user to remote the wy2= float(y2) dummy = setwindow(.FALSE .,wxl, wyl,wx2,wy2) keyboard, (video) monitor and mouse up to 150 feet away from the PC. call fill There is also an optional Local b) Module that lets you connect another subroutine fill keyboard, monitor and mouse at the INCLUDE 'FGRAPH.FD' integer*1 dat(256,256) PC. The unit has a switch selectable integer*2 dummy,ipx option that sends the display to both double precision wx,wy monitors simultaneously. Keyboard open(l,file='wall',form='binary', recl=256,status='old') access is controlled by the local user do i=1,256 in a shared system. The unit derives read(l,err=30) (dat(i,j),j=1,256) enddo it’s power from the PC and there is 30 close (l,status='KEEP') no external power necessary. Retails are, Host $250, Remote $115, Local do wx=3,318 do wy=4,198 $150. i=nint2(wx) if(i.gt.200)i=i-2OOt5 j=nint2(wy) ipx = dat(i,j) if(ipx.lt.O)ipx=ipx+256 inc = int4( ipx/4) dummy = setcolor( inc ) dummy = setpixel_w(wx,wy) enddo enddo return end cl wxl=l wyl=l. wx2=1000. wy2=1000. VGA splitter dummy = setwindow(.FALSE.,wxl,wyl,Wx2,wY2) Our VGA splitter shares your PC video signal (the display on your Listing3-((a)Afferthevideomodeandcolorpale~eareset, theimagedisplaycoordinate monitor) with as many as 8 others system is defined and set. (b) The background texture is read from a file. (c) Once the up to 250 feet away. Retail for the 4 background is complete, the window coordinates can be reset to values used during the port is $385, 8 port $699. This unit is animation. ideal for training and classroom en- texture map (contained in the binary intensity value ranging from 0 to 63. vironments. VGA line driver image file WALL) and fill the entire Each of these values corresponds to Our VGA line driver is used to screen with its image. The FORTRAN the gray value defined within the B/ increase the distance your VGA code used to read this texture map has W “cola? palette. That gray “coloY is signal can be sent, up to 250 feet the form shown in Listing 3b. then set within the video display win- from the PC. Retail is $199. This texture map was externally dow. This is accomplished by setting Market Central manufactures a created using a Fractional Brownian the location of the pixel (within the variety of interface converters, print Motion fractal technique used for video window using setpixel_w) buffers, and fiber optic equipment at modeling surfaces. It is stored as a 256 to the value of thei,j indices of the data our plant in Pittsburgh, Pa. For x 256 binary image. The code in List- within the texture array and then set- additional information on these or ing 3b inputs this image and then con- ting the pixel color at that location to o products please contact us. verts the byte data to integer data so the referenced palette gray shade (us- MARKET CENTRAL, INC. that itsdynamic range spans the inter- ingsetcolor (inc) ).Sincethescreen 600 N. Main St. val of 0 to 255. This data is then di- is 320 pixels long and the texture map Houston, Pa. 15342 vided by four so that each point in the is only 2% points in extent, the hori- (412) 746-6000 texture map can be assigned a B/W zontal components of the texture map FAX (412) 746-5400

Reader Service X166 October/November 199 I 35 a) inteoer*l bal(64.64) are wrapped around to fill the full 320 integer*4 inc, Imsize, xwid, ywid horizontal pixels. A 2- to 4-pixel bor- integer*1 buffer[ALLOCATADLE] (:) real*4 wx, wxx. WY, WYY der was also left blank as the back- integer*2 action(S),error,ipx ground texture map was displayed. DATA action / SGPSET, $GPRESET, SGXOR, SGOR, SGAND / This was done to leave room for other open(l,file='ball',form='binary',recl=64,status=~old') background drawing. do i=1,64 read(l,err=30) (bal(i,j),j=1,64) Once the background “fill” func- enddo tion iscompleted, the window coordi- 30 close (l,status='KEEP') nates can be reset to values used dur- do wx=1.,64. ing the actual animation sequence do wy=1.,64. i=nint2(wx) (shown in Listing 3~). But before the j=nint2(wy) animation is actually initiated, an im- ipx = bal(i,j) if(ipx.lt.O)ipx=ipx+256 age map of the three-dimensional ball inc = int4( ipx/4) must be entered and the remainder of wYY=wY wxx=wx*(5.5/7.) the background display needs to be dummy = setcolor( inc ) set up. dummy = setpixel_w(wxx,wyy) enddo enddo CREATING AN IMAGE MAP b) xwid = 64*(5.5/7) A three-dimensional rendering of ywid = 64 the ball was created externally and imsize = (xwid*myscreen.bitsperpixelt7)/8 stored as a 64 x 64 binary image for use imsize = 4t imsize*ywid with our visualization code. It was ALLOCATE ( buffer( imsize ), STAT = error) constructed as a simple spheroidal if( error.ne.0) then dummy = setvideomode( SDEFAULTMODE ) object having a radius of 32 pixels and stop 'error: insufficient memory' a surface defined by 64 shades of gray. endif The size and scaling was chosen to c) optimize its construction, but it’s ob- wxl=l. wx2=64.*(5.5/7) vious that the size is unacceptable for wyl=l. our visualization process. The radius wy2=64. of the ball spans 10 percent of our call getimage_w(wxl,wyl,wx2,wy2,buffer) physical coordinate viewing field. call putimage_w(wxl,wyl,buffer,action(3) ) Using the “window coordinate” sys- tem fixes this problem for us. It basi- listing 4-_(a) The image of the ball is retrieved from disk and displayed. (bl The size of the cally rescales the ball as it maps it over buffer needed to contain the ball is determined and allocated. (cl The ball is erased by to the 1 to 1000 coordinate range. This XORing it with itself. reduces the ball’s size to about one- Here the ball’s image size to be inverted wherever a point in the third of its original. (imsize) is the number of bytes image buffer exists. This behavior is The code in Listing4a shows how needed to store the image. This is de- exactly like that of the typical cursor, the ‘ball” image file was retrieved fined by the bounding rectangle of which, when put against a complex from a disk file and then displayed on width of xwid and height of ywid. background twice, results in the back- the video screen using the setcolor The display aspect ratio is included. ground being restored. Therefore, and setpixel w utilities. The image is then captured by a call to employing this same technique, we It is displayed in the upper right- the get image-w graphics utility and will be able to “animate” our ball hand corner of the screen so that it can then erased from the screen by writ- against our background without eras- be captured to an image buffer file for ing the image over “onto itself” in a ing it or having to rebuild it after each later displayatanylocation within the logical XOR fashion using the motion increment. active viewport. A correction to the put image-w utility. See Listing 4c. horizontal display coordinate was The put image w function trans- FINISHING THE BACKGROUND made during the graphical display to fers to the screen the image stored in adjust for the aspect ratio of the 320 x the buffer. It is referenced to the upper Before that actual animationevent 200 video window. This correction left comer of the image as defined in can take place, the background needs assures that the mapped ball remains the window coordinate system. The to be completed. This is accomplished a sphere when it is displayed. After act ion variable defines how the in- by erasing large rectangular sections the ball is drawn, the size of buffer teraction between the stored image of the “texture-filled” screen to leave needed to contain it is determined and and the one already on the display behind the wall, ground, and the tar- then allocated according to the code in takes place. Use of "action (3) = get hole. This is accomplished by set- Listing 4b. $~~~~“causes the pointson the screen ting the active palette color to black

36 CIRClJll CELLAR INK a) inc = 0 dummy = setcolort inc ) dummy = rectangle w( SGFILLINTERIOR, 0.,0.,1000.,104.) dummy = rectangle-w{ SGFILLINTERIOR, 98.,100.,1000.,747.) dummy = rectangleIw( SGFILLINTERIOR, 723.,752.,777.,902.)

b) inc = 63 dummy = setcolor inc ) call moveto_w(O.,O.,wxy) COMPUTER ANIMATION dummy = lineto_w(lOOO,O) dummy = lineto w(1000,1000) FOR PROFESSIONALS dummy = lineto-w(O,lOOO) dummy = linetozw(O,O) call moveto w(O.,lOO.,wxy) Animate static graphic images from your dummy = lit&o ~(100,100) favorite graphics program, user written dummy = lineto-w(100,750) program, or post processor in real time! dummy = lineto-w(725,750) dummy = lineto-w(725,900) dummy = lineto-w(775,900) Superior Tool For: dummy = lineto-w(775,750) dummy = linetoIw(1000,750) l Scientific Visualization CFD - Structural Dynamics - Shock Listing 5-_(a) lhe background/s completedbyeraslng the area where the anlmation Is to Physics - Fractals - Molecular take place. (bl The final step is to outline the wall, ground, and hole. Biology-Weather Forecasting and employing the rectangle w procedure defined in the previous Sci- l Multi-Media presentations function to draw and fill “blank” s&c- entific Modeling section. A brief out- tions of the screen as shown in Listing line of that calculation is shown in * Instructional Aid 5a. Listing 6. Once the background structure As stated above, the animation is 15 - 30 high resolution, full color EGA has been isolated, the active color in- achieved by overwriting the ball in a or VGA frames per second (typical) dex is set to bright white and the wall, logical XOR fashion. This is accom- ground, and hole are outlined using plished bytheloopshowninListing6. LINKABLE routines for user written programs in ‘C’, FORTRAN, Pascal, Microsoft’s line drawing functions as The ball is erased at the position it and QuickBasicrM in Listing 5b. occupied during the last cycle and The background is now com- then drawn at the next position. This Combine SLIDES and ANIMATIONS for pletely constructed and the ball is is done over and over until the ball’s seminars, conferences, and classrooms. stored within an image buffer for fast motion is stopped according to the ONLY $199 video display. The actual “scientific problem boundary conditions. Since visualization” process can now be ac- the motion calculation utility uses a tivated and rendered. coordinate system of -1.0 to 1.0 with itsoriginatthecenteroftheimage(the RAINDROPm RENDERING window coordinates range from 1 to 1000), a set of transformation equa- Once the operator enters the ini- tions (wxl=, wyl=) between the two PRINT SCREEN UTILITY tial horizontal velocity, the motion of systems was employed. This was done FAST, compact PrtScrn Utility for end the ball is determined according to deliberately to demonstrate how mul- users AND developers. Hardcopy as fast as 10 seconds. Average binary size - 6 kbyte. 14 video graphic 100 i=i+l standards. Scale, rotate, colorize and wxl = dfloat(((x/0.002)+50O~*O.967) more. ‘Call’from user-written programs. wyl = dfloat((500-(y/0.0021)_60) Complete 9 and 24-pin dot-matrix, inkjet, and laserjet printers. call putimage_w(wxl,wyl,buffer,action(3f) ! erase . COMPLETE LIBRARY find new ball position ONLY $44.95

and test for boundary conditions

200 call putimage_w(wxl,wyl,buffer,action(3)) ECLECTIC SYSTEMS ! draw got0 100 3106 St. David Ct. l Springfield, VA 22153 (703) 44cunX4 FAX (703) 455-6965

listing 6-Once the operator enters the initial horizonfal velocity, the motion of the ball is For IBM-compatible computers determined and displayed.

October/November 199 1 37 tiple coordinate systems could beused its size. This offset was easily accom- actiondisplayed on your monitor.The interactively within a single visual- plished within the transformation insight gained speaks for itself. ization problem. And, since the ball is equation. But remember, visualization not a point, both the x and y window shouldn’t be viewed as the end result coordinates of the actual mapped ball THE VISUALIZATION EXAMPLE of a process of scientific analysis. In- image had to be offset to account for stead, it should be considered as part Once all the pieces described of the process itself. Its interaction above are put together, you end up with the concept of “human percep- REFERENCES with a working version of the bounc- tion” makes it more than a simple 1. Microsoft FORTRAN V&O, ‘Ad- ing-ball scientificvisualizationmodel. application of techniques for display- vancedTopics; MicrosoftCorpo- It would be redundant to list the final ing data. Used with thought, visual- ration, 16011 NE 36th Way, Box code here, but you can download it ization can be used as a paradigm for 97017, Redmond, Wash. 98073- from the Circuit Cellar BBS. exploringregionsof untapped knowl- 9717. 2. J.D. Foley and A. Van Dam, “Fun- edge. Visualization is not new, but its damentals of interactive Com- ONWARD AND UPWARD use as a perceptual tool and by the puter Graphics,’ Addison-Wesley general scientific community is. 4 Publishing Co., Reading, Mass,, By integrating physical simula- 1982. Chris Ciarcia kas a Ph.D. in experimental 3. W.M. Newman and R.F. Sproull, tion with visual simulation we have physics and is currently working as a staf ‘Principles of Interactive Com- been able to demonstrate the effec- physicist at a national lab. He kas extensive puter Graphics, 2nd ed.,’ tiveness of the scientific visualization experience in computer modeling of experi- McGraw-Hill, New York, 1979. process, even with such a simple ex- mental systems, image processing, and artifi- 4. ‘Visualization inscientific Comput- n’al intelligence. Chris is also a principal in ing; A Special Report of ACM ample as our bouncing ball. This vi- SIGGRAPH, Computer Graphics, sual approach has made the task of Tardis Systems. . 21, App E, (1987). pp. El-E7. data interpretationa simplerand more 5. A. Smith, ‘Volume Graphics and straightforward task. Just think of try- IRS Volume Visualization, A Tutorial,’ Pixar Technical Memo 176, Pixar, ing to scan lists of (x,y) data in order to 404 Very Useful San Rafael, Calif. (May 28, 1987). determine how the ball would move, 405 Moderately Useful and then compare that to the visual 406 Not Useful MS-DOS EPROM PROGRAMMING SYSTEM NEEDS NO INTERNAL CARD 0 s 04. *1.32 mnd 40’ pir, EEPROMS 2708.2758, TMS2716*, 2716 2804,2816A, 28Cl6 27Cl6,2516,2532*, 2564* 2817A*. 2864A. 28C64 68764*, 68766*, 2732,273ZA 28256,28C256,52B13* 27C32,2764,2764A, 27C64 52833* 27128,27128A, 27Cl28 27256,27C256,27512 874lA*, 8742*,8748(H)* 27CSl2,27513* 8749(H)* s751*, 87csl* 27011*, 27COll* (I MEG) 8752* 8753*. 8744* 27010,27COlO 27C1000,27C1001 27C020,27C2001 (2 MEG) 27CO40,27C4001(4 MEG) PARA : PORT ,A FAST. EASY-TO-USE SYSTE YORKS WlTA ANY DESK VP OR LAPTOP MACAlNE ‘EXPANDABLE. FL.EX4BL.E DI ;N SUPPORTS CURRENT, iD FUTURE DEV,CES 6UPP”RTS s. 16 & 32 BIT DA1 ‘ORMATS ,NCLCD,NG Wt :D SPLlT & DOUBLE WORD ,READS AND CONVERTS INTE ,EX, MOTOROLA S-RECO D AND RlNARY F,LES ‘BARDWARE PROTECTED AG IST DEFECTrVE AND ,NC RRECTLY ,NSERTED DE”,CES ,NO SOFTWARE INSTALLAT YECESSARY - PROGRAM DTALLY SELF CONF,GUR,NG SYSTEM OFTWARE Cc ,MMANDS .PROGRAM EPROM(S) .SAYE EPROM(S) OR .COPY EPROM(S) FROM D,SK FILE BUFFER TO DISK .“ER,FY EPROM ERASED .READ D,SK FILE ,NTO .PROGRAM EPROM(S) .SELECT BUFFER EDITOR BUFFER FROM BUFFER .SELECT DEUCE TYPE .;;t;PROM(S) INTO .COhwARE EPROM(S) .DE”,CE CEECKSUM W,T’B BUFFER .SET BUFFER (0. 1.2.3, ( PLUS AN INTEGRATED BUFFER EDITOR WITH 18 BYTE LEVEL COMMANDS 1 SYSTEM INCLUDES: PROGRAMMING UNIT, POWER PACK CONNECTING CABLE, OPERATION MANUAL & SOFTWARE $289 soFlU&RE AV*IL*BLE ON 3 ,,I” OR 5 1,s” DISK &P”“A”” SPPcIw CALL ABOUT OPTIONAL ADAPTERS - A Y)FT TRAVEL CA E IS AYAlLABLE FOR SIP.00 TO ORDER SEND CAECK, MONEY ORDER, WRITE OR CALL: ANDRATECH P.O. BOX 222 VISA piwq I MILFORD, OHIO 451.50 (513) 831-9708 ADD ss.00 FOR SHrnPlNC FAX ,513) 831.7562 ADD $‘%mI Km C.O.D. WRITE FOR MORE ,NFORMAT,ON OR CALL AND LlSTEN TO OUR vTALKMG’ DATA SBEEI

38 ClRCUlT CELLAR INK FEATURE Add a Video Display to ART’CLE Your 803 1 Microcontroller Larry Duarte Graphics and Color Liven Up Any Output

I J

The design I present here can be our choice. The chip includes full com- I n many control ap- used with most basic 8031-based cir- patibility with IBM CGA and MDA, plications, it is often nec- cuits, and requires minimal software Hercules, and high-definition CGA. It and hardware overhead. Since 8031- has an internal 6845 and character- essary to display informa- type circuits have been presented generator ROM, and requires just two many times in the past within the RAM chips and a clock to be fully tion of some form for hu- pages of this magazine, I’m only in- functional. In this article, the 72C81 is cluding those portions of the 8031 cir- configured for monochromeCGA; that man consumption. Most cuit necessary to clarify thediscussion gives us the ability to switch between (see Figure la). The video interface 80-column and 40-column modes, solutions have centered could also be adapted to other proces- which is very useful for small moni- sors with a few changes. tors. on one- or two-line LCD The 72C81 comes in an 84-pin THE NCR 72681 CGMA PLCC package. The pinout is shown displays because of their in the schematic in Figure lb. The heart of the video interface is small size and low cost. NCR’s 72C81 CGMA (Color Graphics ADDRESS DECODING and Monochrome Adapter). There are However, with the right lower priced alternatives, but its fea- The 72C81 was intended for use in interface, it is almost as tures and level of integration made it IBM-compatible display adapters, and easy and inexpensive to design into your circuit an 80-character by 25 line or 40-character by 25line video display which uses either mono- chrome or color. Video displays give you much more room to display text and graphic information, and color livens up any Adding a video display interface to yourmicrontroller design is straightforward to do using NCR’s 72C8 1 CGMA chip and allows the use of graphics and color to quickly improve any screen. user interface.

40 ClRCUlT CELLAR INK as such uses standard CGA addresses for its I/O ports and video buffer and includes 20 bits of address input. The 8031 does not support separate I/O and memory addressing, but does support two separate 64K areas known as Code space and Data space. In my setup, the system EPROM is mapped in Code space (selected by *PSEN) while RAM and I/O share Data space (selected by *RD and *WR). “Glue logic” wasnecessary to con- vert between the reduced 8031 ad- dress space and the much larger 72C81 space. In Figure 1, the 74LS138 breaks up the 8031’s Data space into eight blocks of 8K each. The fourth block- 24K to 32K-is reserved for I/O addressing. Reads from or writes to this area generate *IOR and *IOW through the 74LS32. The bottom 2K of the I/O block is further broken up by the 74LS154 into 16 blocks of 128 ad- dresses each. A memory map for this sample system is shown in Figure 2. The 74LS244s are used to move the 72C81 I/O port addresses out of the lower RAM area and adapt the 8031 16-bit address to the 20-bit ad- dress bus of the 72C81. They perform the following translation:

8031 Video Buffer 8000-BOO0 I/O Ports 63D4-63DC

73C81 Figure 1 a-Since 803 l-type circuits have been presented many times in the past, only Video Buffer B8000-BBOOO those portions of the schematic necessary to clarify the discussion are shown here. I/O Ports 3D4-3DC for the chip to operate properly. The to stop the processor clock without Thus, to display information you 72C81’s internal 6845 places a high losing the registers. We also don’t use only have to write to Data space be- priority on displaying RAM (so that the internal oscillator circuit of the tween addresses 8000h and BOOOh. To the CGA’s famous “snow” doesn’t CPU. Instead, a clock is generated ex- deal with the display’s control regis- flurry across the screen) and some- ternally (in our case using a 7404) and ters, write to addressesbetween63D4h times has to delay writes to the video is used to drive a 74LS74 and a 74LS32. and 63DCh. Dealing with the display’s buffer. Since the 8031 doesn’t have While the IORDY line is low, the clock control registers is the same as dealing any kind of “wait” or “ready” input, is passed through to the processor. with a standard IBM PC CGA board, connecting IORDY presents some- When IORDY line goes high, the clock so I won’t go into that here. There are thing of a problem. If we ignore is shut off, stopping the processor in plenty of excellent references avail- IORDY, we’ll likely lose information its tracks until the video processor is able that describe the CGA in detail. that was sent to the display, but ig- ready to continue. The 74LS74 guar- nored by the 72C81 since it was busy antees that turning the clock on and THE MISSING WAIT STATE doing other things. off is synchronized. The solution involves using the While documentation NCR pro- CMOS 8OC51 or 8OC31. These chips SOFIWARE vides for the 72C81 is very good, it use static memory for theinternal CPU fails to adequately stress the fact that registers, rather than dynamic as in Listing 1 shows a very simple in- the IORDY output must be hooked up most NMOS processors, allowing us terface to the video display. Its main

October/November 1 W I 41 Figure 1 b-The heart of the display interface is the NCR 72C8 1 CGMA chip. Whiie intended to be used to make graphics boards for IBM PC-compatible computers, it is read/y adapted for use by many embedded microcontrollers.

purpose is to initialize the display and I/O Map write “Hello, world” to the screen. It is written in C and can be compiled to Code Space 64~ 64~ Date Space ROMable code using the Franklin C cross-compiler for the 8031 (or anyone else’s compiler with some minor modi- Program ROM fications to the source). A few addi- 46K 1408 1012 27512 tions to this code should make it use- 1290 I011 WW video ful for any application. RAM 1152 1010 1024 109 Or . 32K 32K CONCLUSION 896 108 video uo 24K The circuit board components can 708 107 be purchased for about $35.00. For 640 106 27256 16K (32~) control applications, a small 5-inch to 512 105 P ram 9-inch monochrome monitor (color 384 104 “81 RY frequency, 12-volt supply1 can be 256 103 OK OK bought for $25.OOfromsurplus houses.

128 102 Plus 256 Bytes Internal RAM The ability to add a video display 24K 0 101 will be useful for many 8031 projects. NCR also has a similar chip that sup- ports VGA graphics. The NCR 77C22 Figure 2--The 805 I *s address space is broken into two regions: read-only Code space and supports the standard VGA modes read/write Data space. while providing enhanced modes such

42 CiRCUlT CEf LAR INK Data Acquisition /* TEST VIDEO PROGRAM */ #include /* special address method */ Solutions #define XBYTE ((unsigned char *) Ox2OOOOL) Reliable, Aflordable and Flexible #define VlIREG XBYTE [Ox63D4] /* video 6845 address reg. */ #define VlDREG XBYTE [0~63D51 /* video 6845 data register */ #define VlMODE XBYTE 10~63D81 /* video mode register */ #define VlCOLOR XBYTE [Ox63D9]/* video color register */ #define VlBUFF 0x8000 /* video frame buffer */

unsigned char let, curx, wry; unsigned short pos;

movcur() /* MOVE CURSOR TO POSITION X,Y */ (. IPCG711S 12 Bit A/D + D/A $295 1 unsigned har high, low; unsigned short x; 0 8 single-ended 12-bit analog inputs, 2.5 KHz l 1 D/A, 16 digital inputs, 16 digital outputs pos = (unsigned short) (curx + (unsigned short)(cury*80)); high = (pas / 256); l Wirine terminal board and cable included low = (pos - (high * 256)); VlIREG = OxOE; 1PCG812 A/D + D/A + DIO $395 1 VIDREG = high; l 16 single-ended 12-bit analog inputs, 30 KHZ VlIREG = OxOF; VlDREG = low; 0 A/D with multiple ranges, DMA, interrupt l 2 D/A, 16 D/I, 16 D/O, counter, pacer l QBASIC driver, utility software and manual scrn800 /* SET SCREEN TO 80 COL */ PCL-818 High Speed A/D $875 1 VlMODE = 0x01; VlIREG = 0x00; VlDREG = 0x71; VlIREG = 0x01; 0 16 S.E. or 8 differential 12-bit A/D, 100 KHz VlDREG = 0x50; VlIREG = 0x02; l Programmable ranges, auto channel scanning VlDREG = Ox5A; VlIREG = 0x03; 0 A/D with direct I/O, interrupt or DMA VlDREG = OxOA; VlIREG = 0x04; VlDREG = OxlF; VlIREG = 0x05; a 2 D/A, 16 D/I, 16 D/O, counter, pacer VlDREG = 0x06: VlIREG = 0x06; l Supported by most popular DAS software VlDREG = 0x19; VlIREG = 0x07; VlDREG = OxlC; VlIREG = 0x08: PCL726 6 Ch. 12-Bit D/A $495 1 VlDREG = 0x02; VlIREG = 0x09; VlDREG = 0x07; VlIREG = OxOA; 0 6 12-bit analog outputs, voltage or 4 - 20 mA VlDREG = 0x06; VlIREG = OxOB; l 16 digital inputs and 16 digital outputs, utility VlDREG = 0x07; VlIREG = OxOC; VlDREG = 0x00; VlIREG = OxOD; IPCL-722 144 Ch. Digital I/O $345 1 VlDREG = 0x00; VlIREG = OxOE; VlDREG = 0x00; VlIREG = OxOF; 0 144-channel digital I/O with interrupt VlDREG = 0x00; 0 Emulating 8255 mode 0, buffered circuits for VlMODE = 0x29; high driving capacity, I/O . programmable VlCOLOR = 0x00; 0 Compatible with OPTO-22 I/O racks curx = 0; cury = 0; IPCG720 DIO and Counter movcur(); $175 1 a 32 D/I, 32 D/O, 3 programmer counters clrscrn0 l User selectable counter clock source ( 0 Breadboard area for customized circuits unsigned char a, b; unsigned short c: Signal Conditioning and more . . .

l Wiring terminal, isolated D/I, relay output, c = 0x8000; /* START OF VIDEO BUFFER */ for(a = 0; a != 25; at+) relay driver, scanner, multiplexer, amplifier for(b = 0; b !=80; b+t) l Interface for thermocouple, RTD, strain gage 1 . IEEB-488, RS-23214221485, stepping motor XBYTE [c] = 32; /* SPACE */ l Industrial PC chassis, 286/386/486 CPU ctt; XBYTE [c] = 15; /* NORMAL ATTRIBUTE */ cards, RAM/ROM disks, PC-bus card cage c+t; 1 Free 120-page curright /* MOVE CURSOR RIGHT */ reference guide t unsigned char a; for your system if (cury == 24 && curx == 79) and OEM needs return; if (curx == 79) { curx = 0: cury++; movcur(); lndustdal 8 Lab Auton@ion with PCs return; 1 ADWNECH. 1310 Tuily Rd., Suite 115 listing 1 -Most of the code necessary to drive the display is used to initialize the contfo//er San Jose, CA 95122, USA chip. Once set up, displaying text is straighfforward. (408) 293-6786, FAX (408) 293-4697 Reader service # 107 October/November 199 1 43 curx++; movcur(); 1 as 640 x 480 with 256 colors and 800 x 600 with 16 colors. The only problem scrnprt() /* PRINT CHAR TO SCREEN */ ( is going to be its packaging: a WI-pin unsigned short realpos; surface-mount quad flat pack doesn’t realpos - ((2 * pas) + 0x8000); XBYTE [realposl = let; lend itself to easy prototyping. For realpos++; now, and for most control applications, XBYTE [realposl ~15; curright{); the 72C81 will be quite adequate. +& ) printf(5) /* SIMPLE STRING PRINT FUNCTION */ char *s; ( CONTACT char *p = s; movcur(); NCR MIcroelectronics Divfslon while(*p != '\O') ( 1635 Aeroplaza Dr. iet = *p; Colorado Spilngs, CO 80916 scrnprto; p++: (800) 5252252 1 (303) 5965611 1

main0 ( Larry Duarte has designed hardware, fit-m- unsigned short x; ware, and software for a number of companies, for(x = 0; x != 10000; xt+) /* DELAY FOR UNIT TO doing applications rangingfrom cyptograph- STEADY */ its to point of sale. scr'n80 0 - clrscrn(j; printf(*'Hello, World!"); IRS 1 407 Very Useful 408 Moderately Useful listing 1 -continued 409 Not Useful

The Circuit Cellar Project File, Volume 1 has page after page of new or expanded hands-on projects and tutorials. Circuit Cellar INK’s editors have chosen a dozen of the top projects from the Circuit Cellar Design Contest, independent submissions, and top-response articles to make a book with something for every interest. You’ll get projects about:

l A VCR Data Backup Card l An LCD Namebadge

l A Digital Joystick Port for Your PC l A Car-computer Diagnostic Tool l An Electronic Combination Lock

* A Power-line Frequency Monitor l An LCD Tester l Building & Debugging WOO Multitasking Computers

All of this is yours for only $24.95 (includes domestic delivery’) Order your copy today! The Circuit Cellar Project File, Volume 1 4 Park Street l Vernon, CT 06066 Tel: (203) 8752199 l Fax: (203) 872-2204

See this book al The End&fed Sysrerm Conference Boofh #8 The lMICON496KC “16-BIT Personal Controller”m COMPLETE DIGITAL CONTROL SOLUTION - HARDWARE & SOFIWARE DEVELOPMENT KIT

MICON-196KC “l&BIT PERSONAL CONTROLLER’h comprises of two parts (kits) 1. The HARDWARE DEVELOPMENT KIT contains: - CPU MODULE (3.5%X.6”) with 6OC196KC prooessor (16 MHz) has 8 ADC channels lOBit resolution, 3 Pulse-Width-Modulated outpub (DAC), one DMA ohannel, 6 High-Speed Output channels, 4 High-Speed Capture Input ohannels, 40 Digital I/O ports, one full duplex RS-232 serial port; - MEMORY MODULE (b5”x3”) with 64K M emery space RAM and/or EPROM; - Z-Connectors BUS MODULE; - PROTO MODULE (3.6k3.5”) with a 3-Conneatora Bus Module; - POWER SUPPLY & 6FT BS-232 COMMUNICATION CABLE 2. The SOFTWARE DEVELOPMENT KIT contains: - PC based SYSMON - System Monitor for software development phase; - SOC196 Machine Language Assembler; - User’s Guide with HARDWARE SCHEMATICS and APPLICATION DEMO PROGRAMS. COMPARE US AGAINST THE COMPETITION FEATURES: MICON-196KC COMPETITION MODULAR ARCHITECTURE YES NO PROTOTYI’ING MODULES YES NO MICONA Corporation COMPACT FOOTPRINT YES NO MICON Division 8OC196 Assembler, SYSMON (system Monitor) INCLUDED PAY EXTRA Power Supply & Communication Cable INCLUDED PAY. EXTRA 1885 Surveyor Ave. Bldg. 102 SIMI VALLEY, CA 93063 THERE IS NO COMPARISON ! TEL: (805) 522-9444 The MICON-196KC “1BBIT PERSONAL CONTROLLER”m sells for: $245.00 FAX: (805) 522-9779 Quantity & students discount. P.O., Visa & MC accepted. Immediate delivery.

BTK52 BASIC-52 TOOLKIT The BTK52 is an intelligent front end for program development on the DIGITAL DESIGNERS MC5 BASIC-52 CPU. It reduces 8052 prograr development time substantially and can be used with any MCS BASIC-52 based target MINIMIZE YOUR LOGIC system. The BTK52 runs on any IBM-PC/XT or compatible.

l Program download from PC host to tdrget

l Program upload from target to PC host . BASK program renumber utility, with “irom, * “through, ” “start, n 2nd “fncrement” . Full streen program editmg

l Single line editing with automatic error line number detection

l Full on-/,ne help f~ihty

l Transparent, adaptive line compression ior id/ fnput line buffer utilization

l A// func tnns a cesGb/e wh only one keystroke tram the termfnal emulator

l $125 KARNAUGH MAP SOLVER FOR PC’s BXC51 805118052 BASIC COMPILER Minimum Gates from Your Specs l Fully compatible with code written for MCS BASIC-52 interpreter l Combinational, Sequential l Now with integer, byte and bit extensions for code that runs more than 50 times faster than the MSC BASIC-52 interpreter l Mealy & Moore State Machines

l Full floating point support l 2 to14 Inputs, Any Number Outputs l In-line assembly language option l Sum of Products, Product of Sums 0 Compile time switch to select 805 l/803 I or 8052/8032 CPUs

l includes Binary Technology’s SXA-57 cross-assembler and Hex file l JK, D, SR, and T Flip Flops

manipulation utility l Expert Reference and Tutorial l Compatible with any RAM or ROM memory mappmg l 60 Day Money Back Guarantee l Runs on IBM-PC/XT or compatible l MUCH MORE l $295 SAVE 40% : $1 10 +&PW 603-469-3232 l FAX 603-469-3530 Binary Technology, Inc. Man Street . P 0 Box 67 . Merlden NH 03770 q mIEE3

ReaderSetie I1 15 October/November 199 1 45 FEATURE ARTICLE Part 2

Steven E. Sffuuss ISDN (S/T) Interface % P.K. Govind Design Example of a PC Plug-in Board

I n Part 1, we discussed the key *Call setup for either voice or T7540 are programmed via the PC elements of the ISDN (2B+D) Basic data conversation on any B channel. bus interface. Rate Interface (BRI) standards. Now aDisplay of Layer 2 and Layer 3 2. Data Port. Data transfer on the we present a design example of an flow control parameters for D chan- B2 channel is supported by the T7121 integrated voice and data communi- nel traffic. HDLC formatter. It connects to the cation circuit which supports the l File transfer exercise on a cho- PC bus interface and transfers data to CCITT 1.430/ANSI T1.605 BRI stan- sen B channel. and from computer memory. It also dard. The design uses AT&T’s family connects to the T7250B for serial data of ISDN devices and includes an in- HARDWARE DESIGN exchange on the B2 channel. terface to an IBM PC host computer. 3.2B+D Framer and D channel Sig- The hardware was built on an XT- A block diagram of the BRI naling Port. The T7250B provides the style card and installed in a spare ex- adapter board is shown in Figure 1. It user-to-network interface for ISDN pansion slot. The application software is subdivided into five sections. We connectivity. D channel processing is contains Layer 2 (1.441/Q.921) and will begin with a quick summary of provided via the embedded HDLC Layer 3 (1.451/Q.931) D channel call each section and then move on to a formatter of the T7250B, which has management functions conforming to more detailed description of the indi- 16-byte FIFO buffers in both transmit the AT&T 5ESS central office switch. vidual sections. and receive directions. This architec-

HARDWARE HIGHLIGHTS

aLine interface support and (2B+D) multiplexing is provided by the T7250B line transceiver for terminal end- T7540 T71.21 T725OB 12718AM tran41armersj points. D channel operation is handled using the 16-byte internal FIFO buffers. l B channel voice port Local Bus support with speakerphone functionality is provided via I I the T7540 digital telephone PC Bus Interface Address Data Bus Buffers Device Control Circuitry Decoders Programmable Array Logic CODEC. I l B channel data port I I 1 support with HDLC or non- HDLC protocols is provided Figure I -A simplified block diagram of the (2B+D) BRI adapter board for the IBM PC. by the T7121 synchronous data formatter which has 64-byte buff- 1. Voice Port. Voice access is pro- ture simplifies the software imple- ers in the transmit and receive paths. vided by the T7540 digital telephone mentation of LAPD (Link Access Pro- CODEC. It connects to the user-pro- cedure for the D channel), which is SOFTWARE HIGHLIGHTS vided handset, a speakerphone, and used to set up B channel voice and an auxiliary alerter via 4-pin RJ-11 data calls. *Menu-driven operation to exer- modular jacks. It transfers digitized 4. Line Termination. Line trans- cise each device separately, with ac- voice to the T7250B on the Bl chan- formers, protection circuitry, and re- cess to internal registers. nel. The operational parameters of the sistor circuitry are contained in this

46 ClRCUi7 CELLAR INK Handset _ Gain Control ,Dx Analog Audio ---) Codec ---) Serial TDM Speaker/ Blocks & Microphones Interface Programmable (p or A law) Highway _Dr b Filters - Interface

-T- --I- -T-

Figure 2-A simplified block diagram of the AT&T V540 digital telephone CODEC. section. This circuit is connected to division-multiplexed bus. This serial amined over the entire channel band- the T7250B line transceiver section. highway is programmable and ac- width or an 800-Hz second-order The physical interface for ISDN basic cepts variable data rate clocks rang- high-pass filter can be selected. Speech access is provided via an &position ing in frequency from 64 kHz to 4.096 tends to have a large part of its en- RJ-45 modular jack. MHz. The serial highway interface ergy above 800 Hz, whereas room 5. PC Bus Znferface Circuitry. The connects directly to most PCM buses. noise has a significant part of its en- BRI adapter board is mapped into the In our design, the KM interface con- ergy below 800 Hz. Selecting the 800- I/O space of the PC with address lo- nects directly to the T725OB ISDN S Hz high-pass filter will reduce the cations ranging from 200h to 3FFh. interface chip. The parallel micropro- need for gain switching due to noise. Data bus buffering between the local cessor interface of the T7540 is - To reduce the amount of micro- bus and the PC bus is provided by a ible and is interfaced easily with Intel processor overhead required to moni- bidirectional bus transceiver. Address or Motorola . In our tor the voice signals, maximum-value decoding for chip selects and device adapter board design, the PC micro- registers are provided on the T7540 control signals are also provided in processor (80x86) controls the trans- to obtain an envelope of the received this section. fer of information in and out of the and transmitted voice signals. These programmable internal registers of maximum-value registers retain the VOICE PORT WITH SPEAKERPHONE the T7540. highest value of the, received signal FUNCTIONALITY The three analog audio interfaces since the last register read was per- of the T7540 are the handset, hands- formed. The maximum-value method The AT&T T7540 digital tele- free, and auxiliary interfaces. Each of can provide a reasonable representa- phone CODEC (Figure 2) provides these interfaces consists of a differen- tion of the signals for a period of sev- the flexibility needed to support a va- tial input and a differential output. eral milliseconds. The time required riety of analog voice ports. Audio The handset and auxiliary outputs can between register reads depends on functions include a CODEC-filter fea- drive a 300-Q load directly and are the hands-free algorithm developed turing CL/ A-Law companding. Addi- programmable from +0 to -23.25 dB by the user. Figure 3 shows how the tional voice port functions include in increments of 0.75 dB. The speaker T7540 is wired on the BRI adapter programmable touch-tone (DTMF) output can drive a 50-Q speaker di- board. generation and ringer tone genera- rectly and is adjustable over a 69-dB tion. The device also contains a pro- range in 1.5-dB steps. DATA PORT INTERFACE grammable sidetone insertion inter- The T7540 provides the function- face. The T7540 is controlled via an ality needed to support microproces- Data transfer on the ISDN B2 external . sor-controlled hands-free speaker- channel is supported by the T7121. It The T7540 has a serial interface phone operation. The microprocessor connects the serial communication for digitized voice, a parallel inter- monitors and controls the system in link carrying High-level Data Link face for microprocessor control, and such a way that the coupling from Control (HDLC) bit-synchronous data three pairs of differential analog au- the speaker to the microphone and frames to the host PC. There is an dio interfaces to the handset, hands- poor hybrid matching does not result optional transparent mode of opera- free speakerphone, and auxiliary in oscillations, ringing, or unpleasant tion in which no HDLC processing is equipment such as answering ma- echoes. performed, allowing the use of other chines or alerters. The T7540 provides signal moni- protocols (Figure 4). The T7121 com- The serial KM interface for digi- toring of the transmit and receive municates with the PC as an I/O- tized voice is a fullduplex serial time- paths. Received signals may be ex- mapped peripheral and is controlled

October/November 199 J 47 via programmable registers. The HDLC transmitter and receiver are each provided with 64 bytes of FIFO storage. The 64-byte buffer depth re- duces the number of status polls, thereby reducing the number of in- terrupts to be processed by the PC. The 17121 is directly connected to the T725OB in our design (Figure 5). This is made possible by the flex- ibility of the serial bit transport inter- face on the T7121. The l7250B pro- duces all clocks and frame strobes necessary for the T7121 to properly function in a TE application.-

2B+D FRAMER & D CHANNEL SIGNALING PORT

The network interface for ISDN (2B+D) access is handled by the - satile T7250B. This device conforms to the BRI specifications of the 1.430/ T1.605 standard, outlined in Part 1. Figure 6 shows how the T7250B is Figure 3-cmuir connections for the T7540 on the BRi UdUPtef board. connected in our integrated voice and data application. The Bl channel is driven by an external clock source at VSSR, RPR, RNR, VT, and VDDR connected to the T7540 for voice trans- 6.144 MHz. are inputs to the line receiver. RPR port. The B2 channel is connected to VDD, VSSl, and VSS2 provide and RNR are the transformer connec- the T7121 for data transport. With this power and ground to the device. VSSl tions. The VT input allows an exter- hardware arrangement, it is also pos- is the ground reference for input buff- nal decoupling capacitor to filter noise sible to swap the Bl and B2 channels ers and other internal logic. VSS2 is from the receiver’s voltage reference by programming the T7250B to inter- the ground reference for the output level. Separate power and ground nally exchange the Bl and B2 octets. buffers. VDD is the power input for pins for the receiver, VDDR and VSSR, The D channel processing does not all the digital logic. minimize noise problems. require an external HDLC formatter CS\, RD\, WR\, AO-A3, DO-D7, RXDATA contains the 2B+D se- since the T7250B formats the D chan- RESET, and INT form the micropro- rial bit stream received from the net- nel information internally as it con- cessor interface (PC bus interface). work. CKCOD, MCKBI, FSEBl, structs the BRI (2B+D) frame. Sixteen- byte FIFO buffers allow efficient pro- cessing of D channel data by reduc- ing the interrupt overhead for the PC. Tranqwmt Mode A block diagram of the T7250B is I given in Figure 7. We will briefly de- scribe the functionally related groups DXA of pins in Figures 6 and 7. DXB Internal Register VDDT, TNR, REXT, and TPR be- Bank ~twi$LILMk CLKX a long to the line transmitter. TPR and Microprocessor Highway CLK Bus Interface ++ Interface TNR are the transformer connection FS points. REXT sets the transmitter out- DRA put current and VDDT is a dedicated “‘R”B” Receive power pin for the line transmitter. - FIFO HDLC TXBl and TXB2 are the inputs for 64 bytes Receiver - the B channel information to be trans- I mitted to the network. Transparent Mode CKG/XTALI and XTALO provide direct connections to a crystal. Alter- natively, the CK6/XTALI pin may be Figure 4-A simplified block diagram of the AT&T l7 12 I HDLC formatter. 3 48 ClRCU/T CELLAR INK FAST COMPLETE ACCURATE CKB2, and FSEB2 provide the pro- the 16-byte queue via R3. A transmit- grammable clock and strobe signals frame-complete tag bit is then set in a DRAM TEST associated with the Bl and B2 than- control register after writing the last nels. All clock and strobe signals are byte of data to the queue. The l725OB DIPS - SlMMs - SIPS synchronized to the 2.048-MHz clock, automatically handles HDLC fram- CKCOD, to reduce CODEC noise ing and transmits the D channel data. problems. The RESET pin resets the Received data is automatically loaded l725OB and restores all the default val- ues of its internal registers. ~l7121_IRcn The T7250B has DZWlSCA\ two register banks: Y the foreground bank of 16 registers +5V DIG

(RO-R15) and the +SV DIG background bank of nine registers (BRl- I BR9). The fore- ground registers Li 0.01 pF provide most of the chip operation con- trol and status infor- mation. The back- ground registers RAMSTAR provide additional functionality such - Ins. RESOLUTION as D channel ad- ACCESS SPEED VERIFICATION dress recognition, 80 ns. thru 180 ns. (Std.) $249.00 autoactivation, and Figure 5- Circuit connections for the T7 12 1 on the BRI adapter 45 ns. thru 110 ns. (Fast) $349.00 parallel readout of board. 4MEG Option Add $ 89.00 a selected B channel. AUTO-LOOP An optional serial data transfer mode into the 16-byte queue after HDLC Continuous Test 6.25 MBitskec. may be programmed to provide con- processing. The queue manager also \DAPTERS: tiguous access to 18-bit (2B+D) infor- creates an end-of-frame status byte mation groups. This feature is useful for each frame and stores it in the SIMM/SIPADAPTER $189.00 for 144-kbps clear channel applica- Tests 64K, 256K, 1 M & 4M Devices queue if an end-of-frame condition 8 or 9 Bit versions. tions (e.g., compressed video) where has been detected. Status information the B and D channels are not chan- is also available in a separate register. neled into 64-kbps and 16-kbps par- The transmit and receive FIFOs may cels. In our design, for the purpose of be programmed to specific fill levels this article, we only use the standard and the T7250B may be instructed to ISDN channel-structured mode of interrupt the controlling microproces- operation. sor. The interrupts are also maskable The background registers are ad- to allow a polled mode of operation. 4 X ADAPTER $ 89.00 dressed the same way as the fore- Tests 64K & 256K By 4 Bit Devices ground registers. Functions provided LINE TERMINATION

AC ADAPTER $ 18.00 by the background registers are ac- Regulated +5V @ 1Amp. cessed by setting three bits in R15 of The T7250B meets the 1.430/ the foreground bank. Even when the T1.605 line transceiver requirements FREE RAMFACTS background registers are in use, the at the ISDN S/T reference point when DRAM NEWSLETTER foreground registers RO and R15 are a transformer with a 2.5: 1 turn ratio always accessible. The foreground is used. Our design (Figure 8) uses a registers Rl-R14 may be accessed by pair of AT&T 2718AM transformers resetting the three bits of R15. which have a very ‘small leakage in- COMPUTERDOCTORS D channel HDLC operation is ductance and self capacitance. Trans- 9204-B Baltimore Boulevard handled by a built-in queue manger. former selection is a crucial element College Park, Maryland 20740 The user loads the LAPD bytes into in meeting the line interface imped- vfADE IN U.S.A. U.S. PATENT No. 4.965799

ReadersGlvice 1126 50 CIRCUIT CELLAR INK ante requirements of the BRI stan- have extremely low capacitance and be removed if the 100-Q termination dard. The transformers also isolate exhibit a very low forward voltage is included in the premises wiring for the integrated circuits on the BRI drop when forward biased. They also passive bus operation. board from line transients. have an integrated protection ring to The resistor network in the trans- protect against extreme static dis- PC BUS INTERFACE CIRCUlTRY mit path and the resistor network in charges. The protection circuitry the receive path are used to meet the shown here is very minimal, since our Figure 9 shows the PC bus inter- electrical requirements of the stan- board is intended for a laboratory and face circuitry. Our design uses a total dard. test environment only. of 96 PC I/O addresses, separated Line protection from static dis- Jumpers J3 and J4 are used for into two distinct blocks of 64 and 32 charge transients varies from instal- 100-R terminations of the receive and bytes each. The block of 64 bytes is lation to installation. On our board, transmit loop, respectively. These used to decode the complete I/O we use a simple protection scheme. jumpers should be in place when the space for the T7540 digital telephone Dl-D4 and D5-D8 are BAT85 Philips board is being used in point-to-point CODEC and address its internal reg- Schottky barrier diodes. These diodes configurations. These jumpers should isters. The second block of 32 bytes is used to decode the I/O space for the

I- T7250B and the T7121 HDLC data formatter, each of which contains 16 fromS50.00 internal registers. Splitting the I/O Cross-Assemblers addresses into two distinct blocks al- Simulators from$lOO.OO lows easy mapping to the available PC I/O address space. The user must Cross-Disassemblers fromSlOO.00 be careful to use an I/O area which is currently not being used by the PC Developer Packages for other peripherals. from $2OO.OO(a $50.00 Savings) A 74LS245 8-bit bidirectional buffer driver (ICl, Figure 9) buffers Make Programming Easy the PC data bus. Note the PC data Our Macro Cross-assemblers are eas to use. With powerful bus is brought directly to the buffer conditional assembly and unlimited incluJe files. input pins (2-9). The buffered PC data bus, referred to simply as DO-D7, is Get It Debugged--FAST routed to devices on the adapter Don’t wait until the hardware is finished. Debug your software with our board. Simulators. The enable signal for ICI is de- Recover Lost Source! rived from IC6, a Programmable Ar- Our line of disassemblers can help you re-create the original assembly ray Logic (PAL) device. The PAL is language source. programmed to logically AND all the active-low chip select signals for the Thousands Of Satisfied Customers Worldwide I/O-mapped peripheral devices lo- PseudoCorp has been providing quality solutions for microprocessor cated on the adapter board. If the problems since 1985. ISDN interface adapter board is be- Processors ing accessed, IC6 outputs an active- Intel 8048 RCA 1802,05 Intel 8051 Intel 8096,196kc low signal to the enable lead of ICI Motorola 6800 Motorola 6801 Motorola 68HCll ?;3$&()5 (pin 19). This action takes ICI out of Hitachi 6801 Motorola 6809 MOS Tech 6502 the high-impedance tristate mode and Rockwell 6502 Intel 8080 85 Zilog 280 NSC 800 Hitachi HD64180 Mot. 68k,8,10 enables its output buffer drivers. The data bus (DO-D7) is driven either by New the PC or by one of the devices on the Zilog 28 Zilog Super 8 board. l All products require an IBM PC or compatible. The direction of the data flow is determined by the system read pulse, PC_IOR\. When PC_IOR\ toggles to For Information Or To Order Call: a logical low, the PC reads data from the selected device on the board. Con- PseudoCorp sequently, data flovirs from the board 716 Thimble Shoals Blvd, Suite E to the PC. Otherwise, data flow is Newport News, VA 23606 from the PC to the board. The default (804) 873-1947 FAX:(804)873-2154 condition for data flow is from the PC

Readersewice #192 October/November 199 1 5 1 to the adapter board. Uti- lizing this scheme mini- mizes bus contention problems which can hap pen in memory- or I/O- mapped systems. IC2, a 74LS244 octal bus driver, buffers the PC address lines PC_AO-PC-A4 and the read and write (IOR\ and IOW\) bus control signals. These signals are used by the I/O-mapped peripheral devices, the T7540, T7121, and the T7250B Interrupt control functions are provided using a 16L8 PAL (see IC 10, Figure 10). This logic has been included to ex- pand the maskable inter- rupt ports to three pri- oritized interrupt ports. In our design, there are two interrupt sources. Figure 6-Circuit connections for the 772508 on the BRi adapter board The interrupt inputs are T725OB_IRQ\ and T7121_IRQ\. The RD_STATUS\, is asserted (active IRQ) to identify the source of the in- T7540 does not have an interrupt pin. low). This causes IClO to turn on its terrupt. The lines 105108/(D3-DO) The interrupt inputs are multiplexed output pins 102-108 (pins 13-19). and 102/D6 are masked by the inter- to present an active-high interrupt These outputs are directly connected rupt handling software since they are pulse to the PC via jumper J5. to the buffered local data bus leads unused in our design. Once the inter- When IClO issues an interrupt to D6-DO. The PC examines 104/D4 rupt source has been identified, the the PC, an I/O read qualifier signal, tT7121_IRQ) or 103/D5 (T7250B_ interrupt output signal from IClO clears, allowing further interrupts. CKCOD REXT I 1 I -- TXBl SOFTWARE DESIGN MCKal FSEBl The modular soft- RXDATA ware is designed to sup TX92 I - I I L RNR port the call manage- CK92 VT ment functions for ISDN FSEB2 XTALI Layer 3 as defined in D-Channel HDLC XTALO CCITT Recommendation CKDM I.451 (Q.931). It also sup- ports Layer 2 flow con- 1 TIMOUT trol functions on the D

I I ” 1 channel as defined in the PWRDN Recommendation I.441 SYSCKO (Q.921). The Layer 1 de- vice drivers are specifi- cally designed for ISDN TE applications using the AT&T’ devices, the T7250B, the T7121, and the T7540. Layer 2 and Layer 3 software is an 1s~ WI lnterfaca 8-pin modular jack

5kn. 1% 2710AM Line RPR

- FromNT

Line RNR 27256 EPROM EMULATOR 34.8n.l% 34.~~ 1% 0.w -

Emulates 2754,27125, & 27255 EPROMs.

Plugs into target EPROM socket and connects to PC parallel port via telephone cable.

Loads Intel, Motorola, hex, and binary files.

Reset outputs restart target after downloading.

Downloads 32K in 2 sec. Iv-45 (12MHzPCAT) $199 Figure O-Line termination circuitry for the ISDN BRI board at the (WI reference point. adaptation of the DGM&S ISP188 nary ones may be sent to the T7540 to 27010 EPROM EMULATOR package designed for the MS-DOS silence the CODEC when the handset environment of the PC. The general is not in use. Up to 4 units can be daisy-chained to structure of the software modules is The B channel data exchange emulate consecutive EPROMs and to shown in Figure 11. module supports the functions pro- support 18 and 32-bit systems. vided by the T7121 HDLC formatter. LAYER 1 DEVICE DRIVERS Queued packets are transferred via the 64-byte-deep FIFO buffers in the The device driver modules con- T7121. If needed, the HDLC opera- trol and monitor the operation of each tion may be bypassed to carry user- device. The following functions are defined bit synchronous protocols. L - provided for the voice, data, and sig- The module for D channel opera- Emulates 2754, 27128, 27256, 27512, and naling ports: tion contains the following tasks: 27010 EPROMs. l B channel control-T7540, (a) transmit and receive LAPD Plugs into target EPROM socket and connects T7121, T7250B frames from Layer 2 to PC parallel port via telephone cable. l B channel voice control-T7540 (b) activate or detect activation at Reset outputs restart handset gain, filter selection the (S/T) interface target sytem. l B channel data exchange- (c) deactivate or detect deactiva- $349 T7121 tion at the (S/T) interface l D channel operation-T7250B (d) detect or report link error con- The B channel control module al- ditions to the ISDN TE state manager lows access to voice port operations The ISDN INFO state control provided by the T7540, the data port module supports all activities at the operations provided by the T7121, and bit transport level of the (S/T) inter- the channel selection provided by the face by controlling and monitoring T7250B. the line transceiver functions pro- The B channel voice control mod- vided by the T7250B: for example, the ule provides volume control, DTMF transmission of INFO 1, INFO 3 and generation, and alerting tones to the the reception of INFO 2, INFO 4 us- handset or the speakerphone con- ing the line transmission registers of

nected to the T7540. In addition, bi- the T7250B. Reader Setie #187

October/November 199 I 53 le.6 (PAL)

r-i E ICl(245)!

IC5 (LS682 I-D-? PC_AEN 17 P7 PC-AS 15 P6 pc_tom Iom pc_IOw\ m-m 13 P5 IOWl E-M A0 PC-A7 11 .-P4 P-Q CS T754Oi \ PC-A6 8 ~ P3 PC-Al Al To T7540. T7121, T72508 6 P2 CS T725OS\ PcA2 A2 A3 Pi PC-A3 A4 / NW PC-m Q7 06 105 CS T7121\ ~ 04 P>Q Q3 cl2 Ql Qo (from IC2)

Hgure Y - Ine PC ws mertace Tar addess decoding and data bus buffering on the ISDN BRI board.

LAYER 2 IAPD manager. Memory management lish, maintain, and disconnect net- structures allow the transfer of data work connections at the ISDN inter- The purpose of the LAPD proto- bytes via the FIFO buffers of the face using the resources of Layer 2 col standard (1.441) is to provide the T7250B HDLC data formatter. and Layer 1. It provides call control following services: procedures via message structures to *one or more data link connec- LAYER 3 SOFTWARE set up, connect, or release a call on tions on the D channel using the ad- the B channel. dress field of each LAPD frame (Fig- The I.451 /Q.931 Layer 3 standard The Layer 3 software module is ure 12) documents the procedure to estab- implemented in subblocks following *two types of information trans- fer: unacknowledged UI (unnum-

bered information) frames and ac- IClO. PALl6L6 knowledged multiple frames using +SV DIG extended (module 128) frame num- bering *establishment of and release of multiple frame data links *full implementation of timers T200 (transmit initiation) and T203 (max time without frame exchange) *detection and recovery from frame sequence errors *display of variables and excep- tions associated with established links The software module for LAPD provides the interface to Layer 3 and

Layer 1. It also links to the TE state :igure IO--The interrupt control logic section of the lSDN BRI bourd.

54 ClRCUlT CELLAR INK Data Call Keyboard Conversation File Transfer

Operating System Application Interface Utilities C Language

ISDN Layer 3 Call Reference Control, “Tr’ State - Module - Packet Format Control, Manager Layer ‘YLayer 2 Control

Layer 2 Frame Buffer - LAPD Queueing, Module Flow Control

Signaling INFO Layer 1 Voice Port Data Port Port state - Device - Control Drivers T7121 T725OB

Bl 82 D I

IISDN BRI Line

Figure 11 -General structure of the software environment.

Flag Address Control Information CRC Flag LAPD Frame

Octet 2 Octet 2 is transmitted first; within each octet, Octet 3 the least-significant bit (LSB) is the first bit

Figure 12--7he bit fields of an LfJAD frame contain complete address, control, and data in- formationplusCRCerrorcheck- ing. n I?. SAPI=Service Access Point Identifier 6 TEI = Terminal Endpoint Identifier C/R = Command/Response Bit EA = Extension Address (O=extend; I= Final)

October/November 199 I 55 the protocol control diagrams of the Steven Strauss is a licensed Professional Engi- Q.931 standard. Each subblock is neerandamemberoffhetechnicalstaffat REFERENCES treated as an independent task under AT&T Bell Laboratories in Allentozun, Pa., the control of the application program specializing in communications devices. He 1. T7540 Preliminary Data Sheet, holds a B.S.E.E. from Pennsylvania State D!X9-148SMOS. AT&T Micro- interface and TE state manager. The University and an M.S.E.E. from Rensselaer electronics, 1991. functional signaling supported in the Polytechnic Institute in Troy, N.Y. 2. T725OB Advance Data Sheet, Layer 3 module has been tailored for DS89083SMOS. AT&T Micro- electronics, 1989. the services offered by the AT&T 5ESS P.K. Govind is a distinguished member of the 3. T7121 Data Sheet, DS90- central office switch. Layer 3 software technical staff at AT&T Bell Laboratories in 087SMOS. AT&T Mlcroelectfon- to support new supplementary ser- Allentown, Pa. He is an application wnsult- Its. 1990. vices or to support other central of- ant for communication a!evices and has exten- fice switches requires some custom- siue experience in product planning, system ization. Such customization is avail- integration, and product akvelopment. Mr. IRS Govind received an M.S. and Ph.D. in physics able from third-party vendors such 4 10 Very Useful from the Unimsity of Colorado, Boula%r,Colo. as Link Technology, Holland, Pa., and 411 Moderately Useful DGM&S, Mt. Laurel, NJ. Since our 412 Not Useful software was very coarse and only served to test our design, we feel it would cause more problems than it would solve to release it.

INTEGRATED VOICE/DATA ADAPTER BOARD SUMMARY

The ISDN adapter board design outlined here provides a low-cost, high-performance terminal endpoint. This board allows users to simulta- neously access both voice and data services of an ISDN BRI line at the S or T reference point. The PC plug-in board can operate in any IBM-com- patible computer using the industry- standard architecture (ISA). A four-layer printed circuit board with the functionality outlined in this article has been prototyped and tested. The adapter board design pro- vides the audio functionality needed in a digital telephone or an integrated voice-data workstation. Software run- ning on this hardware platform sup- ports not only the Layer 1 “device drivers” but also the CCITT standards 1.441tQ.921) and 1.451(Q.931) for Lay- ers 2 and 3. The user interface is via window-driven menu options which are very flexible and easy to use. This board allows users to quickly learn about the T7540 digital telephone CODEC providing speakerphone functionality, the T725OB ISDN Basic Rate Interface “s” transceiver, and the T7121 HDLC formatter. For additional information and documentation on the devices out- lined in this article, contact AT&T Mi- croelectronics at (800) 372-2447. $P

56 ClRCUll CEl LA R INK Circuit Cellar Ink cover artist Robert Tinney pruudiy offers these distinctive 16” x 20” Lknited Edition Prints. Facb is an exquisite Limited Editions reproduction hrom the pages of Byte Magazine, and is part of an edition of only 1000 prints, The museum quality stock is acid free, ensuring briknce and durability for decades to come. The artist personally inspects, sigz~s and numbers each print, which is accompanied by its own Certificate of Authenticity. Order your prints beautifully triple-matted and framed! The frames are of the silver m&al variety, and mats are chosen to complement the colors of the print(s) you order. Plexiglass only.

The price of each print ia shown at left. Order two or more and deduct 15%! Frames are onty $39.50 each. For shipping, add $5 per order for unframed prints ($25 overseas); for framed prints, add $6.50 for one print and $4.50 for each extra print (ground). No frames shipped overseas. Full refkmd if not satisfied --I_------For VISA, MasterCard or AMEX orders call 1-3188263003. r ORDER FORM z-l I Qty. # Title Amount I -- I -- s I I --- - :s I If you order two 01 mom, deduct 15% S I Frames ($3950each) S I I shipping chwges! sw ‘bowi ; I OIhaveendoaedachedrormoneyoldertoRobertTinnqrGraphira I @iust be drawn on a US. bank no feign collectkm, p em. I Billmy aVISA q Mastcr(ird 0 AmericanExpresa I cm1 u: Expire%- I Name: I Address: I I city: ststez- 7.ip: I

UK s60 UC s80 L------.-A 2”~ 4” EMBEDDED PC

Microcomwter. “Megatel Wildcards provide PC functionality in a flexible, smalllformat.” Wildcard 88’” Multi/IO VidlMem: l CPU clock to IO MHz l On-board SCSI Host Adapter l 640Kb User memory l Replaces full PC motherboard (supports up to 7 devices) l VideolColour LCD controls l Co-processor and BIOS socket l Floppy Controller (1.44M. 1.2M) CGA, Hercules@. IBM@ Mono: l DMA. Bus, DRAM, Keyboard l 2 RS-232, I Parallel, I RS-485 (runs LCD Panels) controllers multi-protocol serial port For in/ormation on our re~emtatives please contact our head office at the number 6ebw. All Wildcards are low power single +5 volt operation. 125 Wendell Ave., Weston, Ont. M9N 3K9 Fax: (416) 245-6505 (416) 245~3324 Wlldcard 88 and Megatel are trademarks of Megatel Computer Corp Hercules is a trademark of Hercules Carp IBM is a trademark of IBM Corp megatel@ ReaderService #l&3 October/Novsmber 199 1 57 Real-Time Multitasking Executive

l INTEL 80~88/86,8096/8OC196

l MOTOROLA 68OxO,683xx, 68HC11,68HC16

l INMOS T400, T800 l ANALOG DEVICES 2100

l Preemptive Scheduling l Written in C

l Fixed or Dynamic Priorities l Source Code Included

l Time out on some services l No Royalties

l Configurable and FiOMable l Technical Support

l Intertask Communcations l Widely Ported

- Messages l Sensible License Agreement

- Queues l Most Popular C Compilers - Semaphores Supported We feature a series of single board computers for l Memory Management process control applications. Each is available as a l Resource Manager bare printed circuit board, or fully assembled and l Over 40 Executive Services l System Level Debugging Utility tested. Optional development software Is also l System Generation Utility available. Please contact us to discuss your requirements and receive a literature package covering technical specs and pricing. One Time License Fee $2,995 Discounts for Multiple Licenses/Ports The only real-time kernel you’ll ever needTM

Micromint’s BRUTE-52 is the ultimate compact controller. One look at the list of features will tell you that this full- featured controller has the power to crush your most de- manding applications:

. CM05 8OC52/80C32 . 12-M pamllel TrL I/O . Three l&blt counter timers . E-bits buffered high-voiioge. hiih-current otipvh . 11.0592 MM System Clock l B-bits optoisolated non-polarized DC inputs . Hardware Watchdog Timer . 12-btt plus s’iJn analog-tobiital convwter . Hardware Clock-calendar 8 channek! 60 Samples/second! 1.2 mV resolution!

l Optoisotied Serial Communicatiinr . 12-M digital-to-analog converter RX?32 or IX4851 3OC-9600 bps! 2 channels! 1.2 mV resolutiinl Selectable ranges!

l Optokotied Serial Printer Poti, . onty 3.5 x 5.3 Inches! RS232 15C-9600 bps . Operates at c-70% .5Vonh/ Opemtiin . CorwJmes only loo-2fYJ mA wqxeva on ccnllQuotbnl . Up to 56 Kby%s RAM and/or EPROM . Use networked or stand-alone . 1 KM EEPROM BRUTE-52 offers you all these features starting at only S289! (quantity one) When you add in Micromint’s renowned quality, sevices, andsupport, you won’t finda better value in compact control. To order BRUTE-52, or for more information. contact: Micromid, Inc.

4 Park Street l Vernon, CT Ck5066 Phone (203) 87 1-6 170 l FAX (203) 872-2204

ar rrw t-oeo sysr.Prm ReaderSewtce 1174 58 ClRCUil- CELLAR INK OrCAD Schematic Design Tools 6 A Working Engineer’s Impression I.4 by Bruce Webb Schematic Capture with Schema 64 by Ken Davidson cl October/November 199 1 59 SPECIAL OrCAD SECTION Schematic Design Tools Bmce Webb A Working Engineer’s Impression

The heart of the OrCAD SDT soft- Like a lot of people, I stuffed making ware is a drawing program called DRAFT. DRAFT starts with a blank printed circuifs with drafting tape and drawing sheet that includes a title block where company name, sche- “rub-on” pads. Not content with such crude matic title, revision date, and so on are stored. The title block is not just an techniques, I started investigating what area on the drawing; it is a kind of header that makes it easy to keep track was available to computerize the process. of your documents. A pull-down win- dow provides access to the DRAFT So, five years ago I tried using a general- commands. The operation is intuitive, though some time with the manual purposeCADprogrum. may keep the user from confusing commands.

Then I got a printed circuit layout ORCAD DRAWING FEATURES program (Tango from Accell Tech- nologies). Last year my company OrCAD Schematic Design Tools Drawing a schematic is as simple bought an autorouter and schematic (SDT) is a low-cost schematic capture as retrieving the parts that make up capture software. Each upgrade made program which may be used with the design from libraries and connect- the job a little easier, a little faster, and other design products as part of a ing them with lines or “wires” on the more accurate. The last improvement complete printed pack- screen. OrCAD also allows groups of turned out to be the most profound. age or alone to create standard and wires to be collected into buses to Getting the schematic into the com- easy to read schematic diagrams. more easily get the connections from puter makes a big difference. OrCAD SDT is not a single pro- one area of the schematic to another The process of printed circuit lay- gram; it is a collection of programs (or without cluttering. Special connections out involves four basic steps: “tools”) that provides a way for the such as power or ground are made to 1) Design the circuit (draw sche- user to create, edit, check, and print nodes which are implicitly connected. matic) schematics. It requires a minimum of The process elements are pretty much 2) Place parts on board five megabytes of hard disk space on the same as hand drawing, except the 3) Route connections (manual an IBM-compatible computer with at lines stay straight without a ruler. and/or auto) least EGA graphics, 640K or more of Large schematics may be divided 4) Check board against schematic RAM (EMS supported), and a mouse. into sheets with either a flat or hierar- Schematic capture programs per- The results of your efforts may be chical structure. Connectionsbetween form or assist with three of the four: printed on most popular printers or sheets are accomplished using mod- designing, routing, and checking. The on an HP-compatible plotter. I use a ule ports. The flat structure has the hardest part for me has always been 16-MHz80286machinewith4Mbytes same level of detail on all sheets. In a making sure that the printed circuit of RAM, a super VGA display, and an hierarchical structure, the detailed matches the schematic before I spend HP-compatible laser printer. I use lower levels of the drawing are repre- the timeand money fabricatingboards. TangoPCB and autorouter to create sented as blocks at levels nearer the That is where schematic capture makes PC board layouts from OrCAD net top.OrCADSDTallowsblocksofsche- a big contribution. lists. matics which are repeated in the de-

60 CIRCUIT CELLAR INK SCHEMATIC CAPTURE SOFFWARE (EECAD) signtobeshownonceonasingle sheet an EPROM or static RAM (like 2764 or pins wired to a third could be con- and then referred to by a block desig- 6264) can be installed. nected together directly. Power and nation. The more complex your sche- One of the hardest skills I have ground lines are generally tied to matic, the more you will appreciate learned in drawing schematics is pre- nodes which are implicitly connected the completeness and flexibility of dictinghowmuchspacewillbeneeded to keep the drawing less cluttered. these structures. Fortunately, if your between components for wires to run. The net list provides a way to needs are simpler, these options do Moving a part to another area on the communicate the schematic connec- not get in the way. schematiccanbedonesothatthewires tions to a PCB layout program. All of move with it, but the results are usu- the connections are then routed either LIBRARIES ally messy and have to be redone more by hand or using an autorouter. I pre-

Schematic versions of electrical components are stored in SDT’s ex- OCAD boasts 50,000 users and have developed suppotf tensive libraries of more than 20,000 parts. The components are rectangles for them that I found to be reasonable and clear. There or logic shapes with the “pins” repre- has always been someone at the other end when I catted sented as lines. Each pin is labeled with its function name. Using library and if the person I first reached couldn’t help, I was called parts relieves the user from the effort back within a few hours with the answers. of redrawing them, and since the li- braries have been debugged by years of use, it is unlikely that you’ll en- than once. I usually try to complete fer to route most boards by hand and counter any mislabeled or missing small blocks of schematic and place then check my work using the pins. The libraries are organized by them rather than placing individual autorouter.Checkingcanbe thereally families such as CMOS, ‘ITL, or ana- parts. This is also a good idea when hard part to do by hand! When the log, and by manufacturer such as placing parts on the PC layout. You process is complete, there will be a Motorola or Intel. have a schematic. Now what? schematic diagram that exactly Only the libraries you use need to A schematic capture program matches the printed circuit board and be installed. There is no point in hav- helps you to draw an easy-to-read and vice versa. ing OrCAD search through digital somewhat standard drawing, but the Having an accurate and verified components if your design will only real is what happens once the schematic is an extremely valuable use analog parts. Components not schematic is complete. The schematic tool for someone trying to modify or available in OrCAD libraries can be can be used to create a file of the debug a circuit-ven if that someone made from existing parts or built from drawing’sconnectionscalled a net list. is the original designer! scratch. I have created, for example, a The net list is an ASCII listing of all of OrCAD SDT can create a number complete library of my own of Maxim the wires on the schematic with the of reports related to the design. They interface and microprocessor control endpoints of each being a component include a parts list, designation list components that OrCAD didn’t in- pin. The connections are grouped to- (Ul is an 8031), and so on, that help clude. I also created special RAM/ gether into nets. The grouping is im- ensure compatibility between the ROM chips for designs where either portant because it recognizes that two printed circuit and the schematic.

A typical drawing made with OrCAD might include individual gates, complete chips, and bused signals. This sample was OUtpUt On (7 plotter with a line-tipped pen.

October/November 199 1 61 SETTING UP isdifficulttodistinguishbetweenwhat and file names were appropriate. For might have been problems with the example: OrCAD has chosen to use an in- documentation and my limited un- stall program for setup and to trans- derstanding of the design process and NETLIST MYBOARD.SCH mit updates. There is a total of four impatience when I started using C:DESIGN\MYBOARD.NET /S l.ZM-byte floppy disks on which the OrCAD. I needed the software right software has been archived (com- away, so I began by drawing some is the command to create a net list pacted). One of the disks marked “IN- simple designs and working things from a drawing called MYBOARD. SCH STALL” is placed in A: drive and the out with the Reference Manual in and place the file (MYBOARD. NET) in user types the word INSTALL from hand. I don’t recommend reading all subdirectory c : \DESIGN. The /s at the prompt. The install program asks themanualsbeforestarting. Itisbetter the end signifies that the file should be questions about hardware and library to jump right in and then go back later written in the format for the Tango requirements to customize the sys- to learn some of the finer points. PCB program that I use for layout. It tem. Nothing could be easier. The pro- A sample schematic is included required great feats of memorization grams are installed in a well-orga- with the program and is discussed in for those who didn’t use it every day, nized way in several subdirectories the user’s guide. Following the tuto- or lots of looking through the manual. andchangesaremadeto~~~~~~. SYS rial with the manual in hand is very OrCAD has recently improved the and AUTOEXEC . BAT automatically. helpful, but cannot cover all of the software (Release IV) to include an The programs come with five topics encountered when designing a integrated windows-style environ- manuals including: Installation and real schematic for a project. ment that they call ESP. On-screen Technical Support Guide,OrCADSDT ‘buttons” are used to select programs User’s Guide, OrCAD ESP Environ- ORCAD’S LATEST EFFORT and set up options. The program ment User’s Guide, Text Editor User’s switches are replaced by setting up a Guide, and OrCAD SDT Reference. My one major complaint about local environment with the switches The manuals alone are not par- OrCAD SDT when we first purchased set as defaults. The result is an intui- ticularly helpful if it is the first time it was that each program of the collec- tive user interface that works well. usingschematiccapturesoftwaresince tion had to be invoked from the DOS The new environment is not per- some of the lingo can be confusing. It command line with whatever switches fect, though. The programs are not

Easy to Use PC Software - ICON Based - Mouse Driven Ultra Fast Performance - Advanced Editing Tools Output to Printers, Plotters & Lasers

ISlSDESlGNER is the Schematic Capture for anyone The Micro’IYacker’” can significantly reduce the needing to enter designs. Provides netlist, multi-sheet, cost of your next real-time product development user configurable partslist & Electrical Rules Check report. project. Advanced features speed software devel- BBEsA PCB new autorouter uses an advanced multi- opment and enhance quality assurance. strategy to achieve very high connection rates & it’s fast! FEATURES 10 copper layers, Design Rule Checker and MORE. W 2K or 8K Trace Memory n Instruction Disassembly n Interval Timer for 280. 8085, 6502, R4 SYSTEMS Inc. n Performance Analysis 6802, 6809, P.O.Box 451 n FE-232 Interface 8031/8051, 80188/80186, n IBM PC Software V4ON50 West Hill, Ontario n Symbolic Disassembly Canada .Ml E 4Y9 (416) 439-9302 n Low Cost from $1295. Call for Free Brochure Download DEMO from BBS at 416 289-4554 (2400/8/N/l)

Readerservice 1194

62 CfRCfJfl- CELLAR INK SCHEMATIC CAPTURE SOFWARE (EECAD) truly integrated and still exist sepa- telephone or via BBS. Updates and months with Release IV. The few idio- rately. The parameters supplied by fixes are free to registered users. syncrasies in the way it operates are the user are correctly inserted when OKAD publishes a newsletter once a within the limits I am used to and the theprogramsarecalled,buterrorhan- quarter to highlight common misun- problems it has solved for me are dling is sparse and just as cryptic as derstandings, make announcements, many. + ever. The dialogue between the envi- and to remind people that they are ronment and DOS is recorded in a file there if you need help. Support may that must be read and interpreted us- be extended for an additional charge. OCAD SDT Rdease IV ing a text editor. I guess I am a little OrCAD boasts 50,W users and cost: ss9s.oo spoiled by software that diagnoses have developed support for them that Requkements: problems and helps fix them rather I found to be reasonable and clear. 64oKRAM than just telling you “filenot found” at EGA or VGA graphics Therehasalwaysbeensomeoneatthe HardDIsk the point at which the program failed. other end when I called and if the Mous0 person I first reached couldn’t help, I SUPPORT was called back within a few hours with the answers. 3175 N.W. AlocI& Dr. OxCAD’s support of their prod- HUkboro. OR 97124 ucts starts even before you buy them. THE BOllOM UNE (5cxQ 6909581 They have a demo version of all of their products so potential buyers can Schematic capture programs are get a feel for the software and make just about necessary for designing Bruce W&b is a Chemical Engiw turd Electronic Entrepreneur who is a pincipal in comparisons before they plunk down complicated boards to ensure that the Cottage Resources Corporation. a lot of money. They provide a free board and the schematic match and bulletinboardwherevideoandprinter definitely necessary if an autorouter is drivers and new libraries may be included in any part of the equation. IRS downloaded. Any questions or prob- OrCAD is affordable and well sup 4 13 very Useful lems can be answered by a reasonably ported. I’ve been using the package 4 14 Modetiety Useful knowledgeable support staff on the for about a year, including several 415 Not Useful

DC/CAD ~cms4ladamM11 1 W3f4DElWFWa(punrs! Tiiii It ~s-J-w=~~Autorouting ThlatopratadcADout~fheJcompetitionintha1990 CAD Show-down. DC/CAD displayed its power and flexibility when routing a double-sided board while cCWIIpeting routers usedfourtosixlayers.Thiinon-wpyprcWc@d~~ surface mount support ildudes: Take it Esrsv.easy on your cargo with a custom Cabbage Case l ~lillilportsauloplaeer 0 “1.mil” aulorouting with rip up 6 retfy built to the exact dimensiins of your equipment. l Thomughallnawgdesignndechecker Take it easy on your back with our extension handle and tilt wheels options. .Op(ionalsimu&Jncapability&pmtededmodefor386users Take it easy on your LEASE PROGRAM L SITE LICENSE AVAILABLE wallet. Let Cabbage Cases 30 DAY MONEY BACK GUARANTEE show .vou how easy it is to save money on q&y, custom-built road cases that make shipping and traveling with your valuable cargo safer and easier. Prices quoted over the phone. Call 800-8882495 today. 1166-C Steelwood Rd. Columbus, OH 43212 L 999/999-2499 l 614/499-2499 bbcm . FAX/~2799 SCHEMATIC CAPTURE SOFIWARE (EECAD) ntegrated and still exist sepa- telephone or via BBS. Updates and months with Release IV. The few idio- The parameters supplied by fixes are free to registered users. syncrasies in the way it operates are :r are correctly inserted when OrCAD publishes a newsletter once a within the limits I am used to and the grams are called, but error han- quarter to highlight common misun- problems it has solved for me are s sparse and just as cryptic as derstandings, make announcements, many. 4 he dialogue between the envi- and to remind people that they are nt and DOS is recorded in a file there if you need help. Support may ust be read and interpreted us- be extended for an additional charge. OrCAD SDT Release IV ext editor. I guess I am a little OrCAD boasts 50,000 users and cost: $595.00 1 by software that diagnoses have developed support for them that Requirements: ms and helps fix them rather I found to be reasonable and clear. ts4oKRAM st telling you “file not found” at There has always been someone at the EGA or VGA graphics Hard Dfsk !nt at which the program failed. other end when I called and if the Mouse person I first reached couldn’t help, I )RT was called back within a few hours OrCAD with the answers. 3175 N.W. Alocfek Dr. CAD’s support of their prod- Hllfsboro, OR 97124 arts even before you buy them. THE BOTfOM LINE (503) 690-9881 ‘lave a demo version of all of roducts so potential buyers can Schematic capture programs are eel for the software and make just about necessary for designing Bruce Webb is a Chemical Engineer turd .risons before they plunk down Electronic Entrepreneur who is a prkipal in complicated boards to ensure that the Cottage Resources Corporation. If money. They provide a free board and the schematic match and nboard where video and printer definitely necessary if an autorouter is s and new libraries may be included in any part of the equation. IRS oaded . Any questions or prob- OrCAD is affordable and well sup- 4 13 Very Useful %n be answered by a reasonably ported. I’ve been using the package 4 14 Moderately Useful edgeable support staff on the for about a year, including several 4 15 Not Useful

WW DOUBLED IN LIBRARY SIZE DC/CAD Tii It grates Schematic, PCB Layout & Autorouting top-rated CAD out-routed the competition in the 1990 Showdown. DC/CAD displayed its power and flexibility I routing a double-sided board while competing routers four to six layers. This non-copy protected package with ce mount support includes: M-strategy I-mil parts autoplacer Take itM easy on your cargo with a custom Cabbage Case nil” autorouting with rip up & retry built to the exact dimensions of vour equipment. Irough annotating design rule checker Take it easy on your back I 2-way GERBER and DXF support with our extension handle tional au&ground plane support with and tilt wheels options. tional simulation capability & protected mode for 386 users Take it easy on your LEASE PROGRAM 8 SITE LICENSE AVAILABLE wallet. Let Cabbage Cases 30 DAY MONEY BACK GUARANTEE show you how easy it is to save money on quality, custom-built road cases that make shipping and traveling with your valuable cargo safer and easier. Prices quoted over the phone. *DESIGN =COMPUTATlON Call 800-888-2495 today. RI. 33, Sbermon ~cpwe Fanningthh, NJ 07727 1166-C Steelwood Rd.. (908) 9384661 l (908) 9384562 (FAX) Columbus, OH 43212 2AwimL..J~ 3uhl%+ 899/9902495 614/49#2499 d$wV FAX/49&2799

October/November 199 1 63 SPECIAL SECTION Schematic Capture with Schema Ken Davidson I

S o what’s wrong with notes on paper napkins? Sure, they can be a little mushy to write on, and you can’t fit a whole lot onto one, but they travel real well, and once you’re done with them, you can use them to wipe the sweat from your brow. Steve tells stories of the “good old days” when he could sketch out a circuit on a dinner napkin, bring it down to Ray Long’s to have a board laid out (see

“Bringing in the Pros” in issue #20 of CIRCUIT CELLAR INK for more on Ray’s company), and have a working board in hand in short order.

Those were also the days when Omation Inc. was trying a novel can often dramatically improve his Circuit Cellar projects tended to be idea for the software industry: a free productivity by using a good word less complex. The PC boards were all demo disk containing a version of the processor. He is able to shed many of laid out by hand using several layers software that was fully functional ex- the more mundane and error-prone of acetate, rub-ons, tape, and a good, cept for some key features such as tasks onto the computer and direct all sharp knife; circuit designs were san- saving or printing. We gave them a his energies to actually writing. ity checked by the designer’s keen eye call, received the disk, and have been Most of the designer’s (writer’s) and perhaps an associate looking over using Schema for all our schematics time will be spent entering new infor- his shoulder; and the person laying ever since. mation and manipulating and modi- out the PC board had to be able to fying it. This stage is where a good manually swap gates within a pack- SCHEMATIC CAPTURE SOFlWARE user interface is a must. If the designer age or catch a bad pin number on the has to labor at using the computer, it’s schematic. Invariably, when the pro- Before I get into Schema proper, not going to save him any time and totype PC board came back for first let me go over a few schematiccapture he’ll be less likely to use it in the fu- test and didn’t work, at least half of basics. There are two key questions to ture. All schematic capture packages the problems could be attributed to ask when looking at any software: I’veseenuseagraphicalinterfacewith layout mistakes. what will the software do for me that at least one on-screen menu and sup About six years ago, we started I either can’t do now, can’t do effi- port (if not require) the use of a mouse. looking for a better way. Reasonably ciently, or can’t do effectively (i.e., They allow the designer to manipu- priced schematic capture packages how will it save me time?); and is it lateeverythingassociated withacom- that might be considered for serious easy enough to use that I’ll continue to ponent as a single unit. For example, professional use were just starting to use it and not be hindered by it? the outline of the part, the pin num- show upon themarket. Wealso started Foranyonenotfamiliarwithsche- bers, and the pin descriptions are all working on Ray to upgrade his shop, matic capture packages, it is useful to integrated. Individual components or trying to convince him that his pro- consider the idea that they are to cir- groups of components may be moved ductivity could jump markedly if he cuit design what word processors are anywhere on the screen and wire con- were tocomputerize. Up to that point, to writing. A good word processor nections may be changed at any time. there wasn’t a piece of silicon to be does not make a good writer (as I’m Humans are the only ones who found in his shop. often reminded), but a good writer can lookat a design to determine if it’s

64 ClRCUlJ CELLAR INK SCHEMATIC CAPTURE SOFWARE (EECAD) going to work, but the computer can PC board layout software to ensure Schema includes full mouse sup often helpcatch theobviousmistakes. accurate transfer of the design from port. While not required, you’d have A good piece of schematic capture the symbolic schematic stage to the to be a fool not to use one. software will do a “design rule check,” physical hardware stage. Similarly, The majority of the screen is con- which is akin to the spelling checker word processors often support nu- sumed by the main drawing area. found in most word processors. (The merous file formats to ease the transi- Downtheleft sideisamenu, thetopof word processor won’t tell you whether tion from, for example, the author’s which always contains the top-level the critics will like your piece, but it IBM PC to the publisher’s Macintosh. commands while the bottom changes can at least make sure you’re using depending on what command has words from the English language.) SCHEMA: THE SCREEN been selected. At thebottomleftof the The design rule check looks for such drawing area is an optional screen blundersasmultipledriversconnected When we received the demo disk coordinate box that is continuously together, inputs left floating, multiple and tried out the package, the most updated with the current location of components with the same reference striking feature at first glance was its the cursor. Many different display designator, and labels used in only user interface. Most drawing pack- adapters are supported, including all one place. ages allow you to see only a static the major super VGA boards. It was a Once your design is complete, you view of your drawing and force you to pleasure to upgrade from a vanilla may elect to print or plot the finished use scroll bars or awkward keyboard CGA to an 800 x 600 VGA display. product. Most schematic packages commands to move to other parts of One of the 1024 x 768 boards on the support at least HPGL pen plotters the schematic. With Schema, when market would provide an even larger and dot matrix printers. Most also thecursorreachesanedgeofthedraw- window onto the schematic being support a broader range of plotters ing area, the whole area starts to drawn. plus laser printers. Likewise, most smoothly and quickly scroll across the word processors have a list of sup- schematic, stopping either when the PART DEFINITIONS ported printers longer than their list cursor is moved away from the edge of supported features. ortheedgeoftheschematicisreached. The first step in drawing any sche- In order to aid in the transfer of With such a feature, the designer can matic is defining the components. your finished design to the next stage, very easily move from one part of the Omation includes extensive libraries most schematic capture packages also schematic to another without lifting a containing all the popular logic fami- support the generation of a “net list’ finger or moving the cursor very far lies (LS, CMOS, etc.), microprocessors, (which is usually the reason for using from the area of interest. It also elimi- memory, and, of course, active and the software in the first place). Any nates the frustratingly slow screen passive analog components, so connectionbetweentwoormorecom- redrawsoftenencounteredwithdraw- chances are most of the parts you’ll ponents is called a “net.” A net list is ing packages. If you want to get a want are already defined. For those nothing more than a list of compo- better feel for what the drawing looks that aren’t, or if you’re not happy with nents on the board and a list of con- like as a whole, a number of zoom the predefined version, you can go to nections between them. It is used by levels are supported. the object editor.

AO-A15 u3 \ 6264

\a12 2+m uz

I_ Al 9Al A0 I0 A0 WRITE 27 R\W +5 26 -CEZ 200CEl READ 2200E

Comparing the same circuit between Schema and OrCAD shows that both programs get the job done, but each has its own SW/e. Schema’s output was done on an HP LaserJet printer.

October/November 1 W I 65 SCHEMATIC CAPTURE SOFtWARE (EECAD)

Theobjecteditorisintegratedinto may have slightly different labels or you can make the change without hav- themaindrawingprogramand hasan additional symbols. ing to delete and re-place the part. almost identical user interface to the When a component contains sev- Any pin on a part that has been schematic editor. It includes the es- eral gates within the same package, a properly defined has a perpendicular sentials for drawing boxes, circles, each gate must be defined separately. line at one end denoting where the bitmapped images, labels, pin num- In the above example, you must de- wires are to be attached to the part. bers, and so on. You may also edit fine each of the six inverters in the Wires also have arrows at each end, so anything already on the screen. 7404 package as separate body ob- making sure the arrows always touch In order for Schema to be able to jects. Granted, you can define a single the perpendicular on the parts’ pins is do a design rule check, it must know gate, then make copies and small the best way to be sure connections more about the component than sim- changes to do the rest, but it can still be are made properly. Wire arrows and ply what its schematic symbol looks time consuming. pin perpendiculars may be turned off An even bigger nuisance is hav- at any point and are never printed in ing to define each style and rotation of the final schematic. For anyone not a gate separately. To again use our Anotheraid in getting thingslined 7404 example, if we want one inverter up is a redefinable grid and optional familiar wifh symbol with the inverter bubble on snap to the grid. Leaving the grid and the output side and one with the snap on all the time is another good schematic capture bubble on the input side, plus all four way of assuring that proper connec- packages, it is rotations of both styles, we must de- tions are made. fine 48 separate objects to cover all the When connections must be made useful to consider the bases. Luckily, Omation has already betweenpartsthatareatoppositeends done the work for virtually all the of the page or on different pages alto- idea that they are fo popular gates in use, so you may never gether, a wire may terminate at a la- circuit design what run into it. bel. This becomes the name of A named object is used to tie to- thenet,andanyotherwiresconnected word processors are gether all the body objects associated to the same label elsewhere on the with a particular component and is drawing are also connected to the same fo writing. used when placing a component on net. To clarify the drawing, groups of the page. It is a textual description of labeled connections may be bused to- the component that includes your gether. The schematic editor provides like. For each pin on the component, stock number, a short description of fat and narrow arcs and lines for the you must tell Schema what its number the part, and the name of the body creation of buses. The arcs and lines is and whether the pin is input, out- object family. To use the 7404 example are only cosmetic, however, since it’s put, bidirectional, tristated, analog, or once more, the six main body objects the labels that determine to which nets “don’t care.” Schema uses the pin func- making up the package might be called the wires are connected. tion information during postpro- TM-lA, TO4-lB, on up to TO4-lF, so I find that overuse of buses and cessing to make sure all the parts are you include the “T04” family in the labels make the final drawing confus- connected in harmony, and uses the description of the “7404” part. The ing and difficult to read. I like to make pin number information to generate hierarchy helps a great deal when de- direct connections whenever possible, the net list. fining a component with several sec- using buses only for data and address A somewhat confusing aspect of tions, but can be a hassle when defin- lines. If control and other signals must Schema (but powerful at the same ing something like a microprocessor go from page to page, I always try to time) is the differentiation between that consists of just one body object. bring the individual signals to either ‘body objects” and “named objects.” the left or the right side of the page. When we first started using the pack- THE SCHEMATIC That way, a quick glance down the age, the distinction between the two two sides of the page will tell you if a was vague, but the documentation has Defining the parts is the boring particular signal is used on that page. been improved over the years. A body part of the process. Once done, you When all the interpage signals are object is the graphical symbol used can start the actual drawing of the brought to buses at random points on when the component is put on the schematic. The schematic editor al- the page, you’re forced to scan the schematic.Bodyobjectsmaybenested lows you to place any predefined part entire contents of every page to find (and are often called “nested objects”); on the page, assigning a referencedes- the signal you’re looking for. for example, a simple inverter object ignator and, when necessary, a value Rearranging portions of the sche- may be defined once, then used mul- to the part. The part requested may be maticiseasy.Simplydragaboxaround tiple times when defining body ob- changed at any time, so if you find that the area you want to move, grab the jects representing a 7404, 7406, and you want a different value resistor or corner, and the whole area moves in 7414. All use the same basic shape, but a different gate in the same package, unison. When released, any wires that

66 CIRCWJ CELLAR INK crossed into or out of the moved area are still connected, though often end up as diagonal lines that must later be Ten microwatts. squared off and cleaned up. The ad- With its automatic power cycling, that’s the vantage of this “rubberbanding” ef- average power draw of the nanoLlNK fect is that once you make a connec- Controller/Peripheral in a typical application. No tion with a wire, that connection is extras--it’s all built-in and can be enabled with one instruction. Run your application for over never broken until you delete the wire. two years on a 9V battery, or forever on a It’s just one more way that the com- thumb-sized solar cell. puter can be used to keep track of the And because the nanoLlNK Controller/Peripheral little details while you concentrate on was designed to function as a PC peri heral--no doing the design. programming required--OR as a stan8 -alone As I mentioned when describing controller, you can use it on the bench, in the field, or both. 8 A/D inputs, 32 l/O lines, 1A the object editor, support for rotated power & PWM outputs, and much more. parts is pretty slim. Recent versions of A full-function BIOS is included--no device Schema include a rotate command in drivers to write. A typical data-logging the draw and edit menu entries, but application requires less than a dozen lines of the command relies on the existence code. And an interactive editor & macro of rotated versions of the part in one of Less money, less assembler is included--no expensive cross the libraries. If a rotated version hasn’t power, less time, development tools to buy. been defined, one must be defined less work. And the price? $395, quantity l--call today. before a rotation can take place. Scaling isn’t supported atall. Once To place an order, or for an object has been defined, its size more information, call: nano Power can’t be changed unless you go into 1-800-GET-DATA (438-3282) the object editor and redefine it. Un- 1-602-996-0255/fax -l-EsA dklskm d AlrDlgltd Corporatl~n less you’re trying to fit a D-size draw- ing onto a B-size page, I don’t think you’ll miss scaling.

POSTPROCESSING AND PRINTING L l Position and/or Velocity Once the drawing in complete, there is a host of postprocessing that maybedone toit. While theobjectand Mtibn Cb7lWl schematic editors described above are llllllllllllllllllllllllllllllllllllllllllllllllllllill integrated into one program, the rest of the Schema package consists of sepa- rateprogramsforeachpostprocessing task. As I mentioned before, a design DCX- rule check may be done to look for silly drawing mistakes. A list of parts, 8 -Axis Programmable Motion htioller sections within each part, and refer- l State-of-the-art Digital Multiiunction Controller can be configured in minutes ence designators may be produced, as using “off-the-shelf” components well as a complete bill of materials l DCX motherboard contains intelligence/ memory/firmware and 8 sockets for with your own stock numbers next to “plug-in” Modules each component. The net list may also l 1 to 8 “plug-in” DC Servo, Stepper or Special Purpose Control Modules can be generated at this point. be mixed/matched on same DCX board Almost all PC board layout pro- l Install in any PC/XT/AT compatible, or use “stand-alone” with RS232 grams use their own net list format. and/or IEEE-488 interface Modules Omation includes a very useful utility l High level interface libraries in ” C” and ” BASIC,” with examples and source that converts their net list format to code, included those used by the major PC board layout programs and systems. Our Precision Micro Control layout house (Custom Photo) pur- CORPORATION chased a Calay system in response to 8122 Engineer Road, San Diego, CA 92111 (619) 565-l 500 FAX (619) 565-l 511 our prodding, so the final step we

ReoderSetie #191 October/November 199 1 67 SCHEMATIC CAPTURE SOFTWARE (EECAD) always perform before sending the Schema can output a page in just 2-3 THE BOTTOM LINE schematic to have a board made is to minutes, and I find the quality to be convert the net list to Calay format. much higher. Since mistakes are more Does Schema live up to the two Any potential incompatibilities are often found on the printed page than questions I posed earlier? It most cer- flagged during the conversion. (Cus- on the screen, the printer makes it tainlydoes. Icanwhipoutaschematic tom Photo also purchased a copy of much more convenient to make check in a fraction of the time it would take Schema so they could draw schemat- plots as work progresses. me todoitbyhand,aresultofSchema’s ics for customers still using napkins.) Also included in the suite of pro- combination of features and user in- Both printing and plotting are grams is a setup utility for configuring terface. In fact, I’m so comfortable with supported to suit the equipment you the drawing program and individual the package that I’ll do design work have on hand. When we started with schematics, a librarian used to main- right on screen and skip the hand- Schema, we always used a relatively tain libraries of objects and parts, and sketching stage altogether. It’s easy to slow plotter to generate output. The several utilities used to pass informa- draw some ideas, print them out, check results were usually acceptable, but tion back and forth between Schema’s them over, perhaps build some test the plotter usually had problems with drawing program and Schema PCB (a circuits, and make necessary changes, bitmapped symbols and it often took separatepackagethat Jeff knowsmore all without lifting a pencil. 15-20 minutes to plot a single page. about than me; see ‘Working with an Since I’ve been using Schema for One advantage of plotting is that mul- Autorouter” in issue #20 of GR~UIT so long, and haven’t had any real ex- tiple colors are supported, so it’s pos- CELLAR INK). perience with other schematic pack- sible to, say, separate functional blocks Tying everything togetherisa text- ages, iYs impossible for me to make by drawing one block in one color and based menu program that lists all the any real comparisons between them. another block in a second color. Schema modules plus most DOScorn- While it has its quirks and weaknesses Since it took so long to plot each mands and any user-specified pro- (any piece of software has to have a page, I would always make as many grams. Again using a mouse, it is easy few), it’s always done what any good additions, changes, and fixes as pos- to jump around to the various pro- piece of software should do: act as a sible on the screen before generating grams. In virtually all cases, program tool to help, rather than hinder, the new hard copy. The switch to an HP options may be specified on the com- work process. LaserJet changed that methodology, mand line or may be chosen interac- Should you run out and buy however. With the laser printer, tively. Schema? Only you can make that de- cision. All I can tell you is I don’t think you’ll be disappointed. +$’

Schema III cost: $495 Requirements: 512K RAM Graphics card (Hercules, CGA, EGA. VGA, super VGA) Hard Disk Mouse (optional)

Omation, Inc. 801 Presidential Dr. Rlchardscm. TX 75081 GOFASTTM (800) 553-9119 (214) 231-5167 Lightning-Fast Floating Point Accelerators mpower your 80x86 applications with GOFAST IEEE accelerators are opti- E GOFASTaccelerators. Fast, reentrant, mized for 8051, 8096, 8086, 80386, i960, Ken Davidson is the manag’ng editor and a andROMable, GOFAST accelerators boost 6801, 6809, 68HC11, 68xxx, 8085, 280, member of the Circuit Cellar INK engbzeering performance and make sure you can em- R3000 and more. staf, He holds a B.S. in computerengineering bed your application. cdl for your free GOFAST information and an M.S. in computer science from Link and go with C: Microsoft@, Bor- diskette today: 503-641-8446; FAX 503- Rensselaer Polytechnic Institute. land@, Intel@, MetaWare@, and WATCOM’. 644-2413; 800-356-7097. Dynamically replace 80x87 coprocessors during execution. IRS 142 15 NW Science Park Drive 416 Very Useful 0 ,991 us software Corporation. GOFAST and DynacoP 3-e Portland, OR 97229 trademarks of US Software Corporatton All other trademarks 417 Moderately Useful belong to tile,r respective owner* U S SOFTWAREBI 4 18 Not Useful ee us at The Embedded Systems Conference Booth #709 68 CIRCUIT CELLAR INK DEPARTMENTS

(Re-)Starting C Firmware Furnace

I I OK, even I admit it now: A cursory glance through any maga- C for microcontrollers has arrived. zine catering to the firmware trade Whether you like it or not, if you don’t will reveal several C compilers priced From the Bench speakCyouwon’tbeahitattheparty. well under the tropopause. For this Indeed, a recent RFQ arrived stating column I will use the 2500AD com- “the software will be written in the C piler, which I bought earlier this year programming language” without for a specific project that didn’t suit specifying the CPU. The handwriting Avocet C. It costs $600 and includes is on the wall! the compiler, assembler, and an as- Rest assured that Firmware Fur- sembly language simulator. nace won’t turn into Yet Another C While I don’t intend to start a Column. There are cases where as- review series, either, I will also look at Silicon Update sembly language code is still required the Micro-C shareware compiler from (and I will gleefully point them out), Dave Dunfield in the next column. If but, for the most part, source code you thought you couldn’t afford C, listings will be in C rather than assem- the times they are a-changin’ (and for bler. For us, C will serve as a “high- the better, too). level assembler” rather than a “low- level” language. IN THE BEGINNING During the past two years I used Avocet C for many of my projects, The C language makes several some of which you have seen here. assumptions that just aren’t true after Practical Algorithms Judging from the BBS traffic, though, the CPU emerges from a hardware the market leaders are Franklin and reset. For example, although Archimedes. Any of these three will uninitialized C variablesare supposed set you back about two kilobucks, to be set to zero, 8051 hardware does whichisalotofcointodropin theslot, not clear either internal or external especially if you are not convinced C RAM before executing the instruction puge 103 is a Good Thing. at address OOOOh. And the hardware Unfortunately, switchingbetween has no idea of how to load the proper C compilers is not as simple as com- values into C’s initialized variables, peting vendors would have you be- either. wConnecTime Obviously, all variables must be lieve, quite apart from the up-front cost. Each compiler accepts a different set up before the first line of C code subset of the C language, the run-time executes, so the code that gets control libraries are nearly disjoint, and the immediately after a hardware reset assembly language interfaces are ut- cannotbe writteninc. Nomatterhow terly bizarre. While “straight C code” simple the C code, some assembly is will port, your programs won’t be- still required! cause they will depend on features Every C compiler package in- unique to your current compiler and cludes a startup routine that must be assembler. linked with each C program to handle The good news is that the market these initializations. Avocet calls it hasroomformore than just thebiggies. CRT5lx, 2500AD refers to C8051xR,

70 CIRCUIT CELLAR INK FIRMWARE FURNACE

Ed Nisley

andMicro-Cuses8051RL.Ineachcase, too little, or the wrong kind of initial- the *RD and *WI3 signals. I/O ports “x” marks the spot for the memory ization for your purposes. Contrary to are memory-mapped in the External model identifier, which I will discuss popular opinion,changing the startup data space, so there is no separate I/O later, so you must use the appropriate code is not sinful-it can be essential! addressspaceasthereison8086CI’Us. routine for your situation. Internal RAM has only 128 bytes Each company decides what func- MEMORY MODELS (in the 8052 derivatives, 256 bytes) to tions should occur in the startup rou- hold the CPU’s working registers, the tine. Avocet includes just memory and The 8051 architecture defines sev- hardware stack, and 128 directly ad- stack initialization, 2500AD heaves in eral different address spaces. Program dressable bit variables. The working ring-buffered and interrupt-driven instructions are burned into EPROM, registers are not usually accessible serial handlers, and Micro-C just sets which is located in Code space and from the C code level. The hardware the hardware stack pointer. You must accessed by the *PSEN logic signal. stack may or may not hold C function review the contents of the file to make Variables can be in either Internal or parameters, but will always hold the sure that you arenot getting too much, External RAM, the latter accessed by function return addresses. Bit address-

+ c3 1 10 uF

Note order!

Figure l--The controller for the sample LED display is a typical 8032-based circuit regular readers should be very familiar wifh.

October/November 199 I 71 ing varies by compiler; some have TWINKLE, TWINKLE, LED mode ismore frenetic, suited for those good support, others none at all, while occasional high-caffeine days. some have rather clumsy support that There’s nothing like a good hard- Listinglshows BLINKBOX'S~~~~ isn’t worth using, ware project to justify some software loop. There are two key data struc- A further complexity arises when experimentation and find how things tures: the Timers array holds the 40 external hardware combines theCode really work. I’ll use the 8032 system variables that determine when each and External RAM address spaces by shown in Figure 1, which will run LEDchangesstateandthe~nodeData ORing the *PSEN and *RD signals. with the Small memory model be- array, which holds the 40 bits (five The Code space must start at address cause it has no external RAM. Figure 2 bytes)thatmapeachLED.TheDataID OOOOh because that’s where the CPU shows the “output device,” a rectan- and B it Ma s k variables convert begins execution, so RAM must start gular array of 40 multiplexed LEDs. TimerID into an AnodeData index at a higher address (typically 2000h or Each of the 40 LEDs is associated and bit location. 8OOOhl to avoid collisions. with a C variable located in the 8032’s Although you might think Most 8051 C compilers support at Internal RAM. The firmware counts AnodeData should be located in the least two memory models, known as the variable down at a regular rate. bit-addressable section of Internal Small and Large. The Small model When the value hits zero the firmware RAM, it turns out that the 8051 in- uses only Internal RAM, while Large updates the LED, turning it OFF or struction set doesn’t have a general- uses External RAM for variables and ON as needed. The result is a pleasant ized “set bit” instruction (despite what the C parameter stack. Of course, the blinking array that’s sure to brighten you might conclude from the 8051 memory model names are not stan- up any office decor. When you see it in App Notes). The bit location is en- dardized and there are several per- action you may be reminded of the coded in the instruction, rather than mutationsandcombinationsavailable. status panels in those old Star Trek being held in a register, so 120 differ- For example, Micro-C’s Medium sets...the ones before the fake large- ent instructions are necessary to turn model corresponds to Avocet’s Large, screen CRT displays. 40differentLEDsonandofforcomple while 2500AD uses the terms Internal A jumper changes the display ment their state. It is far simpler to and External Mode. Read the manual mode so the LEDs blink briefly when generate a byte index and mask in carefully! the corresponding timer hits zero. This software and do the bit twiddling “by

8 x 3.3K 0 x 2N2907F\

8 x 39

5 x 4.7 K

FigWe 2--The flashy part of the sample circuit is the array of 40 1EDs arranged in five rows and eight columns.

72 ClRCUIT CELLAR INK hand.” Situations like this make RISC Affordable 8031 Single Board architectures look good. Computers MODESEL is the input from the display mode jumper; depending on Control-R Model 1 (now includes MAX232) $49.95 whether the jumper is installed or not, Our original 8031 SBC. The ControCR 1 now includes the MAX232 chip to the LED bits are turned on or comple- provide serial t/O and has 14 digital VO lines that can be used to measure or mented when the Timers entries hit control user designed circuitry. Requires 5vdc and measures 3.0” x 4.0”. zero. In any case, the Timers entries are reloaded with a new (pseudo!) Control-R Model 2 (now includes MAX232 & 8K SRAM) $79.95 random value and begin timing anew. An expanded version of the Control-R 1. Now comes fully populated with 8K We’velooked at real random num- of SRAM and MAX232 for serial I/O. Expansion is provided by direct access bers before. There is one pin left over, to 8031 ports 1 and 3 as well as data, address, RST, l lNTl, l WR, ‘RD, so you should have no trouble moni- ‘PSEN, ALE and Tl. Requires 5vdc and measures 3.5” x 4.5”. toring an outside event to create truly Datalog-R Model 1 (with MAX232 & 8K SRAM) $179.95 random values. Say, a Geiger counter? The newest member of our SBC line. Features serial l/O, 4 ea. BK device The AnodeData array is in Inter- sockets user configurable as RAM or ROM, expansion connection and a nal RAM, so changing a bit there has socket that will accept an (optional, $70.00) 32K byte removable memory no effect on the LEDs. TmrTickO (1, card. This SBC is designed for applications requiring removable, non-volatile shown in Listing 2, gets control when storage or can be used without the memory card as a conventional SBC. Re- Timer 0 generates an interrupt. It re- quires either Svdc or 12vdc for operation and measures 6.0” x 4.5”. loads Timer 0 to generate the next interrupt on schedule, copies an To place an or&r contact: AnodeData entry to the LED anode Cottage Resources Corporation drivers, and selects the next cathode Suite 3-672,1405 Stevenson Drive driver to illuminate the correspond- Springfield, Illinois 62703 USA ing row of LEDs. l-2 17-529-7679 l Visa, Mastercard, or COD Orders accepted

HERE A VAR, THERE A VAR...

Now for the tricky part. Listing3a shows the C language variable decla- rations for BLINKBOX. c and Listing 3b is the assembly language code pro- duced by the 2500AD compiler, slightly edited to get rid of blank lines and suchlike. Notice how the vari- ables are spread out over two differ- ent address ranges: those near600 hex are in EPROM, while those near 10h are (or will be) in Internal RAM. An ordinary variable, such as DataID,isagoodstartingpoint.These variables must be initialized to zero before the programbegins, whichmust obviously be handled by the startup code. All we need to know is where MultiBsk~Executives the variable is located in Internal RAM (which is OOlBh) in order to plop a AccelerateReal-%eDesip zero into it. n a hurry to develop real-time applica- MultiTask! executives support today’s Initializedvariablesaremorecom- Lions? MultiTask! executives give you a most popular microprocessors: plex. The initial value must be stored full set of standard system services for most 68OxO,68HCll, Z8O/Z180/64180,8051, embedded processors. in EPROM (otherwise it would vanish Source code keeps you in control. And 8Ox86N-Series, 8096/80196 & i960. when the power goes off!), but the ourProtoTask!TM execunve lets you develop Call for a free EasyTask!TM information variable itself must be located in RAM code on the PC. No matter which target you diskette: (800) 356-7097 or(503) 64-8446. so the program can change it. For ex- choose or when you choose it. ample, RandomValue holds the cur- 14215 NW Science Park Drive Portland, OR 97229 rent randomnumberand isinitialized 0 1991 US Sotware Cmporatm MultlTaskl, ProMTask’ and to 1. The startup code must somehow EasyTask are trademarks of US Software Corporation. * U S SOFTWARE@ I ReG&r se*9 6210 See us at The Embedded Systems Conference Booth #70’ October/November 199 1 73 #define MODESEL SFB.P3 -6 connect the initial value in EPROM at while (1) { 065Bh with the variable’s true Internal RAM address. for (TimerID=O; TimerID

Professional Quality 80x86 ROM Development Tools ROMable DOS, Only $6 each! ROM Your MS & Turbo C Code! Place your programs in PROM with ROM-DOS. Pur- Now C_thru_ROM eases ROM development with all chased in quantity, this complete ROMable operating versions of Turbo-C, C++, and Microsoft C. New system costs only $6 per copy. And its small size-less features include support for Turbo Debug and than 32K-helps conserve valuable target system mem- mote debugging via a ROM socket, which ory. ROM-DOS was designed as an embedded DOS, oes not use a serial port on the target providing features like power conservation, the abil- system. C_thru_ROM is a complete ity to run your executables directly in ROM, and ROM development packagecontain- full access to built-in devices to support any ing everything you need to work kind of target system. Plus ROM-DOS with your choice of compiler and get provides the power you’d expect from a your application up and running in ROM desktop DOS: a full-featured command - quickly. It includes: a full 80x86 locator processor, extra utilities, batch file which outputs in Intel OMF, hex, and binary; support, and more. And now it is ROMable startup code; two choices for remote de- compatible with MS-DOS 3.3. ROM bugging (a CodeView-like debugger or the Turbo DOS boots and runs from either disk remote debugger); full floating point support; a ROM- ROM and can easily be configured to meet y able library (with printJ malloc, etc.); and much more. needs. Ask for our free demo disk. Call, write, or fax Datalight today for full details. For more information Call Today Toll-Free l-800-221-6630 Datalight 17455 68th Avenue NE, Suite 304, Bothell, WA 98011, USA l (206) 486-8086 l fax (206) 486-0253

Readersen4ce#l37 e ClRCUlT CELLAR INK #define SCOPESYNC SFB.P3 7 #define REFRESH -3333 - #define INTOVERHEAD 63 90. Box5670 Van Nuys, CA 91408 interrupt TmrTickO() { /*-- reset timer with correction for interrupt setup routine */

SFB.TRO = 0;

THO = (BYTE) ((REFRESH+INTOVERHEAD) >> 8); TLO = (BYTE)((REFRESHtINTOVERHEAD) & OXFF); l&tor. ph&oresistor, =eY .- SFB.TRO = 1; re!ay.transformer. It’s. voilage regulator. capaators. rimpots and other goodies. Returned to the distributor /*-- update the display */ 3r variety of reasons, we’ve found that most of them mrk to some extent. We don’t want to test them and SCOPESYNC = 1; vouid prefer to sell them “as-is’ at a greatiy reduced #rice. Mounts to any standard electrical junction box. qfrared senscw detects movement up to 65 feet and P3 &= -ALLCATHODES; /* turn off cathode drivers */ Jrns on lights. Sensor can be adjusted for sensitivity IM duration of fighting. The position d the sockets and if (NUMCATHODES == ++CathodeID) { /* step to next cathode '/ he infrared sensor can be easily adjusted. Will handle CathodeID = 0; MO 150 watt PAR 36 lamps. Suitable for wet locations. Scans++; /* indicate a complete scan is done */ lulbs not included.CAT# IL-101 $7.50 each )

Pl = -AnodeData[CathodeID]; /* send this row, inverted */ ;prague # UGN3075LT >perates on 4.5 - 24 Volts 0 P3 I= CathodeBits[CathodeIDl; /* lights on again */ :an sink 10 ma. With suitable output pull up. can be MODESEL = 1; /* ensure input bit is enabled */ lsed directly with bipolar or CMOS logic circuits. Espe- ially suited for electronic mmmutation in brushless SCOPESYNC = 0; ).C. motors using multple ring magnets. Very tiny sur- 1 aca mount package 0.175” X O.OYX 0.06” thick. CAT X HESW-5 2 for $1 .OO 1OO for $45.00 Lame auantities available

listing 2- Thisinterrupthandlerupdates the LEDs with thenextrowofeight bits from internal RAM. .his NEW con+xct flash assembly comes from a J.S. manufacturer of cameras. piler places all variables that don’t they came from, or what they do for a Jnil operates on 3 Vdc md measures 2 l/2” X 1 l/4’. requireinitialization(toanythingother living. Listing 4 shows the 2500AD deal for use as a strobe. warning light or attention get- than zero). If the program consists of startup code for this task; the rather ar. Corrplete with instruction on how to wire. CATX FSH-1 $3.75 each 10 lor $35.00 several source modules, the linker will Teutonic naming convention makes it combine all the internal uninit easy to see what’s going on: the sec- data sections from each file into a tion starts at internal uninit single block. data_addr and continues to T ‘anasonic (Matsushita) X EFR RCBK40K54 Knowing where that block starts data end addr, \n ultrasonic microphone mnsisring mternal uninit )f a bimorph type piezoelectric caramic and how long it is, we can write a with the total length being j& the ‘ibrator. Ideal for burglar alarms, auto loor openers, flow rate detectors and simple loop to zero the whole section difference between those two values. emote mntrol systems. Nom. Freq. 10 kHz. Max input volts: 20 Volts. in one shot. We don’t need to know Theinternal const_datasec- lY16’ diameter X 3/8’ hioh. 5/6” lono leads. the identity of the variables, where tion groups all co&t variables such

const BYTE CathodeBits[] = (0x01,0x02,0x08,0x10,0x20); ‘remium quality metal tape #define NUMCATHODES (sizeof(CathodeBits)) /* LEDs down display */ n C-60 cassettes (30 min. ,er side]. One of rhe finest BYTE CathodeID; /* current cathode selector */ bfand-namt’ tapes on the market. in durable. clear ,hstic;ranspon &chanisms. Recorded and bulk vased. the remrd-protect tabs have been removed #define NUMANODES 8 /* LEDs across the display */ mnd therefore. need to be taped over to rerecord. Au- BYTE AnodeData[NUMCATHODES]; /* outgoing bitmap data */ liophiles will appreciate the wide dynamic range of this BYTE DataID; /* index into AnodeData */ ape. ff your clssette deck has a “metal” setting you BYTE Counter; /* utility counter */ vill hear the difference. A real bargain1 CATX C-6OM $1.25 each. 10 for $10.00 BYTE Scans; /* incremented for each full scan */

#define NUMTIMERS NUMCATHODES*NUMANODES WORD Timers[NUMTIMERS]; /* countdown timers for blinks */ BYTE TimerID; TERMS: Mnimum order $10.00 Shipping and handling BYTE BitMask; for the 48 contimntal U.S.A. S3.5Operord~r. Allothers including AK, H/, PR or Canada must pay full shbpiping unsigned long RandomValue = 1L; /* src of pseudorandom numbers */ AN orders delivered in CALIFORNIA must indude state 3!as tax 16 %. 6 l/4%. 6 7/Z %. , 7 %) LimRsd Ouentiiies const char *CopyRight = NO C.0 D Prices subject ro change without notice. "Copyright 1991 Circuit Cellar INK/Ed Nisley"; Call or Write For Our FREE 60 Page Catalog (Outside The U.S.A. Send $2.00 Postage) listing 3a-This code defines the variables usedby BLINKBOX. The const keywordidentifies ALL ELECTRONICS CORP. ‘variables’ that wi// not be changed during the program.

ReaderSewice 1105 October/November 199 1 75 as CathodeBits in EPROM. The programs that use Internal RAM, Ex- startup code need take no action for ternal RAM, or a combination of the these “variables” because the com- two; pick the one you need. piler has already created the code to Some compilers support initial- access them. ized bit variables, either as ordinary The initial values of variables such bytes with software bit extraction or The DrylCE Plus is a modular emulator designed so you can get maximum as RandomValue are combined into directly in 8051 bit RAM. Although flexibility from your emulator purchase. internal init data in EPROM. the 2500AD compiler includes bit vari- The base unit contains all the hardware The section’s Internal RAM starting ables that can be coerced into the bit necessary to support pods containing many of the most popular members of the address is internal data init RAM, they cannot be initialized, so 8051 family of embedded control addr, but the EPROM add&s d& your startup code doesn’t have that to microprocessors. Buy one base unit, and pends on a trick the 2500AD section worry about. select one or all of the pods you need to do the job at a much reduced cost. You definitions concatenate the initialized get the same great functionality found in data after the constant data. Other FINAL BEGINNINGS our popular DrylCE 8031 emulator plus compilers use different methods to real-time Execute-to-Breakpoint, Line-by-Line Assembler, and much more. determine the addresses, but the final In addition to setting up the vari- And the price is (almost) unbelievable! loop looks much the same. ables, the startup routine must load (Yes, it works with the Mac, too!) BLINKBOX IWedS no more Vari- the stack pointer (SF’) with the stack’s Base Unit (w/W232 IF) -- $299 able initialization because it doesn’t Internal RAM address. The 8051 hard- Available Now! use External RAM. The 2500AD com- ware stack grows upward from the Available Pods: piler comes with startup routines for current SP value; pushing a byte on 8031/32,8OC31/32,8OC154,8OC451, 8OC535,8OC552/562,80C652,8OC51 FA, 8751/52,87C51/52-- $149 each internal const data 061C 01 _CathodeBits: Ibyte 001s - 16K Trace Buffer option: Avail. 1st Qtr ‘92 061D 02 -byte 002h Standard 8031 DrylCE -- Still only $199 061E 08 .byte 008h Enhanced 8031 DrylCE -- $269 061F .byte OlOh 0620 :: .byte 020h ;unsigned char CathodeID; internal uninit_data 0015 _CathodeID: :dsl - The 8051 SIM software package speeds the development of 8051 ;unsigned char AnodeData[(sizeof(CathodeBits))l; family programs by allowing 0016 -AnodeData: .ds 5*1 execution and debug without a ;unsigned char DataID; target system. The 8051 SlMulator OOlB DataID: .ds 1 is a screen oriented, menu - command driven program doubling ,*unsigned char Counter; as a great learning tool. $99. OOlC -Counter: .ds 1 I-unsigned char Scans; OOlD -Scans: .ds 1

;unsigned int Timers[(sizeof(CathodeBits))*81; 0621 .i_align OOlE -Timers: .ds 40*2 A fast and inexpensive way to implement an embedded controller. I*unsigned char TimerID; 8031/32 processor, 8+ parallel I/O, up to 006E -TimerID: .ds 1 2 RS232 serial ports, +5 volt operation. I-unsigned char BitMask; The development board option allows 006F BitMask: .ds 1 simple debugging of 8031/51 family _

programs. $ggea I-unsigned long RandomValue = 1; internal init data 065~ 0000 0001 -RandomValue: Ilong 1 - - internal const data Other products available: 0621 43 6~ 70 79 72 _STP~: Ibyte "Copyright 1991 " 69 67 68 74 20 MyGAL - GAL Programmer $199 31 39 39 31 20 FORTH Card - FORTH development card for 43 69 12 63 75 .byte "Circuit Cellar " STD Bus $279 (OEM-$199) 69 74 20 43 65 6C 6C 61 72 20 49 4E 4B 2F 45 .byte "INK/Ed Nisley",O 64 20 4E 69 73 6C 65 79 00 064~ 0621 -CopyRight: .word -STPO

listing Jb-The 25ooAD compiler produces this assembly language code from Listing 3a. (619) 566-l 892 Addresses near 6021 are in EPROM and those near 1Oh are in Internal RAM.

Recder Set-&e 5 ClRClJlT CELLAR INK the stack increments the stack pointer The catch with Small model is that and stores the byte. As a result, stan- miserly 128 bytes of Internal RAM. dard C library functions which as- Expect severe memory problems for sume a “growing down” stack will any but the tiniest of programs. If your Quality U.S.-manufactured PC&s give the wrong results on an 8051. startup routine puts the stack after all cards and software for single user, Depending on the compiler and the other variables, you can use an OEM, or embedded applications. memory model, the internal stack may 8032 to get 128 more bytes of Internal beusedforfunctionargumentsaswell RAM without having to change your asretumaddresses.However,itseems code. 8051 C compilers also pass arguments Nearly all 8051 code, including in registers as well as on the stack, and compiled C code, assumes the work- may stack arguments in nonstandard ingregistersareinBankO,whichstarts ways. If you plan to write assembly at Internal RAM address OOh. The language functions that will accept startup code should set the PSW to parametersorretum values, make sure ensure this, as errors resulting from a 200 kHz THROUGHPUT you read the documentation on how it misplacedregisterbankaredevilishly * 8 SE. analog inputs, 12-bit 5 psec AID works, then write some test code to hard to isolate. For example, library - FIFO interface & DMA transfer -Trigger-in and trigger-out; pacer clock verify that the dot is actually correct. functions often use the direct-address * 4 Conversion modes 8 channel scan * 4 Independent timer/counters Just to increase the confusion, equivalents of the registers: Rl is In- * 16 TWCMOS digital I/O lines stacks in External RAM tend to grow ternal RAM location 01 h when Bank 0 . Assembler, BASIC, Pascal 8 C source code downward. Ifyouwriteamixedmodel is active, but it’s 19h in Bank 3. Imag- DataModule PRODUCTS program, return addresses grow up in ine the confusion if you store some- Plug-cmnpatihle with Ampro CowModule Internal RAM and arguments grow thing into Rl (at 19h) and then do a DM402 12.bit IO0 kHz analog I/O board with trigger, T/C, DMA & I6 DIO lines __.____ $395 down in External RAM. And you C JNE A, 0 1 h expecting to test Rl . The DM602 12.bit 4-channel D/A; voltage range thought this was going to be simple, code looks OK, so you can spend a lot select: current loop & DIO control __.___. $289 right? You have been warned.. . of time searching. DM802 24.Line opto 22 compatible 82CS5 PPI-based DIO interface $149 POPULAR XT/AT PRODUCTS ;-- Clear uninitialized variables to zero AD1000 8 SE. 12.bit AiD inputs; 25 kHa throughput; three S-MHz timer/counters; 24 Sno_internal_init_data: .equal $ PPI-based digital I/O lines. .._. $275 mov a,#.low.internal uninit -data end-- addr clr C ADA1100 ADIOOO with 38 kHz throughput, 2 D/A outputs, and configurable gain $365 subb a,#.low.internal -uninit data addr mov r4,a :saveIsb c?f uninit data size ADA2000 8 Diff./l6 SE. analog inputs; 12. mov a,#.hiqh.internal uninit data end addr bit 20 ps A/D; I2 or 8 l.~s A/D optional; two 12. subb a,#.hiqh.internal-uninit-data-addr bit D/A outputs: programmable gain: 3 T/Cs; Or1 a,r4 -;checkfor s"lze = 0 40 DIO lines from 82C55 PPI $489 jz Sno internal uninit data ADA3100 8 Diff./S.E. 12.bit analog inputs; mov r0,8.low.internal u?;init data addr 200 kHz throughput; gain select; FIFO inter- clr ;zero Ginityalized data area face & DMA transfer; pacer clock; external Sinternal-uninit loop: .equal $ trigger; 4 conversion modes, multi-channel mov @FO,a scan & channel burst; 4TKs; 16 DIO lines; inc r0 two fast-settling analog outputs ____.___..__ $659 djnz r4,Sinternal uninit -loqpdec uninit data size AD510 8 S.E. inputs; 12.bit integrating A/D with programmable gain .,...... ,...... __.___ $259 Sno_internal_uninit_data: .equal $ ADA900 4 Diff.LS.E. inputs; I &bit V/F type A/D; ,.-- Copy initial values from EPROM to Internal RAM variable resolution & conversion speed; l6-bit @ 16 Hz; 12.bit D/A, T/C & I6 DIO lines _.___ $410 mov a,#.low.internal - init- data end-- addr DA6OO/DA700 Fast-settling 2/4/6/8 -channel clr c 12-bit D/A; double buffered _.__..._ $192/359 subb a,#.low.internal init data addr ;init data size DG24/48/72/96 Digital I/O lines; 82C55 based; mov r4,a ;sag l&of init data size optional buffers & line resistors $110/256 mov a,#.hiqh.internal init data end addr TC24 Am9513A System Timing & 82C55 subb a,#.hiqh.internal-init-datazaddf- - ;init data size or1 a,r4 Digital I/O control card .__.___.__.___.__.__..... $218 jz Sno internal init data ;skip init if = 0 MX32 External analog multiplexer $198 mov dpt?,#internal const data end addr ;data addr ATLANTIS/PEGASUS/PEGASUS Acquire mov rO,#.low.interiial init data aadr ;runtime addr Menu-driven, real-time monitoring, control, Sinternal init loop: .equal $ - - - data acquisition and analysis turn-key soft- c Ff -a ware packages $1.50/290 move a,@a+dptr I*load init data byte Call for your Free Catalog! inc dptr iincrement source address mov @rO,a ;store init data byte inc r0 djnz r4,Sinternal_init_loop ;dec init data size

&--This part of the 2500A D startup code clears the uninitialized variables to zero and Real Time Devices, Inc. Listing State College, PA USA sets the values of initialized variables. The rather long values starting with ‘internal_’ correspond to the section names in Listing 3. FAX: 814/234-5218 RWderSetie #I96 October/November 199 1 77 With all that in place, the startup The code in Listing4 is an excerpt cause you can tailor the routines to routine can simply call the main () from a severely edited version of the your needs. For example, the 25OOAD function to begin the program. Most 2500AD startup code that will initial- code reserves another work area on embedded applications have a “do ize simple Small (or Internal) model the stack under the assumption that forever” loop, so main ( ) will never programs that don’t use serial I/O. your interrupt handler will call the return. If it should, the startup code Even if your project doesn’t fit that reentrant library routines. BLINKBOX had probably best branch back to the description, looking over my doesn’t need this, so I could excise that beginning, reinitialize the variables, STARTUP I . A5 1 file will help you sort code and save a considerable amount and start over. out what is essential in the standard of stack space. Of course, your C code begins C8051x.SRC files. I cut out the serial handlers be- withmoreinitializations,butthemys- The interrupt keyword isa re- cause BLINKBOX has no serial I/O terious startup code is finished. It’s in cent addition to the C language which functions. In any event, I don’t think your hands now.. .for better or worse. allows you to write interrupt handlers that code belongs in the startup file: in C rather than assembler. Because an better you should have a separate col- SURPLUS SETUPS interrupt can occur at any time, the lection of serial drivers. handler must save (and restore!) the The 25OOAD startup code is de- CPU’s working registers so the inter- READY TO RUN signed to work with their hardware rupted code is not affected. The development board and includes se- 2500AD compiler inserts calls to The BBS files for this column in- rial drivers to support console I/O. - interrupt_entryand -inter- clude the BLINKBOX . ~5 1 code, my Several equate statements define the rupt routines around each modified startup code file, and the memory model and other parameters, handler: the logical place for those hex file resulting from the compila- then a bunch of #if statements auto- routines (which must be written in tion. Even if you don’t have the matically select theright routines. This assembler) is the startup code file. 2500AD compiler, you should be able works well if you have their hardware The Avocet compiler, on the other to use the STARTUP I . A5 1 file to see and want to use their serial I/O, but hand,insertsboilerplateentryandexit what kind of setup you will need when neither is true for BL INKBOX and prob- code around each handler. The you tinker with your compiler. ably won’t apply to your situation. 2500AD approach seems better be- [Editor’s Note: Software for this article is available from the Circuit Cellar BBS and on Software On Disk #23. See page 105 for downloading and ordering infor- ma tion.] ~~~~~~oxrequiresmore than 128 bytes of Internal RAM, so you must use an 8032 instead of an 8031. The obvious savings from making Tim- ers an array of BYTE isn’t quite enough, but changing the random number to an unsigned int might do the trick by eliminating a number of library routines that chew up stack space. Try it with your compiler and see. :Imetrlcs Technology’s 9-Bit Solution networks popular 8- and 16.8lt microcontrollers by Next time, I’ll take a look at Dave taking advantage of the bult-In 9-Btt multiprocessor modes. Dunfield’s Micro-C, a shareware C 9 Benefits of the 9-Bit Solution compilerthatjustmightbewhatyou’re l Lowest cost embedded controller l High s eed (62.5K baud) with low looking for. Stay synched! + networking alternative networK overhead l Compatible with your micro- l IIigh reliability protocol includes controllers CRC checking Ed Nisley is a Registered Professional En@ l Multi-drop Master/Slave RS-485 l Low resource requirements no network need and a member of the Circuit Cellar INK l 250 nodes per network engineering staff. He specializes in finding innovative solutions to demanding and un- Cimetrics Technology’s 9.Bit Solution usual technical problems. includes the NBS-2 ($165) or NBS-10 ($249) PC/XT/AT network interface, the NSF ($750) or Tiny-NSP ($199) network IRS 4 19 Very Useful 420 Moderately Useful 421 Not Useful See us at The Embedded Systems Conference Sooth #418 Reader Service if 122

78 CIRCUIT CELLAR INK FROM THE Redefining BENCH Remote Control Jeff Bachiochi Now You See ‘em--Beep-Now You Don’t I I

Thank you American Airlines. It is HANDS ACROSS THE BORDER great to be back in the USA. Don’t get Beinghiredasaconsultant isalot likeplayingfireman. One has to know which type of extinguisher will put out me wrong, it’s not that I didn’t like the blaze in the shortest period of time, with the least Mexico. It’s just a bit difficult without amount of damage. If the fire has not grown too large, you can salvage enough to create success out of failure. The knowing adequate Spanish. 5,” “no,” task at hand was not a three-alarm fire, but red tape promised to stoke the blaze. and “gracias” won’t cut it when you The biggest failure of this project was a lack of firm need to hold an intelligent conversa- specifications. The product had to be continually modi- fied, because the rules changed depending on where the tion Like, “What do you mean I don’t equipment wasbeingused. Hand-wired prototypes would not work consistently in the field. This meant delivery have the proper papers to pass cus- schedules were now approaching impossible. toms? That’s my plane!” Believe me, I want to see specifications before I start any project. Without rules, no one can play the game fairly. Designing you don’t argue with a uniformed data acquisition or any other type of equipment is impos- sible without complete requirements, I’m not suggesting guard brandishing a “pistola.” I felt like this product had been designed without any specifica- a malformed part on an assembly line: tions. I’m indicating that these were ideal specifications and only realistic in an ideal environment. The actual Honk! The quality control inspector environment can play havoc with what you might expect to see. Environmental noise, from subaudio through RF, checks my specs and presses the re- can have an impact on your data. In most cases, simply by ject button. Into the pile of discarded looking at the data in the actual environment, you can determine if the environment is adding anything to the parts I fall, along with the other bodies raw signal. If it is, you can make appropriate changes in the specifications to eliminate it. It is important that you and who can’t speak Spanish. I’ll never say your customer agree to the specifications prior to any another bad word about airline agreement or, like this company, you may never get out of the design stage. counter personnel, the last refuge for LET’S SIMPLIFY THINGS a “gringo.” Simplifying a client’s design can often result in major Mexico is a strange combination of high and low cost saving, especially when production quantities are technology. Road repair is done with pickaxes, shovels, high, and establishes the true value of hiring a consultant. and wheelbarrows; no heavy equipment. Businessmen, For instance, this client’s product used a !aptop as a serial however, wouldn’t be caught dead without their hand- I/O device permanently attached to the product. Other held cellular phones. It became obvious by the number of hardware could be used here to simplify the product and “boops” and ‘beeps” heard during lunch (from 2 PM to 5 make it more user friendly. PM) that this was when most deals were formulated. Deals One of the most exciting products I’ve seen lately is the like this one; the one which brought me to Mexico. configurable legend switch (see “Silicon Update” in Issue

October/November J 99 J 79 .!I PI+- P16- PlSd PM+ p13- P,Z$ PI,-- Pd- FOR LM2136

ANNUNCIATOR

01 40KHz OSCILLATOR I DUIIVPi) L

Figure 1 -The complete schematic for the hand-held LCD terminal doesn ‘t include much more than an 875 1 controllerplus some simple interface circuits. #20,April/May199l,ofC1~currC~~~~~INKforrnoreinfo). I began scratching out bits of circuitry on the back of These are expensive little buggers, but increase flexibility my drink napkin. My initial thought was to use an RTC52 to the point of payback in many cases. This idea could be with an RTC-LCD board, which has a LCD display driven used to reduce the number of keys necessary on a product, by memory mapped I/O. I realized immediately that it like the one being developed in Mexico. would be overkill. A micro which receives ASCII serial Every time I pick up my calculator, my mind goes into input and directly drives an LCD panel could scan keys a whirl. Every key has a legend printed on it, as well as one and send serial ASCII with few, if any, additional chips. An above it and one below it. Some of them are printed in 8751 would serve well here. That would eliminate an white, while others are printed in orange, green, orblue. It address latch, RAM, and EPROM. With a few glue chips I has a shift key, a mode key, and arrow keys. It doesn’t have could map the LCD into I/O space. No, that’s not what Ed a help key. You might have such a calculator somewhere would do. I remembered his “Firmware Furnace” col- collecting dust because you’ve lost the manual. Unless I umns on LCDsand keyboards (see issues #and #16). I felt used it every day, I would quickly forget the correct key a bit of a challenge here-I’m not much of a software sequences to do various functions. Powerful, but not user junkie. “Just to keep the glue to a minimum,” I kept saying friendly. over and over, trying to convince myself that it was neces- A better approach for I/O would be to use a simple sary. LCD display to provide output and redefine the functions of a few keys. You can see this being introduced on some PALM-SIZED TERMINAL newer test equipment. I’ve previously written routines for 4 x 20 and 8 x 40 HASTA LA VISTA LCD displays. Since the LCD will be mainly displaying menus for my home control system, and key definitions During the five-hour flight back to Connecticut (thanks will take at least one line, the small display won’t be again, American), my mind slipped back to thoughts of adequate. This design will use the larger display which has home control. I couldn’t think of a much simpler approach a physical size of 2.5” x 8”. See Figure 1 for the complete for I/O on my home control system. schematic of the terminal. Only the read and write subrou-

80 ClRCUlT CELLAR INK screen is 340 dots wide by 48 dots high. The controller uses either a dot- or char- acter-addressable mode. The latter uses an internal character set, making simple text display a breeze. The HD61830 con- troller is used on many LCD displays available today and interfaces easily to most MPUs with either a 4- or &bit data bus. Through the LCD controller’s 16 reg- isters, you have control over the display mode,cursorposition,displaystartwithin memory page, writing and reading a dis- play address, setting or clearing a pixel (in dot mode), and verifying the status of thecontroller (busy). Once initialized, you needn’t be bothered with refresh, charac- ter fonts, or display memory. If you have Photo 1 --The terminalconsists of an LCD display (on the bottom), theprocessorboard a limited number of I/O lines, the 4-bit (on the raisedportion) and a 9-V battery. Note the IR receiver module near the upper interface is handy. However, remember left corner of the display, with the /R transmiffer diode next to it. it takes two nibble transfers to pass a byte tines will need any severe tweeking, since these were of data, so there is a bit more work to be done per com- written for memory-mapped I/O. The code actually ends mand. up being a bit shorter by manipulating the LCD’s control Eight push buttons fit neatly below the 40character lines directly using CLR and SETB. display. They also form an B-bit port which works out The display I chose features an HD61830 (an Hitachi nicely. I use single-key entries, so the keypress loop is a dot matrix liquid crystal graphic display controller). The simple port read to determine whether or not a key has

OPERATOR INTERFACE

aLExIBLETECHNICALS?XCIFICATIONP Throw away your two- or four-line operator

interfaces. Why bs cryptic and unfriendly l Based on PC code compatible V25 when you can make your new or existing microprocessor l Operate locally, or up to 1 km from host machinery or instrument user friendly? l Drives any graphic panel size from J.B. Designs have produced an intelligent 240x 128 to64Ox 400 pixel l CRT or vacuum florescent interface stand-alone graphic controller (IGC) card. optional

This card is designed to meet the require- l Supports a 6 x 4 matrix keypad in ments of user friendly man-machine inter- addition to an IBM-AT keyboard face in industrial systems or portable instru- l One RS-232 and one RS-232/485 serial channel ments. The bard is like a stand-alone * Supports PC-compatible Time of Day CGAcard capable of connecting to existing Clock ornewequipmen!viaRS-232/485channel. - Eight-way DIL option switch . Standard software emulates a VDU Standard software emulates a substantial 9 User-programmable in Microsoft ‘C subset of the AMPEX 210+ terminal. So for special applications Three 32pin memory sockets for you can treat the IGCas a standard VDU in * RAMRPROMs. One of these sockets simple applications. Other user-specific inte rfaces can be written in high-level languages on the PC and transferred to the containes the driver software for the board for running under a DOS emulator. LCD displays

l Works from a single 5V input power Either matrix or IBM-AT keyboards an be used. Touch screen interface is possible. supdv (other power Input options - 1 m T\FCl~~lP F> ‘l’Ft’T..T~lC\T nP,y, LTD. alsd &latiej I l Size 200mm x 220mm I l Board power consumption ?r, Glos. GL7 2PB, U.K. approximately 200ma. at 5L 135 658122 * Fax: (44) 285 655644

October/November 199 1 been pressed. The port has internal pull- ups and each of the port’s eight bits are connected to one of the push-button switches. The other side of each switch is grounded. The port will read an FF hex if no switch is pressed or a low on the particular input bit connected to the pressed (grounded) key. The routine could be rewritten for multiple key en- tries or even a 4 x 4 keypad. Let’s take a look at a few possibilities using the display and eight keys. Figure 2 shows a simple one-key entry. From this “sub-sub-sub” menu (Living Room/X- 10 Control/Lighting), the choices are exit back to the main menu, previous menu (X-10 Control), select a lighting device to control (see more items), or redisplay this screen (it may have been garbled in trans- Photo 2-lhe 8 x40 dispk~y allows the use of very descriptive menu selections and up mission). to eight choices across the bottom of the display. If digits O-9 are needed, it requires a two-key sequence As you can see, there is a good deal of flexibility in the as shown in Figure 3. If the column with 2,5,8, and 0 is amount of information and how it is presented. Of course, chosen, a second screen is displayed eliminating the if you think in binary, any of the ASCII characters can be unselected items. Rotating the selected column eases de- entered directly by pressing the appropriate keys using finitive selection as shown in Figure 4. This can be ex- seven of your ten fingers. For me and my ten thumbs, this panded if necessary to include alphanumeric characters is out of the question (besides the fact that I am acknowl- and still only require a two-key sequence (see Figure 5). edging only single strokes).

X-lOTW523 DEVELOPERS KIT! DATA LOGGER AT LAST !! Now you cm TRANSMlT & RECEIVE X-10 COM- MANDS under control of YOUR application program. We supply you New PC driver con- with the I-O SOURCE CODE. Be up and running in MINUTES !! verts WICE68HCll to Write your own CLIPPER/BASIC program. We also have canplete a real time data logger. Saves target data in a application packages. Shipped within 24 hours worldwide. file while running user Phone cur BBS for complete pricing and details. program.

l PC based user friendly ICE with data lo ing capability. l Real time and full speed up to 14MHz c yock rates. l Single chi and expanded modes. Each Kit contains: $ 7 5 l Data wattK windows for memory, registers & stack. l On-board 64K emulation RAM maps in 4K blocks. * X-10 TW523 Transceiver l 64K real time hardware breakpoints. * Serial OR Parallel RJ-1 l/DB25 Interface l Breaks on address, address range, and memory RDIWR. l Full symbolic debu ng. * Microsofflurbo C I-O Drivers(source) l Supports all A,E an D arts. l 115.2K bps RS-232CTp lin . * 6 foot cable l 30 day money back guarantee. * Technical Reference Manual (Wytecl WICE 68HCll emulator $795.00 Suite 140 52 PLCC to 48 DIP adapter $55.00 18X-T E. Lake Street DEALER INQUIRIES WELCOME Call: (708) 894-1440 Bloomingdale, IL 60108

BARAN-HARF’ERGROUP q LOS ANGELES*TORONTO VOICE 416-294-6473 BBS 416-471-6776

ReoderServicefl13 ReaderSewice+217 82 CIRCUIJ CELLAR INK Living Room - X-10 Control - Lighting 1 - Table Lamp 2 - Reading Lamp RAM - 4.5 x6.5" d 3 - Floor Lamp 4 - Ceiling Lamp 14 l/O lines and decoded DIP switch - Serial pWtw/ DB2$ti&%&3~k BpSys in EPROM, w/ source code - RAM, l/O “&&rol f~&$$%t’ ” ‘F, id ia * ‘ MAIN PREV SEND Cross assembler included - CMOS and BASK: options a&@$&*, MENU MENU 1 2 3 4 MORE SCRN Assembled and tested - Readv for voPf neg oroiect: ’

Figure 2-Several/eve/s ofmenus can be easily traversedusing the reconfigurable push buttons.

TALK BACK

If you use a PC, then you probably know when you hear a beep, it probably means something just went wrong. If you’re using a Macintosh, you might hear a “raspberry” instead of a beep. In any case, this audible sound is enough to get your attention. These indicators give a gentle re- minder (except, perhaps, in the case of the raspberry) that you should take a closer look at what you just asked the machine to do.

Similarly, there is a TSR I’ve seen that can generate a Call or write for technical flver and appli&#& notes clicking noise whenever a key is pressed on the PC’s keyboard. This gives an audible feedback when typing, similar to the old IBM keyboards or an even older type- writer. Not a big deal, but can give a bad typist a bit more confidence. Such feedback is almost mandatory on flat keypads, like the ones used on microwave ovens. You’ve probably seen the technique used everywhere, from oc- tane selection at the gas station to your bank’s ATM. Piezoelectric devices produce a loud sound output for their size and are therefore a good choice for annunciators. A port pin on the microprocessor serves well as a piezo driver and indicates debounced keystrokes from the eight push buttons. It will also sound at the reception of a bell character (07 hex), from the serial port. This way, the source of the serial transmissions can get my attention or just indicate the end of transmission.

1 Select the column holding your number

12 3 4 5 6 MAIN PREV 7 8 9 SEND MENU MENU 0 SCRN

SEALEVEL SYSTEMS INC. FigureJ-A two-stepprocessisused when selecting from alargelist PO BOX 830 ofitems. In the firststep, the large group is divideddown to amuch LIBERTY, SC 29657 smaller group with the first button press. 1 COMMUNICATIONS 6 I/O (803) 843-4343

October/November 199 1 <*> = and HOME CURSOR WITH VOICE MASTER KEY@ FOR PCs/COMPATIBLES C-><#><#> = MOVE CURSOR to Y(row+20H) ~ VO/CERECoGNmoN M7iYSPEECHh%ZSPONSE #(column+20H) CilVE A NEW LMMENWON TO PERSONAL COMPUTlNG The amazing Voica / MaaerKaySysmmaddsvoiwr~tojlnt~mypogmmwapplii. -0 &TWO 8SCqDeS8qU8nC8SCIr8sUppOrt8d bythe LCDds- Voice command up M 256 keyboard macros frcnn within CAD, DTP, word prccessing, pbyrouthesh the Wshset~pgmeP~FuuYT=~ ceupieslessthM64K~ hanci-hekitmhd. \imq=WMw@n&araol. Ardproductivitymm1 SPEECH RECORDING SOFTWARE SECllON DQitaWy recurd your own speech, sound, THE SOR ormusictoputintoyourownsoHwara pograms. S&ware povides sampling rate variraion~. graphics-based editing. and The software is written as two parts: the main body data compression utiWie8. Create software sound files, voice memos. more. Send and the serial interrupt service routine. [Editofs Note: voics mail through LANs or modem. A Software@ this article is availablefrom the Circuit Cellar BBS wperior speech/sound development tool. INTERACTWE SPEECH INPUTIOUT- andonSofhuareOnD&k#23. Seepage 105firdownloadingand PUT Tag your own digkized_ speech files to ordering injwmatin.1 The mice recogrntion IMQCS. Prowdss spwm main body includes the initial- mspmss to your spoken commands -- al ization code and the key scan loop code. Initialization sets from rvllhin your application sofhvarel Ideal for business. prassntation, education, ar up the serial port (using timer 11, clears thebeeper, calls the elnwtainmmlt pmwams vou rxlrmnw use. kigmmt the system for v#kukss uses In rc<ias, fa&ry-pro&3 controls, .horne LCD UO~INIT routine, and enters the key scan loop. This automation. new products, etc. voice Master Key system does r all! loop is where we stay as long as a key hasnot been pressed EVERYfHfNGfNCLUDEDVoicsM&WKeySystacagistsOfE4plUg4inWrd dusblongMw6@tmicr~huQa.sdtwsrs,andmarnJal.Cerdfitsany (or a serial interrupt has occurred). Once a key is pressed, avaitWeslot.Extsrn@pcitsamsistofmicInputsandvolumscontrMdoutpul we debounce it by pausing and rechecking to make sure sockets.Highqualitythroughwt.easymdfuntouse. it’s still good. If it is, the beep routine is called and the ONLY $149.95 COMPLETE ORDER HO- (503) 3424271 Mondsy-Friday 8 AM to 5 PM Pacifc T#ne appropriate character is placed into the transmit buffer. VISAMasterCard phone or FAX orders acwpted. No CODS. Personal chec+ia ~to3weekshippingdelay.Spedlycompvterrypeanddiskfonnai(311IT’orE Once the key is released, execution returns to the key scan I 114’7 when orderina. Add $5 st&mina charae for deliirv in US.4 and Canada loop. F&igllinquiraaC&UClcowXfU’~6F~. .WMYYIYmET&(CKGU4R4MEE~M0~C~rS#?BRY&9 If a serial interrupt--either transmit or receive--oc- CALL CM WFUTE FOR FREE PIKBDIJCT CATALOG. curs, execution branches to the serial interrupt routine. A anmk check is made on the receiver first to give serial input 675 CONGER ST. TEL (503) 3424271 EUGENE, OR 97402 FAX: (503) 34Zf283 priority over transmitting. Received characters are pro- JB cessed through the LCD routine as part of the serial inter- ueaYJmsewlce #I32 rupt. The LCD routine manages the display positioning and filters out two escape sequences (shown in Figure 6) from the serial data. In addition, the bell character will call the beeper routine. It will normally be used to indicate that the system is awaiting a decision and a keypress would be appropri- ate. Choosing the 87C51 for its internal serial port, timer, and EPROM, and using an LCD display which doesn’t require any housekeeping makes for simple code. Fewer devices also means power savings. Although I could steal the smart power regulator I offered in last issue’s column, a simple on/off switch is the simplest and least expensive approach. There is no need for the device to be able to turn itself on, at least none that I’ve thought of up to now. I already have an alarm clock, smoke alarms, and a door bell. Maybe if I added a speech synthesizer to the IR terminal.. . On second thought, not now. I just found a package of airline peanuts in my pocket. I think I’ll get me a cold one and relax. This one’s for you, American! + Jejj Ihachiochi (pronounocd “BAH-key-AH-key”) is an ekctricaI engi- nar on tk Circuit Cellar INK engineering staff. His background includes product design and manufacturing. IRS 422 Very Useful 423 Moderately Useful 424 Not Useful Select the column holding your number Select the column holding your character A B C D E F G H I J K L M N 0 P Q R S T U V W X MAIN PREV SEND MAIN Y 2 0 12 3 SEND MENU MENU 2 5 8 0 SCRN MENU 4 5 6 7 8 9 SCRN I 1 q cl1-1~0000 1 q cluIuuucl Figure a-The next step after that shown in Figure 3 is to make a Figure 5-7heentirealphabetplusnumberscanbeencodedusing second selection from the smaller group. several button presses to select a particular character.

COMMUNICATION IS THE KEY held master when any of the eight individual keys are pressed. The slave’s response is an IR transmission of the Communication between the hand-held terminal and appropriate ASCII message, which is displayed by the the host computer can be done in one of two ways: infrared LCD. With this ping-pong approach, you can find your or hard-wired RS-232. I primarily use the IR interface, way quickly through predetermined menus to any num- which I already described in “From The Bench” in issue ber of acquisition and control functions. #21. To help eliminate transmission and reception errors, The LCD display requires a negative bias voltage to I only use 7-bit ASCII characters, even though the display boost the contrast. Since I’m already supporting a stan- has a full 8-bit character set. Protocol is set by the home dard RS-232 port, I can steal some negative voltage from control (slave) unit. The slave listens for IR and responds the MAX233 being used for the RS-232 interface to drive only to the reception of ASCII characters 31h through 38h the display (the MAX233 is a MAX232 with internal charge (ASCII characters l-8), which are transmitted by the hand- pump capacitors).

The $595 Solution to 8051 System Development

n Table based absolute macro cross-assembler PDKSI using manufacturer’s assembly mnemonics. n Includes manual and MS-DOS assembler disk with tables for ALL of the following processors: 16CSX 64180 6801 8048 H8pOO 28 37700 6502 6805 805 1 H8/500 280 50740 65816 6809 8085 ‘lUS320 2180 78ClO COP400 6811 8086 TMs340 2280 SUPER8 COP800 68000 8096 TMS370 MORE...

n Users can create tables for other processors or The PDK51 is a fully integrated l KS i1 cable ask us, we have many morel hardware, firmware, and software l PDKSl tutonai l Opfronal: dlumrnum ~~-845, system designed to help you develop mumtorlrlrbugger ,ource-$25, n Generates listing, symbol table and binary, your products quickly and cost b<*> = CLS and HOME CURSOR WITH VOICE MASTER KEY” FOR PCs/COMPATIBLES <=?<#><#> = MOVE CURSOR to #(row+20H) VO/CE ffECOGN/T/ON W/TH SPEECH RESPONSE #(column+20H) GIVE A NEW DIMENSION TO PERSONAL COMPUTING The amazing Voice Master Key System adds voice recognition to just about any program or application. Figure ~-TWO escape sequences are supported by the LCD Cys- Voice command up to 256 keyboard macros from within CAD, DTP. word processing, spread sheet, or game programs. Fully TSR and occupies less than 64K. Instant olay routines in the hand-held terminal. response time and high recognition accuracy. A real productivity enhancer1 SPEECH RECORDING SOFTWARE Digitally record your own speech, sound, THE SOFT SECTION or music to put into your own software programs. Software provides sampling rate variations, graphics-based editing, and The software is written as two parts: the main body data compression utilities. Create software sound f&s, voice memos. more. Send md the serial interrupt service routine. fEdifor’s Note: voice mail through LANs or modem. A G$twarefor this article is availablefrom the Circuit Cellar BBS superior speech/sound development tool. lN+ERA&TlVE SPEECH l.NPUT/OUT- &onSoftwareOn Disk#23. Seepage105fordownloadingand PUT Taa vour own diaitized speech files to voice re&gnition ma&s. P&ides speech mfering inform&ion.] The main body includes the initial- response to your spoken commands -- al zation code and the key scan loop code. Initialization sets from within your application software! Ideal for business, presentation, education, or lp the serial port (using timer l), clears the beeper, calls the entertainment programs you currently use Augment the system for wireless uses in robotics, factory process controls, horns KD UOI INIT routine, and enters the key scan loop. This automation, new products, etc. Voice Master Key System does it all1 oopis where we stay as long as a key has not been pressed EVERYTHING INCLUDED Voice Master Key System consists of a plug-in card durable lightweight microphone headset, software, and manual. Card fits an) or a serial interrupt has occurred). Once a key is pressed, available slot. External ports consist of mic inputs and volume controlled outpul ye debounce it by pausing and rechecking to make sure sockets. High quality throughout. easy and fun to use. t’s still good. If it is, the beep routine is called and the ONLY $149.95 COMPLETE ORDER HOTLINE: (503) 342-1271 Monday-Friday 6 AM to 5 PM Pacific Timt appropriate character is placed into the transmit buffer. VlSPJMasterCard phone or FAX orders accepted. No CODS. Personal check: subject to 3 week shipping delay. Specify comp&r type and disk format (3 l/2” or ! 1nce the key is released, execution returns to the key scan l/4”) when ordering. Add $5 shipping charge for delivery in USA and Canada DOP. Foreign inquiries contact Covox for C & F quotes. 3ODAYMONEYBACKGUAR4NTEE/f NOTCOMPLffEL YSAT/Sf/ED If a serial interrupt-either transmit or receive-+c- CALL OR WRITE FtR FREE PRODUCT CATALOG. ‘urs, execution branches to the serial interrupt routine. A COIlOX INC. ‘heck is made on the receiver first to give serial input 675CONGERST. TEL (503) 342-i 271 )riority over transmitting. Received characters are pro- EUGENE, OR 97402 FAX: (503) 342-l 283 essed through the LCD routine as part of the serial inter- ReaderService f132 upt. The LCD routine manages the display positioning nd filters out two escape sequences (shown in Figure 6) rom the serial data. In addition, the bell character will call the beeper outine. It will normally be used to indicate that the system 5 awaiting a decision and a keypress would be appropri- te. Choosing the 87C51 for its internal serial port, timer, nd EPROM, and using an LCD display which doesn’t squire any housekeeping makes for simple code. Fewer evices also means power savings. Although I could steal le smart power regulator I offered in last issue’s column, simple on/off switch is the simplest and least expensive pproach. There is no need for the device to be able to turn self on, at least none that I’ve thought of up to now. I lready have an alarm clock, smoke alarms, and a door ell. Maybe if I added a speech synthesizer to the IR Frminal.. . On second thought, not now. I just found a package of irline peanuts in my pocket. I think I’ll get me a cold one nd relax. This one’s for you, American! $? ff Bachiochi (pronounced “BAH-key-AH-key”) is an electrical engi- LY on the Circuit Cellar INK engineering staff. His background eludes product design and manufacturing.

422 Very Useful 1 w.rq, SEALEVEL SYSTEMS INC. 423 Moderately Useful PO BOX 830 LIBERTY, SC 29657 COMMUNICATIONS 6 I/O 424 Not Useful I (803) 843-4343 October/November 199 1 85 SILICON 1 ;mraFyE Nuts About RISC Go on a Low-Fat Acorn Diet

Almost three years ago, in the first issue of CIRCUIT CELLAR INK, I wrote short piece entitled “RISC vs, Reality” in which I, with tongue somewhat in cheek, attacked the RISC hype and zealotry then at its most strident. The main point, admittedly presented with inflammatory rhetoric, was that RISC was more a marketing ploy than a technological “revolution. m Essentially, the RISC concept (which I was careful to point out, has some technical merit) had devolved to mean any new chip which isn’t an 80x86 or 68xxx. Since then, having failed to displace low-end PCs (i.e., 80x86- and 68xxx- based systems), many RISC suppliers are pushing (hoping) for an “embedded RISC” market to emerge.

For some reason, whenever I hear the term embedded HIGH-FAT CHIPS RISC I can’t help but visualize a “UNIX toaster.” Built-in multitasking means you can burn more slices at once while The problem with most RISCs is that there is nothing the ubiquitous Ethernet port handily connects to your reduced about them. In the beginning, the RISC argument coffee maker. Even the fussiest chef won’t tax a 4gigabyte was that a simple CPU and a complex compiler could virtual address space. achieve performance similar to the opposite (i.e., complex Frankly, so far most of the embedded RISC offerings CPU, dumb compiler) setup. This is meritorious-better to are about as practical as a UNIX toaster. However, there is spend more initially for a fancy compiler if the payback is hope on the horizon as suppliers migrate their existing smaller/cheaper CPUs in each and every unit sold. “CRISCs” (Complex RISCs, or UNIX chips optimized for Somewhere along the line, reflecting various players’ cranking floating-point loops) towards “Retro-RISCs,” marketing agendas, the RISC pitch mutated from one of whichattempt to recapture the simplicity and innocence of “good performance at lower price” to “highest perfor- the original concept; kind of the micro equivalent of the mance at any price.” Thus, we end up with “reduced” Mazda Miata. chips like the i86OXP with 2.5 million transistors and a As suppliers continue to strip unneeded UNIX bag- $500+ price tag! Unless you’re designing the mother of all gage and cut prices and chip count into the realm of real- toasters, it’s not very relevant. world controller feasibility, I imagine I’ll have more to say In the quest for performance, traditional RISC features about embedded RISC. are being jettisoned left and right to the degree that the Meanwhile, we can start with one of the oldest RISCs term RISC has become meaningless technically (if in doubt, which, thanks to its age, turns out to be a good example of revert to the marketing definition: RISC = NOT [80x86 OR a Retro-RISC. Whether the Acorn CPU (now rechristened 68~~x1). Even the feature most identified with RISC- the “ARM” for Advanced RISC Machines) itself takes off LOAD/STORE architecture (ALU works only on regis- or not is hard to predict. Nevertheless, I think we can catch ters, not memory operands)-may be under attack. In a a glimpse of tomorrow’s popular embedded micros in recent review of a new controller chip featuring LOAD/ today’s ARM. STORE, one pundit noted that “programmers won’t ap-

86 ClRCUlT CELLAR INK preciate its lack of memory operands for the arithmetic The register set looks about as conventional as can be and logical instructions.” CISC lives!? on the surface: 16 32-bit mostly-general-purpose registers. The bottom line is that complexity is inherently linked R13 is used as a software multilevel stack, R14 as a hard- to performance, otherwise we’d all be using l-bit Turing ware one-level stack (LINK), and R15 is the PC and ESW machines. (using the upper 6 bits of the PC for PSW yields a 26-bit, or 64-MB, address space). The elimination of a conventional dedicated stack pointer and program counter in favor of ARM-2 i86OXP using regular registers is one example of the minimalist philosophy that characterizes much of the ARM-2 design. Actually, the register set consists of 27, not 16, regis- 0113 x 113 mils 0410 x 610 mils ters. As shown in Figure 2, the 27 physical registers are ml .O pm 00.8 ym/3-metal mapped against the 16 logical registers using a register l 27k transistors l 2.55M transistors bank approach. However, this isn’t the complicated pro- cedure-call/return-oriented register window mechanism q promoted by some RISCers, but a simple interrupt-ori- ented context switch scheme much like the alternate reg- ister set on Z8Os. Essentially, a portion of the register space is automatically swapped depending on the state-USER, Figure 1 -The ARM-2 is only about one-twentieth the die size of the SUPV, IRQ, FIRQ-of the CPU. For example, in response IMOXP, even though the latter is bui/t with a denser process. to a fast interrupt request (FIRQ pin), the CPU will auto- matically switch a portion of the register set (R8-R14). The But isn’t the goal of most embedded designs “ad- idea is that the FIRQ handler can (hopefully) find every- equate performance at minimum cost”? If so, the world thing it needs in the swapped registers and do its thing still needs someone to champion the original RISC con- without any slow memory context save (push) or restore cept. (pop). This, along with the (mostly) short/fixed latency of instructions, means interrupt response time is very good- LEAN & MEAN MACHINE typically, less than 1 ps. Contrast this to many UNIX-type RISCs, which seem to have little understanding of real The ARM-2 CPU looks a lot like other 32-bit CPUs on time at all. Just try to figure out the interrupt latency on one paper: 32-bit registers and ALU, 64-MB physical address of those superscalar/pipelined, compiler-optimized, space, USER/SUPV protection, and so on. However, there virtual memory behemoths and you’ll see what I mean. is one big difference: the ARM-2 die size is a measly 113 x 113 mils. Figure 1 puts this in perspective by comparing against the previously mentioned state-of-the-art i86OXP. 31 8 7 0 Note how the ARM-2 is only about one- I I I RO twentieth thedie sizeof thei86OXP, even though . . the latter is built with a denser process (0.8 urn . vs. l.Oltm).Transistor-wise, the ARM-2isalmost RlO exactly 1% the complexity of the i86OXP! Rli Is the i86OXP faster than the ARM-2? Of User I R12 course. Is it 100 times faster? Maybe, especially Mode RI3 t I I R14 if your forte is weather simulation or some (LINK) similar matrix-floating-point-bound applica- R8 R9 tion. Is it better for a toaster (or other non- Fast RlO rocket-scientist applications)? No way! IRQ I Rll Mode R12 Its tiny die size might lead you to believe t I R13 the ARM-2 pushes reduction to the frontier of R14 marginal usability as promulgated by true RISC (LINK) IRQ R13 zealots-you know, the folks who would have Mode R14 you believe you don’t really need a multiply (LINK) instruction since it can be reduced to shifts and SUP R13 Mode R14 (LINK) adds. In fact, the ARM-2 has a multiplier and a 31 302928272825 2 1 0 number of other “CISCy” features. Since com- [N[ZlClVl IIF] PROGRAM COUNTER IMllbq R15 plexity is out of favor, let’s call the ARM-2 a PSWPC “Clever Instruction Set Computer.” I’ll point out its deviations (most of which I agree with) Figure 2--The ARM‘s 27 physical registers are mapped against 16 logical from “correct” RISC dogma as we move along. registers using a register bank approach.

October/November 1991 87 Flags The instruction set is truly reduced, con- Instruction Function Ooeratlon Affected sisting of little more than LOAD/STORE to ADC I Add With Carry 1 Rd:=Rn+Shitt(SG?)+C 1 N I 2 9 C 3 V get stuff in/out of registers, the typical ALU ADD Add Rd:=Rn + Shitt(S2) N, Z C, V ops (Figure 31, and branch. Instructions are AND Lld I Rd:=Rn l Shift/!%?) I N. Z. C fixed in length at 32 bits which won’t help BIC Bit Clear Rd:=Rn l -Shii@) N; Z, C CMN Compare Negative Shift(S2) + Rn N, Z, C, V code density, but it does keep things simple. CMP Compare Rn - Shift(S2) N,Z,C,V The ALU ops typically accept three oper- EOR Exclusive OR Rd:=Rn @ Shift(S2) N, Z, C ands as is usual for a RISC: MLA Multiply With Accumulate Rd:=Rm l Rs + Rd N, Z, C, V MOV Move Rd:=Shift(S2) N. Z. C MUL I Multi& I Rd:=Rm l Rs I N. Z. C. V ADD RO,Rl,R2 ; RO=Rl+R2 MVN Move Negative Rd:=Shift(S2) N; Z; C’ ORR Inclusive OR Rd:=Rn + Shitt(S2) N, Z, C RSB Reverse Subtract Rd:=Shift(SP) - Rn N, Z, C, V Of course, a two-operand instruction can be Reverse Subtract impersonated by making the destination With Carry Rd:=Shift(S2) - Rn - 1 + C N, Z, C, V equal to one of the sources. SBC Subtract With Carry Rd:=Rn - Shift(S2) - 1 + C N, Z, C, V SUB I Subtract I Rd:=Rn - Shift(S2) I N. Z. C. V Exploiting pipelining, most ALU ops TEQ Test For Equality Rn @ Shift(S2) ’ ’ N; Z, C’ effectively execute in one cycle. Exceptions TST I Test Masked I Rn l Shift(S2) I N, Z, C are Multiply (MUL) and Multiply& Accumulate (MLA), which can take up to 16 Figurefunc+iono,,~ S-Most is possib,e of the typical ALU operations are supported by the ARM, but extra clocks. Give the ARM-2 credit for being one of the first to include the Multiply&Accumulate function A skip (only one clock) is much faster than a branch now in vogue on the newest machines. Loads, stores, and and, furthermore, the number of instructions (i.e., code branches are memory bound and thus take a minimum of size) is cut in half. A potentially helpful side effect is that three clocks and possibly more depending on the speed of the ARM-2 sequence executes in the same time down the memory subsystem. Load/Store Multiple, which moves either path (i.e., whether Rl or R2 is stored). multiple registers to/from memory, is much slower Another use for the skip feature is replacing sequences depending how many registers are transferred. of the form: Addressing modes (only used with LOAD/STORE; see Figure 4) consist of PC relative (with up to a 12-bit ; IF RO=Rl or R2 then branch offset), base reg + (12-bit) offset, and base reg + index reg. CMP RO,Rl However, through clever use of pre- and postincrement BEQ options, the few basic modes effectively do the work of CMP RO,R2 many more, and getting at memory isn’t too hard. BEQ As for data types, the ARM-2 supports 32-bit words and bytes-that’s all! No BCD, strings, bit fields, and so with the ARMized forth. Refreshing isn’t it? However, underneath this mild-mannered CMP RO,Rl programmer’s model lurk singular features which aren’t IF NZ CMP RO,R2 RISC or CISC or AnyKindOfISC that I know of. They are BEQ strange, which is probably why I like them! First, every instruction features conditional execution Another branch bites the dust! depending on the programmer-specified state of the PSW Indeed, besides conditional execution based on the flags (Z, N, etc.). Actually, those of you familiar with PSW flags, it turns out that the ARM-2 programmer can microcoding (and other lost arts) will recognize this”skip” also specify whether ALU instructions should set the flags function and perhaps even remember what it’s useful for. or not. This solves the oft-encountered dilemma of inter- How often have you faced a programming situation ference during the time between when a condition is like “If theZ flag is set, store Rl, else store R2”? Invariably evaluated (i.e., flag set) and the result of the evaluation you end up with something like: used (e.g., conditional branch). Thus, on the ARM-2 you can do cute things like: BNZ next STORE Rl * see if RO and Rl are equal BRA continue kMP RO,Rl and set flags next: STORE R2 ; in any case, set Rl = Rl t R2 continue: ADD Rl,Rl,R2 but don't set flags . original CMP flags still valid With the ARM-2 skip feature, you can effectively write ;3EQ RO- WAS EQ-- Rl

IF Z STORE Rl But wait, it gets even better. The processor doesn’t IF NZ STORE R2 have any SHIFT instructions. Well they’re not needed

88 CIRCUIT CELLAR INK I Addressing Mode ODeration Svntax since every ALU instruction is a SHIFT instruction! That’s PC Relative EA’ = PC f Offset (12 Bits) LABEL right, backed by a barrel-shifter (i.e., l- to 32-bit shift in one clock), one source operand (including immediates) can be Base Register Offset EA=Rn shifted during any ALU instruction. With Post-Increment Rn f Offset 4 Rn IRnl. Off So, instead of a SHIFT instruction, you just use a Base Register Offset EA = Rn f Offset (12 Bits) MOVE instruction: With Pre-Increment” Rn +I- Offset + Rn [Rn. Off]

Base Register Index EA=Rn MOV RO,RO LSL n (n=l to 32) With Post-Increment Rn + Rm-, Rn [Rnl, Rm Shifting an immediate yields a quick and easy way to Base Register Index EA=RnkRm With Pre-Increment Rn f Rm-r Rn load large immediate constants: [Rn, Rml

’ Effective Address MOV RO, #3 LSL 31 ; RO=#COOOOOOOH I *’ Program control of index register update (i.e.. Rn may be left unchanged) Normally, loading large immediate constants on a Figure 4-Through clever use ofpre- andpostincrement options, a RISC processor has to be done piecemeal since the number fewbasicaddressingmodeseffectivelydo the workofmanymore. and opcode won’t both fit in the fixed 32-bit instruction word. It’s been said (by me anyway) that RISC means “Rel- More interestingly, the shift feature leads to constructs egate the Impossible Stuff to the Compiler.” In particular, which, though rather bizarre looking, are very fast. For the more esoteric chips call for a whole class of optimiza- instance, say you want to multiply a register times 45 tions known as “code scheduling” in which convention- decimal. Now your average Joe Programmer will prob- ally generated intermediate code is reordered for optimal ably just use the slow MUL instruction. But, an astute ARM execution. Many RISCs feature (?) delayed load and/or guru will come up with delayed branch, so the compiler will try to move a useful instruction into the delay slot. The latest chips with mul- ADD RO,RO,RO LSL 2 ; multiply by 5 tiple execution units call for the sequential intermediate ADD RO,RO,RO LSL 3 ; multiply by 9 code to be automatically “parallelized,” a black art indeed. The problem is that reordering code involves a raft of complicated “dependency analysis” algorithms to ensure the massaged code works as intended. However, the ARM-2 calls for no such gymnastics THE “GREAT DEAL” CATALOG since there aren’t any delay slots (much less multiple execution units) to worry about. Furthermore, the oppor- 386TM -SX 16MHz Computer with 40MB Hard tunities afforded by the unique instruction set are easily Drive and 14” Color VGA Monitor handled as peephole optimizations-simple text search/ - Intel 386.sx .1 parallel and 2 microprocessor, at serial ports. replacement of the output code. Thus, the compiler can 16 MHz. IOl-key RO .I MB RAM. keyboard. simply generate a MUL , # 4 5 which the optimizer can * 40MB hard drive. . 1 &bit VGA easily recognize and replace with the faster ADD/SHIFT * Five expansion display adapter sockets. res. 800x600. sequence. Similarly, short forward branches can be opti- . One 3.5” 1.44MB 80387 math co- and one 5.25 processor slot. mized into oblivion using the conditional execution fea- 1.2MB floppy . Includes DR- ture to skip the formerly branched around code. disk drive. DOS 5.0.

* IBM comoatible Soinnaker-r ~~ . 14” VGA color Eight-in-One Mfr. Sugg. Retail: $3,469.00 YOU GET WHAT YOU PAY FOR monitor, res: SOfhWK?. 640x480, .4lmm . One Year Mfr. dot pitch. Warranty! 2999s l Factorv New! item No. B-3537-189036 S/H 549.00 Based on the glowing review so far, you will probably

FOR FASTEST SERVICE, CALL TOLL FREE be surprised when I say the ARM-2, as it is today, isn’t a good choice for most embedded designs. l-800-729-9000 EBE 1 The gotcha is that while the basic CPU architecture is DAMARK INTERNATIONAL, INC. Please rush me: ~ PROTEK COMPUTER(S) 7101 Wlnnetka Ave. N. @ $999.99 each, plus $49.00 S/H each. neat, the chip implementation has limitations that make P.O. Box 29900 Item No. B-3537-189036 Minneapolis, MN 55429-0900 MN res. add 6.5% sales tax. system design difficult. The problems stem from the heritage of ARM-2-the (then Acorn) chip was designed as an alternative to the

Customer Service: 80x86 and 68xxx for use in a personal computer supplied l-800-733-9070 to schools by the BBC. CopyrIght ,991 DAMARK lnternat,anal, Ix As such, the CPU itself was never designed to work All r19hts reserved. stand-alone, but instead was meant to work in concert with outside memory and I/O control chips. Unfortu- nately, these bring along a lot of “desktop” baggage-

90 CIRCUIT CELLAR INK video, sound, virtual memory MMU, and so on-that are likely not needed in an embedded design. Yet, designing an ARM-based system without them isn’t easy. The basic problem is the ARM-2 bus interface: there isn’t one! Well, of course there are address, data, and control lines (Figure 51, but they need significant condi- tioning to connect to conventional memory and I/O chips. For example, the ARM-2 relies on address pipelining and burst transfers to achieve no-wait-state performance with slow DRAMS. If you don’t use their outside memory controller (MEMC) chip (with MMU, video support, etc.), High Performance a few PALS will be called for unless you can afford a big performance hit. Siniilarly, without their IOC glue chip, Multimegabyte Disk Emulators connecting byte-wide static ROM, RAM, and I/O chips NEW MODELS / LOWER PRICES isn’t easy. Speaking of ROMs, you’ll need four of them Floppy Drive and multimegabyte unless you roll your own “x 8 boot ROM” circuit. Need a emulators for ISA bus computers wait state? Whip out those old 6800 clock stretch circuits! 180K to 14 MB capacities I haven’t even mentioned the follow-on chip, the ARM-3, since it seems to have just gone farther down the EPROM, Flash or SRAM technologies desktop path. While it does have a slightly easier bus Autobooting, Single or Dual disk interface, the major additions are 4K bytes of cache and a emulation under PC or MS DOS dedicated coprocessor interface. In my opinion, cache is of List prices from $195 dubious merit in embedded designs since it blows deter- minism (how long, exactly, a section of code will take to CURTIS, INC. 2837 No. Fairview Ave. l St. Paul, MN 55113 execute). If the ARM-3 had a way to use the cache as RAM, 6121631-9512 FAX 6121631-9508 or even a way to lock key stuff in the cache, I would be more PC DOS IS a trademark of IBM; MS DOS IS a trademark of M~croscoft interested. As for the dedicated coprocessor interface, the packaging penalty seems high (I’d rather not deal with 150-16O-pinchips)sinceIprobablydon’tneedacoprocessor (which is fortunate, since the catalog doesn’t show any for sale). The ARM-3 may be fine for tutoring UK techno-tots, but it’s not going in my next toaster design. How many 8051 compilers BACK TO REALITY

There is hope for the ARM. Recently, control of the Promo& world peace! architecture has been spun off to a new company, Ad- vanced RISC Machines Ltd., with investment from Acorn (the original designer), VLSI Technology Inc. (chip

Address Bus POWW &E-A0

Cbdc Inputs :: ; Your firmware dArelopment will be more peaceti - ‘IRQ Interrupt - - ‘FIAQ and easier using &e language you already know COlltVJl BASIC.

0 BCl51 BASIC cross compiler l Extensive compile-time and System run-time error handling options l Integer math with four data types COtltK4 *Co-existwiih BASIC-52orstand-alone*Unlimitedphonesupport, outstanding documentation *Now supports DS5000T & ‘C51F CPA , Series l With assembler and utilities $299 l Assembly Language Programmer’s Toolkit $99 Systronix Inc. 754 East Roosevelt Avenue Figure 5-The ARM-2 features the normal address, data. and Salt Lake City, Utah 84105 control lines, but they need significant conditioning to connect to 801387-7412 FAX: 801-487-3130 conventional memory and I/O chips.

October/November 199 1 weighting curves, and investigates some of its effects. ations less than 20 dB/decade can be realized with some- The consequences of this work are of particular inter- what more complex filters [71, but the frequency range est in the field of noise reduction. Automobile manufactur- over which the characteristic is maintained is restricted, ers, forinstance,areinterested in reducing noise within the the more so the smaller the attenuation rate. Maintaining cab of a vehicle. Reducing noise to inaudibility might an attenuation of, say, 10 dB/decade over a broad range of arguably present a positive danger to the driver by isolat- frequencies usually requires multisection filters. ing him psychologically from his control of the vehicle. On The A-weighting filter in current use combines two theother hand, the duration of exposure during long trips independent 20dB/decade high-pass sections, one hav- argues strongly for reducing cal; noise at le& to-co& pktely innocuous levels. How the use of the linear A- weighted curve causes the expenditure of excessive effort in such an endeavor will become evident later.

~SITIVCTY OF THE -AVERAGE” EAR

A program to calculate the subjective effect of sound lhust relate subjective loudness levels (phons) to mea- sured intensity levels (dB referred to W-l6 watt/cm2) at various frequencies. Nonlinear relationships of this sort maybe handled in two ways: either with a lookup table or an expression that represents the data with acceptable accuracy. Unlesslookup tables occupy a large space within ._ .- the computer memory, multiple interpolations are often necessary in their use. Use of an expression is preferable Figure2- ‘ParTidfflter’r8~nS8S apPrOXknOi8 th8 H8tCh8FMUnSOn from the standpoints of speed and economy, and was the cLyves beloW ‘OaD Hz* approach of choice in this article. I must admit to some bias in this matter. In 1953 I observed that above 1000 Hz, the Fletcher-Munson curves are almost linear with intensity. This being the case, their inversion to obtain the frequency response of the ear is permissible. The lower peak had a resonance at 3800 Hz with a damping factor of 0.20 [61.

FREQUENCIES BELOW 1000 HZ

Below 1000 Hz, the Fletcher-Munson curves show that the ear’s sensitivity is markedly nonlinear with intensity. At 30 Hz, for example, a sine wave tone having an intensity ._ .- level of 1OOdB has a subjjve loudness level of 100 phons. Rlraercrm Reducing the intensity by less than40 dB makes the sound r virtually inaudible (0 phons). At 100 Hz, the same reduc- rburo 3-Eqquations moy be us8cY to approXmaf8 the F/etcher- Munson ClJ’VBS. un8S are CCYlculated Whi/8 th8 dots Clr8 from tion would not have nearly as much effect; the subjective n8tcher_tison, level would only be reduced to 40 phons. - Extrapolated bass-response Fletcher-Munson curves meetcloselyatapointcorresponding to(6Hz,lOOdb)with two exceptions: the curves for loudnesses of 110 and 120 phons. These levels, corresponding to the sound gener- ated by hammer blows on a steel plate (or what amounts to the same thing: a rock band) are not of very much interest in sound-reduction work. [Author’s Note: Sounds of these intensities are perceived other than by the ems (they are notsilencedbyclosingfheears,andareperceivedbysomepeople ordinarily considered deaf). People who are exposed to such sounds often deal with them in unusual ways.1 The sensitivity curve for the IO-phon loudness level has a slope of -30 dB/ decade, while that for the 70-phon curve is -2OdB/decade. An analog filter with attenuation of 20 dB/decade is easy to design since it uses a single R-C network. Attenu- Flguro 4--phon W8/QhtlnQ fCJCtOfS. CuyeJ cYr8 COfMtUnt ht8fldb’. foundry), and Apple. The involvement of Apple has in- accessed much faster than external memory, performance spired speculation; my guess is the ARM core might end would be high and scale linearly with clock rate. With all up buried in support chips designed for tomorrow’s Mats. memory on-board, bus interface headaches disappear and Meanwhile, ARM Inc. also supplies the usual variety low-cost, low pin-count packages are feasible. of tools running on the usual platforms: C compiler, simu- Thanks to its excellent efficiency (performance per lator, assembler, linker,even (shudder) a UNIX port. While transistor), the ARM architecture is arguably one of the I don’t have specific quality info, the fact that the tools have best candidates to serve as the core of tomorrow’s 32-bit been around a long time is a positive sign. “C’ingle Chips. + Anyway, the key point is that the new company is not constrained to serve only one customer (Acorn/BBC) or market (educational PCs). Now, they have the freedom to COMTACT design chips that truly serve the embedded control mar- ket. Manufacturing is expected to open up as well since Advanced RISC Machines Ltd. ARM Inc. intends to license a variety of suppliers to offer Park End standard and custom variants based on the CPU core. Swaffhan B&beck It wouldn’t be hard to make a highly integrated ver- Cambridge 685 ONA sion of an ARM microprocessor. This would involve add- England ing the modern bus interface features (chip selects, wait Phone: 0223 813000 states, DRAM refresh and high-speed access modes, etc.1 Fax: 0223 812800 and typical I/O functions (some timers and a UART or two) found on contemporary competitors. The chip could Tom Cantrell holdsa B.S. in economicsandan M.B.A.from UCLA. He be further enhanced (“tarted up” as they might say in the owns and operated Microfuture, Inc.,and has been in Silicon Valley for jolly old U.K.) with a fancy interrupt controller, low-power ten years working on chip, board, and system design and marketing. operation modes, and similar bells and whistles. A la “My Fair Lady,” the once homely ARM can be transformed. IRS Even better, why not take advantage of the CPU’s tiny 425 Very Useful size to pack on a lot of (EP)ROM and RAM-say 64KB and 426 Moderately Useful 4KB respectively. Since the on-chip memory could be 427 Not Useful

P-C-B ARTWORK MADE EASY ! Create and Revise PCB’s in a Flash

* HERC, CGA, EGA, VGA, SUPER-VGA * HELP SCREENS Model 250 for Algorithm Development, * EXTREMELY USER FRIENDLY Data Acquisition, Instrumentation. Audio. *AUTO GROUND PLANES * DOT- MATRIX, LASER and PLOTTER ART l TMS32OC25 DSP at 10 MIPS. * GERBER and EXCELLON OUTPUT l Up to 192 Kwords RAM. * CREATE YOUR OWN FILMS with 1XART l Multi-Channel Analog IO - 250K Samples/set. * LIBRARIES l Development Software, including Assembler & * DOWNLOAD DEMOS from 24 hr. BBS! Debugger. l Applicattons Software includes FFT. Signal REQUIREMENTS: IBM PC or Compatible, 384K RAM Display, Data Acquisition &Waveform Editor. DOS 3.0or later. IBM compatible printers, HP Laser l No Gap Sampling to/from Disk at Very High PCBoards - layout program 99.00 Rates. (PCBoards HP or HI PEN PLOlTER DRIVER 49.00) l Supports Multiboard & Standalone (EPROM) Operation. PCROute - auto-router 99.00 l From $1095. Other DSP Products Available. SuperCAD - schematic pgm. 99.00 Demo Pkg. - ( includes all 3 programs) 10.00 Call or write for more information DALANCO SPY PCBoards 89 Westland Avenue 2110 14th Ave. South, Birmingham, AL 35205 Rochester, N.Y. 14618 l -800-473-PCBS/ (205)933-l 122 (716) 473-3610 BBS / FAX (205) 933-2954 I

PRACTICAL ALGORITHMS Measuring Subjective

Charles P. Boegli Sound Levels

uccasionally the merit of an experimental paper “loudness of a sound numerically equal to the intensity stands uncontested for many years. Among such works is level in decibels of a lOCO-Hz pure tone which is judged by that of Fletcher and Munson [l], defining the sensitivity of listeners to be equally loud” [4], was the unit in which the human ear to tones of various frequencies. Their curves loudness levels were expressed. (Figure 1) were the foundation of all sound evaluation Obviously no linear filter can reproduce the ampli- work for more than a half century. They show that the tude sensitivity of the human ear. The proposed B-weight- sensitivity of the ear is reasonably linear with intensity ing filter (which used the 70-dB equal loudness contour above about 1000 Hz. Below that, however, the response is instead of the 40-dB) recognized this fact. The original nonlinear with intensity, dropping off more rapidly at suggestion was to use the A-weighting filter if only a single lower levels than at midfrequencies. filter were available. In more sophisticated instruments, This effect is familiar to audiophiles. When the level of the A-weighting filter was recommended for measure- music reproduction is below that of a live concert, the ments up to 55 dB, the B-filter for measurements from 55 “bass” control is advanced to restore satisfactory balance. to 85 dB, and a flat response for measurements of very loud The “treble” control, however, needs little or no adjust- sounds (85 to 140 dB). ment for variations in playback level. Since the epochal work of Fletcher and Munson, other Instruments were soon developed for measuring sound workers have modified and reinterpreted the curves. The and noise levels. The usual method for determining the ISO, for instance, wrote a standard 151 that presents curves subjective noise level at any location was to pass the signal somewhat different from those of Fletcher and Munson. from a calibrated microphone through a weighting filter to The difference lies principally in the region below 1000 Hz, convert the flat response of the microphone to the charac- where IS0 curves are much more linear with level than the teristics of the “av- Fletcher-Munson erage” human ear curves.

[21. The subjective h Examination sound level was 120 of the work in displayed on a sound and noise meter. 100 evaluationthatfol- For weighting lowed on the heels thecontributionsof of Fletcher and various frequen- Munson reveals a cies, the original continuing ten- recommendation dency toward lin- was to use a curve ear treatment of the corresponding to ear’s response, the inverse of the long after the need sensitivity of the for it has passed. human ear to a level I Thisarticle lays the of 40 decibels above basis for a com- a reference of lo-l6 puter algorithm watt/cm2 [3]. This that evaluates was the “A” sound levels with weighting filter. the nonlinear The “phon,” a unit Fletcher-Munson of loudness level relationships defined as the Figure 1 -The original Fletcher-Munson curves were developed in the early 1930s. rather than fixed curves, and investigates some of its effects. ations less than 20 dB/decade can be realized with some- asequences of this work are of particular inter- what more complex filters [7], but the frequency range rld of noise reduction. Automobile manufactur- over which the characteristic is maintained is restricted, mce,are interested in reducing noise within the the more so the smaller the attenuation rate. Maintaining :hicle. Reducing noise to inaudibility might an attenuation of, say, 10 dB/decade over a broad range of resent a positive danger to the driver by isolat- frequencies usually requires multisection filters. chologically from his control of the vehicle. On The A-weighting filter in current use combines two lnd, the duration of exposure during long trips independent 20-dB/decade high-pass sections, one hav- ngly for reducing cab noise at least to com- xuous levels. How the use of the linear A- rrve causes the expenditure of excessive effort endeavor will become evident later.

’ OF THE “AVERAGE” EAR ram to calculate the subjective effect of sound subjective loudness levels (phonsl to mea- sity levels (dB referred to 1tP watt/cm*) at luencies. Nonlinear relationships of this sort lied in two ways: either with a lookup table or on that represents the data with acceptable nlesslookup tablesoccupy a large space within

3r memory, multiple interpolations are often d I their use. Use of an expression is preferable FigureS- ‘Partial filter’ responses approximate the Fletcher- Munson ndpoints of speed and economy, and was the ches below loc0 Hz. choice in this article. admit to some bias in this matter. In 1953 I It above 1000 Hz, the Fletcher-Munson curves near with intensity. This being the case, their obtain the frequency response of the ear is The lower peak had a resonance at 3800 Hz )ing factor of 0.20 161.

ES BELOW 1000 HZ

IO0 Hz, the Fletcher-Munson curves show that sitivity is markedly nonlinear with intensity. example, a sine wave tone having an intensity B has a subjective loudness level of 100 phons. FflEGiJEMY CPS z intensity by less than 40 dB makes the sound udible (0 phons). At 100 Hz, the same reduc- Figure 3-Equations may be used to approximate the Fletcher- Munson curves. Lines are calculated while the dots are from lot have nearly as much effect; the subjective Fletcher-Munson. only be reduced to 40 phons. ated bass-response Fletcher-Munson curves it a point corresponding to (6Hz, 100db) with ns: the curves for loudnesses of 110 and 120 3 levels, corresponding to the sound gener- mer blows on a steel plate (or what amounts thing: a rock band) are not of very much und-reduction work. [Author’s Note: Sounds ities are perceived other than by the ears (they are ~closing theears, and areperceived by some people rsidered deaf). People who are exposed to such eal with them in unusual ways.1 The sensitivity lo-phon loudness level has a slope of -30 dB/ ? that for the 70-phon curve is -20 dB/decade. g filter with attenuation of 20 dB/decade is n since it uses a single R-C network. Attenu- Figure 4-Phon weighting factors. Curves are constant intensity.

October/November 199 I 95 ing a corner frequency at about 100 Hz and the other near high-pass filter with a comer frequency offi has a response 500 Hz. Thus, the response shows an attenuation of 6 dB/ described by octave from 500 to 100 Hz, and 12 dB/octave from 100 Hz down. This is the inverse of the 40-phon curve defined by ISO, not Fletcher and Munson. (We do not know whether the filter was designed to match that curve, or the curve to G (dB) = 10 logf2- 10 log(f: +f2) match the filter). Sensitivity curves may be viewed as the response of The frequency response of a cascade of one high- and one the ear to a constant-level input. To simulate that response below 1000 Hz requires filters with broad-band 03/21/91 ANhLYSIS OF RECORD SYNTHETIC-13 slopes that are not integer multiples ENTIRE RECORD: SELECTED RANGE: of 6 dB/octave. One approach is to NININUN FREQUENCY 15 CPS. NININUN FREQUENCY 15 CPS. introduce a “partial” filter that has NAXINUN FREQUENCY 16986 CPS. NAXINUN FREQUENCY 16986 CPS. no physical existence at this time, TOTAL LEVEL: 2579.0 'SONES IOfbL LEVEL: 2579.0 SONES but which serves for modeling. SPECIRUN OF CONPONENTS > 0 PHONS: The response of a low-pass filter 10 N with a comer frequency of& follows

the expression (x 1e ) “=& PHONS or, if the output is expressed in decibels, El 10 20 5a 1ebe 2&e 1eEiea~ 2eeee FREQUENCY CPS G (dB) = 10 log(fo)2 - 10 log(fa +f2)

Figure 5--The SOUNDCOM program generated a report for a distribution of Xl-& sounds wherefis the frequency. Similarly, a from 15 to 15,C00tiz.

THE $99.95 EDUCATION THE PRIMER MICROPROCESSOF TRAINING SYSTEM

TEACHES: l INTEL 8085 PROGRAMMING Debra Andersen Nanette Traetow

l DIGITAL 8 ANALOG INTERFACING 49 Walpole Street 242 East Ogden Avenue, l PROGRAMMING INTEL PERIPHERALS Norwood, MA 02062 Suite A ’ MICROCOMPUTER ASSEMBLY & DESIGN (617) 769-8950 Hinsdale, IL 60521 FEATURES: l ROM MONITOR OPERATING SYSTEM Fax: (617) 769-8982 (708) 789-3080 * 8 DIGIT, 7 SEGMENT, LED DISPLAY Fax: (708) 789-3082 l 20 KEY KEYPAD ’ DIGITAL INPUT PORT WITH DIPSWITCH ’ DIGITAL OUTPUT PORT WITH LEDs Barbara Best l ANALOG TO DIGITAL CONVERTER l DIGITAL TO ANALOG CONVERTER 569 River Road Barbara Jones l 14 BIT TIMER’COUNTER WITH SPEAKER Fair Haven, NJ 07704 & Shelley Rainey OPTIONS: l BASIC OR FORTH LANGUAGES IN ROM (908) 741-7744 3303 Harbor Blvd., * RS232 SERIAL PORT CONNECTS TO PC Fax: (908) 741-6823 Suite G-l 1 l BATTERY BACKED CLOCK AND RAM Costa Mesa, CA 92626 iMAC OFFERS A COMPLETE UNE OF MICROPROCESSOR TRAlNlNG ;YSTEMS STARTING AT $99.95 QUANTlTY 10 FOR THE PRIMER KIT. (714) 540-3554 Fax: (714) 540-7103 Christa Collins 7640 Farragut Street rC?lrlt. inc Hollywood, FL 33024 618-529-4525 FAX: 618-457-0; 1 Cl (305) 966-3939 P.O.BOX 2042 CARBONDALE, IL 62902 Fax: (305) 985-8457

96 CIRCUIT C_ELLAR INK 83/21/91 ANALYSIS OF RECORD SYNIHEIIC-7 The value of n can be found from ENTIRE RECORD: SELECTED RANGE: the fact that at frequencies well HINIHUI'l FREQUENCY 28 CPS. tlINItlUIl FREQUENCY 28 CPS. above f,, the response is 20n log NAXIHUll FREQUENCY 17288 CPS. l'lAXIfiUH FREQUENCY 17288 CPS. TOThL LEVEL: 265.8 SONES IOWL LE'JEL: 265.8 SONES Cf,lf,) below that at zero frequency. Having set the corner SPECTRUM OF COMPONENTS > 13 PHONS: frequencies, we use It3 G, n=---- PHOii log? (2)

whereG_isthegainatafrequency well abovef, . The response curves of a family of thesefilterswithf,at FREQUENCY CPS 6 Hz andf, at 400 Hz approximate the shapes of the Fletcher-Munson o- rrgure >lrnllar TO ngure 6. me somvare generated a report for a distribution of60-db sounds. curves below 1000 Hz, as Figure 2 shows. low-pass filter, both electrically independent, is thus ex- pressed by FREQUENCIES ABOVE 1000 HZ

Above 1000 Hz the response of the ear is much more linear with level than at low frequencies. The similarity of The notion of a partial filter is introduced by a factor n its response to that of a filter with a resonant frequency of which may have fractional values: 4000 Hz and a damping factor of 0.2 was previously noted [61. The Fletcher-Munson curves also show a second peak G(dB)=2Onlog(~)+lOnlog/~) (1) in the vicinity of 14,000 Hz. Attempts to simulate the response with cascaded filters have had limited success, and this by carefully adjusting the damping factors and resonant frequencies. Parallel filters were even less suc- cessful. A close approach to the ear’s high-frequency re- sponse may correspond to the principal resonances of a The Ciarcia diaphragm, which will not be attacked here. Design Works The response (by definition, the output for a unit input) of a single simply resonant filter in LaPlacian nota- Does your big-company marketing tion is department come up with more ideas than G(s) = (3) the engineering department can cope with? ?s+:ZTs+l Are you a small company that can’t afford a full-time engineering staff for Because of the separation of the resonant frequencies, the treatment of the two filters as independent, avoiding the once-in-a-while ideas? complexities of interaction, seems justified. Representing Steve Ciarcia and the Ciarcia Design the sensitivity of the ear then involves merely adding the Works staff may have the solution for you. contributions of each resonant filter to the expression for We have a team of accomplished programmers low-frequency response, remembering that the sensitivity and engineers ready to design products or solve (i.e., the input required for a unit output) is the inverse of tricky engineering problems. Need an optical speed equation (3). sensor, personnel tracking system, or 7axis drill For the first peak, T = 3.98 x U15 and Z = 0.3 gave a controller? The team has done it! slightly better fit than the values previously proposed. Whether you need an on-line solution for a unique When these constants are introduced, the phon contribu- problem, a product for a startup venture, or just plain tion of the first filter is experienced consulting, the Ciarcia Design Works P = 10 log[(3.9062 x lo-r5) f4-(1.025 x lO-7 f2 + 1 stands ready to work with you. Just send me a fax 1 I (4) discussing your problem and we’ll be in touch. A similar expression for the second peak is

Remember...8 Ciarcia design works! P = 10 10g[(1.0000 x lo-‘6) f4-(1.910 x 10-8) f2+ l] (5) Call GYl3) 875-2199 l Fax (203) 872-2204

98 ClRCUlT CELLAR INK 03/21/91 TOTAL SENSITIVITY ClNALYSIS OF RECORD SYNTHETIC-11 ENTIRE RECORD: SELECTED RANGE: The Fletcher-Munson curves HINIHUH FREQUENCY 15 CPS. flINItlUH FREQUENCY 15 CPS. are presumably represented by fl~XIf'lUli FREQUENCY 145 CPS. IIcIXItlUf'l FREQUENCY 145 CPS. TOTAL LEVEL : 92.0 SONES TOTfiL LEUEL: 92.0 SONES 100 dB plus the sum of expres- sions (11, (4), and (5). The quality SPECTRUM OF COllPONENTS > 0 PHONS: of the fit was checked by plotting 18 these sums at various phon levels with the help of a spreadsheet (x 10 PHONS program. Figure 3 shows the re- sulting curves, along with points selected from the Fletcher- Munson curves themselves. The fit is reasonably good in FREQUENCY CPS the region below 1000 Hz; an anomaly in the 80-phon curve is also visible in Figure 1. Above this Figure 7-A SOUND-generated report of u recording containing evenly distributed 80-db componenfs from 16 to ICO Hz. frequency the fit shows the effects of assuming linearity and also the previously mentioned quency curves should pass through a single point at the fact that the response at the 14,000-Hz peak is poorly upper limit of audibility. Within practical limits thismeans represented by a second resonant filter. I would assume, that curves in the high-frequency region should show however, that the determinations made by Fletcher and some tendency toward convergence, whereas the Fletcher- Munson also showed large variability in the very high- Munson curves are almost parallel. This is not to attack the and low-frequency regions because of differences in the determination they made, but rather to assess the practical limits of audibility of various persons. limits to the accuracy of their difficult work. Since most Presumably a given subject is incapable of gauging the noise-reduction work is concerned with lower frequen- loudness of tones he cannot hear; thus, all the high-fre- cies, the inaccuracy of fit should not have a severe effect.

PROFESSIONAL CIRCUIT DESIGN

QiCAD -Completely stand-alone or PC-dwen 8 ZIF Sockets for Fast Gang -Programs E(E)PROMs Programming and Easy * 1 Megabit of DRAM -User uwradable to 32 Megabit . 3/ 5” ZIF Sockets B-232 Save time and money! Pa;allel lo and Oui ’ .32K internal Flash EEPROM for eas” fIlmware upgrades - Ouick Pulse Algorithm (27256 QiCAD is a full-featured in 5 sec. 1 Megabit in 17 sec.1 * 2 year warranty printed circuit layout package . Made I” the U S A *Technical s”pport by phone that gives you everything you *Complete manual and schematic - Siooie Sockel Programmer also need to design circuit boards available. $550.00 quickly. *Spilt and Shuffle 16 & 3’2 bit -100 User Definable Macros. 10 User Definable Configurations . lntelllgent ldentlfler l ON-LINE HELP * Binary. Intel Hex. and Motorola S -2716 to 4 Meg&t l AUTOROUTER e POWERFUL EDITING New lntelllgent Averaging Algorithm Programs 64A r 10 sec. 256 III 1 mn 1 Meg (27010 011) l HPGUDMPL PLOTS I” 2 m,n 45 set 2 Meg (27C2001) I” 5 rmn Internal card with external 40 p,n ZIF l GERBER . Reads. Verlfles and programs 2716 32.32A. l POSTSCRIPT 64 64A. 128.128A 256.512.513 010.011.301 27CZOOl. MCM 68764 2532, 4 Meg&is l EXCELLON (DRILL) - Automatically sets mosramming voltage * Load and save buffer to disk l EGA / VGA compatibile *Binary. Intel Hex, and Motorola S formats -No aersonaliW modules rewired - 1 Year warranty -10 days money back guarantee complete price *Adapters available for 8748. 49 51, 751, 52. $195.00 55. TMS 7742.272iO.57C1024. and memorv cards I 4 601 South Maine Street . Made in U S A EMPDEMO EXE avallable BBS (916) 972-801 12 I NEEDHAM'SELECTRONICS CalI for more lnfarmatlon (702) 423-1654 FAX 4539 Orange Grave Ave * Sacramento. CA 95841 (916) 924-8037 (Monday way 8 am-5 pm PST, C.O.D. @@- FAX(916)9729960 eeader Service # 147 RecderSetice#l8.2 October/November 199 1 99 This having been said, it should neverthelessbe noted that digitization of the signal, or by subsequent digitization of extremely high-frequency tones, entirely unnoticed by an analog recording, this record is converted into one some people, often cause considerable distress to others, representing the intensity of the sound at the sampling and that workers in noise reduction should not overlook intervals. The sampling speed (samples/second) must be their importance. well above the highest frequency to be measured (cycles/ In Figure 4 the curves derived from the expressions second); if the well-known Shannon criterion is used the given here have been inverted and adjusted so that they factor is at least 2. show the weighting factors (in dB) at several intensity The record is then transformed (by well-known meth- levels. The weighting is the same for all frequencies above ods) into one relating intensity to frequency; that is, the about 1000 Hz; below that, the weighting varies depend- frequency spectrum of the sound. Expressions derived in ing on the intensity. this paper can then be used to convert the sound pressure of each component into phons. SOUND EVALUATION Phons are superficially similar to decibels in appear- ing to be logarithmic measures and are, in fact, identical in In practice, a calibrated microphone may be placed in magnitude at 1000 Hz. But the analogy cannot be pushed the location at which the sound is to be measured, and a too far. Sounds below about 0 phons at 1000 Hz are recording made for an interval of time. Either by direct inaudible and have no subjective effect, while sound pres- sures below 0 dB -Y (like volt- ages) definite physical quanti- ties. The fact that phon addi- 03/21/91 AMLYSIS OF RECORD SYNTHETIC-14 tion does not accurately repre- ENTIRE RECORD: SELECTED RANGE: sent the subjective level of a ?lINIIlUH FREQUENCY 15 CPS. NINIMUtl FREQUENCY 15 CPS. composite sound is recognized tlAXIllUtl FREQUENCY 145 CPS. rVlXI?WH FREQUENCY 145 CPS TOTAL LEVEL: 2.8 SONES TOTEIL LEVEL: 2.0 SONES inISORecommendationR131, which proposes the use of SPECTRUH OF COtlPONENTS > 0 PHONS: “sones” as a measurement of 5 subjective sound. The conver- II I I II sion equation 181 is as follows: (x 10 PHONS

inwhichSrepresentssonesand El P, phons. Presumably the sub- FREQUENC?CPS jective effect of a composite sound can be found by adding the sone contributions of the Figure b--similar to Figure 7. but with 60-db components. individual components. The extensive work that has been done in evaluating composite sound levels, however,appears 93~21/91 fWNALYSIS OF RECORD SYNTHETIC-IS to indicate that sone sum- ENTIRE RECORD: SELECTED RIINGE: mation is not the whole an- tlINIHUH FREQUENCY 15 CPS. HINIMJN FREQUENCY IS CPS. swer. llAXItlUfl FREQUENCY 145 CPS. WIXINUII FREQUENCY 145 CPS. The program SOUND. COM TOTAL LEVEL: .B SONES TOTAL LEVEL: .8 SONES (which operates under MS- DOS) computes thephon value SPECTRUH OF CONPONENIS > 8 PHONS: 5 of every frequency in an arbi- trary frequency spectrum, us- (x 1e 1 ing the nonlinear equations PHONS presented in the last section. It reads a simple ASCII record of up to 20,000 pairs of frequency- 0 intensity data points. The fre- 10 20 200 quencies are expressed in FREPUENC?CPS cycles per second and the in- tensities in decibels above UY’ watt/cm2; thetwonumbersare Figure 9-Similar to Figure 7. but with 50-db components, separated by a comma and each

100 ClRCUlT CELLAR INK pair of values is on a separate line in the record. The present version of the SOUND . COM program devotes the first four lines to header information. Synthetic records can be gen- erated with a competent word processor or a short pro- gram; that is the way they were made for testing this program. [Editor’s Note: Sofhoare for this article is available from the Circuit Cellar BBS and on Software On Disk #23. For downloading and ordering information, see page 105.1 The subjective contribution of each frequency present in a measured spectrum is calculated using the expres- sions derived in this article, converted into sones, and summed to obtain a quantity presumably proportional to the total subjective sound level. The output of the program is a printed graph showing the phon level of every fre- quency and intensity in the input record, together with the accumulated sones. SOUND also allows the user to examine a smaller range of frequencies more closely, and calculates the sone contribution of that part of the entire range. Figure 5 is the report generated by this program for a distribution of 90-dB sounds from 15 to 15,000 Hz, while Figure 6 is the same for 6@db sounds. The nonlinear response of the filter is quite evident. Applying this program to “synthetic” records shows immediately that a linear weighting factor not only wastes effort in reducing low-frequency sounds to which the ear is not sensitive, but fails to assess fully the importance of high-intensity low-frequency sounds. Figure 7is theanaly- sis printed by SOUND of a record containingevenlydistrib- uted 80db components from 16 to 100 Hz. Figures 8 and 9 are similar records for identical distributions of 60- and 50- db components. The poorer low-frequency sensitivity of the ear at lower levels evidently reduces the subjective sound levels more than correspondingly; at the lower

The BCC52 Computer/Controller is Micromint’s lottest selling stand-alone single-board microcom- Author’s Notes luter. Its cost-effective architecture needs only a K)wer supply and terminal to become a complete de- elopment or end-use system, programmable in fit lASlC or machine language. The BCC52 uses The of the Fletcher-Munson curves presented in Aicromint’s @X52-BASIC CMOS microprocessor this article permits development of a compact algo- which contains a ROM-resident BK- byte floating- boint BASIC-52 interpreter. rithm for converting sound pressures into phons, and The BCC52 contains sockets for ~JI to 48K does away with the need for fixed weighting curves bytes of RAM/EPROM, an “intelligent” 2764028 IPROM programmer, three parallel ports, a serial and decisions as to which one to use. A computer erminal port with auto baud rate selection, a serial jrinter port, and is bus-compatible with the full line of program was written to demonstrate its use. Because XX-bus expansion boards. BASIC-52’s full ffoating-point BASK: is fast and efficient of the numerous ways to sum contributions of sound mough for the most complicated tasks, while its cost-eflective design al!ows it IO be ;onsi&red for many new areas 01 implementation. It can be used both for development components, the program is not proposed as a final md end-use applicatiir% solution to the problem of sound evaluation. PROCESSOIl InpurfOurpur What has been shown, however, is fhat equip- ment ordinarily available in a competent testing labo- ratory, combined with a computer program, may do a betterjob of assessing sound than the manyspecial- ized instruments now on the market. Mr*ow I TEL (203) 871-6170 The notion of a “partial” filter will hopefully allow *expandable to 6% bytes FAX: {20%) 872-2204 *hve onhard sodte(s approaching other physiological phenomena than -up 10 lour 6264 (BKxB) static RAM TELEX: 64 3 3 3 1 *aIhe~ an BK 2764 Q 16X 271ZtJ EPROM sound. Responses of the human body to stimuli are si*qLr l&y. 100 oly* often nonlinear, which makes devising circuit analogs s109.00 5149.00 5294.00 5220.00 for them difficult. 5199.00 s159.00 $259.00 S189.00

Reader Service t- 1 lb See us al The Enrbedded Systems Conference Boolh X619 October/November 199 1 101 levels, some low-frequency components become inau- Charles Boegli is president of Randen Corporation in Blanchester, Ohio. dible. Low-frequency sounds being more difficult to at- l&den is a small company offering services in technical computer tenuate than high, the linear weighting curve can be re- programming and analog circuit design. sponsible for spending a lot of time reducing the intensities of sounds that are already inaudible! 4 IRS 428 Very Useful 429 Moderately Useful 430 Not Useful

REFERENCES AND NOTES

(1) Fletcher, H. and Munson, W. A.: ‘Loudness, its facturers. I believe the primary interest of those Definition, Measurement, and Calculation.’ J. people is in leading the market in developing Acoustical Society of American 5.2 (October new testing equipment. Whether the lineariza- 1933) p. 82 tion of the Fletcher-Munson curves may have (2) Powertrain Mounting Design Guide. GM Publica- been an accession to the makers of sound-level tion, October 1986 meters is a matter for conjecture. Certainly, (3) Langford-Smith. F. ‘Radiotron Designer’s Hand- nonlinear responses were difficult to build into the book,’ Fourth Edition. Harrison, N. J.: RCA Victor analog circuits in existence when that standard Division, Radio Corporation of America. April 1953 was written. p. 826ff. (6) Boegli, Charles: ‘Transient and Frequency Re- (41 King, A. J. et al: “An Objective Noise-meter Read- sponse in Audio Equipment.” Audio Engineering, ing in Phons for Sustained Noises,” with Special 38,2 (February 1954) p. 19ff. Reference to Engineering Plant. Jour. iEEE88, Part (7) Boegii, Charles: ‘Equalizer Design Chart. * in Markus. Ii (1941). p. 163 J. and Zeluff, V. Electronics for Communication (5) IS0 Recommendation 226. Within standards orga- Engineers. New York: McGraw-Hill Book Com- nlzations like ISO, the development of test meth- pany, 1952, p. 249. ods is usually handled by appointed committees (8) IS0 Recommendation R 131. thatincluderepresentativesofequipmentmanu-

YOUR WINDOW l Real Time Capture l RS-17OA Video Input 1 EMUIATION l US-170A Display Output l Dual Resolution PRODUCTIVITY l 256 Grey Levels l PC/Xl/AT Compatible n Easy to learn & use l Programmable Input LUT l Interrupt Capability Windowed interface -- l Fast Dual Port Video RAM l External Trigger Input l Easy Software Interface c 3 sec. typ. at 115KB l Complete Documentation a n Sourteleveldebua Introducing truly affordable, precision image capturin Tar eted for OEM ap lications where on board processing an dg/or co9 or are w A 4K frame trace buffer with advanced searching capabilities. not require c? Superior spatial accuracy, small board size, and price open up many applications. It features dual resolution of either n Hyperlinked On-line help guides you through the emulation process. 512 x 484, or four images of 256 x 242, both with 256 grey levels. n iceMASTER connects easily to our PC, requires no disassembly, or expansion Software support includes a menu driven control program, slots. Works on any PC (DOS or 0!/2), MicroChannel or EISA. Even loptops! ‘C ’ librar with source, TIFF files with LZW compression, and a novel RAilr disk emulator which provides DOS access to the n Supports more than 50 different 8051 family derivatives. M68HCll board’s images. as files! support will be available early in 1991. Simple yet flexible software interface saves development time. n Try iceMASTER risk free! Satisfaction Guaranteed or return for a full refund!* For example, all rows and columns are accessible wtthin a single RAM segment, allowing fast searches. n RENTALS AVAILABLE! Ideal for consultants and researchers! Custom board designs and software services are available. n Call today for free demo disk and ask about a free CORTEX-l OEM pricing : Quantities of 100 plus, $325. 8051 MatroAssembfer!(800) Call for brochure and specifications. 638-2423

OM~@ENATION CORPORATION

Specializing in Computer Vision Me&k Lqmlkn PO Box 1329 Chondkr, b 85244-l 329 PO Box 84568, Vancouver, WA 98684.0568 Phone 1602) 9260797 FAX 1602) 926-I 198 TELEX 4998050MllNK Telephone/FAX (206) 944.913i * Wnh 1 Odoy haul penad wxTI/IT regrrfered trademark af,nfe,mc,o”al Burlnerl Ma

Excerpts from fhe Circuif Cellar BBS Conducted by Ken Davidson The Circuit Cellar BBS 300/ 1200/2400 bps 24 hours/7 days a week (203) 8 7 1 - 1988 Four Incoming Lines Vernon, Connecticut

We’re real short on space this time, so we’ll keep it to just I guess you could make the oscillator fixed and use a program- mable digital divider chain, but do you really the precision? one real thread and a little snippet of one at the end. Event timing always seems to be on people’s minds and usually hastobedonewithaslittlepoweraspossible. Oneuserwho Msg#:24830 asked a basic question received replies detailing a number From: RICHARD KIMBALL To: ED NISLEY of different solutions. Thanks for the response. I’m kind of fixated on digital. I’ve messed with 555s before, even just to generate pulses for a Msg#:24766 counter, but for this application I want something that either 1) From: RICHARD KIMBALL To: ALL USERS programs similar to a digital watch, or 2) programs via DIP switch or even EPROM (since I have a programmer). I’m looking for a VERY low-current 5-volt programmable digital timer which can be set for l-65536 seconds or minutes and which is self-resetting. The application is a remote (outdoors) unat- Msg#:24858 tended intervalometer for time-lapse photography. The alarm From: ERIC BOHLMAN To: RICHARD KIMBALL output must be capable of driving a low-current relay or equiva- lent device for turning on a shutter-release solenoid. If having to set the time in binary isn’t a problem, you could use something like the Intersil 7240, which is an astable combined I’ve considered numerous microprocessor and microcontroller with an 8-stage counter (you’d have to chain two of them to get scenarios and have developed some nice enhancements, but the the resolution you want). The counter stages have open-drain power requirements are too quick to drain my batteries. outputs, so you can wire-AND them via DIP switches; just tie the common of the switches to the reset line on the chip. Also, I wonder what effect the seasonal temperature extremes might have on the device. Around here we’re talking typically 20 As far as low temperatures are concerned, I think your main degrees in winter to 8.5 degrees in summer. problem would be keeping the batteries alive.

Any ideas would be most welcome. If the device exists, I’d love to know where to get it. Msg#:24876 From: RICHARD KIMBALL To: ERIC BOHLMAN

Msg#:24815 Thanks, Eric. Your idea is worth looking into. Where can I get the From: ED NISLEY To: RICHARD KIMBALL Intersil part and data sheet? I’m pretty sure DIP switches would be OK. Eventually I’d like to refine it with some kind of multi- Why digital? mode LCD display which could show interval, elapsed time units in current interval, and number of intervals expired. But, If you want real low current, how about a CMOS 555 timer? It’s hey, I’m just shooting a shutter, right? got good output drive, low standby current, and reasonable temperature stability. Msg#:24898 The only catch is that big caps tend to have nasty temperature From: ERIC BOHLMAN To: RICHARD KIMBALL stability. You could run it at a higher frequency, use a smaller (better) cap, and divide the output by a few orders of magnitude Mostofthesmall-quantitymail-orderdistributorscarrythe7240. in a fixed digital chain. There goes your current again, but you Some of them may be able to supply data sheets; otherwise find can use CMOS counters and get most of the benefit. Put a FET your local Intersil distributor (last time I checked, Intersil was driver on the output and you’re off and running. part of GE, but that may have changed) and ask for their databook.

October/November 199 i 103 MsgWz24895 chip to various devices. Give me an address and I’ll send you the From: FRANK KUECHMANN To: RICHARD KIMBALL data on the chip.

If you don’t mind piecing a few chips together, you could use an OKI MSM5832RS clock chip in “interrupt” mode (AO-A3 = 1). Dl Msg#:24953 would output a l-Hz signal, D2 a l/60-Hz. Chain two dual 4-bit From: RICHARD KIMBALL To: FRANK KUECHMANN binary counters for the 045535 unit count. Set the interval desired by driving magnitude comparators with the counters; Thanks once again, Frank. You know, I’ve been mulling this hex-readout thumbwheel switches set thedesired interval. When thing for well over a year, all the time having Circuit Cellar BBS the mag camps output the “=” level, it resets the counters and phone number posted on my PC. I’ve talked to the few engineer triggers something to actuate your shutter. Use4OOO-seriesCMOS friends I have and ended up basically feeling out of luck. This is at 5 volts and you’ve got very low drain (essentially leakage GREAT. current except for the 5832).

Msg#:24977 Msg#:24928 From: FRANK KUECHMANN To: RICHARD KIMBALL From: RICHARD KIMBALL To: FRANK KUECHMANN Some further info: Exar makes at least one “programmable” Where can I learn more about the OKI MSM5832RS? Didn’t timer/counter you might lookat. Howard Sams publishes abook Radio Shack have that in their inventory at one time? Seems like called ‘The ICTimer Cookbook” (Jung is theauthor, I think) with I’ve seen it somewhere. Maybe Jameco? lots of useful info.

Msg#:24941 Msg#:24915 From: FRANK KUECHMANN To: RICHARD KIMBALL From: STEVE CIARCIA To: RICHARD KIMBALL

Places like Digi-Key have had it in the past, but prices are lower Why not just use a whole RTC31 or RTC52 as a timer. Considering at outfits like B.G. Micro in Dallas, Texas. Jameco currently has it has an II-MHz crystal, it can be very accurate. Also, the RTC52 the Saronix 58321 variant of the 58321 (OKI), but the ‘321 has BASIC includes a real-time clock command that can be triggered muxed address/data lines that complicate things. I have the full on interrupt, and could easily give time lapse, interval, history, OK1 MSM5832RS data, plus a lot of experience interfacing the and so on in just a few program lines.

Complete 16MHz 8OC286 Single Board Computer for embedded PC appli- ncluded cations features a 4M-byte PROMDISK disk emulator with battery back-up and an MS-DOS 3.3 compatible disk oper- - 100MHz sampling rate(12 channel) \ j - 24 Channels(50 MHz), Timing and state ating system in ROM. - 2K samples/channel( 12 Channel mode) * 24 Bt trigger word Y# Features Include: * TTL threshold level - Internal and External Clocks 2 4M-byte DRAM Q Xl Size Board - Menu driven software 3 Keyboard Port Q 80287 Socket - FREE software updates on BBS Zt2COM, 1 LF’T Cl WatchDog - More sophlstlcated units also avallable 2 IDE Disk Port Timer 14M PROMDISK Q Floppy Port 1 100% PC/AT Q Optional Video Compatible Daughter Bd. Other Products: l IND-88 PC/XT Single Board Computers l PROMDISK III & IV Disk Emulators l EPROM/RAM Memory Board l FLASHDISK Driver for Micro Soft FFS l FlexScan I & II Bar Code Decoders - 20 and 24 pin PALs, EPLDs * Byle SpliVMerge(l6 8 32 bfl) l Custom PC Compatible Hardware & Software - 16V6 ,2OV6 ,22VlO GALs - JEDEC, INTEL HEX, Motorola’s’ files - 2716-27020 EPROMs - Dallas NVS RAM programmlng * 67xxx MlCROs - PC/XT/AT COMPATIBLE - EEPROMs(incl. 6 pin serial) * FREE software updates on BBS Call- (201)808-8990 2598-g fortune wdy vista, ca 92083 Link Computer Graphics, Inc. phone: 6 19/598-2 177 fax: 6 19/598-2450 369 Passaic Rd., Suite 100, Fairfield, NJ 07004 FAX (201) 61388786 Reader wvice X161 RecderServke #162 See us at The Embedded Systems Conference Booth #921 104 CIRCUIJ CELLAR INK MS@:24927 about 150 feet of cable. Any feedback on this would be appreci- From: RICHARD KIMBALL To: STEVE CIARCIA ated.

How about current consumption, Steve? I’m trying to put some- thing together to function in the bush over a several-month Msg#:25975 period. I’d considered the 8031/52 route, but the specter of From: KEN DAVIDSON To: PHIL ROBERTS battery depletion prevented any serious evaluation. The R5422 spec states that you should be able to go up to 4000 feet using 24-gauge wire at data rates under 100 kbps. Your 150 MsgX:24950 feet shouldn’t present any problems (that’s the reason why we’ve From: STEVE CIARCIA To: RICHARD KIMBALL been supporting RS-422/485 on all our new processor boards).

Remember, the 8OC52-BASIC chip is CMOS. If you remove the 75176 (RS485 driver) chip, the RTC typically pulls about 15-20 mA. If you reduce the need for RS-232 communication and can remove the MAX232, it drops to about 8-10 mA. Then, if you The Circuit Cellar BBS runs on a IO-MHz Micromint reduce the crystal frequency, it starts dropping dramatically. I OEM-286 IBM PC/AT-compatible computer using the actually got one board down to 2 mA while still running a BASIC multiline version of The Bread Board System (TBBS program. 2.1M) and currently has four modems connected. We invite you to call and exchange ideas with other Circuit Msg#:24954 Cellar readers. It is available 24 hours a day and can be From: RICHARD KIMBALL To: STEVE CIARCIA reached at (203) 871-l 988. Set your modem for8 data bits, 2 stop bit, and either 300,1200, or 2400 bps. Hey, that ain’t so bad! I’m counting my pennies and thinking about how I can short change my six-year-old this Christmas. Thanks again. IRS 431 Very Useful 432 Moderately Useful 433 Not Useful One of the biggest advantages of RS422 is its long- distance capability using simple twisted pair wiring, as we see here.

Msg#:25952 From: PHIL ROBERTS To: ALL USERS

Can somebody advise on the spec for cable lengths using RS-485 or RS-422. I have an application which involves mounting a piece of RF hardware as close to its antenna as possible. The unit is presently using a BCC52 to format its nonstandard output to RS 232and feed a computer. I’m looking at needing to drive through $95 EPROM SOFTWARE and BBS AVAILABLE on DISK Software on Disk PROGRAMMER Software for the articles in this issue of Circuit Cellar INK may be downloaded free -PLUGS INTO PRINTER PORT of charge from the Circuit Cellar BBS For those unable to download files, they are -00 ROMS FOR SBC cm MVOISK also available on one 36OK, 5.25” IBM PC-format disk for only $12. -PROGRAM 2764,270,0 EPROMS

~ Circuil Cellar BBS on Disk Every month, hundreds of information-filled messages are posted on the Circuit Cellar BBS by people from all walks of life. For those who can’t log on as often as they’d like, the text of the public message areas is available on disk in two-month installments. Each installment comes on three 360K, 5.25” IBM PC-format disks and costs just $15. The installment for this issue of INK (OctoberNovember 1991) includes all public messages posted during July and August, 1991, ToordereitherSoftwareonDiskorCircuitCellar BBSon Disk,sendcheckormoney order to: Circuit Cellar INK - Software (or BBS) on Disk P.O. Box 772, Vernon, CT 06066 pr use your MasterCard or Visa and call (203) 875-2199. Be sure to specify the II Issue number of each disk you order. Please add $3 for shipping outside the U.S. II

Recdersetie#170

October/November 199 1 105 STEVE’S OWN INK The Circuit (Storm) Cellar 1 Steve Ciarcla

1 here’s a funny thing about New Englanders and Hurri- Let’s see, I’ve pulled out some extra tarps: three 5’ x 7, two canes. For most of the year we sit around fearing that the next 9’x12’,a17’x29’,anda27’x39’.I’vechargedthreeextra12-V100- hurricane will blow us off the face of the earth, yet at the same AH batteries for the pump, eight 12-V 6.5AH batteries for the time we are thoroughly disappointed when a hurricane happens radios and TVs, and made sure the Circuit Cellar automatic low- to choose someone else as the target of opportunity. After all, voltage lighting system is ready. There are the rechargeable why go through all the preparations and not have the satisfaction flashlights (7), the regular flashlights (6) and a box of two dozen of a good story to tell afterwards. D-cells, the car cigarette-lighter-type fluorescent lights (31, and All New Englanders haveanindigenous yearning to survive two 12-V portable power packs (just in case). After all, there’s a through a particularly devastating hurricane and then narrate, hurricane coming.. . with particular exaggeration, all the details to future generations Let’s see, the AM/FM radio and a shortwave unit are ready of friends and relatives. “Boy, you should have been around back but, wait, what about a TV? The two sets operating behind me are in 1954. We had Carol on August 31, Edna on September 11, and 115-V units. I don’t want to have to start the generator to use then Hazel on October 15! It took six months to dry out, and was them. Better go do an inventory of battery-operated stuff. the worst...” I guess I must never throw anything out. I was amazed at Right now I’m sitting in the Circuit Cellar waiting for Hur- what was on the shelves of the Circuit Cellar. There were nine ricane Bob to zero in on me. I’m using a UPSbacked computer so battery-operated TV sets, ranging from 1”-6” B&W and color I don‘t have to rewrite this whole thing after the crash. Even with conventional TVs to the latest 3” and 4” color LCD units. Unfor- the rather regular power glitches starting to occur, I’ve still got tunately, no one ever discussed hurricanes with the designers or one TV on a local station and another on the cable Weather each wouldn’t have had such varied operating voltages and Channel. According to the latest reports, Bob’s headed straight unique connector configurations. The lowest-power LCD units for the Rhode Island/Connecticut border. Unfortunately, my had the weirdest connectors and operated at voltages like 9.8 V house is 40 miles from Rhode Island on a hill surrounded by or 10 V. The largest conventional color TV had a readily available potentially brittle trees. connector and ran on 12 V but would have consumed a whole Actually, I’m probably more prepared than most people to battery between commercials. make it through natural disasters, but I equivocate over terminol- Here was the first obstacle and the storm was only an hour ogy like “survivalist” in any descriptions. I’ve already checked away. Warm up the soldering iron, quick. Do I settle on a 1” 6-V the propane-powered backup generator. It’s one of those big Panasonic unit and get a magnifying glass; whip up a quick 12- two-cylinder jobs that’s supposed to do the whole house. Given V LM317-based adjustable regulator with assorted universal all the electrical goodies around here, however, I have to shed output connectors and polarity reversers; swipe one of the ma- some of the big loads when I start it. It takes care of the essentials, rine batteries from the pump and put it on the 12-V color TV but if it has any problems I can drag the other big Honda anyway; or, just drag over the Honda and leave the projection TV generator over from the garage, or use the ET0 generator on the on and forget all this battery crap? Maybe we should do both (just tractor. Or, I suppose I could attach one of the 200-W UP!% to a 12- in case). After all, there’s a hurricane coming.. . V battery. You know, now that I think of it, the power has only !30 here I am sitting among the tarps, lanterns, propane, been out for three hours in the past 11 years. But, them’s a emergency supplies, TVs and radios, backup this and backup hurricane coming.. . that, waiting for Armageddon. The wind is blowing about 40-50 Let’s see, I’ve brought the propane lanterns over, an extra 20- MPH; the rain is pelting hard against my mostly glass house; the lb tank, checked the chain saw, and mixed an extragallon of two- darkness outside has switched on all the outside lights; and the cycle gas. We have one of those 9600-gallon-per-hour 4 HP video monitor down in the Circuit Cellar is showing me a new pumps (just in case) and about 100 feet of 2-inch hose, but I’ll wait river channel between the house and garage. All I can say after all for the flood before dragging that out. Then again, we also have this is it better be a damn good hurricane. a smaller 1.5-HP gas pump (1150 GPH), three l/5-HP pumps, and a special 12-V high-volume electric pump too (just in case). Remember, there’s a hurricane coming.. .

112 ClRCUlT CELLAR INK