Announcing a complete hardware and software solution from NetBurner

The NetBurner MOD5234
ETHERNET CORE MODULE with eTPU

Only

99
Oty.700

NetBurner MOD5234 Ethernet Core Module Features
INDUSTRIAL TEMPERATURE RANGE I -40°C to +S5°C PERFORMANCE AND MEMORY I 32-Bit CPU I Freescale Cold Fire MCF5234 147 Mhz 12MB Flash Memory ISMB SDRAM DEVICE CONNECTIVITY 110/100 Ethernet 13 UARTsI 16-channel eTPU I FC I SPII CAN 147 Digital 110 I 16-bit Data Bus I SD/MMC Flash Card Support

~~~~[}W~[bW

~~~©[W~©§

~~~~~IfIJJ\~~
Circuit Cellar's first book, Assembly Language Essentials, is a matterof-fact guide to Assembly that will introduce you to the most fundamental programming language of a processor.
Author Larry Cicchinelli provides readers with:
• An introduction functionality • Essential • Important polynomial • Overview terminology algorithms evaluation of Interrupt Service Assembler Routines program ... pertaining to higher-level architecture and programming languages to Assembly language & its

& computer

that may be built into highmultiplication, division,

level languages

• Free, downloadable

and morel

Embedded Systems
High-End Performance with Embedded Ruggedness
Unbrickable design

TS-7800

SOOMHzARM9
• Low power - 4W@5V • 128MB DDR RAM • 512MB high-speed (17MB/sec) onboard Flash

$229 $269
qty 100 qty 1

• 12K LUT customizable FPGA • Internal PCI Bus, PC/104 connector • 2 host USB 2.0 480 Mbps • Gigabit ethernet • 2 SD sockets • 110 GPIO • 2 SATA ports

3x faster
and backward compatible with TS-72xx

• 10 serial ports • 5 ADC (1O-bit)

• Sleep mode uses 200 microamps • Boots Linux 2.6 in 0.7 seconds • Linux 2.6 and Debian by default

TS- TPC-7390
7"ColorTouch Panel Computer

• Low Power, Industrial Quality Design • Mountable aluminum frame • 200 MHz ARM9 • 64MB SDRAM (128MB opt) • 512MB Flash w/ Debian Linux • 800 x 480 video core • Dedicated framebuffer- 8MB RAM • Audio codec with speaker • Boots Linux 2.6 in less than 2 seconds • Unbrickable, boots from SD or NAND • Runs X Windows GUI applications • Runs Eclipse IDE out-of-the-box More Touch Panel Computers on our website

$449
qty 1

• Over 25 years in business • Open Source Vision • • Never discontinued a product Engineers on Tech Support

• Custom configurations and designs wI excellent pricing and turn-around time • Most products stocked and available for next day shipping

Design your solution with one of our engineers (480) 837-5200

75 mm / 2.embeddedARM. Start your embedded system around a TS-SOCKET Macrocontroller to reduce your overall project risk and accelerate time to market.5K LUT • Optional DIN mountable enclosure Ideal for gateway or firewall. Current projects include: • TS-4200: Atmel ARM9 with super low power • TS-4300: Cavium ARM11 with dual 600 MHz and FPU • Dual 100-pin connectors • Secure connection wI mounting holes • Common pin-out interface • Low profile wI 6mm spacing • TS-4500: Cavium ARM9 at very low cost • TS-4700: Marvell PXA168 with video and 1.) • 64MB DDR-RAM • 256MB ultra-reliable XNAND drive • Micro-SD Card slot • RS-232. RTC • Header with SPI and 11 DIO • 480Mbitls USB. USB. www. COTS baseboards are available or design a baseboard for a custom solution with drastically reduced design time and complexity. web server. and unattended remote applications $92 series starts at TS-SOCKET Macrocontrollers Jump Start Your Embedded System Design qty 100 TS-SOCKET Macrocontrollers are CPU core modules that securely connect to a baseboard using the TS-SOCKET connector standard. PoE option • Boots Linux 2.. fanless • Power via 5-12 VDC. Ethernet. Visit our TS-7BOO powered website at . == Technologic Sysl:iems We use our stuff.2 GHz CPU • TS-4800: Freescale iMX515 with video and 800 MHz CPU • Several COTS baseboards for evaluation & development .com .24 in < 3 seconds • Un-brickable. PoE (opt.2 watts)..New Products TS-WIFIBOX-2 A Complete Solution for 802. boots from SD or flash • Customizable FPGA . protocol converter.11 9 WiFi Applications • Low power (3. WiFi audio.6. RS-485. CAN.953 in.

. Circuit Cellar is a registered trademark Reproduction oIlhis publication in whole or in part without written consent from Circuit Cellar Inc. To do this in an everchanging media landscape. we cannot progress to higher levels of achievement. Circuit Cellar staff and contributors remain dedicated to the same goals of looking inside all relevant embedded technologies and encouraging communication between electronics engineering professionals. Circuit Cel~ disclaims any responsibility for the safe and proper function of reader-assembled pf'Oiecls based upon or from plans.56.281. lacademic:s.0411. P. As you see below. 4 Park sr. or information published by Circuit CellaJ(j. 800. Clrculadon Dept.g. it's bound to be a collectible. funds only via Visa. Two-yaar (24 issues' .com GENERAL INFORMATION 860.. is prohibited. we feature articles on several essential engineering topics: functional upset (p.cc-webshop. (Look inside the box!) On the issue's first page. encoder implementation (p.com www. design planning and testing (p. CanadalMaxico $80. as we celebrate Circuit Cellar's 250th issue. Without a continuous effort at understanding and improving present achievements. microprogramming (p.cc-access.281. and error checking and the CRC (p.THE MAGAZINE FOR COMPUTER APPLICATIONS (ISSN 1528'()608) is pu~ished monlh~ by CilOu' Cel~r Incorporated. 4 Park.2199. cutting-edge engineering ideas to bear on any number of relevant tasks. spectrum analysis (p.871.64). Hold on to this issue. All rights reserved. Want an even better idea? You can purchase additional copies at www. Vernon.S. multidisciplinary practitioner who can confidently bring innovative.281. E-mail: newproducts@circuncellar. C8nada'Maxico $110.TASK JMANAG£R Issue 250 and Beyond his month. MasterCard.3741 • 978. or that readers have a right to constructor operate any of Ihe devices descr1bed herein underlhe relevant patent orolher InlellectlJai property Iawofthereader'sJur1sllctlon.com.O. from programming to robust design to electronics theory.7708 • www.cc·access.. it featured a Robert Tinney cover with the depiction of a PC being lifted . deecriptions. Incorporated. NH 03755-5650 Address ChangesiProblems: E-mail: subscribe@circuilcellar. bank.us Fax: 978. 4 Park sr. problems. CT and additional offices.S.crtptlon-ralatad qUIIIlons to Clrcun Cellar Subtcrtptlons.. NH 03755-5650 or call 800.th a car jack. and disseminate need-to-know informaaround the world in the fields of embedded hardware. CT 06066. Circuit Cellar Ink is a publication designed to increase that awareness. The reader assumes any risk 01 infringement liability for constructing or operating such devices.3741·978. and interact with the editorial department's staffers (http://twitter. E-mail: reprints@circuitcellar.com AUTHORS Authors' e-mail addresses (when available) are included at the end of each article. NH 03755-5650. Fax: 860. 68). and we deliver needto-know information about a variety issues. Circun Cellar.. Vernon. Inc. I encourage you to submit articles. Periodical ra1espaid at Vernon. P.com AUTHORIZED REPRINTS INFORMATION 860. we expose engineers to new technologies (e. One-year (12IssulI) subscription rate USA and po8SI88ions $45. P. Vernon. 14). 26). E-mail: subscribe@circuncellar. CT 06066.6301. embedded software. . All subscription orders payable in U.269. Postmaster: Send address changes to ADVERTISING Circuit Cellar.com Editorial Office: Ednor. Our aim is to help each reader become a well-rounded. design challenges and sample programs).2199.t-deliv'erv platlorms to reach a diverse international readership of professionals. 36. E-mail: info@circuncellar. Box 5650. Steve Ciarcia set forth the magazine's mission: To further the education for and communication with those individuals intelligent enough to recognize that sometimes it is very important to know exactly what's in the box and how it works. we have good cause to consider what we have accomplished and hat we plan to do in the future. The information provided by Circuit Cellal® is for educational purposes.O.com Cellar's mission is to collect.454.us·www. 1187 Washington St. Like Issue 1 shown above.7708 peter@smmarketing. or check drawn on U. MCU-related technologies on a regular basis. Direct subscription orele.com Subscribe: 800.com PRINTED IN THE UNITED STATES CONTACTS SUBSCRIPTIONS Information: www. participate in design challenges. because 01 possible variation In Ihe quality and condlllon 01 materials and workmanship 01 reader-assembled projects. We facilitate peer reviews of MCU-based design projects of all sorts.ub.7706 ADVERTISING COORDINATOR Kim Hopkins E-mail: khopkins@circuitcellar. Furthermore. E-mail: editor@circuncellar. Hanover. all other countrill $63.smmarketing. CT 06066. Entire contents copyright 0 2011 by Circuit Cellar. MA 01930 USA 800. Hanover.ubscription rata USA and po.com New Products: New Products. $80. We must not ignore the fact that it is a combination of people and machines that create intelligent personal systems. and . and technologies. and electronics specialists who work with embedded.Street..com. select.. This month. Circun Cellar Subscriptions.454.. www. In January 1988. Now let's focus on the present. Moving forward.O. Today.269. Circuit Cellar uses an assortment of print and electronic conIter. 16). Circuit CellaJ® makes no claims or warrants that readers have a right to build thilgs based upon Ihese ideas under patenl or other relevant intelleclual property law in their jurisdiction. as we continue this tradition and seek out new opportunities.com! cj@circuilcellar.6301.875. Gloucester.. Box 5650.875. ion. Hanover. and we need you+our readers-to get involved.rakoczyphoto. Circun Cellar. and applications. Circuit Cellar® makes no warranties and assumes no responsibility or liability 01 any kild for errors in these programs or schematics or for the consequences of any such errors.com/editor_cc). CIRCUIT CELLARGI. all other countriu $118. we've evolved into something more than a publisher of a print magazine about hardware rojects. Circuit Cellar shipped its first issue. 01 Circuit Cellar.com/advertise ADVERTISING REPRESENTATIVE Peter Wostrel Strategic Media Marketing.circuitcellar. international postal money order. Box 5650. 46). Inc.

.

May 2011 - Measurement & Sensors Stereo Spectrum Richard Pierce Analyzer 26 36 Control Shaft Encoders Keith Brown Reprogrammable UAV Autopilot System (Part 2) Testing and Results Mariano Uzarraga. Renwick Curry.com . i 68 80 www. J. and Gabriel Elkaim Getting Started with Microprogramming A Look at the Meta-Assembler Thomas Mitchell Testing Platform Construct a Custom Jaime Gamica (Part 2) 46 56 Scope TASK MANAGER Issue 2S0 and Beyond C..clrcultceliar. Abate ~4 64 THE CONSUMMATE ENGINEER Functional Upset George Novacek LESSONS FROM THE TRENCHES Design Development (Part 1) Planning and Tools George Martin FROM THE BENCH Error Checking Jeff Bachiochi NEW PRODUCT NEWS TEST YOUR EQ CROSSWORD INDEX OF ADVERTISERS June Preview PRIORITY INTERRUPT Happy 2S0th Steve Ciarcia CIRCUIT CELLAR- 8 -:13 74 79 I i ~ 6 ~I 't'l IN 0 .

VB. and KOC certified . sensor monitoring.Net L9.Software Development C++ or any ."'bedded CE 6.riOBase. just.F ramework 3.ng\J~ge (0#.. -SamsW1g.Net Com pact. -and even Web reporting.1X 1 .WrndDWs®:E. ..eed more sophisticated features in a touch screen? Enter the GUWIN? A Revolutionary Touch Controller.) = Eth~rn8tiO/.5 .(C#. FtC. VB.2450 (533 M Hz) ARM Processor -128MB SDRAM 1128MB NAND Flash .CE. Cheaper 'than a PC.Faster CPU and More Memory? The CUWIN5000 Now Shippingl N. and more features than an HMI touch screen. RS-485 x 1 -IJSB 2.to name a few.Keyboard and Mouse (optional) .. world.Audio (Line Out) I RTC .) for the' creation of tlighly sophisticated applleatlorts involving data acquisltlon. rx . Programmable in CHar any' .Net. machine control.Net Lang~age. etc..Net.oughouUhe. etc:.RSC232 )( 3. .0 x " USB 1. The CUWIN'? A Revolutionary TouchController Already in USe in thousands of appllcaflons thr.0' .

6 V. www. SealiO modules operate from 9 to 30 VDC. the 5TC12C5A6052 executes Instructions In one to six clock cycles (about six to eight times the rate of a conventional 8051 device). In addition. www. Available packages include DIP-40. PLCC-44. and a one-time-enabled WDT. Its eight Form C outputs are conflgurable as normally open or normally closed. It offers 60 KB of flash memory. the 5TCl2C5A6052 has two extra 1/0 ports. The SeaIl0-570's eight isolated inputs are 5. Ordering options enable connection to a host device via wireless (802. and installation is accomplished using Sealevel's software configuration tools. Sealevel Systems. and signal strength in real time and works with UWTC series receivers for a complete wireless system. an on-chip oscillator. food processing.500-VDC external isolation. RS-485 (ModbuS/RTU). An extended temperature range (-40° to 8YC) is optional. www. flexible field wiring.50 in 1. The modules Include field-removable terminal blocks to help facilitate fast.11 big). Prices start at $265. 5eaVO-570 modules are designed for applications such as process control. a lO-source. Featuring an enhanced kernel. The UWPH-2-NEMA is ideal for outdoor or high-humidity applications including water treatment. LQFP-48. The 5TC12C5A6052 costs $1. The 5TC12C5A6052 retains all the features of the standard 80C51. Ltd. 1. Omega Engineering. LQFP-44. a two-channel PCNPWMlDAC.024 bytes of EEPROM.com ~I I £W PRODUCT Nrws .omega. The transmitter Includes free software that converts a PC Into a multichannel chart recorder or data logger. a 5PI (5Iave/Master).280 bytes of data RAM. eight optically Isolated digital Inputs. They feature high-input impedance and easily connect to a variety of sensors. STC Microcontroller. In-system programming and in-application programming enable you to perform upgrades through a programmer or through the firmware. broadcast communications. The device has a maximum working frequency of 35 MHz. a 10-bit ADC. Table-mount and DIN-rail-mounting options are available. CIRCUIT CELLAR" www. The modules' AID inputs are independently software selectable for ±5 VDC or ±15 VDC ranges. and eight Form C relay outputs.5 to 5.clrcultcellar.. USB. HIGH-PERFORMANCE 1-T 8051 MICROCONTROLLER The 5TC12C5A6052 is a single-chip microcontroller based on a high-performance 1-T architecture 80C51 CPU. Power can be input via a terminal block or DCjack.000-piece quantities.COST-EFFECTIVE. Pricing for the Sea1/0-570 starts at $399.com WIRELESS pHITEMPERATURE TRANSMITTER The UWPH-2-NEMA wireless pH temperature transmitter features a high-performance. or RS-232.com . The 5TCl2C5A6052 offers high-noise immunity and has very low power consumption.to 30-VDC-rated and provide 3.stc-Sl. two to three UARTs. and QFN-40. The standard operating temperature range for the modules is -20° to 70°C. while the low-voltage version operates at 2.. and they can SWitch DC loads up to 24 W. and remote environmental monitoring. chemical. four-priority-Ievel interrupt structure. waste treatment. Ethernet (ModbustrCP). and has a fully compatible instruction set with industry-standard 80C51 series microcontrollers. Inc.com MULTIFUNCTION ANALOG AND DIGITAL COMBINATION MODULE Combining analog and digital 1/0. data acquisition.sealevel.1 to 3. microprocessor-based wireless radio transmitter that is built into a NEMA enclosure. temperature.5 V. The Sea1/0-570 provides eight single-ended 16-blt analog Inputs. and disinfecting. STC Microcontroller offers a free USB ISP tool for new customers. Inc. It transmits pH. and 1. It operates at 3.

and a serial interface. 0 Linear Technology Corp. the current draw on the pack Is reduced to less than 1 ~A. HIGH-VOLTAGE BATTERV STACK MONITOR The LTC6803 is a high-voltage battery monitor for hybrid/electric vehicles.linear. electric vehicles. Each cell is monitored for undervoltage and overvoltage conditions. www. GPIO lines. from -40 to 125"C. which enables it to monitor a wide range of battery chemistries and supercapacitors. the current consumed by the integrated BMS can potentially unbalance the cells. The LTC6803 monitor is priced at $9. The battery monitor has a cell measurement range from -300 mV to 5 V. an associated MOSFET discharges overcharged cells. and thermistor Inputs for added functionality.95 each in 1. Each LTC6803 can measure up to 12 individual battery cells in a series. a high-voltage input multiplexer.com - CIRCUIT CELLAR" .25%.com NPN www. a temperature sensor. The battery-measuring IC includes a 12-bit ADC. For long-term battery pack storage. LTC6803s can be stacked In a series without optocouplers or Isolators for precise voltage monitoring of every cell In long strings of series-connected batteries. highperformance battery systems. The maximum total measurement error of the LTC6803 is less than 0.clrcultcellar.SECOND-GENERATION. The LTC6803 addresses this concern through a standby mode that draws less than 12 ~A. and other high-voltage. When powering from this input. The monitor features an onboard 5-V regulator.000-piece quantities. a precision-voltage reference.

www.com NPN CIRCUIT CELLAR· • www.windmill.co. The W-Family is ideal for nonvolatile memory applications that require frequent or rapid writes or low-power operation. The memories are available in industry-standard "green" packaging that Includes an eight-pin SOIC for serial devices and a 28-pln SOIC for parallel devices. ferroelectric process. The parallel devices cost $1. power meters. data loggers. Windmill software Includes ready-to-run applications that can be used to chart and log data.48 for the FM18W08. They offer NoDe lay writes.000piece quantities.com . control analog and digital outputs. This can be critical when managing binary data. SERIAL DATA ACQUISITION SOFTWARE FOR WINDOWS 7 Windmill Software Ltd. ComDebug sends l6-blt two's complement integers. The price includes lifetime technical support and a money-back guarantee. and send data directly to Excel. Windmill software works with Instruments communicating with ASCII or binary messages. WIDE VOLTAGE SERIAL AND PARALLEL F-RAM Ramtron International Corp. including PICs. digital indicators. GPS receivers. enables you to see all sent and received bytes including non-printing characters. W-Family serial SPI devices offer full-bus speed writes and can operate over the industrial temperature range of -40°C to 8Ye. unsigned integers. and laboratory scales.96 for the FM16W08 and $3. RS-485. The software suite costs $80.The Windmill 7 data acquisition and control software suite for Windows 7 (64and 32-bit). such as carriage returns. 100-trillion high-endurance read/write cycles. RS-422. motion sensors. The FM24W256 and FM25W256 memories cost $2. with an operating voltage range of 2.7 to 5. and 38-year data retention. and Modbus. multi meters. monitor the COM port. It can collect readings from the majority of serial instruments that can be plugged into the computer's COM port. gyro compasses. single bits of data.SPI. The FM24W256 and FM25W256 W-Family memories are available in 256-Kb serial 12Cand SPI. You can control the state of the PC's serial port output lines and see the state of the Input lines.5 V. and parallel communication interfaces. Vista. and XP can be used to read and control up to 10 devices over RS-232. respectfully.35 in 10. www. The 64-Kb FM16W08 and 256-Kb FM18W08 devices feature a parallel communication interface. and ASCII values to instruments.ramtron.uk Devices in the W-Famlly of F-RAM memory are available in serial 12C. The software's COM port monitoring program. You can mix and match equipment from many different manufacturers in many combinations. Performance enhancements Include a 25% to 50% reduction In active current requirements and serial devices with faster power-up initialization.clrcultceliar. W-Family products are built on an advanced. Com Debug.

!.CAPACITIVE SENSOR SIGNAL CONDITIONER The ZSSC3122 cUte device is a capacitive sensor signal conditioner (SSC) featuring a wide-dynamic range.AND lO-FINGER MULTITOUCH CAPACITIVE TOUCH-SCREEN ICs The MAX1l855 and MAX1l871 are two new products in the TacTouch line of touch-screen controller ICs for resistive and capacitive touch technologies. with a Z-pressure metriC associated to each touch point. 54:iiini)' RoHs~nl~' ~!:!IJ23~~ffl!JI EDX-O'06 Virlex-5 US'B-F'PGA board I Vlrux·S J '!!s:BL'nnlfg. The MAXl1871 is a mutual capacitance touch-screen controller that can detect and track up to 10-finger simultaneous touch.2FGG~84C '!IV XC'6SLX1 D(t.q5Vti. which eliminates the cost of laser trimming and speeds the production of fully calibrated sensor modules.E11SF23C8N Cdo.cE75F23e8N EP4C.. Its mixed-signal design offers 14-blt capacitive-to-digital conversion and full 14-bit compensation of sensor offset.. The standard supply voltage is l. RoHs·"'mP. ready·to shipjffime.and lO-point touch detection with sensitivity and noise immunity performance.r.soT-1Ff9~65~ Rol"S""mllllaJlt~ Maxim Integrated Products www. nonvolatile EEPROM.ilis are.ZFGG484C .)!lj.!!.000: 1 ratro between touch and no-touch.com -----NPN www.~fGG484{. USB COin. The MAXl1871 also includes architecture to reject noise (by more than 40 dB) from external sources.t:~~G.SPI.:)"f$~ !Il6• 541t1m) RoHS~I~ FOUR..ii mm). or alarm outputs.lIo!(4'3Y541f\!1l! XCM-107' Virte:o.MIXCM:se~!lS .. I I I USS'imerlaoo Crod~ r.~ I VlrteX-5 1I. and calibration software. Contact Maxim or a distributor for pricing. equivalent to a 1. Programming and singlepass calibration are available through a standard PC environment using the ZSSC3122KIT development tools.5 V with accuracy up to 0. XCBSL_X15~. Unit prices start at $4.~e:IB6<·~mmr Zentrum Mikroelektronik www.ff6m Japan ·S!o. The package Includes TSSOP 14..aiately Feel &ee to contact U~ to eustomize speed grade or any fl:ol.1FGG'4i14C G~I~ ea.ll. a development board. They are capable of touch detection from a ballpoint/stylus and gloved hands.ft!ttD(.~i~ • High' quality and highly renable board.j xC5vLxlOT-1FfG665C ~cI.ckeo ite. This enables the part to be used in high LCD noise environments such as next-generation on-cell and in-cell touch screens.dOWlllo~d teghnieaLdQewnenl§before.25% full-scale output accuracy.54 in volumes of 1.8 to 5. All processing is included on-chip to output up to 10 XIY-touch location coordinates. For applications requiring only fourpoint touch detection. PDM. It accommodates single and differential input sensor configurations. 0 • Basic and simple i6alllres 4Siogle:jiowersupplf6peration.zmdLcom Dresden AG (ZMDI) IWIiS CQllpoan( ~ OA-004 r ~II" il USB EeSC55FiaoC8N. Sensitivity and temperature are measured through an internal digital-signal processor running a correction algorithm.:-S L"'{TFPGA board &.tun:. the MAXl18551 MAXl1856 implements a four-finger simultaneous mutual capacitive multitouch solution that eliminates any ghosting effect. It features a built-In Sleep mode that lowers current consumption to less than 1 jJA for temperatures up to 8SOe. All calibration is digital and completed in one pass. fmlD FPGA Boards: fJom Japan ACM-023 CydonclV E F484 FPGAboard [C~clOIIdVE[ 1 MRAM I EP4.clrcultcellar.~.maxim-ic.n! . • Sam!l:sizer~QiJnec{o~laye lj.000.25% over a -40 to 12SOC range.#Jm XCB$LX7~. ree. The controllers offer four. FPGA conI'lQ'y~ CYClone III l'Sn. The chip delivers 14-bit resolution and 0. The system interface offers 12C. via a standard 12Cinterface to a host microcontroller. The ZSSC3122 can Interface with capacitive sensors from two to 10 pF with sensitivity as low as 125 atto-Farads (aF) per digital bit. The SSC connects to microcontrollers but also can be used in standalone designs for transducer and switch applications.r~ JS.!lW (00. a USB cable.usa~ C'r1idil ~~(ss~.CE5SF21C8N EP4.com CIRCUIT CELLAR" . ~96~LX4-~. Calibration coefficients are stored in an onboard._ USB Co>~ IMRAM XC§VLX30·1FfG676C FP'GAc6iiIiJiirSIbil~i~. j.. The controller's analog front-end is built from the ground up for capacitive touch and provides almost 60 dB slgnal-to-nolse ratio performance.F'PGA board C<!nllg.p_urr.

T. voltage offset.l!om todayl Love SaeUg's Unique Electronics? 1 g:!k uniqtJe Get aJfree "uniqu~ geek H . B.ign"IAnaJy~!".dghcorp. harsh.Was ~1.PRECISION HIGH-TEMPERATURE AMPLIFIER .0-nVh/Hz. ±5 V. The modules measure voltage (±25 mV. data rate (9.5" AB5 case with plug-in screw terminal connectors. Rated performance is specified from -25 to 70°e. I fo. and checksum. jet engines.ore pure_hosel t-.com + DG1022 &sjc~i9juil + Dg-1052E AfliIly!:ill-]leoo9" 20MRz FUllctrrm/AWG * 50 MHz2-ch QigffalOiiciIT6swpo . Its CMRR performance Is 100 dB above the temperature range of 5SO to 21O°e. The sensors' communication features include channel address.@ Analog Devices. next DGH Corp.£aolig. P"cli. The amplifier is designed to perform in high-temperature applications. The AD8229's input voltage offset varies by only 100-nV. D6000 series modules are packaged in a 6" x 4" x 1.. and hostile environments. the amplifier helps improve maintenance and increase operation lifestyle. R. Because it is built to withstand these environments.!- MiXlid:"'!!Ignal S!oopg_2Ch t 16 Oifiiiaf ellan nil 1!lC Now only ~899) Dgll02D -100MHz Mixr. E.094 Now only $799) SEVEN-CHANNEL HIGH-SPEED MODBUS DAQ MODULES The D6000 series of seven-channel analog input smart data acquisition modules communicate through the Modbus RTU protocol with R5-485 output.com -i 12 ~ ~urirqu"lng i1 CDft! 5 (See wsrf_c..fandalrilJlI .d"Slgnal·~ . so it is well-suited for sensors that read faint signals. or current outputs at 250 conversions per second. Transient suppression on all R5-485 lines is provided. The conversion rate is 8/s to 25/s. www. and input noise. and space exploration.0-nVlv'Hz high-temperature.~I i I~ $50 or ". 0 + 001102CA + OC204·1A :S. .shirt with your.War: 01. The AD8229 amplifier is priced at $150 each In 1. Inc.S.oC above the entire temperature range. Input noise is 1.. and gamma-ray detection.: NPN CIRCUIT CELLAR· - www. programmable voltage. current (±20 mA). The series also features a two-channel analog output module with 12-bit DAC resolution.2_0MHz W"V<lf~mn G<>nuraf(lr 00 1052D·. ±10 V). such as those used In down-hole drilling.f01 a limited INSTRUMENTATION rime onlNI Ftinelion/ Arbit~r:Y DC 1022 . The AD8229 instrumentation amplifier is specifically geared toward engineers who design electronics for extremely hot.729 channels can be strung on a pair wired to a serial port on a host computer.05% of F5 max. Accuracy is ±0. ±1 V. Now only (: 1 .) FonaW:a. The series enables sensors to be interfaced to any computer. www.2!ib + 16 DigibllCh8Jil'lUJ. and communications values are stored in EEPROM.agQ 40MHz FUllefilll'l/AWG f II 100 MHz 2-ilhannitlDigital O"'CiJIOIlOO Wae.2.. The measurement resolution is 16 bits. and thermocouples (J. detdil.799 only for alimltQd "mIll Call us at 888-772-3544 or go to www. Up to 247 modules or 1.com . ±100 mV.clrcultceliar. Modules with IS-bit digital input and digital output are also available. nuclear magnetic resonance spectroscopy. C).290 Hurryl Tbic ~a19i'l Now only (:1.. including common-mode rejection ratio (CMRR).000-plece quantities. 5.. A universal module measures all of the above. ±50 mV.analog. Each module requires 10 to 30 VDC unregulated supply. All scaling. K.600 to 115 K) parity.~ The AD8229 is a 1. linearization and calibration. which eliminates the need for pots or switches. low-noise instrumentation amplifier that performs at up to 210°C in extreme environments. such as downhole drilling.095 50MH. The input to output isolation is 500 VRMS' The input burnout protection is 250 VAe. The modules also feature a customer-programmable digital filter. The D6000 series costs $245 to $375.or processor-based equipment containing a serial port.

IW"'I:'I"~i" •. It's fairly straightforward to create the number 55 by using the digit 4 five times: 44+44=55 4 Problem } return k. while (t = n & -n) { ++k. Contributed by David Tweed I " nn-or-tn ._I~m'kernel support for USB mass slorage and 802. The lens being used on it gives it a 22° horizontal (cross-track) field of view. Call530·297·6073 ..11 b long wilh a fully integrated Clock/Calendar puis Ihe IOnlnn=I". When flying at 10. !MAD:! IN USA 13 .jkmicro.com mathematical operation.000' above the ground. .com CIRCUIT CELLAR" ~ !!'. } 2-What advantage does this function have over a more "conventional" implementation? Problem Can you create the number 55 using the digit 4 Just four or fewer times? You may use any What's your EQ? .wl ~ .h ahead of Ihe competition. here's a problem where "thinking outside the box" can help lead to a solution.J"he answers are posted at ) www.Email sales@jkmicro. l-What Int foo (Int n) Edited by David Tweed Tesl YourrQ t 1 does the following C function compute? Problem 3-A 15-megapixel consumer-grade digital camera is being used for aerial photography.. n &= -t..comieq/ You may contact the quizmasters at eq@circuitcellar.. but no other digits.CIRCUIT CELLAR Problem { int k = 0.£.clrcultceliar. what is the approximate per-pixel resolution? 4-While not an engineering question per se.. International Orde~We/come www.circuitcellar.com www.. int t..com JK mlcrosystems.

a topology of many control systems. and generally necessary for electromagnetic compatibility (EMC). EMBEDDED ISSUES What is functional upset and what can we do about it? Every embedded controller has at least one input and one output.com I 1~1 . This is not such a good idea for high-intensity fields such as those generated by lightning effects. In the end. To minimize the impact of such a problem. from DC to microwaves. If JL J'"'= Interference will continue to generate differential signals in any asymmetric input in Figure Ib. functional upset has occurred. But the interference. presumably on the same potential. by thoughtful system topology. with the output being a function of the input in some predefined way. I mentioned two areas of interest: the physical robustness of circuits. For effective electromagnetic interference (EMI) suppression.Tilt CONSUMMAII tNGINttR Functional Upset by George Novacek (Canada) Functional upset occurs when an embedded controller stops working as designed. and the effects of lightning on the system performance resulting in functional upset. INTERFERENCE SUPPRESSION While the embedded controller designer can protect his circuits from being damaged. Consider Figure la. ensuring the signal integrity with good wiring practice and protecting of the peripheral devices are the system designer's responsibility. an engineering tradeoff must be made. known as damage tolerance. n my 2011 article. and particularly those encountered as indirect lightning effects (Circuit Cellar 246). due to interference. albeit clamped to a safe level. the embedded controller stops working as designed. remains superimposed on the input signal. even avoided. Figure I b is an example of effective topology to minimize the effects of magnetic fields and ground noise. In this article I'll revisit the topic of functional upset. Functional upset is the result. the shielding grounded at least at both ends is recommended. I have seen voltage differences between two points on a chassis. but eliminating returns through the chassis and common paths will significantly reduce its effects. Fixes after the fact are costly and often not very effective. Having each twisted pair shielded is even better. even completely obliterated. Many problems can be minimized. which is thus distorted. When.clrcultceliar. but system design must always come first. I covered the topic of how to protect electronic circuits from electromagnetic pulses (EMPs). as much as 200 V. CIRCUIT CELLAR" www. you should follow professional wiring practices and create system topologies in a thoughtful. The shield grounded at both ends forms a one-turn loop with potentially huge currents circulating through it. Harnesses using twisted pairs laid close to the chassis go a long way toward robust design. The transient protection inside the controller limits the input signal excursions to prevent damage to the electronics. It is important that each signal and its return use their own twisted and preferably shielded pair as shown in Figure lb. Electromagnetic fields and shared return currents induce unwanted signals into the loops as shown. It is not unusual to see doublebraided harnesses with the outer shield grounded at the controller end only and the inner braid grounded at both ends. systematic fashion. They both may be the same person.

would disconnect hydraulic pressure from the actuators. any imbalance in the circuits will -POWER~ ~ degrade the immunity and INPUTS INPUTS r--L. if accepted by the syssuccessfully interfaced with optocouplers. interference induced into the twisted pairs results in a a) +POWERc=>---------~------.net) is a professional engineer option may be to use metal conduits for wiring. upon detection of an optocouplers had been discouraged from being used in critiinvalid condition. deal with the system upset. but that view also seems to be changing.com - CIRCUIT CELLAR" . When the interference has ceased. In my many years in engineering. The 26 feature articles for Circuit Cellar between 1999 and 2004. Once you've defined the interference levels to be seen inside the controller.clrcultcellar. sure that the worst-case scenarios will be handled without distortion or even destruction. I Input signals are tested for plausibility. at best. weighing less than a copper wire bundle. such as Ethernet or the milInterface by twisted shielded pairs itary MIL-STD-1553B. We can build differential stages to accept good data become available again. It's just like driving into hundreds of volts of common-mode signal. but some off the loads. For precision and characteristics not achievable by other causing the nose wheel to free castor-a behavior similar methods. is to respond to the upset by turning isolation and common-mode range in kilovolts. but the test is the Another tactic is to hold the last good data until more ultimate proof. and so on. interference levels the embedded controller will experiOn aircraft where weight is always a concern. I a fog patch: you hold steady until you emerge from it. and keep working as if nothfuture articles. and huge bandwidth. impedance is a characteristic commonly used to calculate Fiber optics provide great isolation.common mode signal. Calculations and simulathe controller either detects clear conditions and reasserts the control automatically or it is manually reset. This would consider methods such as the transformer or optocoupling first in order to avoid the risks associated with scheme can be used with a full-authority. put us in the ballpark. Some A system designer must analyze the working environment and design the harnesses accordingly. but often the most complicatdesign issues. mental basis for making electronics impervious to interferhe was most recently president of a multinational manufacturer for embedded control systems for aerospace applications. George wrote ence is the inherent immunity of symmetrical I/Os. Suppressing and managing interference is ed and costly to achieve. The main disadvantage of a transformer interface is limFigure 1-Two typical system wire layouts ited bandwidth and the cost when relatively low-volume protocols are concerned. Only then can we make thrusting of the engines. Directional control answer. too. I'll cover more techniques in hiccups. iii ing happened. Now retired. result in the interference appearing as a differential signal. you can consider strategies to way into places such as entertainment consoles._-----. your only George Novacek (gnovacek@nexicom. 0==§= e=v= {]=t= www. For example. like lightning strikes. instrumentation and isolation amplifiers are the to the front wheels of a shopping cart. It is important to characterize the conditions that is then maintained by differential braking or differential the amplifiers will be exposed to. digital-engine controller (FADEC). fiber optics. tions will. Duration and subsequent recovery of the system from the hold mode is monitored. It is often Switch used for communications. linear is monitored. and long-term stability. suddenly stop. Transfer transformers can cost hundreds of dollars each. Controller A transformer interface is simple and effective. firmware execution have never encountered that problem. the careful design of the system and the circuits is critical. but personally. with good isolation and commonmode input range. and delayed MORE ON ROBUST DESIGN recovery results in another previously determined action Robust design is a goal toward which we all must aspire. We have merely scratched the surface of robust system The third method is ideal. inherent immunity the shielding effectiveness and the resulting impact on the from electromagnetic interference. Therefore. b) +POWERc=~~------. an aircraft nose wheel steering controller cal applications. You don't want engines in flight to galvanic connections. Unfortunately. Similarly. In a really tough environment. are designed to satisfy the system's safety. The system is designed to ignore one piece of the puzzle. Discrete as well as DC and low-frequency signals can be A simple and common approach. You need to confirm that system upset has in authorities consider optocouplers to have poor reliability fact occurred-that's the job for the built-in test (BIT). The fundawith a degree in Cybernetics and Closed-Loop Control. They provide tem safety analysis. are finding their ence.

gain Down) through the dsPIC. The overall design is conceptually simple (see Figure 1). I built a couple of different-sized versions of this spectrum analyzer. The dsPIC's analog inputs require this center level in order to use the A/D converter's signed integer conversion mode. depending on the standard.~ ~ ~s\RIIflt=================:::::J by Richard Pierce (USA) Stereo Spectrum Analyzer There are plenty of spectrum analyzers on the market. R5/R33 in combination with a Microchip Technology MCP4261 dual digital potentiometer determine the gain setting of the audio quality CIRCUIT CELLAR" - www. Resistors R11/R22 and RI2/R21 attenuate the input signal and center it at a level that's half of the supply voltage. An input section adjusts the stereo audio signal level to an appropriate value for a microprocessor's A/D converter. The circuit is designed to work with any signal in this range (see Figure 2). Both of these versions use the same core control CPU and audio signal processing. My design gives you two integrated channels of display. ANALOG INPUT The analog input is designed to work with a "line-level" stereo signal. automatic brightness. One solution is to build an analyzer to suit your needs.5 to 2 Vpp. and a multiple-display mode. which is connected to a couple of buttons (gain Up. each with its own 16 x 16 LED bar graph: perfect for stereo. each with a 16 x 16 LED bar graph. This design features two integrated channels of display. They just use a different LED display component (see Photo 1).048-bit FFT design that features a 16 x 16 x 2 multicolor LED.com . udio spectrum analyzers are widely available.clrcultceliar. Even though there's nothing wrong with the available spectrum analyzers. one using small and one using mediumsized LED arrays. But you'll likely need two of them to see both channels of a stereo signal. The microprocessor performs an FFT analysis to convert the audio signal time domain to the frequency domain and then displays the results on a pair of 16 x 16 LED arrays. 2. which can vary from 0. After attenuating the input. The display shows the signal level for both stereo A channels from about 25 Hz to 20 kHz in 16 bands each. I created a stereo. The input section is a simple variable gain amplifier that AC couples the line input to the analog inputs of a Microchip Technology dsPIC processor. The gain setting is controlled by a dual digital potentiometer.

Rather than doing it the obvious way and driving 32 columns of 16 rows.com CIRCUIT CELLAR" J3 WHT BLK VEL Line audio Vi2 R5 cro R12 AN-R O. and the dual digital potentiometer resistance is matched to within 0. green. A 136-bit shift register is used (128 column bits plus eight row bits) to enable the controller to talk to the display using one serial peripheral interface (SPI) port. or orange (both red and green). To drive the displays. the displays are organized as 64 columns of eight rows. not having a filter means that the input signal is not distorted at all. you should always buy them in complete batches to ensure a uniform brightness. The same gain setting is used for both of the stereo channels. (red and green).Upper haH Left Right ~ ~ Row drivers (8) I-- ~ rh 00000000 00000000 00000000 00000000 00000000 00000000 88888888 00000000 88888888 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 88888888 88888888 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 8X8 RIG (4) LEO Array 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 I Programmable gain amplifier L Line in Level shifter r I ~ 0 Mode 5V 8X8 RIG (4) LEO Array I 8-bit Shift register Lower half I I Level shifter 64-bit Shift register i I sensor Light 64-bit Shift register i I I Clip Indicator LEOs Oiag 3.l!J/film ANALYZER DISPLAYS The primary spectrum analyzer displays are 8 x 8 red/green LED arrays (see Figure 3).circuitcellar.os R17 . Each LED pixel can be red. When you buy LEDs (of any type). Because of the large number of display chips cs O. Pushbutton controls Eh SPI AN5 [ ANO ANI PGC PGO MCLR Gain up 0 ~ 0--- RB6 RB5 dsPIC33FJ64GP802 ~J ICSP Gaindown 0--- RBI5 Figure I-The spectrum analyzer is designed around a dsPIC33F J64GP802 processor. MCP6244 op-amp. On the other hand. Four 8 x 8 LED arrays are used for each channel (a total of eight arrays) so that each channel display is 16 x 16. so accurate results are easy to achieve. the result is a total of 128 columns that must be driven. so there are some conditional code switches to select the type of display you have and use an appropriate brightness control range. input signals with frequencies higher than about 22 kHz will confuse this spectrum analyzer.3V I PWM ~ RBIO ~ RA4 - R- -: "<._____ 1~: V/2 _j I =-+17 I~ . Because there is no low-pass filter in the input section. so no channel gain balancing adjustment is needed. a multiplexing scheme must be used. Since each LED requires 2 bits www. but diodes Dl and D2 are there anyway to provide additional protection from large transient or inadvertent input signals. I found out the hard way that the LED array brightness varies a lot with LEDs from different manufacturers. This op-amp is pretty hard to kill.2 % (typical).l!J/film tone vee vee Figure 2-Analog signal conditioning to.

. so you don't want to co:<cr-ml!)~(') o.. The "bug" LED is a diagnostic indicator. A dozen display modes are available. by the same time.. However....com ..5 "' . power supply..<c m 0.. the dsPIC requires a 3.. Once the power-up is complete and the adding a simple attenuator to the input signal to bring it display chips have been initialized.5 row can have up to 64 LEDs on at a time and two rows are being driven simultaneously. In each orientation. c. using 3. green.. since each '" QQ if' 00 if' 00 "'''' "'''' .. ister chips can provide enough current to drive the 2' ROWl ROWl ROW' ROW' LED columns directly 22 22 8x8 RIG 2"x2' 8x8 RIG 2"x2" ROW2 ROW2 ROW6 ROW6 ROW2 ROW2 ROW6 ROW6 23 23 LED Array LED Array ROW3 ROW3 ROW? ROW? ROW3 ROW3 ROW? ROW? because only one LED in ROW4 ROW4 ROW4 ROW4 DSP5 DSP6 each column can possibly be ~ ~ ~r-!. This is a high enough refresh rate that there is no visible R57-64 R49·56 200 200 249 flicker in the display. and norshift register chips able to provide more LED current than mal/peak decay. oo><>:>r-:o.... fast/slow response... The display orioutput. The Mode column shift registers are also connected to the dsPIC's PWM button is used to select the desired one.5 MHz is used here....... which operates at 5 V but has TTL-level inputs that are compatible with the 3.1 T'"" T'"" T'"" ROWl ROWS 21 ROW5 ROW2 ROW3 ROW4 ROW6 22 ROW6 ROW2 ROW3 ROW4 ROW6 22 ROW6 ROW3 ROW4 ROW? 23 ROW? ROW? 23 ROW? DSP7 ROW8 24 ROW8 DSP8 ROW8 24 CIRCUIT CELLAR" - www.... The directly from the 5-V main bus and makes the 74VHC595 style choices are bar/dot.. A photocell (actually an integrated light sensor entation can be horizontal (the classic style for spectrum and amplifier) is used to detect the ambient light level.... The FFT algorithm will continue to from the dsPIC.)rJ)J: R81-B8 ~""''''''''''''''''''''''''''-~Qr-~~.('. Turning on all the LEDs at once would overload the I-A power supply and exceed R89-96 R97-104 R73-80 200 200 249 the MOSFET current rat249 ings.3 V would.2~ $OUU ~E5~~ '" "'''' on at a time. Overload can be resolved by possibility of large currents being drawn by random data in the driver chips that might turn on a lot of LEDs at adjusting the gain setting downward or.circuitcellar.. the display is down to the maximum level of 2 V pp' enabled... there are severThe display is operated at 5 V. This really is R40-48 R65-72 249 Oi "-:... which enables the display's overall brightness to be controlled...c::==:::and long PCB traces...... but too much clipping will eventually confuse the algorithm and cause the display turned off during power-up.0 ~'"! <:t (') L.. MOSFET row drivers are used (see Figure 4). which enables it to run al choices for the colors and styles that will be used.. But. orange..n<t(') T'"" T'"" Q r.'"l "" r- 0'" N 0.. a relatively low SPI clock rate of 2...3-V and VU style (which is green with orange/red at the top).. The 74VHC595 shift rego co N""''''''''''''''''''''''''''''''' 0..~ do that (see Figure 5).3-V CMOS signals ing saturation (mathematically overflowing) and the signal is being clipped. resulting in a net display refresh rate of 8 ms (125 Hz). and analyzers) or vertical. which is really nice for a stereo the display brightness is automatically adjusted accordingly...5 .. overtalk to the display chips..' ROWS ROWS ROWS 21 ROWS ROWS 24 ROWS ROWS 24 ROWS ~ '0 CL(I)(I)CC 0 CLr... This is done by the 74HCT365 load means that the FFT analysis algorithm is encounterhex buffer chip. Every millisecond one row (136 bits) is clocked out to the display.. The mode.... so some level of conversion is needed to An additional LED indicates when input overload is occurring. A spare op-amp is used to generate a signal that keeps operate even when saturation is occurring. maximum current that's actually needed stays reaROWS 21 ROWS ROWl ROWl ROW' 8x8 RIG 2"x2" 8x8 RIG 2"x2" ROW2 ROW2 LED Array LED Array sonably low due to the disROW3 eowe ROW4 play organization and by not providing any display modes Figure 3-The spectrum analyzer's right-side display that use the orange color very much (since an orange One more input button to the dsPIC selects the display pixel requires twice the current of a red or green pixel). The N. This prevents the inaccuracy in the display... In the context of this spectrum analyzer. display (see Photo 2).. The color choices are red.. if necessary.

.

.. ::.. memory access errors.. I programmed primarily in C language (using a Microchip Technology C30 compiler) with some sections done in Assembler for performance reasons. from one to II...r..--l!)or-~o:. This dsPIC has enough memory and processing power to perform the spectrum analysis on two audio channels and update the display at a rate of about 12 updates/second. Ideally.... In addition to the various program logic error traps that are sprinkled throughout the code.. as there is a lot going on in the software...... TWIDDLES & BUTIERFLIES This is the fun part. it gets everything done for this application while operating at only 10 MIPS.. that repeat forever.... The dsPIC will operate at up to 40 MIPS... the spectrum analyzer application tries to shut down everything (enter a failsafe condition) and then blinks an error code on the diagnostic LED...C\I .o::-cry C\lT'""T'""T'""T'""T'"" ..-- ~ ~~ ~ h R137-144 249 R145-152 200 R153-160 249 R16l-16B 200 co:wr-WL!l"'-cry ~. so 100% of the dsPIC processing power is still available to do other things (e.. The DMA module is triggered when each A/D cycle completes and it automatically transfers the A/D result to the DMA buffer RAM and increments the DMA address....r.. This happens completely in the background. The display ~o!Q!Q o..the last LED.2 update rate is determined by the sampling rate and sample buffer size required for the FFT. an FFT analysis)..'.g....liI ~ouu " ~ "" 000: !Q!Q § ~Cj~6 ~rr.. No kidding this time. but the dsPIC doesn't have quite enough RAM to do that..___ .. but because it's got a 16-bit architecture and has instructions that are optimized for FFT types of calculations. This code is just a number of blinks... and stack overflow.. not by a processor power limitation....OO(f..a: a ~ !Q!.. C"-N OOlWI'-(O".. A crystal-based oscillator is used so that the frequency analysis results are highly accurate.com Rl05·112 249 R113·120 200 R121·128 249 R129-136 200 ROWl ROW2 ROW3 ROW4 ROWl ROW2 ROW3 ROW4 8x8 RiG 2"x2' LED Array DSPl ROWS ROW6 ROW? ROWS 21 22 23 24 ROWS ROW6 ROW? ROWS ROWl ROW2 ROW3 ROW4 ROWl ROW2 ROW3 ROW4 8x8 RiG 2"x2" LED Array DSP2 ROWS ROW6 ROW? ROWS 21 22 23 24 ROWS ROW6 ROW? ROWS ~§~~ . it would read and analyze analog data from both channels continuously.... This is utilized by the spectrum analyzer application to read analog data from one of the stereo input channels while simultaneously performing the FFT data analysis on the other stereo channel. A timer kicks off each A/D read at a 50-kHz sampling rate. So.. and the serial port (which is not used by the spectrum analyzer) is brought out for use as a potential diagnostic port.. this spectrum analyzer is actually looking at the analog signal from each channel only half of the time. The dsPIC33FJ64GP802 has a built-in DMA capability that can be used with the A/D converter.... If any errors occur.... The dsPIC has a total of 16 KB CIRCUIT CELLAR" www.......l!)CO"-:O::u..5.clrcultceliar. CONTROL A Microchip Technology dsPIC33FJ64GP802 processor is at the core of this spectrum analyzer design.. . The dsPIC is programmed via ICSP... the dsPIC has an error-trapping mechanism for conditions such as oscillator failure.

There are minimum and maximum limits applied to the PWM value so that the display is not too bright and it's never completely off. Once that's done. so more bins are combined into each group at the higher frequencies. "The Fast Fourier Transform").g. I also used some stock Microchip Technology FFT library subroutines and an integer square root algorithm that I found online. After all of the 16 column values are determined.clrcultcellar. When the buffer is half full. peak decay. and some RAM is needed for program variables and stack. an 8-KB buffer is needed to perform the 2. the ADC is switched to the other stereo channel. The column display value can be 0 to 16. the DMA starts filling its 2-KB buffer with data from one of the stereo channels. and the second half of the DMA buffer is transferred to the FFT buffer. where each bin gives the amplitude of the signal at a particular frequency. the data is further modified to implement the fast/slow response. most of the activity is in the lower end of the frequency range. 2 KB is used for storing some FFT constants. The FFT analysis code is based on the algorithm described by Steven W. the push buttons are polled and debounced. The number of bins in one group varies from one bin at 24 Hz to 529 bins at 16 kHz.048-bit FFT is used. The FFT analysis process will use another 4 KB of RAM for a total of 8 KB when it's done. so there are 17 entries of 32 bits in each charset.048 "bins" of equally spaced frequencies. so different sized groups of bins are totalized and averaged to determine each display column value (which is a representation of the total signal magnitude in the group frequency range). a new buffer acquisition cycle is started (on the first half of the DMA buffer).of RAM. 2 KB is dedicated to DMA use. For audio signals. if you want to have a linear frequency spectrum display instead).048-bit FFT. 4 KB is needed to store one sample period. and the orientation of the data that's finally displayed. the display data is moved off to another buffer where the display refresh timer interrupt simply reads it and transfers it out via the SPI to the display chips. Between the audio data buffer acquisition cycles. Refer to past issues of Circuit Cellar for more information about FFTs. So. These were adapted for the dsPIC and optimized somewhat to reduce the RAM requirement. Button inputs are queued up so that they are handled at an Photo 2-Some of the spectrum analyzer's display modes . the ADC is switched over to read the photocell and then the display brightness (PWM value) is set accordingly. and there is 4 KB of data in the FFT buffer ready to be analyzed. which gives a frequency resolution of about 25 Hz. the display data is fed through more code that translates it from horizontal to vertical. The bins to use for the frequency groups are set up in a table so they can be easily changed [e. A 2. If the display orientation is vertical. which allows for a maximum effective input frequency of about 22 kHz. and depending on the display mode. the results for display are calculated. Of this total. Smith in The Scientist and Engineer's Guide to Digital Signal Processing (Chapter 12. The FFT output is 2. But the desired www. a little fancy footwork is needed to make everything fit into RAM. First. The FFT analysis is now able to run while the DMA collects the next set of data into the DMA and temporary buffers.. When the second half of the buffer is full. Once an FFT analysis is complete. The sampling rate is 50 kHz. so the temporary buffer is now free. Each output column value is fed through a "display charset" that is established based on the current mode setting. The temporary buffer is then combined with the FFT buffer.com CIRCUIT CELLAR" display is not linear. the first half is transferred to a temporary buffer (at the same time as the DMA continues to fill the second half of the buffer). The display charset is a translation table that tells which LED(s) should be turned on for a particular column display value. and each column is 32 LEDs (16 red and 16 green). Periodically (every 1/50 of a second). This spectrum analyzer display is set up to show frequencies on an exponential scale (see Table 1).

all you have to do is change uses it too.073 Hz setting is changed. And even at All the various software tasks are only 10 MIPS. Any time a gram. Using four layers for the Assembler source base PCB probably wasn't necessary. memory buffers. accessing it from RAM. For example. 9 488 Hz 378-598 Hz For performance reaHowever. but the digital potentiometer were all created using script-generapower. spare capacity to handle all processor if desired. but it didn't hurt and it made the layout process a lot easier.575-2. it must be would have to be stored 5 122 Hz 110-134 Hz in flash memory and changed in both the sa. analog signal processthe display was so ing. the RAM. even and" sa" include files.213 Hz 4. The display charset the speed constants in the . So.678-12.749-7. and the 3.749 Hz beginning of the protings (gain and mode) are 14 6.036 Hz 12. Input frequencies are shown in there is plenty of spare ROM after five seconds. files. so communication with tor programs. respectively.270 Hz 964-1575 Hz has a small amount of are loaded from flash 12 2.795 Hz memory to RAM at the EEPROM. and display rotation code tures and need more processing ty user. not to be using the SP!.000 Hz (actual limit is approximately 22 kHz) settings are automaticalbe used directly from flash memory since ly rewritten to the EEPTable 1-This is a frequency display table. horizontal base PCB using a rightYou may notice angle header.678 Hz stored there. magic.073-20. processing time availThe EEPROM is good for able. This 1 24 Hz 37-61 Hz compile and run cordsPIC doesn't have a 2 49 Hz 37-61 Hz rectly. The code is configurable to run at tent integrity are maintained.185 Hz 1. It the rotation code mounts vertically. The confusing that I display PCB contains the column ended up creating drivers and the LED arrays. If you run low on 15 9. These are for with the high currents the display use by C and can draw.h and . and it 7 220 Hz 183-256 Hz must always be the about flash memory 8 317 Hz 256-378 Hz write endurance limits.inc] files primarily for the display PCB for the requirements.Column Center frequency Frequency span for the application to C::==::::lappropriate time.772 Hz 2. so endurance times when the display is guaranteed ory is only a little bit slower than shouldn't be a problem.h and . the processor is idle synchronized and interlocked so the CODING NOTES about 50% of the time. however. A fourThese files must be kept in sync layer board costs only a few dollars CIRCUIT CELLAR" www.inc the digital potentiometer is limited to logic is pretty obvious and could be files. 20. these tables can 16 16. the display is the SPI's prioricharsets. the twiddle and window constants is included in the CONSTRUCTION The spectrum analyzer's electronsource files. or 40 MIPS. Using four layers pret"p33FJ64GP802" ty much guaranteed that there would not be problems with noise. The speeds up to 40 MIPS (the maximum generator code for speed for this processor). that there are dual I chose a four-layer type of PCB (.inc files. The The base PCB contains all of the process of rotating control logic. display 10. For Hamming window constants. The power supply has enough tweaked by hand. is PCB and a display PCB (see Photo 3).795-4.com . The display rotation ics are built in two sections: a base code. if built-in EEPROM.h 6 159 Hz 134-183 Hz you'd have to worry and sa. SPI. Accessing data from flash memabout 1 million writes. so 3 73 Hz 61-85 Hz any permanent settings you want to change the 4 98 Hz 85-110 Hz CPU speed. and display conThe FFT "twiddle" constants.clrcultceliar. so the set13 3.875 Hz 7. the MCP4261 10 781 Hz 598-964 Hz digital potentiometer sons.3-V power supply. each display column. attached to the empirically. if you add feaexample. same value in both files. some data tables 11 1.

.1 ~ . The photocell..3V 3. No Set-Up Required 10A Solar Charger for Lighting • High Efficiency PWM Charging • Charges Batteries During Daylight and Switches Lights on at Night • Suitable for 12V and 24V Systems • LED Status Indication for Charging.5---'-I:2:2I..3V ~W-"---+--T'D more and it sure beats trying to track down and fix noise problems.circuitcellar. Low Battery etc www. attached to the back of the display PCB. is wrapped around the bottom of the PCB so it receives light from the front of the unit and it has some play for adjustment.futurlec.com www.J O+~+--3.5V 3.:U2 0.£. It should be located such that it Great New Products New ET-Easy Stamp • Includes ATMega168 with Installed Arduino Bootloader • Direct USB Program Download • Up to 22 lID Points.. 1O-Bit ADC Included • Compact.com CIRCUIT CELLAR" .11-1 R5 R6 R7 TSL12S R8 R2 R1 R3 R4 0.3V Figure 5-The spectrum analyzer's processor and power supply ~PWM5 RCK5 SCK5 C3 S005 CLR5 ___c--1 -:.s 5 1O'f-. Easy to Use and Program Ultrasonic Range Finder • Ideal for use on Robots and Water Tanks • Measures from 3cm to 3m • High Accuracy • Ready to Run.

audio input connector. Smith.circuitcellar. I-A power cube completes the unit. the front and back panels slide into slots.fearlessnight. I www. and everying goes together sort of like a Chinese puzzle. RESOURCE S. iii Richard Pierce (rsp@fear/essnight.com CIRCUIT CELLAR" - www. try aiming the photocell up or down to get the desired effect. A standard 5-V. He also designs home entertainment! automation gadgets. The only fasteners are the four screws that attach the bottom plate of the box.circuitcellar.com /pubCircui t_ Cellar /2011/250. so it's hard to kill and it won't distort the signal it's monitoring.vellemanusa. SOURCES LED Arrays Fearless Night I www. What can I say? This is a lot more entertaining than a simple VU meter. The signal input is protected and has a high impedance. OPERATION Operating the spectrum analyzer couldn't be easier.receives as little light from the LED arrays as possible.microchip.sparkfun. (Why do they use white plastic for these anyway?) This improves the way it looks through the front panel and reduces the amount of reflected light on the photocell. There's nothing to calibrate. and power connector are all mounted on the back panel. Inc. I www. I painted the edges of the LED displays with some flat black paint. If the automatic brightness doesn't seem to work well. 1999. The Scientist and Engineer's Guide to Digital Signal Processing.com . Just plug in the power and line audio connectors and press the mode and gain Up/Down buttons until you get a desirable display. and MCP4261 Digital potentiometer Microchip Technology. Inc. I then put the entire assembly in a custom wood box with an acrylic front panel and a plastic back plate.com LED Arrays SparkFun Electronics I www. The base PCB slides into a couple of wood cleats. The control push buttons. go to ftp://ftp. California Technical Publishing.com Audio analyzers Velleman.com) is a medical product design engineer who studied Computer Engineering at the University of Illinois. PROJECT FILES To download the code.com dsPIC33FJ64GP802 Processor. C30 Compiler.

Multi·tuncj:i<:m HT66FXx HT69Fxx' voltage source. series further broaden the Plash range to provide an increased 'Selection of flexible device solutions. lnternat R-typelC-fype LtO driver.K's HT66Fx)( AiD type series and its HT68Fxx 1/0. QA~~' Inc. TinYPower uitea low power te_chnology.?5Z'.om tllljf~hP.-4 LCD SCQM :oulputs for diredtd~iving -ofLC0 panels. &mif!lII_'$$Ia<i~hC/lai'>o. . Jncludesall the HT6. industrial control. -_ . Internal Data E:EPROM fUricti_on etc._. automotive pe1'i'fi'lher~JproduQts to name buta few. cQflI$umer promuets. Holte.~u HT6SFxxfunctions with an additiona_llnt_ernal High Speed 1.instrumentationp)ToductS. IRe wi.12C interfaces.ldOscillat(_)fS High' Noise IFTimutritY and Excellent ESD preteennn .th four freqlJent'W selections. _ .t. 1~1'29. Additiemally.SV Ultra Low Power ·Multiple LoW-pOWerOpetaWfg Modes' Fast Wake-up FunctIon Multiple Exterr\a'· CCilrnmunioation: tnterfa. FaN {§itO)2p~:~885 .'Inc. Multiple Communication lntertaces..Intemal Aceurate Hi9hfLow Spe.~ Uses Holtek's.Enhanced 01-1> MC'U WlED 6ac:kllght fl'umQi'il61yd" Fffirilf.ces . HT67Fxx' Includes .?n!t.2~bltADCwith the internal reference voltage source.. Dual_ SPI or . household appliances.Holtek's new ultra low power consumption Flash MCU device series. greatly reduce power requirements to meet the demands of today's environmentally conscious prodUGts.2V-S.8Fxx:funotions: With an addifioflaJ12-bIt ADCand fntemal referenee.e application area suchas health care prGt!:hJots.988Q.ge Range: 2. Modules. The. HDLTEKsemIC.onOUI:TElA Teli (!>10J. serIes LCD type" in utilising HolteK's unique TinyPowerTM technolo§lY.. HT68Fxx Internal MultHlmctlon'Timer Ire pins with rei-mapping functiOn.Saml"cmducfl)~ {USA}•.l~~ Ho1tak. SID Flash MCU HT66/67/68/69Fxx Series Wide Operatihg VOIta. the HT67Fxx series AiD with LCD type" and the HT69Fxx.complete device range G(l)ntainsan extensiv_e range of peripheral functions making them suitable for use ina diwers.

Whether they are described as "Gray code. leaving the inspiring label"C" for the common. I found that I was buying units that did not do the job. not knowing what resolution was needed for a finger-rotated control shaft. The relative polarity of the two waveforms might differ." "incremental encoders. Therein lies the real world. They are also meant to be turned by human fingers. It can be adapted to any bigger PIC with little trouble since the PIClO family's instructions are a subset of larger PICs. high or low. Did you catch them? Yes. As part of this article.~s\-RIIflt=================:::::J ~ ~ by Keith Brown (Canada) Control Shaft Encoders Searching for an ideal control shaft encoder can be a time-consuming task. Also. This article details some workarounds to help determine which encoder is appropriate for an application. These devices are intended to be used as controls mounted on a panel with a knob on their shaft. An interesting debounce and decode circuit is also presented. but these have generally fewer than 100 resolvable steps per rotation." "Gray scale. Unless you have vintage wheels. The 2-bit Gray code is effectively a degenerative case of general Gray codes. it is not always clear which level. I'll get into the real-world aspects later. The devices are a subset of what are called "shaft" or "rotary" encoders. it does not really matter since just swapping the signals will accomplish the direction reversal. but that does not matter. either check out a real unit with a meter. or are purely optical in one without a ball. but not really useful either. All four I/O pins are used. corresponds to a switch being closed or open: Sometimes the datasheets don't show whether it's assumed that the common is wired to the system's positive voltage with pull-down resistors or wired to the ground with pull-ups. It seems universal that the names of these signals are A and B. the waveforms are nominally square and the overlaps are intended to be 90°." "2-bit quadrature. either in hardware or software. but first the theory. I'll also present a small debounce and decode circuit. or design your system to enable the easy swapping of the detected direction.clrcultceliar." or even "phase difference signal" types. Two inputs from the decoder and a clock pulse along with an up/down flag are used to drive an external counter. I wrote the code in Assembler and it served as a testbed. and trying to gauge just how much debouncing was required. It is not necessary to know anything about Gray CIRCUIT CELLAR" www. There are two "weasel words" in the last paragraph. Anything better requires an optical disk or another method with finer resolution (even some resistive potentiometers can be better than this under appropriate circumstances). But again.com 26 . they all share this basic principle: at a constant rotation speed. your car radio almost certainly uses one of these types of low cost encoders for its volume control. T his article is about control encoders that are built from mechanical switches whose contacts alternate between conductive and non-conductive areas arranged in one or more circles. they output two nominally square waveforms with what is intended to be a 90° overlap. My frustrations included not knowing beforehand how the control would feel (Just what do the torque specs meani]. So. The scroll wheel in your mouse is likely in this category as well-although the actual mouse position sensors usually use an optical disk in a mouse with a ball. Just swap A and B if the opposite phase relation is desired. Calling them Gray code devices is not wrong. My goal is to let you in on what I learned when I was doing my own search for an ideal control shaft encoder for a couple of my projects. CODE THEORY I think "2-bit quadrature" or "phase difference signal" are the most descriptive terms. I used a Microchip Technology PICI0F206 in an SOT-23 six-pin package (see Figure 1).

if either input A or B is held to the ground by an attached encoder. There are four lines above the code waveforms and each indicates with dots where detents can occur. It turned out that I found four different detent schemes with three electrical-to-mechanical resolution ratios (see Figure 3). However. time can flow either way. DETENT DETENTE The biggest surprise I had when trying these units was how many different situations there are regarding the position of the detents with respect to the A codes. you see 00. Now we have another "real-world" aspect to considerthe positioning of the detents.. and then 10. for a given A mechanical resolution. if you have an upward edge on B when A is low (AB transition 00 to 01). for each and every case where a signal changes level. I had originally thought that if a unit had detents. since that is what I found in all the units that had this resolution ratio. rV-DD--GP-" I f-LJ I --t >-----i- ---+ -+ --+ --+ A QA c D E F B ca QC on QE OF OG ::::JQ:~ aH 22 21 20 19 18 17 16 15 74AS867 (j) ~'03 ex 5Wt~ . one with detents at A==B and the other with detents at A!=B.OC- l~o"" ~1 vee ua U1 '----". header Is not shown. or four detents per cycle are all available. And. An important characteristic of this sequence is that if signal B leads signal A. the encoder is rotating in the opposite direction. At first. I found that it actually makes the decoding software more difficult. But if the lead/lag relationship is reversed. And. The firmware in the PIC10F206 needs to be changed depending One thing to watch out for is that the processor cannot be programmed (The programming Otherwise. ~ J. L www. I show it when both A and Bare high (contacts open). The second and third lines show two cases with two detents per cycle. an advantage..circuitcellar. the encoder will have to be removed for programming. I'll show the code I used to implement this later. the electrical resolution is two B or four times finer. the opposite direction is indicated..) If the encoder can be set to a position where both contacts are open. it can be determined which direction the shaft is rotating. But if the upward edge on B happens when A is high. and Figure 2-A typical timing relationship of the the mechanical A and B phases. Figure 1-A simple testbed circuit. then that setup can be used. using Figure 1 again. two that are the state of the signals before the edge changed and two that are the state after the change.. Why waste perfectly good codes? Besides. This can be done by looking at 4 bits.1/01 1/02 Encoder under test . Moving from left to right in the figure. One.01. when you look at things in detail. As an example. codes here. It units with several relationships to the positurns out there is tion codes.JCL~8 s on the type of encoder being tested.com - CIRCUIT CELLAR" . The first line from the top shows just one detent per cycle.. there is also the possibility of three other cases. the direction is the same (as if time flows from left to right in the figure). Time----+ making the size of the contacts smaller by the Figure 3-The detents can be built into the same ratio. the encoder is going in a certain direction.vcci vee 1 €-. it didn't make sense that these were made with fewer detents than code positions. 11. All you need to know is that the overlapping codes that result from the waveforms in Figure 2 change only 1 bit at a time and that all four binary states of the 2 bits are represented. the detents would occur at every code position so that the mechanical and electrical resolutions would be the same. Unlike most such diagrams. resolution is 360 L _j divided by the number of detents. two. Let's define the electrical resolution as B the angle determined by 360 x 4 Time -----+ pulses per revolution (PPR).

LL) 2 (HH. model numbers. DATASHEET DESPAIR . A situation I found at least once was signal timing 3 diagrams that showed the detent positions as being in line with a signal edge." Photo 1 shows the devices and Table 1 lists the manufacturers. More on this later. with the thumb applying force in one direction and the forefinger in the other. nominal sizes. resolutions (both PPR and number of detents). Ergonomic Design for People at Work (Volume I. the maximum torque falls off. To describe the electrical resolution. Contact apart. and specifications stated in terms of entities that were not defined elsewhere in the datasheet. form. Several of these would rather say how high a voltage the contacts can handle (most designers won't care that the unit that is going to be used to switch a logic level can handle 120 VAC) rather than inform the designer how the code pattern relates to the detents. I will refer to the units by their numbers. 1983). The knob used to drive the device's shaft acts as a force multiplier. in one case.50 to around $6) and bought 11 more. The same grid is used in and sliding noise refer to the all of the other photos. appears similar to units 9 and 10 Cheap Cheap.com relationships of all 14 units. Some were used with the PICI0F206 testbed.43 N-m (0. In the rest of this article. Actually. I went on a buying spree (the units cost anywhere from $0. whichever you prefer. The first seven units were bought from distributor "D" and the last seven were obtained from distributor "M. the maximum torque that can be applied to a knob is in the order of 0. But there is still a significant range to the finger feel in these devices. The exceptions are units 5 and 6. or between size and number of detents. PPR. which are in the same-lugged package.clrcultceliar. CIRCUIT CELLAR" www. Number of detent [sic].LL) 2 (HH. fit. which you can see in the photo and the first column of the table. After 2". the devices differ greatly in size. part numbers. but it seems that chatter centimeter. There is no direct correlation between size and resolution.5" knob) to about 2 N-m for a 2" diameter knob. The same numbers apply to Photo 1. This was either a serious design flaw or a serious misunderstanding of how the units were designed on 7 the part of the datasheet authors. pulses per Photo I-All 14 of the units examined. Unit 4 is the smallest and unit 1 is the largest.LL) 4 4 0 4 Notes Acoustically noisy! Warning: similar units may contain barlings! All plastic housing Same as above. All but two of the encoders have PCB through-hole terminals.) According to Eastman Kodak's book. cases where specifications were quoted without a clear indication of test conditions. As you can see in photo I.Index [1] [2] [3] [4] [5] [6] Manufacturer Grayhill Panasonic CUI Bourns CTS CTS CTS Mountain Switch ALPS Piher Taiwan-Alpha BI BI BI Pari number 25LB10-Q EVE-GA1F1724B ACZ16NBR1E-15KQA1-24C 3315C-001-006L 288T232R161A1 288T232R161A2 290VAA5F201A1 101-5437-EV EC11B15202AA CI-11CO-V1Y22-HF4CF RE130F-40-20F-12P EN11-VNB1AQ15 EN12-VN20AF20 EN16-V22AF15 Number of detents 36 24 24 0 0 16 0 24 30 30 12 20 0 24 PPR 9 24 24 6 4 4 20 12 15 15 12 20 24 24 Nominal size 1 inch 12mm 16mm 9mm 16mm 16mm 9mm 10mm 11 mm 11 mm 12mm 11 mm 12mm 16mm Codes/detent 1 4 4 0 0 1 0 2 (HH. but with detents PPR not verified Cheapest (less than $1) Appears similar to units 10 and 12 Appears similar to units 9 and 12 Cheap. and.2" or half a that. I also found nonsensical units. The torque needed to turn the shaft is another aspect of detents. datasheets can use any of the following: pulses per rev12 13 olution. It turns out that these numbers are all much larger than the largest torque spec I found in encoder datasheets. and the code/detent The datasheet state of affairs is generally despicable. Many were taken revolution per track. the torque itself is not the entire story. (Think of it as a differential force. Of the PCB mount types. six are designed so that the encoder's shaft is parallel to the PCB and six orient the shaft at right angles to the PCB. THE LINEUP After encountering problems with three encoders from past projects. Note bounce is most often called just that the background grid is nominally either 0. and function same as unit 3 [7] [8] [9] [10] [11] [12] [13] [14] Table I-The encoders' manufacturers. One can also obtain SMD versions of some of the smaller types. and resolutions.

nxp.A simple choice ~ ~ Up to 128 KB Flash with 512 Byte page erase and 8 KBSRAM Industry's first ROM-based divide library for Cortex" -MO.com/cortex-mO .LPC1200 Cortex-MO .offering fast and deterministic execution for 32-bit division Unique configurable peripherals suited to energy efficient applications Supported by LPCXpresso tool chain for easy development and migration ~ ~ www.

and it would seem obvious that the slower you turn the shaft on this kind of switch. those from BI Technologies.) One thing I never found any reference to in the datasheets is the acoustic noise level of the clicks when moving between detents. a wide range of speeds can be obtained. if the bounce times are specified at either the maximum or lifetime test speeds. So. I'll just list some of the most unusual things I found.") The contacts for units 5 and 6 can be seen through an opening. Another observation: If you look at the angles covered by the contact area and the insulator between them. I found all of the following: oz-in. connecting each outer one as a function of the angle to the center common one. take it apart. you will see that the contact area's angle is the smaller of the two. The first encoder I tried. 5." The majority of the datasheets have contact bounce specifications in the range of 2 to 5 ms. and it took Google "define: barling" (no definitions found) to convince me that this had to be a term for bearing! Another translation problem was found in unit lO's document where the term "phrase difference" is used instead of "phase difference. It uses a very different contact/track arrangement. and this angular size needs to be subtracted from the conductive portions to approach the ideal performance. mN-m. but at this specific intersection of mechanical and electrical design. so I was able to conclude that they are of the same type of design. 1. with the contacts wiping near the centers of each track. I was confused by a word I had not seen before: some of the encoders covered by the document were built with "barlings. or are a maximum speed. I opened up unit 3. 6. often says. but after thinking about it some more. but these are seemingly associated with either the lifetime specifications. Four of the datasheets do not have this very important specification (those that cover units 1. I suspect that instead of 1 n. those specs will be next to useless! This might mean that to get absolutely reliable results from these units some sort of dynamic deb ounce logic or circuit would have to be used.000 Mn was meant. In all of these three datasheets. unit 1 (Grayhill). In the datasheet for unit I. but 1 Gn seems unusually high. but the conductive areas are significantly different. There was an unusual number of odd or just wrong entries in the datasheets. the rotor is made up of three contacts in the same circle and equally DECODER DECONSTRUCTION David Jones. the longer the bounce time. N-cm. This was on the datasheet for unit 8. In the datasheet for unit 2. The only datasheets that supply a clear test condition for both the bounce time and the sliding noise are the last three. that consistency does not exist. Why? The sliding contacts themselves must necessarily cover an angle larger than zero. I realized there wasn't a problem." The term was used consistently throughout. It's definitely a straightforward implementation. Photo 2-The back of encoder Note the nine contact areas in track on the inside. Sometimes there is a specification for mechanical vibration.000 mn. 1. I was concerned that these radial connections to the pins would cause extra pulses at one particular location.3. each of the tracks and the common CIRCUIT CELLAR" - www. the sliding noise is specified at 60 RPM and the bounce time is at 15 RPM.com . and not necessarily tied to the contact bounce spec. Unit I. When one is using fingers to turn a shaft. Photo 2 is a view through the board from the back of the unit after a small label was removed. The rotor must consist simply of three contacts connected together on the same radial line. host of the EEVblog. "Don't turn it on. and 8)! Often it is not clear at what shaft speed the deb ounce spec applies: a speed will be listed. it clearly states that the insulation resistance between terminals is 1. This proved to be quite a different beast (see photo 3). (The last one has no length component and therefore is not a torque. gfcm. where the two tracks are at quite different radii. (I'll leave this as a proverbial"exercise for the student." I followed his advice and started doing just that. You can clearly see the encoder's contact pattern and that there are nine PPR per track. was annoying in the application that I intended it for-lighting control in a quiet room-because it was just too loud! the largest one. a further difference is seen: the insulator's angles seem to be about the same for both tracks. The first unit did not need much deconstruction.circuitcellar. and gf. As you can see in Photo 3a. In the first photo.C:===:]same problem: when a contact is sliding along a conductive section and it momentarily opens. is made from a fairly thin PCB that's heatstaked to the plastic body. I think electronics engineers are used to a fairly consistent standard with our IC and discrete electronic component datasheets. A wide range of units is used to specify torque.

bJeto follow this course._.(741'pages). " ~"o" "'• CD-ROM including . [-blocks ' hartlware.t.~. a E\ej<.0 d"'"" software for it.« .!...'0 prite:'~ -e'...:lektdr Certificate C ~3 Plea'Se~. We will start with the absolute basics and we will go into a lot of detail.and example files sof~~. e" ".elektor.00.><"''':' $575.comldistancelearning' for further information. Allrelevant products are available ' individuallybut also as a set at a discounted price.\6"".O! P \ au\hOl"'" own em bedded applications and write the appropriate ".elekt~ ACADEMY .. - . Your course package: • Courseware Ring Bind~(::'.~:" • Application Board ~ Contents: • Background • Digital Ports • Serial Communication (RS232) • Analog Signals • Pulse Width Modulation • Timers/Counters/Interrupts • • • • • • • Memory LCD Display PC Communication SPICommunication USBCommunication Configuration (Fuses) Answers to the assignments . C and Flowcode In this course you will learn how to program an embedded microcontroller.. Please checkwww.is reqtired which you may already have (in part)...~c.. You cannot learn about software without understanding the hardware so we will also take a close look at the components PR\CE SLASHED! 570 D\SCOUNT de"gne"aodO\he"eade S'lo'"': and schematics. • . • Appendix -..DISTANCE LEARNING COURSE Programming Embedded PIC Microcontrollers ~ using Assembly. At the end of the course you will be able to design your'O)e<"and ".rte:to ~ a.

and 13 were all found to use the same scheme. spaced. That only leaves unit 4. It has contacts on opposite sides of the device's body but at the same radius. and 14 also use the same scheme. You can certainly understand the advantage of using one radius instead of three. so it was hard to immediately see that this was the scheme in use. I found only one that uses this scheme: unit 7 (see Photo 4).com . I added a line through the center of the unit to show this (see photo 4).13 sq em) CIRCUIT CELLAR" - www. Save Cost & Space on Every PCB!! Solutions for: PIC.23 mm (5.8 tt: /80 mm since this is a 20 PPR unit) difference in the lengths of the two contact arms. BOM • CZOOO. so the required circumferential offset would be only a 0. which is totally sealed. 12. II. on the other hand. It's likely units 9.com Tag-Connector footprints as small as 0.SPY-BI-WIRE• sPl/nc. however. It is a scheme where one track is used but two sliding contacts are spaced with an effective offset of a quarter cycle. 10. The stator. is shown to be made up of three parts. dsPIC • ARM. the contacts are about 5. MSP430 • Atmel • Generic JTAG • Altera Xilinx. which seems rather hard to control.PlugOfNails. the offset JTAG Connector Plugs Directly into PCB!! No Header! No Srainer! Our patented range of Plug-of-Nails'" spring-pin cables plug directly into a tiny footprint of pads and locating holes in your PCB. Altium Mini-HOMI • & More www. I thought I was looking at something unique when I opened this unit. ineh (0. Looking at the dimensions.8 mm apart on a line through the center. It's a clever transformation since it requires the same number of sliding contacts (three) and the same number of continuous metal sections for those contacts to slide on (three again).02 sq. Of all 14 units. What seems to be the case is that the contact arms are the same length but both land on the code disk just a bit above the center line. each occupying a third of the circle (see Photo 3b). but there is no squeezing of tracks into smaller radii.Photo 3-The inside of encoder 3. There is another type of design that appears in various sources I consulted. eliminating the need for a mating header. and unit 7 in the undecided column. The contact arrangement found in unit 3 turned out to be the most common scheme when I opened more and more units. Some of these units are so small that it is hard to imagine that two tracks (three counting the common) could fit in the radius available. which is required with the straightforward scheme. 8.circuitceliar. Ideally. Units 2. The contacts were in wells filled with silicone grease. this turned out to be the most common style of track/contact arrangement.

. a slide switch. the test shaft angle. Both of effects of age.com Configu(able Protctvping System with Built·ln Test Equipment can be implemented (see Listing 1)./ PC-Based My approach to debouncing was to • 12C. or occurs near either of the whether to allow for the degrading The maximum number of instrucother contact's transitions. By changing the value of USBee. but to that is supposed to be quarter cycle between the A and B contacts. the tradeoffs are has reached a transition.115 mm! . the real world intrudes.'" . would be half of the calculated value./ Affordable take samples in a tight loop as quick• l-WI. longer or shorter deb ounce times www. but it was ing at or near the same likely that since no knob was being used. only one contact wait a minute! Isn't that can change state at a time. it seemed to work fine. about 10 times faster than the specs say? Welcome But again. debounce period of 320 ms. but that is not the case with these sliding contact types. in theory.e.ij'SBee j I! E (N ~ ~ www. CAN . there should be no need for debouncing. USB. This can be seen by the fact that switch F. The first is speeds were on the low when the bounce on one side. In an optical encoder." That is what these encoders are: circular track slide switches. whether to ignore transiThe second is when slidPhoto 4---Inside encoder 7. it is all about tradethe time the other contact offs.I Conflgurabte Ganssle covers are also suggested in ./ Sign a I General. be able to sense every sinclosed opens briefly) gle detent at low speeds. I had no means of measuring situations that can cause both contacts to be changthe shaft speed.com CIRCUIT CELLAR" if 33 .ganssle. / ProtocoLAn alv~. so something like 0.er N. Bear in mind that most of the 16 switches dealt with there would have had some kind of spring-driven snap action that cannot be implemented in a position encoder. so it runs in 10 ms in the processor I used. which gives a need for contact deb ounce.comj debouncing. Here./ Oscillescopes.. Async. . Like most design decicontact has not finished by sions./ Logic Ana Iyz"rs . and it is a given that tions in the loop is 10 when the these conditions will be exacerbated by aging and will depend on shaft speed.value read from the contacts matches the stored value.clrcultcellar.12S ly as possible but to require that N samples be the same before a change TM is declared. There are two back to the real world. SPI.USBee.htm).DX ProtolYler • USB based Elect:r!cal E~ngr~ne. 0 ~ 'C. A value for N (the constant CONTACT BOUNCE NEE 0 E 0 in the code) such Now. This was unique in the set as it turned tions that might happen at ing noise (when a contact out to be the only one with one physical track and an offset of a higher shaft speeds.ors . . was found to be "very sensitive to the rate of activation../ High Speed lJSBl . In an ideal situation. But would not be needed since../ pregramma~ several of the encoder datasheets. Useful information about contact bounce is available at the Ganssle Group's website (www. . let me justify the as 32. Both the R-C filtering approach and the use of the MC14490 hex debouncer that Jack . ~S/2.

no change is reported..get back newest read ing movwf old_sample .. w . In a one-code-per-detent encoder. pulse width. The listing shows how the two least-significant bits (LSBs)of the look-up result are used to decide whether to increment or decrement the software counter i n t ern ale 0 U n t or to do nothing. Ili.NEEDED . To use with a one-code-per-detent encoder. else flagCA_edge) = true.read in the port .store these two bits into a variable subwf old_sample. To change the code to handle a two-code-per-detent encoder. if CClooked_up & Ox03) == 2) internal_count++.e.otherwise just decrement the counter: decf needed_count.just want two bits from it! andlw OxOC entry movwf . Ilclear a possibly set clock output.the old and new match so decrement the counter if not at zero already: movf needed_count.f goto loop_start at_end .since samples are different. combo = Centry & Ox06) I CCcombo »2) & Ox03. the next 2 bits are used to decide which encoder output had an edge change so that the two flags A_edge and B_edge can be set accordingly. In a two-code-per-detent encoder. these don't seem to be as popular as the four-code-per-detent case.if subwf result was zero then old and new are Cstill) goto are_same .f .now the new is the old goto loop_start are_same .now put the new reading into old_reading movf ent ry. if CClooked_up & Ox04) ) flagCB_edge) = true. if Clooked_up !=O){ if CClooked_up & Ox03) == 1) internal_count--. only one change would be needed: require the LSB of the counter to be 0 to produce an output pulse instead of requiring the "10" condition. combo is 2 new bits from encoder + the 2 old bits CK_OUT = Low.Z . need to re-start the debounce counter: movlw NEEDED . it turns out that at least one change on both phases is also required. then an output pulse is issued.w .initialize counter. flagCB_edge) = flagCA_edge) = false. which tells the processor what to do. The last sentence reflects the key difference between a one-code per-detent and a four-code-perdetent encoder: if either of the tracks is seen to toggle without activity in the other. Also.com . the external counter would be told to increment and decrement repeatedly under that condition.needed_count <. neither the internal counter • -- Listing 2-Some pseudocode to show the logic of the look-up table. Clear it here for a longer looked_up = table_start[combo].w movf . This is the advantage I alluded to earlier: fault tolerance. All variable names are the same as in the Assembler code. The pseudocode in Listing 2 is a distillation of the Assembler code on the Circuit Cellar FTP site.if needed_count is zero.is the new value the same as the previous value? btfsc STATUS.syntax is basically a test for zero btfsc STATUS. but as Table 1 shows. LOOK WAY UP It only takes a simple 16-entry look-up table to affect the decoding of the combination of the two previous bits and the two new bits into a number. movwf needed_count . LOOK UP. A two-code-per-detent case would seem to be the ideal. The variable names are taken from the actual code so that you can read the Assembler code easily. go to at_end goto at_end . half of the entries are zero because there are four combinations that are deemed incorrect (where both bits have changed) and four other combinations that represent no change at all. o ~ ~ _ . The constant NEEDED determines how many times through the loop the processor will run when the values do not change so that a new stable condition can be declared. loop_start GPIO.at end of search for NEEDED values the same the same the contacts will get worse with time. if CflagCA_edge) & flagCB_edge) & CCinternal_count&Ox03)==O»{ CK_OUT = hi gh.:: ~ ~ ia' I 34 CIRCUIT CELLAR" - www. If the counter is modified.Z .circuitcellar. If an edge happens on both A and B and the counter is such that its two LSBs are 0.• Listing I-The simple debouncing routine.

