1 EDITOR’S I’ve Seen the Future INK Curtis Franklin, Jr. 1

I recently led a panel discussion at the Embedded Systems 32-BIT PROCESSORS Programming Conference. I met interesting people, arranged for a few articles, and ran into lots of folks who were carrying crystal There weren’t many people talking about 8-bit processors at balls in their fanny packs. I thought you might like to know what the show. Intel mentioned the 8051, saying that they have now they say you’re going to be doing in the next few years... shipped over 100,000,000 of them, but that came as a passing statement at their press conference announcing the latest mem- OPERATING SYSTEMS bers of the 80960 family. Motorola was ready and willing to talk about 68030 and 88000 applications, National was discussing the You’re going to be using an operating system. I’m not talking 32000, and everyone was announcing the arrival of the 32-bit about the operating system on your , but the future. Once in a while I heard talk about 16-bit chips like the complete multitasking operating system that you’ll be building 80186 and 8096, but there was a noticeable absence of discussion into each and every control project. Depending on who you talk on anything having to do with 8-bit applications. to, you’ll be using an MS-DOS variant, a UNIX variant, or a All of the predictions I’ve talked about are fine and probably specialized embedded 0s for your development. All of these will true if you are involved in building avionics for the B-2 or make your life easier, your software more powerful, and your automating a nuclear power plant. If, on the other hand, you’re breath fresher. They may be right, but I’m not fully convinced. working on building automation, data logging, or day-today First, an operating system assumes that you can accept a process control, 32-bit processors and million-line applications hefty chunk of overhead in your software. Anyone who’s still running under UNIX may be a bit of overkill. forcing their code into 8K EPROMs will be in special trouble, but there will be more about that a little farther down the page. Most CIRCUIT CELLAR INK folks at the show weren’t worried about memory constraint, and they weren’t terribly worried about the cost the OS adds to the So what are we going to do? We’re going to renew our project. I’ve seen prices ranging from $99 for Coherent (a UNIX- commitment to 8-and 16-bit applications, with a special empha- like OS) to $3,000+ for some of the specialized embedded prod- sis on stretching the limits of the possible with 8-bit processors. ucts. It’s a different type of overhead, but substantial overhead There are new g-bit processors coming onto the market, and we increase all the same. Finally, an operating system adds another will let you know about them. If you need more power, there is level of complexity to any debugging exercise. You can’t just alot of activity in 16-bit processors, and we’ll keep you up-todate worry about how your software is interacting with the hardware, there. Operating systems will play a part in both 8- and 16-bit you have to consider how the passions in the hardware-OS- applications, as will high-level languages, so we’ll look at how application software triangle are affecting one another. The time both can affect the project you work on. Finally, we’ll remember involved is still more overhead that must be absorbed by the that one of the reasons most of you read C IRCUIT CELLAR INK is project. All of this overhead is starting to add up, unless you’re that we take “the road less traveled” in our approach to applica- writing a truly large application. tions. We’re going to be going a little farther down those less- traveled paths in upcoming issues. LARGE APPLICATIONS A NOTE You know the 8K EPROM I mentioned in the last section? Well you can forget putting code into it. You’re going to be Scott Ladd’s “Practical Algorithms” is taking a one-issue va- writing embedded software that needs 500,000-l,OOO,OOO lines of cation. It will be back in CIRCUIT CELLAR INK #19. code. Stop for a moment and let that sink in. Are you still with me? If you’re going to spend the time, money, and effort to develop a million lines of embedded code, the overhead of an operating system gets lost in the background noise. Furthermore, I’m willing to say that, if you have a million- line program, you need an operating system to support your code. You also need a high-level language, heavy-duty libraries and support programs, and a debugger that will work with you in a most intimate fashion. Oh yes, you also need a processor that will let you get to that much code.

December ‘90/January ‘9 1 1 FOUNDER/ EDITORIAL DIRECTOR Steve Ciarcia PUBLISHER Daniel Rodrigues THE COMPUTER EDITOR-in-CHIEF Curtis Franklin, Jr. APPLICATIONS MANAGING JOURNAL EDITOR Ken Davidson PUBLISHING CONSULTANT John Hayes ENGINEERING STAFF Jeff Bach/o&i ONDI-The ON-Line Device Interface, Part 2 Edward Nisley 12 Software for Remote PC Control CONTRIBUTING 0 by John Dybowski EDITORS A complete computer remote-control system wraps up with a look at Thomas Cantrell the software for remote control, operation, and display. Christopher Ciarcia NEW PRODUCTS Principles of PC-based Data Acquisition and EDITOR Control Systems Harv Weiner 018 by Chris Ciarcia CONSULTING Writing control software can’t start until you understand the problems. EDITORS A lesson in control theory can save you hours in wasted design time. Mark Dahmke Larry Loeb An Interface for Portable Battery-Backed RA CIRCULATION Using the Mitsubishi BEE Card for Non- COORDINATOR volatile Data Storage Rose Manse/la by Tim McDonough & Bruce Webb CIRCULATION “Credit card” memory offers non- CONSULTANT volatile storage in a portable package. Gregory Spiizfuden Interfacing to Mitsubishi’s version couldn’t be simpler, ART & PRODUCTION DIRECTOR Tricia Dziedzinski

PRODUCTION A Venerable History and a ARTIST/ILLUSTRATOR Lisa Ferry Certain Future by Steve Ciarcia & Burt Brown BUSINESS Motorola’s 68HCll is a powerful 8-bit MANAGER processor. It’s a perfect choice for a Jeannette Walters compact controller. ADVERTISING COORDINATOR Dan Gorsky

STAFF RESEARCHERS Designing with Flash Memory Northeast Eric Alberf Is There a New Alternative to EEPROM and SRAM? William Cuf/ew by Markus A. Levy Richard Sawyer Flash memory is the lat Robert Stek nonvolatile storage. Midwest Jon E/son A PC-bus design illus- 7im McDonough trates techniques for West Coast interfacing and Frank Kuechmann programming. Mark Voorhees

Cover Illustration by Robert Tinney

2 ClRCUlT CELLAR INK Circuit Cellar BBS-24 Hrs. 300/l 200/2400 bps, 8 bits, no parity, 1 stop bit, (203) 871. Editor’s INK 1988. 1 I’ve Seen the Future by Curtis Franklin, Jr. The schematics provided cl in Circuit Cellar INK are The times are a’changing...and so is our industry. A recent industry drawn using Schema from conference provided a (murky) crystal ball for your editor. Omation Inc. All programs and schematics in Circuit Cellar INK have been care- fully reviewed to ensure that their performance is in ac- Reader’s INK-Letters to the Editor cordance with the specifi- cations described, and pro- 141 gramsarepostedon theCir- cuit Cellar BBS for electronic MWroductNews transfer by subscribers. Circuit Cellar INK makes no warranties and assumes 811 no responsibility or liability of any kind for errors in these Firmware Furnace programs or schematics or ANSI Controls and Fixed Points for the consequences of any 61 The Furnace Firmware Project Continues such errors Furthermore, be- 7 cause of the possible vari- by Ed Nisley ation in the quality and con- The fine points of getting the right results and showing them to the ditionof materialsand work- user are the heart of this installment. manship of reader-as- sembled projects, Circuit Cellar INK disclaims any re- sponsiblity for the s&e and proper function of reoder- From the Bench assembled projects based Magnetic Levitation: An Example in Closed-Loop Control upon or from plans, descrip- 71 tions, or information pub cl How to Defy Gravity Without the Use of Black Magic lished in Circuit Cellar INK. by Jett Bachiochi Closing the loop with a floating ball can teach you a lot about how CIRCUITCELLAR INK (ISSN 08968985) is published bi- a control system works. monthly by Circuit Cellar In- corporated, 4 Park Street, Suite 20, Vernon, CT 06066 (203) 875-2751. Second- Silicon Update class postage paid at Ver- non, CT and additional of- Goodbye CRT, Hello LCD fices. One-year (6 issues) by Tom Cantrell subscription rate U.S.A. and New LCD devices and controllers make LCD a more viable choice passessionsS14.95.Canoda/ Mexico S17.95. all other than ever before for demanding display applications. countries $26.95 (surface), $38.95 (air). All subscription orders payable in U.S. funds only, via international postal ConnecTime-Excerpts from the Circuit Cellar BBS money order or check drawn on U.S. bank. Direct Conducted by Ken Davidson subscription orders to Circuit CellarINK.Suhcn’piions.P.0. Box 3050-C. Southeastern, PA 19398 or call (215) 630- Steve’s Own INK 1914. POSTMASTER: Please The Whole Job sendaddresschangestocir- by Steve Ciarcta cuit Cellar INK, Circulation Dept.. P.O. Box 3050-C. Engineering doesn’t end when the solder cools. Steve talks about Southeastern, PA 19398. the rest of the job. Entire contents copyright 0 1990 by Circuit Cellar In- corporated. All rights re- served. Repfoductionofthis publication in whole or in Advertiser’s Index partwithoutwrittenconsent from Circuit Cellar Inc. is prohibited.

December ‘90/January ‘9 I 3 READER’S INK Letters to the Editor 1

MILDEW REDUX only logical thing to do was to modify the return address on the stack. I wrote to you last year concerning the problem of This method, while very practical, would probably be mildew attacking diskettes which have been stored for six frowned upon by those adhering to strict structural tech- months or more in a tropical climate without air-condi- niques, especially those who develop software for military tioning. In your published reply (CIRCIJ~ CELLAR INK #ll), applications (per standards like DOD-STD-2167). How- you could not offer a remedy but asked that we write back ever, if it is viewed as a form of exception handling, then it if we found a solution. Well, it does seem that we have would probably be considered “respectable.” solved the problem since nearly a year has passed and we I’m not sure, however, that this method helps “dis- have not had a recurrence. The solution found was neither cover where your code has been,” as your subtitle to the the use of desiccators nor of fungicides but the use of a article suggests, but rather, it “changes where your code is cupboard kept a few degrees above room temperature. going to.” This remedy was suggested by a friend who said it was used by photographers to store stocks of film and keep Kenneth J. Ciszewski them freeof mildew. It seems to work for diskettes as well, Overland, MO with no bad sideeffects. Thecupboard is warmed by a bulb of about 10 W (I use either a 60-W 240-V bulb at 120 V or two 25-W bulbs in series as I could not get a 10-W bulb). I suspect that others living in humid climates may LEG0 CONTROL have this problembut without recognizing it. If you exam- ine the surface of your disks (especially back-up copies) in I’d like to comment on the letter “Keep those Legos reflected light, mildew appears as light blotches-it is Moving” in CIRCUIT CELLAR INK #16. The little motor driver difficult to see otherwise. Frequent use keeps it at bay for circuit that was described is essentially available as Spra- some time, but may eventually lead to disk errors. Con- gue UDN-2952B or UDN-2952W full-wave bridge motor tinuous air-conditioning no doubt also prevents mildew. drivers. They are available from Circuit Specialists, Mesa, Arizona. They are capable of 3.5 A of output current and Andrew Mancey feature thermal protection. They require a 5-V and a motor Guyana, South America power supply. Typically, the control signals are a DIREC- TION and a NOT ENABLE line. The use of a NOT EN- ABLE line prevents the motors from running when the control lines are disconnected. Remember that TTL inputs BACK TO THE COMEFROM float high. It isalso possible to drive the NOT ENABLE line with a PWM signal to allow speed/torque independence. The article by J. Conrad Hubert entitled “Implement- I have successfully used these to control some small ing a ComeFrom Statement” (CIRCUIT CELLAR INK #15) DC motors. DC motors have an overrun problem when brought back memories of a project I led in 1980 to develop stopped. In order to minimize this, I added a relay and a microcomputerized controller for the paging system at some logic which would short the motor winding when Lambert St. Louis International Airport. We wanted to stopped. This provides very quick dynamic breaking. The trigger the interrupts of a 6502 (part of an motor is acting as a generator into a short circuit and AIM-65 board) from a sanity timer to restart the system in therefore stops rather rapidly. case the processor got off track and wasn’t executing properly. We had the same problem: Once we got the Ron Dozier microprocessor’s attention, how would we get it to go back Wilmington, DE to restart instead of back to where it left off when the interrupt occurred, without causing stack problems? The

4 ClRCLJlT CELLAR INK ON ANOTHER LEVEL It would be nice to get some help. Of course, for you to run “tutorials” might alienate some of your other subscrib- I have been “into computing” for quite a few years ers for the same reason I have gotten tired of some of the now: My first computer job was in 1957, preparing data for other computer magazines that seemed to run yet another the IBM computer operated by Hughes Tool in Houston. I “Getting started in BASIC” (or assembler, or C, or.. .) worked on mainframes (IBM 7094s, 36Os, 37Os, and article every 18-24 months. HW2OOOs) for several years, while wanting a computer of I wonder if the information I am looking for can be my own. I finally managed to “graduate” to micros in 1981 found in the books of Ciarcia’s Circuit Cellar articles, or when my boss got me an Apple II+ (at last, a computer of whether I should get some other (more theoretical?) books “my own”). and try a few projects (like Don Lancaster’s “Cookbooks” I have been mostly a software person for many years perhaps)? Any adviceand direction you can provide would (application and systems programmer and systems ana- be appreciated. lyst, currently teaching programming at a community college), but I have occasionally messed around with elec- Richard P. Winslow tronics (yes, I know my way around a soldering iron&my Riverton, NY call sign is KA7PHM. I subscribed to CIRCUT CELLAR INK because I hoped to When C~RCUZT CELLAR INK was started, we discussed the find a place that would give some tutorials on computer idea of presenting articles for computer novices. We decided that circuit design-such as how to go about putting together there was no way to do that without “watering down” the a computer “from scratch”-you know, what chips are content for our core of readers: experienced engineers and pro- needed, what ones go together, what the significance of grammers. Wedo print tutorials, but they’re&signed to “teach microprocessor timing diagrams is, how to interface to 0ia dogs Ned trick.g and not to give folks an elementary memory (and get the RAS and CAS signals timed right), education. and so forth. In short, I need help to get me going (with There are many books that contain the sort of information some assurance) in hardware. you’re looking@. Ciarcia’s Circuit Cellar, Volumes 1-7; Don What I have in mind is to learn enough to try to design Lancaster’s Cookbooks;and any number of titles from Tab Books a microcomputer I have wanted to build for several years canget youstarted down the road tomicrocomputerand control- now, so I can try my hand at writing the system software ler design. Good Luck! for it, and.. .(the stuff dreams are made of, you know!)

A DIVISION OF MING E&P. INC.

1. Exclusive items at good prices. 2. Unique items at better prices. 3. Popular items at the best prices. I-800-669-4406 (ORDER DESK ONLY) 1. Prices are subject to change without notice. 2. VISA, MASER CARD and COD(add $3) accepted. * Tiny size, only 1” X 1.5”, powered by 12VDC. 3. Freight charge adds $5 UPS * 4 Mb DRAM, up to 2 minutes recording time. * 4096 possible codes. 100-200’ line-of-sight distance Ground, $8 UPS Blue, $15 * 16 variable-length messages each w/ direct trigger

* Small size, 1.25” X 2.75”, powered by SVDC. * Single channel RF receiver. 977 S. Meridian Ave. Alhambra, CA 91803 * Same as RI%-01, except it’s a multi-channel RF TEL: (818) 281-4065 FAX: (818) 576-8748 * 8 bit address codes, 4 bit data codes. RC-01 Combination of TX-88 & RE-01 $29.95

December ‘9WJanuary ‘9 1 5 PHONE WIRE IAN ONE FOR MODULA-2

I was reading through CIRCUIT CELLAR INK #17 when I This letter is about the choice of language for Scott ran across “Low-Cost LAN using X-10 Technology” in the Ladd’s column on Practical Algorithms, and responds to ConnecTime section. Mr. Don Lasley’s letter to the editor in &curr CELLAR INK There is an excellent base for a low-cost home LAN 407. Please enter my vote for Modula-2 as the choice for using the existing telephone wire. Each jack has an IW algorithm exposition. (inside wire) feeding it. The IW is either a 2-or 3-pair cable. C is not more powerful than Modula-2-anything, The phones only require a single pair (red/green), leaving including bit-twiddling, that can be done in C can be done the yellow/black pair available for a low cost 2-wire LAN. in Modula-2. Of course, you have to know Modula-2 as Most homes do not have the second telephone line in- well as you know C in order to be able to do the same things stalled, so all that is required is that the yellow/black pair equally easily. Mr. I_asley can’t complain that the language be disconnected from the jack used by a telephone. This is he hasn’t bothered to learn, is clumsier or harder to use required since many phones use the yellow/black pair for than the language he’s used extensively. switch hook signaling (A and Al leads). I have used this As a principal engineer performing quality control for second pair for quite some time with no major problems. a major consulting engineering company, I review work The average home hasbeen prewired with five jacks, so the by a large number of engineers and analysts. Based on this odds are pretty good that there is one near the PC or exposure, my conclusion is that there is no doubt that, desired location at this time. while C is great for quick-and-dirty hacks, nobody, includ- I have a suggestion to make so that the LAN can be ing the programmer, should expect to go back later and used by more than one device: Transmit the data on a understand what was done. Programs written in Pascal, single wire (yellow) using the last wire (black) as a circuit and especially Modula-2, on the other hand, tend to be busy wire. This way, when you have multiple devices clearer and better organized, making them easier and connected they will not access the data line at the same faster to review and verify. They are also more likely to time. produce reusable code.

Don Houdek Stephen R. Troy Spring Grove, IL Severna Park, MD

P-C-B ARlWORK MADE EASY ! Create Printed Circuit Attworkon your IBM or Compatible * MENU DRIVEN * HELP SCREENS *ADVANCED FEATURES * EXTREMELY USER FRIENDLY E)G31 controller board assembled without EPROM $129.00 *AUTO GROUND PLANES C:ontroller KIT DG31 K: PC board and all components except * 1X and 2X PRINTER ARTWORK screw terminals, RAM and EPROM $70.00 * 1X HP LaserJet ARTWORK

EiPROM 27C128 CMOS programmed with TILE firmware * HP and HI PLOTTER DRIVER optional 49.00 (Programmable controller with Real Time Clock) $20.00 REQUIREMENTS: IBM PC or Compatible, 384K RAM EiPROM 27C64 CMOS programmed with DG31M and disk DOS 3.0or later. IBM compatible printers. (IBM format) with monitor program, modules source code listings and manual $30.00 PCBoards - layout program 99.00 PCRoute - auto-router 99.00 HIOME AUTOMATION and SIMPLIFIED SECURITY SYSTEM - - schematic pgm. 99.00 complete project using TILE controller and low cost SuperCAD electronic modules (shipping included) $10.00 DEMO PKG. - 10.00 Call or write for more information PCBoards 2110 14th Ave. South, Birmingham, AL 35205

TERMS: Skippiq US/CAnAdr $6. Ckck on MONET ondEn plrrrr. (205) 933-l 122

Reader Service #156 Reader Service I1 73 WIRE-WRAP PROTOTYPE CARD FOR PC/AT HOME AUTOMATION The unique diskette CATALOG ON format allows for dynamic A manually FLOPPY DISK changes, so that each catalog wrappable distributed may have the prototype card for Home Control Concepts most current information, IBM PC/AT and has released its newest prices, and new products. compatible com- catalog on diskette. The 1990 Additionally, far more puters has been Home Automation Catalog information can be distrib- announced by on Floppy Disk includes uted on diskette that can cost- CANA Group. home automation and effectively be distributed via The Protosystem security equipment, specifica- paper mail. AT has been tions, pricing, explanations, The catalog is available designed to and uses. The catalog also from Home Control Concepts simplify prototype includes information on for $1.00 (refundable with design and save home automation, the CEBus any product order) or free debugging time. (Consumer Electronics Bus) from several computer The board home automation standard, bulletin boards including features wire- SMART HOUSE, and GEnie. wrap pins industry definitions. The soldered in place catalog is menu driven and Home Control Concepts on every signal has illustrations of home 9052 Westvale Rd. line, tantalum automation and security San Diego, CA 92129 bypass capacitors equipment. An IBM PC or (619) 484-0933 on every power compatible computer with line, and holds graphics is required. Reader Service #500 more that 100 16- pin IC sockets. The board is designed for ease of use and minimization of assembly errors. The signal pins are never closer together than 0.200” (double the normal distance). The signal lines are grouped into FRACTAL GRAPHICS SOFTWARE address, data, and control buses, and each signal pin has a large, functional name label. The labels are on both sides of the A drawing program that uses fractal geometry to create board for ease of troubleshooting. complex images is available from Cedar Software. The The board deals with a number of bugs that plague high- program, “Fractal Grafics,” can be used for graphic design, speed circuits by eliminating the conditions that cause them. scientific visualization, and educational illustration as well as The hand wiring can be used to reduce the chance of cross talk desktop publishing and presentations. Fractal Grafics takes a by using several levels of loose wiring rather than a neat simple template drawn by the user and automatically contin- bundle. The power and ground planes are low-inductance ues the pattern. For example, the user draws the trunk and paths to the power pins around the edge of the board that first few branches of a tree, and the program will draw the reduce losses. The large number of locations for power pins rest. A mouse or keyboard can be used to rearrange parts of eliminate the need for daisychaining and long power leads, any shape without losing texture or detail. The changes can thereby reducing voltage drop and noise propagation. then be reflected through all levels. The program features an A manual, entitled ‘The Principles of Wire-Wrapping” is on-line interactive tutorial, point-&click menus, and full color included with the board. This brochure describes techniques in control. color coding of wires, socket ID labels, and test points to make A 120-page guidebook and over 150 hands-on examples a circuit much easier to test and debug. explain and illustrate fractal art, science, philosophy, mathe- The Protosystem AT is available from stock and costs matics, history, and literature. Example templates, which can $149.95. be modified as required, are included. Chaos theory and the formulas used to create fractals are explained, and a program CANA Group to draw the famous Mandelbrot and Julia sets is included. 100 Walnut St., Suite 402 Fractal Grafics works on IBM PC compatibles with 384K Peoria, IL 6 1602 RAM and CGA, EGA, or VGA displays. A mouse and math (800) 747-2262 Reader Service #502 coprocessor are optional. PCX file compatibility allows the exchange of images with all major graphics programs. The program sells for $79.00 and includes one free program update.

Cedar Software

Rl Box 5140 l Morrisville, VT 05661 (802) 888-5275

Reader Service 850 1 NElAPRODUCTNEWSNEWPRODUCTNEWS

PATTERN RECOGNITION BOARD

A pattern recognition board, featuring 24 ‘ITL/DTL digital I/O lines, is available from Keithley MetraByte. The PIO-INT is an IBM PC/XT/AT compatible board that has been designed for use in data acquisition and control applica- tions, and consists of three byte-wide ports provided directly from a standard 8255 PPI. On-board circuitry monitors two of the three ports and is capable of generating interrupts on either the change of any bit in the port(s) or when a specific bit combination or pattern ap- pears. With a bit interrupt, a change of any unmasked bit from either 0 to 1 or 1 to 0 will generate an interrupt. Changes can be read from the Status Register, and only those bits that are activated by the interrupt Mask Registers will generate an interrupt. With a pattern interrupt, an interrupt is generated on a given pattern of bits in any port. Only unmasked bits can participate in a pattern match interrupt, and they are com- pared with a stored pattern of bits in the PIO-INT’s Pattern Filter delays are selectable independently for the two ports. Match Registers. The PIO-INT is provided with a sample assembly driver The third port, while not monitored and without inter- callable from BASIC, together with its source code listing on a rupt generation capability, can be used as an auxiliary I/O utility disk. The PIO-INT sells for $399. port, and can be divided into two nybble-wide ports. Each port can be individually configured as an input or output port. Keithley MetraByte To prevent spurious interrupts, generation of an interrupt 440 Myles Standish Blvd. is delayed by a two-stage digital filter. The filter is clocked by Taunton, MA 02780 a programmable discrete decade frequency ranging from 1 Hz (508) 880-3000 to 10 MHz. The effect of the filter is to allow actuation delays Fax: (508) 880-0179 Reader Service #503 from 100-200 ns to 1-2 seconds before interrupt generation.

EXPRESS CIRCUITS

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

Special Support For:

TANGO. PCB l OTHER PACKAGES ARE TANGO SERIES II NOW BEING ADDED TANGO PLUS FULL TIME MODEM PROTEL AUTOTRAX GERBER PHOTO PLOTTING PROTEL EASYTRAX smARTWORK HiWIRE-Plus Express 0 EE DESIGNER I Quotes: EE DESIGNER III Circuits l-800-426-5396 314 Cothren St., P.0. Box 58 Phone: (919) 667-2100 PADS - PCB Wilkesboro, NC 28697 Fax: (919) 667-0487

ReaderService X134 December ‘90/January ‘9 1 9 I NElA/PRODUCTNEWS/V~lM’RODUCTNEWS

DIGITAL TROUBLESHOOTING KITS

Three digital logic test kits which are TTL and CMOS compatible have been announced by Global Specialties. The LTC-6, LTC-7, and LTCJ each feature a logic probe, LM- 2A 16channel logic monitor, DP-1 logic pulser, and SQ-1 tone-ohmmeter packaged in a rugged plastic carrying case. An accessory kit, consisting of interchangeable probe tips, gro&d clips, tip adapters, and quick hook cables is also supplied. The tone-ohmmeter locates bad ICs and circuit shorts UNIVERSAL ANALOG multiplexers, eight op-amps, without unsoldering parts. The DP-1 digital pulser is a pocket- eight voltage regulators, 16 sized pulse generator used to stimulate logic circuits with TEST INTERFACE latched digital output lines, either a single pulse or continuous pulse train. The LM-2A BOARD and 16 latchable input lines. simultaneously displays the static and dynamic states of 16 For custom circuit applica- logic inputs. A universal analog tions, a breadboard area is Each kit contains a logic probe to find pulses even too fast interface that is controlled by provided around the DUT for an oscilloscope. The LTC-6 kit contains the LP-1 IO-MHz a single 24bit TT’L digital that can accommodate up to probe; the LTC-7 kit contains the LP-3 35-MHz probe; and the I/O has been announced by 35 16-pin DIP components. LTC-8 kit contains the LP-5 100-MHz probe. Late1 Engineering. The FB- The FB-1000 uses a 24-bit The price of the test kits range from $299 to $379. 1000 Analog Test Interface Family board is an 8” x 12” control bus, made up of three printed circuit board de- &bit ports. Several manufac- Global Specialties signed to provide a conven- turers make 24-bit I/O cards 70 Fulton Terr. l New Haven, CT 06512 ient and flexible interface for the IBM PC and com- (203) 624-3103 l Fax: (203) 468-0060 Reader Service #504 between a Device Under Test patibles, and sample IBM (DUD and the test system BASICA subroutine drivers menu interface, command controller or microcomputer. to control the FB-1000 from DSP OPERATING interpreter, batch command It features a variety of signal two of these products are ENVIRONMENT processor, file and memory interface and control func- provided. Any 24-bit digital management, and screen tions and includes locations I/O controller that is TTL An IBM PC-based graphics with hardcopy for 64 relays, two analog compatible can be used. operating environment, support for dot-matrix, laser, The FB-1000 package designed to develop or study PostScript, and HPGL includes a parts list, sche- Digital Signal Processing devices. output device support. matic, board layout, instruc- (DSP) algorithms, is available The batch command An introductory version tion manual, software from BittWare Research language allows users to is available for $250. The full drivers, sample programs for Systems. DSP Headquarters create and simulate an entire release, with additional the IBM PC and compatible (DspHq) allows an algorithm DSP system, complete with hardware and software computers, and the FB-1000 designer to write functions to user-input, breakpoints, and interfaces sells for $495. printed circuit board. The operate on a block of data single-step. Source code ex- The demo disk can also package, in quantities of one and it will supply the test amples are provided for the be downloaded from the to three, sells for $250, data, handle file and memory popular “MathPak87” and DspHq bulletin board at (301) dropping to $150 for quanti- management, and generate “Numerical Recipes in C” 8383205. Modem parameters ties of 10 and above. graphics. DspHq was analysis routines. Interfaces are 300/1200/2400-N-8-1. designed to be an open are currently available for The BBS is devoted to Digital Late1 Engineering architecture to allow users to most signal processing Signal Processing, DspHq, P.O. Box 391 integrate included functions, boards based on the AT&T and other related topics. Topsfield, MA 01983 popular function libraries, DSP32/DSP32C devices, and (508) 887-9506 and their own routines others will be available soon. BittWare Research Systems Reader Service #!506 written in “c” or Pascal. Other features include 400 East Pratt St., 8th Floor Algorithms pass and share context-sensitive help, cross Baltimore, MD 21202 common data structures and referenced for ease of use; (800) 848-0436 can be calculated by PC or pull-down menus; detailed Fax: (301) 879-4465 downloaded to a signal parameter setup; up to eight processor. DspHq includes a display windows; and color Reader Service #505 NElM’RODUCTNEWS/VM’PRODUCTbiEWS

ADVANCED STEPPER counters, a timer, and stall MOTOR COUNTER/ detection. The unit’s compact CONTROLLER (2.2” x 4.1” x 1.1”) size and rugged casing, which is noise A new advanced and EM1 shielded, allows it to counter/controller has all the be placed in small places near necessary commands and fea- mechanical components, tures to do complete motion reducing complex wiring and and I/O control in one small the usual noise generation. package. The I/O Master RC- Price was not available at 207 from Semix has a high- press time. speed counter, I/O, and an increased command set that Semix, Inc. facilitates its use for distrib- 4160 Technology Dr. uted stepper motor control Fremont, CA 94538 via a computer or as a stand- (415) 659-8800 alone system. Fax: (4 15) 659-8444 The IlO-kHz counter and 1100 points of memory allow Reader Service #!507 the RC-207 to do complex monitoring of as many as computer, except at initial multiple-axis control. Up to forty motors can be done programmmg. twenty I/O Masters can be from one computer. Program- The RC-207 features 8K daisy-chained with just a ming can be done in a simple bytes of EEPROM and 8K three-line cable to a host com- language such as BASIC or C. bytes of SRAM, as well as puter located up to 2500 feet The RC-207 can be many commands to allow the away. Each I/O Master can configured for stand-alone process to be easily manipu- control two stepper motor control as well. By writing lated and changed. Some of drivers alternately and 20 the program into each l/O these include: selectable baud inputs/l6 outputs; thus, Master’s EEPROM, the units rate, echo-back capability, centralized control and can be used without a host jump routines, flag settings,

DunPnn+unI I I UWWIIIl WI SrOMPOUT Modular data acquisition and control for your IBM PC EPROM MADNESS Our hardware and software are designed to work together- so ProControl makes process control MORE simple and LESS expensive. IBM PC Host Adapter $129.95 lnterfoces IBM PC’s to P.c=%z?+:g! bus //O modules AND provides 24 digital I/O lines. TM/?-36 Timer Module $69.95 3 (expandable to six) programmable counter The PROM KING emulates EPROMS, saving both time and channels. fncludes C and BASlC examples and money during your development cycle. Programmable in driver software. seconds via your PC printer port or any computer RS232 AIfV-124 A/D Module $129.95 port, it can emulate most 27xxx devices. Four (expandable to eight) /Z-bit l 8K-8M bit devices l 8-256 bit downloads digital-to-analog channeb. l High speed download: l Easily expandable: -Universal RS232 -4 EPROMS per unit Graphical Instrument Library (GIL) -PC printer port -Up to 8 units CGA Version FREE with any Pf&zz+ce! module. l Menu driven software l Also programs like VGA/EGA/CGA/Hercules version may be purchased with l Battery backup a real EPROM or without source. Cal, or see our cafafog for pricing. $599 for 150nS units with 256K bits Ask for pncing of other options. More l/O modules are Made in USA by available. Call for our FREE catalogue today! TMXEL k4BS INC. BOX 239*RONKONKOMA.NY*11779 (404) 352-4788 516-737-5147 FAX-51 6-737-0349

December ‘PO/January ‘9 I 11 ONDI- Part 2 The ON-line Device Interface Dybo wski 1 John Software for Remote PC Control

H aving developed the hardware for a flexible remote computer control system, we will now investigate how the IBM keyboards work, and take a look at the prototype software for a simple remote control application. Our system configuration will consist of a computer, ONDI, and a Hayes-compatible mo- dem; ONDI and the modem will remain powered up at all times.

THE FUNCTIONS OF A REMOTE toggle switch which will enable or operational environment in which CONTROL DEVICE disable auto answer, or put the system ONDI will operate. ONDI runs in one into a local mode of operation. ONDI of three primary states: idle, local, or We won’t get too fancy but we’ll will have the capability of being seri- remote. When either local or remote, try to touch on some of the more ally accessed either locally or remotely, ONDI can function in a transparent or important elements. To get started we where remote access will be used for command line mode. Command line must have the capability to control control purposes and local access for mode puts the user in direct commu- and monitor the computer power. configuration, check out, and down- nication with ONDI. Transparent Keyboard emulation for both PC/XT- loading. Interactive communications mode allows direct communications and AT-style keyboards will be will be carried out using a command between the local and remote com- needed. The modem will typically be line format which will handle buff- puter. Priority is given to the local required to auto-answer an incoming ered input with echo, and a transpar- interface so ONDI can transfer directly call, which we will want to enable or ent mode of operation will release the from remote to local operation if the disable under software control. This communications lines to the modem/ switch is thrown to the local position. will be accomplished serially via the computer. An escape sequence will be The following rundown briefly de- Hayes AT command set by either set- used to return to the command line. scribes the major operational states ting the modem to answer on the first A timeout facility monitors the and modes that ONDI can assume: ring or by issuing the reset command modem line for periods of inactivity. Idle: The idle state is entered on which will return the modem to its Abort times will be set at two minutes power-on following system initializa- switch-selected settings. during log on and five minutes for tion and is the point of return follow- To ensure that the modem is al- normal remote operation and will ter- ing the termination of most other states. ways configured to the desired state, minate the session on expiration. ONDI waits here for something better we will also monitor DSR and trans- With the power to access the re- to do. mit the appropriate sequence on a sources of a computer remotely, there Remote state, log-on mode: This transition of DSR going from off to on is a potential for problems, so pass- modeallowstheuserattheremotesite which would indicate either the con- word access protection will also go on to access ONDI in order to satisfy the nection or powering up of the mo- our list. Finally we will twiddle some log-on requirements. If successful, dem. For ease of implementation, the LEDs on ONDI to indicate these vari- ONDI proceeds to the remote com- modem’s result codes will be disre- ous states and modes of operation. mand line mode. garded and the modem’s CD line will Remote state, command line be used to find the state of carrier. STATES AND MODES mode: In this mode the remote com- To simplify the user interface, the puter is in direct communication with operational state of ONDI will be Having defined the desired fea- ONDI and has access to the remote controlled by a single three-position tures, it is now possible to outline the command set. Remote state, transparent mode: mode), and switch to transpar- K-Send as keyboard The computer’s COM port is con- ent operation. data. nected to the modem. ONDI monitors X-Switch to transparent opera- P-Display password the modem transmit line. If the escape tion. Pc”text”>-Set password. sequence is detected, control returns Lctext>-Line check, retransmit P”“-Deletes the password. The to the remote command line mode. to the remote computer. password is case sensitive. Remote state, CTTY mode: Like A-Abort, hang up line. L-Line check, retransmit the transparent mode, except that text to the local computer. ONDI issues the DOS MODE and Power-On Reset X-Switch to transparent operation. CITY commands to the local com- puter via simulated keyboard input SOFlVVARE STRUCTURE prior to entry. On exit ONDI CTlYs back to the console via the COM port. The code structure is segmented Local state, command line mode: in a modular fashion such that use- The local computer is in direct corn- ful pieces can be extracted or munication with modified for your own use. It access to the local command set. should be evident from the Local state, transparent mode: The computer’s COM port is connected to the mo- dem. ONDI monitors the sponding to the various computer transmit line. If statesand modes. Also, the escape sequence is de- it should be noted that, tected, control returns to for the most part, the the local state/com- required lower-level mand line mode. This is support functions the point of entry when Local Transparent remain consistent as the mode switch is set we traverse the vari- to local operation. ous process loops. With the above in NOW, THE mind, the structure COMMAND SETS adopted for the main- line processing is Where possible, to The local command set consists of the composed of two parts: the main reduce the amount of unique com- following: (MAIN) application driver, which mand mnemonics, the practice of us- H-Display a list of these com- handles the specifics of the moment, ing the command without an argu- mands on the local console dis- and the low-level resource handler ment is used to return the function’s Play* (IDLE) that’s responsible for perform- status. In entering the commands, M-Display computer mode: AT ing the grunt work. upper or lower case is OK. The remote or PC/XT. IDLE is a callable routine that is command set is as follows: Ma-Select AT mode. the interface between the application H-Display a list of these com- Mx-Select PC/XT mode. and the hardware and background mands on the remote console B-Display boot delay time. interrupt functions. The functions of display. Bnn-Set boot delay time, 0 to 99 IDLE include monitoring and de- S-Power status; returns ON/OFF seconds. The boot delay time is bouncing the toggle switch and mo- indicating the computer power the amount of time ONDI waits dem CD and DSR signals (returning status. after executing the S+ command only when a change in state occurs), S+ -Turn computer power on. in remote mode. This is to pre- and relaying the SIO-related informa- Report if computer logic power ventaccidentallyinjectingsimu- tion such as receive complete, receive is not detected within five sec- lated keyboard data before the timeout, receive error, and escape onds, delay for boot-up (as pro- keyboard’s power-on transac- detect. These events are indicated by grammed via the local command tions have been completed. returning result codes to the calling line mode). C-Display selected COM port. routine in the accumulator. The bene- S- -Turn computer power off. Cl-Select COM port 1. fit of this approach is that the applica- K-Send assimulated C2-Select COM port 2. This is the tion software becomes much simpler keyboard data. COM port used when the Ccom- to code and comprehend since the C-CTTY to COM port (as selected mand is processed in remote details of handling the data input are via the local command line mode. centrally processed in a routine that,

December ‘90/January ‘9 1 13 RELAV once we have working, we will not be assembled, the receive logic issues an INTERFACE apt to disturb. Typically the applica- interrupt and simultaneously pulls the tion calls IDLE whenever it has com- clock line low until the received char- pleted its specific function such as acter has been processed. This is an interpreting a command or transmit- indication to the keyboard that it now ting a string of data. On return, the must not transmit. An idle keyboard application has the option of either releases the clock line allowing the processing or ignoring the return code pull-up resistors to hold it at a positive as appropriate. A quick look at this state and asserts the data line to a logic arrangement confirms the premise that low; therefore, the interface is capable a typical program executes five per- of unidirectional traffic only. The PC/ cent of its code 95 percent of the time. XT keyboard is capable of encoding %. (CONNECTS ~0 w-232) IDLE'S return codes are: 128 unique key codes. A byte with a

WI-16 RELAY INTERFACE ...... $ 69.95 l-Received text available value of 0 to 127 is considered a make Two 8 channel relay output ports are prowded lor :onlrol of u lo 16 relays (expandable lo 126 relays 2-Receive error (command line code. Break codes are formed by using EX-1 g expansion cards). Each relay output port :onnecls lo a relay card or lermlnal block. A varlely of overflow) adding hex 80 to the make codes. For clays cards and relays are stocked. call for more Info 35-422 avatlable (dlslances lo 4.000 feel) PS-6 port 3-Escape sequence received example, key 1 produces scan code ielector may be used10 control salelllle AR-16 nlerfaces. (up lo 16.364 relays) Q-Receive timeout Olh on make and 81h on break. The bit 9D-6 REED RELAY CARD (8 relays) $ 49.95 9H-6 RELAY CARD 10 amp SPDT 277 “AC) ...... $69.95 5--Enable local operation format for data transmission consists EX-16 EXPANSION IJARD (16 channel) ___...... $ 59.95 6-Disable local operation of a “1” start bit and eight data bits. WNALOG TO 7-CD went on The AT keyboard uses a bidirec- &CD went off tional serial interface to carry signals DIGITAL 9-DSR went on between the keyboard and the com- IO-DSR went off puter. As in the PC/XT keyboard, all 11-Enable auto answer keys are classified as make/break, 12-Disable auto answer however in order to increase the total number of keys that can be encoded, THE KEYBOARD ACCORDINGTO IBM the method of indicating break codes is different. When a key is released, The keyboard as implemented by the break code consists of hex FO fol- IBM for its PC/XT and AT computers lowed by its make code. Since the performs physical key scanning using interface is used for bidirectional an on-board processor that detects communication, the data and clock CONNECTS TO RS-232 when a key is pressed or released and lines are both released and passively \DC-16 (16 channel) $ 99.95 signals the computer by sending a pulled up when the keyboard is idle. nput temperature, voltage. amperage, pressure, !nergy usage, energy demand, llghl levels, ]oysllck make or break scan code. Keyboard This permits either the keyboard or novemenl and a wide varlelv of other woes of analoo scan codes are assigned by number- the computer to take control of the ing the physical keys on the original interface. Data transmission to and PC keyboard from left to right, top to from the keyboard consists of 11-bit bottom.Thecomputer’sBIO!Sconverts data streams composed of a “0” start the unique key codes to ASCII repre- bit, eight data bits, odd parity, and a sentation (where possible) for use by “1” stop bit. Unlike the simple hard- the computer. Keys that have no cor- ware interface of the PC/XT, the AT responding ASCII symbol areassigned uses a dedicated to talus inputs (opt0 lsolalors sold separaiely) -E-6 TEMPERATURE INPUT CARD $ 49.95 a value of ASCII null which indicates communicate with the keyboard. This ncludes 6 solld slate temperature sensors. -emperalure range is mmus 76 lo 145 degrees F. that the next byte should be inter- arrangement incorporates a commu- . FULL TECHNICAL SUPPORT...prowded over the telephone by our staff. EACH ORDER INCLUDES A preted as a scan code and not an ASCII nication protocol that provides for FREE DISK WITH PROGRAMMING EXAMPLES IN BASIC, C AND ASSEMBLY LANGUAGE. A delalled code. The keyboard communicates to errordetection, timeoutabort,retrans- technical reference manual IS also Included. the computer over an interface that * HIGH RELIABILITY...englneered for conl~nuous 24 mission, and recovery from line con- hour mduslrlal appllcalions. All IC’s socketed consistsof a data and clock linedriven tention. A command set is also sup- - Use wlh IBM and compallbles, Tandy, Apple and most other computers wlh RS-232 or RS-422 polts by open-collector devices that are ported both to and from the keyboard. All standard baud rates and prolocols may be used (50 lo 19,200 baud). pulled up with resistors at each end. Fortunately, experience shows that, * Use our 600 number lo order free InformalIon packet Techmcal Information (614) 464.4470 The PC/XT keyboard computer for the most part, these elements can interface is implemented in hardware be ignored and reliable communica- using a shift register where the data tions can be attained by simply clock- ELECTRONIC ENERGY CONTROL, INC. 360 South Flflh Street. Su11e 604 bits are sequentially shifted in on the ing the key codes into the computer. Columbus Ohlo 43215 falling edge of each clock transition. The basic procedure for translat- Reader Service + 130 When an entire character has been ing ASCII data to key codes is the