alps. Operating as PLD De5ign5. The datasheets are generally so poor that I can only conclude that in all cases you should get a sample or two before designing one of these in. 1983. RESOURCES EEVBlog.ctscorp.com Eastman Kodak Company.com/pub/Circuit_ Cellar/2011/250. Inc. There are so many variations in mounting style.com RE130F-40-20F-12P Encoder Taiwan Alpha Electronic Co. I can't really suggest a list. The other conclusion I offer is that device manufacturers generally need to improve how they prepare their datasheets. resolution.i5Iand. I www. Ergonomic Design for People at Work. But I hope photo 1 and Table 1 will help.com PROJECT FILES To download the code. I www. quick-anddirty applications.panasonic. Go to www. go to ftp:// ftp. and size.grayhill. and EN16-V22AF15 Encoders HI Technologies I www." 2004.com ACZ16NBRIE-15KQAl-24C CUI. Volume 1.cui. which consutts in the seiecnon of PLD5 and de5ign5 circuit boetas for customers (With and without PLD5). www. and 290VAA5F201Al CTS Corp. I www. Inc.eevblog.com ENll-VNBlAQ15. Inc. I www.onsemLcom EVE-GAIF1724B Encoder Panasonic Corp. www. You may contact Keith bye-mail at kdbrown@i5Iand. EN12VN20AF20. P Eng. The Ganssle Group. he ha5 pub1i5hed two earlier eruae» in Circuit Cellar. John & Sons.microchip.netl-kdbrown for aetsus.ganssle. For one-off.com CI-IICO-VIY22-HF4CF Encoder Piher International Corp.taiwanalpha.com Encoder Encoders 25LBIO-Q Encoder Grayhill.com PICIOF206 Microcontroller Microchip Technology. iii Keith Brown.nor the two edge flags are needed.net.com www.htm SOURCES ECllB15202AA Encoder ALPS Electronic Co. 288T232R161A2.clrcultcellar. Inc. ENCODERS IN HAND There are many important aspects to consider when using one of these encoders in a design..circuitcellar.com - CIRCUIT CELLAR" . I www. Wiley. com/debouncing.com MC14490 Hex contact bounce eliminator ON Semiconductor I www. IIve5 on Vancouver 15land. I www.bitechnologies. "A Guide to Debouncing. I suggest having an assortment on hand.piher-nacesa.bourns. Be. Inc. I www. 3315C-OOI-006L Encoder Bourns.com 288T232R161Al. I www. I www.

While this environment sacrifices some efficiency. respectively.~ ~ ~s\RIIflt=================:::::J by Mariano Lizarraga. any performance issues are made insignificant by the speed with which changes can be made and tested. the software can be easily retargeted for better processors without having to rework the low-level. sensor calibration. Renwick Curry. We'll also present results from temperature compensation. and Gabriel Elkaim (USA) Reprogrammable UAV Autopilot System (Part 2) Testing and Results In the first part of this series. The sensor DSC's low-level software architecture (see Figure 1) is a combination of blocks provided by Lubin Kerhuel's dsPIC Simulink Embedded Target (ET) (shown in (Simulink blocks) www. generating signals to the UAV's control surfaces to stabilize the aircraft and fly it along the user-designated mission (at its highest level. traversing waypoints at a given altitude and airspeed). we introduced the hardware used in the Santa Cruz Low-cost UAV GNC System (SLUGS). In this article. rapidly increasing the prototype-simulate-test cycle. back-end code. These are interconnected via a SPI at 10 MHz and are called the" sensor" DSC and "control" DSC. and flight tests. Complicated algorithms and changes are easy to implement. If JL SOFTWARE ARCHITECTURE The SLUGS has two Microchip Technology dsPIC33 digital signal controllers (DSCs) that serve as its main processing units.com . an open-source unmanned aerial vehicle (UAV) autopilot primarily focused on supporting guidance. running at 40 MIPS. you were introduced to the SLUGS reprogrammable UAV autopilot system. Lastly. Most researchers in the GNC field are already familiar with MATLAB Figure 1-Low-level software architecture for the sensor DSC 36 CIRCUIT CELLAR" - and use it to prototype and simulate new algorithms. This article details the system's software and flight test results. and control (GNC) research. we'll focus on the software architecture and algorithms.clrcultcellar. The control DSC position estimation interacts with the user through the ground station. The sensor DSC is in charge of reading the sensor data and converting it into a high-quality estimate of the aircraft position and attiAttitude and tude (3-D orientation). This offers several D Simulink ET blocks advantages. One of the key advancements in the D C Function call SLUGS autopilot is that the DSCs are proD Simulink blocks grammed directly from MATLAB Simulink D Modifiable by end user using a block and signal flow metaphor for visual programming. navigation. n the ill" part of this two-part series.