14 CIRCUIT CELLAR INK same regardless of which style key- board we use. The method basically consists of performing a table lookup using the ASCII character as an index. The table returns either the translated scan code, a flag that indicates that a secondary lookup must be performed using the shift table, or a flag that indicates that the control table must Avoid the hassles be consulted. Once the final scan code of programming is determined, the sequence is as- EPROMs sembled and transmitted to the com- puter. For unshifted characters, only one scan code is transmitted, but in the case of shifted or control charac- ters, the scan code must be framed with a shift or control make code and a shift or control break code as appro- priate. Note the performance degra- A ROM Emulator can dation when transmitting strings of greatly reduce the shifted characters, particularly in the AT emulation routines, since for ev- time spent writing ery shifted character, three extra bytes and debugging must be transmitted. It will be left as ROM code an exercise to the reader to consider how to keep track of the shift mode so we won’t have to frameeachand every shifted character with the shift se- quence. Note that the only break codes that are transmitted are for the shift and control keys. Our keyboard emu- lation routines have the capability to transmit the source string from pro- gram memory or internal data mem- ory. Finally, bear in mind that we’re commands. Received character echo- working under the assumption that ing is handled from the receive inter- the keyboard isinactiveand that we’re rupt and may be enabled or disabled. operating from a known state, other- Receive timeout and escape sequence Emulates 2764,27126, & 27256 wise we would have to constantly detectionarehandled withalittle help Plugs into target ROM socket and monitor the keyboard traffic for codes from the timer interrupt routine. connects to PC parallel port via such as ALT make, shift make, control The escape sequence is defined as modulartelephone cable make, and the toggling of caps lock. at least one second of silence followed Accepts 32K x 8 SRAM or NV SRAM by three “minus” characters. The re- Loads Intel Hex, Motorola S, SERIAL COMMUNICATIONS ceive abort timer is implemented as a hex, and binary files softwareretriggerableone-shotthatis High and low RESET outputs for Communications for the system rearmed every time a character is re- automatic startup after downloading are fixed at 1200 bps, no parity, and ceived. The receiver signals the fore- Includes all necessary software one stop bit. Due to the nature of the ground when a return is received or and cables - worksrigktaway! discrete memory areas in the DS2250, on buffer overflow indicating either the transmitter can be set up to trans- normal completion or an error. mit from program memory, external data memory, or internal data mem- SYSTEM TIMEBASE ory. Although the transmitter is fully interrupt driven, it is used in a polled All system timing is referenced to mode in this application. The receive the timer interrupt routine that exe- interrupt handler implements the cutes every 25 milliseconds. In addi- buffered command line where the tion to handling the escape sequence backspace character allows editing of guard time timer and receive abort

Reader Service Y 172 December ‘90/January ‘9 1 15 timer, a general-purpose timer is ONDI immediately begins executing run between unattended computers. supported for counting delay times the program. [Editor’s Note: Soffware Consider a secure modem appli- from one second to five minutes. A for this article is availablefrom the Circuit cation. The remote calls in and leaves sync flag is also set every time the Cellar BBSand on Software On Dbk #18. a password. ONDI hangs up, powers timer interrupt is invoked. For downloading and ordering informa- up the computer, and starts a pro- tion, see page 92.1 gram inputting the password on the PUSHING THE CODE AROUND command line. Now, the computer THE EXPANDED CONTROL DEVICE takes over and searches its database, Although we could use any stan- logs the transaction, and, if the pass- dard communications program with After test driving the prototype word has a corresponding telephone file manipulation capabilities to trans- code, it is apparent the device can in number, it dials it directly. This turns fer our hex file to ONDI, this would fact operate a computer remotely. Still, out to be an almost trivial exercise, require a multistep process to config- this rudimentary implementation mainly because the computer is used ure the DS2250, load the program, and requires human intervention from the to compute and the controller to con- verify the program. A better solution remote computer and is quite limited. trol. Just a simple matter of software. is my LOADER utility. Not only does it Our DS2250, with its inherent intelli- Stay tuned.+ build a DS2250 configuration file for gence, however, can be programmed setting up the chip, but the program to function independently. First, we My appreciation goes out to Dan Burkefor his will accept a command file either on might implement the capability of re- participation in this project. the command line or interactively that cording key code sequences directly John Dybowskihas been involved in thedesign will not only direct LOADER to execute from the keyboard so that we could and manufacture of hardwareand software for the required programming steps, but later play them back to the computer. industrialdatacollectionand communications Will hi0 COnfigure LOADER'S opera- Next, wecould provide for stand-alone equipment. His crowning achievements are tional communication parameters. The initiation of sequences, where ONDI his daughter Ondi and his son John. process of downloading to ONDI would operate the computer using simply consists of setting the load predefined sequences in response to IRS switch to the load position and external events. With the addition of a 400 Very Useful invoking LOADER. Once done, we set communication protocol, we could 40 1 Moderately Useful the load switch to the run position and relegate remote communications to 402 Not Useful Total control with LMI FORTH’” Rw Programming Professionals: an expanding family of compatible, high- performance compilers for microcomputefs For Development: interactive Forth-83 Interpreter/Compilers The EP-751 txoc rams 67C751 67C752 and 2716 through 275i2. Software incldded. Quick pulse for MS-DOS, OS/2, and the 80386 algoriilhm. Simple installation. l 16-bit and 32-bit implementations Combine with bA51-FC to rogram: 67C51, l Full screen editor and assembler 87C51-FA. ‘FE. ‘FC, ‘652, ’ !j4, ‘526. l Uses standard operating system files ------2 --2 8 9 500 page manual written in plain English Combine with PASi-FC & PLdC adapters to l Support for graphics,floating point, native code generation program: 67C51 (-FA, -FB, -FC), 67C552,67C451. = PA26-32 adapts programmers for PLCC 2764 thru For.Applications: Forth-83 Metacompiler 27512. PA3232 adapts for 2701 O_, 27020,27040 l Unique table-driven multi-pass Forth compiler PLCC. PA260-44 adapts 16-bit wide PLCC l Compiles compact ROMable or disk-based applications EPROMs. l Excellent error handling l Produces headerless code, compiles from intermediate states, EP-751 .*...... *...... and performs conditional compilation PA51 -FC ...... l Cross-compiles to 808O,Z-80,8086,68000,6502,8051.8096, 1802,6303,6809,68HC11,34010, V25, RTX-2000 ...... l No license fee or royalty for compiled applications m Laboratory Microsystems Incorporated I%.% Office Box 10430, Marina de/ Rey, C4 90295 Phone Credit Card Orders to: (213) 306-7412 FAX: (213) 301-0767 buy:Cal Systems Corporation -0. Box 6184, Syracuse NY 13217 USA

,

, ClRCUll CELLAR INK Principles of PC-based FEATURE Data Acquisition and ARTICLE Chris ck7fcia Control Systems

I could start this article with some sweeping statement like “PC-based data acquisition and control systems provide the greatest versatility and flexibility, etc., etc, ,” but most of you are already sold on that idea. If you’ve spent any time reading past issues of this magazine then you appreciate how many different things your PC can do. Instead, I’d like to discuss the basic principles behind the application instrumentation used in those articles. In other words, I want to discuss how your PC is able to interact so effectively with the real world and what pitfalls you may encounter as you try to control your environment,

Figure 1 -Process DAAC System. Physicalparame- Analog ten and process charac- Pressure Vent Containment Vessel Pressure Multiplexer teristics are derived from Control Valve pressure (transducer) and temperature (thermo- couple) measurements which are amplified and digitized and then fed to a PC for status monitoring and decision input. The PC then analyzes the process response, calcu- lates error and generates a series of control se- quences which are fed back to the process for control manipulation.

Bidirectional Computer Data Bus

18 ClRCUlT CELLAR

i We can all appreciate that the world around us very rarely lends Output itself to simple understanding, evalu- Output Code ation, or control, especially if we at- S&%S Word I , tempt our control using a computer system. Most real-world physical para- meters are analog and require some form of interface to the world of artifi- cial computation and control.

DATA ACQUISITION AND CONTROL

The basic interfacing modules which are employed in most real- world interactive systems are the analog-to-digital (A/D) and digital- to-analog (D/A) data converters. The A/D converter is a circuit which con- verts an analog (continuous) voltage or current into an output digital code. And conversely, the D/A converter converts a digital code word into an output analog voltage or current. Of course, that’s not all there is to a real- world interface. In reality DAAC sys- tems are created using one or more of the following components: Quantizer Error

Figure 2-Due to the stair-step nature of the digitization process, there is always a small DA/D and D/A converters amount of quantkation error associated with the digitized signal. l transducers .sensors pressure measurement from the con- level and may be a high-impedance *amplifiers tainment vessel’s pressure transducer signal, a differential signal with com- l filters through the interface, to the computer. mon-mode noise, a current output, a *analog multiplexers Then we’ll follow the computer’s re- signal superimposed on a high volt- *sample-holds sponse back through the control inter- age, or a combination of these. It is adigital control sequencers face, to the actuator located at the usually amplified to a range of l-10 l PC computer controller and pressure vent control valve, where volts. I/O bus modifications in the processes’ status Theamplifier output is channeled .actuators will be made. through a low-pass filter which re- Let’s assume that the pressure (or duces the undesirable high-frequency To see how the above components force per unit area) within the con- components (noise) within the signal. can be combined to create a workable tainment vessel is measured using a Sometimes the signal is then passed computerized feedback control sys- standard pressure transducer. Here, through a nonlinear analog function tem, consider the diagram shown in an elastically deformable sensing ele- circuit which may modify the signal Figure 1. Here, measurements of ment responds to an omnidirectional by squaring, multiplying, dividing, “some heating process” within a pres- fluid/gas pressure. The deformation doing RMS or log conversion, or lin- surized vessel are used to monitor within this element, usually the com- earizing it. and generate feedback control se- pression of some sort of bellows or The processed signal is introduced quences which will optimize the de- convoluted diaphragm, is then meas- to an analog multiplexer which se- sired process. The primary inputs to ured and an electrical signal is gener- quentially switches between a num- this DAAC system are the measure- ated which varies as a function of that ber of different analog input channels. ments of (analog) physical parame- deformation displacement. This ana- Each input is connected to the output ters such as temperature, pressure, log signal is then fed through an of the multiplexer for a set time inter- velocity,acceleration,ordisplacement. amplifiertoboost theamplitudeofthe val during which the sample-and-hold To gain an elementary under- transducer output signal to a reason- module receives the signal voltage for standing into the design configura- able level for down-line processing. sampling while the A/D converter tion of the needed elements within the The typical transducer output usually converts that value into a digital form. DAAC system shown, let’s trace the rangesover the microvolt-to-millivolt This resultant digital word is then

December ‘QO/January ‘9 1 19 the A/D process. Typically this con- version is characterized by a nonlin- ear transfer function like that shown in Figure 2. This figure represents the AU=FxTa quantizer for an ideal 3-bit system with eight output states, like that used 2, = aperture time in a 3-bit A/D converter. These eight AU = amplitude uncertainty states are referenced by a sequence of binary numbers which range from000 to 111 over an analog input range of O-10 volts. gure J-Any analog to digitalconversion takes a finite amount of time during which thb _ in,put signal may change, The absolute resolution of the quantizer circuit is specified by the dumped onto the DAAC system’s several of these individual functions. number of output states defined in bidirectional data bus for access by But understanding the basic concepts bits, or, in terms of a binary-coded the PC controller. behind each of the above described quantizer power, 2*, where n is that This, of course, is not the only components is of extreme importance number of bits. Thus, an &bit quan- approach to data acquisition. In an when designing and configuring your tizer has 256 output states and an 24- often-used alternative, the measured DAAC system, or for when you use an bit quantizer has 1,677,220 output signal is amplified and converted into “integrated” data acquisition board. states. Most applications call for a 212, digital form at the transducer: The Your original analog data is manipu- or 4096, output format. output is then transmitted to the PC lated and altered by these devices. So In our example diagram there are through a serial port. However, im- how you quantize, sample and code 2”-1 analog decision points or thresh- plementation of this technique re- your measured data will in fact deter- old levels within the transfer function quires that the data be converted to mine the quality of your measure- (at +0.625, +1.875, +3.125, +4.375, parallel form and then multiplexed ment results. Here, quantization re- +5.625, +6.875, and +8.125). These de- onto the data bus. fers to the process of transforming a cision points are precisely set halfway In the feedback control portion of continuous analog signal into a set of between the code word center points the DAAC interface, for all intentsand discrete output states which are then (+1.25, +2.50, etc.) in order to divide purposes, we do the inverse of the coded into a discrete digital word the analog voltage range into correct input data acquisition process. The which represents each output state, quantized values. So, when an analog computer, based on analysis of its during a specified sampling timeinter- signal level is submitted, the quan- input, determines the necessary out- val. tizer circuit determines what thresh- put control functions required to elicit old level has been obtained and as- a specified response within the “de- THE QUANTIZER TRANSFER signs the binary code corresponding fined process” according to its opera- FUNCTION to it. Keep in mind, for anyone output tional guidelines. These control out- code word there exists a small range puts are digital in form and must be Quantizing an input analog sig- of voltage differential about its center converted to analog form to drive the nal divides the signal into discrete point where an input voltage can be process. This conversion is accom- levels or states whose size or range assigned the same code. This range plished by employing a D/A con- determine the overall resolution of between any two adjacent decision verter, usually coupled to a points is known as the storage buffer which stores analog quantization size, the digital word until the quantum Q. For our ex- next update. These buffers ample (shown in Figure are under the control of the 21, the quantum is Q=l.25 sequencer. The output of V. In general it can be de- the D/A converter is used output termined by dividing the to drive actuators which full-scale analog range by directly control the various the number of output parameters. states. Q therefore repre- sents the smallest analog QUANTIZATION AND difference which can be SAMPLING THEORY resolved or differentiated by the A/D quantizer. Many of the commer- Asawtootherrorfunc- cially available A/D and or Figure 4-h order to keep the inputsignalsteady during the conver- tion for the quantizer can D/A boards may combine sion, a sample and hold circuit is typically used. be derived by running the

20 ClRCUlJ CELLAR INK input through its entire range while of time to complete the quantization zero crossings of the waveform, and taking the difference between the and coding steps. This “active” time the amplitude of the error becomes, output and input. This is the irreduc- depends on several things, such as the ible error that results from the quanti- overall resolution, theconversion tech- AV =+&in wt)t=o z&ion process. It can only be mini- nique, and the component processing = GAW mized by increasing the number of speed. This aperture time refers to the output states (the absolute resolution). time uncertainty or “the time win- The resultant error as a fraction of the Typically, for a given analog input dow” during which a measurement is peak-to-peak full scale is level, the output will vary anywhere made. And as such it results in an from 0 to s/2, with the error being amplitude uncertainty if the signal e =LUL=&a zero only at points with analog values changes during this interval. 2A that correspond to the code center To understand this better, con- For example, the aperture time re- points. This variation is defined as the sider the diagram shown in Figure 3. quired to digitize a IO-kHz signal to 12 quantization uncertainty or noise. As Here, the input to the A/D converter bits of resolution can be estimated as, a result, the quantizer output can be changes by AV, the maximum error ‘5= =e thought of as a combination of the due to the signal change during the xf analog in and the Q noise, where this conversion time window, T. The error 0.0002441 noise has a peak-to-peak value of Q in this measurement canbe estimated = 3.14159 x (10.0 x103) and an average of zero. The RMS value in two ways: as an amplitude error or can be computed from the triangular as a time error, which are related to = 7.7x lo-g waveshape. It is useful in analysis and each other by: that is, 7.7 nanoseconds. With num- is usually Q/3.464. bers like these, one begins to under- stand the difficulty converting signals SAMPLING THEORY dt in the tens of gigahertz range, where where dvCt)/dt is the rate of change some of the latest scopes are now em- No process is instantaneous! Like with time of the input signal. If a sinu- ployed. most things, the A/D converter re- soidal input signal is employed, the Also affecting the overall aper- quires a small but significant amount maximum rate of change occurs at the ture time is the sample-and-hold time.

ENV96 Ask streamlines your about other design process by allowing ENVIRONMENT 96 you to bring your idea to Development Tools. prototype quickly and efficiently.

ENV96 is a plug-in development board for Intel’s 6096/6CC196 microcontroller. ENV96 includes an 8097BH or 60C197KB, processor support hardware, a shared 64K RAM module, an interface to the PC, a wirewrap area with digital and analog power and ground distributed throughout, and wirewrap pins on the PC Bus and processor pins. Easy to learn Debug software simplifies HWLSW debugging.

Annapolis Micro Systems, Inc. __~ 190 Admiral Cochrane Drive Annapolis, MD 21401 (301) 841-2514 FAX: (301) 841-2518 ReaderSewice#l59 q der Servb1107 December W/January ‘9 I

_f ‘owilouo Sodw * LWxwtrl Rfww * Fwt Shi&rg LilliLm9 time of the A/D converter is often ?O. Box567. Van. . ., NUYS.. ...:...... :::..:. CA ., . . . 91408...... reduced by the “typically” shorter ~ii~l~~~~~~~~~~~~~~~~~~~~ , I’.. time of the sample-and-hold circuit, 4CCC Electronicse 5N3-1 ,/ ‘\ which is a function of its bandwidth uew Prepped power SWlY a> , lvlth wires end connectors and switching time. \ / ~Mered to inputs and A sample-and-hold is simply a xnputs. Open framn style. \, ,/I.’ Rsgulated. Voltage end ‘l_./ voltage memory device in which an xl&t adjustment trlmmers. 4.94’ X 4.W X r. JL and CSA Ifsted. CAT* Pt3-53 510.00 eech input voltage is stored on a high-qual- .~ ...... :. ..:.. ..:...... ity capacitor. A popular version of ~~~~~~~l,~~~~~~~~~~~ this circuit is shown in Figure 4. Here, lubicon CE photoffash capadtor. A, is a high-impedance input buffer 8.m dfa X 1 .l’ hlgh. These are nw apaclors that have been prepped amplifier, such as an analog multi- rkh 1.4’ black and red wire leads A, ofdered to the terrrinals. CATX PPC-210=B plexer. is the output amplifier which 2.50 each - 10 for 522.50 - 100 for $200.00 buffers the voltage on the hold Large quantities availebb. Call for pridng. capacitor C, which has low leakage and low dielectric absorption charac- ~irpax#C82711-Ml I7 Vdc 23.25 ohm teristics (typically MOS type). S is an tual coil. pemwent electronicswitch,usuallyaFET, which magnet stepper motor. 7.5 degrees per step. is rapidly switched on or off by a Z.25” dia X .91’thi&. 0.25‘ dia. shalt Is 0.6’ bng. Two hole mounting flange, 2.625”canters. 6 wire leads. driver circuit which interfaces with CATw SMTd S6.M) each. 10 for S5O.M) TTL inputs. 4irpaxX C 62710 - 12 Vdc. 36 ohm dual coil permanent nagnet stepper motor. 7.5 degrees per step. 2.25 dia. Figure 5-The digitization process involves The sampleand-hold works in aody X 0.93’ high. Mounts on 2.675’ canters. 6 wire sampling the original signal at fixed inter- two modes: sampling (or tracking) cads. CATW SMTJ $7.00 each - 10 for $65.00 vals. The samples are then used to recon- when S is closed, and holding when struct the original. the switch is open. When used with It is derived from the device that an A/D converter, the device is kept lotron I NC12E3 hese aI8 the same samples the input signal voltage and in a hold mode until a new input sig- lens we have In our :atalog for 59.00 each. stores it on a capacitor for the time nal is required. This is the case for a Ye just received another required by the A/D quantizer to do sample-and-hold used in a data ac- Dad of them and want to rwe quantities at a its thing. This means that the aperture quisition system following a multi- ,pecid price. Rated: 12Vdc. 0.16 1.69’ square pfastlc housing X 1.25” thick. 5 blade fan. Two 9. pIgtail leads. CATX CF-122 10 for $65.00 - 100 for S500.00 ...... ,... ., ...... ~ a1 v

: connectors. \ko Includes a F-61 ,plkxr and a 75 ohm srmlnator bad. New able6 manufadured for *-an=== BM pc networks. UL listed. Specs: 75 ohm Impsdance. :able jacket O.D. 0.405’. Dielectric 0.285’ dia. Center anductor 0.047” diameter. IBM P/N 1501906 COW SCOPE. CATW RG-11-l 100 foot roll $15.00 ‘\ CATW RG-1 l-2 200 foot roll 527.50 1. Freq. “., ~~~e~~~~~~~~~~~~~~~~ ) 0 ~~~~~~~~~~~~~~ ;c ii~~kofftrc~~~~~~~~:~~~~~:

for lho 46 wnlfnentat U.S. A US0 ;r oder. All otf& idudng AK, Hl PR or Canada muSt pay full ohfppirig W o&m dolivored in CALFCftNlA musl fmtu& state ial00 tax (6 l/4 x 6 3/4 %, 7 l/4 %) .Ouanrrfies Limited NO C.O.D. Prices s&ject to ch.wge wittkwl notice.

I______Call’ Toll Free, or cl& ___this coupon ___ FREE 60 Page Catalog Containing over 4,000 ITEMS ALL ELECTRONICS CORP. P.O. Box 567 l Van Nuys, CA l 9 1408 Freq. I 0 I I I Nun f*-fc f* fc t f*+ fc 2

Figure 6-When the frequency spectrum shown in (a) is sampled andreconstructed at a rate less than twice fc, frequency folding or aliasing results (b).

Reader Se&e Xl03 22 CIRCUIT CELLAR INK plexer (see Figure 1). While with an D/A converter, it is used as a deglitcher. Here, the device is used to continuously track the input signal, then switched into the hold modeonly at specified times.

THE SAMPLING THEOREM

In most DAAC systems, analog signalsare sampled on a periodic basis, similar to that demonstrated in Figure Figure 7-An inadequate sampling rate causes an alias frequency. 5. Here the sinusoidal input signal tion process shifts the original spec- If the sampling frequency f, is not (5a) is sampled on a periodic basis, de- trum out to f, 2f, 3fti and so on, in high enough, then the part of the termined by a train of sampling pulses addition to the one at the origin (a spectrum centered around f, will fold (5b) which represent a fast-acting piece of this spectrum is in Figure 6b). over (frequency folding) into the origi- switch that connects the signal to the sample-and-hold for a very short pe- riod of time, then disconnects it for the Cross-Assemblers fromsO. remainderofthesamplingperiod.The result of this operation is identical to Simulators from$100.00 multiplying theanalogpulsebya train of sampling delta functions of unity Cross-Disassemblers from$lOO.OO amplitude (see Figure 5~). The ampli- tude of the original signal is preserved Developer Packages in the modulation of the pulse enve- from $2OO.OO(a $50.00 Savings) lope with the amplitude of each pulse (sample) being stored between Make Programming Easy samples within the sample-and-hold. Our Macro Cross-assemblers are eas to use. With powerful From this, a reasonable reconstruc- conditional assembly and unlimited incluJe files. tion of the original signal can be achieved (see Figure 5d). Get It Debugged--FAST Don’t wait until the hardware is finished. Debug your software with our Now the important question must Simulators. be answered: “How much sampling must I do (what resolution) to retain Recover Lost Source! most of my input information?” Our line of disassemblers can help you re-create the original assembly Obviously, if I sample at a rate language source. where little or no change takes place between samples, I won’t lose much. Thousands Of Satisfied Customers Worldwide Equally obvious is the fact that infor- PseudoCorp has been providing quality solutions for microprocessor problems since 1985. mation is being lost if there is a large amount of change in signal amplitude Processors between samples. So to get an answer, Intel 8048 RCA 1802,05 Intel 8051 Intel 8096,196kc let’s consider the Sampling Theorem, Motorola 6800 Motorola 6801 Motorola 68HCll Fcn~z1&;05 which states: 6301 Motorola 6809 MOS Tech 6502 Rockwell 65CO2 Intel 8080 85 280 NSC 800 “If a continuous, bandwidth-lim- Hitachi HD64180 Mot. 68k,&lO ited signal contains no frequency com- ponents higher than f,, then the origi- New nal signal can be recovered without Zilog 28 Zilog Super 8 distortion if it is sampled at a rate of at . All products require an IBM PC or compatible. least 2f, samples per second.” The best way to understand this is to consider the diagrams in Figure 6. For Information Or To Order Call: Here, Figure 6a shows the frequency spectrumof a continuous bandwidth- PseudoCorp limited analog signal with frequency 716 Thimble Shoals Blvd, Suite E components out to f,. When the signal Newport News, VA 23606 is sampled at a rate off,, the modula- (804) 873-1947 FAX:(804)873-2154 ,. ,__^~ A_- ,,.TT December ‘PO/January ‘9 1 23 analog signal to less than half the sampling frequency in order to elimi- nate frequency folding.

SETTLING TIME

An important aspect of any data acquisition system is called the set- tling time. That is, “the time elapsed from the application of a full-scale step input to a circuit to the time when the output has entered and remained within a specified error band around its final value.” Its importance lies in the fact that our DAAC system is made up of sev- eral analog operations which must be performed in a set sequence. As such, each operation must be accurately settled before the next operation can Figure 8-The length of un amplifier’s setMng time depends on how long it takes the be initiated. For example, a buffer output to sew/e info the limits of the error band. amplifierprecedinganA/Dconverter nal signal spectrum. As a result, the device that measures a physical pa- must have accurately settled before folded part of the spectrum causes rameter (our pressure transducer or the converter can do its thing. An distortion in the recovered signal. thermocouple) and thenamplifiesand example of this settling time is shown Otherwise, if the sampling rate is in- filters it. both are critical to the sys- in Figure 8. Here a full-step input creased tof,-f, > f,, then the two spec- tem’s overall performance. The am- which has been submitted to an am- tra are separated and the original sig- plifier may act to boost the signal plifier is followed by a small time delay nal can be recovered without distor- amplitude, buffer the signal, convert a afterwhichtheamplifieroutputslews tion. Therefore, frequency folding can signal current into a voltage, or extract or changes its maximum rate result- be eliminated by either using a suffi- a differential from common-mode ing from internal amplifier currents ciently fast sampling rate or by filter- noise. A filter, typically a low-pass which must change internal capaci- ing the signal before sampling to limit antialiasing filter, is often used to tances. Then, as the amplifier ap- its bandwidth to fs/2. reduce man-made electrical interfer- proaches its peak value, it may over- Figure 7 demonstrates the effect ence noise, reduce electronic noise, shoot and then reverse and under- of an inadequate sampling rate on the and to limit the bandwidth of the shoot the full-scale value before fi- sinusoid in Figure 5. If a nally entering and remain- sampling rate less than ing within the specified twice per cycle is employed, error band. As seen within an alias frequency in the , Figure 8, this settling time

recovered signal willresult. I is measured from the start