This ensures that no sudden transients are experienced by the aircraft when switching between manual and autonomous mode. and it was necessary to rewrite it in C and provide it as a C function call block in Simulink. implemented From sensor DSC [SPlj From radio modem [UARTj quq quq [}> - as an interrupt-driven state machine to decode the data. The control DSC's low-level software architecture (shown in Figure 2) is currently less resource intensive than that of the sensor DSC. it was decided early in the design process that many of these would be rewritten in C to provide greater flexibility and full control of the implementation. In a similar manner. and magnetometer data are passed through a calibration and temperature compensation block to produce temperature-compensated data in meaningful engineering units. The packets sent from the sensor DSC are received and placed in a circular queue. and temperature) are read directly from the hardware via the DSC's ADC and passed through a digital low-pass filter bank to attenuate sensor noise. velocities. controller gains. position. schedules them for transmission. binary communications protocol. the control surfaces should be in exactly the same place that they were before the switch. but also sent to the GCS and logged to facilitate debugging and post-flight analysis. The GCS commands protocol decoder reads the queue. and used for both control loop tuning and fault diagnosis in real time. COMMUNICATIONS PROTOCOL q q Navigation and control q q q [IDq j > D D C Function Simulink call blocks [3> q To control surface servos [PWMj D D Modifiable Simulink by end user (Simulink ET blocks blocks) Figure 2-Low-level software architecture for the control DSC www. Although the ET offered ready-touse blocks for most of the DSC's peripherals. These data are used to drive the GCS display. data received from the radio modem-containing ground control station (GCS) commands-are stored in a separate circular queue. During our initial development phase. and sends them to the radio modem for ground telemetry data. The magnetometers are configured and queried through PC. For instance. The data being received by the input capture port from the radio control receiver (RCRx) are received and scaled from the PWM duty cycle to angular values in radians corresponding to control surface deflection commands. recorded for post-flight analysis. accelerometer. absolute and differential pressure.blue). blocks implemented in C (shown in yellow).clrcultcellar. The guidance and control algorithm generates the required control surface commands. The data being received by the RCRx are scaled from the PWM duty cycle to angular values and passed to the guidance and control algorithm to be used as initial conditions for the manual-to-autonomous transition. and the digital stream is decoded according to the device specifications. In hardware-in-the-loop (HIL) simulation (see Part 1) and in real flight. The ET's UART block did not offer this capability. and course over ground (COG) information.com CIRCUIT CELLAR" The complete autopilot system generates 168 different meaningful variables. yet effective. we decided to adopt the . In other words. and passes them on to the navigation and control algorithm. The GPS serial stream is read via a UART port and placed into a circular queue data structure. These values are not only used by the autopilot. which are scaled from angular values to the correct PWM duty cycle and sent to each of the control surface's servos. the attitude and position estimation algorithm (shown in green) processes the data and sends the results to the control DSC via a communications protocol encoder (which separates the data into sentences and manages the SPI inter-processor communications bus). rate gyro. sensor biases. an instant after telling the autopilot to fly the airplane. battery voltage. The algorithms and test procedures are detailed later. The inter-processor communications (IPq protocol decoder reads from the queue and assembles the data for the navigation and control algorithm (shown in green). where each message contained a 4-byte header and a 3-byte trailer. The analog sensor. Attitude. control surface commands. to use less processor time while sending data through the serial port. and basic Simulink blocks (shown in white). and many more are generated on every cycle. These commands are also passed on (along with the data sent from the sensor DSq to a protocol encoder. interprets those commands. The analog sensors (dynamic and static pressures. we soon realized that adding a new sentence to the protocol was tedious and error-prone. it was necessary to use the direct memory access (DMA) feature of the DSC. This is one of the key advantages of the ET: C functions can be merged into the overall generated code with great ease. After a detailed evaluation of possible solutions. The accelerometers and rate gyros are queried via a SPI. temperature. we produced a very simple. Nevertheless. which splits them into different sentences. An NMEA 0183 protocol parser reads data from the circular queue and decodes the protocol sentences producing position. The data are assembled into a data structure that is passed to other parts of the code for further calculations.

Figure 4 shows the imporFigure 3 shows how the protocol's packets are structured.----Packet sequence System ID lightweight. This is inexpensive and requires very little board real estate. the scatter plot (top packets are sent out. The board was sealed inside a Ziploc bag and placed inside the lab's freezer. although this was existing project (provided the project is coded in C). a simple linear coeffi. possibly increasing the noise in the calibrated tools available with the protocol will generate all of the sensor output. nonlinearities. as the communications protocol of structure The advantage is that this dramatichoice was the capability to automatically generate all of the required C cally reduces the temperature drift of code to serialize. we conducted the following experiment. red) shows a the payload data. TEMPERATURE & SENSOR COMPENSATION The sensors used in the SLUGS are relatively inexpensive MEMS devices. After after temperature compensation (bottom plot. both for floating-point and integer values.---Message length at ETH Zurich.com . deemed effective for our needs. Data tures (C-structs in particular) for transThe new sensor reading is the raw Checksum high ------' Checksum low ---. a more careful temperature curve could be used documentation on how to integrate MAVLink into an instead of the simple linear correction. These are automatically logged and displayed on the GCS. using the captured data. the project itself has great Lastly.of temperature versus sensor readings. required C code.circuitcellar. Although temperature compensation does not completely remove the sensor's temperature Due to limitations in the RF link bandwidth. while dependence. In order variable or calculation accessible within the autopilot software. A mesthe linear temperature coefficient. As expected. Temperature compensation is used on the SLUGS to attenuate this null shift via an onboard. it corrects the majority of the effect. This protocol is a cient (delta sensor counts/delta tem. we performed a scatter plot Photo I-The SLUGS autopilot on top of an electric grill used to record data for temperature compensation calculations CIRCUIT CELLAR" - www.. and have proven very useful when testing out new algorithms.I mission. One only needs to describe the fields of the now a function of both the sensor and the temperature packets at a high level using a simple XML syntax. But the feature that tipped plus the coefficient multiplied by the the scales toward selecting MAVLink difference in temperature from a Figure 3-Communlcatlons protocol message nominal point. The protocol implements a small set of using static data (and several are estimated on-the-fly by "spare" messages for debugging that can be assigned to any the attitude and position estimation algorithms). and the sensor. the disadvantage is that the sensor reading is structures. a 2-byte checksum is appended to the significant improvement over the uncompensated reading message to verify its validity upon reception. powered. receive. It shows the temperaThere is a I-byte packet start sign (the letter U). send.. pack. A clear correlation A packet sequence is a counter that gets incremented as exists between the two. tance of temperature compensation. and placed on top of an electric grill to generate a slow temperature sweep (see photo 1). The largest error seen in these low-cost sensors is a null-point shift as a function of temperature. Furthermore. The system and component identiright) confirms the dependence between the two and shows fiers uniquely identify the source of the message. the static pressure sensor (top center). The sensor reading Message ID allows the serialization of data strucis then adjusted using this coefficient. low-power linear Microchip Technology MCP970I active thermistor. and decode these data the sensors. The resulting reading sage identifier indicates what type of message it is. they tend to have larger noise. blue). C:===open-source communications protocol r----Start of message (Ox55) MAVLink developed by Lorenz Meier From that plot. the board was taken out... started data recording. As a result. After an hour. others that do not change very often are sent at a lower Bias points on the sensors are relatively easy to calibrate data rate (10 Hz).. (bottom plot. some of these messages are sent at a high data rate (100 Hz). and temperature drifts than traditional (and more expensive) inertial sensors. To determine which sensors within the suite required temperature compensation.. In order to find the temperature dependence for a given sensor. message-marshalling perature counts) was extracted using Component ID library for autonomous vehicles that a least squares fit. Payload ture run (top left) and compares it with the readings from data specifies the size of the actual data being transmitted.

the semi-major axes to the scale factors.circuitcellar. The autopilot was turned on and allowed to converge on its attitude. The original design did not include longitudinal acceleration (dV/dt in body coordinates). This is held as a direction cosine matrix (OCM) in order to correctly account for the rotation. (The specific algorithms that back out the parameters to correct the accelerometers and magnetometers can be found in the References section of this article. and this does not preserve the Photo 2-Alrcraft tumbling while recording data for sensor calibration www. but this was found to be necessary to account for changes in speed. (This is necessary to do only once.(0'. In the case of the magnetometer. The center of the ellipse corresponds to the null shift. and z measurements.~ mathematical sequences. For the accelerometers and magnetometers. If the sensors were ideal. The three axis sensors measure the x. BOO' 1(01) 1200 1600 Two attitude filters were designed. you get a rotated ellipse. in fact.com CIRCUIT CELLAR" e POSITION & ATIITUDE ESTIMATION . and z components of a single (nonzero) vector.500 () .e=re track. Several candidates for computing this term were compared on the basis of tracking errors before choosing a high-pass filter to compute the approximate numerical derivative. against a better sensor. (You cannot simply add angles. The other used GPS COG. expeto match scale factors. Tlrne(s) Time'(9) waypoints requiring changes in altitude and Temperalure Compen$lllad $!alic P. A one-axis rate table and a least squares process extended Kalman filter (EKF)with state variables consisting were used to find the best scale factor match between the MEMS gyros and the FOG. In practice.) Photo 2 shows the aircraft being tumbled by one of us prior to a test flight. not before every flight. these are often referred to as hard. you would see points on the surface of a sphere. null shift. and the rotation to non-orthogonality within the axes. the UAV was carefully leveled into flying attitude in the lab using a high-accuracy spirit level. the aircraft was tumbled out at the field while telemetry data was stored on the ground station in order to get as close to the flying configuration as possible. and non-orthogonality errors. One Tlrnel(s) used magnetometers for a heading reference. This design was placed in a Simulink simulation of aV5~_'~------~ -200 '0200400 500'1000 1500 500 1000 1500' 600F UAV flying a closed course defined by Temperalure . y.and soft-iron effects. 600. a KVH OSP-3000 fiber optic gyro The initial design for the position filter was a nine-state (FOG). When plotting the real measurement instead of a sphere.1 e). and you rotated the body around all axes and plotted the x. The COG design Figure 4-Static pressure sensor (barometer) temperature compensation results was created because of the possibility of the high noise magnetometer readings (which were. y. two different methods were used depending on the sensors. they were matched rienced in the field) due to the UAV's electric motor.) Lastly. This was used to generate a small rotation offset matrix to correct for the difference between the autopilot mounting and the aircraft body coordinates. an ellipse method was used to simultaneously find scale factor. ) relationships for rotation 400 300 200 The initial design of the attitude filter used a complementary filter with a magnetometer triad for a heading reference and estimates of inertial velocity from the position filter. For the gyros.

elevator. and they were deemed unreliable. Manual direct can be combined with Pilot Feedthrough such that Attitude estimate Figure 5-Position and attitude filter architecture of position and velocity in North-East-Down (NED) coordinates and accelerometer biases. This filter performed well in the six DOF simulations with noise characteristics taken from the sensor specifications. Thus. as shown by the excellent performance of the UAV under autonomous control. The autopilot itself has three different submodes of operation. Due to the relatively clean GPS data and the fast GPS update rate. the elapsed time-from beginning the o -'100 -'I !SO -wPPojh. The new filter design reduced the computational load on the sensor DSC from near 100% to 40%. we replaced the EKF with complementary filters for horizontal position and velocity.l! . The outlier changes in altitude readings were trapped with a threshold test before further processing. the accelerometers' in-flight readings contained a high level of noise and the output of the EKF was unusable.. The filter performed strapdown navigation calculations for the state and covariance matrix at 100 Hz between GPS updates by integrating accelerometer readings after they were transformed to NED coordinates.. and can be individually tuned in flight.Accelerometers Gyros Velocity estimate Aceel biases Attitude estimate Rates estimate I estimation Gyro biases Attitude I Baro altimeter GPS Data Accelerometers Position estimation Accel biases Position estimate Velocity estimate redesign to the first download to the autopilot-was less than 24 hours. The input measurements were horizontal GPS position and velocity. The outer loop implements a high-level.. The inner loop comprises a set of proportional integral derivative (PID) controllers separated into lateral (pitch and airspeed) and longitudinal (roll and yaw) channels. In addition. one to command pitch based on altitude error with a strong saturation limit (set from the GCS to 15°). Airspeed is set to a constant and held by the inner loop PID controller. V UAV_ . barometric altitude was blended with GPS altitude readings to eliminate drift. This loop generates the direct commands to the control surfaces: ailerons. Unfortunately. Sensor readings were logged during manually controlled flight. Using the SLUGS environment.. altitude. These each contain saturation limits on the servos. These data were then replayed after the flight through the Simulink position and attitude models. and throttle. The objective of the first few flights was to log sensor readings while the UAV was manually controlled to validate attitude and position estimates before using these outputs for closed-loop guidance and control. demonstrating the flexibility and usability of the SLUGS for research purposes. accelerometer readings.. and airspeed.com . I NAVIGATION & CONTROL The control system designed for the SLUGS is based on the successive loop closure (or inner/outer loop) approach for aircraft control.. the attitude filter with COG heading reference was downloaded to the autopilot in the field and used for the remainder of the flights. For the vertical channel. It was downloaded to the autopilot for further testing. rudder.. The first mode is Pilot Feedthrough. waypoint-based navigation. These are designed to stabilize the UAV and receive mid-level commands of turn rate. where the GCS sends mid-level commands directly to the autopilot. the attitude and position filters did extremely well when compared with more sophisticated models using other flight-test data (see Figure 5). barometric altitude. Altitude is controlled with two cascaded PID loops. The final design performed extremely well.. and a second to command the elevator to achieve the desired pitch output from the first PIO stage. These telemetry data also showed that the GPS readings had little noise (except for altitude drift and very large jumps in altitude readings) and GPS updates were averaging 3 Hz. Magnetometer readings were taken in the field during static ground testing before the first flight.circuitcellar. where the pilot commands are received by the RCRx and passed directly through the autopilot untouched. It is completely implemented in the control DSC (see Part 1 of this series). and the direction cosine matrix from the attitude filter. which in turn generates commanded turn rate and altitude for the inner loop. The second mode is Manual Direct. I.00 Figure 6---Time progression of the UAV position and the computation of the LZ vector during a flight test CIRCUIT CELLAR· - www.

" is scaled by ground velocity. Flight tests were performed at UCSC's east field. one week of flight tests (more than nine flights) was devoted to tune the PID gains for the inner loop. this corresponds to a command-in-roll angle for the UAV). This also makes the core avionics trivial to mount and unmount from the UAV for lab testing and HIL simulation. Furthermore. b-The autopilot pod is mounted. in which the GCS operator configures the waypoints. Modifying the aircraft's fuselage involved shaving out a significant section of the "cockpit'" (see Photo 3a) to make way for a wireframe •••• pod (see Photo 3b). and height) and additional configurations that are necessary for its operation. the UAV's position is in blue. but the autopilot others. and the commanded path is in red. FLIGHT TEST RESULTS The UAV employed for flight tests was a modified version of an off-theshelf Multiplex Mentor radio control (Re) aircraft.the safety pilot controls some of the control surfaces. This is extremely useful when tuning control gains. During the first three weeks of flight tests. One. The third submode is Autonomouswaypoint Navigation. c-This is a full view of the aircraft fuselage with the wings and pod mounted. The L2 vector is shown in green. but all other controls remain with the safety pilot. it protects the main avionics in case of a crash. This pod. The "look ahead" length. securely housed the autopilot and the radio modem (see Photo 3c) in the airframe. And two.clrcultcellar. The outer loop receives the waypoints (in latitude.) www. called "L2. making the aircraft less sensitive in a tailwind and more sensitive to cross-track errors in a headwind. This initial test period was also used to tune the aforementioned position and attitude estimation filters. the UAV was flown under pilot control. it provides a vibration-isolated environment on which to mount the autopilot. The inner loop gets the PID gains for each controller. (The green arrow indicates the pod. and the navigation algorithm becomes responsible for generating the mid-level commands. In our project. The airspeed control loop is tuned for decent behavior while the safety pilot can keep the UAV within the bounds of the test area. throttle is given to the autopilot. Tighter control is achieved by shortening the look-ahead distance. For instance. Figure 6 shows data from an actual flight path of the UAV in the presence of wind. We cut out the "cockpit" to mount the autopilot pod. the UAV is tracking a point that is on the path from the previous waypoint to the next one that is ahead of the UAV. the safety pilot can induce errors by climbing or diving the UAV and seeing if the throttle control responds correctly. The collected flight data were analyzed offline to verify and validate the inner workings of the autopilot.com - CIRCUIT CELLAR" I! I . The tuning process Photo 3a-External modifications to the Multiplex Mentor RC aircraft. made out of balsa wood. All modes receive configuration settings from the GCS operator. but at the risk of oscillations about the path. longitude. Once the position and attitude estimation filters were proven to work. The pod has two functions. The angle between the aircraft and the L2 point is used to command the lateral acceleration of the aircraft (conveniently.

He has more than eight years of experience we achieved basic flight and waypoint following. at its beginnings. The munity of users each adds their own improvements. roll. This has changed. altifeatures. Using Simulink as the primary development platform. Also. and a ground vehicle. Renwick Curry (rcurry@ucsc. He was also our safety pilot. HIL simulation. an The navigation loop was shown to perform robustly. MS. Figure 7 shows a typical route around the preprogrammed waypoint track under than once he saved us from having to build another UAV We would also like to thank Vladimir Dobrokhodov for all of his autonomous control.circuitcellar. and its HIL simulator. These were first used in Simulink and Mariano Lizarraga (malife@soe. ------------------------ TAKING FLIGHT We presented a top-level view of the SLUGS. and he holds a BS. Finally.c::===n. software simulation.S. and an aviation setety engineer for NASA. but there is room time during flight while for improvement. Naval good tracking results even in the presence of turbulence Postgraduate School.:(m) it within the test area The SLUGS has been while the inner loop stabislowly adopting all these Figure 7-Trajectory plot of the UAV under autonomous control. a spacecraft guidance engineer (Mariner and Apollo projects). HIL simulation. The secondary objective was to validate the SLUGS in an autonomous boat. we would Simulink. and turn rate. This craft. thus the short separation between waypoints. or Java) wasn't used. only had control of the rudand now there is a wide der.$C 0 50 '00 I. we're taking steps tude. and from UCSC.110 tors. and calibration. We recently adopted the openthe safety pilot retained partial control of the airsource GCS software QGroundControl. and a PhD in Computer Engineering and wind. work is being done to use the dence between Simulink and HIL simulations and flight tests.·. like to thank Lorenz Meier at ETH Zurich for all of his help in C++. He has worked as a faculty member (MIT and Cornell). ground station was physically located at the origin.edu) earned an AB In Physics from Middlebury College. the safeproject is in active develty pilot could recover comopment and has a thriving plete control by flipping a community of contribu·.'$C ~100 . but. iii flights were always performed within visual range of the safety pilot. its ground control station.edu) holds a BS in Naval then compiled and downloaded to the autopilot hardware. and more the control to the SLUGS autopilot. The inner and outer loops performed well. A high-level programming language (such as C. and PhD in Aeronautics and Astronautics from MIT. switch on his transmitter that turned the analog it was mostly focused on MUX back to pass through. UAV researchers can easily transition between software simulation. Sciences Engineering from the Mexican Naval Academy. He is currently a Research Fellow in the Computer Engineering Department at the University of California Santa Cruz. The waypoint track set for the flight the United States and elsewhere.nvolved adjusting the gain conditions with successful of each controller one at a results. The Simulink models used for integrating MAVLink into the SLUGS. and flight tests are exactly the same.com . The SLUGS was flight tested under nominal flying writing software and designing hardware for UAVs. Authors' note: We would like to express our deepest gratitude The pilot would do several circuits around the path to to Greg Horn for working so hard on the board schematics and layout and hand·solderlng the components of the first two make sure everything was working correctly. the safety pilot support. Renwick Is currently an Adjunct Pro· fessor in the Computer Engineering Department at University CIRCUIT CELLAR" ~ www. to adapt the SLUGS's code The primary objective of base so it can work in a wider variety of autonomous experimental testing was to validate the results corresponvehicles. then release batches of autopilots. using it to skid the range of tools to support UAV through turns to keep autonomous airplanes. Finally.ucsc. We presented results for its sensors. . the UAV took off under pilot control. In particular. For every flight test. a VTOL aircraft. an opensource UAV autopilot. and flight testing without the need to re-code the algorithms in a traditional programming language. autonomous quad-copter Eventually. The lized airspeed. ternperature compensation. the SLUGS is currently being complete workflow in the SLUGS: Simulink to HIL simuadopted in several educational research laboratories in lation to flight test.SO 200 . This will undoubtedly test experiments consisted of four waypoints defining two help improve the overall quality of this project as a comshort and two long legs (roughly defining a rectangle). with MSEE and Electrical Engineer's degree from the U. It is important to stress that all of the SLUGS's control help In making the SLUGS happen and lending his experience and navigation loops were implemented directly in as a long· time UAV developer and end user. Any time it was deemed necessary.

on Automatic Control. He Is an Associate Professor In the Computer Engineering Department at University of California Santa Cruz.O. Euston.Enhanced 8OC51 CPU. Mahony.kerhuel." Journal of Guidance.of California Santa Cruz.resa1. navigation. 2009. Pflimlin.aasi. SPI Volume Discounts Available Ggridconnect~ www . QGroundControl. 55.edu Systems Lab. 2008.5-62K on-chip flash ROM . MAVLink Micro Air Vehicle Communication Protocol.com dsPIC33 nsc and MCP9701 Thermistor Microchip Technology.edu UC Santa Cruz Autonomous http://asl.com CIRCUIT CELLAR" ." IEEE Transactions Vol. R.com/malife/SLUGS Embedded Target for PICs. T. R. "A Complementary Filter for Attitude Estimation of a Fixed-Wing UAY. Hamel. 1T per macblne cycle STC Microcontroller • Binary level compatible with conventional 8051 . I www. Gabriel Hugh Elkaim (elkaim@soe. OOT • In-SysIem program or In-Applicalion program • AddressIng up 1064KB of external RAM • Dual cIaIa pWlter •8 Y8CIDr addrass." Australian National University College of Engineering &. Inc. 2007..5. "Nonlinear Complementary Filters on the Special Orthogonal L. www.com g +1 800975-4743 www. and T. P. Inc. Park. No. How. Control and Dynamics.ucsc. Source code repository. Artech House Publishers. S.circuitcellar. Mahony. Deyst. GNSS Applications and Methods (GNSS Technology and Applications).ucsc.eu/wiki/Index. Kerhuel. I www. Hamel. PWM. "Performance and Lyapunov Stability of Non-Linear Path Following Guidance Method.soe.. J. and president of AASI (www. where he works on autonomous vehicle guidance. a company specializing in aircraft flight-path optimization. P. J.org SLUGS Project. Coote. http://slugsuav. Kim.qgroundcontrol. 2 laVal • On-chip ADC. and J. Aerospace Engineering from Princeton University.com). and control. ridconnect. Gleason and D. and J.lmamal O8C1llator. EEPROM.kvh.soe. as well as an MS and PhD in Aeronautics and Astronautics from Stanford University. S. GitHub Inc.ucsc. 2008. Gebre-egiabher. www. http://github. 30.com The World's Largest 8051 MCU Family .microchip. M. Computer Science.edu) holds a BSE in Group.Up lei 204aKB SRAM . Vol.php5. 2010. Simulink RESOURCES SOURCES nSP-3000 Fiber optic gyro (FOG) KVH Industries.

.

~s\-RIIflf=================:::::J

~

~

by Thomas Mitchell (USA)

Getting Started with Microprogramming (Part 2)
A Look at the Meta-Assembler
The first article in this series detailed the architecture, programmer model, instruction set, and general operation of a simple microprogrammed processor. Here you learn about real-world microprogramming and the meta-assembler.

n the first article in this series [ ,et the groundwork for building a custom microprogrammed processor suitable for an FPGA, and I detailed the "what" of the simple microprogrammed processor (SMP). Now I'll tell you about the "how." Real-world microprogramming is the focus of this article. So, to begin, let's look at the meta-assembler.

If JL

In the SMP development, I used WinTIM to develop the SMP microcode and to develop Assembly language programs for the SMP. The first step is to create a "definition" file. The purpose of the definition file is to define the structure of the microword and symbolic values, which are assembled to generate microwords. This concept can be better explained with an example of a definition file.

WinTIM
Previously, I used WinTIM-which was developed Van Heest and Mitch Kispet as a class project at the Institute of Technology-to generate the test vectors my Advanced Micro Devices Am2910 VHDL design against real hardware. I -.used WinTIM for the development of the listing SMP because, although it has its limitations, it's free and the source is available. WinTIM is based on the program TIM, which is Texas Instruments's version of Hi-Level Engineering's HALE meta-assembler. WinTIM is a metaassembler, and it's a program that can be configured to convert Assembly language mnemonics from different processors into a binary form. A metaassembler makes no assumptions about the format of the Assembly language because the format must be defined before the source can be processed. In fact, a meta-assembler can generate binary patterns (an executable, if you like) for many purposes, including assembling a source file into processorexecutable binaries, microprograms, or look-up tables. by Eric Georgia to verify

MICROPROGRAM

DEFINITION FILE

Listing 1 is an example of a constant definition in a WinTIM definition file. The TITLE directive is just what it says, a title for the definition file. WO RD is a directive

1-An example of a constant definition in a WinTIMdefinition file
13 10

; Am2910 Instruction: ; Logical Microword Bits: ; Physical Microword Bits:

· ·

.***************************************************************.
71 - 68

;

·

.***************************************************************.
Microinstruction EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU EQU H#O H#l H#2 H#3 H#4 H#5 H#6 H#7 H#8 H#9 H#A H#B H#C H#D H#E H#F Definitions

. . .

; Am2910 JZ: CJS: JMAP: CJ P: PUSH: JSRP: CJV: J RP: RFCT: RPCT: CRTN: CJ PP: LDCT: LOOP: CONT: TWB:

0

"..... ".....

<N

<n

" ~

0 <N

a' ~ 46

Jump to location zero Conditi onal jump to subroutine Jump map Conditi onal jump to pipeline Push/Conditional Load Counter Jump to register or pipeline subroutine jump vector Conditional Jump to register or pipeline location Repeat loop until cnt=O (loop on stack) Repeat loop until cnt=O (loop on pipeline) Conditional return from subroutine Conditional jump to pipeline and pop stack Load counter and continue Test end of loop Continue Three way branch
CIRCUIT CELLAR" -

www.clrcultceliar.com

--•

Listing 2-The eight sections of the microword defined using the sub-format (SUB) directive. The definition for the SMP format is at the bottom of the listing.

.***************************************************************. , Microword Field Format Definitions .***************************************************************. , AM291o: SUB 4VH#E, 16V%:H#000%, 4VB#01l1 ; Controls the fields for the Am2910 Microprogram Sequencer AM2901: SUB 3VB#001, 3VB#01l, 3VB#100, 4VH#F, ; Controls the fields for the Am2901 ALU REGLD: SUB 9VB#000000000 ; Controls register load enables MUX: SUB 6VB#00000 ; Controls the processor and interrupt 4VH#F, 1VB#o

, ,

enable

set and clear

multiplexers enables

RWEN: SUB 4VB#0000 ; Controls Memory and lID read and write SUB 3VB#000 SHIFT: ; Controls shift multiplexer IMAP: SUB 2VB#00 ; Controls which instruction PSTATE: SUB 6VB#000000 ; Indicates processor state SMP: .__ DEF AM291o, AM2901,

it is a "don't care. This feature can be used to define multiple sub-formats where differing bits may be variable or not, depending on the context. Only one format is used in the SMP microprogram . The definition for the SMP format is at the bottom of Listing 2. The SMP format consists of the eight previously defined sub-formats. There is no overlap between the different sub-formats, but different formats can be defined from different combinations of subformats and fields. The SMP microprogram uses only one format, but I could just as easily have defined different formats with most of the bits fixed and only a few variable fields.
II

MICROPROGRAM
map is used for JMAP

SOURCE FILE

The microprogram source file is akin to a normal Assembly language source file except it's coupled with a definition file that explains which bit patterns correspond to which source IMAP, PSTATE ---,_ code"instructions." Listing 3 shows an excerpt from the SMP WinTIM

REGLD, MUX, RWEN, SHIFT,

that sets the microword size-in this case, 72 bits. What follows are comments (they begin with a semicolon "j") about the subsequent definitions. The "jump to zero" (JZ) Am2910 instruction is defined using the EQU (equate) directive as H#O [i.e., a hex digit with a value of 0). The other 15 Am2910 instructions are similarly defined. In Listing 2, the eight sections of the microword are defined using the sub-format (SUB) directive. For example, the Am2910 section is defined with a sub-format with three fields. The first field (4 VH# E) is a 4-bit variable field with a default value of hex E. The second field (16V%: H#OOO%) is a 16-bit variable field with a default value of hex 0000 [i.e., a 16-bit binary value of all zeros). The % after 16 V indicates the values assigned to this field will be right-justified if they are less than 16 bits. The: after the 16 V% indicates that values assigned to this field greater than 16 bits will be truncated to 16 bits. The third field (4 V B#O 111) is a 4-bit variable field with a default value of binary 0111. So what does all this mean? This statement defines the format of the Am2910 section and sets default values. These values are as follows: The Am2910 instruction is a hex E-that is, a "Continue" (CO NT) instruction, with the Am2910 direct input set to hex 0000 (12 bits right-justified and expanded to 16 bits). The test input is "ALWAYS"that is, the condition code input to the Am2910 is a logical TRUE. Because each field of the sub-format is defined as a variable, they can be set to any value with the same number of bits. However, if the "V" is omitted, the sub-field is defined to be the constant value, or, if the value is omitted,
www.circuitcellar.com CIRCUIT CELLAR"

source file. Like the definition file, there are typically directives that precede the actual source. The TITLE directive states the title of the source file, the LIST directive controls the output of the listing file generated. The "B" parameter of the LIST directive indicates that the formatted object code will follow the listing of the source, rather than be interspersed with the source code. The "W" parameter of the LI ST directive indicates that the listing should word-wrap rather than truncate lines longer than the listing width. The FORM directive defines the output of the formatted object code in the listing where a "1" indicates a binary digit, a "3" indicates an octal digit, a "4" indicates a hex digit, and a "b" indicates a blank space. The WIDTH directive sets the width of the listing file. The 0 RG directive sets the location for the object code output. The first actual line of source code starts with MA IN:, which is a location label. In this case, it has a value of hex o which is the location value previously defined by the ORG directive. What follows is SMP, which indicates that the following parameters will be applied to the SMP format. CONT is the Am2910 instruction, H#O% is the Am2910jAm2901 direct input, and ALWAYS is the test input control. The resulting value will be hex E00007, which is only 24 bits. Where is the rest of the microword? The next seven lines all start with a forward slash, which indicates that this line is a continuation of the previous line. Therefore, the eight lines constitute one microword of the microprogram. The comments at the end of ea~h u line are a convenience to keep track of which part of the microword the parameter applies to. The resulting

I.~
'0 IN
ia'

~ IN ~ _~

~ 47

C::==~microword (formatted according to the FO RM directive) is:

listing 3-An excerpt from the SMPWinTIMsource file

00000 E 0000 07 007 FF a 000000000 0000 00 00000 00 00
Reading from left to right, hex 00000 is the microprogram location (not part of the microword). Hex E is the Am2910 instruction. Hex 0000 is the Am291O/Am2901 direct input. Binary 0 and octal 7 are the test input polarity and test input select, respectively. Octal 007 is the Am2901 instruction. Hex FF are the Am2901 A and B addresses. Binary 0 is the Am2901 carry-in. Binary 000000000 is the register load enables. Binary 0000 and 00 are the multiplexer controls. Binary 0000 is the read/write enables. Octal 0 is the shift control. Binary 00 is the IMAP control. Octal 00 is the processor state. So, is that clear? Well, maybe not. Microprogramming takes a little bit of effort to learn. What I find helpful is being consistent in the writing of micro-instructions and good comments. In the SMP microprogram, every micro-instruction uses the same eight-line format with comments to indicate the different sections of the microword. If you use a similarly consistent format, then writing a line of microcode becomes a matter of plugging in values for the relevant fields and leaving the rest at their default values. When writing a microprogram, it is important to have a clear picture of the structure of the microword, the values that can be applied to the different fields, and how these values translate into hardware signals.

ORG H#OO initialize Am2901 0 register to zero MAIN:
I I I I I I I

SMP CONT, H#O%, ALWAYS, OREG, ADD, DZ .., NCI, NOLOAD, DEFMUX, NORW, DEFSHIFT, DEFIMAP, SINIT

Am2910 Am2901 REGLD MUX RWEN SHIFT IMAP PSTATE

Instruction fetch Loads MAR with PC and increments the PC FETCH: SMP Am2910 Am2901 REGLD MUX RWEN SHIFT IMAP PSTATE

I I I I I I I

RAMA, ADD, ZA, PC, PC, CI, MARLD, DEFMUX, NORW, DEFSHIFT, DEFIMAP, SFETCH

Asserts MEMRD until MWAIT is true, i.e. read memory addressed by MAR MDIR is loaded while waiting for MWAIT SMP CJP, $%, NMWAIT, MDIRLD, DEFMUX, MEMRD, DEFSHIFT, DEFIMAP, SFETCH Am2910 Am2901 REGLD MUX RWEN SHIFT IMAP PSTATE

I I I I I I I

"PROGRAMMING" THE VHDL
Up to this point, the HDL and microprogram development have been independent. Now, we need to use the binary generated by WinTIM to initialize the block RAMs in the control store. This is the easy part, because I wrote a program to process the .mif file output of WinTIM and turned it into a text array, which can be used in the control store VHDL code to initialize the RAM. The following runs the program:

mif2array <mif file> <array file> <array size>
The array size sets the number of values in the array regardless of the number of values in the .mif file. This is necessary because the initialization of an array in VHDL expects all of the values of the array to be initialized whether they are used or not. Values not defined in the .mif file are initialized to zero.

If the array size parameter is omitted, the array will use only the .mif file values. To install the microcode into the control store VHDL, open the array file and copy everything. Then open the Control_Store.vhd file and find the definition of the signal RAM. Paste the copy buffer after the line that says "Insert microprogram here" and save the file. Use the Xilinx ISE program to rebuild the bit file for the target device. Clearly, this is not the fastest way to update microcode, but Xilinx provides a program, "data2mem,"

listing 4-The .bmm file for the SMP

ADDRESS_SPACE control store RAMB36 [OxOOOOOOOO BUS_BLOCK U1/inst_Mram_mem1 [0:35]; U1/inst_Mram_mem11 [36:71]; END_BUS_BLOCK; END_ADDRESS_SPACE;

OxOOOOOl ff]

48

CIRCUIT CELLAR" -

www.circuitcellar.com

o.l..IIt '.!l p(ogr.5~:....ifi(. Keynote: Or.~e:m."ee mobile app at http://gettag.'i~aIS~"lo~'inl'ta:c~ coverin'g ih'~tg~i£:s Il\al ilri!mqSt11r\'poJtfln~toiOu'pnq.eatdJer Stan this QR code t.ated c:halieng&son th e exp 0 floor. Informed ~~.rietIJf1Q1o. "\Ivir:eJisii~~~rNelWli'RIrl'.~pllr I:i~'tne~.~ ~E>iPd'..2b. Opening.mQbi .olog.SIi&¥~~l~!irislf1l. d".~~or:"atte:n~i)e5 eVaJuati.q. Hugh Herr Biom echatn'l ~lcs R~s.e~·ir\.b. solutl ons to you r most d iff(".lat9~~~ri'g.ntifY '5pe'.n Sensors and Sensor Integrated Sal!5ors !!l'!aSen5iog rechll.sensing.r:ln~s 1iIg:ej~~rW. Don~t M Iis: these ex-pDF I00r" H Ig hlfg hts.':~ri'g o \0 miike ao:!IS'ons.£IaSli.teqion and «)ntrol.The Only Indust")' Event in North Amadea ExclusiVely Focused o. Systems I Find the Solutions to Vour r~d'.:l Id e.lmThHude~rnore $!l\n:rorsindurtry.o Register" Now on Your Mobile Devite! Get the.y CNU"ng"~1 Gain the knowledge yO\! need from leading experts and peQl"$lnth" Tl\ei~~fl'!i'enc~ • MSYtS ~i1ljlHii~~.gl~I!'5!nd '. indutirl191 .

mem file: mi f2mem <mi f fi 1 e> <mem f i 1 e> <a rray si z e> This program works the same as mi f 2 a r ray except for the output.com Values for Condition field ZERO: CARRY: SIGN: Eau EaU EaU EaU 2B#OO 2B#01 2B#lO 2B#1l OVR: Values for Destination RO: Rl: R2: R3: R4: R5: R6: R7: and Source fields Eau EaU EaU EaU EaU EaU EaU EaU 3B#OOO 3B#OOl 3B#OlO 3B#Oll 3B#lOO 3B#lOl 3B#110 3B#1l1 SMP Instruction SMPINSTR: IMMEDVAL: DEF DEF Field Formats 5VB#OOOOO. The look-up tables are CIRCUIT CELLAR" www.andthesecond definition defines the second 36 bits mapped to Ulli nst_mRam_meml1. To use this utility. Unfortunately. The third line defines the first 36 bits of the RAM mapped to Ul/inst_Mram_meml.mif file into a . 3VB#OOO . The last two lines define the end of the bus block and address space definitions. and the interrupt generator.. address modes. It can also modify the configuration bits for a block RAM in an existing .DP Decoder f--------Display register Display controller AN3. this step is a manual process. which defines the constants for the SMP instructions.>. such as VHDL or Verilog source code. 16V%:H#OOOO 2VB#OO. branch conditions. I wrote another program that can convert a . 512 locations).def.. - r. 3VB#OOO. 3VB#OOO. the display register. The bit file is the existing . the I/O decoder." ~1 4 MDI 10DI 10DO lORD MWAIT 10WR 10ADDR Xilinx XC3S200 FPGA • Spartan-3 starter kitbo ard • ~ ~ A-G. The first line defines the address space for the control store mapped to a RAM36 (36-bit-wide block RAM device) as starting at hex o and ending at hex IFF (i.bit file created by ISE.. Use the following command from the command line to modify the existing .ANO I I I Quad seven-segment display ~ Figure 1-This is a block diagram of the SMP demonstration application that includes an SMP. 128 x 16 ROM. The bottom of the listing shows two defined mlcroword formats: SMPI NSTR and I MMEDVAL.. the display controller. Listing 4 shows the . data2mem -bd <mem file> -bm <block RAM memory map file> -bt <bit file> -0 b <new bit fil e> The mem file is the file created by mi f2mem. The second "programming" of the VHDL from the microcode involves defining the entries of the instruction register map multiplexer look-up tables..bmm file for the SMP. the switch register.Clock Reset I I I I I I I I I I I I I I r----------------------------------------·.bit file: Listing 5-An excerpt from SMPASM. that can convert various binary formats into other formats. rDSMP CLOCK RESET '-- Interrupt generator .e. The block RAM map file describes which logical RAMs correspond with which physical RAMs. and registers.clrcultceliar.. 128 x 16 RAM.bit file. ~VO 128x 16 RAM DO ADDR WE DI L 128x16ROM DO ADDR I MRD MWR MDO Memory decoder i MADDR r - ~ INT - Switch register Slide switches I I I I I I I L. the memory decoder.

LIND REG. REGREG" RDEST. LREGIND.vhd file. VAL SMPINSTR ILD. but actually I had been testing the components all along. INDREG" RDEST. INDIND" RDEST. The address can be found on the last line of the micro-instruction. Two Boards Two Layers Two Masks One Legend Unmasked boards ship next day! Complete A to Z Guide to Performing A Patent SeIU'Clh www.RN: RDEST. REGIND" RDEST. I tested a stand-alone SMP using simulation. VAL ILD.~ -~ '0 0'1 ia' ~ www. The post-operation entry points are designated: LREG and LIND. RSRC TESTING & VERIFYING At this point.defined in the IR_Map_Mux. RSRC I LD. I verified that the SMP LD.midwestpatentservices. The instruction entry points all have the form Ldnstruction mnemonic>. The pre-operation entry points are designated: LREGREG. which does not define an actual instruction. but the values for the tables are defined in smp_const. and I started to test the SMP.RI: RDEST. RSRC ILD.com MIDWEST PATENT SERVICES info@midwestpatentservices. Search the Assembly phase list file and find each of the labels for the entry points.NI: MACRO RDEST. LINDIND.com I.vhd.circuitcellar. REGIMM" VAL RDEST. INDIMM" IMMEDVAL VAL ENDM 16V%:H#OOOO RDEST.com_j www.NN: RDEST.apcircuits. listing 6-An example of the macros used to define the load (LO) Instruction for all of the possible address modes Load Register Instruction LD <dest>..NR: RDEST. LINDIMM. all of the pieces were in place. Designed a Brand New Device? Learn to search online databases to see if your device is cutting edge and may be eligible for a patent by using this new instructional DVD! $9.RR: MACRO SMPINSTR ENDM MACRO SMPINSTR ENDM MACRO SMPINSTR IMMEDVAL ENDM MACRO SMPINSTR ENDM MACRO SMPINSTR ENDM RDEST. which is the beginning of the main processing loop. In the sections titled Pre-Operation LUT. The value of inst_NOP is assigned the address of the location MAINLOOP. rather it is a place holder for undefined instructions. Instruction LUT. LD. The last constant definition in the Instruction LUT section is the value inst_NOP. The values that are assigned can be determined from the Assembly phase listing file. I was really verifying that the SMP microcode implemented the programmer's model of the SMP. and LINDIOP. RSRC LD. RSRC LD. RSRC ILD. LREGIOP..com CIRCUIT CELLAR" 51 . <src> LD.95 each! As low as. and PostOperation LUT are the constant definitions that define the jump points for each of the maps. I say that I "started" testing. LREGIMM. RSRC ILD. To do this. RSRC LD.

The interrupt generator generates an interrupt every 500 ms. Therefore. R2. I LDIV.com fetched instructions and operands correctly. The features I used on this board were eight slider switches. I chose the Xilinx Spartan-3 Starter Kit board because the available I/O devices were simple yet sufficient to the task. Listing 5 is an excerpt from SMPASM. the switch register. and registers.NI CJMP. and the interrupt generator.H#FFFF = O? Flag Set? If true jump to INCRDISP else jump to MAINLOOP Disable interrupts Clear interrupt flag Increment counter Read the Switch Register Add the value to counter Output resultant to Display Register Enable interrupts Continue looping EQU EQU EQU H#OOIO H#0020 H#0030 Display Register Switch Regi ster Interrupt Generator R2. a 128 x 16 RAM. address modes. H#FFFF R3. These formats are used in macros that define the values for CIRCUIT CELLAR" www.RI LD.RI LD. To implement the program. generates the display register write signal. The goal of the SMP software was to demonstrate a few of the SMP's features. RI.RI RET! R2. the address modes. . However. the display controller. and translates the hex digit into the seven-segment values. H#FFFF INCRDISP. would be more satisfying. selects the corresponding hex digit from the display register. RI EI JMP. and access to I/O devices. and that every instruction worked correctly. RO. I felt that a demonstration in hardware. My goal in the demonstration was to show that the SMP is a functional processor. The primary requirements were to test instruction execution.I DI LD. H#OOOO H#FFFF H#FF80 H#OOOO Initialize Stack Pointer Point interrupt vector to ISR Initialize counter to zero Initialize RI to H#FFFF Initialize R2 pointer to H#FF80 Clear memory location H#FF80 (interrupt flag) Enable interrupts Does (R2) .RR OUT. the I/O decoder. even a simple application. that the SMP responded to interrupts correctly. the display register. INTGEN Set interrupt flag Read interrupt generator (clear interrupt) Return from interrupt Figure 1 shows the SMP demonstration application. The interrupt is cleared when the SMP reads the interrupt generator register. RI LD. I LD. a 128 x 16 ROM. two microword formats are defined: SMP I NSTR and I MMEDVAL. R2. generates the interrupt generator read signal. the I/O decoder selects whether the output of the switch register or the display register is output to the SMP 10DI input.def. but at the same time not to get caught up in an involved hardware and software project. but this time for assembling SMP instructions. Likewise. ZERO MAINLOOP R2. and generates the IOWAIT signal. one push button switch. branch conditions. It consists of an SMP.NI IN.Listing-The Assembly languageprogram 7 DISPREG: SWREG: INTGEN: ORG H#OOOO START: LDSP.circuitcellar. The memory decoder selects whether the RAM or ROM output is directed to the SMP MDI input. and a quad seven-segment LED display.RI ADD. interrupt response. RO.I H#FFFF ISR RO. the memory decoder. I used WinTIM again.NI EI MAl NLOOP: CMP. At the bottom. and generates the memory wait (MWAIT) signal. RO RI. generates the RAM write signal. The display controller scans the four seven-segment digits. H#OOOO SWREG RI DISPREG INCRDISP: MAINLOOP ORG H#0070 ISR: LD.I JMP. which defines the constants for the SMP instructions. R IN.NI INC. I wanted the demonstration to use simple hardware and software.

adding 8-bit operations. <destination operandmode> <source operand mode> The source and destination operand modes are: register direct (R). The interrupt flag is set by the interrupt routine. Two operand instructions will have both the destination operand and source operand modes. single operand instructions will have either the destination operand or source operand mode. and Assembly code. The program consists of a processing loop that loops back to the top of the loop (MAINLOOP) when the interrupt flag is not set. The input (I N) instruction uses the source operand as an I/O address. adds it to the counter.clrcultcellar. such www. Certainly the SMP is not as complex as the Data General MV8000. but both were implemented with microprogramming. which responds to interrupts generated by the interrupt generator. "Building Microprogrammed Machines with FPGAs. microcode. as adding additional instructions. INC RD I S P increments a counter. and streamlining its operation. Whether or not I use the SMP in a future application. consider that the demonstration program is running on completely reconfigurable hardware programmed from VHDL. otherwise. The net result of this effort is a quad seven-segment display that increments every half second.com CIRCUIT CELLAR" . and it was exhilarating to watch the SMP fetch and execute its first instruction. I just wanted to design my own processor. While this may not sound impressive. The format for all opcodes is: <instruction mnemonic>. Listing 7 shows the actual Assembly language program. I started my 2009 Circuit Cellar article. Listing 6 shows an example of the macros used to define the load (LD) instruction for all of the possible address modes. what am I going to do with it? There is certainly a lot I could do to improve the SMP. I did not design the SMP with a particular application in mind. and the output (OUT) instruction uses the destination operand as an I/O address. I now have all of the tools I need to build microprogrammed machines for various applications.each instruction and address mode. and writes the result to the display register. In this series. It certainly was fun working out the architecture and implementing the design. and immediate (I). I attempted to show how microprogramming can be used DOWNLOAD our free CAD software DESIGN your two or four layer PC board SEND us your design with just a click RECEIVE top quality boards in just days THE SOUL OF THE SMP Now that I have a working custom-made processor. it falls through to the increment display code. reads the value of the switch register. Now I can say that I actually created a new processor. The real value of this project is the experience I gained by developing a nontrivial application on an FPGA using microprogramming." by talking about Tracy Kidder's book The Soul of a New Machine. and a few instructions will have neither. Photo 1 shows the target board with the demonstration program running. register indirect (N).

Inc. Sure. J. you'll enjoy the thrill and challenge of manipulating dozens or hundreds of control signals in a complex digital system to bring it alive.ti. along with flexible.and CMOS using discrete logic (SSVMSVL5WL5I).circuitcellar.com ISE Software and Spartan-3 Starter Kit Xilinx. Using the SMP architecture and a change of microcode. Thomas has implemented designs with ECL. I feel microprogramming can be a useful addition to a digital designer's toolkit.com/support/documentation/sw_manuals/ xilinx11/data2mem. Xilinx. 54 ~ Visit www. Hamblen. 1999.C::==::::lto build real machines. but if you're like me. http://users. programmable logic (PALs.xilinx. He graduated from the University of Delaware with Bachelor's degrees in Electrical Engineering and Physics. albeit just the basics. Intel case in 1989. edu/ -hamblen/book/wintim. microprogramming can be difficult. www." The Georgia Institute of Technology. in its heyday.circuitcellar.gatech. TTL.com) is a registered profes- sional engineer who has worked for the Department of Defense for the last 31 years. and television. He has worked on numerous high-speed digital designs SOURCES TIM Meta-assembler Texas Instruments.. and microprocessors. Bitsavers. and systems." UG658. PROJECT FILES To download the code. "Introduction to WinTIM. I could just as easily build a special-purpose processor that runs completely on microcode. Microprogramming provides unprecedented control over complex digital systems. Seminar. But microprogramming. using a processor as an example. Inc. Just ask Judge William Gray who presided over the NEC v. and liquid crystal displays will be showcased by the world's most prominent technology and business leaders.xilinx. at least in some small measure.com/ pub/Circuit_Cellar/2011/250.sid2011_org for more event iniormstion. OLED. 2009.com DISPLAY WEEK 5 The future of display technology will be unveiled in Los Angeles at the SID 2011 International Symposium. LOS ANGELES MAY 1 5 . Take a peek behind tile curtain to see what technologies you'll be using in the very near future at Display Week 2011.com . "Data2MEM User Guide. boards.org/bitsavers. touch interfaces. microprogram sequencers. RESOURCES AMD Datasheets and Am2900 Bit-slice course notes. but it is not a skill that's beyond the abilities of mortal engineers.20 2011 CIRCUIT CELLAR" www. Thomas later received Master's degrees in Electrical Engineering and Applied Physics from The Johns Hopkins University. and FPGAs).ece. was just as commonly used to build special processing systems. go to ftp://ftp. iii of components. Major advances in 3D. and Exhibition.org. www. accomplished my goal. I www. I www.computer-refuge. e-Paper. I hope that I have.pdf. You also understand how CPUs work. You now know how to implement microprogrammed machines in programmable logic. ~I o -. complex PLDs. Thomas Mitchell (thmitche@gmail.

DELIVEREDSTRAIGHT TO YOU.com today! CIRCUIT CELLAR® .It's not about where you read. 12C/day Use the enclosed subscription card or sign-up at CC-Access. it's about WHAT you're reading. Innovative Project Designs! Superior solutions! Hot products! GET IT NOW.

but it also has some interesting features that you'd have a hard time finding on a surplus oscilloscope from the 1970s.com . built with readily available parts. connected via JP9. with only a few leftover bits requiring mechanical switches. provides a highinput impedance buffer to the input divider. with the distinct advantage of having all the code and hardware designs available for improvement or modification. I use a Microchip Technology MCP6S21 PCA (ICl) to adjust the gain of the input stage. They typically have sampling rates in the range of 1 to 10 mega-samples per second (MSPS) and have either a small monochrome graphics LCD or use a USB connection and a PC for the display. I built a compact oscilloscope. The PCA is controlled by a three-wire SPI. in conjunction with ADC input pins. In Spectrum Analyzer mode. All of the parts for the oscilloscope cost me about $50 (see Photo 1). has a limited bandwidth. I implemented as many functions as were practical in software. HARDWARE & CIRCUITRY The input stage is shown in Figure 2. it acts as a basic oscilloscope with a sampling rate up to 750 ksps. I was inspired both by a Circuit Cellar design challenge and by the demise of my old analog Tektronix oscilloscope. IC2A. The first op-amp. The PCA's output is sampled by the microcontroller's internal ADC and then processed and displayed on a monochrome 128 x 64 pixel display. The various features are controlled by several potentiometers.to 5-V input range of both the PCA and ADC. A Texas Instruments TLV2374 quad op-amp (IC2A-D) is used to buffer and shift the level of the signal. IC2C provides a low-impedance reference voltage of half the supply voltage (nominally 5 V). I call my design the "Scopey II.clrcultceliar. There's ample evidence for this. I intended for my design to be comparable to such scopes. The oscilloscope's status is displayed onscreen along with other Photo I-A analyzer fully functioning Scopey II OSCilloscope and spectrum 56 CIRCUIT CELLAR" - www. A BNC connector is attached via JPl. a 256-point FFT is performed to obtain the spectrum of an input signal. In Oscilloscope mode. A useful bits of information like the waveform's RMS value and the frequency bin of the largest peak of the FFT output. Just look at the numerous amateur oscilloscopes on the market. as an inexpensive alternative to rotary encoders or switches. I also wanted the hardware to be simple so I could later integrate it into other projects where an embedded oscilloscope or spectrum analyzer-type function is useful. The signal under examination can be DC-coupled to the input or AC-coupled through a capacitor using a toggle switch. on the front panel. It is then attenuated by a resistor divider with an approximately 1:8 ratio. The finished design." Every electronics engineer needs an oscilloscope.~RIIflt=================:::::J ~ ~ by Jaime Garnica (USA) Testi ng Platform Construct a Custom Scope The Scopey II is a handy oscilloscope and spectrum analyzer. and has eight THE SCOPEY II DESIGN The design is fairly straightforward (see Figure 1). A typical BNC connector leads to a voltage divider followed by a programmable gain amplifier (PCA). and much of what was left is under the control of a Microchip Technology dsPIC30F4011 microcontroller. while back. IC2A uses the output of IC2C to shift the input signal up 2.5 V so the input to the PCA and then to the ADC is centered in the 0.

An antialiasing filter on the input is noticeably absent from this design. a few diodes. I rearranged some connections for the current version so it could be easily built on a single-sided board produced using the toner transfer method. On the 1/8 input gain. The PGA's output is fed into an analog input pin (AN3 through JP1) and sampled at a few user-selectable rates (up to 750 ksps). and display.SPI Input attenuator Programmable gain amplifier Potentiometers Graphics display Figure 1-The design features a PGA. and displayed in a suitable format. the samples are scaled. The heart of the functionality of this device is the dsPIC30F4011's built-in ADC. In Oscilloscope mode. In FFT mode. Based on their positions. potentiometers. only one is scanned. and then begins storing samples until the 512 sample buffer is full. you will have enough time for 39 instructions to read the first sample before it is overwritten-a virtual eternity. Figure 3 depicts the dsPIC30F4011based circuitry. In my case.com CIRCUIT CELLAR" 57 . The original version of this design was built on a pad-per-hole protoboard. Several registers must be configured correctly for the ADC to function properly. I. The power supply consists of a transformer. as well as how external reference pins and analog inputs must be connected internally to the sample-and-hold (S/H) amplifiers. the samples are then scaled appropriately based on the gain settings and displayed. Each potentiometer has its wiper connected to an analog pin. AN3. Microchip has a nice C compiler for the dsPIC microcontrollers. ~ if ~ www. using the potentiometers on the front panel. a readily available 128 x 64 monochrome display based on the KS0107/0108 driver/controller combination. as well as the trigger level and slope. In either mode. however. the ADC can go about its business for 16 samples before issuing an interrupt. The functions for setting up and running the scope's functionality are in the oscope. A PGA is used to adjust the overall gain. sets up the ADC for that rate. arranged in memory. It calls oscGetVdi V and oscGetTdi V. The ADCSSL register enables you to select which analog input pins will be scanned during conversion. The magnitude is then found. Instead of interrupting every time a sample is ready. six of which I used that are powers of two. but I left it off so you can view firsthand the effects of undersampling (see Photo 2). The user can select the sampling rate. and the other terminals connected to power and ground through JP5. which read the potentiometers. it reads its potentiometers. Both S/H amplifiers are connected to the ~ ~ I . the vertical resolution of 64 pixels results in about 20 mY/pixel sensitivity. The dsPIC30F4011's datasheet indicates how to configure the ADC for proper operation at various sampling rates. All of the registers for the ADC are explained in section 17 of the dsPIC30F family reference manual. it moves to either the Oscilloscope mode or FFT/Spectrum Analyzer mode. It has a maximum sampling rate of 750 ksps. which is posted on the Circuit Cellar FTP site. At an execution speed of about 30 MIPS. and configure the ADC. A whopping 14 digital I/O pins are used to control the display. scaled. and transformed to their frequency domain counterparts. You can set the total input gain to 1/8. possible gain settings. the maximum input that will not clip is close to 40 V pp' When set at the highest gain setting.~ o 10k Figure 2-lnput stage of the Scopey II. SOFTWARE I wrote the software entirely in Assembly. When the scope starts up. 1/4. The function oscSampl e is used by both the oscilloscope and the FFT functions. the software retrieves the desired sampling rate. os c GetT d i V configures the ADC using several different functions based on the speed of conversion requested. The first thing to remember is to configure the pin you use as the analog input as an analog pin in the ADPCFG register. or 4. The ADCHS register determines which analog pins are connect~:d t~o each of the two S/H amplifiers. You can easily add one if necessary. but I wanted the challenge (and fun) of working with pure Assembly. The micro controller's ADC buffer is a great feature. 2.s file. and 7805 and 7905 voltage regulators arranged as usual.clrcultcellar. set the gain of the PGA. microcontroller. 1/2. collects samples until the desired trigger is seen.

The errata indicates the maximum sampling rate is 750 ksps. For an oscilloscope. are functions to display 32 x 32 pixel icons. the ADC is set to wait for the entire 16-word buffer to be full before issuing an interrupt. direct access to individual pixels-are quite a bit more expensive. Also included in the software. but that would be much less fun. Also. and the entire block must be written back. pixels are arranged in vertical lines of eight. As you may know.~ 4 5 6 7 8 9 LeOl0 10 LCD11 11 LCD1212 LCD1313 LCD1414 LCD1515 16 17 18 PWMl H/REl PWM2LJRE2 PWM3L'RE4 PWM3HIRE5 37 36 34 33 PWM2H/RE3 35 LCD15 Le06 LCD? Le08 LCD9 Leos FLTA/INTO/RE6 15 RC131CN11T2CKIU lATXISOSCllEMUDl 16 RC14ICNOfT1CKIU1ARX/SOSCOiEMUCl RBOIANOICN2/EMUD3IVR+ 17 it ~ LCD14 ~ 14 RB1/ANliCN3iEMUC3/vR· t+3 OSC2/CLKOIRC15 OSC1/CLKI RB21AN21CN41SS1 RB3iAN3/CN51INDX RB4!AN4/CN6fIC7/QEA RB5IAN5ICN71IC8/QEB i 6 7 8 9 RDOiINTliIClI0Cl/EMUC2 RDlfINT2fIC2/0C2/EMUD2 RD2!OC3 RD3iOC4 RB6iAN6iOCFA RB7/AN7 RBa/ANa C1RX/RFO C1TXIRF1 IIIII +5V LCD10 LCD11 LCD13 LCD12 1 2 3 4 5 JP5 I ~~ R14 10 r----to"i:Q_ 19f-o 10 30 29 __!_!!_ _____!_ p'" -=:=- VPPIMGLR PGC!EMUCfSDll!SDA/U 1 RX/RF2 26 25 27 28 24 . but the start time of each conversion is spaced out by Timer3 to achieve the desired sampling rate. But for the FFT. optimized specifically for the dsPICs. but not used in this project. Ah yes. I would love to say I wrote the actual code that performs the FFT myself. the set will only drive a 64 x 64 screen. This is set in the SSRC bits of the ADCON 1 register. arranged in rows. and. if you want text. You have to do a little prep work in order to get things arranged nicely so that Microchip's software will give you the results we seek. In order to change one pixel. is the software behind the FFT function. but I don't have to because Microchip is kind enough to provide some useful DSP-type math-intensive functions. you'll have to code your own font and display functions or borrow them from someone else. I need the data in signed fractional format so it can function properly with the fixedpoint math routines from Microchip. of course. serial instead of parallel interfaces. which does not require both S/R amplifiers. having both connected has no effect on the operation.5V PGDIEMUDISD01/SCLlU1TXIRF3 CN171U2RXIRF4 CN 18fU2TX/RF5 SCK11RF6 VSS VSS VSS DSPIC30F4011 R12 10k . The SMPI bits in the ADCON2 register enable you to set the number of samples the ADC collects before an interrupt. I used the ADC interrupt to implement triggering as well as the retrieval of samples from the ADC buffers. AN3. In this design. To achieve this.5V ~"'? +5V----R~ -f~ . the software is essentially mapping a sample from the ADC to one pixel on the screen. I used two different techniques to achieve the desired sampling rates. where various sources can be programmed as the signal to end sampling and begin conversion. As soon as one conversion is complete. Next. You can CIRCUIT CELLAR" www. At all slower speeds. I want the ADC's output to simply be an integer. because the datasheet specifies the maximum sampling rate at 1 MSPS.com . the input to the FFT function is 256 discrete points. One interesting aspect of the software is the display driver. but in this case. the individual pixel must be changed. First. so that the entire 128 x 64 screen is accessed as two halves. each conversion is done in the same amount of time as at 750 ksps. the function that turns one pixel on or off given just its coordinates.5V -=I=- ~ Figure 3-The dsPIC30F4011 connects to the input stage via JPL occurred. the KS0107/0108 does not have a character generator. A subtle but interesting problem with using the FFT to obtain the spectrum of a signal is called spectral leakage. by far. the next starts and the length of the conversion determines the sampling rate. For the oscilloscope's functionality. So.3' ~~ ret VDD VDD VDD AVDD -+ R2 10 ~'1~ 38 +rR13 ~H o~ LCD17 LeD16 ~~ PWM1L'REO LCD4 'I 10k Il. A much simpler option is to use a display with a different controller. In this design. the stack of eight that it is a part of must be read. With few exceptions. the samples are compared to the trigger value (level and slope) until the trigger is found. The most interesting bit of software. The heart of the display software is. the ADC alone controls the sampling rate. During the interrupt. with eight rows on the screen. displays based on the KSOl07/0108 cost virtually nothing on surplus sites. This is especially important because using the wrong format for the math routines results in garbage output. Some issues arise. while better controllers- with built-in character generators. I wrote a set of functions for a full complement of character displaylike 5 x 8 characters. If a trigger has not occurred. This is accounted for at the end of oscGetTdi v by setting the FORM bits in ADCONl. both S/R amplifiers must be connected to one input.5V R1 10 -+ +5V -r 0.clrcultceliar. the software proceeds in a more or less predictable fashion. gasp.C:==:::::::Isame analog input. the KSOI07/0108 combo has some idiosyncrasies that make writing software for it a little strange. then the 16 samples are stored. There are also several functions for drawing or erasing lines used to create eye-pleasing borders around the various data areas on the screen. if a trigger has already . For 750 ksps.

comlusa • Phone 860-875-2199 ~ektor .com where the three latest editions of Elektor magazine are available in PDF files (i. THER EVEN MOR TO DISCOVER.NOW.com also supplies the most extensive Elektor search engine found on the web (all issues since 1998). With a simple click you download the complete edition (front to back!) or any single article.elektor-plus-usa. the current issue and the two preceding ones). you have permanent access to the three latest editions of the magazine in PDF format. The upgraded Elektor PLUS subscription! G> G> G> G> G> G> G> All 11 issues including the Summer Circuits edition Included in your PLUS subscription: Annual DVD 2011 50% cheaper than normal retail price Up to 40% discount on selected Elektor products Elektor is delivered to your doorstep every month Read your copy before everyone else NEW: On your personalized Elektor PLUS website. www. as well as to a fast Elektor search engine! Your Elektor PLUS subscription gives you exclusive access to the new website www. Subscribe now www.elektor-plus-usa.e.eleldor.

4 in the correct frequency bin. the limited screen real estate and the apply the window. Given computed and stored in a table. wl is a pointer to the last through a rectangular window. There are plenty In this simple case of one sinusoidal stored near the beginning are not of window functions out there. though. These values were prewill fit nicely into your samples. To are dealing with a periodic signal. the imaginary K LJn=o to say that this window shape is not part of each value is set to zero. you can take the one pixel wide.-------. Examining execution of oscFFTarrangeStart in have. as the inputs and outputs of the FFT are comfK = kfs/N.-------.. H there are other fretN range from 0 to l=-before being sent 96 of which the display is configured a' quencies. At N-l jmnT .2 and be displayed as one line. The samstrange will happen. which is function that is one while the samples is the DFT of a sinusoid of frequency located in the same buffer to which wl are collected and zero elsewhere. FFT is done in place. Before the ples you get directly from the ADC thing is spectral leakage. which the window will be applied. starting from the last addresspurposes and others.1. nallooks like. then the actually call the Microchip DSP shape is given by: sum is N for that frequency and zero functions. Here to the last sample value. for your stored. they won't "line up" CIRCUIT CELLAR" www.------. mathematically. o frequencies.-------n quencies that fit an entire The samples also need to be 1..8 500 ksps will result in all the ues have a place to be once 0. Saminserted between the real valpling a 125-kHz sine wave at ues so that the complex val0. if we have a signal. the data is in the wrong which is 256 in this case. The values shows a comparison between the Another way to think of the problem is are complex. oscope. as you would expect. Since the samH we use one or some combination of these frequencies. This second way of lookstill give the "correct" answer even if Assuming the ADC is configured to ing at the problem suggests one soluit is not what we really want. giving 128 frequency bins. wl is a pointer to the data to be transFor any other frequency (i. Intuproduce values in the correct format. w3 and w2 point to the coeffiwhere N is the number of samples to In other words. it's done. particularly conducive to what we are Then the sample is multiplied by the trying to accomplish. been passed the discrete Fourier transform (DFTI. and wO is a pointer the product of the original signal and a ments. so Microchip kindly proshape of a rectangular window and a vides _Squa reMagnitudeComp 1 ex so that only those certain frequencies fk Hann window. The next frequency. the sum will be nonzero for all frequencies.. OL-----~------~------~------~------~ pled signal is real. will look pretty much the same as the . the problem is evident. by using a differes in the buffer so that the values ent window function. formed. The 0. H you you can obtain the magnitude. They are the transform that the FFT implespace in the buffer. base 2 log of the length of the FFT. Figure 4--A comparison of a rectangular window and a Hann window the relative powers of each there is a problem. and n is an quencies that your otherwise trusty sigorder.. The interface to the FFT functions The math doesn't really care what we provided by Microchip is fairly of samples there will be discontinuities that do not reflect what the actual sigare trying to accomplish. cate that your signal has power at freAfter the FFT.com 60 . and if you repeat the chunk closest frequency bin is about 123 kHz. and once 0. on the screen.nT = implications of that.------. All the power will be at complex.s. one might guess something the first step is to insert the zero imagtion: modify the input so that the discontinuities are eliminated. window values from the table-which actual signal. 2. _FFTCompl exI P does a for all others.clrcultceliar. 0.5 number of periods into your rearranged a bit before being samples.5 plex numbers. itively. where wk = 2 1t fk: a lot of math. These frequencies are transformed. whose is one of the fk frequencies. not fkl. so it will straightforward when using Assembly. I are multiplied by their corresponding only consider the results for positive . and that strange inary part for each sample. correctly.. we see that if 00 overwritten. Figure 4 nal generator might disagree with. _Bi tReverseCompl ex is prointeger where 0 S n S n ..___ ~ .6 power of the signal appearing the data is transformed. but I input at a frequency 00. the transform will indicients needed to perform the FFT. w3 holds a pointer to the table 00. wO holds the that frequency. but it is sufficient oscFFTa r ra ngeSta rt. in-place FFT.e. perlog of the magnitude to reflect haps a 124-kHz sine wave.. vided to rearrange them. At oscFFTarrange you chose to use a Harm window. Using points... magnitude and then take the 50 100 150 200 250 Now. where 0 < k < N/2. The appearance of value from the Hann table and the spectrum can be improved. one can explore the full of values for the Hann window. the sampled values repeating your one chunk of samples symmetry of the output of an FFT. X (0) ) = ~ e e·JID.then identify a bunch of freto the FFT function. placeholdo 50 100 150 200 250 everything will look almost ers with zero value need to be exactly like we expect.

.

2010. or even an inquisitive sibling who still has that spark of amazement about the world around them.ti.com . In addition to playing around with microcontrollers. which requires a UV light source. Now you can build your own.com LCD·00710 Framed graphical LCD Sparkfun Electronics I www. Photo 4 shows the spectrum of a I-kHz square wave shown in Photo 5.microchip. In Electrical Engineering in 2007. and the photoresist or presensitized boards. Smith. Jaime enjoys the occasional Cocoa programming adventure. you will have a device for probing circuits and fiddling with knobs. as 32 pixels on the left are reserved for displaying settings and the frequency of the largest spectrum component. The component selection is not critical. TESTING AT THE BENCH I developed the Scopey II oscilloscope in order to indulge my own interests in test equipment and to add a useful tool to my workbench. I succeeded. SOURCES dsPIC30F4011 Microcontroller and MCP6S21 PGA Microchip Technology. typically from a laminator or clothing iron. Photo 3 shows a 58-kHz sine wave's spectrum. PROTOTYPE I constructed the original prototype on a pad-per-hole prototyping board using a combination of pointto-point wiring and wire-wrapping. this remarkable companion gives us the corrective lenses we need to see into the world of electronics. RESOURCES Microchip Technology. Upon completion. The values of the spectrum are not individually useful at this point. you can give it to a child. There is something Zen about test equipment. I www.com/pub/ Circuit_Cellar/2011/250. "dsPIC30F Family Reference Manual. you'll also have a compact platform around which you can build a host of intelligent monitoring projects. helping us accomplish that very task. sitting quietly at our benches is the humble oscilloscope. There is an additional philosophical satisfaction when I build something that I can reuse for future projects.sparkfun. Stanford University. the values are converted using the table log'Iab to base-lO log values. taken for granted. From telescopes and microscopes to gas chromatographs and particle accelerators. All the while. iii Jaime Garnica (jbgarnica@gmail. The product of my toiling is a three-IC device that can be easily constructed without much financial strain and would be useful for analyzing signals up to a few hundred kilohertz.S.clrcultceliar. we are always seeking ways to explore our reality. The previous FFT results are stored at old Wave and the new results are stored at newWave.com) earned a B. 2004. He is currently pursuing his Ph. I www.The square wave used for the spectrum in Photo 4 CIRCUIT CELLAR" • www. The toner is then transferred to the board using heat and pressure. go to ftp://ftp. one of which is glossy photo paper.com TLV2374 Precision amplifier Texas Instruments. grandchild. The prototype was built using 5 % resistors and gives satisfactory results.D. nephew. Inc. This method is a relatively fast and affordable alternative to photosensitive resist. The frequency of the square wave is the highest peak. Photo 4--The spectrum of a l-ktiz square wave. You can see the odd harmonics that compose the square wave." DS80169E.com Photo 5. they are mostly useful for the comparative magnitudes of the various frequency components. Inc. At oscFFTl ogi sh.) Of course. Often PROJECT FILES To download the code. The process involves using a laser J. Each point is scaled so that the largest peak goes to the top of the screen.Photo 3-The spectrum of a 58-kHz sine wave to show. uniquely human. urge to find ways to see what we cannot see. printer to print the mirrored artwork for the board on either commercially available transfer paper or one of several alternative materials. developer solution. I get a lot of satisfaction when I build something that is useful. Mathematics of the Discrete Fourier Transform (DFT) with Audio Applications Second Edition. niece. This design is not intended to be a precision instrument. And it satisfies a deeper. (And when you tire of this. scaled so that a full-scale value places its pixel at the top of the screen (0 being the top of the screen and 63 being the bottom). I made a later version with boards using the toner transfer method for resist on single-sided PCB material.circuitcellar.

NEW for 2011! Identify specific solutions to your most difficult sensing.I&I~ code to Register Now on Device! Mobile Yo. Sensors Expo brings together the largest and best-in-class showcase of sensing technologies attendees to evaluate and make informed decisions. [" til1 .\~~ TECHNOLOGY UPCRT_. This year's Conference Program includes more Technical Sessions in Tracks covering the topics that are most important to you and your business. and systems for Tuesday. June 7 9:00 AM . Hugh Kerr Biomechatronics Researcher ENERGY lR4.. detection and control-related challenges on the expo floor.10:00 AM Don't Miss these Expo Floor Highlights: Opening Keynote: Dr. including: • • • • MEMS Energy Harvesting Wireless Sensor Networking Novel Approaches to Measurement & Detection • Wireless Sensor Data • Mobile Sensing .The Only Industry Event in North America Exclusively Focused on Sensors and Sensor Integrated Systems! Find the Solutions to Your Sensors and Sensing Technology Challenges! Gain the knowledge you need from leading experts and peers in the sensors industry.NEW for 2011! • Cutting-Edge Technologies .1.

Hopefully. I learn. Go slowly. you can apply the language tools to your advantage. Don't worry.com. the language and compilers let you easily add graphics and keyboard libraries to your code. With all of the modern progress in system design. I am actually describing the design process you can use for your particular requirements. and you are not held back by trying to fit your THE PLAN I am designing a spring tester for my personal use. Writing C code is comparable to learning a foreign language: it just takes practice and time. Also look at the flowcharts and code presented in Circuit Cellar. covered C programming in many of my previous articles." They are difficult to design.] All are interesting projects. By this. It's become a strong point in all of the articles.] A while back Steve Ciarcia sent me a link to a product that plugged into a cigarette lighter in the car. I also believe that this trim language lets you focus on the design of the system. You will find that the more code you write the easier it becomes. If you followed along. I'll introduce other languages (Java and BASIC) and perhaps an RTOS or two to get the job done.com I AI . I read about a CNC-controlled cake decorator (good idea) and a flaming fireball controller for Guitar Hero. Also. You should be able to modify components from this description and CIRCUIT CELLAR" www. I design into a complicated language. The next step is to start building something. particularly if you have little or no interest in measuring springs. You can look up answers to your language questions on the 'Net. you will soon understand how this all unfolds. It would be interesting to know if any of them are making any money! A DOSE OF C You should be able to read and understand C code. but it's still informative to see that code. The C programming language is structured. All sorts of clever projects are available on the 'Net. It's time to design a project. every time I get to look at C code that someone else has written. Watch out for design requirements that describe the "perpetual motion machine. Writing C code is a bit more demanding than simply reading it. As we go about the design process. you should now have a sound foundation in the language. It probably isn't fair to make you read about that design. But let's start with a simple plan and get comfortable with the product design process. It comes in a basic set of rules and keywords. However. And because C is so universal and popular. and emitted a sound like a Ferrari or monster truck engine at that same speed. Keep your plans realistic. you can ask your associates. THE PRODUCT It would be great to say we are going to design the next blockbuster product. Just break the code down to the basic language operations. (I've seen some on hackaday. (I'm not so sure about that one. The C programming language was developed to design control systems for AT&T. This is one of C language's great features.) Recently. I mean you don't get graphics or keyboard routines as part of the language (as perhaps with Visual BASIC). You can include external libraries and even publish your own libraries. Follow these tips as you prepare to develop your next product. Perhaps it's not in a style that I want to adopt. (Great idea. It listened to the interference generated by the engine.LtSSONS~ROMrntmtNClltS Planning and Tools by George Martin (USA) Design Development (Part 1) You can read and write C code. your foundation in C will serve you well. determined the engine speed.clrcultceliar.

you recognize that I'm using selection of the CPU easier.add your own specific modules. although I once did a chorus of synFreescale's Kinetis. Most of the the display. An example might be calibrate this system." I am referring to both the software and hardware modules. interface electronics on a separate printed circuit board. The sooner you get facts on paper the sooner you will be able to spot problems and opportunities. to capture your thoughts. I suggest a new one game. a router. perform a go/no-go type of test. and measure leaf-type spring. calibrate the device. That makes the column. you need a PC ally. print the results of a measurement. or power over the Ethernet. You also need to consider price. gather statistical manufacturing data. At this point. that we can use to build our product. or Renesas's RX. This is especially true for stepper motor drive and signal conversion with the strain gauge. And. the room temperature. a ture to hold everything in place. a plug into a USB mechanical design and fabrication are connector. So. Circuit Cellar has run in past years this might be moving a lever that would be suitable to use in this compresses the spring. work with different spring rates. Not much value here. I started the design down on paper is always a good idea. I'll probably cover the PC in a saw. TASKS & SCHEDULE Before you can make a schedule. So. That's not my background. necessary to complete this project. It's a good program these or others of this class of CPU. repair policy. It's likely that the CPU demo boards do not have this level of interface. I will say some in the block diagram and more. (I omitted those connections ure the force on the spring. You also need force other input signals the user cannot gauges and calibration weights to directly affect. This diagram looks rather generic. with an evaluation board from the CPU manufacturer. THE TOOLS What tools are necessary for this Well. you need to identify what needs to be done. Some plug into the wall. At this point. if you would like to learn how to interface to an LCD or an SD card for file I/O. If you've been following my to $5 in volume. most of my systems look like to run the compiler and test and this and the devil is. before we come to shop for fabrication. This is only a list of functional requirements. you'll need to know how you're going to sell that product. you might label this activity as brainstorming. Let's take a look at what Figure 1 is all about. and have some effect on the products used in design challenges input signals. of course. but after you get a few designs under your belt. And a picThey all also have evaluation boards ture is certainly worth 1. save the results of a measurement. and a drill press. I'll also take suggestions for various interfaces and write about how I'd implement those designs. all have C compilers and cost less Figure 1 is a block diagram of the than $20 in low quantity and closer system. enter key strokes on the keyboard. but I suggest not. recall the results of a measurement. weight. We'll leave the sales side of the product design out of the discussion. These are high-power units with all chronized talking Big Birds for the of the peripherals that I've included New York Toy Show. You may want to wait until a prototype is built. such as Texas Instruments's Stellaris. update software. and much more. They toys are getting rather sophisticated. That's the easiFigure 1 shows a user who can see est part on the toolset. What would a customer like to have in this product? They likely want methods to measure the characteristics of a spring. let me know. Are you selling online or through a distributor? Price. you should be able to generate a datasheet. There is just too you'll have to contract with a machine much to cover. That is a lot more than we'll ever be able to cover in bimonthly columns in Circuit Cellar. warranty.024 words. by "modules. and a fixfor now. For the spring tester. I envisioned this product to consist and I added local storage and connecof a stepper motor and a lead screw to tions to a PC or the 'Net. Actudesign project? Well. If you are going to make a product to sell. size. compare the measurements of a spring to a standard. It's not a toy or a For the CPU. you say. let's get further along with You might need to prototype some the design. accuracy. you will see that you are actually laying down some valuable groundwork. I would caution you to develop a parts and manufacturing budget very early on if you're going to develop a product to sell. and I (or misusing) the Unified Modeling don't think you can go wrong with Language (UML). One of the blocks is named Interface you can build everything with a table to PC. in the details.) The PS could be a battery. But. or dedicated column. compress the spring and give a disThe power supply (PS) touches each placement value. There's a CPU. I find that putting thoughts debug the code. that point. and advertising campaigns are important factors to consider. that's why I'm the expert. Figure 1-System block diagram I think we can best categorize this design as an instrument. . Some of the spring tester. a load cell to measmodule.

Since I designed this for my own use. Just exactly what is a spring tester? Look it up on the 'Net and you'll find several examples (mostly for valve springs used in automobile engines). reads the force gauge. and comparing of all of the data. See you next time. data acquisition. Will your instrument have all of the I/O (keyboard. As the test mechanism takes out all of the slack. But what I might want to see is the spring rate between two points. This would look like a line passing through zero and the slope would be the spring rate.. Each spring has an installed length and a working length. and printer) to display all of the measured data and settings? I don't suggest presenting the data in list form. like UML. but I would have to be careful that the code is easily ported to a microprocessor-based standalone unit if the product is ever going to be sold as a standalone system. you won't measure the working spring rate. to think about the system design. WHERE ARE WE NOW? Well. We could o ~ then use the PC's display to see the data and the keyboard to ~ input all of the setup variables.rxmcu.With that datasheet you can compare it to other existing products and you can give it to prospective customers and get their input. Again. Inc.freescale. Inc. But I believe it's better to use higher-level tools. You could put a file system for a CF card in the system. and the displacement will be 1" to 2". Ignore absolute accuracy at this point. Ethernet. I plan to start looking for parts to implement the design.com Magic Draw No Magic. and then the unit to PC communication would be a required design step. and remote control systems. or move a memory card between the units? Then you have the saving. I had the option of going with a microcontroller that runs the stepper motor. and has a few simple buttons to open and close the mechanism. SYSTEM DESIGN I used to start coding at this point because I thought that was the fastest way to get to the real design issues. Then it's easy to move that card between the unit and the PC. Somewhere between these two end points lies our information. but it's complicated for the spring maker. At this point you've started up the spring-rate curve. These readings come in pairs and they are referenced or compared to the desired spring rate. Viewing hundreds of readings showing displacement and force would just be a waste of time. a budget. Now this type of display could be useful. You should either think about spring testing (and send me your comments). Inc. That's fine. I'm mainly interested in small coil springs.com/USA TI Stellaris Texas Instruments. You also spent some time questioning the operation of the unit and the partitioning of the design between a standalone approach and a unit that requires a PC to operate. and then we could just scroll through the list to select the spring we are going to test. I encourage you to take these steps. At this point it's time to write up a list of parts.com ~ 66 CIRCUIT CELLAR" www. the force measured goes from zero (or perhaps a level better described as noise) to some nonzero reading. As you can see. But how would we enter these length numbers? I could see the code might have a database of standard spring part numbers internally.net) began his career in the aero- space industry in 1969. I www. I'll also gather data on the CPU reference designs I'm recommending. Plus.. He Is also a nationally ranked revolver shooter. iii George Martin (gmm50@att. This is a good solution. USB. he set out on his own and co-founded a design and manufacturing firm (www. and at the end of compression you get into what is known as coil bind.. SOURCES Freescale Kinetis Freescale Semiconductor. Envision loading a spring to be tested into a fixture and then running the stepper motor that moves the lead screw to compress the spring. This is where the coils are actually touching each other and the force shoots up. I www.nomagic.com RX Family Renesas Electronics Corp. graphical input and output. I knew that option would get me closer to a working unit.clrcultceliar. Also you can begin to think about how you're going to sell your product. let's just move all of the data over to a Pc. That's probably . George is a charter member of the Ciarcia Design Works Team. The data you need to gather is displacement versus force. early design choices can have a great impact on the final design. This is called the spring rate.embedded-designer. This tester is a device that measures and reports spring displacement versus force. or think about your own product and map out the steps I described. but what if I wanted to zoom in or magnify a region of the display? How would I do that? Well. I www. if How are you going to communicate with the stepper motor and force gauge? Should you use serial port. you've had a first pass at the UML diagram of the main sections of the design.com . The force will be 10 to 25 lb. These points would be the resting length and the compressed length.ti. I www. and a task schedule.. but could you turn this into a product? Would it ~ be too complicated for a spring maker to use? I think so. At the beginning of compression. After five years at a real job. fine for me. recalling. this is sufficient for my use. Start the project by considering only coil springs in compression. His designs typically include servo-motion control. He is currently working on a mobile communications system that announces highway Information. display. you know the features the product should include.com). But then how did I set up those standard springs? Another output might be a graphics-type display that plots the spring data readings as we are running the test. This approach would also commit me to save and graph the data on a Pc. but it requires a PC to be part of the instrument.

icbank. Auto MO.IlMDlX . . LAN·:cabte :.MoN'\qring & Accessory Etc : PoWer adaptel\9V lSOOmA..Nl~5.halrDUplex) : ~8S'J~.Qffer TCP/IiPCommL..~.RS-485 to Ethernet Converter Povvaful feature· .lnicatiqn to Devices with RS485 IfF Specification Network 5etlal : :rep.I~. _._ www. Ethemet...tloi1.~oob. ~1-nt:U-.LED: PoweG Networ.IPV4. mMP. l'erm!n~1blodi:f/F1YJje COiIlNlprogra'm : 11' Addre.200.l)ata .mnsmlt.Pro'tocolconverter R54BS beo/ieen Ethernet. PPPoE.k. 110/100 Base-TXAuto oegollatlon (fUIW. 1. Ulll~ DI:IC:p.ss' .com .-DIP SWrtd1(4as Baud'Ra:te setting) . PQit ~ttln9f serlal dJrKllUonconfi~ ~ra. AR~ tGMP. 48S-POlt transrni5S!on signal I[bank A.

or by the packet via software. Each of the 8 data bits. checksums.C. today we employ various means of examining its integrity. but it has the advantage of not requiring a huge accumulator. the total of all the bytes in the string (or block) is ANDed with OxFF (limited) to 8 bits wide. if the data string is large. As most data is exchanged via some sort of serial link. you weren't around B. it is often the integrity of the data itself that is of most concern. or larger checksum values. strings or blocks of data often use byte. It's a requirement.clrcultceliar. as an indication that the data was received without error. Error checking matters. You can think of a UART using parity as the equivalent of a I-bit R checksum. the same techniques can be used by your application to protect its data. either a I or a 0. This might be a byte at a time in hardware. the actual data is often broken into pieces. which may be required when using the first approach. The most common approach is to use a checksum or a cyclic redundancy check (CRC). When sending data within a network. I 6S+-- ~I emember when we used highly condensed polycyclic aromatic hydrocarbon (bitumen) for its sealing properties? Oh. Whereas the UART's parity spans a single byte. While tampering may be on the minds of many people. word. as between UARTs. Each wrapper contains its own technique to ensure packet integrity.{ROM Tilt RtNCII by Jeff Bachiochi (USA) Error Checking Data security isn't a perk.? Maybe you remember using sealing wax to protect your document. A UART can automatically append an extra parity bit to each byte it transfers. and the cyclic redundancy check. you no longer wear that signet ring? Do you have a PIN? Most people today have more than one. While any rollover of a checksum's width decreases its effectiveness in indicating a data CIRCUIT CELLAR" www. is added together: Byte = ObOOllOOOI 0+0+1+1+0+0+0+1=3 This total AND I equals the parity of the byte: 3 = Obll Ob11 AND ObOI = ObOI An alternate approach to this is to XOR each bit value with the previous result: Byte = Ob00110001 (result initialized to 0) o XOR o XOR o XOR o XOR o XOR result (0) = 0 result (0) = 0 1 XOR result (0) = 1 1 XOR result (1) = 0 result (0) = 0 result (0) = 0 result (0) = 0 1 XOR result (0) = 1 The second approach might not seem any simpler. An application will have little control over packets and how they employ packet integrity. Each piece is wrapped by the open systems interconnection (OSI) model so that its correct reception can be ensured and the piece can be reassembled with others back into the original data.com . This article covers the topics of error checking. A single bit error (or at least an odd number of bit errors) can produce an error flag. When using a byte checksum. A word checksum can handle more bytes before being limited by its I6-bit width. Checksums can be pretty simple to use. Oh. However.

) There are multiple standard divisors for 16-bit CRCs. implementing a data integrity method can result in identifying an integrity issue. USB. the divisors are given as polynomials. Bluetooth. I'll use the CRC-16 standard as the (polynomial) divisor. The cause is not the focus of the discussion. Let's take a look at dividing the single byte Ox31 by Ox18005. any odd number bit error. (The MSBit is in red. allowing the remaining 16 bits to be held in a word register. That's "odds" as in. it is fairly easy to see a bit error in a string of text. Instead of using some potentially humongous divide routine.) The MSBit of the dividend determines whether we subtract the polynomial (if it's a "1") or O. To accomplish this. If we consider the data as the dividend. we need to keep things in manageable chunks. CRCs can determine a singlebit error. review what happens to the 17th bit.com CIRCUIT CELLAR" Note that the divisor (polynomial) is 17 bits long. many others. Modbus. If we start by shifting the data (dividend) left into a 16-bit register 17 times." then a (16-bit) zero is XORed with the dividend register. After repeating the function eight times (once for each bit of original data).28. as the result is equal to the . (If you're a math enthusiast. what determines what the divisor is? A divisor is dependent on the width of the CRC and the polynomial chosen for its effectiveness based on probable error types. The X. The simplicity of checksums makes it ideal for basic error checking. the final result (remainder) is the CRC value for the data. which has the same checksum as: 241 + 32 = 273. If errors occur in the same bits of two different bytes. M-Bus Cordless telephones Table 1-Here are a number of popular 16-bit CRC forms error. also known as CRC-16 and CRC-16-ANSI X." then the (16-bit) polynomial is XORed with the dividend register. or even 64 bits). many others. as the design and adoption of these transmission systems give us confidence in their low inherent error rates.25. known as CRC-CCm DNP. I've got a couple of projects coming up that use a CRC instead of a checksum as a method of error detection. You may have noted that each of these is actually 17 bits in width. Because we are dealing with base-2 or binary math. rather than just its own data width. But. Ox31 becomes Ox310000 = ObOO 11000 10000000000000000 Ox18005 = Obll000000000000l0l 0010001 (Quotient) 110000000000000000101 I 001100010000000000000000 (Dividend) (divisor) 00000000000000000 01100010000000000 00000000000000000 11000100000000000 11000000000000101 00001000000001010 00000000000000000 00010000000010100 00000000000000000 00100000000101000 00000000000000000 01000000001010000 00000000000000000 10000000010100000 11000000000000101 1000000010100101 = CRC valueOx80A5 (remainder) CYCLIC REDUNDANCY CHECK A CRC is a more effective means of error detection than the checksum method because each piece of data (nominally a byte) can affect the full data width of the CRC. For instance. You'll note that you don't really have to XOR 0. This seems to be a good time to look at how this works. refer to the titles in the Resources section at the end of this article. XMODEM. let's www. This choice always produces an MSBit of "0" in the result (which reduces the result's width). If the carry holds a "1. The subtraction (normally used in long division) is simplified to an XOR function (disregarding carries). If the carry holds a "0. Errors that develop between the transmission and reception are dependent on the transmission medium and the environment. it still boils down to the odds. I won't discuss this further here. A checksum is incapable of recognizing that this kind of error has occurred. HDLC. 16 bits. The quotient is not used! So what about that 17th bit? Look back at the previous example. we end up with the first bit shifting out (into the carry) and the 2nd through 17th bits (in blue) in the 16-bit register.25 standard uses 216+ 212+ 25 + 2° or OblOOOlOOOOOOlOOOOI (Oxll021). but you will see shortly that the MSBit (and it is always a "1") can be discarded. For example: 240 + 33 = 273. and many burst errors.Name CRC-16-IBM CRC-16-CCITI CRC-16-DNP CRC-16-DECT Polynomial x16 +x15 +x2 + 1 x16 + x12 + x5 + 1 x16+x13+x12+x11 +x10+x8+x6+x5+x2+ 1 x16 + x10 + x8 + x7 + x3 + 1 Used In Bisync. We will treat the data as one potentially huge binary dividend and divide it by the divisor (OxI8005). the additive method of calculating checksums is replaced with a division method. We need to pad the data byte Ox31 (and any data string) with 16 bits of zeros (the width of the CRC we are using). there is no context from which you can extrapolate the correction information.clrcultcellar. The CRC-16 standard uses 216+ 215+ 22 + 2° or ObI 1000000000000101 (Ox18005). a checksum error won't be found. The checksum's width makes no difference (8 bits. IEC 870. ANSI X3. This is accomplished by doing some base-2 long division. Bring down the next digit (in green) and the result again gains a bit of width. a two-bit error. Some simple errors can be missed by the checksum method. SD. The same issue with two errors in a parity-checked byte exists with a checksum. For the remainder of this discussion. First. "Are you a betting man?" and not odds and evens. However. The context of the data can often help point out errors. if the data is a binary block.

along with its potential variants. This enables the actual OxFFFFFFFF OxFFFFFFFF OxFFFFFFFF OxFFFFFFFF PARAMETERIZED MODEL TableOffset = MSB WorkingWord MSB WorkingWord = LSB WorkingWord LSB WorkingWord = Data byte :. By this you can see that in the dividend the 17th bit is held in the carry. it's The algorithm for encoding a CRC is the same for decodimplied. we prepare to repeat (LSBit first). CIRCUIT CELLAR" www. A parameterized model can present how drastically they can alter the resulting CRe. The calculated CRC is appended to the data at the the XOR.e.:: ~ a' Figure I-To calculate a CRC value for data. Figure 2-Based on previously calculated CRCs for all byte values. and if the final CRC value must be reflected. Ox32. In Reflect CRC No Yes No Yes fact.Form Polynomial Width Initial CRC register value Final XOR value CRC-16 Ox8005 16-bit OxOOOO OxOOOO CRC-16 Ox8005 16-bit OxOOOO OXOOOO CRC-32 Ox04Cl1DB7 32·bit CRC-32 Ox04CllDB7 32-bH polynomial Ox18005 to become Ox8005. the algorithm must perform some process based on each bit of the data. ) illustrated in Table 2. the result is the CRC for one bit value that must be XORed with the final calculated CRC. shows the polynomial disand the resultant 16/32-bit CRe. Ox31. Ox33 . Test sequence "123456789" "123456789" "123456789" "123456789" While the polynomial itself is a good start (see Test CRC OxFEE8 OxBB3D OxFC891918 OxCBF43926 Table 1) to providing a CRC routine for encoding and decoding your data. there are more where these came from. These include the initial value of the CRC. optional. I previously mentioned CRC-16 and X25 as two Reflect data (byte) No Yes No Yes 16-bit standards using different polynomials. whether the data (input bytes) are to be initially reflected of data. cussed earlier. a nice 16-bit value. we don't need it. but they include a way of determining that the algorithm produces the desired effect. a dividend. The resultant CRC value remains a constant predetermined width. forces out a new value into the carry. a look-up table can speed up on-the-fty CRC calculations by reducing bit treatment to byte treatment. the function by shifting in the next bit of data.com ~ 70 . The CALCULATING 17th bit of the divisor (polynomial) isn't really needed.. These include a string of test data (l. When the carry is "1/' the 17th bit of the polynoing it.clrcultceliar. This list. there are often other facTable 2-Thls parameter model for two CRC-16 and two CRC-32 variants shows tors involved. So. which Optional test data helps to give some level of confidence to your algorithm.. The data is fed in and the algorithm produces a mial (which is always a "1") will always be eliminated by CRC. At this point. Should there be more data (bits). The last two parameters are these possibilities in a simple list form..

ble C~JCl.cI<·Ox883D· . once I got correct results with the algorithm. . or 8) determines whether the algorithm calculation used is by the bit. If you are willing to give up some program space.com CIRCUIT CELLAR" byte table might be used to speed up the CRC calculations. I added a drop-down menu so each parameter can be changed.!. or it just needs to be done faster.pl~TMle • N i. For a 16-bit CRC.Icul~ons· N Photo I-Running my CRC application on my PC displays the present CRC parameters followed by user choices. Calculating a CRC for a long string of data can take some time. but you will have to do twice as many lookups for the same amount of data. The proof can be displayed as well (see photo 2). Figure 2 shows how the algorithm for a www.1 D>::I2 OXll IIJ<j4 Q&.~ .EIt!. broken down into byte-sized chunks._Cl" dlh-l6-b~. I started this BASIC application to simply try out the algorithm shown in Figure 1. The CRCTable variable (1. if necessary. The bit that pops out of the other end is used to determine whether or not to XOR the polynomial with the WorkingWord. or byte.. This shifting and XORing is repeated until all the bits of all the bytes have been operated on. The nibble table is much smaller.Table c. then the calculated CRC should match what was appended to the data. OOij ilx311J. 4. One benefit to this is the ability to easily create a table for any variation of a 16-bit CRC form. There are two loops within the algorithm. "Outp\l\-N fOutV~U:I!!!:II(b1Ja{lD . which shows operations on each bit. BRUSHLESS AND STEPPER MOTORS... I had to make it more flexible.·N . and 16 bits of 0 are appended to the data. finally comparing the result to the CRCTestCRC. Figure 1 depicts a possible algorithm for finding a l e-bit CRC value for a string of data. A similar algorithm can be used based on nibbles. Anything larger will cost just too much valuable space. unless either of the two remaining operations changes it further. If you will be doing a lot of CRC work. you can consider other options. While I started by hard coding in the constants of a specific 16-bit parameter model.clrcultcellar. BUILD ME A TABLE I like building some quick sample code to make sure I understand the algorithms. You will need to decide how much space you are willing to give up for table use. Liberty Basic gives me a good playpen for fooling around with code. If the received data is passed through the same algorithm. an outer loop to retrieve each data byte and an inner loop to shift each bit of the data byte into the WorkingWord register.pl<iy PrOOI. The result left in the WorkingWord register becomes the CRC.N "nt[refinitic. ICSERVO BRUSH. The application uses the CRCTestString as default data and pumps it through the algorithm (looping through each bit of each byte of the string). a CRC table might be the right approach. en 'lynomiGl. Photo 1 shows a run displaying only the proof results. tables will range from 16 words for a nibble table to 256 words for a byte table.<31i Il:dSC <11110-1 i:8Pc~":!r'''Te. ~ck ~'ring • 1t<~. MOTION CONTROL MOTION CONTROLLERS FOR JEFFREY KERR. and finally a comparison of the calculated CRC with the check CRe. Each data byte in the string (or buffer) gets reflected.D>dI01lS n~iolCRC • O>:I)~OO ~edlnpU!-N . The inner loop in Figure 1 has disappeared and it is replaced by a precalculated table holding the results of all possible byte CRC calculations.tlon'El • N i. nibble. LLC transmission and stripped off at the reception end. the used algorithm steps.

PD.(~0)0x0021MdingbjIO . (OMY'"0) 0x00~6 a<ldio9 b~a ".~:2a. Q.."ng bllD .11 •• 0.Ib:ilO~ Cbc!lOFF. Oxom ~. m~ 1t<N'2o. M3E7.1Ixcr24C. 0>8:151.IllA'l. Mm.-N N "nt Defillillon. and out pops the nibble OxF.lJ>:8m.ll. leaving OxFOOO the WorkingWord.0x0. 0x0~1 e.1MI1.Qx0312.1)" 0x0004 ooon9 Word' 0x00U4 . The sixth nibble is now pushed into the WorkingWord and out pops OxF. Oxlms."Y"0) 1bO~62 odd. .Ib:~lDa [J>1J1C6.(''''rry<O). OxOIO'!. Ib:ilC41.S ooon9 Word • MOOD "'\fOod lot· (""". O:. 0. OxaZDF:0>:Il2W\. Ox825D. 0x008C sIll1l. OxOooa MOOo.llifIed len· (i>orry-O) 1Ix0~02 o.5. Each bit operation Is shown In groups of data bytes. 0·.·1 ' . . Suppose your data is the single-byte OxFF. DNA must unzip into two half strands (like a ladder with breaks through each rung). Some of us are interested in what's inside the black box.~iftod left. 43. 30. .~~:9~:e~~2J~~~ ~E3: ~2E6: ~<II2EC_ Ml2~9.O)IIxOOO~ o. !b'OlES. UxOOFA'OxfIOE6. cnc IG I!!I~El OaDIt OxBVOS. 1bO.<:J.iOlAf. DNA goes through this process during reproduction.i0023 o.-. !b'030o. a table of 256 CRCs (for bytes OxOO to OxFF) is calculated and displayed. (l.. 1bB. Williams.Il<OlOC.OxOO. Prentice Hall. 0xfI~21.lIod I"~' (""rry<OIIbO~Jl Mding. O>illOE. ¥ i!jpl~Teble InlT~te CeIaIlaiion N •• 'nlT~fe . .mrt. 183.Qlil<d Ion.CEt.1·91016 000'9 Wold.OxOI92.1Ix01F4.oU( Velue .ll. I present this for those of you who are interested in knowing more about the inner workings.QxOI32.. This shows the relationship between nibble calculations and byte calculations..hm.O'1A ib61 DB.c 0xr09o. O>OJ8't O>8JB1.1l0~aOXO04E.37 Qx38 1Ix3!l CT~I. txt. O ~SO.N JI-llo.1t<N'2F_ 0x!J22A 0x02lB.OxfIoa1. !b'0246. MlED.OxeJ1a 0x012E.OxOI S8. This is a brute-force implementation. D>:lJ16.1I:. OxfI009. S. chromosome damage. so please be kind. if you look at the last table entry in the byte table (see photo 3) you'll see that Ox0202 is indeed the CRC for the byte OxFF. Ib<0096. APPLICATION DOWNLOAD You can download a copy of this application from the Circuit Cellar FTP site and learn how CRCs can be created. IIxODO~ Q1kingWOld.IWlOEE.J8B.ll3FJ.N :lntPtool.1bOlA6.10E. O<lllO~ 1b0301. O&lIlAF.1b:80S.<0066. OXOZ3{1t<N'31. Computer Networks. 1b0462 Photo 2-Toggling display/print options allows different amounts of data to be displayed or printed.com .lalion.II1~D. 0. you'd have OxFFOOOO.. go to ftp://ftp.. (c... OxB~7. . >.1b02~1 .OxfI~6..lbg381.-. 0x023E. (See Section 3. OxOilEa..killedIBfi. IbOll a . !b'i2~O. This byte table can be copied and placed > WHO KNOWS? Methods like the checksum and the CRC provide a level of confidence to data transfer integrity.II:dl~3A.81 sn lIxlI167.ross.1ixu I 0&.0001 Mo.11>8080.IMI~G1.. 83530 !b'OJ55. Photo 3 is a table displayed in rows of eight CRCs.I .UXO~C.DSF. 0x0137.1)08(0&1061. 'Iepllljl Proof. 0x0! I c_ b. 1l>:fl00l arning Woro -OxOom .Ox0252. IIxO002 ooon9 Word • 0x0002 ohin. www. Ul!IIcrE~ O:.. 0x018E. Biologically. J90.net/crc/ download/ crc_ v3."rtg Word . ~oac into any application in which you want to implement this method of calculating CRCs. D~~~=~6.1b01G:!. "A Painless Guide to CRC Error Detection Algorithms.1l<81A. 0270. OxfIJ. 0 93.IlIEF_ 0>01 EA. 1l<1l12C CI:.1Ix01FE. WorkingWord is initialized with OxFFOO. 0xfI~11.. 1bVQMi. ~30. Ib6Il45.E.O>Ql5~. Note that the first 16 values are also the CRCs for a nibble table. 30. O>1)16F.IlOEl. Qi. Tanenbaum."'! bllO • 11-.n9 bila. Photo 3-With CRCTable = 8 and DisplayTable = Y.ctrcultceliar.. 0x01Al.. All of this is based on bit calculations for finding the CRC of a string of data.6261. H 'EO._OX :ttfI8dln~:U. 1b6007. 110. The table entry is again Ox0022.b. PROJECT FILES To download the code.) R.C6. I 38. I added code to use the algorithm to calculate CRC based on all possible single-byte input values.ll3~ o.0·.lb:inol. 1n O>D126.oioC5A Cl>. Why am I showing you this? Well.IM)~ce:.1b:008C~d(li.:e219..d I. OX0220XOR Ox0022 = 0x0202.Ox!JJOA IbO. 21 1. The input byte value is an offset into an array of calculated CRC values for all byte values.1b(l08:e. 0>831 n OI<8Jl7. son.IM1FB.ll1. !b'DIE5. tlidJlBt . OxOm E. 1981.com or at www.0) IIxOOOIMdirtgliilO ·1-.1MI207.The fifth nibble is pushed into the WorkingWord. DldllM. .(WIOeD. Ox$<FD.a06c. QxD~3S:QxDD3" (l:<aO:rl {NJO~~.2..A.d loft· (""rry. OxOI'Oc.. 0>037" Mm. OXOOCC.Ib02Got.. II>:03SC. D:<Ill ii.. You need to be confident that what goes into a transmitter is exactly what comes out of the receiver. OxSI~F_IIxOI'oIA. O&llCF.d I"~· ("""Y"O) Ibom 1 oo.llllB.lbOoa2. UMl. '1~0.OxOI5E.. 8:J.<80Sa OxOOB.$11 F. I know you "C" guys probably have canned routines for doing CRCs within your applications. 1b01CA. 0'\ Bil. Ox81S'I.>d)OOO ael<· 0xI383D ao!< Strirtg· MI il>Q2 043 Qx3~ M5 0>3e0>. OxfIUOF_b'OOOA0:. ~>JIIQ. 0x02F$. CIRCUIT CELLAR" - www.:.ooongWord' MIl8 ol\. 0xIl231 00009 Word . 11..d leII.0-> IIxO046 coongWcrd. To replicate.com /pub/Circuit_Cellar/2011/250.Il01B. The in table entry at offset 0xF is OX0022(see photo 3).) Q.1I.ll:iIill!1..layTabl. 0x0257.IO -1-. 0x037E. 0xII26E. x. 360.II. 01:8145. 1 n 1bV17"1I:<~17C.bachiochi@imaginethat now. 031)).1b02Sa.ll12!1_1IxO CI:.0208.g biiD. II:dllSA. 1993.0x0023 .circuitcellar. ~xOon. OxFOOO XOR Ox0022 = OxF022. I UFO.<Idin9 bilO . sn. . What is the term used to describe the error-checking process that goes on to protect against DNA integrity errors? iii Jeff Bachiochi (pronounced BAH-key-AH-key) has been wrWng for Circuit Cellar since 1988.. RESOURCES A.1l<830B..:>7AIMI2SB. Ml. Mltl!t o.9. o.roN. 0l:839F. DxO~I2.hillEd IBft.. OxalFS. 0:<018" 0><6169. BQOulpiJl'f. DlsplayProof = Y. Oxi1'F1_ 1Dl. IMIZD5. 0xfI2~9.dding biiO • [1.1-> IIxOOll orkingWcrd .OXOU4~. His background includes product design and manufacturing. ! Jl.<0284.M1S8.(oMy-O) 0:.:OxO~42.baOC9.". OoI". 0:.' N .0. 0x0~~7.lIl<Dm.com. 041368: 1b838D.lbOioa. and that's fine. OxSl6F.j1N • .0xfI19D.' [1.3 on pages 128 to 132..11>:0181>.0x02il2. (~O) IbOll a ad:di"g bOO . You can reach him atjeff. In this case. (lX81(l). 0>0002.." Version 3.OxODOS . M36. Q Ib(lOC6. Ml18. !l. 0xS27F.' Ib:e.Oxll2F7_ Ox02F2. After padding and reversing the data.. MOW. Jbc831F. Once the algorithm had been proven based on the correct CRC value calculated over all the bits of the test string. Each half must be rebuilt as an exact copy of the original or you have an error.1b:009C.. OxOO~G . o:xaOSB.R.0x0078.lmaglnethatnow.leaving Ox0220.

~ CoreArchitect~ Any Part Family Any Tool Type Any Tool Provider ( Reset ) ( Search) _ -- Digi-Key Tools Xpress.. Compare it to Other Tools..~RlO:S.www..com Pick a Tool.. The Digi-Key Tools Xpress intuitive research engines are used by engineers worldwide to locate.i'U1. W.. is the only site in the industry where engineers can quickly find.''~'iI'' . Cl\I'GA 1fT aD' LCDT""".OCJIottoo.Without Leaving Our Site.-." """'" Qt:4~ IIJE. YE. IO!._' ' _-_-__. and Buy It from Digi-Key Tools Xpress -. NXP LPC2478 Evaluation Boards Eval. Find the Right Development Tool. engineered by Embedded Developer. with features and performance specs._ . 24D:'. Evaluate It.CtJ. ~~te _Fl>olI _ .""'"!~ Tuell Xprm.DevtoolsXpress. ToolsXp.. and prices.!6 ftJ.. Boards IJSB.Rms. n. compare and buy the leading development tools.~:24-M.. . CAH ~ """'" L'O ____ "" ~..::.2 .I:Ieb:t!I._ YES YES C/C+ . availability.~=="'~ -3:2(ti240l4-tIICd:lrI...--_ -__. Fi:tdinBI Join the thousands of engineers worldwide who use Digi-Key Tools Xpress for their development tool needs. LPCZ47iEvol_ Ji~.. so you can make an educated decision! I~ I IDEs.:b:Sae9il !1Ue~~~f' -"""...ress- Search Results for. use 0Tt\0>IW... RKtI$I. L~==""" IS<~ RFQ .I:~ IIICBUlIJIEtoi&.'r~USB. . . Any Tool. df".. RTOS JTAG Emulators Debuggers ~--~--"'P'!~~ .1.. ToolsXpress Engineered by Embedded Developer SM . Compare before you buy: tools are listed side-by-side. compare and evaluate hardware or software development tools.'BNld _=IlCC~_ ~~~~~ b1in"aI R:AM 1. "<w<..

or x Stop error [two words] Used to trail off Exposure to ultraviolet light makes it disappear Design language (related to Cain) o 74 ~ILtWOW~1 ~ ~ The answers will be available in the next issue and at www. 16. 19. 10. 17. 9. 3. 11. 13. 4. 6.2 13 14 Across 1. 8. . in computer terms Sensitive to the degree An update a bird may comprehend Software used to talk over the 'Net Needs to run before an as can start A unique ID that follows IEEE-managed rules Down 2. 18. A quick response Founded a binary system [two words] Used to measure electrical resistance Performs an intervention when things go wrong [two words] What it means to *. HP (hint: not a printer maker) [two words] Not a lot of logic Tap into your computer's memory Ensures things are running smoothly To exterminate.com/crossword. 15.. . 5. 14. 12. 7.circuitcellar.

S12K RAM with Flash backup • Plug-in Flashlil 186 processor . Knobs. XD.. and more .TechnologicaIArts.com www. Parts and Supplies.. Magnets.com with your file or send it to IDEA BOX.r • .. Terminal Strips" L...com 503-743-3194 Turner. ALL TEXT AND OTHER ELEMENTS MUST FIT WITHIN A 2' x 3" FORMAT. a' ~ www.281.. UART. On the web at www. Motors.. Canada): 1-877-963-8996 www.com - CIRCUIT CELLAR· 75 . freesca/e~ Alliance Member Topologies Supported: Planar.Serial Ports • 1 B5 • DOS Features: Automatic text scroll and crawl 'TTL-232' and SPI control ports Any size for custom fonts Vector and bitmap graphics • Accepts BM B 0 i "kOn Chi P • 2 16-bit Time".:.ds 0.S. E. D.comladvertise). Fuses. Panel Meters.DiA .comlvendor/ is your guide to a variety of engineering products and services. Solder Accessories. PO Box 180. Switches.86 centre . Fans.itier Devices" and much more .. Relays. I/O expansion... Stack.. Pe..:: ..com Free 96 page cata/Og~ 1-800~826-5432 ""7 I. including Ethernet:."h . Wall Transformers. Cameras.. Solar Cells. Backplane... EmaH Tech. GPS.3741.... Batteries. XE.. Call5JO-297.. Video Accessories" Sirens.e.ipheraISoa.EI!E. 33 MHz wi Flash 'File system • 44 0 ig italllO Iin es wi CPLD • Con s ole I Debug Serial Port . CT 06066.5"x4W C-programmable computer • 16-bit HCS12 processor docked at 40 MHz • 8 PWM.1-34V DC or 5V DC power . "'1 Iolt 1I.. ROX THE DIRECTORY OF PRODUCTS AND SERVICES AD FORMAT: Advertisers must furnish digital files that meet our specifications (www. 8 counter/timer.6073 Email sales .. 24-bit data acquisition.clrcultcellar. bob-4 • Low cost 2. The Vendor Directory at www. 5PI and I'C ports • S12K on-chip Flash..jkmicro.. OR. • Expansion cptlcns wilhP. Compact Flash card.52 II. Displays. E-mail adcopy@circuitcellar. • 512K DRAM & 512-K Flash • Wat~hdog Time...2. C.:II brary and cable Wi-Fi. lkmlcro._ :: . deadlines. NE.ED..com.allelectronics... relays. s: • Flas. For current rates. XS 0 ~ ~ Toll-free (USA. and more information contact Peter Wostrel at 800.978.Ie 1. Buzzers.7708 or peter@smmarketing.us.circuitcellar.. Alarms. Vernon..'. . and 8 digitall/O • 16 lD-bitA/D inputs • Dual RS232/485 ports. Tower MCU Families Supported: S12A.454.!. Speakers..". USA JK microsystems Evaluate * Educate * Embed Adapt9S12 Modular Prototyping System For education • development ALL ELE COR Electronic and Electro-mechanical Devices. • Borland C/C++ ver • Serial 4.101' .circuitcellar. Support Drive. Opto Electronics. h' i. • • AC Adapter USB. Circuit Cellar. Heat Sinks.

USB 3. code.com 262. protocols..522.95 Lakeview Research LLC www.Add USB to Your Designs less expensive MCU with smaller program memory Chips. ~o .. ~ debugging.._. •Save hundreds of dollars in component costs in projects CCS Compilers Save You Money Compilers Starting at $150 _.ccsinfo.. embedded hosts.com .6500x35 ISBN978-1-931448-08-6 $54.com By the author of Serial Port Complete ~- CC-ACCES CIRCU.Lvr.0 and superspeed too! USB Complete Fourth Edition Jan Axelson The Developer's Guide ___ www....co":!/sAVE sales@ccslnfo. wireless options.IT CELLAR·-- CIRCUIT CELLAR· - www.clrcultceliar.

KUlnl Pc. FII"II'IW"'I'J upgl":ll..... FA!!' AGt!w. ~A" SI.fiOn SaJes@jJcmicro. R5-232.cortl www. high-performance kernel drivers for Windows. bit-bang. Ethernet. AOC.com.95u9.full $PiJod ~"" USa C!lI"iYlllr'I e'i . AOC.lC8 gJ _.com • Embedded. USB...lQ·pom FtTR F.u[ _-. Personal.clrcultcellar.CA95616 USA Tel:530-158-0180. . Davis. VB.~·" Free Tliniiildli1d W!IU:kI'l'l1l. CAN. De'~h~ Pl.95u •• qty.. in C.QN.1::". 1 MaxSonar-WR Dimension Proximity Position Level From 16MB to 128MB A . el:e. Pocket-Size ~CC Micro Computer Control amazon:CQuk- www. $Irnl). I/Os.Cl(ilM!r Wo~ up lCI1Mbl.com JAMECO® [IMo.JtOIBJt[c:.. UJ.com 1_II~IIII CIRCUIT CELLAR· . auppgrt D~ 11 & a b"lllCl s·uppm. • U-DrillfITM 5. Fax: 530-158-0181 www. 12C Master.fI'I. !ltIggt. C++.MaxSonar Perfect for OEMs & Engineers XL-MaxSonar-EZ • High acoustic power • Real-time calibration 'Tlnyslze • $39.Jl. DL.. C/C++ Programmable .. RS232.L . Inc.x II:Glmp!.lO.com J K microsystems. FPGA port • Software library and example code • New.mcc-us.. Powerful ..lern. 1 (IP67) • Industrial packaging • Weather resistant • Standard %" fitting • $99. OAC. • Low Cost User Interface with Ethernet. ll'lch.com - INC.llll .d:llbre:~" US8 Silm.pl!il FlrDiram.95u8. amazoncorrr ElECTrR. CE. OAC••••. 1 (IP67) CaJl53Q. 5PI Master.297. 1950 5th Street.jlrmlt.$149 qty 1 • 25MB/sec data bus. Linuxand MacOS www.. Relays_ ..~ use. sales@tern..quickusb.lable/ i MaxSonar-WRC • Compact packaging • Weather resistant • Quality narrow beam • $99.. 'MAC Ii·Unw.7"QVGA TFT. International Orders Welcome Exactly why is USB hard? JB~S SySlems Prototype BusBcarci Part# QUSB2 . CF.ljIp""od TERN" www. qly.: No~ct'lI)r~)lUinI. qly. CF.'Miw. Standalone.

Smart Outlet Communication .JPEGSe~alCamera .including books.s.RS-232 and More Source Level Debugging in MPLAB $89. HEATSINK-Creates liquid or air 17. Includes Software for Windows 98. HYPERTEXTMARKUPLANGUAGE- group of messages to enclose text Used to weave the Web [four words] 7. Define Your Data.II ~. NANOSECOND-lo-' ROTFL-Common not real s text message: PARENTHESIS-Used 10.accessories. linux.z. > Grows with your product line: for a new product wI different processor or connectivity type. LOCALBUS-Makes 4. SCAN-One to login J and L a series of lines [two words] word for main board or "Rolling on the floor laughing" 11. with variable names that YOU create. 9._:. UHF EPC Gen2 RFID Reader. See our full range of products.a _Q 'KIE L vii :ilil eX fIeM fA c!'- en- ~ LIl. OMEGA-O 20. Arduino Shields (WiFi) Ai" . 6. 5.. NT.and componentsat: PICBASIC PRO'" Compiler $249. SSH-Protocol allowing the exchange of data between networked devices 12. _Q 1. > Simple for non-technical end users. MOTHERBOARD-Another system board 18. ZUCKERBERG-Social THREAD-A [two words] ~ H T f1' p eli z u elK E R B EIRI GI H1R E A1D brighten things [three words] 3. 8." NO PC PROGRAMMING AT ALL . but the engineer appreciates what's happening under the hood. Supports: More than 300 PIC.. and securely.I~ =r t::.just point your browser at your device! low cost integrated system manages upgrades across different processors & connectivity types: > lets your end users upgrade your PIC firmware safely.com CROSSWORD ANSWERS from Issue 249 I'L 0 CiA 'L B Ius Down 2.0. 12C.com www. GPRS.. _M . elL fA I N W P T "T 0 R vlo 1''''''0 dHE L Ds dB o A1R D _M R D cA cl[2: E NlE R D1I '0 D E _!!_ eN eN . such as 16. With Accessories for $119. The simplicity of the language allows both hobbyist and engineer to master it quickly.just add another SUMS bootloader. Software.z.melabs.j =r ==- . Xp. eK c!''OIA R clo DEI .linksprite. This is a true compiler that produces fast.--- cL direct conneclions networking guru c_R. B to 4O-pin DIP.95 (as shown) RoHS Compliant Programs PIC MCUs including low·voltage (3. > Automatically delivers upgrade by email. Charger.ab on tal using TCPmaker's drag & drop Visual Page Designer. and Vista. USB Cable. Street hting System. TORVOLDS-Creator terns 19. www.com . fluidity. Modules > low-SpeedModemPro > Low-Spead hieldfor S Aldulno. _Q cK A A elL F r"!' eM cL r1' r1' ~ eNrAeN~ re- P R A R E1N T HE _Q S II I s I .me/abs. simply.com 888-316-1753 USB Programmer for PIC®MCUs PICBASICPRO™ Compiler Bridges the gap between ease of use and professional level results. 2. ower-Line Communication. > Encrypted system protects your firmware from theft or from being programmed into the wrong device. Me. KELVIN-Between 14.Collular modules • GPS.s.Power-line Communication Street lighting System Easy as 1-2-3: 1.TheIlrst oneIn Iheworldlll > High-Speed odem M > High-Speed odem M lor DMX512 . and Programming Adaptor fo. Inc.®Microcontrollers Direct Access to Internal Registers In-Line Assembly Language Interrupts in PICBASIC and Assembly Built-In USB. Generate Your Code.:. eli G 1'5 cAIN .Power-Llne --frr r r. and Android• From the makers of HIDmaker FS: www. optimized machine code that's stable and dependable..com 888-474-1041 mE microEngineering Labs.3V)devices.z. to "wire it all together.tracesystemsinc.Arduino Shields: WiFi. OPAMP-Used cuiis [two words] to build electronic cir- way a computer reads data 15. 3. I rr-: r£N E A fR. PASSWORD-Required 13.clrcultceliar. IR.95: Includes Programmer. LIGHTEMITTINGDIODE-Used to Across . BARCODE-Data. Lay Out Your Content (with gorgeous web-ready screen controls that you can g.95 www. current folWard and back- fA ~ CIRCUIT CELLAR· - www. luetooth B modules • lS6410 embedded system with Win CE6. ZENERDIODE-Permits ward of Unix-type operating sys- "r1' . for all Microchip C compilers. ROBOT-Mechanical.

Inc. Inc. Inc. 51 AP Circuits 43 77 75 23 13 Lemos International Co. Inc.454. SID Inl'l Symposium 75 All Electronics Corp.281.59 23 49 61 73 Bitwise Systems BusBoard Prototype Systems Ltd.CIRCUIT CELLAR" Call Peter Wostrel now to reserve your space! <N J 800. Inc.. Inc.us 79 . Custom Computer Services. JK microsystems. 78 51 75 5 C2 29 C4 75 Technological Arts 77 Tern.. Mouser Electronics. Inc. Holtek Semiconductor USA Page 76 Lakeview Research Lawicel AB Page 12 Saelig Co. Futurlec Grid Connect. Inc. Inc. 19 Labcenter Electronics UK RRINI£W . 63 77 54 Sensors Expo & Conference 2011 Senix Corp. Inc.. ESC Chicago ESEC Japan Embedded Developer 43 77 32 Tag·Connect 2. 24 Pololu Corp. LLC JK microsystems. 9 WIZnet Co. Inc. Inc. Inc.77 IC Bank Imagineering.com . LLC Page 53 ExpressPCB ezPCB FlexiPanel Ltd.. Micro Computer Control microEngineering Labs.3 Technologic Systems 25 77 11 Humandata Ltd.32 75. Inc. 67 44.. -~ ATTENTION ADVERTISERS of June Issue 251 Theme: Communications July Issue 252 Deadlines Space Close: May 12 Materials Close: May 19 The Chameleon Platform: Low-cost Hardware Development with a USB AVR and CPLD Wireless Authentication: RFID Checkout System Design The Net Butler: Construct a Multifunctional Network Controller Build a Fixed Cellular Phone with Emergency Auto-Dial Theme Internet & Connectivity o (('J THE DARKER SIDE Stay Cool!: Temperature Management Primer THE CONSUMMATE ENGINEER BITs and BITEs: Tests for Ensuring System Safety ABOVE THE GROUND PLANE Plastic Extruder Thermal Analysis FROMTHE BENCH Vehicle Diagnostics (Part 1): The CAN Protocol and OBD-II www.clrcultcellar. MCC. 35 ARM 77 77 7 76 33 75 31.3741 or 978. NetBurner NXP Semiconductors Parallax. 78 Trace Systems. 76 Triangle Research Inl'l. 10 Pico Technology Ltd. Inc.45 78 C3 71 13.7708 e-mail: peter@smmarketing. Comfile Technology. Inc. 78 LinkSprite Maxbotix. CWAV Decade Engineering Elektor EMAC. Midwest Patent Law Mosaic Industries. Inc. Ironwood Electronics Jameco Jeffrey Kerr.lfND£X Ot lLADV£RTIS£RS Page 76 AAG Electronica. Inc.

perhaps you can understand that at the time it was my way of saying to McGraw-Hili: "Inside the box still counts. by the way. Founder and Editorial Director Happy 250th Relieve it or not. Comparing the publishing economics of Circuit Cellar and BYTE is ridiculous. home control systems. and me (along with the staff of great people behind "Ciarcia's Circuit Cellar" including Ed Nisley. It was a 10. Back in 1977. I lose track of events. a few projects even went a bit overboard. C. We started the magazine so quickly it didn't have a lot of advertising. but let's just say that if enough readers subscribe you don't trash a magazine. Sometimes. First of all. sleve. Wow.) The degree of complexity in the projects advanced with the prevailing technology. J. as they say. If my knowledge is correct.) Circuit Cellar (first in BYTE and then as a magazine) has existed uninterrupted for 34 years and is still going strong! Joining with Elektor adds new audiences. and commercial-quality embedded controllers and peripherals. Carl Helmers.) I have to admit that at the conclusion of my time with BYTE. There were a number of people upset about the changes at BYTE. visited my house and saw my basement "lab" and all of its equipment. but it was on national newsstands almost immediately. the staff included BYTE's former publisher. the journal was purchased by McGraw-HilI. the proof is in the pudding. and after the editor. (The articles are posted on Google Books. I think my idea for a BYTE column and an embedded design magazine is still pretty sound. One of the last "Ciarcia's Circuit Cellar" complete-instruction DIY projects 24 years ago was a VGA Mandelbrot generator with 64 processors! Somewhere in the middle of my tenure with BYTE. and products that will certainly result in Circuit Cellar magazine being around for many more years to come. I find I've been getting more questions about how it all started and why we are who we are. I even wrote a couple of articles for a new "small systems journal" called BYTE. and I had a lot of support.or serial-port-connected expansion peripherals because that was the prevailing computer connection. McGraw-Hili closed BYTE. Later projects included more standalone devices. I rejected that McGraw-Hili changed BYTE's editorial direction to PC-everything and dictated that nothing else existed from then on. 23 years later. Column popularity and the advertising revenue generated by "Ciarcia's Circuit Cellar" pretty much kept the publishing company off of my radar and out of my face until a few years later when it decided to commit the publishing equivalent of hari kari. I almost missed this.RIORITY by Steve Ciarcia. and it only takes one whiff of solder fumes to remind me of everything back at the beginning. When Circuit Cellar Ink started as a bi-monthly. Abate's 'Task Manager" (p. as they say. My last article in BYTE was in late 1988. but now that Elektor and its international audience have joined Circuit Cellar. Now that you know a bit more of the magazine's history. It wasn't until I saw a proof of C. I didn't reject that IBM had a good computer and a massive following. Many of you know the history of Circuit Cellar and how we all got here. is the perfect time to recap the story for those who don't know it. had it a while. I bet). Perhaps the 250th issue. I was an engineer at a big aerospace company that believed any computer not delivered in six trailer truck loads was too insignificant to bother with. that's 23 years! I know a lot of you have been with me since day one (feeling kind of old too. is history. (I guess we were on a roll. the "Circuit Cellar" is a real place. he suggested that I start a column called "Ciarcia's Circuit Cellar. I'm putting my money where my mouth is!) Of course. Coincidentally (or not) Circuit Cellar Ink magazine started the month before I left BYTE (it had "Ink" added to its name initially for trademark reasons).to 14-page monthly article that presented a technical problem and then described the detailed construction of a piece of hardware that solved that problem. I was left on my own to experiment and document the great things happening with these "new-fangled" microprocessors. when I'm down at the cottage. The premise of "Circuit Cellar" and the popularity of BYTE was always that computers were ubiquitous-not that a specific computer should be everywhere. The success of the articles was immediate. and closed it too. told you the title of the first issue of Circuit Cellar magazine. The rest. "Ciarcia's Circuit Cellar" was unique. Jeff Bachiochi. Then CMP took it. 4) that I realized this is the 250th issue. Early projects were mostly parallel. but the knowledge to design and use any computer should be everywhere. But perhaps you don't know that either." The circuit cellar "lab" still exists today. (UBM Techweb is the latest owner and will be starting an online version soon. I was given a choice to take the money and be PC-compatible (and quiet) or collect my marbles and leave. resources. The good news was that I didn't have to do it all myself-far from it. its chief editor. its circulation director. J.com 80 ." (And. and Ken Davidson).ciarcia@circuilcellar.

's ENGINEER 1-/Radio disk jockey O.Can You Solve This? . Forrest M.Jameco. The stunt rules prevented any physical contact between O.Jameco.Smith organized a stunt to raise donations for a charity by conducting his radio show for one week while suspended from a ISO-feet tall crane. I I I D. sign up for their catalog.J. A cell phone with a solar charger served as D. The weather cooperated with light wind.oJ.dropped his cell phone to the concrete below.and the ground. Mims III Sign up for our e. bottled water. His little home in the sky included fell-wrapped freeze-dried meals.J. pocket knife. notebook.com/teaser I0 to see if you are correct.com . dear skies and pleasant temperatures. Go to ~ameco. pencil. How did he continue his show? (hint: OJ's engineer was an Alexander Graham Bell history buff).J. rubber bands. binoculars. MP3 player.J.'s only link to the radio station.com/adventure1 1-800-831-4242 I www.J. paper dips.newsletter and get a FREE comic book. While you are there. and a portable radio. www. All went well until! O.

1. made-in-the-USA. so it's easy to see how the traces are connected.PROPELLER mULTICORE STARTUP SPECIAL~ A great way to play with the multicore Propeller P8X32A mlcrocontroller at a great prlcel This open-source. 5 MHz removable crystal. the Propeller Platform USB is an easy-to-use development tool for the multicore Propeller microcontroller. a ProtoPlus module. Traces in the prototyping area are also marked in the silkscreen. limited-timeonly kit Includes a Gadget Gangster Propeller Platform USB. All 32 Propeller I/O are available via pin sockets.3 V regulated power. . breadboard and protoboard friendly module. USB. The ProtoPlus module adds video and audio to your Propeller Platform and includes a prototyping area. and a cool plnstrlped acrylic enclosure to house your completed project! Combining a 64 KB EEPROM. and a microSD card slot on a compact. We have --~ several tutorials available online to get you started. along with 5 and 3.5 A power regulation.

Sign up to vote on this title
UsefulNot useful