However, if, according to , time to the final entry into the Sampling Theorem, we ;ja. 314 Full __ the specified error band usearategreaterthantwice Scale 1 ,,/~ (typically fO.Ol% to -to.1 % 2 a cycle, the original fre- , of the full-scale transition). quency will be preserved. 2 Q ;’ 2 112 Full __ , ANALOG MULTIPLEXERS a Scale , , AMPLIFIERS AND FILTERS t*I , . , I An analog multiplexer I’m not going to say too , I is the device which time- l/4 Full __ . much about amplifiers and Scale , shares an A/D converter , I filters within this article, , between a number of ana- since most of you have been log input channels. It is repeatedly exposed to those composed of an array of devices. Suffice it to say that 000 001 010 011 100 101 110 111 parallel switches con- the front end of our DAAC Input Code Word nected to a common input system (shown in Figure 1) line (with only a single extracts a signal from a Figure 9-The transfer function of an ideal 3-bit DAC. feedthrough active at one rM

FS Converts your PC into i Brainwave Entrainqq 314 Afl.&g machine output ,R Output Glitches or Spikes 1

114 irsJA

Register Actuator

Sample Hold L v out

Tktis unique new hardware- ftware combination turns your ;3XT/AT/386 or clone into a la1>-grade, audio/visual brainwave sYnthesizer. The Synergizer uses P’ecisely controlled light and sounc Pa ttems to safely induce electrical adtivity in the brain, providing easy act:ess to Alpha and Theta states.

Deglitchsd WA Converter Features of the Synergizer include: il%dependent light and sound co:ntrol, multiple time ramps and Figure ICI--uurpuT splrtes (glitches) and a deglltched DAC-actuator system. so1und/light levels (over 32,000), on-board stereo sound generation time), and a decoder-driver circuit cross talk-the ratio of the output with waveform, filter and other which decodes a binary input word voltage to the input voltage with all so1und parameter controls, and an that specifies the appropriate switch channels connected in parallel and off oPNtional Software Toolkit. The latter setting. The decoder-driver interfaces (usually expressed as an input-to- Pr ’ svides the source and object code with standard TTL logic. output attenuation ratio in decibels). necessary to custom program the Primary characteristics of the To realize a large number of multi- III7it. The Synergizer provides more multiplexer, which you should keep plexed channels, you can connect ca13ability than any other similar track of, are: analog multiplexers in parallel (called device at a remarkably low price. Rtsquires DOS 3.0 or above, 512 K transfer error-this is defined as single-level multiplexing) using the &2M, and hard drive. the input-to-output error of the multi- enable input to control each device. It plexer with the source and load con- is also possible to connect the output MINDSEYE SYNERGIZER $395 nected, expressed as a percent of in- of several multiplexers to theinputsof Board. software. liehts. manual. put voltage. EXTERNAL CdNTRbL UNIT $95 another (called double-level multi- software-assignable controls. break-before-make switch-a small plexing) to expand the number of STUDIO TYPE HEADPHONES $35 time delay between the connection to channels. standard MlnlStereo plug. the next channel and disconnection SOmARE TOOLKIT $50 from the previous channel which as- DIGITAL-TO-ANALOG CONVERTERS sures that the two adjacent channels are never simultaneously connected D/A converters (DACs) are the SYNETIC together. devices used by computers for com- SYSTEMS The leader in Personal Mind-Tech settling time-defined the same as munications with the real world. They in our amplifier example except that it are employed in a variety of ways, is referenced from the time the chan- such as for CRT displays, voice syn- ORDER PHONE nel is turned on. thesis, automatic test systems, digi- 800-388-6345 fhroughpuf rate-the highest rate tally controlled actuators, and so on. Credit Cards Accepted atwhichamultiplexercanswitchfrom To understand how such a device Information: 206-632-l 722 channel to channel with the output works, consider the transfer functioxi PO Box 95530 Seattle, Washington 98145 settling to its specified accuracy. for a 3-bit DAC shown in Figure 9. (il 14,

Reader Service ~#I89 December ‘9O/Jonuary ‘9 1 27 configuration that provides a maximum deviation of the actual deglitched analog signal to our feed- transferfunctionfromanidealstraight back control device actuator (of the line at any point along the function. It pressure valve or heating element). is expressed as a percent of the full All D/A converters produce output scale or in least-significant bit size. It spikes, or glitches. They are most seri- assumes that the offset and gainerrors ous at transitions of l/4,1/2, and 3/ have been adjusted to zero. 4 of the full scale (fs). An example of Today, most A/D and D/A con- this is shown in Figure 10. They are verters enable external trimming of caused by the small time differences offset and gain errors, at least at ambi- between current sources being turned ent temperature. Nonlinearity error, off and on within the D/A converter. however, cannot be adjusted out and Take for example the major code tran- remains an inherent characteristic of sition at half scale from 0111.. .llll to the converter. 1000...0000. Here the MSB (leftmost But remember, be careful when bit in the converter) current source you operate a converter over a signifi- tumson while all othercurrent sources cant temperature range. Theeffect due are off. As a result, the small differ- to this change must be carefully deter- ence in switching time causes a nar- mined. Of key importance is whether row half-scale spike which could cause the device remains monotonic; that is, a hiccup in a finely tuned actuator. whether it has missing codes. This can To overcome this problem, the be determined by computing the “dif- digital input to the DAC is controlled ferential nonlinearity tempco” speci- by an input register while the con- fied for the converter. If you assume verter output is stored on a sample- that the converter has at least half the and-hold. When the digital input is least-significant bit of differential non- upgraded by the register, the sample- linearity error, then the change in and-hold is switched into the hold temperature resulting in an increase mode. After the DAC has changed to to 1 can be written as, its new value with all spikes settled *t = 2-” x lo6 out, the sample-and-hold is then switched back into a tracking mode. 2DLT As a result of this process, the output where n is the converter resolution in changes smoothly from its previous bits and DLT is the specified differen- value to the new value. tial nonlinearity tempco in parts per million (ppm) of full-scale range per ERROR FUNCTIONS IN A/D AND degree Celsius. Here, t is the maxi- gure 11 --Most A/D and D/A converters troduce some degree ofoffset, gain, and/ D/A CONVERTERS mum change in temperature that the of nonlinearity error. convertercanhandlebeforeitbecomes Of course, actual A/D and D/A non-monotonic. Here, each input code word produces converters don’t have the wonderful/ This suggests that an organized a single discrete analog output value, ideal transfer functions I’ve described approach be undertaken when you generally as a voltage. There are 2” dif- above. In reality they contain three design your DAAC system. The A/D ferent values produced including zero, different types of operational errors, and D/A converters are the primary with that output having a one-to-one called offset, gain, and nonlinearity components. so you should draw up a correspondence with the input. errors. They are all functions of time checklist of required characteristics There are many different ap- and temperature and they all appear which, at minimum, should include proaches used for DAC implementa- simultaneously. the following key items: tion, but most in use are of the parallel Examples of these error functions type, where all bits change simultane- are shown in Figure 11. They are de- 1. converter type ously upon application of an input fined as: 2. resolution code word. Serial-type converters, on offset error results from transfer 3. speed the other hand, produce an analog function failure to pass through zero. 4. temperature coefficient output only after receiving all digital gain error is the difference in slope input data in sequential form. between the actual transfer function After your choice has been nar- To employ a DAC within our anditsidealone.Itisusuallyexpressed rowed down by these considerations, process control application (see Fig- as a percent of analog magnitude. you should then determine how your ure 11, I have chosen to describe a nonlinearity error is defined as the system fits the following:

28 CIRCUIT CELLAR INK 1. analog signal range environment because of the large *Analog-out (D/A only) with 4- 2. type of coding number of data channels and the need to 64-channel output capability.

3. input impedance for fast multitasking environments. l Analog-out expander boards for 4. power supply requirements However, in simpler systems, where multichannel analog out capability. 5. digital interface required the number of data channels is less l CombinationA/D/Aunitswith 6. nonlinearity error thanlOO,thePChascomeintoitsown. 8 to 64 analog I/O channels. 7. output current drive This is where the steadily increasing To be honest, there are other con- 8. type of start, stop, and status computing power of the PC has made figurations, but you get the point. signals consistent inroads. Systems with fewer There is a whole realm of real PC- 9. size and weight analog channels allow having the oriented application DAAC system analog circuity located directly on the components available. The availabil- APPLICATIONS OF DAAC SYSTEMS same printed circuit board as the I/O ity of hardware and associated driver interface logic. The card is made to software has made the “desktop” PC Recently there has been marked just drop into any of your 16-bit or 32- a necessary part of the well-equipped enthusiasmforusingmicrocomputers bit slots with the analog input coming lab or shop floor.+@ for data acquisition and control. It is directly from the amplifier or your currently estimated that nearly40%of transducer. A multiplexer in front of Chris Garcia has a Ph.D. in experimental all computer applications require some the card enables the PC to handle nuclear physics and is currently working as a form of analog I/O. And of that, it’s multiple channels on the same card. staffphysicist at a national lab. He has exten- estimated that more than half use a PC Theresultis thatthisunitcanbetreated sive experience in computer modeling of ex- perimental systems, image processing, and in one form or another. Of course, the as a standard I/O peripheral using artificial intelligence. Chris is also a principal actual applicationdeterminesboth the canned software drivers. Examples of in Tardis Systems. type and number of analog signals in- different peripheral configurations volved. In most industrial process that you can find on the market are: control or monitoring operations, DAnalog-in (A/D only) with 8- to IRS hundreds of control points are con- 256channel input capability. 403 Very Useful tinuously processed. These systems *Expandersforapplicationsneed- 404 Moderately Useful usually don’t lend themselves to a PC ing extra analog channels. 405 Not Useful

PC-Based Logic Analyzers illips-8xc552 based Microcontroller Board Hardware: . 8~~552 CPU l wire wrap area with uncommitted DIN 41612 connector l RS232 interface-9 way (AT) or 25 way (XT) connector l Single 5 volt supply l Power fail detect l Processor contains: I’C, 8 channel 10 bit ADC 2 channel PWM 16 extra l/O lines over Application areas: 8031

l real time control Multi function l Data Acquisition timer/counter with Sophisticated Logic Analysis capture and compare l software/development a’, Unsophisticated Prices evaluation Production l Standard 8031 peripherals I/O, serial port, timers, ID160 (50 MHz) for $695 Software: ram, etc. *ID161 (100 MHz) for $895 l Powerful Monitor/ *SO MHz or 100 MHz Sampling l 8K Trace Buffer l 32-channel Debugger PROM included Operation *Multi-Level Triggering *State Pass Counting l BASIC, Forth, Assembler, l Event Timer/Counter l Performance Histograms l Hardcopy Monitor (optional) $495P0 Futput *Disassembles popular E-bit micros *and much more ! 30 Day Money Back Guarantee FM 603-469-3.530 l 603-469-3232 INNOTEC DESIGN, INC. Binary Technology, Inc. 6910 Oslo Circle, Suite 207 Buena Park, CA 90621 a P 0. Em 67 e Meriden. NH 03770 Mav S+wze+ WEE3 Tel: 714-522-1469 FAX:714-527-1812 L q

Reader Service #I& 30 CIRCUIJ CELLAR INK New Products Low cost Alpha Products proudly announces two new product lines: CNel serial communications Data Acquisition devices, and Alpha Box interfaces. These new products are not merely A-Bus and Control accessories. but complete sets of products A-Bus Sensing 6 Measuring: for all of your interfacing needs. Read switch status. Detect or measure voltage. Read pressure, temperature, weight All the products are used to connect different and other sensors. For example: types of devices to your computer. Our l High-Speed 1 P-bit A/D converter: 8 lOus communications devices help you connect analog inputs. 1 mV resolution $179 devices that have computer interfaces l 8 Bit A/D: 8 inputs, 0-5.1V in 20mV steps, already built in. C-Net provides the option of 7580 conversions/set. $142 .._. connecting many diierent M-232 devices ---_.A%. _. .___.. l 12 Bii A/D: *4V in 1 mV steps. 13OmS to a single serial port on your computer. We “We can make your PC do things you conversion time. 1 input. expandable $153 also carry converters to other standards, wouldn’t believe.” ’ Temperature Sensor: 0-29O’F lo including M-422, RS-485 and IEEE-488. Accuracy. 1omVPF. $12 l CNet Adapter. Connects the master control l Digital Input: 8 opto-isolated. Read voltage computer to CNet. $74 C” From Your PC presenceswitch closure. $85 l Quad CNet Module: Connect 4 RS-232 . Command l Latched Input: Each individually latched to serial devices to CNet. Each device is - Control catch switch closures or alarm loops. 885 configurable (baud rate, parity. etc.) and has - Communlcatlons ’ Touch Tone Decoder: $87 4.8K byte input and output buffers. 9895 l Counter/Timer: 3 18-bit counters. Generate ’ CNet Device Module: Connect any RS- Bring new dimensions to your computer with or count pulses. Time events. $132 A.Bus. CNet and Alpha Boxes. No longer is 232 Device to CNet for data collection or l Clock with Alarm: real time clock with communication, with handshaking. $195 your computer limited to number crunching calendar and battery backup. 998 or word processing. Now you can connect it Alpha Boxes and A.Bus cards both provide to all kinds of equipment. sensors or A-Bus Switching 81 Governing: ways to interface other types of devices to machines. This offers unprecedented power Switch any type of electrical device. Adjust your computer. Alpha Boxee sense, from production lines to experiments to home level or position. A sampling: control. measure, switch and govern. They feature: l Relay Card: 8 individually controlled l Each box is an attractively packaged self industrial relays. 3A at 12OVAC. SPST. $142 Each product is designed to fit your needs: contained module that connects directly to l Digital Output Driver: 8 outputs: 250mA at the computer and includes power supply. They’re affordable. Compare our prices: the 12V. For relays. solenoids... $78 cost of a solution is surprisingly low. l The input boxes offer the option of logging ’ Reed Relay Card: 8 individually controlled data “off-line” and downloading it rapidly to They’re simple and easy to connect to your relays. 2OmA @ 8OVDC. SPST. $109 computer and your application. and carefully the computer. l Multiplexer: Switch up to 32 channels to a designed to adapt to your software easily. l Built-in intelligence provides a simple and single common. $83 They’re vereatile. An infinite number of consistent interface to your software. l Smart Stepper Motor Control: Micropro- combinations is possible: one of them is right cessor controls 4 motors. English commands A Sampling of Alpha Box Products: for you. Easily expanded or changed for for position, speed, units, limits, etc. $299 future projects. l Digital input: 84 lTL/CMOS/0,5V input ’ Telephone Control Card: On/off hook. channels. $495 They’re proven. We have customers around generate and decode touch tones, call ’ Digital Output: 84 lTUCMOS/O.5V level the world. including Fortune 100 companies, progress detection. $159 outputs. 9495. 12OVAC control available. most major universities, governments and ’ X-10 Controller: Control and sense ’ Digital I/O: 32 TTL Level (0.5V) Inputs and individuals. standard wall outlet power modules. $149 32 outputs. 8495 ’ Voice Synthesizer: Unlimited vocabulary, l Analog Input: 18 channels. 0-5.1V. 20mV text to speech sofbvare built in. $159 steps (8 bit). 2000 readings/set. 9495. ’ D/A: Four 8 Bit Outputs. Adjustable full Expansion Option: 18 more channels. $100 scale. $149 ’ 12 Bit Analog Input: 18 channels, Overseas distributors ’ 24 line lTL I/O: Connect 24 signal. TTL programmable gain. 1OOOg inputslsec. max. UK: Pinna Electronics. Scotland 0/5V levels of switches. (8255A) $72 8995. Option: 18 more inputs. 82rXl Tel: (9294) 805298 Fax: (9294) 88288 ’ Analog Output: 4 channel. 12 bii D/A. *5.1V Ada: Batam DA, Singapore A*Bus Adapters and Software: outputs. 9495. Expander Option: 12 more Tel: 473-4518 Fax: 479-8498 Adapters connect AsBus cards to your outputs. $200 Scandinavia: A/S Con-Trade Norway particular computer. l Counter: 18 inputs, 24 bit. $595 Tel: (94) 41 83 51 Fax: (94) 4194 72 ’ Plug-in adapters for IBM PC/XT/AT/388 and compatibles ($89). Micro-Channel ($93) Apple II. Commodore, TRS-80.

l Serial adapters for Mac, PC, etc. ’ Odin PC compatible software. Control relays from analog inputs or time schedules. 242-C West Ave, Darien, CT 06820 USA (203) 656-l 806 Fax 203 656 0756 Logging. Runs in background. $129

Reader Senke # 105 December ‘9O/January ‘9 1 3 1 FEATURE ARTICLE An Interface for Portable Tim McDonough Battery-Backed RAM & Bruce Webb Using the Mitsubishi BEE Card for Nonvolatile Data Storage

CL V I ou can’t take it with you.” The SRAM version of the BEE card other RAM device in the computer’s Notc so long ago, the adage about we used has 32K of 250-ns CMOS memory map. There are no special wealth and death held with equal static RAM (Mitsubishi part no. disk drive interfaces to build and no validity for portable or remote data 0256SRMSP25). Power consumption disk BIOS to write as there would be gatheringapplications. Portableunits is 200 milliwatts maximum at 5 volts had we incorporated a disk drive. Se- lacked the power to support floppy and the package has a rated operating lecting the32Ksizeallowed us to place disk drives, and networks are simply temperature of 060°C. Each card some conventional EPROM and not feasible in every situation. Fortu- measures 54 mm wide by 86 mm long SRAM on the board and still address nately, engineers have provided sev- and is approximately 2.3 mm thick. the BEE card within the 8031’s 64K eral possible solutions to the data The card includes a holder for a thin, addressspace withoutaddingany sort portability problem in recent months. circularlithiumbattery(typeCR-2016) of a bank switching scheme. One solution gaining acceptance is that provides power to retain the cards The second reason for using the the “data card”-a credit card-sized data any time external power is not BEE card is it has no moving parts device containing battery-backed supplied. Mitsubishi rates battery life such as drive motors that generate RAM. at 4 years when operated at 25°C. A heat, collect dirt, and make noise, or Credit card-styleRAM cards have write-protect switch, located on the heads to go out of alignment. Since the recently appeared in such consumer end of the card, can be used to protect BEE card is all solid-state, battery- products as video games and even datafrombeingaccidentallyoverwrit- backed SRAM, it has none of these personal computers such as the Atari ten if desired. shortcomings. Most of the flexibility Portfolio pocket computer. These A 32K BEE card was chosen for of toting around a floppy disk is re- applications typically use a mask-pro- several reasons. First, using the BEE tained, although in our case not quite grammed ROM card or a similar one- card as a mass storage device is very as much data storage is available. time-programmable ROM card, but straightforward. It can be read the RAM cards are also available in from and written to - Photo 1 -The Datalog-R_ I allows the EEPROM and battery-backed SRAM ... fheuse versions that make them ideal for without storing and transporting infor- ma tinn available RAM card storage capacities range from 8K bytes to 1 megabyte of stor- age. Recently, we designed a basic general-purpose single-board computer, the Datalog-R I (pronounced “data logger,one”;seePhoto l), that could be used for simple process-control functions and would also provide nonvolatile, removable storage. We chose to incorporate a 32K-byte “BEE card” from Mitsubishi Plastics in our design.

32 C/RClJ/T CELLAR INK 8031 TO THE RESCUE the 8031’s *PSEN and +RD signals to serves as a mass storage device in this derive a three-wire bus that can be system, the RAM/ROM/BOTH op- A schematic of our design is used to configure on-board memory tions are not jumper selectable. shown in Figure 1. The size of the fin- in one of three ways. The jumpers Other connections to the BEE card ished board, without the BEE card allow each 8K device to be designated are similar to any other memory de- inserted,is4.5”by6.0”. A34-pinheader as RAM or EPROM like you might ex- vice. *WR, *RD, high-order address provides access to ports 1 and 3 of the pect. A third position, “BOTH,” causes lines,anddemultiplexeddataandlow- 8031 as well as providing access to the the 8031’s Program and Data memory order address lines are all run to the 5-volt DC power bus and ground con- spaces to be overlapped within a given special 32-contact socket where the nections. Additional connections are 8K block. This option is provided to BEE card itself is inserted. provided for an RS-232-compatible allow compatibility with certain ver- The printed circuit board for the serial communications port and an sions of Forth and other high-level Datalog-R I includes space for a 5-volt external reset switch for the 8031. languages that require a single, com- DC regulator to make it simple to run Aside from the use of the BEE bined memory space for proper op- the data logging system from an exter- card, the system is a fairly conven- eration. nal 12-volt power source. Twelve volts tional 8031-based single-board com- A jumper is also provided on pin DC is readily available in vehicles and puter that should be quite familiar to 31 of the CPU to enable or disable the is easily obtained in out-of-the-way C~~curr C~LAR INK readers. A 74LS138 internal ROM found in some 8051 locations where instrumentation and address decoder provides selection of family . This makes i t sensing equipment are often powered 8K memory devices at OOOOH, 2OOOH, possible to use mask-programmed by photovoltaic arrays that charge 40OOH, and 6000H. Jumper blocks on 8031 microcontroller derivatives such secondary storage batteries. the *CE line of each 2%pin socket let as the Micromint 8OC52-BASIC CPU theuserselectthebaseaddressofeach or the Intel 8052AH-BASIC CPU. MOVING THE DATA package depending on individual A third gate in the 74LSO0 pack- needs. age is used to generate a *BCS (BEE Although perhaps not typical of a Two gates of a 74LSO0 NAND Card Select) signal from address line logging device, we chose to equip our package are used in conjunction with 15 of the CPU. Since the BEE card design with an RS-232-compatible

f

,- *- T0 RO I’ DATA BUS . Figure 1 a- The Datalog-R I consists of a basic 803 1 circuit with a simple expansion header.

December ‘90/January ‘9 1 33 communications port. The port is tion when the total volume of data is probe might be sampled four times implemented using the 8031’s built-in small. per hour and its 8-bit value stored UARTand a Maxim MAX232 to main- along with the time and date to the tain single-voltage power supply IN THE FIELD BEE card. Even without doing any operation. An 11.0592-MHz crystal clever programming to compress the allows no-hassle programming of Using the Datalog-R is quite information, data stored in a format standard data rates from 1200 through simple. Although we have inserted such as YYMMDDHHMMcdata 9600 bps. and removed the RAM card from an byte> would allow for an entire A serial port makes sense in this operating system many times, it is month’s (31 days) worth of data to be application for a couple of reasons. advisable to have the power off when- collected before the BEE card needed First, and most important, it allows a ever swapping cards. This avoids the to be changed. Throw out the year and Datalog-R board with appropriate possibility of inserting or removing the month, or write them only once as firmware to be used as an inexpensive the card while it is being accessed by “header” information whenever the BEE card reader back at the lab so the the 8031 and perhaps corrupting the system is powered up and the storage user can move the collected data to data or damaging the card. time can easily be stretched to fourty- another computer for analysis and The BEE card is inserted in the eight days! further processing. Second, we recog- Datalog-R with the legends and the Our approach with this design nized that there is a lot of scientific electrical contacts facing up. Once a was to build a system that was appro- instrumentation equipped with com- card is inserted, power is applied to priate for smaller, simple applications. munications ports that the original the computer and the system is reset. It has helped us solve some unique manufacturer assumed would be In most cases customers have devel- problems and we’ve gained valuable connected directly to a host computer. oped their final applications to begin experience regarding the use of “RAM By using a Datalog-R as a sort of “mini running immediately after reset, re- card” technology along the way.+ host” that polls the equipment for quiring no further operator interven- information and stores it in the BEE tion. We would like to thank Claire Bienen at Mit- card, it is possible to use the equip- A 32K BEE card holds a lot of data subishilnternationalforhelpingout withtech- ment in a remote location without if you choose your storage algorithm nical information, support, and of course the having to dedicate a PC or an expen- correctly. In a typical temperature BEE cards used in OUY original prototype. sive computer to data collec- loggingapplication, a thermistor-type Many thanksalsogo to Carl Baxter of Business and Technical Consultants for his real-world testing of several early prototypes.

1 R-535 Prototyping Board with R-Ware 1 Tim McDonough and Bruce Webb are princi- pals in Cottage Resources Corporation. A Comolete Svstem for Developing Embedded Control Applicitions a Sources Board includes: power supply, 80535 processor ( enhanced 8052 with 3 timers plus watchdog timer and 12 Mitsubishi International, Inc. interrupt. sources at 4 programmable 520 Madison Avenue priority levels), up to 128 k on-board New York, NY 10022 memory, Eprom burner, RS-232 serial port at 9600 Baud, 28 digital I/O An assembled and tested Datalog-R lines, 8 analog input lines, 2-l/8” by I (less the 32K BEE card) is available 6-l/2” breadboard with 8 pushbuttons, for $179.95 (plus $3.00 S&H per 8 to gle switches, 16 LEDs, 2 numeric disp9 ays. order). 32K BEE cards are available for$57.95 each when purchased with R-Ware includes: ROM resident monitor the Datalog-R I. program and PC-based ti;egr&f menudriven software Cottage Resources Corporation assembly, PC-to-board communication: 1405 Stevenson Dr., Ste 3-672 download and debug. Springfield, IL 62703 Plus user’s manual and control (217) 529-7679 experiments with example software. Prices start at $395.- RIGEL CORPORATION IRS P.O. Box 90040 406 Very Useful Gainesville, FL 32607 407 Moderately Useful (904) 373-4629 408 Not Useful

Reader Service X11 34 ClRClJfJ CELL4 R INK Figure 1 b--The second half of the schematic shows a bank of on-board RAM and EPROM plus the socket for the BEE card.

WITH VOICE MASTER KEY@ FOR PCs/COMPATIBLES VOICE RECOGN/T/ON W/TH SPEECH RESPONSE Rm=IT GIVE A NEW DtMENStON TO PERSONAL COMPUTtNG The amazing Voice --Master Key System adds voice recognition to just about any program or application. 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 response time and high recognition accuracy. A real productivity enhancer! SPEECH RECORDING SOFTWARE Digitally record your own speech, sound, or music to put into your own software programs. Software provides sampling rate variations, graphics-based editing, and data compression utlllties. Create software sound files, voice memos, more Send voice mail through LANs or modem. A superfor speech/sound development tool. INTERACTIVE SPEECH INPUT/OUT- o Emulates up to 8 l- @Accepts Intel Hex, PUT Tao vour own diaitized soeech files to voice re&gnition macyos. Proiides speech Megabit EPROMS with Motorola S-Record, and response to your spoken commands -- all one control card. Binary files. from within your application sofhvare! Ideal for business, presentation, education, or 0 Downloads l-Megabit l Software available for entertainment programs you currently use Augment the system for wireless uses in robotics, factory process controls, home programs in less than 10 IBM PC and automation. new products, etc. Voice Master Key System does it all! seconds. systems. EVERYTHING INCLUDED Voice Master Key System consists of a plug-in card, durable lightwght microphone headset, software, and manual. Card fits any l AIIOWS examination available slot. External ports consist of mic Inputs and volume controlled output and modification of in- Call or fax today for sockets. High quality throughout, easy and fun to use. dividual bytes or blocks. more information! ONLY $149.95 COMPLETE ORDER HOTLINE: (503) 342-1271 Monday-Friday 6 AM to 5 PM Pacific Time VISAJMasterCard phone or FAX orders accepted. No CODS. Personal checks Base 27256 EPROM System $395.00 subject to 3 week shipping delay. Specify computer type and disk format (3 l/2” or 5 Other configurations available. l/4”) when ordering. Add $5 shlpping charge for dellvery in USA and Canada. Foreign inquiries contact Covox for C & F quotes. Incredible Technologies, Inc. 3ODAYMONEYt?ACKGUAB4NTEE/FNOTCOMPLETEL YSAT/Sf/ED 709 West Algonquin Road n CALL OR WRITE FOR FREE PRODUCT CATALOG. Arlington Her hts, Illinois 60005 . (708) 437-243% Fax (708) 437-2473 COVOX INC. 675 CONGER ST. TEL: (503) 342-1271 Visa, Mastercard, and American Express accepted. EUGENE, OR 97402 FAX: (503) 342-i 283

Reader Setice Y142 coderw SW&Y3 #127 December ‘PO/January ‘9 1 35 1 FEATURE 1 ARTICLE Using the Steve Ciarcla Motorola MC68HCll & Burt Brown A Venerable History and a Cerfain Future

I come from the school that says microcontroller chips very different. Using the 68HCllA1, we were all computers are equal, some just run While the RTC52 generally meets all able to put functions like parallel I/O, a little faster than others. Provided my programming objectives and can battery-backed RAM, EPROM, that the price is not the overriding be expanded to include lots of I/O, EEPROM, watchdog timer, battery- issue (such as 8088 chips suddenly multiple boards cannot always be backed clock/calendar, serial ports, being regularly priced at 39q each), I accommodated in every application. I and an A/D converter in a low-cost generally choose a processor for my still see the need for a more highly 3.5”~ 4.5” form factor. Combined with projects based on ease of use and ease integrated very low power single- high-level languages, cross-assem- of explanation. In point of fact, how- board microcontroller for future proj- blers, and a monitor, this RTC-HCll ever, most of my projects treat the mi- ects. board offersa formidable platform for crocontroller as a ge- many fut&e Circuit neric device. I may state Cellar projects. theprocessortypebut1 Of course, we have use high-level lan- to start some place, and guages so that the code I can’t just drop an is transportable and not RTC-HCll into some processor specific. project without detail- For me, develop ing the design of it for you beforehand. After ment tools and low-cost 8W32K high-level language RAM/EPROM you familiarize your- support take prece- I MC68HCll Al self with the 68HCll dence over issues like Microcontroller from the sidebar, I’ll fill brand loyalty. As most you in on the specifics of you already know, I of the RTC-HCll don’t like to program board architecture, at- any more than I have to: ND Converter tributes, and memory I usually use a control- map. Finally, with help lerboardwithan8OC52- from Burt, I’ll address RTC Stacking some software, devel- BASIC processor that Expansion Bus can be directly pro- opment tools, andpro- grammed in BASIC. Figure 1 -Funcfiona/ block diagram of the RTC-HC I 1. gramming examples Many of my applica- for the RTC-HCll. tions-oriented projects have been At first I considered using the new greatlyexpeditedbyincorporatingoff- Signetics 8031-based super chips and THE BASICS the-shelf BCC52 and RTC52 control- porting BASIC-52 to them, but I was lers rather than reinventing the wheel advised that it would be an ordeal and The RTC-HCll is a single-board, each time. that there were many incompatibili- g-bit computer/controller based on While I’ll be the first to say that a ties. Instead, thanks to a vocal group the Motorola MC68HCllAl MCU. computer is a computer, I temper that of Circuit Cellar BBSers who offered Like the 8031- and V25-based designs assertion with a little reality. When it opinions, I ended up selecting the Mo- previously presented in the pages of comes down to fitting a variety of torola 68HCll. The 68HCllAl chip CIRCXT CELLAR INK, [Editor’s Note: specific control functions on a few (see sidebar) is a wonderfully func- See “Creating a Network-Based Embed- square inches of PC board, integration tional microcontroller which offers ded Controller,” CIRCUIT CELLAR INK #8; density and on-chip attributes make considerable on-chip attributes. and “PC Programming Comes to Embed-

36 ClRCUlT CELLAR INK ded Control,” CIRCUIT CELLAR INK #27.1 the RTC-HCll uses the same dual vertical-stacking I/O expansion bus. I took advantage of the 68HCllAl to build the following features onto the board:

*Motorola MC68HCllAl MCU running at 8.00 MHz *Up to 21 bits of TTL-level I/O (8 bits are shared with ADC) aAsynchronous serial port; either full-duplex RS-232 or half-duplex RS-485 Gynchronousserialport withdata transfer rate of up to 1 MHz l 8-channel, 8-bit A/D converter 0512 bytes of EEPROM *Battery-backed real-time clock/ calendar ‘Up to 64K of on-board RAM/ Figure 2-7he block diagram for the MC68HC 11 MCU shows a host of on-board devices. EPROM, 32K bytes of battery- backed RAM address space and while the MCU is INTERNAL AND EXTERNAL MEMORY *Five-volt-only operation in any of four different operating *Small 3.5” x 4.5” form factor modes. (See the sidebar and Figure 2 Up to 64K of external memory can *Compatible with RTC-series I/O on MCU operating modes for a more beusedontheRTC-HCllboard.There expansion boards detailed discussion.) Included on the are two sockets (U8 and U9), which processor itself are a 16bit timer sub- can each accept an 8K or 32K static RTC-HC 11 HARDWARE system with programmable prescaler RAM or EPROM. A Dallas Semicon- and S-bit pulse accumulator; a stan- ductor DS1210 power fail/battery AnRTC-HCl 1 computer/control- dard NRZ asynchronous serial inter- backup chip converts one of the exter- ler board is composed of the three face; a high-speed synchronous serial nal memory sockets into nonvolatile distinct hardware subsystems shown interface; an eight-channel g-bit A/D memory for data logging or program in Figure 1. These include the MCU converter; 512 bytes of EEPROM; 256 development purposes. In a typical itself and its associated I/O and reset bytes of static RAM; and “Computer RTC-HC11 system (shown schemati- circuitry; external RAM, EPROM, and Operating Properly” (COP) and clock cally in Figure 3), U8 will contain memory address decoding; and the monitor watchdog timers. EPROM and U9 will contain RAM. on-board real-time clock/calendar In addition, there are seventeen The 68HCll MCU contains 256 with battery backup and write-pro- hardware interrupts and one software bytes of internal RAM located at ad- tect circuitry. interrupt with all on-chip interrupt dresses $0000 through $0100. This At the heart of the RTC-HCll sources being maskable. Two external memory region is also referred to as board lies a PLCC-packaged Motor- inpu ts,IRQ (*INTll and XIRQ (*INTO) “page zero” RAM. Typically, a pro- ola MC68HCllAl HCMOS microcon- are provided for interfacing to other gram will place data which needs to troller unit (MCU). This is a high- devices with the IRQ input being pro- be frequently accessed in this area. speed, low-power, fully static MCU grammable for either edge- or level- There are also several machine lan- design featuring over half a dozen sensitive operation. guage instructions which operate sophisticated on-chip peripherals. In Software features include low- exclusively on data in this area. The fact, all of the on-board I/O devices power STOP and WAIT modes which Al-version MCU also contains 512 with the exception of the real-time can be exited by internal or external bytes of nonvolatile EEPROM mem- clock arelocated within the MCU, and interrupts and a special “wake-up” ory. Each byte may be individually an RTC-HCll board can be stripped feature for using the asynchronous accessed and the entire memory array downtojusttwochips(the68HCllAl serial interface in networked systems. can easily be bulk erased. By default, and the MAX232) and still be able to Double accumulators and index reg- the EEPROM is located at addresses run small assembly language pro- isters along with a full complement of $B600 through $B7FF. This can be grams. bit manipulation and branch instruc- changed by reprogramming a con- All of the MCU’s subsystems can tions are provided. Six different ad- figuration register. be accessed by a program executing dressing modes allow for code opti- An 8K or 32K static memory chip from anywhere in the processor’s mization in all situations. may be inserted into U9 to provide

December ‘9a/January ‘9 1 37 &Ire Ja--The first half of the RTC-HCl 1 schematic shows the processor, bus buffers, I/O decoding, and serial interfaces. programs with additional memory. tain executable code and the MCU systems, most of the external I/O lines The U9 socket is decoded in the range will fetch its reset vector from loca- are shared with at least one other of $0000 to $7FFF. Reads or writes to tions $FFFE and $FFFF. In some situ- subsystem. For example, any or all of this area are disabled by the MCU ations, it may be desirable to install a the eight A/D converter inputs can during any access to an on-chip stor- low-power static RAM in U8 and also be used as TTL inputs. Thus, an age location. Access is also disabled configure the battery backup jumpers application which required only four for addresses $7COO to $7FFF by the to continuously maintain its contents. channels of A/D could use the re- U7 PAL (see Figure 4) if the I/O select maining four channels as TTL input. jumper for theon-boardreal-timeclock GETTING IN (AND OUT) This flexibility allows for allocation of is installed. The ROM monitor (BUF- on-chip resources with a minimum FALO 3.4) does not require the use of Since the 68HCll processor con- amount of waste. As a result, configu- external RAM. Several iumpers must tains several on-chip peripheral sub- ration of each on-chip subsystem be- be set to indicate the size comes somewhat compli- of the installed chip and cated with the 68HCll OKI = IA15 ‘A14 ‘A13 ‘Al2 ‘All * Al0 l BDIO to enable the battery CSRAM = /Al5 l /OKI having over sixty con- backupand write-protect X8000 = Al5 ‘IA14 l IA13 l /Al2 l SEL8 l E figuration registers, the circuitry. XAOOO = Al5 ‘/A14 * Al3 l IA12 ‘SELA l E details of which are be- XC000 = Al5 l Al4 l IA13 l /Al2 * SELC l E The U8 socket is de- yond the scope of this CSROM = Al5 * IX8000 l IXAOOO l /XC000 coded at addresses $8000 DS = E article. (Tofullyutilizeall to.$FFFF. During normal RD = RW l E the features of the RTC-HCll operating WR = IRW l E 68HCl1, I recommend modes, the chip inserted Figure I-Use of a PAL greatly reduces the number of discrete gates on obtaining a copy of either into this socket will con- the board. the “68HCll Program-

38 ClRCUlT CELLAR INK Quality U.S.-manufactured cards and software for single user, OEM, or embedded applications. NEW PRODUCTS! NEW CATALOG! NEW PRICES! mer’s Reference Manu or the upper conversion or Volume II of the “Motorola ange limit. Typically, this ref- Microprocessor, Microcontroller, erence will be set to 5.00 volts and Peripheral Databook.“) yieldingaconverterresolutionof5.00/ The RTC-HCll processor board 256 or 19.6 millivolts per step for an can decode up to three 8K blocks at &bit ADC. Source impedance for addresses $8000, $AOOO, and $COOO each channel should not exceed ten for use by off-board I/O devices or thousand ohms and total sample ac- - 4 CM./8 S.E. channels, 1Bbit resolution RTC-series expansion boards. In ad- - 2op A/D (lY&S or 8ps optional) quisition and conversion time for - Programmable gains of 1,2,4,8, & 16 dition, a 1K I/O block which is fixed each channel is on the order of - Three 8-M& timer/counters -Two 12-bit D/A outputs at address $7COO can be enabled to twenty-two microseconds. The ADC - 16 TTUCMOS digital I/O lines - Six-layered conskuction allow access to the on-board real-time reference voltage is set by an LM336 - Dedicated GND adiacent lo each analoa sianal clock/calendar. If one or more exter- reference diode set at 5.00 V. The - Supports twisted-iair or ribbon cable! - - nal I/O blocks are enabled, the chip LM336 is powered from the positive Call today for our new catalog featuring the select lines to the corresponding on- voltage output of the MAX232 RS-232 following hardware, software and much more! AD1000 8 S.E. channels; 12.bit 20 ps A/D; Function Connector(s) sample & hold; three ~-MHZ timer/counters; Namem 24 TTL/CMOS digital I/O lines. .._. $275 PORTA O-2 Input T3-1 -T3-8 ADA1100 AD1000 with 2-channel D/A and 3-6 output resistor-configurable gain ..,...__.....__. $365 7 Input/Output AD2000 8 Diff./l6 S.E. channels, 20 ps A/D; sample & hold; three &MHz timer/counters; PORTD O-5 Input/Output Jl-1,3,5,7,2 (J1-4,T3-10) binary programmable gains of 1,2,4,8, & 16; PORTE O-7 Input J2-6,8,10,12,14,16 16 TTL/CMOS digital I/O lines $359 IRQ Input JP15-13 ADA2000 AD2000 with 2-channel D/A and 40 ‘ITWCMOS digital I/O lines .__... $489 XIRQ Input T3-9, JP15-11 ADlOO/AD500 Single-channel/8-channel, RESET Input JP6-1 S.E., 12-bit integrating A/D; programmable J gains of I, 10, & 100 . . . . ,...... ,,. $1591259 ADA100 Single-channel, differential input, Iawe I - I IL-comparltxe ports on The MC68HC.Z IA 1 1. 12-bit integrating A/D; X-bit D/A output; pro- grammable gains of 1, 10, & 100. Plus 10 board RAM or EPROM are held high driver. This chip must be installed for TTL/CMOS digital l/O lines. .._...... __. $219 ADA300 &channel R-bit 25 ps A/D; single 8- whenever the external device is being the ADC to operate to its maximum bit D/A; 24 TTL/CMOS digital I/O __ $199 accessed. range. DA600/DA700 Fast-settling 2/4/6/8 -channel Up to 21 bits of TTL (logic level) Each of the eight input channels 12-bit D/A; double buffered ,... $1921359 DG24/48/72/96 ‘ITL/CMOS digital I/O cards I/O can be utilized on the RTC-HCll can be read and the resulting voltage with up to 96 lines; 8255.based; Opt. buffers processor, however several of these calculated as follows: and pull-up resistors $110/256 TC24 Five ~-MHZ timer/counters; uses pow- lines are input-only, output-only, or erfulAM95 13Achip; 24digital I/Olinesfrom shared with another subsystem. Table Input voltage = (Vler/256) TTL/CMOS-compatible PPI chip $218 ATLANTIS/PEGASUS High-performance lisabriefdescriptionofeachI/Oport x (Port input value) data acquisition/analysis software; foreground/ or signal which can accept a TTL-level background operation; maximum 25.KHz rate; supports hard disk streaming; pull-down win- input or output, as well as the For example, if Vref = 5.00 volts, dows; interactive graphical data anal sis; connector(s) on which the signal ap- and channel 0 of the A/D converter is hypertext help .__.....__.....__...... $l50?250 pears. read and its value is 200 (decimal), The on-chip A/D converter can then the input voltage to channel 0 is be used to measure analog inputs in 5.00/256 x 200 = 3.91 volts. Listing 1 Real Time Devices, Inc. the range of O-5 VDC. All channels are illustrates the use of the analog-to- single ended (referenced to ground) digital converter while in a BASIC-11 with an adjustable precision reference program. Phone: 8141234-8087 FAX: 814/234-5218 Reader Service #I@ December ‘Xl/January ‘9 1 39 tgure JD- Ine second nalt or the I<‘IC-HC I I schematic includes the external memory, real-time clock/calendar, andpower supervisor circuitry.

Position and/or Velocitv SERIAL OPTIONS A standard asynchronous serial port with selectable baud rate, parity, character length, and stop bits is pro- vided as an on-chip peripheral sub- system. This subsystem is externally interfaced through both a MAX232 RS-232 driver (U5) with true positive and negative voltage levels, and an SN75176 RS-485 driver (U6) capable of driving up to 6000 meters of 24 8 -Axis Programmable Motion Gmtroller AWG, 2-conductor cable. Both inter- State-of-the-art Digital Multifunction Controller can be configured in minutes face chips are always enabled with using “off-the-shelf” components Port D bit 2 controlling the direction of DCX motherboard contains intelligence/ memory/firmware and 8 sockets for data flow on the RS485 interface. A “plug-in” Modules logic one (1) on Port D, bit 2 places the 1 to 8 “plug-in” DC Servo, Stepper or Special Purpose Control Modules can RS485 interface driver into transmit be mixed/matched on same DCX board mode. Another jumper terminates the Install in any PC/XT/AT compatible, or use “stand-alone” with RS232 RS-485 transceiver with a 100-ohm and/or IEEE-488 interface Modules resistor. High level interface libraries in ” C” and ” BASIC,” with examples and source Access to the serial port through code, included BASIC-l 1 is accomplished simply by Precision Micro Control usingBASIC’s~~1~~and INPUT state- CORPORATION ments since this is the default console 3555 Aero Court, San Diego, CA 92123 port for the BASIC interpreter. FAX (619) 565-l 166 (619) 565-l 500 A four-wire (In, Out, Clock, Se- lect), full-duplex high-speed synchro-

ReoderSewiceX175 40 CIRCUIT CELLAR INK nous serial interface is available for MC68HCllAl SIGNAL DESCRIPTION communications with external I/O RESET-This active-low bidirectional control pin is used as an input to initialize the MCU devices such as EEPROMs, AD&., to a known startup state and as an open-drain output to indicate that an internal failure PLLs, or other RTC-HCll processor has been detected in either the clock monitor or the computer operating properly circuit. boards. This interface can transfer XTAL, EXTAL-provide the interface for either a crystal or a CMOScompatible clock to serial data at up to 1 MHz; clock phase control the internal clock generator circuitry. The frequency applied is four times higher and polarity are software program- than the desired E clock rate. mable. Because its operation is rela- E-Provides an output for the internally generated E clock, which can be used for timing tively complicated, you’ll excuse me reference. The frequency of the E output is one-fourth that of the input frequency at the for glossing over its relevance and XTAL and EXTAL pins. suggesting that you seek out a Motor- IRQ-The asynchronous interrupt input to the MCU. Either negative edge-sensitive or ola “68HCll Programmer’sReference level-sensitive triggering is program selectable. This pin is configured to be level sensitive Manual” for more details. during reset. An external resistor connected to VDD is required on IRQ.

XIRQ-Provides the capability for asynchronously applying nonmaskable interrupts to YOU WANT IT WHEN? the MCU after a power-on reset @OR). During reset, the X bit in the condition code register is set, and any interrupt is masked until enabled by software. This input is level sensitive Data collection and control appli- and requires an external pull-up resistor to VDD. cations are usually time dependent. MODA/LIR AND MODB/VSTBY-During reset, these pins are used to control the two basic The addition of a hardware clock/ operating modes and the two special operating modes. The LIR output can be used as an calendar relieves the microcontroller aid in debugging once reset is completed. The open-drain LIR pin goes to an active-low state during the first E-clock cycle of each instruction and remains low for the duration of from timekeeping overhead. The Oki that cycle. M6242B CMOS clock/calendar (UlO) has both a clock/calendar and se- VRL and VRH-Provide the reference voltage for the A/D converter. lectable interrupt outputs. Thirteen R/W/STRB-provides two different functions, depending on the operating mode. In registers hold time and date informa- single-chip mode, the pm provides STRB (output strobe) ftmction; in the expanded- tion and three registers are used for multiplexed mode, it provides R/W (read-write) function. The R/W is used to control the direction of transfers on the external data bus. control purposes. These registers are addressed by the latched addresses AS/STRA-Provides two different functions depending on the operating mode. In single- BAO-BA3. To enable the chip, I/O se- chip mode, the pin provides STRA (input strobe) function, and in the expanded-multi- plexed mode, it provides AS (address strobe) function. The AS may be used to demulti- lect jumper JP2 pins 7 and 8 must be plex the address and data signals at port C. connected. This decodes a 1K I/O block for access to the clock chip be- INPUT/OUTPUT LINES (PAWA’/, PBO-PB’I, PCO-PC7, PDCWDL, PEO-PE7)-These I/O linesarearrangedintofour8-bitports (A, B, C, andE)andone&bitport (D). All portsserve ginning at address $7COO. Table 2 is more than one purpose depending on the operating mode. Port functions are controlled the complete clock/calendar register by the particular mode selected. In the single-chip mode and bootstrap mode, four ports address/function table. Each register are configured as parallel I/O data ports and port E can be used for general-purpose static inputs and/or analog-todigital converter channel inputs. In the expanded-multiplexed is a nibble (4 bits) wide with the lower mode and test mode, ports B, C, AS, and R/W are configured as a memory expansion bus. 4 bits of the data values significant. Each value is between 0 and 15; most PORT A-In all operating modes, port A may be configured for three input capture func- tions, four output compare functions, and pulse accumulator input (PAI) or a fifth output are from 0 to 9 (a decimal digit). compare function. Each input capture pin provides for a transitional input, which is used The STDP output from the to latch a timer value into the 16-bit input capture register. External devices provide the M6242B can be used as an interrupt transitional inputs, and internal decoders determine which input transition edge is sensed. The output compare pins provide an output whenever a match is made between source. The upper part of JP25 allows the value in the free-running counter (in the timer system) and a value loaded into the par- selection of either *INTO or *INTl for ticular l&bit output compare register. When port A bit 7 is configured as a PAI, the the interrupt. Two modes of interrupt external input pulses are applied to the pulse accumulator system. The remaining Port A lines may be used as general-purpose input or output lines. can be selected through the control registers D-F of the M6242B. The IRT PORT B-In the single-chip mode, all port B pins are general-purpose output pins. Port B (interrupt) mode gives a one-time may also be used in a simple strobed output mode where the STRB pulses each time port B is written. In the expanded-multiplexed mode, all of the port B pins act as high-order interrupt pulse while the ST (stan- (bits 8-15) address output pins. dard) mode creates a recurring inter- rupt pulse. PORT C-In the single-chip mode, port C pins are general-purpose input/output pins. Port C inputs can be latched by the STRA or may be used in full handshake modes of parallel I/O where the STRA input and STRB output acts as handshake control lines. In DON’T FORGET the expanded-multiplexed mode, Port C pins are configured as multiplexed address/data pins. During the address cycle, bits 0 through 7 of the address are output on MN-PC7; during the data cycle, bits 0 through 7 (PCS-PC7) are bidirectional data pins controlled by The RTC-HCl 1 hasbeen designed the R/W signal. sothataDallasSemiconductorDS1210 Power Monitor IC can be installed in PORT D-In all modes, port D bits O-5 may be used for general-purpose I/O or with the serial communications interface (SCI) and serial peripheral interface (SPI) subsystems. Bit socket U13. This chip monitors the 5- volt power supply and automatically

December ‘9a/January ‘9 1 41 B!ziName Function 0 is the receive data input, and bit 1 is the transmit data output for the SCI. Bits 2 through 0 (Sl) Seconds EO 5 are used by the SPI subsystem. Tens of seconds $7COl : $Ip, Minutes $7CO2 PORT E-Used for general-purpose static inputs and/or analog-to-digital channel inputs 3 (MllO) Tens of minutes $7CO3 in all operating modes. 4 (HI) Hours $7CO4 5 (HlO) Tens of hours $7CO5 RESETS-The MCU can be reset four ways: an active-low input to the RESET pin; a power- 6 (Dt) Days $7CO6 on reset function; a computer operating properly (COP) watchdog-timer timeout; and a 7 (DlO) Tens of days $7CO7 clock monitor failure. The RESET input consists mainly of a Schmitt trigger that senses the 8 (MOl) Months $7CO8 RESET line logic level. 9 (MOlO) Tens of months $7CO9 10 (Yl) Years $7COA RE!+El PIN-To request an external reset, the RESET pin must be held low for eight Ecyc 11 (YlO) Tens of years $7COB (two Ecyc if no distinction is needed between internal and external resets). To prevent the EEPROM contents from being corrupted during power transitions, the reset line should 12 (W) Day of the week $7COC be held low while VDD is below its minimum operating level. 13 (CD) control register D $7COD 14 (CE) control register E $7COE POWER-ON RESET (POR)-Occurs when a positive transition is detected on VDD. The 15 (CF) control register F $7COF processor remains in the reset condition until RESET goes high.

able 2--The functions and register ad- COMPUTER OPERATING PROPERLY (COP) RESET-The MCU contains a watchdog timer dresses for the OKI M6242B CMOS clock/ that automatically times out if not reset within a specific time by a program reset sequence. calendar chip. If the COP watchdog timer is allowed to timeout, a reset is generated, which drives the RESET pin low to reset the MCU and the external system. switches either U8 or U9 to battery The COP reset function can be enabled or disabled by setting the control bit in an power if the supply voltage falls be- EEPROM cell of the system configuration register. Once programmed, this control bit remains set (or cleared) even when no power is applied, and the COP function is enabled low 4.75 volts. In addition, the R/*W or disabled independent of resident software. line is held high to prevent data cor- ruption when the changeover to bat- CLOCK MONITOR RESET-The MCU contains a clock monitor circuit which measures the E clock input frequency. If the E clock signal is lost or its frequency falls below 10 kHz, then tery power takes place. Jumpers JP8 an MCU reset is generated, and the RESET pin is driven low to reset the external system. through JPlO are used to configure either U8 or U9 for battery backup. INTERRUPTS-There are seventeen hardware interrupts and one software interrupt (ex- cluding reset-type interrupts) that can be generated from all the possible sources. These (Note: You cannot back up both U8 interrupts can be divided into two categories: maskable and nonmaskable. Fifteen of the and U9 at the same time. Also, if you interrupts can be masked with the condition code register 1 bit. All the on-chip interrupts elect to install thisoption, a low-power are individually maskable by local control bits. The software interrupt is nonmaskable. The external input to the XIRQ pin is considered a nonmaskable interrupt because, once static RAM with a standby current enabled, it cannot be masked by software; however, it is masked during reset and upon draw of around 2-S lrA must be used receipt of an interrupt at the XIRQ pin. to prevent excessive current drain from ANALOG-TO-DIGITAL CONVERTER-The MCU contains an g-channel, multiplexed-in- the on-board battery. Higher current put, successive approximation, analog-to-digital (A/D) converter with sample and hold. RAM chips will still work, but you Two dedicated lines (VRL and VRH) are provided for the reference supply voltage input. will be replacing batteries far more These pins are used instead of the device power pins to increase the accuracy of the A/D conversion. often.) The g-bit A/D conversions of the MCU are accurate to within +1 LSB (+1/2 LSB quantizing errors and +1/2 LSB all other errors combined). Each conversion is accom- RTC-HCll SOFTWARE plished in 32 MCU E-clock cycles. An internal control bit allows selection of an internal DEVELOPMENT conversion clock oscillator that allows the A/D converter to be used with very low MCU clock rates. A typical conversion cycle requires 16 microseconds to complete at a ~-MHZ bus frequency. The MC68HCll series is one of Four result registers are included to further enhance the A/D subsystem along with control logic to control conversion activity automatically. A single write instruction selects Motorola’s most popular 8-bit micro- one of four conversion sequences, resulting in a conversion complete flag after the first four controller families and there areabun- conversions. Simply convert one channel four times and stop; sequential results are placed dant software development tools. One in the result registers. telephone call to Motorola’s Freeware bulletin board system provided us with an IBM PC-based cross-assem- AUTOST CALL0 PORTD IFiTHEN/ELSE bler, a ROM monitor, 68HCll simula- ADCO TIME CLEAR LIST PRINT DIM ABSO RTIME tor, a very fast integer BASIC, and a C CONT LLIST FOR/NEXT PEEK0 compiler. [Editor’s Note: The Motorola FDIV() PACC DATA NEW Freeware BBS can be accessed at (512) WHlLElENDWH POKE RNDO EEPO 892-3733, parameters N81. In addition, NOAUTO RETURN REM SGNO ELOAD ONIRQ RETI TRON software for this article is available from CHR$() ESAVE ONTIME STOP the Circuit Cellar BBS or on Software On TROFF HEX0 FREE PORTA Disk #28: See page 92 for downloading SLEEP ONPACC HEX20 INBYTE and oidering information.] The BASIC- PORTB GOT0 ON..GOTO TAB0 INPUT PORTC GOSUB ON..GOSUB 11 interpreter required a few changes to its console I/O routines since it was Table J-BASIC- 11 keyword summary. P.O. BOX 1108, POWAY CA92074-1108 (619) 679-8360 ERAC CO. VISA or Master Card (add 3.3%).Check or Money SINCE 1974 order. no CODS. Calif. orders add 7.25 %. Toshiba CD-ROM Drive AT BUS DESIGN SWITCHERS Model TXM-3201A1.660MB 400 mS access The first book to fully document the PCjXTjAT 5Vj75A, 12V!6A.-l2Vj3A.-.%‘j5A $ 75 KI: includes int i ext drive. SCSI controler and (ISA)bus. Covers detalled signal defmishlons. 5V,‘9 5A.l2V,‘3.8A.-12V/ 8A 29 aabie, audio Interface setup software drivers timing diagrams and compatability issues Also 5V/6A.i2Vj2A. -l’V/lA 24 and Microsoft Extension. Meets Yellowbook Included are the SjlS bit part of the EISA buss 5Vj6A 24V/l 25A,l2Vj 6A:i 2Vj 6A 24 standard 60day warr $ 265 The author, Ed Solan IS a member of the P996 5V/3A, l?V/2A, -12V/ 4A 19 working group that developed the AT bus stand- 5Vj2OA. 12Vj4A. -12V/l 5A:5Vjl 5A a6 Microsoft Bookshelf ard for IEEE Over 200 pages Including 100 ll’.Volume CD-ROM Reference Library The tlmlng diagrams and tables.7”xg” $69.95 5V,‘30~100A/200A 291991159 American Hentage Dictiona~.Quotes, P.T Fu!l Size 270 W 69 Chicago Manual of styie.Thesaurus,Spelilng Baby 80286 Motherboard Gslot MISCELLANEOUS checker. Forms/letters & more $ 109 12 MHz G2 chip set 9 X 9”. AMI bias. 4 Meg Serial Mouse 10O”omlcrosoftcomp ,250DPI Ram sipps or dlps(OK)4 Layer $ 110 Twobutton.db9jdb25conv.jWith Dr Halo $38/42 48Meg Hard Drive Kit Speedlink2400i Modem 300j1200j2400 baud KPTI K/t :ncludes 3 l/2” RLL 35mS drive, CPU CARDS 81 BACKPLANES 2 yrs warr Hayes camp ,114 card. volume con- W D iiA2 Contr cables and 5 l/4” moun?mg 80286-8 CPU Card. (KaYpro) trol. ii Chip set, tel cable, Internal % 65 hardwa!e.l year warrantee. $ 245 Phoenix, 80287sct.uses ext mem board $65 Turbo 80286 1 Oj8 CPU Card. ( I- ISUS! AT I:0 .2 Senal(COM 1.4). patr port (Ipt 1-2) DX5000 386 motherboard Chips & Techn chip set. AMI blos. 80287 game port. manual. 2 se! port ext.cabies $20 9038&25/33,64K to 256K Cache (user- socket.Owalt.1 Meg(OK) DIP. nlcadiext batt DC Fans 12v.Brushless. 3W. 5 blade.l”deep. upgrade). Welteki80386. 16Meg on board 24 pg manual $109 3 i/4” mcuntlng noles $5 (OK) Dallas non-volatile ciockjset-up, AMI 80286-12 CPU Card. (Action Instruments) Battery Holder, holds 4 AA ceils Velcro backmg ElOS IS c\Sj2. XENIX.Wlndows 3 Cornpat. G2 -TAG chip set. Award.l/2 size. 80287 socket and 4 pin connector, use for AT. XT. etc $ 1 50 ible FuiiATForm Glayers.NortonSI31 6(25) 4M simms(OK). Parr and 2 comm portqcon- Computer Power cords $2 15forS20 4C 5(33)Pwr- Meter (MIPS)5 93 (25),9(33) flgarablej Dallas elk. lnstr Manual $ 295 Key Switches with spade !ugs and keys $2 OC 1 year ‘Warrantee $ 87,7/l 106 AT Backplane 12 slot 3j4” spacing,( blank)% 15 Test Probe wire.Rubber Red or Black AFT/$1 00 AT Backplane 8slot WIT keyb. & pwr corm IC Sockets. Soider tall. 14 16.18 oin lo/$ 1 00 Msoft MS DOS 3.3/GW BASIC fits standard case. 6 AT & 2 PC slots $ 39 Car Ltghter Adapter. 15’CaDle.plg tails 5 1 00 Users guide and users reference $12j$8 AT Backplane l&lot & up. drff styles $54 &up KAWRO PARTS AND SERVICE - CALL

68HCll BASED SINGLE BOARD COMPUTER

The 0-11 is a single board computer targeted for 68HCll based embedded control applications. Board resources include 32K EPROM, 28K RAM, 512 bytes of EEPROM, 24 available parallel port lines, 3 serial ports (2 of which are RS-232C buffered), 8 channel/ &bit A/D converter, +5 only power supply require- ment, and processor supervisory circuit. Quantity one pricing: bareboard with dots: $75.00; assembled and tested: $250.00 ALLEN SYSTEMS

2346 Brandon Road l Columbus, Ohio 43221 COMMUNICATIONS 6 110 614-488-7122 [803] 855-1551 Reader service R104, I ReoderSewiceXlM December 'pO/Jarxmy ‘9 1 43 $FFFF %FFFF

r-l

-$S7FF $BSOO-

--I- EE Star! --_____--______OK, RTC - - OK,_ RTC- - - .- $7m OK, RTC Non-volatile / $5SFF- ESAM Area 13K “xx. * BASIC 11 we0 -EE Start

-RAM Slarl -8103F SlOilO-

- Available address space for - A” extra 1K of user RAM can this mods be utilized in n-c&s 1 and 2 if the on-board cbckkabndar is disabled

Not available; used by BASIC 11 Eil - FigureS--The tlexibilityofthe MC68HC 11 'S memory mapping leads to a number of possible configurations when running - Internal to SSHCllAl MCU BASIC- I 1. originally designed to run on Motor- cation can be directly saved and auto- rupt every hour. When the service ola’s MC68HCllEVB, but it’s a real matically executed on reset or power routine at line 500 is called, the ADC is performer on the RTC-HCl 1. Changes up, eliminating theneed to repeatedly sampled and the readings are printed were also made to allow BASIC-l 1 to program and erase EPROMs. A BA- to the console (serial port) and also take advantage of the RTC-HCl l’s on- SIC-1 1 keyword summary appears in saved in EEPROM. Line 500 resets the board battery-backed RAM and real- Table 3. ONTIME setup so that BASIC’s TIME time clock/calendar chip. Listing 1 is a simple BASIC-11 variable continues to increment prop- The following sections contain a example which uses the RTC-HCl l’s erly. brief summary of each of the BASIC ADC, EEPROM, and timer subsys- Once a program has been de- and assembly language development tems. Line 40 sets up an interrupt bugged, several options are available options and a few examples of how an service routine and uses the 68HCl l’s for permanently saving the tokenized embedded application can be config- timer subsystem to generate an inter- code depending on how the inter- ured for the RTC-HCll. 10 REM Stores all eight AID converter channel readings to the BASIC-l 1 20 REM first eight EEPROM locations once each hour. 30 TIME=0 40 ONTIME 3600,500 For many of us, the quickest way 50 GDSDB 700 60 GOTD 50 to develop embedded software will 500 ONTIME mm+3600,500 510 PRINT "ch O","ch l","ch 2","ch 3","ch 4","ch Sn,'Lch 6","ch 7" be to use BASIC-11, a fast integer 520 PRINT I__,_,_,_,__-_-_____,_,,__-____~_____-~~~~~~~~~~__~~~~~~~--~~ BASIC interpreter with built-in sup- 530 FOR I=0 TO 7 port for most of the 68HCll’s on-chip 540 A-ADC (I) : REM read the A/D converter 550 PRINT A, : REM send the reading to the console peripherals. This BASIC can execute a 560 EEP(Ik-A : REM save reading in nonvolatile EEPROM thirty-thousand-iteration FOR...NEXT 570 NEXT I 580 PRINT : PRINT loop in less than four seconds (an IBM 590 RETI PC takes 38 seconds by comparison) 700 REM This subroutine is called whenever the timer interrupt 710 REM is NOT being serviced (i.e., most of the time for a one- and has built-in keywords for access 720 REM hour timer) to the I/O ports, interrupt request 730 RETURN lines, timer/pulse accumulator, A/D converter, and EEPROM. Using bat- Listing 1 -Using BASIC- I l’s ADC and EEP functions allows BASIC to directly exercise the tery-backed RAM, a BASIC-l 1 appli- A/D ano EEf%OM.

44 CIRCUIT CELLAR INK preter’s configuration up about 9K of the avail- bytes have been set. Ul- ASM [] Line asm/disasm BF [] Block fill memory able ROM space leaving timately, my intention BR (-][] Set up bkpt table 23K in which to store a is to have configuration BULK Erase EEPROM ROM-based BASIC pro- bytes that are located in BULKALL Erase EEPROM and CONFIG gram. Since the RTC- the on-chip EEPROM CALL [] Execute code at addr HCll has only two which determine how PROCEED Continue execution memory sockets, careful RAM and EPROM EEMOD [ [caddr>]] Modify EEPROM range attention must be given memory will be shared LOAD ITI Load S-record from terminal to the values used to by the BASIC-11 inter- VERIFY Load or verify S-records MD ( []] Memory dump configure BASIC-l l’s preter (initial software MM [] or (] Memory modify RAMstartandEEstart releases will involve MOVE es1 > [] Block move to help eliminate the pos- separate EPROMs for OFFSET [-]1 Trace n instructions is too large to store in ration (Mode l), BASIC either EPROM or bat- is given access to all Table 4-BUFFALO 3.4 ROM monitor command summary. tery-backed RAM. Sec- available RAM from $1040 to $7FFF. disk before powering down the RTC- ond, some way to transfer the pro- This allows you to develop the largest HCll. gram out of the RTC-HCll’s RAM possible RAM-based program, about Some people like to keep their and into an external EPROM is re- 28K, and is the best choice if your ap- program and data’on instant call. Stor- quired. plication does not require nonvolatile ingthecodeinROMorbattery-backed One solution is to use the pro- program storage or automatic load- RAM is the alternative. This is where gram shown in Listing 2. This code is ing on power up. Volatile program Mode 2 (the “EPROM” mode) and designed to be appended to the end of storage is not a problem if you use a Mode 3 (the battery-backed RAM your debugged application and then terminal emulator that supports ASCII mode) come into play. entered via a GOTO to line 31000. The transfers on a PC for communications. Referring to the memory map in program will dump a Motorola S-rec- Simply list the program and save it to Figures, note that BASIC-11 itself uses ord format file to the serial port which

Pods and Software ncluded

- 1OOMHz sampling rate( - 24 Channels(50 MHz), - 2K samples/channel(l * 24 Bit trigger word - TTL threshold level - Internal and External Clocks - Menu driven software - FREE sofm/are updates on BBS - More sophisticated units also avallable

- 20 and 24 pin PALs, EPLDs - Byie SpWMerge(l6 & 32 bit) - 16V6 ,2OV6 ,22VlO GALS - JEDEC, INTEL HEX, Motorola’S files - 2716-27020 EPROMs - Dallas NVS RAM pro ramming * 67xxx MlCROs - PC/XT/AT COMPATI B LE - EEPAOMs(incl. 6 pin serial) - FREE software updates on BBS SEALEVEL SYSTEMS INC. Call-(201)994-6669 Link Computer Graphics, Inc. COMMUNICATIONS 6 I/O 4 Sparrow Dr., Livingston, NJ 07039 FAX:994-0730 [803] 555-1581

ReaderService X154 >ader Service X165 December W/January ‘9 I 45 can then be captured by a PC-based 31000 REM This program will dump a combined user program and communications program like Pro- 31010 REM BASIC11 interpreter image at a start address of $8000. 31020 REM AUTOST will be set; store $55 to $1040 for debug mode comm or Kermit. This S-record file 31030 REM ***** gather info from page-zero memory ***** will contain your BASIC application 31040 REM 31050 SH=PEEK($0004)*256 code from RAM, a copy of the inter- 31060 SL=PEEK($OOOS) preter itself from ROM, and a few 31070 BB=SH+SL 31080 IF PEEK($1040)=$55 THEN 31090 ELSE 31100 bytesof information that BASIC needs 31090 PRINT "BASIC start address is: $":HEX(BB) to auto start the ROM-based applica- 31100 SH=PEEK($0006)*256 31110 SL=PEEK($0007) tion. This file can then be sent directly 31120 BE=SHtSL to an EPROM programmer to pro- 31130 IF PEEK(S1040)=$55 THEN 31140 ELSE 31150 31140 PRINT vvBASIC end address is: $";HEX(BE) duce a 32K device (27256) which, when 31150 SH=PEEK($0008)*256 inserted into socket U8, will automati- 31160 SL=PEEK($0009) 31170 VB=SH+SL cally run your BASIC-11 application 31180 IF PEEK($1040)=$55 THEN 31190 ELSE 31200 on reset or power up, 31190 PRINT WAR start address is: S";HEX(VB) 31200 SH=PEEK($OOOA)*256 The last configuration, Mode 3, 31210 SL=PEEK($OOOB) allows a portion of battery-backed 31220 VE=SH+SL 31230 IF PEEK($1040)=$55 THEN 31240 ELSE 31250 static RAM to be used for semiperma- 31240 PRINT "VAR end address is: S1';HEX(VE) nent program storage. Here’s how it’s 31250 SH=PEEK($OOOC)*256 31260 SL=PEEK($OOOD) done: 31270 HL=SH+SL BASIC-l 1 has an ESAVE keyword 31280 IF PEEK($1040)=$55 THEN 31290 ELSE 31330 31290 PRINT "Highest line # is: ";HL;" ($";HEX(HL);")" which is intended to move a program 31300 REM from BASIC’s program RAM to some 31310 REM ***** print first line of combined EPROM S-Record ***** 31320 REM category of nonvolatile external (to 31330 VC=VE BASIC) RAM storage. ESAVE uses the 31340 CK=O 31350 PA=$8000 : REM start address of combined EPROM value contained in an internal vari- 31360 IF PEEK(S1040)=$55 THEN 31370 ELSE 31390 able to determine where in memory to 31370 PRINT "Combined EPROM start: $";HEX(PA) 31380 PRINT place the saved program. This inter- 31390 RS=(PEEK($FFCO)*256)+PEEK($FFCl) : REM get RAMstart constanl nal variable can be changed by setting 31400 PRINT"S1" ;:PRINT"OE";:PRINT HEX(PA) ;:REM start S-ret print 31410 CK=CK+$OE+$80 : REM update checksum the fifth and sixth bytes of the on-chip 31420 BB=BB-RS : REM subtract RAMstart from BASBEG EEPROM to a value other than $FF. 31430 CK=CKt(((BB.AND.$FFOO)/256).AND.$FF)+(BB.AND.$FF):REM chksum 31440 PRINT HEX~BB); : REM print new BASBEG for EPROM These new EEPROM values represent 31450 BE=BE-RS the memory address at which BASIC- 31460 CK=CKt(((BE.AND.$FFOO)/256).AND.$FF)+(BE.AND.$FF) 31470 PRINT HEX(BE); : REM print new BASEND 11 will attempt to store an ESAVEd 31480 VB=VB-RS program. 31490 CK=CK+((WB.AND.$FFOO)/256).AND.$FF)+(VB.AND.$FF) 31500 PRINT HEXWB); : REM print new VARBEGIN Since the RTC-HCll has a Dallas 31510 VE=VE-RS SemiconductorDS1210RAMbackup- 31520 CK=CKt((~VE.AND.$FFOO)/256).AND.$FF)+(VE.AND.$FF) 31530 PRINT HEXWE); : REM print new VAREND protection circuit, we can use some of 31540 CK=CK+(((HL.AND.$FFOO)/256).AND.$FF)t(HL.AND.$FF)t$55 BASIC’s normal program RAM for 31550 PRINT HEX(HL);"55"; : REM print new HILINE and AUTOST flag 31560 CK=CK.EOR.$FFFF the ESAVE storage area. This isaccom- 31570 PRINT HEX2(CK.AND.$FF) : REM print checksum plished by setting jumpers JP8-11 so 31580 REM 31590 REM ***** print S-records for user program ***** that backup power is supplied to U9 31600 REM from the on-board battery and the 31610 SA=BB+RS 31620 HA=VE+RS read/write line is routed through the 31630 OF=$GFOB : REM set to $6FOB for a user RAM start of $1100 DS121O’s power-down protection cir- 31640 GOSUB 32000 31650 REM cuitry. 31660 REM ***** print S-records for BASIC interpreter ***** This effectively creates an on- 31670 REM 31680 SA=$DOOO board EEPROM into which we can 31690 HA=$FFFF store/retrieve a BASIC-l 1 program 31700 OF=0 31710 GOSUB 32000 byusingthe ESAVE and ELOADcom- 31720 PRINT "S9030000FC" : REM print termination record mands. If we also issue the AUTOST 31730 END : REM ***** EXIT ***** 32000 REM command,the ESAVEedprogramwill 32110 CK=O : REM S-record checksum automatically execute on reset or 32120 REM 32130 IF PEEK($1040)=$55 THEN 32140 ELSE 32160 : REM debug flag power up. The stored program can be 32140 PRINT:PRINT"Memory read from";'*$'v;hex(SA);'* to ";"$";hex(HA copied back to user RAM for editing 32150 PRINT "S-Record starting address: ";"$";hex(SA+OF) : PRINT 32160 LL=16 : REM # of data bytes in S-ret excl. address & cksum by using the ELOAD command. As a 32165 TB=HA-SA+l : REM calculate total bytes (continued) bonus, the user RAM area can be used by theESAvEdprogramfor datastor- Listing 2-S-record dump program. age.

46 ClRCUlT CELLAR INK ASSEMBLY LANGUAGE 32170 WHILE TB<>O 32180 IF TB>=LL THEN 32200 The assembly language memory 32190 LL=TB 32200 CK=O map (see Figure 5) is inspiring and 32210 PRINT "Sl"' uncluttered; kind of like pulling onto 32220 PRINT HEX2'(LL+3); 32230 PRINT HEX(.SAtOF); a five-lane freeway at three o’clock in 32240 FOR X=0 TO LL-1 the morning in a Porsche. 32250 SD=PEEK(SA+X) 32260 PRINT HEX2 (SD) ; Each of the RTC-HCll’s memory 32210 CK=CXtSD sockets can be decoded for an 8K or 32275 TB=TB-1 32280 NEXT X 32K memory block; U9 covers 32290 CK=CK+LL+3 $OOOO-$7FFF, and U8 covers 32300 CK=CK+((SAtOF).AND.$ff) 32310 CK=CKt((((SAtOF).AND.$ffOO)/256).AND.$ff) !§8000-$FFFF. Three small memory 32320 CK=CK.EOR.Sffff blocks are decoded for peripheral 32330 PRINT HEXZ(CK.AND.$ff) 32340 SA=SAtLL devices: $lOOO-$103F for on-chip I/O 32350 ENDWH and configuration, $B600-$B7FF for 32360 RETURN EEPROM, and $7CO&$7FFF for the Oki clock/calendar chip. To make listing P-continued things even simpler, the I/O and EEPROM blocks can be moved to the tively, an IBM PC using a communica- to warm up. Next, apply power to the start of any 4K page, and the Oki clock tions program can be substituted. The RTC-HCll. If the ROM monitor is and EEPROM blocks can be disabled console device you choose must be ca- installed and everything is connected altogether. Refer to the Motorola pable of being configured for 9600 properly you should see the message: “68HCll Reference Manual” (ISBNO- baud, 8 data bits, 1 stop bit, and no 13-566720-8, Prentice-Hall) for thenec- parity if you will be using either the BUFFALO 3.4 text) essary HCll instruction set and regis- ROM monitor (BUFFALO 3.4), or > ter details. BASIC-l 1. The console device is con- Listing3istheequivalentof”Hello nected to the RTC-HCll through J2. Enter a “?“for a list of BUFFALO world!” for RTC-HC11 development; Once everything has been con- commands. If you’re using BASIC-l 1, it simply blinks the RTC-HCl l’s LED nected and double checked, turn on and everything is working properly, to indicate that at least the MCU itself the power to the terminal and allow it your display should look like this: isalive.Theprogramcanbeassembled with the AS11 assembler and then downloaded to the board using either the ROM monitor’s "LOAD T" com- LEARN TO WRITE mand or DLOAD . EXE, aquickand dirty download program for the IBM PC. Another development option is to AND TEST PROGRAMS use one of the BUFFALO series of ROM monitors to download and test FORTHE 8051 your code directly on the HCll. This monitor contains a built-in line as- sembler/disassembler so short test The 805 1 Microcontroller: Awhiicture, programming routines can be entered directly into and Applications l by Kenneth Ayala RAM. Standard memory move/ This new text shows you how to program the 8051 microcontroller. Many change/fill and EEPROM support is examples and sample programs are included to help you master the also included. The monitor itself re- unique instruction set of the 8051. Also included is a disk which contains an assembler and simulator that runs on IBM PCs and compatibles. This sides in a single 8K EPROM and is disk assembles and allows you to test your programs without having to installed in socket U8 on the RTC- purchase any additional 8051 hardware. The disk was developed by HCll. Don’t forget to install JP12 so David Akey of PseudoCorp. You can purchase the text, with disk in- the instruction trace and breakpoint cluded, for only $49.00 + local tax, shipping, and handling. commands will work. 2zzz_ s II TM RTC-HCll INITIAL SETUP To order, call or write: West Publishing Company l Attn: COP Department l P.O. 64833 Setting up the RTC-HCll is very 3773 Hwy. 149 l Eagan, MN 55123 simple. Any standard RS-232 serial l-800-328-9352 l Visa and Mastercard accepted terminal can be used as a console device for the RTC-HCll. Alterna-

December ‘Xl/January ‘9 1 47 BASIC-11 Version 1.54 PORTD EQU $08 DDRD EQU $09 Copyright (c) 1986 - 1990 SPCR EQU $28 by Gordon Doughman 0% $0000 ; Internal RAM main: READY ldy #$1000 : base of on-chip I/O regs # ldaa #SO4 staa SPCR,Y ; set port D pin mode The “#” character is the BASIC-l 1 Ids XSff ; set top of stack prompt. Type "FREE" and press the ldaa #$fO ; set data direction register staa DDRD,Y “Return” key. BASIC-11 should re- spond with a decimal number. top: ldb #SO5 * timing loop bset PORTD,Y $20 : turn led ON MORE TO COME lp0: jsr dly50 : delay for half a second decb This article reads a little like an bne lP0 ldb #SO5 equipment manual, but there aren’t bclr PORTD,Y $20 ; turn led OFF too many other ways to describe a lpl: jsr dly50 hardware and software microcon- decb troller design. I’d much rather be de- bne 1Pl tailing the trials and tribulations of jmp top i repeat forever . . . *** “remotecamera positioning is an unil- * DLY50 - 50 ms delay subroutine luminated environment” or experi- *** menting with “substrate-level particle dly50: acceleration caused bycollapsingelec- pshx tromagnetic fields initiated through ldx #$411e d501p: errant program execution.” dex In all seriousness, I have a few bne d501p pulx projects in mind where the RTC-HCll rts is perfectly suited and I’ll bring them to you as soon as they are working. Listing %-LED blink test program. Since this is my first 68~~ project in a long time (my original Home Control System [HCSI used a 6802) there’s a big hole to be filled.+ INSIDE THE MC68HCllAl Special thanks to Gordon Doughman for his SINGLE-CHIP MODE-The MCU functions as a self-contained microcontroller contributions to this project. Thanks alsogo to and has no external address or data bus. This mode provides maximum useof the all those at Motorola who went out of their way pins for on-chip peripheral functions, and all address and data activity occur to provide us with assistance. within the MCU. This mode would not normally be used on the MC68HCll Al, because of no internal ROM. Steve Ciarcia (pronounced “see-AR-see-AH”) is an electronics engineer and computer con- EXPANDED MULTIPLEXED MODE-The MCU can address up to 64K bytes of sultant with experience in process control, address space. Higher-orderaddress bits are output on the port B pins, and lower- order address bits and the data bus are multiplexed on the port C pins. The AS pin digital design, and product development. provides the control output used in demultiplexing the low-order address at port C. The R/W pin is used to control the direction of data transfer on port C bus. Burt Brown received a BS in Computer Sci- encefrom California State University and has BOOTSTRAP MODE-All vectors are fetched from the 192-byte on-chip boot- been working with computers and electronics loader ROM. This mode is very versatile and can be used for such functions as test for over ten years. In his free time, he enjoys and diagnostics on completed modules and for programming the EEPROM. The bicycling, running, and Italian food. serial receive logic is initialized by software in the bootloader ROM, which pro- vides program control for the serial communications interface (SC11 baud and The RTC-HCl 1 is available from word format. In this mode, a special control bit is configured that allows for self- Micromint. For pricing and data testing of the MCU. sheets, call (800) 6353355 or fax (203) 872-2204. TEST MODE-Primarily intended for main production at time of manufacture; however it may be used to program calibration or personality data into the internal EEPROM. Inthis mode,a specialcontrol bit isconfigured to permit access IRS to a number of special test control bits. 409 Very Useful 4 10 Moderately Useful 411 Not Useful

48 CIRCUIT CELLAR INK FEATURE ARTICLE Designing with

Markus A. levy Flash Memory /s There a New Alternative to EPROM and SRAM?

t. I lash memory (in general) is capturing market share from other memory tech- nologies. It is replacing EPROMs that were traditionally used for code storage because, along with equivalent nonvolatility, it also allows in-system updates. Bat- tery-backed SRAMs that once were used for data acquisition, parameter storage, and even solid-state disks are now targets for the inherently nonvolatile and lower- cost flash memory devices. Many notebook computer OEMs conclude that low power, light weight, and reliability are most easily obtained with a completely solid- state machine, Flash memory has achieved a density ramp from 256K bits to 2 megabits in two years, Combined with a special flash file system from Microsoft, flash memory can even replace the mechanical disk drive. With the design described in this write interface. Erase, program, veri- Intel’s IC memory card adheres to article, you have a platform demon- fications, and other operations are the Memory Card strating flash memory’s functionality initiated by issuing the proper com- International Association (PCMCIA) and flexibility. Applications range mand to the flash memory device. standard. This standard specifies from data acquisition through an I/O Twelve volts must be applied on V physical, electrical, information struc- port, to a DOS-compatible, solid-state for the command register to respond ture, and data format characteristics disk. But first, a few essentials. to writes and execute the operation. of the card. Most impressive is the The 12V requirement doubles as an size, measuring 85.6 mm x 54.0 mm x EPROM AND BEYOND added security feature for data integ- 3.3 mm. Its 68-pin interface includes rity. If you are familiar with other 26 address lines used to directly ad- Derived from an EPROM process memory subsystems, designing with dress 64 megabytes. All buffering and base, Intel’s ETOX-II flash memory flash memory is as simple as any other chip-level decoding is contained technology has similar nonvolatility, technology. within the card, greatly simplifying reliability, and array densities. In fact, In addition to discrete compo- the board-level design. Intel’s flash the flash memory cell is identical to nents, Intel offers flash memory in memory card is available with one the EPROM structure, except for the SIMM and IC memory card formats. and four megabytes. These cards will thinner gate (tunnel) oxide. This is This design will use these modules, so continue to grow in density, becom- where the similarities end. The thin- I’ve included some pertinent infor- ing more and more competitive as ner gate oxide enables flash memory mation. The512K-bytex 16 Intel Flash disk drive replacements. to be erased and reprogrammed in- SIMM (SM28FOOlAX) is based on an circuit, typically 100,000 times. The 80-pin JEDEC standard that accom- MEMORY METHODS name “flash” is derived from its one- modates density upgrades and pres- second chip-level erase and microsec- ence detect (a hard-wired ID that indi- Three fundamental addressing ond-level byte-write times versus the cates SIMM density and speed). The methods can be implemented when slower, millisecond-level byte-write eight l-megabit flashmemory devices interfacing a flash memory array to a times for conventional EEPROMs. on this module are paired up as high system bus: linear, I/O, and paged. Flash memory devices have a and low bytes. They are selected using Eachmethodhasitsbenefitsanddraw- command register architecture that the SIMM’s write enable high and low backs. A linearly addressed memory providesamicroprocessor-compatible (*WEH and *WEL) signals. array is mapped directly into the sys-

50 ClRCU/T CELLAR INK

. tern’s memory space and allows the different portionsof thearray by writ- yourself with the basics of the AT I/O highest performance. However, the ing a page number to the decoding channel bus. memory array would be insufficien tly circuitry. This page ranges in size from The subsystems within this de- small in systems having limited 8K to64K bytes. Analogous to a cache, sign (Figure 1) are the memory decode memory space, as with the 8086. But a larger page size requires less fre- circuitry, I/O and its associated de- this method is practical in an 80386 (or quent switching. Although switching code logic, and a 12V generator for other 32-bit processor) family system pages represents a performance deg- Vrr. The Intel flash memory resides in with a large memory space available. radation, this can provide the optimal four SIMMs. The board handles an An I/O-mapped memory array balance between performance and upgrade path to 16M bytes, based on uses one address-an I/O port-to memory space availability within the 4M-byte SIMMs. transfer data. This method requires system. the least amount of system memory Our design is based on this page- ADDRESS DECODING space but also yields the lowest per- mapped technique. A 64K-byte page formance. size reduces the decoding circuitry. Flash memory addresses can be A page-mapped memory system The PC/AT has been chosen as the decoded in one of two ways: row- is a hybrid of these two approaches. It execution platform, but with minor column and conventional decoding allowsaverylargememoryarray with modifications to the control signals, using separate chip enables. The row- a minimal system interface. A page is any microprocessor environment can column approach of Figure 2is appro- a moveable window into the total be used. Before beginning this design, priate if you are motivated to reduce memory array. It selectively opens it would be helpful to reacquaint board traces. In row-column decod- ing, rows are Output Enables POE), Write Lows (*WRL), and Write Highs (*WRH); and columns are Chip En- Address I I ables (+CE). Although the Data 110 Presence Detect SM28FOOlAX uses only four chip - Decode l/O Control enables, eight are provided since four- megabyte SIMMs could consist of six- teen 2-megabit flash memory devices. Vpp Enable Intel System Flash Page selection, discussed in more BUS Memory detail later, is accomplished by VPP Array writing the page number through an Generator and VPP Xceivers B-bit I/O port to a latch. This will allow access to 256 64K-byte pages. Page signals, PO-P2, are directly con- nected to A15-A17 on each SIMM. They decode pages on the device level. The row-column signals are de-

Transceiver Select rived by decoding page signals P3-P7. They enable components on the SIMMs. Figure 1 --The subsystems in a flash memory board design include memory decode. I/O. The row-column approach, how- and a 12V generator. ever, suffers from simultaneous selec-

December ‘PO/January ‘9 1 51 SAVE Development and Debugging lime of Embedded Microprocessor Systems!

l INTROL-C Cross-Compilers

l INTROL-Mcdula-2 Cross- Compilers Figure 2-Row-column addressing can be used to reduce board traces.

l INTROL Relocating Macro Cross-Assemblers COMPILER PACKAGES INCLUDE:

Compiler l Assembler l Linker TO SIMM0 l Runtime libran/. including SOCKET a multi-tasking executive l

Support utilities l Full year’s maintenance TARGETS SUPPORTED: 6301/03.6801/03~ 6809. TO SIMM1

68HCll l 68000/08/10/12 l SOCKET 68020/030/881/ 851 .32000/ SMEMFt# 32/81/82 SMEMWW AVAILABLE FOR FOLLOWING HOSTS: VAX and MicroVAX; Apollo; SUN; Hewlett-Packard; TO SIMM2 Macintosh; Gould Power- SOCKET Node; IBM-PC, XT, AT, and compatibles INTROL CROSS-DMLOPMENT SYSTEMS are proven, accepted TO SIMM3 and will save you time, money, SOCKET and effort with your develop ment. All INTROL products are backed by full, gure 3-Using separate chip enables trades off board complexity for low power usage. meaningful, technical suppo~ t. CALL or WRITE for facts NOW! 74x245 - 6 WI-- TO SIMM0

INTRO1 TO SIMM2 CORPORATION BHEX

A”-~~~~ ENABLE 9220 W. Howard Avenue Mihuaukee, WI 53220 4141327-7171 FAX: 4141327-7734 Quality Software Since 1979 WRLO-3# and WRHO-3#

Figure 4-A simple buffering scheme is used to connect the memory to the system bus.

Reader Service #lM ClRClJlT CELLAR INK PCMCIA STANDARD MEMORY CARD

AO-15 AO-15

CSL\ (Chip Select Low) MEMDECODE# Introducing ACTOR, the CSM (Chip Select High],

74x273 video capture and image processing library Victor is a library of functions for C program- mers that simplifies development of scientific DO-7 DO-7 00-7 A16-23 m A16-23 imaging, quality control, security, and image database software. Victor gives you device control, image processing, display, and TIFF/ IOWII PCX file handling routines. >CLK Your software can have features such as: IO PAGE NUMBER CLR live video on VGA, resize and zoom, display omK)aceaan*l) CONTROL SIGNALS t multiple images with text and graphics. Image RESET# processing functions include brightness, con- trast, matrixconvolution filters: sharpen, out- :igure a-wmvmg some wrrerlng onro a separare memory cara reuuces me amounf c line, etc, linearization, equalization, math and necessary interface hardware. logic, overlay, resize, flip, invert, mirror. Size/ number of images limited only by memory. Display on EGA/VGA up to 800x600~256. And, to get you up and running quickly, we’ve Included our popular Zip Image Processing software for rapid testing and prototyping of Image processing and display functions. Victor supports Microsoft C, QuickC, md Turbo C . . . all for only $195. Victor and Zip support ImageWise and sther popular video digitizers. NEW? ZIP Colorkit, the software that allows any pray scale digitizer to create photographic quality color images. it’s easy to produce stunning color images with .heZIP Colorkit --capture threeimageswith a ;ray scalevideo digitizer using red, green, and >lue filters and save the images. Colorkit loads he image files and uses a unique optimizing tlgorithm to calculate the optimum color mage. Supports PIW, PIF, PCX, TIFF, GIF, md TGA file formats. ZIP COLORKIT, $75. tigure b--0V swmhes are used to set the board’s address in the PC’s l/O space. VICTOR LIBRARY includes FREE tion of eight parallel device chip en- mum of 64 pages, (i.e., 4-megabyte ZIP Image Processing ...... $195 ables. The conventional, separate chip SIMMs), and Al 7 is used on a 2-mega- VICTOR LIBRARY with video enable decoding method has lower bitdevicebutisa”NoConnect”onthe frame grabber .,.,,...,...... $349 power consumption. Using this l-megabit part. A “No Connect” pin method (Figure 3), upper page sig- implies that page selection will not be ZIP Colorkit ...... $75 nals, I’6 and P7, decode which SIMM contiguous with SIMMs less than four is selected. megabytes in size. Accommodating Zall (314) 962-7833 to order Page selection becomes more noncontiguous pages increases soft- VISA/MC/COD complicated when accounting for ware complexity. Regardless of the CATENARY SYSTEMS density upgrades. To understand this page decoding method, a jumper 470 BELLEVIEW there are two things to keep in mind: scheme rearranges the page signals ST LOUIS MO 63119 each SIMM socket handles a maxi- and accommodatesdensity upgrades. (314) 962-7833

Reader Service X 1 Xl December ‘9O/January ‘9 I 53 According to Figure 2, the jumper settings are as follows: l-MByte SIMM-J7, J2, J9, J4 2-MByte SIMM (16 x 28 FOlO)_ J7, JL J3, J5 2-MByte SIMM (8 x 28 F020)-- J7, JL 19, J3 4-MByte SIMM (16 x 28 FO2Ol-- J8, JL J6, J3 Figure 4 shows the buffering re- quired for system bus interfacing. The 120k PC I/O channel bus is limited to two GND TTL loads on any one line. The “A” transceivers are connected directly to the I/O channel bus. Additionally, each SIMM has its own pair of “B” transceivers to reduce capacitiveload- ing that results from tying more than UNDERVOLTAGE eight flash memory devices together. RESETW SENSING ClRCUlT SIMPLIFIED DECODING HARDWARE Jure 7-A regulated boost converter made from Linear Technology’s LT1072 supplies You are not limited to using e 12 V necessary for programming. SIMMs in your design. The same basic page number through an I/O port to a shown in Figure 2 or 3. The IC card techniques will work for discretecom- latch accomplishes the same page se- itself also contains the “B” transceiver ponents or other module types, such lection as before, but now the “data” buffering. This results in the hard- asmemorycards.TheICmemorycard translates directly into memory card ware reduction shown in Figure 5. provides the simplest solution with address inputs A16-A23. This elimi- You will want to purchase a spring- its integrated decoding. Writing the nates the entire decoding structure loaded connector from Fujitsu, AMP,

Offering exceptional value in a single-board embedded controller, Micromint’s RTC-HCll combines all of the most-asked-for features into a small 3Yx4Ypackageat areasonableprice. Featuring thepopularMotorolaMC68HCll &bit microcontroller, the RTC-HCI 1 gives you up to 21 lines of TTL-compatible “3; an &bit, 8-channel analog-to-digital converter; two serial ports; a real-time clocWcalendar with battery backup; 512 bytes of nonvolatile EEPROM; and up to 64K of on-board RAM or EPROM, 32K of which can be battery backed. Software development can be done directly on the RTC- f HCll target system using BASIC-1 1, an extremely fast integer BASIC interpreter wlh dedicated keywords for I/O port, A/D converter, timer, interrupt, and EEPROM support. In addition, a flex- ible EEPROM-based configuration system allows a BASIC program to be P a 7tr# saved in the on-board, battery-backed static RAM, and then automatically executed on power-up. Micromint also offers several hardware and software options for the RTGHCll including the full line of RTC-series expansion boards as Additional features include: well as an assembler, ROM monitor, and C language cross-compiler. * As nchronous serial rl with full-duplex ._Rs -232___ and -. half-duDY ex RS-485 drivers l l-MHz synchrono& serial port Board wl 8-bil ADC, EEPROM, 8K RAM, and ROM monitor $239.00 * CPU watchdog security l Low-power “s&p” mode RTGHCl l-3 l 5volt-only operation Board as above w/ bettery-backed RAM, clock-calendar, $269.00 l RTC stacking bus and BASIC-1 1 in ROM To Ortdm cAk1,800~635~3355

MICROMINT, INC. 4 Park Street l Vernon, CT 06066 l (203) 871-6170 l Fax: (203) 872-2204

54 CIRCUIT CELLAR INK 8037 I I VCC /dzF+ T-?kY Single Board UNDERVDLTAGE SENSING CIRCUIT 74x138 3 TO 8 DECODER Computers CEO# CEl# CE2# Experience the power of low CE3n cost embedded control in Cl% L --- 1 YS b C;tSR your next project! MEMDECODE# c G2A CE6# G2B Y6 0 n o_CE7# GND rhe Control-R (pronounced Chip Enables will not ba active until Vcc = 4.6 volts. “Controller”) series of 8031 Single At this point. signals are stable and involuntary writes will not occur. 1 Board Computers are designed and sure a--An MC34G54Punciervoltage sensor is used to disable all writes to memory when manufactured to provide the features the power starts to fail, you need at a price that won’t blow your budget. We are commited to or ITT Cannon to use with the mem- byte boundary within the DOS l- providing cost effective products to ory card, laying out your board so that megabyte range, but only the adapter speed construction of your prototype the memory card can be retrieved out ROM area between COOOOH and systems and make one of a kind the back of your PC. Pushing the but- EOOOOH will alleviate compatibility products trully affordable. All SBCs ton on the connector ejects the mem- problems. Using additional inputs on operate from 5 volts DC and come ory card for data security or transport. the “Memory Decode Enable” 74x521 ssembled and tested with complete and an 8-input DIP switch allows documentation and sample I/O PORTS ON THE PAGE MEMORY window placement above 1M byte. Jrogramming information. BOARD Simply connect address lines A20-A23 to input pins P4-P7, respectively. The Control-R I - 11.0592MHz 8031 The page-selecting I/O port Presence Detect (I’D) pins from all SBC with 8K EPROM socket, optiona mentioned is one of eight ports in this four SIMMs are wire ORed together RS232 serial port and header page memory board design. The into the 74x244. This eliminates hav- connection to ports 1 & 3 of the 8031 74x521 comparator’sinputsbeginwith ing to read each SIMM’s I’D pins sepa- 16 I/O lines make it perfect for small A3 to simplify the decoding circuitry rately, but SIMMs must be installed control and data aquisition for the I/O port addresses. This places with equivalent density and speed. applications. $39.91 the base I/O port on an even &byte The page number is written and Control-R II - 11.0592MHz 803 boundary. Use discretion when set- read through the same I/O port. SBC has all the features of the ting the switch to avoid conflict in the Minimal circuitry ensures that the Control-R I plus an 8K SRAM socket AT environment. I recommend using system powers up at page zero. The and expansion bus with address, data I/O addresses between 300H and page memory board’s *RESET signal and RST, lNT1. WR, RD. PSEN, ALE, 318H because this area is assigned for connected to the CLR input of the l7 and power. $64.9: prototype cards. 74x273 latch accomplishes this task. Listed in the order in which they MAX232 - RS232 option for either appear on the 74x138 decoder in Fig- V,, GENERATION computer $6.9: ure6,theeightI/Oportsinthisdesign are: B&B13 (accesses the board’s iden- Why is Vpp generation necessary SRAM - 8Kx8 SRAM (type 6264) $10.00 tifiers); the window address within on this flash memory board when the [or Control-R Il the system’s memory space; the AT I/O channel already has a 12-V PseudoSam - MSDOS cross- SIMM’s presence detect; the V,, ena- supply? True IBM-compatible PCs ssembler for the 8031 $SO.OC bling register; and the page number specify the necessary f5% 12-V sup- reading and writing ports. ply tolerance. However, some systems $3.00 Shipping (UPS Ground) for all US I didn’t diagram the board’s iden- have wider 12-V supply tolerances. orders. Illinois residents must add tifier circuitry because the implemen- Local 12V generation via the circuitry 6.25% sales tax. tation is extremely simple. It consists described below ensures fast, reliable of four identical units made up of a flash memory operation. 74x244 and an8-input DIP switch. The Linear Technology’s LT1072 four enables, BIO-B13, from the I/O switching regulator, a 5-V-to-12-V decoder connect to the corresponding feedback regulated boost convertor, unit’s enable. The I/O space is scanned is the heart of the Vpp generator (Fig- Cottage Resources Corp. Suite 3-672 for the identifiers to locate the board. ure 7). A lOO+F capacitor at the out- 1405 Stevenson Drive The user-selectable page window put handles up to 200 mA, necessary Springfield, Illinois 62703 address can be placed on any 64K- for software that programs or erases

December ‘PO/January ‘9 1 55 to fully charge to 12 V. Reducing the width because the extra decoding is output capacitance value and limiting handled internally. the number of flash memory compo- As with any circuit design, it is nents accessed simultaneously de- important to follow good design prin- creases the ramp time. The diode, ciples. For example: decouple power MUR120, prevents inductor current supplies with 0.1~lt.F capacitors be- absorption from the charged output tween Va: and Vss of every device; and capacitor. During system power-up, shortboardtraceshelpminimizenoise. spurious noise may generate writes which are actually the sequence of SOFlWARE flash memory commands that initiate erasure or programming. Disabling Hardwarewithoutsoftwareislike V,, until voltages stabilize provides a computer without a processor. There- power-up protection. The Motorola fore, understanding program and MC34064P is an undervoltage sens- erase algorithms is the first step to- ing circuit that begins functioning wards functional flash memory. Re- when Va: is above 1 volt. Between 1 call from our earlier discussion that and 4.6 volts, the MC34064P’s *RESET operations on flash memory are soft- output or AT systemRESET clears the ware controlled using the internal 74x74. While the 74x74 remains cleared command register architecture. I have (or *Q = l), the 2N3904 is on, the VC included the complete algorithms input of the LT1072 is 0 volts, and the (Figures 9 and 10). [Edifor’s Note: VOLTAGE SWITCH (VSW) output is Softwarefor this articleis availableon the off. Writing a one to the VPP enable Circuit Cellar BBSand SoftwareOn Disk latch forces *Q low, turning off the #18. Seepage92 for downloadingand or- transistor. This puts the VC input at 5 dering information.1 After working the V, and VSW output generates 12 V. Intel flash memory hotline, I would You do not need the circuitry just like to discuss the common mistakes. described if your system’s 12-V sup- The best piece of advice that I can ply meets the VPP specifications. How- give is please follow the algorithms. ever, because software may acciden- Many people unsuccessfully try their tally (or coincidentally) generate a own custom versions. There are no valid flash memory command to a cutting comers. Starting with the ba- flash memory address, install a switch sics,letmeelaborateafewpointsabout toturnoffv whennotinuse.Alow- the algorithms: resistance&T (Motorola MTlXP05) 1) Flash is programmed to a bi- performs this duty. nary zero by adding charge to the The possibility of spurious writes transistor’s floating gate. Contrarily, to the flash memory devices during charge removal erases the cell to a power-up still exists. Again, the same binary one. During the erase opera- undervoltage sensor (MC34064) solves tion, the device is “flashed” as charge this problem. The *RESET output be- is simultaneously and equally pulled comes the 74x138 decoder’s active- off the floating gate of every memory high enable. This controls the chip or cell. The device must be prepro- write enables for the flash memory grammed to all zeros before erasure devices (Figure 8). so an already erased cell is not further depleted of charge. A FEW ADDITIONAL POINTERS 2) Prior to writing any command, switch on VPP and allow ample ramp Ground *MEMCS16 so the PC/ time for proper operation. Dropping AT recognizes your board with a 16 VPP below 7.5 volts from within any bit bus width. The original design operation, places thedevice in the read Figure O--The flash erase algorithm. operated in both 8- and 16-bit sys- mode. Similarly, abort an operation tems. This flexibility is accomplished by issuing two consecutive reset eight flash devices simultaneously. with additional decoding that multi- commands (FFH) followed by the read Turning VPP off when not in use con- plexesthehighdatabusonto thelower command @OH). serves power, but this capacitance data bus. Again, the IC memory card 3) Closely observe delay times to value requires approximately 100 ms automatically conforms to either bus achieve the highest performance and

56 CIRCUIJ CELLAR INK “permanent” whenitmatches thedata being programmed.

USING YOUR PAGE MEMORY BOARD AS A DATA RECORDER

There is a nearly endless list of data recording applications, includ- ing digital imaging, digital photogra- 8031 In-Circuit phy, point-of-sale terminals, patient Emulation monitors, and flight recorders. The Our emulator provides most features page memory board is appropriate of an 8031 in-Circuit-Emulator at a for many data recording applications significantly lower price. It assists in integration, debug, and test phases of whereanI/Oportof thePC/ATaccu- development. Commands include: mulates data. disassembly, trace, breakpoint, The programming algorithm alter register/memory, and load Intel demonstrates the byte programming Hex file. $199 capability of flash memory. In other words, once the device is erased, bytes 8051 Simulation reprogram randomly. In some record- The 8051 SIM software package ing applications, data is received in speeds the development of 8051 packets, A pointer determines where family programs by allowing execution and debug without a to begin programming the next free target system. The 8051 SlMulator location within the flash memory. is a screen oriented, menu Interleaving increases write per- command driven program doubling as a great learning tool. $99. formance by using the idle time dur- ing the lo-u.s program delay. Ad- dresses are offset such that each suc- cessive data byte gets written in dif- 8031/51 Single ferent devices, looping back in time to Board Compher issue the verify command. Reading A fast and inexpensive way to the data back would be done in a implement an embedded controller. 8031/32 processor, 8+ parallel I/O, similar fashion. up to 2 RS232 serial ports, +5 volt Word-wise, or parallel, program- operation. The development board ming of two devices provides an option allows simple debugging of 8031/51 family programs. $ggea additional means of increasing write performance. Note that flash memory devicesmayprogramatdifferentrates. Prototyping Therefore, the original algorithm must be modified during the verify opera- System tion. If only one byte of the word has The IPC-52 development system allows you, the designer, to verified, the program command and concentrate on Application Specific data are sent again to the unverified Circuitry only, because the 8052, byte. Mask the command sent to the RAM! EPROM, and l/O sections are Figure IO--The flash programming algo- burlt-in and fully functional. The rithm. device that verified to maintain word- prototyping bread-board is wise programming. A mask is the integrated into the system - save reliability. Use the ST1 instruction in substitution of a reset command for days of development time. $220 the software drivers to avoid system the program and verify commands. interrupts during these delays. That way, the programmed bytes do Call us for your custom product needs. Execute CLI once the corresponding not get further programmed on sub- verify command is issued. sequent pulses. Other products available: 4) The verify operation internally The page memory board will MyGAL - GAL Programmer $199 creates marginal conditions to ensure perform these software techniques. FORTH Card - FORTH development accurate and reliable results. The 6-us However, first write the software that card for STD Bus $279 (OEM-$1 99) slew time delay following the verify determines the location and capacity command allows the margin voltages of the board. First, scan the I/O space to settle. In the verify mode, pro- for the board’s identifier. The location grammed data is guaranteed to be of the first identifier byte is also the (619) 566-l 892

ReaderService #138 December ‘9O/January ‘9 1 57 base address for the eight I/O ports. ; Software to read in ASCII test Now the fun begins. Once you’ve Using the proper offset, read the I/O ; pattern to program into flash put your Flash Paged Memory Board port that enables the base-memory DATA ARRAY SEGMENT together and tried it out, imagine con- address transceiver. For SIMMs, cal- STORE IN FLASH Di 'ASCII test pattern to verting it into a solid-state disk. It’s culate the memory capacity by first DB 'be stored in flash' beendoneusingsoftwaredriversfrom reading the Presence Detect pins, fol- DATA _ARRAY ENDS Microsoft. In an upcoming article, we lowed by reading the individual flash will discuss the structure of the Micro- memory device identifiers. Alterna- CODE SEGMENT soft Flash File System and show you IllCl" tively, read the Card Information ax,DATA ARRAY fll0" ds,ax - how to interface it to your board. Structure in the PCMCIA standard IllCl" si,O Finally, I would strongly suggest memory card for the capacity. illCl" cx,size STORE -_IN FLASH thatbeforeattemptingthisdesign,you The preceding steps will confirm obtain the appropriate flash memory the basic functionality of your hard- more _input: literature from Intel (see the source m0" al, [si] ware. Practice programming the flash box). + call FLASH _PROGRAM devices with data from a RAM-based inc si array. For example: loop more-input Markus Levy is an application engineer at Intel Corporation in Folsom, California, and SOURCE holds a B.S.E.Efrom California State Univer- sity. Hisspecialties includesoftwareand hard- Intel Literature: (800) 5484725 ware implementations of solid-state disks in portable computers. His favorite away-from- Daba sheets SM28FOOlAX 1 M-byte SIMM #290244 work pastimes include home remodeling, 1MCOOlFL 1 M-byte IC memory card #290399 swimming, and parenting. 4MCOOlFL 4 M-byte IC memory card #29038a 28FO20 2 M-bit device #290245 IRS Application notes 4 12 Very Useful AP325, Guide to Flash Memory Reprogramming #292059 AI’343, High-Density Applications Using Intel Flash Memory #292079 413 Moderately Useful 414 Not Useful

pASM TM for REAL-TIME EMBEDDED SYSTEMS newfeatures: ; F;;!.Ji,bal;ily *TEXT EDITOR, CROSS ASSEMBLER, AND ll Full MS-DOS compatibility 0 preemptive scheduler COMMUNICATIONS FACILITY IN A COMPLETE 2 80x87 & math emulator 0 libraries for all memory INTEGRATED DEVELOPMENT ENVIRONMENT models support for reentrancy 0 works with Microsoft% l MACROS Zl Stack size up to * CONDITIONAL ASSY and Turbo’C, assembler us $149.95 64K per task and debugger l LOCAL’AUTO LABELS EACH 51 Protected heaps & 0 70 microsecond task l SYMBOL TABLE CROSS REF task-reentrant calls switch (10MHz 60188) * S OR HEX FILE OUTPUT DOWNLOADS pLus S’H* J ~25 register bank support 0 15 microsecond interrupt TO MOST EPROM PROGRAMMERS Zl PC demo source code latency 1 Fast pipe macros 0 5KB to 25KB code size AVAILABLE FOR MOST 8-BIT MICROPROCES- 0 1 year free support SORS AND 680001010. CALL OR WRITE FOR Dev. Kit & & updates TECHNICAL BULLETIN. 30 DAY MONEY BACK No Royalty License 0 30 day money-back GUARANTEE. MCIVIAE. $1995 guarantee Source Code - $1000 Micro Dialects, Inc. Evaluation Kit BL MICRO DIGITAL * PER SHIPMENT: DEPT. C, PO BOX 30014 PC demo - $95 $5 CONTIGUOUS USA Cypress, CA 90630-5630 $10 CANADA AK, HI CINCINNATI, OH 45230 User’s Guide & demo disk - $25 l-800-366-2491 $20 INTERNATIONAL (513) 271-9100 FAX 714-895-2164

Reader Service #161 58 CIRCUIT CELLAR INK FIRMWARE ANSI Controls and FURNACE

Fixed Points Ed Nisley 1 The Furnace Firmware Project Continues

Last winter when I laid out the ters from the serial port. The piezo your application can use TTY-style Furnace Firmware project I forgot beeper sounds off only when charac- output, you’re in good shape. about Serious Heat and Humidity: ters come from the keypad. However, you probably want to right now it’s 90°F at 90% and I have On the other side of the user inter- treat the LCD panel as a static display no intention of firing up the furnace face, sending a character to the LCD screen: write some fixed information, for a code check! So this column in- firmware as well as the serial port is so then move the cursor around to up- cludes the ANSI LCD driver and a simple we don’t even need a listing to date selected values. This improves fixed-point math package. Never fear, explainit: if the LCDEcho controlbit is output speed because fewer charac- when the heating season rolls around set, just Call LCDSendChar from ters are sent and, depending on the again you will get the final wrapup! putch ( ) after sending the character LCD controller, may also eliminate to the serial port. As you saw in CIR- display glitches. But, because TT’Y- PARALLEL CHARACTERS CUIT CELLAR INK#15, LCDSendChar style output can’t handle cursor posi- handles the common “control” char- tioning, this trick is impossible. With The Furnace code so far includes acters: LF, CR, FF, and BS. As long as the putch (1 interface so far, you keypad input and LCD output rou- tines, but they are entirely distinct _getch PROC from the normal C console I/O rou- PUBLIC _getch tines. Wouldn’t It Be Nice If the C >> getch ( ) function returned charac- ,a--- check for a char from the serial port ters from the keypad and putch (1 L?uait MOV A,RRing_cLevel sent output to the LCD panel, in addi- JNZ L?fetch tion to the normal C serial console support? r*--- check for keypad char The keypad firmware in G~curr JNB PadConsole,L?wait ; skip pad if not enabled CALL KbdTestChar CELLAR INK #16 produces a character JNC L?wait : none, so continue waiting for each key press, using the timer tick CALL KbdGetChar ; have one, get it to control polling. Listing 1 shows the SJMP L?polish ; fix it up few lines of code needed to splice those I)*--- get char from serial port ring buffer characters into getch () . A similar L?fetch addition to kbhit () (which is not shown here) indicates when a charac- <<< serial port code omitted >>> ter is available from the keypad. The I*--- polish the character Padconsolebitcontrolsthenewcode L?polish CJNE A,#CR,L?l ; use LF instead of CR in each routine, so you can disable the MOV A,#LF L?l connection and process keypad char- %IF 0 acters separately by calling KbdG- ANL A,#$7F ; strip high bit %ENDIF etChar () when needed. MOV R3,A The keypad translation table now MOV R2,tO ; high byte always zero includes the CR, ESC, Ctrl-C, BS, and RET hyphen characters needed for “nor- _getch ENDPROC mal” console input. Because the three remaining function keys still return listing 1 -Combining keypad input with the serial port requires only a few lines of code. characters above 80 hex, get c h ( ) no If the keypad routine has a character ready, it will take precedence over one from the longer clears bit 7 as it did for charac- seriaial port ring buffers.

December ‘9a/January ‘9 1 61 "ESC [ 1; 3 3 ; 4 lm” changes the color Screen coordinates start with Row 1 and Column 1 in the upper left column. of allsubsequent characters to bright The effect of coordinates outside valid screen boundaries is undefined. yellow on a red background, at least on a color display. (Remeber that ESC Cursor Control represents the escape character.) The numbers are simple ASCII, not binary ESC[r;cH Move cursor to specified row and column ESC[r;cf ditto, this is a synonym codes: the color-change sequence is ten characters long, not eight. ESC[nA Move cursor up n rows, stop at top row An ANSI driver intercepts all ESC[nB Move cursor down n rows, stop at bottom row characters going to the display. It ESC[nC Move cursor right n columns, stop at right column ESC[nD Move cursor left n columns, stop at left column passes through all “normal” charac- ters unchanged, but interprets the ESC[s Save cursor location ANSI control sequences and takes ESC[u Restore cursor location whatever action is appropriate; the ESC[2J Erase display and move cursor to upper left control sequences are not displayed ESC[K Erase line from cursor to right edge on the screen. Under DOS the ANSI console driver is a separate chunk of software installed as a device driver, Display Attribute Control while under OS/2 you get ANSI con- Once set, an attribute applies until it is changed. Some trols “free” with every session. codes set multiple display attributes. Although you could write spa- ghetti to decipher the sequences, Fig- ESC[xm Set display attribute to x ESC[x;ym (You can set several attributes at once) ure 2 shows a state diagram that may make more sense and certainly re- The most useful “x” parameters are: sults in better code. When each char- acter arrives, the action you take 0 Cancel all attributes (return to white on black) 1 Bold or bright depends on which state you’re in: If 2 Dim or normal the character doesn’t match any of the 5 Blink (only on displays that support blinking!) actions for the current state, you reset 1 Reverse video (black chars on white background) everything and send the character to 30-37 Set foreground color the LCD display. Remember that the 40-47 Set background color states themselves don’t do anything: they justremember”whereyou were” Color codes are: until the next character comes in. 30/40 black 34/44 blue 31/41 red 35/45 magenta The state machine driver code is 32/42 green 36/46 cyan too bulky to fit here, but there is one 33/43 yellow 37/4-l white interesting aspect that bears mention- ing. Most state machines you’ll see Figure I-It-m? ANSI COntfOl sequences allow a remote device to control the cursor location and display colors on a local terminal emulator. The ESC symbol designates the are based on a table of “current state Escape character, ASCll code 27 decimal or 16 hex. There are no spaces in the versus input character” that deter- sequences, and the last letter must be capitalized as shown. mines which routine gets control. Because the ANSI sequences have a rewrite the whole smash from the top so you can probably use these codes fairly restricted syntax, I figured out every single time. Something Must Be with no trouble. how to trigger the code based on ei- Done! Notice that these control se- thera specific character (the equal sign) quences start withan escape character or a general class of character (any ANSI ESCAPEES (1B hex, 27 decimal, yclept ASCII 271, digit). Take a look at ANSI . A5 1 for hence their common name of “ANSI this column to get the details; it may Fortunately, the American Na- Escape Sequences.” A left-hand square simplify some of your own code. tional Standards Institute (ANSI) has bracket follows the ESC, which identi- The driver stores all characters in defined a set of cursor, color, and fies this group of commands. Some a buffer, so the action routines trig- screen control codes that are (loosely) commands have one or more numeric gered by the final letter can validate implemented in the PC world. Figure parameters and all end with an upper- their parameters. Because the Set Cur- 1 shows the most useful codes; while or lower-case letter (and the case is sor Position and Display Attribute the LCD can’t display colors, it should significant!). sequences have several numeric para- at least gracefully ignore those codes. For example, the sequence to set meters separated by semicolons, I Most PC terminal emulators have an the cursor to row 2, column 3 looks included a “semicolon detector” ac- “ANSI BBS” mode in their bag of tricks, like "ESC [ 2 ; 3H”. The sequence tion to extract each preceding number

62 ClRCUll CELIARINK r FAST COMPLETE status display looks on both displays; ACCURATE while the PC console is more attrac- tive, the LCD panel gets the job done. PRAM TEST If you look closely at those pho- DIPS - SlMMs - SIPS tos, though, you’ll see something suspicious: where did those decimal points come from?

FRACTIONAL VALUES

Integer arithmetic is good enough for nearly all microcontroller applica- tions, but sometimes you really need fractions. For example, a stepper motor might move 7.5 degrees per step and drive a slider 0.05 inches each time. You could pick tenth-degree units in one case and lo-mil steps in the other, but Wouldn’t It Be Nice If you didn’t have to write special arithmetic and display routines for each situation? The obvious solution is to use floating-point numbers. The catch is that floating-point arithmetic is ex- pensive in terms of both code size and execution speed. Microcontrollers RAMSTAR don’t have numeric coprocessors (by Ins. RESOLUTION Figure 2-This state machine decodes the definition, I think), so all calculations ANSI control sequences shown in Figure 1. must be done in software (or, if you ACCESS SPEED VERIFICATION The final letter in each sequence deter- 80 ns. thru 180 ns. (Std.) $249.0 mines the function. please, firmware). The canonical “Hello, world!” occupies 5903 bytes 45 ns. thru 110 ns. (Fast) $349.01 4MEG Option Add $ 89.0’ from the buffer into a numeric array. using the Avocet fixed-point library; When the terminating letter arrives, the floating-point version requires AUTO-LOOP the decoder action routine can access 16008 bytes and doesn’t include any Continuous Test 6.25 MBitsisec the saved parameters from the array. floating-point operations! DAPTERS: A side benefit of buffering all the To put this in perspective, the SIMM/SIPADAPTER $189.01 characters comes when the ANSI Firmware Furnace routines don’t use Tests 64K, 256K, 1 M & 4M Devices driver receives a defective sequence. printf ( ) orthefloating-pointlibrar- 8 or 9 Bit versions. Rather than just ditching the charac- ies. As a result, the keypad, LCD,clock, ters, the driver dumps the buffer to NVRAM, and C utility routines pre- the LCD panel so you can see what sented so far weigh in at about 8K NTX ADAPTER $149.0 went wrong. This simplifies debug- bytes. There are some good reasons Tests 64 Pin Dual-Edge ging, and also permits programs to why I’m not enthusiastic about float- Lasetwriter Type SIMM’s display “bare” escape characters ing-point arithmetic.. . (which show up as a left arrow). Not all ANSI drivers support this func- iiiiiiii.ffffffff 4 X ADAPTER $ 89.C Tests 64K & 256K By 4 Bit Devices tion, so you can’t depend on it! ~ Tight fraction bits The CDEMOANS programexercises I- eight integer bits AC ADAPTER $ 18.r the ANSI driver by sending a series of Numbers are represented in two’s Regulated +5V @ 1 Amp. complement form: test patterns to both the console and FREE RAMFACTS LCD. The two displays should match, 0.0 = 00 00 0.0039 = 00 01 1.0 = 01 00 -0.0039 = FF FF DRAM NEWSLETTER save that your color monitor will have -1.0 = FF 00 127.9961 = 7F FF 0.5 = 00 80 -128.0 = 80 00 colored characters for some sequences. -0.5 = FF 80 [Editor’s Note: Software for this article is available on the Circuit Cellar BBS and Figure J-The fixed-point numeric format used in the Firmware Furnace project al- COMPUTERDOCTORS Software On Disk #28. See page 92 for lows for numbers between - 128 and + 128. downloading and ordering information.1 9204-B Baltimore Boulevard with a resolution of 0.39%. Each number College Park, Maryland 20740 occupies two bytes. Photos 1 and 2 show how a faked dADE IN U.S.A. >derSetice#l23 December W/January ‘9 1 63 The Firmware Furnace number into eight integer bits code must display some frac- and eight fraction bits. Re- tional values: temperatures member that the point (at least with the lo-bit doesn’t occupy any storage. ADC!), flow rates, time inter- Although there is a bi- vals, and so forth. I’ve put nary point in the middle, the together a simple fixed-point numbers add and subtract math package that illustrates just like ordinary integers. how to design a special-pur- Figure 4a shows how they pose numeric format. combine; if this looks like third grade all over again, FLEXING THE FIX that’s how simple it really is. Photo 1 -A srnall4x2OLCD display worksnicelyto displayallthe Notice thatresultsbeyond the necessary information. In CIRCUIT CEILAR INK #9 valid 128 range cause over- I described the fixed-point numeric ute, elapsed times are a few hours, flow because there are not enough bits format used in the Mandelbrot En- minutes,orseconds,andsoforth.Gen- to encode the full integer value; this is gine, which was an array processor erally, a range of a few hundred units a drawback of fixed-point numbers in dedicated to evaluating the Mandel- and resolution of about 1% is entirely general and not the fault of this par- brot set formula. Because the calcula- adequate, although your application ticular representation. tions required high precision, the num- may need mom bits on one end or the Multiplying two fixed-point bers only ranged from +8.0 to -8.0, but other. numbers is a little bit trickier, because with a resolution of about 10-‘8. Figure 3 shows a fixed-point the product contains twice as many More mundane applications usu- numeric format suited to the Furnace bits. Figure 4b shows that ordinary ally require a wider dynamic range Firmware project. Values range from multiplication produces the correct and fewer decimal places. For ex- +127.9961 to -128.0000, with a resolu- result, but the binary point is located ample, domestic temperatures are tion of 0.39% (or 1 part in 256). Each in the middle of the four-byte result. I under 100 degrees, furnace circulator number requires two bytes, with an used unsigned long int variables pumps run at a few gallons per min- implied binary point dividing the (which are 32 bits in the Avocet C

SUPERVISION/8

CSI-100 RS232 SeriallPowerline interface C~rcun board accepts RS232 serial ASCII commands lrom any PC serial on. modem or dumb terminal. CEBus language or X-10 commands may g e directly entered through senal porl ior ouip~l on the AC powerline. The battery backed clock six 256 .event table control CBM-100 or X-10 modules by time of day independenl of the PC 9350 CSI-lOO-MS Menu Software NOCHARGE 1 CBM-100 Powerline l/O Module Features SIX digflat 10 lknes which are brou ht OUI to .l’ header for easy anachment to accessory In) boards. One t8 line also drives an on-board opto-cot&d triac capable of controlling a 1201240 VAC 4 amp load wa screw lerlninal barrier slnp. Board is compatble wrth CEEus commands. $95 CBM-100-01 CBM-1 w-02 CBM-loo-03 Opto-Isolated Input Driver Terminal Board $269.95Std. Res. 256 x 244 $369.95High Res. 512 x 488

Supewision/B is an adapter with software, the latest in e~momically capturing high quality real world images with your computer.

l HalfSizzCuds l Z.%GrcyInvcls-8Bit l Cqmm Tim l/60 secxmd l TIFF and PCX Format l BinuvImarzeFiIc~BIFl ’ PCKi-IATC-atiblc I I ’ MC/visa. AM. Bxpm g RS-170VideoSounc IDEC, INC. 1195 Doylestown Plkc TEL: 215-538-2600 Ouakcrtown. PA 18951 FAX: 215-538-2665 Reader Service #IO 44 ClRCUlT CELLAR INK in the middle of the quotient, thus needing a shift after the division. In both routines, I calculate the signs separately and perform the long arithmetic on unsigned quantities to avoid obscure problems with C’s sign extension and bit shifting logic. I’m pretty sure the code can be tuned up! Whatever you do, test your code at the ugly boundary conditions: I thought I had this stuff working quite a few times before it reached this condition. Displaying a fixed-point number involves two steps because the inte- ger and fraction parts must be con- verted separately. The former is easy enough; see ConShowInt in CONSOLE. ~5 1 for details. Convert- Photo P--Thesame displayash Photo 1 looksmuch niceron a full-color CRT, butisn’t quite ing the fraction to ASCII is ordinarily as convenient. a tedious operation involving long division and considerable hocus-po- implementation) to hold the interme- Figure 4c shows how the dividend is cus. Listing2 showsa shortcut: entries diate results and product. Extracting aligned to the high end of a four-byte in a table relate fraction bit locations the result is a simple matter of shifting unsigned long int and the divisor and the corresponding packed BCD the product eight bits to the right and shifted into the middle of another. equivalent, accurate to four decimal returning the low-order two bytes. This produces the result directly in the places. Division, being the inverse of lower two bytes of the quotient. An The code in Listing 2 tests each bit multiplication, requires more setup. unshifted divisor would put the result position and accumulates a BCD total

IBM Surplus. 8 wire. 4 windings. 7V @ 350 mA 1.8’ (200 steps per rev.) DC. res. 20 ohm ea. 25 oz. in, torque. Works great on 5vdc. W/Data

#l by OMRON. DPDT 10 A. cont. 150 ohm co 1x1.5x.75 inch. $2.95 e

#2 by P&B. SPST-N.O. 30 A. cont. 160 ohm coil

5534 (DIP) ...... $0.99 High Voltage I Very Dangerous. MC3403 (DIP) $0.49 11OMFD 450VAXlAL ...... $1.99 TL084 (DIP) ...... $0.99 800 MFD 450V CAN ...... $4.95 RC4558 (DIP) ...... $0.49 5100 MFD 350V CAN . . . . . $6.95 4136 (DIP) ...... $0.69 ALL NEW. NAME BRANDS ! LM339(DIP) . . . $0.49 75491 (DIP) ...... $0.49

Reader Service #lGO

December W/January ‘9 1 65 scaling, offsetting, and displaying reasonable numbers, using a fixed- point math package will give you a substantial performance boost and a significant size reduction . ..benefits not to be sniffed at! You will probably find that the dynamic range of f128 available with a single integer byte is not enough. The next logical step is two integer bytes and one fraction byte, giving you f32K with 0.39% resolution. If you can afford four bytes, add eight more fraction bits and extend the reso- lution to 15 parts per million. The algorithms I’ve used scale nicely to more bits and digits, although you will have to modify the register usage because I avoided buffering interme- Photo J-The output of the CDEMOFIX program shows the resutts of all four basic diate results in RAM. arithmetic operaffons on two user-entered numbers. SUMMING UP for all the “one” bits. The final result is all four arithmetic operations. Photo 3 a fourdigit packed BCD value repre- shows the results on a PC monitor At this point, you have nearly senting all eight fraction bits. Display (sorry, they don’t fit on the LCD everything you need to build an 8031 is then just a matter of calling a routine panel!). The source code includes sev- system that’11 blow their socks off: that converts a two-byte binary value eral handy routines, including input interrupt-driven ring-buffered serial into an ASCII hex string. Think about and display functions for both integer I/O, console support for both LCD it: there is no way to tell whether 1234 and fixed-point numbers. and keypad hardware, fixed-point is hex or packed BCD. Slick, eh? If your controller application re- math, nonvolatile RAM, analog in- Besides, I’ve always wanted to quires transcendental functions or puts, timekeeping, and a great glob of use the Decimal Adjust instruction.. . other exotica, you’ll be well-advised glue code. All you need is the pro- The CDEMOFIX program runs to use the standard floating-point li- gram that connects the pieces. through several test sequences, then braries and functions instead of writ- But do you need C? No, it turns prompts you for a pair of fixed-point ing your own code. However, if your out that most of the code doesn’t de- numbers and displays the results of calculations are more along the line of pend on C at all. True, the calling conventions are peculiar to Avocet C, but those can be readily adapted to (a) 1.0 t 1.0 0100 t 0100 = 0200 = 2.0 0.5 + 0.25 0080 t 0040 = 00~0 = 0.75 other compilers-or to your own as- 3.0 - 1.0 0300 - 0100 = 0200 = 2.0 sembly language standards, as you 5.0 - (-1.0) 0500 - FFOO = 0600 = 6.0 see fit. 127.9961 + 1.0 7FFF + 0100 = 80FF = -127.0039 -127.9961 - 1.0 8001 - 0100 = 7FOl = 127.0039 Of late, I’ve ignored the BASIC-52 interpreter because shoehoming the (b) 1.0 * 1.0 0100 * 0100 = OOQJQQJO = 1.0 codeinto that straitjacket requires too 5.0 * 0.5 0500 * 0080 = OOWO = 2.5 -1.D * 2.0 FFOO * 0200 = FFpEee90 = -2.0 much fiddling around for my pur- -2.0 * -3.0 FE00 * FDOO = OOphpQOO = 6.0 poses here. However, I did write the 64.0 * 2.0 4000 * 0200 = OOaepMO = -128.0 LCD and keypad code with BASIC-52 (c) 1.0 / 2.0 Ql.QQJooo / ooQ2MDo = OOOOaQgq = 0.5 in mind, so it would not be too diffi- 2.0 / 1.0 p2QeDooo / ooQJ.QQQo = ooooQ2QJ = 2.0 cult to support BASIC console I/O. -1.0 / 2.0 EppeDOOO / OOp2pe90 = FFF- = -0.5 I’ll leave this as an exercise, and if you -2.0 / -4.0 pEMI,OOO / FFW0 = OOOOD = 0.5 drop a note on the BBS after you’ve Figure 4-a) Because the numbers use two’s complement notation, fixed-point addition studied the problem for a while, we’ll and subtractton work just like Integer arithmetic. Notice that overflow occurs for results even help you out! exceeding the valid* 128 range. b) Multiplying two fixed-point numbers produces a result I’m not entirely satisfied with C with twice as many bits. The product term is containedin the middle two bytes of the four- byte result. c) Uvlding two fixed-point numbers requires two alignments. The Furnace for microcontrollers. The amount of Firmware code moves the divisor to the middle two bytes of a four-byte variable andputs code per line seems excessive, the C- the dlvidendln the high bytes ofanother four-byte vartable. The result appears in the lower language library routines are entirely two bytes of the quotient. too bulky, and there are, regrettably,

66 ClRCUtJ CEl LA R INK

Magnetic Levitation: FROM An Example in THE Closed-Loop Control BENCH 4 Jeff Bachiochi How to Defy Gruvify Wifhouf the Use of Black Magic

I Y 1 ve always had an urge to be a magician. While other kids were watching Mighty Mouse on Saturday mornings, I’d be tuned into Mark Wilson performing impossible feats of prestidigita- tion. One of the more common il- lusions is the levitation of ob- jects. The magician or illusionist will cause an object to literally rise or float without any visual means of support. Solid hoops or rings are passed around the ob- ject to confirm the reality of the situation. Even though we know there is logically some unseen means of support, we allow our- selves to be hoodwinked simply for entertainment purposes. Suc- cessful magicians are most profi- cient at disguising their secrets.

NO VISIBLE MEANS OF SUPPORT equilibrium is reached where magnetic attraction exactly counters gravity somewhere within the IR beam’s path. If you’ve been in any gift/novelty store recently, you may have seen one of the “floating orb” novelties. This is OPEN VERSUS CLOSED LOOP a simple, freestanding frame in which an object, usually a sphere, is held visually unsupported in midair. Quite a Any control process can operate in an open- or closed- stunning illusion! loop fashion. However, the term “open loop” is an oxymo- Upon closer examination, you’ll discover that mag- ron. As the word “loop” suggests, it is made up of a netism is the key to this example of parlor trickery. A continuous path, whereas “open” suggests a noncontinu- magnetic field is generated by an electromagnet hidden in ous path. Open-loop control is simply an action without the top of the frame and attracts the sphere upward. An any knowledge of the result, like turning on the porch light infrared transmitter/receiver pair is mounted across the without looking out the window to see if it actually went frame about one inch below the top. As the orb is gently on. On the other hand, closed-loop control adds some kind lifted into the IR beam’s path, the signal strength is re- of verification that the control has had some effect on the duced at the IR receiver. When the linear output of the IR task. One peek out the window confirms the result. Either receiver drops to about 2.5 volts, an electromagnet is the light did in fact go on, or it was on and you turned it off. switched on. As the IR reception is further reduced by the Possibly, it is burned out or, even worse, another slip of sphere rising toward the electromagnet, the voltage to the paper gets added to your job jar. So, you can see that coil is also reduced. This reduces the magnetic field and closed-loop feedback can not only show the process is gravity begins to win. When the sphere drops, the received operating correctly, but, just asimportantly, what has to be IR increases which strengthens the magnetic field. An done to correct any errors in the output.

December ‘90/January ‘9 1 7 1

An integral mode output changes faster for larger rates of error input, and drives the output at a slower rate as the error input approaches zero. This mode is normally used in combination with other modes where the process lag is short. Integral mode is defined by:

where: P(t) = output at time t Ki = scaling constant t E,(t)dt = % change of input at time t from time 0 I I401 = controller output at time zero

A derivative output is directly related to the rate of change of the error. That is, the output is driven not by the amount of error, but by how fast the error input is chang- ing. Therefore, there is no output from either constant or no error, and maximum output from instant error. This mode is used in combination with the other modes due to its ineffectiveness when the input error is constant. The V = KpVp +Vo derivative equation is defined as:

P=K++I’o lure 2-The proportional control output has a direct linear rela- dt inship fo the error input.

LASERS VISIBLE LASER DIODES HELIUM NEON LASER KITS F Toshiba TOLD 9200. Kits consist of matching Yiiiiz3*TUBES & HEADS 3 mw, 670 nm Red output. laser head and power New hard sealed units Cat. #LDV 9200 $75.00 supply, along with a user’s manual. All kits .5 - 1.0 mW TUBE. Operates on 1300VDC @ fi+d POWER SUPPLY are FDA approved. 4.0mA. Dimensions: 5.8” x 1.0” diameter. Cat. #06 $35.00 for Toshiba - 9200 series diodes, .95mW, 633nm (Red) output with 12VDC input 4.5V input, .75” x .6” dia. power supply. Draws .85 amps. 5-7mW TUBE. Operates on 2200VDC @ 6.5mA. Cat. # LDD-92 $35.00 ~ Cat. #HNKD-95 $110.00 Dimensions: 13.8” x 1.45” diameter. Cat. #50 $100.00 .95mW Kit with 1IOVAC input power supply. @ COLLIMATING LENS @! , Cat. #HNKA-95 .,.,$J for visible diodes. Just $130.00 2 - 3 mW POLARIZED HEAD press over diode. 4.5mW, 633nm (Red) output with 12VDC input Operates on 1800VDC @ 6.5mA. Dimensions: 10.8” x 1.75” diameter. Cat. #L DC-6 $20.00 power supply. Draws 1.5 amps. Cat. #HNKD-50 $200.00 Cat. #23OHP $90.00 +d VISIBLE DIODE MODULE HELIUM NEON POWER SUPPLIES L 4.5mW Kit with 11OVAC input power supply. 0.8 mW typical Cat. #HNKA-50 $220.00 New, factory made, switchers. lo-14VDC input micro P/S for 06 tube. Only 2.1” x .88” dia. output power hc-$ 6.5mW 633 (Red) output with 12VDC input Cat. #12-B @ 670nm (red) power supply. Draws 1.5 amps. $75.00 Cat. #HNKD-100 Factory made module that $230.00 ADJUSTABLE SUPPLIES includes the diode, collomator, 6.5mW Kit with 1lOVAC input power supply. From 1.2 to 2.6KV, 4-6.5mA. For .5 to 7mW HeNe Lasers. and power supply, all in a 1.6” x Cat. #HNKA-100 $250.00 12VDC input supply. .63” diameter housing. Operates 50mW 543 (Green) output with 11OVAC Cat. #12-C $75.00 on 3.9 to 5 VDC @ 80mA. i+* :Input power supply. 11OVAC input supply Cat. #llOADJ $95.00 Cat. # LDM-001 $150.00 I Cat. #GHNKA-10 $465.00 t I Call or write today to receive a FREE CATALOG which includes bOptics, Holography, Kits, Scanners, Books, and more. &r-ladi$~ Instruments “THE SOURCE FOR LASER SURPLUS” 6403 N. 59th Avenue I Glendale, Arizona 85301 . (602) 934-9387 l P. 0. Box 1724 I Glendale, Arizona 85311 ReaderService#153

December ‘90/January ‘9 1 where: P = output K, = gain constant dEP - rate of change of error dt PO = output with no error rate ADDING THE PROPER INGREDIENTS

Most industrial applications which use closed-loop control make use of a combination of controller modes. Thisisaccomplished by combining the proportional mode with either the integral or the derivative or both. The PI (proportional-integral) mode eliminates the offset error normally associated with the proportional mode. The I’D (proportional-derivative) mode is used to handle fast process load changes. While the PID mode can handle virtually all process conditions, it is the most complex. Process control does not necessarily mean computer control. This is obvious in the simplicity of our home heating systems. Once other parameters enter into the picture, however, things change. Nightly temperature setbacks, different temperatures in each room, interfacing where Ki =& for external control (e.g., hand-held infrared) make control impossible for a simple mechanical thermostat. Microcon- Figure 3-An integral mode output changes faster for larger rates trollers give us the ability to change algorithms easily of error input and drives the output at a slower rate as the error through software, which really beats getting out the old input approaches zero. soldering iron and attacking the hardware to alter the

Model 250 for Algorithm Development, Data Acquisition, Instrumentation, Audio.

l TMS320C25 DSP at 10 MIPS. l Up to 192 Kwords RAM. l Multi-Channel Analog IO - 25OK Samples/%x. l Development Software, including Assembler & Debugger. l Applications Software includes FFT. Signal Display, Data Acquisition &Waveform Editor. l No Gap Sampling to/from Disk at Very High Rates. l Supports Multiboard & Standalone (EPROM) Operation. l From S109.5. Other DSP Products Available. DALANCO SPY 89 Westland Avenue Rochester, N.Y. 14618 (716) 473-3610 _ _ ReoderServicet187 Graphics Gems edited by Andrew S. Glassner This handbook provides practi- cal solutions to graphics problems, and every graphics programmer will find it an essential tool in saving time and energy in their daily programming activities.

August 1990, 833 pp., $49.95 ISBN: O-12-286165-5

Curves and Surfaces for Computer Aided Geometric Design A Practical Guide SECOND EDITION V = Kd% (where Kd = R2x C) Gerald Farin 1990,444 pp., $39.95/ISBN: O-12-249051-7

Figure 4-7he output of a derivative mode controller is driven by how fast the error input is changing. The Desktop Fractal offset, gain, integral, or derivative parameters every time Design System we want to adjust the system. Michael F. Bamsley Includes The Desktop Fractal Design Handbook and one floppy disk. APPLYING THE MAGIC OF MICROPROCESSOR IBM Version: The system requires an CONTROL IBM, or compatible, PC with a graphics board (EGA or VGA) and 640K memory. Process control with a simple input and output doesn’t 1989, $39.95/ISBN: o-12-079063-7 Macintosh version: The system runs require a microcontroller. However, using a simple proc- on , the Macintosh SE ess allows one to easily grasp the basics and the advan- series, and the Macintosh II family of computers, with a megabyte of memory. tagesof using this approach on a more cost-effective basis. Color graphics is not required. No math coprocessor is necessary. The software With a small amount of signal processing, the position will work with version 6.0 or higher of (error input) of the process load (ball) can be transferred to the Macintosh operating system. a microcontroller through an analog-to-digital converter, August 1990, $39.95 providing an error signal. The output control uses a digi- ISBN: O-12-0790645 tal-to-analog converter to vary the voltage of the electro- magnet. The hardware selected for this project includes Fractals Everywhere theRTC52andRTCIO.[Editor’s Note:See “From theBench” Michael F. Bamsley in the April/May ‘89 issue of CIRCUIT CELLAR INK (#8) for a 1988,394 pp., $39,95/ISBN: O-12-079062-9 description of the RTC52 and RTCIO boards.1 Both an A/D and a D/A converter are included on the RTCIO board. An Introduction Figure 5 shows the test setup which is fairly simple to to Ray Tracing construct. A hefty electromagnet’s field is directed by a edited by steel bar added to the top pole. This bar is bent down at Andrew S. Glassner each end creating flux lines which tend to pass through the 1989,327 pp., $49.95/ISBN: O-12-286160-4 sphere being levitated. An IR transmitter and receiver are placed below the electromagnet within the magnetic’s limit of attraction. The analog circuitry to interface the IR Order from your local bookseller or directly from input and solenoid driver is wired on a prototyping board. ACADhC CALL TOLL FREE The hardware stays the same no matter what algo- PRESS l-800-321 -5068 Harcourt Brace Jovanovich, Publishers Quote this reference number for rithm software we use. Because the process load will be Book Marketing Department HO120 free postage and handling on 1250 Sixth Avenue, San Diego, CA 92101 your prepaid order * 10120 changing rapidly, I’ve chosen the combination propor- Prlcess”b,ecttochangewltho”tnotlce 01990byAcademlcPress.Inc AllRlghtSRBSBrYsd TWSS--IDIP

Reader Service Xl01 December ‘PO/January ‘9 I 75 Let’s assume that: Ctr-t,> = 0.001 s sample time P, = 0 (no set point) Kr + K, + I’, = 1 (no gain 5Vin/5Vout)

Therefore: E =KpEp+(l -K,XE,-Eo) + 0 0.001 where: E = output KP = proportional gain % E = input (Q-K I = derivative gain (what’s left after KJ (E -g,J = change in input error O.&l = sample time (additional gain dependent on [Er-E J) O=noP,

Since the A/D and D/A converters both have &bit resolution, data in both directions will be in an unsigned character format of ranging O-255. If we use an integer in the range of O-10 to replace the normal gain value (%) and remove the factor of 10 later, all the math can be done in integer format, which speeds up overall program execu- I tion. The program shown in Listing 1 executes at 40 milli- I f ’ seconds per sample when run under interpreted BASIC- to ADC 52. 0-W frokYc At a 40-ms sample rate, the ball drops quickly to the floor. Fortunately, by compiling this BASIC-52 routine Figure 5- me test setup consists of an erectromagnet, 112 transmlt- ter, IR receiver, support frame, and controller. with BC151 Integer BASIC Compiler (also sold under the tional-derivative mode for this project. Here we have a +- r+5 process lag between the time the error is detected (by the IR beam) and the adjusted output voltage changes the magnetic field. This process lag can, if too long, cause the sphere to drop. If the lag didn’t exist, the proportional mode would provide adequate control. Somewhere be- tween the two extremes exists a cyclic condition where the ball merrily oscillates about the set point, gradually rising in amplitude between the control extremes. This generally leads to a loss of control. In this case, a bit of derivative mode control can make up for the process lag by adding additional error correction which is dependent on the r-=-l error rate of change. I Microcontroller 1 The equation for a combination proportionalderiva- tive mode would be: D/A 0-SU OUT

E =K,E, +Kd(Ep-Eo) +po A 1 tp -to where: E = output KP = proportional gain

t, = time of last input = time of this input Figure 6-The interface for the ‘floating orb’ project shows the I/? b0 = set point transmitter and receiver sections and the magnet control.

76 ClRCUlT CELLAR INK AND THERE YOU HAVE IT! 10 TCON=TCON.AND.OF7H : REM CLEAR INTl 20 TCON=TCON.OR.O4H : REM INTl=EDGE TRIGGERED 30 KP=9 : REM 90% PROPORTIONAL Photo 1 shows a slow sine wave fed into the A/D 40 EP=O : REM INITIALIZE TO ZERO converter and the resultant processed D/A output. You : 50 EO=O REM INITIALIZE TO ZERO can clearly see the samples leading the input. Adding the 60 KD=lO-KP : REM 10% DERIVATIVE 70 v=(tKp*Epj+tKD*(~~-~0)*100) )/lo : REM CALC extra input and output circuitry to the microcontroller was 80 IF V255 THEN V=255 REM LIMITS MAX TO 255 ing theeffect in the derivative and the success proved 100 XBY(OEOZOH)=V : REM OUTPUTS VALUE TO DAC path, 110 XBY(OEOlOH)=O : REM SELECTS CHAN 0 AND exciting. Now if only I could make the ball disappear! STARTS A/D CONV One last note: If you value any of your software, 120 IF(TCON.AND.O8H)=OoH THEN GOT0 120 : REM WAIT FOR EOC experiment with magnets at a considerable distance from 130 TCON=TCON.AND.OF7H : REM RESET INTl FLAG your computer and media storage. Unless, of course, you 140 EO=EP : REM SAVE PRESENT SAMPLE AS LAST wish to bulk erase everything in sight. e 150 EP=XBY(OEOlOH) : REM GET A NEW SAMPLE 160 GOT0 70 : REM GO CALCULATE AGAIN 170 END BIBLIOGRAPHY 1 listing 1 -Software to control the orb consists of only a few lines of “Process Control Instrumentation Technology” by BASIC-52 code. Curtis D. Johnson (John Wiley & Sons). name IBASIC- from Micromint), this routine runs at 1.4 Jeff Backiocki (pronounced “BAH-key-AH-key”) is a member of the ms per sample on an RTC52. This is a smidge over what I’d Circuit Cellar INKengineeringstaff. His background includes work in hoped for but still gives 10 samples during the 14 ms it both tke electronic engineering and manufacturing fields. In his spare takes the ball to fall 1 mm. This proved to be adequate. time, Jeff enjoys his family, windsurfing, and pizza. Correction: In the RTC-V25 project presented in the last issue of IRS CIRCUITCELLARINK, themaster crystalshouldbelabeled16MHz. A revised RTC-V25 schematic is available which contains this 418 Very Useful correction plus some design revisions. To obtain a copy, send a 4 19 Moderately Useful SASE to Circuit Cellar INK, 4 Park St., Vernon, CT 06066. 420 Not Useful

FOR EMBEDDED DATA AQUISITION AND CONTROL APPLICATIONS EMAC OFFERS A COMPLETE LINE OF INDUSTRIAL STRENGTH SINGLE BOARD COMPUTERS ANDSUPPORTPERIPHERALS, WITH ALLTHE FEATURES NECESSARY TO PROVIDEYOU WITH ATOTAL SYSTEM SOLUTION ! FEATURES INCLUDE: l DIGiTAL AND ANALOG I/O l TIMER/COUNTERS The EC-32TM is a versatile 8OC32 microcontroller l RS232/422 SERIAL PORTS board. It is ideal for quickly developing products, prototypes or test fixtures. l DISPLAY BOARDS l TERMINAL BOARDS

l 8OC32 microcontroller (8051 compatible) l SIGNAL CONDITIONING CARDS l 35 mA operating current, 100 uA standby l EMBEDDED FORTH 8 BASIC LANGUAGES l Program in C, BASIC or assembly language l PRICES START AT $249.00 CITY 1 l 8 - 92K RAM, EPROM, EEPROM l Breadboard area and expansion bus l RS-232 port and 12 digital I/O lines EVilAC, inc. l $100 Iota Systems, Inc. E QUIPMENT M ONITOR AND C ONTROL POB 8987 618-529-4525 Incline Village, Nevada 89450 P.O. BOX 2042 CARBONDALE, IL 62902 (702) 831-6302 Reader Service # 147 December ‘90 /January ‘9 1 7 7 SILICON UPDATE Goodbye CRT, Hello LCD Tom Cunffel

I can’t remember for sure, but I think my first experi- THE GOOD, BAD, AND UGLY ence with an LCD (Liquid Crystal Display) was during the digital watch craze of the mid-‘70s. Everybody tried to get As mentioned, the original and still claim-to-fame for in the business-the boom attracted unlikely entrants the LCD is low power consumption. A brief explanation of including Intel where I worked (the idea was to sell chips LCD basics will show why. with wrist bands). Needless to say, that episode isn’t dis- The liquid crystal phenomenon actually was discov- cussed in mixed company. ered over 100 years ago but the concept laid dormant until Anyway, my first digital watch had a seven-segment- the ‘6Os, when revitalized research finally gave us our ’70s type LED display. The only problem was that due to high LCD watches and calculators. powerconsumption,theLEDdisplaycouldn’tbeleftonall Figure 1 shows the organization of a simple TN the time.Instead, the watch had a tiny button to turn on the (Twisted Nematic) “reflective” LCD. Naturally, the key display only when necessary. for LCDs is the “liquid crystal” ma- Of course, the concept was an terial-a proteingoo. Likeacrystal, ergonomic nightmare. For instance, the material has the property of working the watch while talking on “turning” light in a certain direc- the phone meant either switching tion. Like a liquid, the orientation of the phone into the shoulder/ear- the crystal is “fluid”; in particular, jam position or executing a maneu- the orientation can be changed by ver something akin to punching h Glass theapplicationofanelectronicfield. yourself in the nose. Checking the To make a display, the liquid time while driving a car was also an crystal is sandwiched between a exciting proposition, leading to the + Rear Polarizer grid of electrodesand sheetsof glass. insight that it’s better to be late for The other key are two polarizers an appointment rather than never + Reflector (front and back) which are oriented arriving (at least in one piece) at all. 90 degrees out of phase. Polarizers Enter the LCD, a technology have the property of only passing which, thanks to “reflecting” rather 1 I light which is “aligned’ with the than “emitting” light, consumed so J polarizer. Perhaps you once tried little power that the display could Figure 1 -The organization of a simple TN reflec- this experiment during the heyday tive LCD. - 1 remain enabled at all times. Since it of “polarized” sunglasses. Take two relied on ambient light, the LCD watches still needed a lenses and put them on top of each other. Now, look high-power lighting system (and the dam button) for use through the pair as you twist them relative to each other. in the dark. In practice, there was usually enough daylight Sure enough, more or less light passes as the alignment (or even moonlight) so that button-fumbling was kept to a between the two lenses is changed. minimum. Finally, behind it all is a reflector panel. Remember, From humble wrist watch beginnings the LCD has the simplest LCDs rely on ambient light. slowly but surely improved and flourished. Now, LCD So, light enters the first polarizer and is aligned in one technology has reached the point that big changes in direction. Next, the aligned light enters the liquid crystal displays and associated products are on the horizon. and is either “twisted” or not depending on whether the In fact, it can be argued that the historical mainstay crystal isenergized or not. Light that is twisted by the crys- display, the CRT, is threatened by the emerging LCD tech- tal can successfully pass through the second polarizer nology. Sure, it won’t happen overnight, but read on and (which is twisted relative to the first polarizer) to thereflec- judge for yourself to what degree the LCD puts the CRT at tor and ultimately back to your eager eyes. On the other risk of extinction. hand, light which doesn’t get twisted by the crystal is

December W/January ‘9 1 79 blocked by the second polarizer and backlight technologiesareavailable thus not reflected. which offer various tradeoffs for Low-power operation is a re- light level and color, size, durabil- sult of the fact that theliquid crystal ity, and power consumption. The requires little power to retain orien- major contenders are EL (electrolu- tation and, like a CRT, need only be minescent) and FL (fluorescent) “refreshed” periodically. Using a lighting schemes. EL is best for low- row/column addressing scheme, end applications due to reduced only a fraction of the panel’s “pix- thickness, weight, and power con- els” (as few as l/100 or l/200) are sumption while, at the cost of wors- energized at any point in time. Thus, + Rear Polarizer ening these three factors, FL gener- the basic “good” of LCDs is that ates a brighter full-spectrum light. power consumption is tiny-typi- f- FL Backlight Another pair of related prob- callyO.O25-1 Wdependingonpanel lems is limited contrast and view- size. Contrast this to the 75 W or so ing angle; both are byproducts of for a typical CRT. I I losses and variabilities in the light’s The only intrinsic ‘bad” for twists and turns. Basic TN LCDs LCDs is that the liquid crystal, like Figure z- double SUP81 h&ted nematic may have contrast ratios as low as display adds another layer of llquld crystal. any other liquid, acts up when 4:l (read “light black characters on exposed to temperature extremes. Most panels are speci- a dark gray background”-in other words, don’t lose your fied to operate in a range of 0_5O”C, but some are limited eyedoctor’sphonenumber).Furthermore, theusefulview- to even a narrower range (e.g., 1040°C). For thenonmetric ing angle may be as little as 30-35 degrees. If you’ve ever out there, suffice it to say you shouldn’t expect your LCD tried to share an LCD display with another person (show- widget to work in a snowstorm or a heat wave. ing them something on the screen for example), you know The basic ‘TN reflective” LCD described so far (the it only works if both of you are real good friends. Unless typical calculator/watch-type display) does suffer from a you butt heads, one of you will see mush! variety of “ugly” problems. Most basic is the reliance on The solutions that have emerged for contrast/viewing ambient light. The solution is “backlighting.” A variety of angle problems are variations of the “Super Twist” theme.

Includes linker, librarian, and cross- reference utility Generates full source-level debugging information Lisa D’Ambrosia Nanette Traetow Automatically bank switches program 49 Walpole Street 242 East Ogden Avenue, greater than 64K using MMU Norwood, MA 02062 Suite A Linker allows code placement at both (617) 769-8950 Hinsdale, IL 60521 physical & logical addresses Fax: (617) 769-8982 (708) 789-3080 Outputs binary, Intel Hex and Extended Fax: (708) 789-3082 Intel Hex files Compatible with M80, SLR, 2500AD, and Avocet Assemblers Barbara Best 569 River Road Barbara Jones Built-in MAKE facility supports depen- Fair Haven, NJ 07704 & Shelley Rainey dency file checks (201) 741-7744 3303 Harbor Blvd., FREE demo disk available Fax: (201) 741-6823 Suite G-l 1 Compatible C-Compilers available soon! Costa Mesa, CA 92626 If you’re ready for a fast, full-featured, affordable product, (714) 540-3554 Fax: (714) 540-7103 give us a call. You’ll be pleasantly surprised. Christa Collins 7640 Farragut Street So~ooLs INC. 8770 Manahan Drive Hollywood, FL 33024 Ellicott City, MD 21043 (305) 966-3939 301-750-3733 301-750-2OO&Fax/BBS Fax: (305) 985-8457

Reader Service #IS6 80 ClRCUl7 CELlA R INK The simplest is called STN (Super Twisted Nematic). The only differ- Most obvious is the lack of ence from TN is that STN twists the color: Generally, all the previously lightmorewhichresultsina20-50% described LCDs are monochrome. improvement in contrast and view- Second, even the best LCDs don’t ing angle. achieve the contrast ratio of a CRT The next iteration, DSTN (one reason color isn’t a good (Double Super Twisted Nematic, match). Finally,a flaw you can’t see Figure 2) is nothing more than the in a brochure’s static screen shot is brute-forceadditionofanotherlayer that the LCD display update rate is of liquid crystal. Contrast and view- + Rear Polarizer relatively slow. Any user of con- inganglearedramaticallyimproved ventional LCDs knows that when f- EL Backlight and a true “black” is possible. The the beautiful screen starts scroll- downside is, besides adding weight ing, it quickly turns into an unrec- and thickness, DSTN needs brighter ognizable blur. backlighting to overcome losses Unfortunately, these limita- tions are in fundamental conflict throughtheextracrystal/glasslayer. tlgure J- me STN display adds a thin poly- The latest version, Film STN mer film to fill the role of DSTN’s second LCD. with the emerging computer stan- aaras,. * notably the shift to Macin- (Figure 3) reverts to the STN single-layer format, but adds tosh-/Windows-like color bit-mapped pointing-device- a thin polymer film to fill the role of DSTN’s second LCD. oriented visual interfaces. Even if monokhrome is deemed Though contrast ratio for Film STN (about the same as acceptable, the slow-update problem is a real show-stop- regular STN, i.e., 10-12:l) isn’t asgood as DSTN’s l&l, the Der. viewing angle is a much more usable 60 degrees or so. 1 Users of modern portable PCs (which wouldn’t even TFT TO THE RESCUE exist without the LCD) can testify that the display quality is quite good-a far cry from the first generation of Now, a new LCD technology is emerging: TFT (Thin “squintable” . Nevertheless, relative to the CRT, Film Transistor), also called “Active Matrix.” As the these LCDs suffer from three major weaknesses. names imply, the concept relies on placing a transistor at

SEE EEM 90/9 I H PC plug-tn or FE-232 box. Pages D 1320-1323 n Pull-down menus with full window support, combined with command-driven User Interface. W Up to 16 MHz real time emulation. n No Intrusions to the 68HCll’s resources. n 48 bit wide 16K deep trace. All functions usable without disturbing emulation. Time stamping. Two level trigger. n Symbolic and C Source Level Debugging, including in-line assembler and disassembler. n Supports A, E, D and F parts. Prices: 64K Emulator and pod $2590: 4K Trace $1995’ YJS only CALL OR WRITE FOR FREE DEMO DISK! 51 E. Campbell Avenue no#au Campbell CA 95008 CORPORATlON (408) 886-1820 FAX (408) 378-7869

Reader Setice it 170 82 ClRCUlT CELLAR INK ReaderService Y171 eachpixellocationincontrast toolder TN STN DSTN Film STN TFT LCD’s remotely driven scheme. The basic merit of the TFT ap- Contrast Ratio 4-8:l 6-10:1 18:l 12:l 4O:l proachis, thankstoreductionincross Response Time 200 ms 250 ms 250 ms 250 ms 40 ms Power Consumption 0.13 w 0.3-7 w 7w 3w 6-15 W talk, precise threshold control, and (with backlight) use of “less twisted” (i.e., faster) liq- Viewing Angle 35 deg. 40 deg. 45 deg. 60 deg. z-60 deg. uid crystal, the pixel canbe switcheh Thickness 5-12 mm 7-28 mm 28 mm 7mm 30 mm very quickly by the local transistor. (with back1 ight) Weight 25-150 g 150-1800 g 1600 g 800 g 1090 g Plus, exploiting FL backlight, con- Resolution Low Med High Med Med trast ratio is dramaticallv immoved Color Mono Mono Mono/Color Mono Mono/Color compared to the older iCds (e.g., 0.5x 0.7x IX lx 2.5x 403 vs. 18:l). Figure4 compares some Figure 4-A summary of LCD technologies shows the benefits and drawbacks of each. general specs for the older LCD types (TN, Sfi, DSTN, Film SIN) and the TFT LCD. would be glad to junk their CRTs in favor of a TFT LCD The TFT LCD has a couple of fundamental advantages today.Theproblemiscost,andalookathowTFTLCDsare over our beloved tubes. The latter rely on phosphors to made will shed some light on the million-dollar question, emit light while the LCD uses the combinationof backlight namely “why do they cost a million dollars.” and passive dyes. Thus, the LCD can achieve wider color range since the variety of dyes is much greater than that of THE WORLDS BIGGEST DRAM usable phosphors (and remember, TFT LCD ‘black” is really black). Also, since the CRT’s phosphors emit light Let’s take a look at a state-of-the-art TFT LCD: the from the surface of the screen, dispersion in all directions Hitachi TM26DOlVC. The TFT LCD is a cross between a introduces a “bleeding” effect. By contrast, in direct lineof regular LCD and a DRAM as shown in Figure 5. Like a sight, the LCD shows absolutely no overlap between adja- regular LCD, the TFT LCD relies on a sandwich of (from cent pixels. front to back) polarizer, glass, liquid crystal, glass, polar- The bottom line is TFT LCDs work real well now and izer, and backlight. The only difference is that additional they will only get better. In fact, the major barrier to wide- layers are placed on either side of the liquid crystal, in front spread use isn’t performance; I imagine 90% of PC users a color filter panel and behind a thin-film of transistors.

ystem rack tape r micro ge data

minis Easy to Use PC Software - ICON Based nframes Ultra Fast Performance - Mouse Driven CTRACK is the first choice for file Complete With Advanced Editing Tools interchange among data processlxq professionals. Now, Qualstar’s loa Output to Printers, Plotters & Lasers cogt I/Z-inch 9-track Streaming tape systems bring full ANSI data inter. PCB BOARD DESIW changetoIBMPCsorMacintosh,acintoskgivine Full range of products available from entry level yaw micro the freedom to exchange through to auto routing. data files with nearly any maklfmm@ or minicomputer in the world. Available in both 7” and 10-l/2’ SCHEMATIC CAPTURE version$ compact Qoalstar tape driver A family of products that feature modern graghical can sit OR your desktop, usingless spcc than nn ordinary sheet of paper. System8 user interface & an intelligent diagram editor. Simply exchange data files include DOS or XENIX compatible on a reel of g-track tape. I software, coupler card and cables. High II relial$ity 1600 or 6250 BP1 capab$t) t may be used for disk backup as well a~ 0 0 0 0 data interchange. Discover the big R4 SYSTEMS Inc. A - ATM advantage 9-track tape has over other i* micro/mainframe links. P.O.Box 451 %& m%%%>kage 0 “$ HFRAMES “$$$o. West Hill, Ontario Write or Call Today I l oeeeeeeeeeeee Canada Ml E 4Y9 I_~ (416) 439-9302 Download DEMO from BBS at 416 289-4554 (2400/8/N/l)

Reader Service #178 December ‘PO/January ‘9 I Conceptually, the TFT LCD is area per transistor will cost much simple. Each transistor is respon- 1 more than ten dies with one times sible for energizing the liquid crys- 4--- Front Polarizer the area per transistor. tal associated with the individual Remember, little stands in the color components of a pixel. The ‘I- Glass w/Color Filter way of making silicon dies Hitachi unit uses a “vertical stripe” !4-- Liquid Crystal smaller-indeed, the problem these arrangement in which each “pixel” 7N-- Glass WITFTS days is coming up with packag- corresponds to three (R, G, B) verti- ing/wiring schemes to handle ever cally aligned “dots” (the total pixel more connections with an ever ti- size, 0.33 mm, is about the same as a 4---- Rear Polarizer nier die. Of course, the cost-reduc- CRT). Thus, the 640 x 480 “pixel” ing “die shrink” concept can’t be panelisreallycomposedofMOx480 t- FL Backlight applied to displays; shrinking a x 3, or 921,600, transistors--about mainframe to fit on the head of a the same as a l-megabit DRAM. pin makes sense, but people like Indeed, the transistor setup is their screens a little larger. quite like a DRAM, with TFTs on Fabricating the TFT LCD panel glass substituting for the DRAM’s Figure 5-lhe TFT LCD is a cross belween a is only part (though the most ex- regular LCD and a DRAM. MOSFETsonsilicon.Unfortunately, pensive part) of the story. The while I can toddle down to local hacker emporium and TM26DOlVC also includes a number of control and driver pick up l-megabit DRAMS for little more than $5, the ICs that together offer a digital video CRT-type interface TM26DOlVC is a much more serious proposition-“Hmm, quite similar to that of typical PC. The electrical interface should I get a color TFT LCD-based PC or a new car?” between the “glass” panel and “silicon” chip portions of You see, the cost has little to do with the number of the panel is interesting: A “conductive organic adhesive” transistors; after all, the fundamental force driving the IC is used, bringing new meaning to the term “glue logic.” revolution is more transistors for less money. Instead, it’s The backlight also plays a big role since stringent the “die size” that kills yield. That’s because the statistical brightness and spectral characteristics are required for chance of encountering a process/material defect grows best results. Hitachi offers a unit (theTB2602) consisting of much faster than the area itself. A die with ten times the six fluorescent lamps and a diffuser. Note that while the

“INCREDIBLE” MICROCONTROLLER

New Features:

64 K hardware breakpoints. Contrvl!er Breaks on Ad- Features dress, address 100% Compiled range, and Data Basic Interpreter RD/WR. The MultlTRAX Microcontroller is a high capability cost-effective PC based real-time ICE. Easy to use, low cost & high perfor- single board control and data/ mance. Complete development support for single-chip & ex- sensor acquisition system. With its panded modes. Complex real-time hardware breakpoints. Sym- multitasking BASIC compiler, the MultiTRAX Controller provides bolic debugger. Windowed user interface. Data watch windows Pllnter PO,, real-time response anb extra- for memory, registers & stack. On-line assembler, disassembler, ordinarily fast program executron in a quick and effective program- single-step and trace commands. ming environment complete with on-board EPROM programmer. Logic analyzer trigger output. With its expandable smgle board form factor and extensive l/O 115.2K bps RS-232C Iink. capability, the MultiTRAX Controller adapts to a wide variety of applications as a complete stand-alone system or as a compre- 30 day money back guarantee. $595P* hensive embedded controller. (Introductory price) . ON-BOARD EPROM PROGRAMMER WICE 68HCll emulator 1 HIGH SPEED CMOS PROCESSOR . 96K BYTES OF APPLICATION 1 48 DIGITAL I/O LINES MEMORY SPACE Regular price: $795.00 1 TWO AS-232 SERIAL PORTS . FOUR EKTERNAL INTERRUPTS * For first 25 customers only lWytec1 1 MULTlTASKlNG BASIC LANGUAGE l PARALLEL PRINTER PORT 52 PLCC to 48 DIP adapter $55 Suite 140 COMPILER IN ROM . SINGLE BOARD FORM FACTOR Call: (708) 894-1440 185C East Lake Street !XPANSION MODULES: Space allocated on board Bloomingdale, IL 60108 . Keypad Module: . LCD mrphy . P”lsc,E”cnt, 1 . A/o CD”veRC, 4X4keyp’d lIIOd”k,%, Frequency cwmc, v . Realthnc Wkh tacflk calendar dock tC=dbaC* 1_11m -1 RRIES” PO BOX 130. Ftenchtown.NJ 08825 Distributors for the Far East wanted ELECTF(ONICS, INC. NJ (908)996-6841 l FAX (908)996-3891 ReaderSewiceXlW 84 CIRCUIT CELLAR INK LCDitselfconsumesabout 1 W (SV@60mA,25V@3OmA Make no mistake, the issue of CRT safety has the max) the backlight requires 17 W (12 V @ 1.4 A) to operate potential of becoming a big economic-political-legal- (36 W, 12 V @ 3 A, during start-up). medical-technical-emotional battle unless studies can Unfortunately for our wallets, the TM26DOIVC’s 21 l- conclusively prove it’s not a problem. mmx 158-mm”die” iseasily one-hundred times the sizeof Of course, you’ve probably guessed by now that the even the latest and greatest “wunderchip.” The term LCD doesn’t have the CRT “emission” and “radiation” ‘WSI” (Wafer Scale Integration) has been used to refer to problems (although I’m not sure about the backlight). forthcoming silicon “wafer” size (6”-8” diameter) chips. Assuming performance and price advantages of the CRT Since the TFI uses a similar-sized pane of glass, “WSI” are slowly but surely eroded by the TFT LCD, isn’t it only could also mean ‘Window Scale Integration.” Either way, a matter of time before the “safety” issue comes to the fore? “WSI” means big bucks and, for now, tight availability. OK, now you can go move your CRT back a tad.. .a According to Hitachi, most OEMs can get a panel or two to play with at about $3500 a shot. Though the price is Contact lower, say $2000, for manufacturing quantities, it’s kind of moot since production is just getting up to speed. I imagine Hitachi America, Ltd. it will be two years before panels are widely available. Electron Tube Division 300 N. Martingale Road, Suite 600 SAFETY FIRST Schaumburg, IL 60173 (7081517-1144 I predict that another factor will emerge in the LCD’s favor: Safety! In my opinion, it is only a matter of time before CRTs are plastered with warning labels alerting the TomCantrellholdsaB.A.ineconomicsandanM.B.A.fromUCLA. He owns and operates Microfuture, Inc.,and has been in Silicon Valley for user to the potential deleterious effects of electron bom- ten years involved in chip, board, and system design and marketing. bardment and/or low-frequency EMF. Note that I am certainly not qualified to say whether or IRS not a safety “problem” really exists with the CRT. How- 42 1 Very Useful ever, in the absence of hard evidence, the ‘belief” that a 422 Moderately Useful safety problem exists will be enough to indict the CRT. 423 Not Useful

Radio Shack, DAK, fasten your seat belts... HCC is unleashing the industry’s most incredibll BLOWOUTSUPER- LAMP MODULES

X-10 Comtlble! I outdoor operation. GE Homeminder wlthX-1O’s RC5000 ONLY $109 Z; ‘;;;: Schedule your home ustna graphic Icons or your Nt Remote phan66teiface. menu LIST $30.00 LIMIT 24 LIMIT i Pad. SeCurlty mode. message system PasSword PrOWCtlOn. more. with 2 rod- Leviton Wall Switch ules, Infrared remote. Cable. Use to wntrol fluorescent lighting, celling fans. motors, etc. X-10 &gfgJty~~ OampatlblS. White. Ivory or Brown. Mode16291. Llst$72.‘2.50 flcc$48 lntelllgent X10 scheduler with 2-wav Inter- f&x. MonltOrspowefllne &allows IFLTt-lEN. Sundowner Controller One ForAllRemote Replaces 13 remotest ONLY $16 X-10 ComDatlbls when usad LIST $10.05 LIMIT 4 with Infrared ozmmati Center 2 W&xeii tum.supt04llghtsonatdusk. (Loft ONLY $87 :i%?2e~ ltdawn.AJso fun~tk~ asa mlnl-Controller. lnfmred Command Center 320.05 ORDER REQUIREMENTS $100 mlnlmum per order. No mlnlmum quantities. We =ePt Mastercard. Visa, Dit%over. Check, or money order. Llmlted time spedals.

A * HOME CONTROL CONCEPTS TOLL-FREE ORDER HOTLINE I-800-828-8537 For Info & Customer Service l-619-484-0933

ReaderService K?Crl December ‘oO/January ‘9 1 85 CONNEC- TIME

Conducted by Excerpts from the Circuit Cellar BBS Ken Davidson

The Circuit Cellar BBS 300/ 1200/2400 bps 24 hours/7 days a week (203) 871-1988 Four Incoming Lines Vernon, Connecticut

These are busy times on the Circuit Cellar BBS. In this Msg#81279 issue, we’ll be covering discussions about state machines, From: KEN DAVIDSON To: ROBERTO PUON modem usage in other countries, and a nifty TV antenna now on the market. Let’s start off with a subject near and That sums it up pretty well. When I was going through school, I dear to those just starting ouf in engineering: school. kept saying, “But that’s not the way it works in the *real* world.” Strictly speaking, with digital electronics you rarely worry about poles and zeros and Norton equivalents, but it’s absolutely necessary (in my opinion) to have a solid background in that stuff Msg#:31195 just so you know why things work the way they do. Much of the From: ROBERTO PUON To: ALL EEs theory and math doesn’t directly apply to real-world engineer- ing, but you often have to keep it mind when deciding on design I’ve had electronics as a hobby for around four years. Most of tolerances and what you can and can’t get away with. what I know I have learned either by trial and error or from The Circuit Cellar. Right now I am a junior in college and I am an EE I have a friend that I graduated with who is working on cordless major. I’ve not taken but one (digital) electronics course. I really phones at AT&T. His digital experience is pretty weak, but he’s enjoy electronics, and if my job is going to be as fun as my hobby an ace analog designer. He uses a lot of the math and theory every has been, work is going to be a party! day that I’ve been exposed to in the past, but was happy to put behind me. I was just talking with him this weekend and he was I have one question for all of you Electrical Engineers which you saying something I agree with: you don’t go to engineering might have asked yourselves when you were in college: How school to learn about what chips are out there or the best way to much of the math that you studied in college do really use in the lay out a PC board. You go to school to learn the basics of the field? design process and to learn how to learn.

The best thing that can happen to you when you graduate is to be Msg#:31211 paired with a 20-year veteran. He’ll be able to teach you things From: JAMES D STEWART To: ROBERTO PUON you never dreamed of in school, but with the proper background, you’ll be prepared to understand why things work the way they As a non-degreed engineer, who worked his way up from fixing do and how to do things the “right” way. There is absolutely no missiles in the Army in 1970 to project leader presently, I would way you’ll be able to come straight out of school and design a guess very little. Ohm’s law and basic math skills are all I’ve ever circuit that works, is cost effective, and is easy to manufacture used. You could probably argue that they are all that I have. The (unless you’ve had hobby or summer experience, but even then one place that I have been stuck in the past is trying to understand you’ll probably need some help). Hell, we weren’t even taught algorithms used with digital signal processors. It hasn’t been a how to solder while in school. serious problem yet, and my contingency plan is to hire a tutor as needed when I start to work with them seriously. The University Just keep plowing through it and telling yourself you’ll be a of California at Berkeley is next door and there are lots of math better person for doing it. ;-) giants willing to work cheap.

I think the amount of math that you need is greatly dependent Msg#:31280 upon the type of engineering that you are doing. Most engineers From: STEVE CIARCIA To: ROBERTO I’UON doing microprocessor development do very little math. If you work in communications, process control, or signal processing, I are an engineer too. :-) you will need more higher math. I feel that if I had had more math, perhaps I would be better able to visualize problems and How much math you use is really dependent upon the job. If you find quicker solutions. are assigned to design radar antennas and don’t know math you

* .d are in big trouble and soon out of that job. Just using off-the-shelf Afl too often, we get stuck in the mindset that for u digital ICs in noncritical control designs, with the manufacturer’s specs circuit to doany useful work, a processor must be included. under one elbow, is not particularly math intensive. Many times, though, a simple state machine may do the trick using less board space and at a much lower cost (in In my opinion, you cannot be a good engineer without knowing terms of both actual hardware and design time). a good deal of math. This math could be broad ranging, including physics and chemistry, and not necessarily just narrow hard- headed stuff for designing your own ICs. A good engineer (EE) will know what Fourier transforms are, but 20 years after study- Msg#:31396 ing them he might not know how to solve them by hand. A good From: DAVID M. WILLIAMS, SR. To: ALL USERS EE will instead know immediately where to find a book on the subject, a math egg-head to do it for him, or a computer program Does anyone have or know where I can obtain plans for a digital that will do it. If all else fails, he can hope that he’s been on the job cypherlock. I have a twelve-key keypad and need something for long enough to have enough seniority to reassign the task to the the kids to use to activate the garage door opener. I had a unit new kid on the block and go back to his tough management job made by 3M but a lightning strike took it out and it’s to hard to (managing the coffee and doughnut fund). get parts for the board. Seems 3M had some chips tailored made and no one including 3M or Harris, who made the chips, has Engineering is 90% intelligent gut reaction and 10% mathemati- replacements. If you know of some plans, I would appreciate cal analysis. The only problem you’ve got as a young engineer is some info. that the majority of old geezers on the project will be winging it by then on politics and reputation and the new guy with have to do the work. In that case you better know some math. Msgk31566 From: BOB PADDOCK To: DAVID M. WILLIAMS, SR. Don’t get me started on this. If you are in school, then learn some- thing. If you really shouldn’t be an engineer, don’t find it out on Well, if your keypad is a 2-of-7 or 2-of-8 type and not the the job. multiplexed type (I was just about to send a message to Ed, about the overlooked virtues of the 2-of-x keyboards) you can make a simple electronic lock. Msg#z31295 What you need is a 2-of-x keyboard, a 27(C)512 EPROM, a From: ED NISLEY To: ROBERTO PUON 74(HC)273 8-bit edge-clocked latch, and a 74(HC)l4 which is used for reset and a slow oscillator. Feed the outputs of the The single most fundamental mathematical operation you’ll ever EPROM into the inputs of the 273, feed the outputs of the 273 into learn is long division...and I was taught this long after I gradu- AO-A7 of the EPROM. Connect your keyboard to A8-Al5 Use ated, so you can save some time. the 14 to make an oscillator and reset for the 273. Connect D7 from the EPROM to one of the 14’s inverters, and use that to drive a What you do when you’re starting work on a problem is take two 2N2222 or equivalent that will in turn drive a relay. critical parameters and divide one into the other. If the ratio doesn’t make sense, the project is usually in serious trouble. What you have just built is a state machine, where the 273 When you do this sort of thing in your head you develop a represents the current state, with the keypad supplying the next reputation for Great Wizardry. state information.

Unfortunately, in order to know which two numbers to divide What you put in the EPROM will determine what the thing does. and when the result makes sense requires a solid background in For example, with 256 states you could have use a 128digit the math you’ll get in college. For example, you need to know number to turn the output on, witlh 128digit number to turn the how fast is do-able, how strong is something about “that thick,” output off (a bit unrealistic for us grown-ups to remember, but and how heavy is something about “that big”. . . which you get the kids can handle it :-) ). Another way to program it is for 32 4- from knowing physical and electrical properties. digit “on” commands, with 32 4-digit “off” commands, and so on. Just depends on how you want it to work. I took the dreaded Fields & Waves courses in the Physics rather than the EE department because I really gummed up my sched- These EPROM state machines are the thing to use where cost is ule (took a semester off killing calves at a medical research center, an overriding factor in a design; at least until the Creeping- but that’s another story). The EEs learned about transmission Features-Creature shows its ugly head and you need the flexibil- lines, klystrons, and stuff like that. In the physics classes, we did ity of a CPU. the really grim math (I knew I was in good company when the Physics major in the back row asked ‘What’s a tensor?” after the first lecture.. .) the hard way. But, while I can’t do any of that stuff Msgk31577 any more, I have a reasonable appreciation for why you build From: DAVID M. WILLIAMS, SR. To: BOB PADDOCK high-frequency stuff the way you do. Thanks for the suggestion. I just got an EPROM burner last No, you’ll not need much of what you learn, but everybody uses month. I’11 look this over and see if I can put one together. My pad a different portion. The value of your education is what you is the 3 x 4 type, pressure film that supplies a ground (or power) know when you’ve forgotten everything you learned in through the key. class.. . think about it.

December ‘90/January ‘9 1 89 A prerequsite for any kind of telephone data communica- There are also the regulatory issues. In most of Europe, the tions is, of course, a modem. What happens when you want telephone system is a monopoly and, like monopolies, they try to to bring it along when traveling, though? promote their own business. In this case it may mean that a renting of the modem from the telephone company is required, at least officially. Let’s just hope that Margaret Thatcher has ob- MS@:31603 soleted those kinds of requirements since my last visit to that From: BOB PADDOCK To: ALL USERS country!

One of my customers is on his way to the United Kingdom, with MS@32142 a Hayes 2400-bps compatible modem (internal modem for a From: BOB JENNER To: BOB PADDOCK Toshiba 5200); he wants to be able to call me with it when he gets there. I don’t have personal experience, but I’ve come close enough to ask the question. The answers I received suggested that the Has anyone here had any experience with making and receiving things to watch for are different modem signal protocols, the international modem calls? What pitfalls should we be looking noisy and long-turnaround phone lines, and the rather different out for? political setup: using someone’s phone line for an unauthorized purpose, like data communications, can jeopardize their ability to have that phone line. At least one person suggested using a MS@:31765 service that goes overseas rather than making the long haul From: PELLERVO KASKINEN To: BOB PADDOCK directly.

The main difficulties in international modeming seem to be Good luck and good traveling! covered, as the modem is 2400-bps type and possibly even supports thedialingin the European network, at least in the pulse dialing mode. And in any case, the dialing can be handled manually if the modem does not happen to comply. What re- mains is the physical connection. If I am right, the British system is something else than modular jack based. In Ireland, I under- I’m sure you’ve seen the print ads for those silly TV-top stand, the modular jack has been introduced by Northern Tele- “satellite dish antennas.” Here’s one caller who wanted to corn, but that is a different story. So, have some good alligator check their validity (the original poster’s name has been clips included in the tool kit! changed to spare him any embarrassment).

MS-DOS EPROM BTK52 BASIC-52 TOOLKIT PROGRAMMING SYSTEM The BTK52 is an intelligent front end for program development on the MCS BASIC-52 CPU. It reduces 8052 program development time NEEDS NO INTERNAL CARD substantially and can be used with any MCS BASIC-52 based target EPROMS EEPROMS system. The BTK52 runs on any IBM-PC/XT or compatible. 2708 (3 supply, 2804,2016A 2758,2716 2864A, 28256’ l Program download from PC host to target 27C16,2516 l program upload from target to PC host 2532’, 2564’ MicroControllers 68764’,68766’ 8741 A’, 8742’ l BASIC program renumber utihty, with “from, n “through, u ‘wart,” 2732.2732A 874a*, 0748H* and “increment” 27C32,2764 8749’, 8749H’ l Full screen program editmg 2764A, 27C64 tl751’, 87C51’ 27128,27128A 8752’9 8744H’ l Smgle line edmng with automatic error line number detectnn 27C128,27256 l Full on-line he/p facility 27C256,27512 ‘Socket Adapter l Transparent, adaptive line compression for full input line 27C512,27COlO’ Required 27010’,27ClOOl~ (DlagramrIncl”ded) buffer utilizatmn CONNECTS TO YOUR SYSTEM’S l A// func lions accewble wh only one keystroke from the termmal emulator l $125

BXC51 805118052 BASIC COMPILER SYSTEM SOFTWARE COMMANDS l Fully compatible with code written for MC5 BASIC-52 interpreter . PROGRAM EPROM(S) . SAVE EPROM S OR . COPY EPROM S) l Now with integer, byte and bit extensions for code that runs more FROM DISK FILE BUFFER TO D\Sk . ;E;E;EPRDh than 50 times faster than the MSC BASIC-52 interpreter m ;b;IEDISK FILE INTO . PROGRAM EPROM(S) l FUN floating point support FROM BUFFER . BUFFER EDITOR . Ft;fEEERPROM(S) INTO . COMPARE EPROM(S) . SELECT DEVICE TYPE l In-line assembly language option WITH BUFFER . DEVICE CHECKSUM l Compile time switch to select 805 l/803 7 or 80.52/8032 CPUs

BUFFER EDlTOR HAS 18 BYTE LEVELCOMMANDS FOR DETAILED OPERATIONS l includes Binary Technology’s SXA-57 cross-assembler and Hex file SYSTEM INCLUDES: PROGRAMMING UNIT, POWER PACK, manipulation utility CONNECTING CABLE, OPERATION MANUAL & SOFTWARE $239 l Compatible with any RAM or ROM memory mapping

SOFTWARE AVAILABLE ON 3 112” OR 5 114” DISK l Runs on IBM-PC/XT or compatible TO ORDER SEND CHECK. MONEY ORDER, WRITE OR CALL: l $295 ANDRATECH P.O. BOX 222 VISA MILFORD, OHIO 45150 pmg 603-469-3232 l FAX 603-469-3530 I (513) 831-9708 CALL cm WRlTE FOR MORE INFO --ADD 15.00 FOR SHIPPINGS 14.w cm Binary Technology, Inc. J Man Street . P 0 Box 67 . Mmden. NH 03770 ^ ,~_.. ,,?^, mm

Reader Service I1 16 90 ClRCUlT CELLAR INK Msg#:31442 MsgX:31530 From: GEORGE MASON To: ALL USERS From: ED NISLEY To: =EVE SAMPSON

Does anyone know of a source that I can look up info on TV My buddy Dave Long (who had 37 antique TVs at the height of antennas? A friend of mine is living in an area where there are no his craziness [and you should hear -that_ story]) built a 5-foot cableTV lines run. Recent small talk has brought up a rumor that parabolic mesh dish and mounted it on (one) of his antenna a company has developed an antenna which sets inside your masts. He’s in Poughkeepsie and gets tolerable reception from window and is sort of like a mini satellite dish. Ever heard of this? Philadelphia, 150 miles away as the crow flies. On the other hand, This dish sounds more appealing than a huge roof-top antenna. he picked his house by reading the Dutchess County topo maps, Any help would be appreciated. finding the highest points, then checking for a house with a basement big enough for a rifle range. Found one, too.. .

He also built (of mesh and fiberglass resin) a 6-meter power- Msg#:31450 steerable satellite dish back in the days when this was the cutting From: STEVE SAMPSON To: RICHARD MITCHELL edge and LNAs were so expensive your eyes fell out. He mounted that one on footings that look like a civil engineering final exam; I’ve seen the ads. If it’s the same one I saw I never had such a good pity the next owner who really wants a lawn at that spot. laugh in my life! The thing you need to know is that VHF and UHF dish antennas are not as effective as beams. The little dish that you set in the window is for decoration only. It works no better than a set of rabbit ears. If rabbit ears will suffice, and you want to look like a yuppie with a mini-dish, then by all means. Msg#:30905 Otherwise, you can go two routes: buy a beam antenna cut to the From: FRANCIS DUNLOP To: ALL USERS exact frequency wanted, or buy some wide-band beams such as those sold by Radio Shack. Depending on the distance and I have written a keyboard interrupt handler that intercepts scan terrain, nothing may help. I wouldn’t plan on reception over a codes, reassigns some of them, and so on. It works fine except I hundred miles. Where do you get these things? In big cities. don’t know how to turn on/off the keyboard lights (Num Lock, There’s usually an antenna specialist company. I don’t have a Caps Lock, Scroll Lock). Is there some command that you send to good answer there. UHF dish antennas are becoming popular the keyboard to do this? I have noticed that if you toggle bits at but these area couple of feet wide, and the “programming” is not memory address (40:17) or thereabouts and then let DOS have worth the reception. control of the keyboard, the lights go on and off. However, for my

n Table based absolute macro cross-assembler using the manufacturer’s assembly mnemonics. n Includes manual and MS-DOS assembler disk Circuit Cellar INK gift subscriptions are avail- with tables for ALL of the following processors: able for the technologically inquisitive people 1802 64180 6801 8048 TMS320 28 on your gift list. You don’t have to fumble with 377cQ 6502 6805 805 1 TMS340 Z80 wrapping paper or fight the holiday crowds, 50140 6.5816 6809 8085 TMS370 Zl80 just give us a call. We’ll make sure your lucky 7500 COP400 6811 8086 TMS7000 2280 recipient has a full one- (or two-) year SUPER8 COP800 68000 8096 TMS9900 MORE... subscription to Circuit Cellar INK, along with a n Users can create tables for other processors gii?i card announcing the giver’s name and or ask us, we have many more! starting issue. n Generates listing, symbol table and binary, Intel, and Motorola hexcode. To make sure your gift card arrives before w Free worldwide airmail shipping & handling. the holidays, CAtt (203) 875~2199 US$199.00 CDNS239.00 before IDEcEmbER 15, 1990. A CIRCUIT CELLAR INK UNIVERSAL CROSS-ASSEMBLERS . P.O. Box 6156 B!BB THE GIFT OF Saint John, N.B., ; E2L 4R6 Canada i TECHNOLOGY 1 Voice/Fax: (506)847-0681

ReaderServiceP195 December ‘90/Januaw ‘9 J 91 real-time application I can’t let DOS have control. Any help The Circuit Cellar BBS runs on a lo-MHz Micromint would be appreciated! Thanks. OEM-286 IBM PC/AT-compatible computer using the multiline version of The B&ad Board ‘System @BBS Msg#:30920 2.1M) and currently has four modems connected. We From: DALE NASSAR To: FRANCIS DUNLOP invite vou to call and exchange ideas with other Circuit I don’t know if it will do exactly what you need, but you can Cellar;eaders. It is available”24 hours a day and can be control the three keyboard lights (AT only) by issuing the follow- reached at (203) 871-1988. Set your modem for 8 data bits, ing instruction: OUT &H60, &HED followed by OUT &H60, &Hxx, 1 stop bit, and either 300,1200, or 2400 bps. where xx is represents the lights in binary-bit 0 for “Scroll Lock,” bit 1 for “Num Lock,“ and bit 2 for “Caps Lock.” For example, &H5 turns on Scroll Lock and Caps Lock and turns off SOFTWARE and BBS AVAILABLE on DISK Num Lock. Keep in mind that changing the lights in this manner does not change the actual shift states which are controlled by bits Software on Disk Software for the articles in this issue of Circuit Cellar INK may be downloaded free 4,5, and 6 at address 0040:0017 (BIOS KB_FLAG) of charge from the Circuit Cellar BBS. For those unable to download files, they are also available on one 36OK, 5.25” IBM PC-format disk for only $12. Msg#:31055 From: ED NISLEY To: FRANCIS DUNLOP Circuit Cellar BBS on Disk Every month, hundreds of information-filled messages are posted on the Circuit Dale’s got the direct keyboard interface knocked, but you can 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 also diddle the shift flags and call the keyboard BIOS (INT 16h, installments. Each installment comes on three 36OK, 5.25” IBM PC-format disks AH=Olh) to have it do the updating. I don’t know if your and costs just $15. The installment for this issue of INK (December ‘SO/January application can stand to have the BIOS in there, but that’s surely ‘91) includes all public messages posted during September and October, 1990. the easiest way to do it. A little experimentation should tell you To order either Software on Disk or Circuit Cellar BBS on Disk, send check or if the BIOS goes off into the bushes for longer than you can stand. money order to: Circuit Cellar INK - Software (or BBS) on Disk IRS P.O. Box 772, Vernon, CT 06066 424 Very Useful or use your MasterCard or Visa and call (203) 875-2199. Be sure to specify the 425 Moderately Useful issue number of each disk you order. 426 Not Useful

PROJECT COMPONENTS AT BLO WOUT PRICES

ItemlChip CCC Project Blowout Price IS-32 Optic RAM Micro D-Cam $25.00 SN76849 Sound Generator $5.00 SN76832AN IR REC IR Remote Control $1 .oo VIDEO FRAME GRABBER AY-3-1350 Synthesizer Whimsi-Bell $3.50 l Real Time l Hi-Res TMS9918AN Sprite Gen. Color Video Display $5.00 TMS9118AN Sprite Gen. 3-Chip Color Vie0 Display $9.00 CORTEX-I TMS99532AN Modem Single chip 300 bps Modem $5.00 TM%121 Real Time Ctl. Chip RTC-4 Timertintroller $6.00 d Dual Resolution Modes SPI 030 Voice Recog. Chip Lis’ner Voice I/o $10.00 Single Frame 512 X 484 Quad (4) Frames 256 X 242 HD6802P Processor HCS - 6802 Processor $1.50 ti 256 Grey Levels 8 Bits NCR5380 SCSI Controller COMM180/SB18O-SCSI $15.00 ti Pixel Jitter

UM~@ENATION CORPORATION Specializing in Computer Vision 4 Park Street l Vernon, CT 06066 PO Box 84568, Vancouver, WA 98684-0568 (203) 875-2751 l Fax: (203) 872-2204 Telephone/FAX (206) 944.9131

ReaderService #141 Reader Service X202 92 ClRCUlT CELLAR INK STEVE’S OWN INK The Whole Job Steve Cicmia

I finally did it. After several happy years using an program, on the other hand, had a team leader with a BSCS 80286-based clone computer, I joined the 1990s and in- or BSEE. They figured that anyone who used their soft- stalled an 80386 fire-breather on my desk. I suppose that I ware ought to know their way around a computer, so they should be feeling pretty excited about the whole affair, but decided not to “waste time” on making things pretty (and the transition focused my attention on a subject that inefficient). Have you guessed which program I would shouldn’t come up any more. As I went through software recommend to other engineers? Just in case there’s some installation on all of the various programs I’ve come to doubt, let me clear things up-the marketing approach is depend on, it became painfully obvious that some pro- the way to go. grams were guided by the hand of a marketing staff and Too many technical professionals feel that their job some by the hand of an engineer. I have a definite prefer- ends when the testing is finished. I’m convinced, though, ence for one type, and I think you’ll be surprised to hear that working hardware (or software) is only part of the job. which one.. . Getting to working hardware or software may, in fact, be I’ll start by describing two installation procedures. It the easier part of the total. The rest of the job is making that doesn’t really matter which program I’m talking about, product easy for a customer to use. Documentation, help because there are scores of packages that use each method. files, user interface (with or without “graphical” in front), What does matter a great deal is the attitude each method and packaging are all crucial parts of a good professional exhibits toward the user. product. All too often, they’re parts that are left to under- In the first installation, I turn to the manual section trained people struggling to make a deadline that the titled “Getting Started.” Following the directions and il- technical professional ignored. It’s a shame that the as- lustrations, I insert Disk #l in drive A, type “Install.” pects of a product that play the majority role in forming a Menus, windows, animated palm trees, and pop-up in- customer’s impression of the package receive the least structions guide me through all 27 screens and 7 disks attention from the engineers. worth of installation. When I’m through, a new subdirec- Writing isn’t easy. Programming pop-up windows tory tree has been created, and I can use the manual as a takes time that could be devoted to optimizing thelast 10% guide to check on the contents of my AUTOEXEC . BAT and of the program. Indexing a manual isn’t nearly as much CONFIG.SYS f&3. fun as designing a fast frame-grabber board. In spite of all In the second installation, I turn to the manual and these facts, the “human interface” is an important part of wonder if a section has been left out. Finally, I find some the job; too important to be left to people who didn’t have installationinstructionsinAppendix4.6.A.Theysay”Copy a hand in the development of the hardware and software. contents of program disks to hard disk. Set FILES= and I’vealwaysbelieved that theengineer should write the HANDLES= for maximum performance.” Oh boy. I copy all manual, but the struggles with upgrading my computer of the disks into a subdirectory I created, type the program made me go back and look at the manuals we’ve written. name, hit ENTER, and...nothing. Checking the program In many cases there is definite room for improvement. I’m disk, I see subdirectories. Inside the subdirectories are an engineer, not a marketing guru, but I can learn a lesson: more subdirectories. Finally, I pull out a DOS shell pro- Engineering’s just a hobby if there’s no one to buy your gram to automate the copying and, over an hour later I’m product. There simply isn’t a more important engineering ready to start. I have to do some test runs to fine-tune my function than building respect and care for your customer AUTOEXEC and CONFIG settings but, two hours after I into the product. start, I at last have a working program. Here’s my guess: The first program was developed with plenty of input from the marketing folks. They in- sisted on all of the pretty graphics (which waste precious CPU cycles) and they forced the programmers to sit with the tech writers for the manual construction. The second

96 CIRCUIT CELLAR INK