0% found this document useful (0 votes)
164 views84 pages

Circuit Cellar November 2011

Uploaded by

Nuno Tavares
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
164 views84 pages

Circuit Cellar November 2011

Uploaded by

Nuno Tavares
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 84

Cover_Layout 1 10/11/11 8:53 AM Page 1

TESTING: PWM Voltage Reference Technique DESIGN TIP: Protect Against EMI Q & A: Embedded Theory & Practice
LOCATION: United States LOCATION: Canada LOCATION: Israel
PAGE: 18 PAGE: 46 PAGE: 50

THE WORLD’S SOURCE f OR EMBEDDED ELECTRONICS ENGINEERING INf ORMATION


NOVEMBER 2011
ISSUE 256

ANALOG TECHNIQUES
Analog Signal Management
& Sound Tone Detection PLUS
“Spark” a Design
MCU-Based Auditory Implement 32-Bit Power &
Navigation System Arduino Compatibility
// Get Started with the chipKIT

Engineer an Alternative
// Program with a Modified IDE
// Shields Explained

to Joystick Control
// And More

Electronics Design:
Processors, Power,
& Interfacing
A Look Inside an
Ionization Detector

$7.50 U.S. ($8.50 Canada)

www.circuitcellar.com
C2a_Layout 1 09/08/11 1:30 PM Page 1

The easiest finished product you will ever create


Start with the PK70 EX

Personality Blades
Prototype Blade (P/N NBPKBP-100CR)................................ $25 ea.
Create your own Personality Blade

CPLD Digital I/O Blade (P/N NBPKD-100CR)....................... $59 ea.


Programmable Xilinx CPLD
32 digital I/O

Multi-I/O Blade (P/N NBPKM-100CR) .................................. $99 ea.


Eight 12-bit analog-to-digital inputs
Two 16-bit digital-to-analog outputs
16 digital I/O
Design your own, or use a
NetBurner Personality Blade FPGA Digital I/O Blade (P/N NBPKX500-100CR) ................ $169 ea.
Programmable Xilinx Spartan 3E FPGA
High-density 62-pin connector

NTP Server with GPS Blade (P/N NBPKX500-100CR) ........... $99 ea.
Network Time Protocol (NTP) server
Precision GPS time reference

Quad UART Blade: RS-232 Version


(P/N NBPKBU-232CR) ............................................................ $99 ea.
Network enable up to 4 RS-232 serial devices

Quad UART Blade: RS-422/485 Version


(P/N NBPKBU-485CR) .......................................................... $119 ea.
Network enable up to 4 RS-422/485 serial devices
Add your label to get a
finished product Quad UART Blade: RS-232/422/485 Version
(P/N NBPKBU-MMSCR) ........................................................ $245 ea.
Network enable up to 4 RS-232/422/485 serial devices

PK70 EX & Development Kit


PK70 EX (P/N PK70EX-100IR) ............................................. $199 ea.
32-Bit Freescale ColdFire 147 MHz CPU
.#4%3".t.#'MBTI.FNPSZ
4%..$'MBTI$BSE4VQQPSUt*$t41*t"EESFTTBOE%BUB#VT
&UIFSOFUt6"35T

PK70 EX Development Kit


(P/N NNDK-PK70EX-KIT) ...................................................... $299 ea.
The Development Kit features NetBurner’s Eclipse, an
enterprise level professional IDE that provides editing,
downloading and debugging in one environment.

Information and Sales | [email protected] Web | www.netburner.com Telephone | 1-800-695-6828

Pk70_blade_ad_v8.indd 1 8/22/2011 10:37:00 AM


1_Layout 1 10/07/11 9:35 AM Page 1

Subscribe to audioXpress magazine!


electronics speak Ê̜Êޜն ÀiÊ̅iÊܜÀ`ÃÊ“audio”,
œÊޜÕÀ
“vacuum tubes”,Ê>˜`Ê“speaker technology”ʓÕÈVÊ̜ÊޜÕÀÊi>Àö Ê

/…i˜ÊޜÕÊŜՏ`ÊLiÊÀi>`ˆ˜} audioXpress!
Recently acquired by The Elektor Group, audioXpress has been providing
engineers with incredible audio insight, inspiration and design ideas for over
a decade. If you’re an audio enthusiast who enjoys speaker building and
amp design, or if you’re interested in learning about tubes, driver
testing, and vintage audio, then
audioXpress is the magazine
for you!

tŚĂƚǁŝůůLJŽƵĮŶĚŝŶaudioXpress?
UÊÊʘ‡`i«Ì…ʈ˜ÌiÀۈiÜÃÊ܈̅Ê>Õ`ˆœÊˆ˜`ÕÃÌÀÞÊÊÊÊÊ
Õ“ˆ˜>ÀˆiÃ
UÊ,iVÕÀÀˆ˜}ÊVœÕ“˜ÃÊLÞÊ̜«ÊiÝ«iÀÌÃʜ˜Êëi>ŽiÀÊ
LՈ`ˆ˜}]Ê`ÀˆÛiÀÊÌiÃ̈˜}]Ê>˜`Ê>“«ÊVœ˜ÃÌÀÕV̈œ˜
Ê
UÊÊVViÃÈLiÊi˜}ˆ˜iiÀˆ˜}Ê>À̈ViÃÊ«ÀiÃi˜Ìˆ˜}ʈ˜Ûi˜ÌˆÛi]ÊÊ
Ài>‡ÜœÀ`Ê>Õ`ˆœÊiiVÌÀœ˜ˆVÃÊ>««ˆV>̈œ˜ÃÊÊ>˜`Ê«ÀœiVÌÃ
UÊÊ/…œÀœÕ}…Ê>˜`ʅœ˜iÃÌÊÀiۈiÜÃÊ>LœÕÌÊ«Àœ`ÕVÌÃÊ
̅>ÌÊ܈ÊLÀˆ˜}ÊޜÕÀÊ>Õ`ˆœÊiÝ«iÀˆi˜ViÃÊ̜Ê
˜iÜʏiÛiÃÊ

Choose from print delivery, digital,


or a combination of both for
maximum accessibility.

Subscribe to audioXpress at
www.cc-webshop.com
today!
2_Layout 1 2/9/2011 2:56 PM Page 1

Embedded Systems
High-End Performance TS-7800
with Embedded Ruggedness 500 MHz ARM9
Unbrickable Low power - 4W@5V 229
$
qty 100
design 128MB DDR RAM
512MB high-speed
(17MB/sec) onboard Flash
269
$
qty 1

12K LUT customizable FPGA


shown
w/ optional
Internal PCI Bus, PC/104 connector
SD Cards
2 host USB 2.0 480 Mbps
Gigabit ethernet 2 SD sockets
3x faster 10 serial ports 110 GPIO
and backward
5 ADC (10-bit) 2 SATA ports
compatible with TS-72xx
Sleep mode uses 200 microamps
Boots Linux 2.6 in 0.7 seconds
Linux 2.6 and Debian by default

TS-TPC-7390
7” Color Touch 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
$ 449
qty 1

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

Over 25 years in business Custom configurations and designs w/


Open Source Vision excellent pricing and turn-around time
Never discontinued a product
Most products stocked and available
Engineers on Tech Support for next day shipping

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


3_Layout 1 2/9/2011 2:56 PM Page 1

New Products

TS-WIFIBOX-2
A Complete Solution for 802.11g WiFi Applications
$ 185
qty 1

Low power (3.2 watts), fanless


Power via 5-12 VDC, USB, PoE (opt.)
64MB DDR-RAM
256MB ultra-reliable XNAND drive
Micro-SD Card slot
RS-232, RS-485, CAN, RTC
Header with SPI and 11 DIO
480Mbit/s USB, Ethernet, PoE option
Boots Linux 2.6.24 in < 3 seconds
Un-brickable, boots from SD or flash Ideal for gateway or firewall, protocol
Customizable FPGA - 5K LUT converter, web server, WiFi audio, and
Optional DIN mountable enclosure unattended remote applications

series
starts at
TS-SOCKET Macrocontrollers
$ 92
qty 100
Jump Start Your Embedded System Design
55 mm / 2.165 in.

TS-SOCKET Macrocontrollers are CPU core modules that


securely connect to a baseboard using the TS-SOCKET
connector standard. COTS baseboards are available or
design a baseboard for a custom solution with drastically
reduced design time and complexity. Start your embedded
system around a TS-SOCKET Macrocontroller to reduce
your overall project risk and accelerate time to market.

75 mm / 2.953 in. 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 TS-4500: Cavium ARM9 at very low cost
Secure connection w/ mounting holes TS-4700: Marvell PXA168 with video and 1.2 GHz CPU
Common pin-out interface TS-4800: Freescale iMX515 with video and 800 MHz CPU
Low profile w/ 6mm spacing Several COTS baseboards for evaluation & development

Technologic
Systems
We use our stuff.
Visit our TS-7800 powered website at
www.embeddedARM.com
Task_Mast_256_masthead.qxd 10/12/11 1:51 PM Page 4

T ASK
MANAGER Tech Evolution
THE WORLD’S SOURCE FOR EMBEDDED ELECTRONICS ENGINEERING INFORMATION

FOUNDER/EDITORIAL DIRECTOR
Steve Ciarcia
PUBLISHER
Hugo Van haecke

L ike many of you, I have shelves of bookended Circuit Cellar


magazines dating back to the first issue. For work-related purposes,
EDITOR-IN-CHIEF
C. J. Abate
ASSOCIATE PUBLISHER
Shannon Barraclough

and out of curiosity, I frequently take time out of my busy schedule ASSOCIATE EDITOR CUSTOMER SERVICE
Nan Price Debbie Lavoie
to thumb through back issues to review many of the embedded
designs of the past 23 years. As I prepared for this issue, I returned to CONTRIBUTING EDITORS CONTROLLER
Jeff Bachiochi Jeff Yanco
Circuit Cellar 224 (March 2009) to reread Guido Ottaviani’s article,
Robert Lacoste
“Robot Navigation and Control,” which was actually the starting George Martin ADMINISTRATIVE COORDINATOR
point for his article about sound tone detection in this issue. (When Ed Nisley Valerie Luster
you get to his article on page 30, you’ll understand why I returned to PROJECT EDITORS ART DIRECTOR
his 2009 robotics article.) After reading the article, I turned to the Ken Davidson KC Prescott
Task Manager section in that issue, where I had written: David Tweed
GRAPHIC DESIGNER
Most quality new designs are the sum total of dozens, perhaps Grace Chen
hundreds, of earlier projects, applications, and programs. When
you see a project in this magazine, you can think of it as a single
Circuit Cellar’s mission is to collect, select, and disseminate need-to-know informa-
point in the long timeline of technological evolution. Looking tion around the world in the fields of embedded hardware, embedded software, and
ahead, you should consider each project, idea, and program computer applications. Circuit Cellar uses an assortment of print and electronic con-
described in these pages as a contribution to future projects. tent-delivery platforms to reach a diverse international readership of professionals,
academics, and electronics specialists who work with embedded, MCU-related tech-
I still believe this. Guido’s article in this issue is an excellent nologies on a regular basis. Our aim is to help each reader become a well-rounded,
example. The project he finished in 2009 was simply a prelude to multidisciplinary practitioner who can confidently bring innovative, cutting-edge engi-
his work with sensors today. And, as you’ll see, the other projects neering ideas to bear on any number of relevant tasks, problems, and technologies.
described in this issue are also contributions to the evolution of ADVERTISING
various important embedded technologies. Let’s review. 800.454.3741 • 978.281.7708 • www.circuitcellar.com/advertise
On page 18, David Ludington continues his series titled “High- ADVERTISING REPRESENTATIVE
Accuracy Voltage Reference Using PWM.” This month he covers a Peter Wostrel
Strategic Media Marketing, Inc.
hardware design to evaluate practical PWM circuits. 1187 Washington St., Gloucester, MA 01930 USA
Turn to page 24 for an article about an auditory navigation 800.454.3741 • 978.281.7708
[email protected] • www.smmarketing.us
system project completed by a team of students at Cornell Fax: 978.281.7706
University. The team describes how it harnessed the power of
ADVERTISING COORDINATOR
various cutting-edge technologies—from embedded to GPS to Kim Hopkins
biological—to build a wearable auditory navigator. The design is E-mail: [email protected]
ready for future upgrades. Cover photography by Chris Rakoczy—Rakoczy Photography
On page 42, Clemens Valens introduces the exciting chipKIT www.rakoczyphoto.com
PRINTED IN THE UNITED STATES
Max32. This is the next phase of Arduino-compatible technology.
CONTACTS
Embedded system protection is a constantly evolving field of SUBSCRIPTIONS
engineering. In this issue, George Novacek provides helpful infor- Information: www.cc-access.com, E-mail: [email protected]
Subscribe: 800.269.6301, www.cc-access.com, Circuit Cellar Subscriptions, P.O. Box 5650,
mation about EMI, EMC, and designing successful systems (p. 46). Hanover, NH 03755-5650
Address Changes/Problems: E-mail: [email protected]
Turn to page 50 for an interview with Shlomo Engelberg, a pro- GENERAL INFORMATION
fessor and author who has helped the field of embedded design 860.875.2199, Fax: 860.871.0411, E-mail: [email protected]
Editorial Office: Editor, Circuit Cellar, 4 Park St., Vernon, CT 06066, E-mail: [email protected]
evolve with his projects, courses, and books since the mid-1990s. New Products: New Products, Circuit Cellar, 4 Park St., Vernon, CT 06066, E-mail: [email protected]
On page 54, George Martin presents the fourth article in his AUTHORIZED REPRINTS INFORMATION
860.875.2199, E-mail: [email protected]
series on product development. His step-by-step tutorial will help AUTHORS
Authors’ e-mail addresses (when available) are included at the end of each article.
you bring a product from idea to production.
CIRCUIT CELLAR® (ISSN 1528-0608) is published monthly by Circuit Cellar Incorporated, 4 Park Street, Vernon, CT 06066.
On page 60, Richard Wotiz covers the topic of ionization detec- Periodical rates paid at Vernon, CT and additional offices. One-year (12 issues) subscription rate USA and possessions $45,
Canada/Mexico $60, all other countries $63. Two-year (24 issues) subscription rate USA and possessions $80,
tion. His article will likely inspire many of you to develop new,
November 2011 – Issue 256

Canada/Mexico $110, all other countries $116. All subscription orders payable in U.S. funds only via Visa, MasterCard, interna-
tional postal money order, or check drawn on U.S. bank. Direct subscription orders and subscription-related questions to
more effective detection systems of your own. Circuit Cellar Subscriptions, P.O. Box 5650, Hanover, NH 03755-5650 or call 800.269.6301.

Lastly, Jeff Bachiochi presents the next phase of his innovative Postmaster: Send address changes to Circuit Cellar, Circulation Dept., P.O. Box 5650, Hanover, NH 03755-5650.

fly-by-wire wheelchair project (p. 66). This project represents not Circuit Cellar® makes no warranties and assumes no responsibility or liability of any kind for errors in these programs or schematics or for the
consequences of any such errors. Furthermore, because of possible variation in the quality and condition of materials and workmanship of read-
er-assembled projects, Circuit Cellar® disclaims any responsibility for the safe and proper function of reader-assembled projects based upon or
only the evolution of a novel system design, but also the evolution from plans, descriptions, or information published by Circuit Cellar®.
The information provided by Circuit Cellar® is for educational purposes. Circuit Cellar® makes no claims or warrants that readers have a right to
of more than two decades worth of electronics control technologies. build things based upon these ideas under patent or other relevant intellectual property law in their jurisdiction, or that readers have a right to
construct or operate any of the devices described herein under the relevant patent or other intellectual property law of the reader’s jurisdiction.
The reader assumes any risk of infringement liability for constructing or operating such devices.
Entire contents copyright © 2011 by Circuit Cellar, Incorporated. All rights reserved. Circuit Cellar is a registered trademark of Circuit Cellar, Inc.
Reproduction of this publication in whole or in part without written consent from Circuit Cellar Inc. is prohibited.
[email protected]

4 CIRCUIT CELLAR® • www.circuitcellar.com


5_Layout 1 10/11/11 9:40 AM Page 1
TOC_256_toc.qxd 10/11/11 11:44 AM Page 6

INSIDE ISSUE
18
256
High-Accuracy Voltage Reference
Using PWM (Part 2)
Hardware Design
David Ludington
November 2011 • Analog Techniques

PWM Generator Board p. 18

24 Auditory Navigator
Garrett Phillips, Matthew Kinne, and Nick Annetta

30 Sound Tone Detection with a PSoC (Part 1)


Analog Signal Management
Guido Ottaviani

42 Super Arduino
Getting Started with the chipKIT Max32
Clemens Valens
DesignSpark chipKIT Challenge Primer Tone Detection p. 30

p. 24 Auditory Navigation System

TASK MANAGER 4
Tech Evolution
46 THE CONSUMMATE ENGINEER C. J. Abate
Shielding and Transfer Impedance
George Novacek NEW PRODUCT NEWS 8
54 LESSONS FROM THE TRENCHES TEST YOUR EQ 17
Design Development (Part 4) QUESTIONS & ANSWERS 50
Processors, Power, and Interfacing Embedded Design Theory & Practice
George Martin An Interview with Shlomo Engelberg
November 2011 – Issue 256

60 EMBEDDED UNVEILED CROSSWORD 74


Ionization Detectors
Richard Wotiz INDEX OF ADVERTISERS 79
December Preview
66 FROM THE BENCH
Fly-By-Wire Wheelchair (Part 1) PRIORITY INTERRUPT 80
Beyond Normal Joystick Control To 4G or Not to 4G?
Jeff Bachiochi Steve Ciarcia
6 CIRCUIT CELLAR® • www.circuitcellar.com
7_Layout 1 10/06/11 11:12 AM Page 1

Find It Here. Faster.


The Newest Products for Your Newest Designs®

Scan Here
to Watch Video

Authorized distributor for the most advanced


semiconductors and electronic components.
Get What’s Next. Right now at mouser.com.

Mouser and Mouser Electronics are registered trademarks of Mouser Electronics, Inc.
NPN256_Layout 1 10/11/11 11:49 AM Page 8

HIGH-EFFICIENCY 3-A STEP-DOWN CONVERTER


The AS1328 is high-efficiency 1.5-MHz synchronous DC-DC step-down converter. This buck regulator features efficiencies up
to 96% and a quiescent current of only 25 µA.
The converter delivers up to 3 A of output current at output voltages as low as 0.6 V. It operates from an input voltage of
2.7 to 5.5 V over a –40°C to 85°C temperature range. Fixed-output
voltage versions are available in 50-mV increments. Alternatively, the
output voltage can be set from 0.6 V to the input voltage via an exter-
nal resistor divider. The AS1328 converter incorporates a Softstart fea-
ture to minimize the initial inrush current. It is available with a Power
Okay function or Low Battery Detection signal.
The converter conserves board space by incorporating internal
compensation components as well as two switches with RDS(ON) of
only 35 mΩ . Encased in a 3 mm × 3 mm TQFN package, the
AS1328 features a high fixed-switching frequency of 1.5 MHz,
enabling the use of small surface-mount inductors.
The converter’s input voltage range makes it well suited for appli-
cations powered by a single li-ion battery. A small footprint enables
the AS1328 to be used in portable devices, including medical instru-
ments, mobile Internet devices, and tablet PCs. The AS1328 con-
verter is also useful for applications requiring high currents such as solid-state drives, set-top boxes, base stations, tele-
com and network equipment, FPGA, DDR, and microprocessor core supplies.
The AS1328 costs $1.30 in 1,000-piece quantities.

austriamicrosystems
www.austriamicrosystems.com

ANALOG RESISTIVE USB TOUCHSCREEN CONTROLLER


The AR1100 Analog Resistive Touch Controller is a high-performance, USB plug-and-play device that offers advanced calibra-
tion capabilities as a USB mouse or single-input digitizer. The controller is available as a turnkey chip or board product support-
ing four-, five-, and eight-wire touchscreens, with free drivers for most major operating systems. The AR1100 is designed for
those who want a drop-in touch controller to universally support their entire standard-resistive-touch portfolio.
Touch input is fast becoming a standard user interface.
Resistive touch provides the benefits of easy integration,
low total system cost, and acceptance of finger, glove, or
stylus input. The AR1100 is designed for touch-input
mechanisms such as medical devices, industrial controls,
and handwriting or signature capture.
USB communication is the industry standard for attach-
ing peripherals to a computer. The easy-to-integrate
AR1100 meets all of these needs in a single-chip solution.
It also features advanced calibration options for alignment
and linearization as well as accurate button pressing for
critical applications with tight spacing.
In addition to the AR1100 controller, Microchip announced
enhancements to its AR1000 Analog Resistive Touch-Screen
Controllers, with new high-volume market pricing, a full suite
of drivers—including those for the Windows CE, Linux, and
Android operating systems—and a new 2-V minimum operat-
ing voltage.
The AR1000 targets low-cost embedded applications using I2C, SPI, or UART communications. The controller is available in
20-pin SOIC, SSOP, and QFN packages for $0.95 each, in 10,000-unit quantities. The AR1100 is also available as a board
product for $12 each in production quantities. The mTouch AR1100 Development Kit costs $89.99 and includes an AR1100
production-ready printed circuit board (PCB) with a USB cable and a five-wire, analog-resistive touchscreen.
November 2011 – Issue 256

Microchip Technology, Inc.


www.microchip.com

8
NEW PRODUCT NE WS
CIRCUIT CELLAR® • www.circuitcellar.com
NPN256_Layout 1 10/11/11 11:49 AM Page 9

QTouch CAPACITIVE-TOUCH CONTROLLERS


The QTouch family of capacitive-touch controllers is International Electrotechnical Commission (IEC) and European Standards
(EN) 60730 ready for the home appliance market. IEC/EN 60730 standards cover mechanical, electrical, electronic, EMC, and
abnormal operation of appliances. These certifications ensure safe operation within an appliance if a fault within the system is
detected by shutting it down.
Selecting the right microcontroller increases the ease
of passing the certification, which speeds a products time
to market. With this certification, manufacturers can easily
design household appliances that are IEC/EN-ready with
Atmel capacitive-touch controllers for buttons, sliders,
and wheels.
The QTouch family also features Atmel’s conducted immu-
nity (CI), which is the ability for a device to perform its opera-
tions despite unwanted “noisy” RF voltages and currents car-
ried by external wires and cables.
The QTouch family of capacitive-touch controllers
includes the Atmel AT42QT1244, AT42QT1245,
AT42QT2640, and AT42QT1481. All devices are IEC/EN
60730 Class B certified and include failure mode effect
analysis (FMEA) support to monitor self tests to help ensure that the system is running properly. In addition, all the new con-
trollers include Atmel’s patented Adjacent Key Suppression (AKS) mode which provides precise discrimination between closely
spaced keys and moisture tolerance with Atmel’s patented QMatrix technology for extreme environments. The AKS mode also
supports high button counts through 24-, 48-, or 64- acquisition channels. All Atmel touch controllers are ready to use with-
out microcontroller programming. Configurations are completed through UART, SPI, or I2C interfaces.
Pricing for the Atmel AT42QT1481, AT42QT1244, AT42QT1245, and AT42QT2640 starts at $2.48 for 1,000-piece quantities.

Atmel Corp.
www.atmel.com

NPN
ZZZ:L]QHW7HFKQRORJ\FRP

L(WKHUQHW:)DVW63,(WKHUQHW&RQWUROOHU
‡+DUGZLUHG7&3,3)DVW(WKHUQHW0$&3+<
‡+LJK6SHHG6HULDO3HULSKHUDO,QWHUIDFH 63,0RGH
‡,QGHSHQGHQW+DUGZDUH6RFNHWV
‡,QWHUQDO.E\WHV0HPRU\IRU7;5;%XIIHU
‡3RZHU'RZQ :DNHRQ/$1
‡6PDOO &RPSDFW3LQ4)13DFNDJH L0&8:$6LQJOH&KLS0LFURFRQWUROOHU
‡+LJK3HUIRUPLQJ+DUGZLUHG7&3,30$&3+<
‡,QWHUQDO.%\WHV%RRW520.%\WHV3URJUDP
)/$6+%\WHV'DWD)/$6+.%\WHV65$0
‡,QGHSHQGHQW+DUGZDUH6RFNHWV
‡,QWHUQDO.%\WHV0HPRU\IRU7;5;%XIIHU
‡7ZR3DFNDJH7\SHV/4)34)1

:L])L:L])L8OWUD/RZ3RZHUÕ6HULDOWR:L)LÖPRGXOH
‡4XLFN%RRWLQJ7LPHOHVVWKDQPVHF
‡8OWUD/RZ3RZHUWKURXJK'\QDPLF3RZHU0DQDJHPHQW
November 2011 – Issue 256

‡2SHUDWLRQ7HPSHUDWXUHîaî
‡&()&&.&&&HUWLILHG
‡&RPSDFW6L]H[[ PP
‡:L])L([WHUQDO3RZHU$03VXSSRUWHG

S T E C H N O L O G Y

1)LUVW6WUHHW6DQ-RVH&$86$7(/(PDLOVDOHV#:L]QHW7HFKQRORJ\FRP

www.circuitcellar.com • CIRCUIT CELLAR® 9


NPN256_Layout 1 10/11/11 11:49 AM Page 10

NEW STANDARD FOR USB-CONTROLLED DIGITAL-PATTERN GENERATORS


Byte Paradigm has upgraded the specifications of its entry-level digital-pattern generator. Since September 1, 2011,
the Wave Generator Xpress has been delivered with a large 8-MB internal memory buffer and supports digital-pattern gen-
eration up to 100 MHz. With the specification upgrade, digital electronics engineers now have 500 times more memory
for storing digital vectors and two times the speed of the previous model for pattern generation.
Wave Generator Xpress enables cycle-
accurate 1-to-16-bit-wide digital-pattern gen-
eration. The USB 2.0 device supports 1.5- to
3.3-V LVCMOS I/O standards. It is PC con-
trolled with 8PI Control Panel software, which
includes graphical user interface, TCL/tk
scripting environment, and a free C/C++ API,
which enables more complex and automated
testing.
Possible applications include post-manufac-
turing ASIC/SoC manual bench functional
testing; FPGA, digital board, and DAC input
stimulus generation for functional testing and
debugging; IP validation on a prototyping
board; custom digital interface access; and
VHDL/Verilog design environment-to-board
prototype digital stimuli generation.
The Wave Generator Xpress costs $699.

Byte Paradigm
www.byteparadigm.com

NPN
Low Cost Panel PC
PDX-089T
l Vortex86DX 1 GHz Fanless CPU
l Low Power Consumption
l 1 RS232/422/485 serial port
l Mini-PCI Expansion slot
l 2 USB 2.0 Host Ports
l 10/100 BaseT Ethernet & Audio
l PS/2 mouse & keyboard
l CompactFlash & MicroSD card sockets
l Resolution/Colors: 1024 x 600 @ 256K
2.6 KERNEL
l Resistive Touch Screen
l Linux, Embedded XP or Windows CE OS Options

Setting up a Panel PC can be a Puzzling experience. However, the PDX-089T


comes ready to run with the Operating System installed on flash disk. Apply power
and watch the Windows XPE user interface appear on the vivid color LCD. Interact
with the PDX-089T using the responsive integrated touchscreen. Everything works
out of the box, allowing you to concentrate on your application rather than building
and configuring device drivers. Just Write-It and Run-It... Starting at $450.
November 2011 – Issue 256

For more info visit: www.emacinc.com/panel_pc/pdx089.htm

Since 1985
OVER
24
YEARS OF
SINGLE BOARD
SOLUTIONS

Phone: (618) 529-4525 · Fax: (618) 457-0110 · www.emacinc.com

10 CIRCUIT CELLAR® • www.circuitcellar.com


9_Layout 1 5/11/2011 4:42 PM Page 1
NPN256_Layout 1 10/11/11 11:49 AM Page 12

CLASS-G HEADPHONE & CLASS-D SPEAKER AMPLIFIERS


The FAB1200 headphone amplifier and the FAB2200 audio subsystem are two products designed to make small speakers
in mobile devices—such as smartphones, tablets and multimedia Internet devices—sound louder and better while minimizing
the impact on battery life.
The FAB1200 is a stereo Class-G ground-referenced headphone amplifier with
an integrated buck converter. It features a charge pump that generates a nega-
tive supply voltage. This enables the headphone output to be ground-centered
and capacitor-free, which eliminates up to two external capacitors. An integrated
inductive buck regulator provides direct battery connection and adjusts the sup-
ply voltage between two different levels based on the output signal level in order
to reduce power consumption. The result of these features is reduced systems
cost and extended battery runtime, with a high level of audio quality. Available in
a 16-bump, 0.4-mm pitch, 1.56 mm × 1.56 mm WLCSP package, the device
offers excellent audio performance for better sounding audio headsets and is
ideal for mobile handsets, tablets/MIDs, and MP3 and portable media players.
The FAB2200 is an audio subsystem with a stereo Class-G headphone amplifier
and a 1.2-W Class-D mono speaker amplifier. It combines a capacitor-free stereo
Class-G headphone amplifier with a Class-D speaker amplifier. A proprietary inte-
grated charge pump generates multiple supply rails for a ground-centered Class-G headphone output to reduce power dissipation
and provide a high-power supply rejection ratio. The filterless Class-D amplifier can be connected directly to a speaker without the
need for two external filter networks, which reduces the overall cost of the solution. The device features automatic gain control
which limits the maximum speaker output levels to protect speakers without introducing distortion. It can also dynamically limit clip-
ping as the battery voltage falls. Available in a 25-bump, 0.4-mm pitch, WLCSP package, the FAB2200 is ideal for cellular handsets,
notebook computers, and tablets.
In 1,000-piece quantities, the FAB1200 costs $0.36 and the FAB2200 costs $0.57.

Fairchild Semiconductor
www.fairchildsemi.com

NPN
November 2011 – Issue 256

12 CIRCUIT CELLAR® • www.circuitcellar.com


11_Layout 1 5/10/2011 11:41 PM Page 1
NPN256_Layout 1 10/12/11 1:52 PM Page 14

100-kHz DATA ACQUISITION MODULES PXIe EMBEDDED CONTROLLER


The DT9812A, DT9813A, and DT9814A are three new The M9036A is a modular PXIe embedded controller
low-cost, USB-powered data acquisition (DAQ) modules. designed to take advantage of the x8 PCI Express links
With the multifunction capability of Data Translation’s ECON- when using the Agilent M9018A PXIe chassis. When com-
series, the modules feature USB 2.0 compliance and fast bined, the M9036A controller and M9018A chassis pro-
sampling rates of up to 100 ksps. vide a high-throughput PXI test platform for peer-to-peer
applications.
This platform is capable of integrating legacy PXI instru-
ments into the hybrid slots of the chassis while providing
up to 8 GBps of system bandwidth with dual x8 express
links to handle demanding RF, uW, and streaming applica-
tions, such as transferring data between cards without
involving the controller. The controller can also operate in
a four-link configuration providing compatibility with exist-
ing PXIe chassis.
The M9036A was designed using an Intel Core i5 2.4-GHz
dual-core processor with hyper-threading technology with
Additional features include: power by USB for portable a removable 160-GB solid-state drive and 4 GB of RAM
measurements; 12-bit resolution for analog input/output sub- (upgradable to 8 GB) in the standard configuration. The
systems; 8-, 16-, or 24-SE analog input channels for flexibili- built-in front-panel connectors enable seamless integra-
ty; two analog output channels to generate sine, rectangle, tion with traditional standalone instruments to create
triangle, or DC waveforms; one counter/timer to perform sophisticated hybrid test systems. This is done using USB
event counting, frequency measurement, edge-to-edge and LAN or DVI-I, GPIB, ExpressCard 34, and an SMB trig-
measurements, and to generate continuous-pulse output ger connector.
operations; and digital I/O lines. The modules also include
software and drivers compatible with Windows XP/Vista/7.
The DT9812A costs $475, the DT9813A costs $525, and
the DT9814A costs $575.

Data Translation, Inc.


www.datatranslation.com

The controller module provides a choice of an external


controller or the new embedded controller for integrated,
compact solutions. It is preloaded with operating system,
controller and chassis drivers, soft front panel and Agilent
I/O libraries including VISA, Agilent Connection Expert,
and I/O monitoring. This enables users to quickly commu-
nicate with and control both modular and standalone
instruments.
The M9036A starts at $6,600.
November 2011 – Issue 256

Agilent Technologies, Inc.


www.agilent.com

NPN
14 CIRCUIT CELLAR® • www.circuitcellar.com
53_Layout 1 08/10/11 10:14 AM Page 1
16_Layout 1 10/06/11 11:11 AM Page 1
EQ_256_Layout 1 10/11/11 12:49 PM Page 17

Test Your

Problem 1—Is the signal carried by an “ideal” coaxial cable immune from external electric and magnetic fields?
EQ
Explain.

Problem 2—What happens if you “ground” both ends of the shield of a coaxial cable?

Problem 3—In what ways are real coaxial cables non-ideal?

Problem 4—How does Twinax, a form of shielded twisted pair, address some of the shortcomings of coax?

Contributed by David Tweed

What’s your EQ?—The answers are posted at


www.circuitcellar.com/eq/
You may contact the quizmasters at [email protected]

STATEMENT REQUIRED BY THE ACT OF AUGUST 12, 1970, TITLE 39, UNITED STATES CODE SHOWING THE OWNERSHIP, MANAGEMENT AND CIRCULATION OF CIRCUIT CELLAR,
THE MAGAZINE FOR COMPUTER APPLICATIONS. Published monthly at 4 Park Street, Vernon, CT 06066. Annual subscription price is $45.00. Publisher: Hugo Van haecke. Editorial Director:
Steven Ciarcia. Editor-In-Chief: C.J. Abate. The owner is Circuit Cellar, Inc., Vernon, CT 06066. The names and addresses of stockholders holding one percent or more of the total amount of stock
are: Elektor International Media, LLC, 4 Park Street, Vernon, CT 06066.
EXTENT AND NATURE OF CIRCULATION: Average number of copies of each issue published during the preceding twelve months; (A) total number of copies printed, 18,302; (B.1) paid/request-
ed mail subscriptions, 5,183; (B.3) sales through dealers and carriers, street vendors and counter sales, 3,723; (B.4) paid/requested copies distributed by other mail classes, 10; (C) total
paid/requested circulation, 8,916; (D.1) samples, complimentary, and other nonrequested copies,1,857; (D.4) Nonrequested copies distributed outside the mail, 2,559; (E) total nonrequested distri-
bution (sum of D.1 & D.4), 4,416; (F) total distribution (sum of C & E), 13,332; (G) copies not distributed (office use, leftover, unaccounted, spoiled after printing, returns from news agents), 4970;
(H) total (sum of F & G), 18,302. Percent Paid Requested: 67% Actual number of copies of a single issue published nearest to filing date: (A) total number of copies printed, 15,600; (B.1)
paid/requested mail subscriptions, 5,354; (B.3) sales through dealers and carriers, street vendors and counter sales, 3,318; (B.4) paid/requested copies distributed by other mail classes, 10; (C)
total paid/requested circulation, 8,682; (D.1) samples, complimentary, and other nonrequested copies, 1,832; (D.4) Nonrequested copies distributed outside the mail,1,781; (E) total nonrequested
distribution (sum of D.1 & D.4), 3,613; (F) total distribution (sum of C & E), 12,295; (G) copies not distributed (office use, leftover, unaccounted, spoiled after printing, returns from news agents),
3,305; (H) total (sum of F & G), 15,600. Percent Paid Requested 71%. I certify that the statements made by me above are correct and complete. Hugo Van haecke, Publisher.

$10
.00
each
(Qty 100)

The gridARM™ System on a Chip (SOC) is a high performance, low cost,


low power, highly integrated single chip with 10 / 100 / 1000 Mbps Ethernet,
USB, CAN, Serial, SRAM Memory, SPI, I2C, RTC and internal peripherals
designed to provide a complete solution for embedded applications.

T H E N E T WO R K I N G E X P E RTS
November 2011 – Issue 256

Leaders in the
embedded and
networking
marketplace
providing network
800.975.4743 USA • 1 630.245.1445 hardware, high
quality software
gridconnect.com/gridarm.html and services

www.circuitcellar.com • CIRCUIT CELLAR® 17


2011-11-014_Ludington_Layout 1 10/11/11 12:55 PM Page 18

F EATURE
ARTICLE by David Ludington (USA)

High-Accuracy Voltage Reference


Using PWM (Part 2)
Hardware Design
The first part of this article series covered the basics of pulse-width modulation
(PWM). This article details a hardware design to evaluate practical PWM circuits.
Also covered is the test setup to evaluate the hardware along with performance
test results showing the achieved voltage accuracy.

T his is the second part of a two-part article series


that demonstrates how pulse-width modulation
(PWM) can be used to generate an accurate programmable
voltage reference. In Part 1, I described basic PWM opera-
tion and identified the two PWM parameters (frequency
array (FPGA) where the clock speed is typically higher
than a microcontroller giving shorter cycle times. How-
ever, FPGA design is not as flexible for changing test
conditions. So, for this evaluation, a 16-bit microcon-
troller will be used.
and voltage) that are important for this application. I also The next component is the PWM driver. A single pole,
identified analog parameters (time delays, offset voltages, double throw (SPDT) analog switch seems like an obvi-
bias currents, etc.) of the PWM generator and filter circuits ous choice to switch between 0 and 5 V. However, analog
that need careful attention during the design to minimize
degradation of the output voltage accuracy.
In Part 2, I will be using the analysis developed in Part 1
to select components and also design and fabricate circuit
boards to test this PWM technique. First, I will describe
the hardware design for this project. It consists of a
microcontroller PWM generator circuit board and a filter
board (see Photo 1). Then, I will describe the software
code used for testing reference voltage performance. Final-
ly, I will describe the test setup and present performance
test results.

HARDWARE DESIGN
So far, the discussion has been at a theoretical/concep-
tual level. In this section, we will choose components
November 2011 – Issue 256

and design circuits to evaluate PWM voltage reference


performance. The first component is the PWM genera-
tor. Most modern 16- and 32-bit microcontrollers have
PWM circuits with clock speeds high enough to mini-
mize delays and enough resolution steps to enable a
wide range of test conditions. Another option is to
design the PWM circuit in a field-programmable gate Photo 1—The PWM generator board and filter board

18 CIRCUIT CELLAR® • www.circuitcellar.com


2011-11-014_Ludington_Layout 1 10/11/11 12:55 PM Page 19

Figure 1—A circuit


board with the PWM
generation and driver
circuits I am using to
test the PWM voltage
reference technique

switches are usually designed with a deliberate difference single-stage filter. For a two-stage filter (keeping the total
between on and off time delays to ensure break-before- resistor and capacitor values the same) the resistors would
make operation which could create a significant voltage be 500 kΩ and the capacitors would be 0.5 µF. This creates
offset. Another possibility is to use a high-speed MOSFET a corner frequency for each filter section four times higher
driver instead. It is used as a low-resistance SPDT switch than a single-stage filter and the corresponding attenuation
with more evenly matched delay times. For this project a four times lower. However, the attenuation of each individ-
MOSFET driver will be used. ual filter stage (25) is multiplied together to give a total fil-
The design of the low-pass filter requires tradeoffs ter attenuation of 625 (56 dB).
between the number of filter stages, the component values, In this project I decided to go with a three-stage filter
and the buffer amplifier parameters. The performance goal with the total filter resistance less than 1 MΩ, but using
for the low-pass filter is to maximize filter attenuation at three 1-µF capacitors with a total capacitance of 3 µF
the PWM frequency while at the same time causing the since the capacitor leakage current should have less
least degradation of the DC output voltage. In general, a impact on the output voltage than the amplifier bias
multistage filter will give better performance than a single- current.
stage filter. The choice of component values for the multi- Figure 1 is a schematic of a circuit board with the
stage filter depends on which parameter (capacitor leakage PWM generation and driver circuits I am using to test the
or buffer amplifier input bias current) affects the output PWM voltage reference technique (the schematic also
voltage the most. contains other circuits that are not being used in this
For example, using a 1-MΩ resistor and 1-µF capacitor, application). A Microchip Technology dsPIC30F2011 digi-
the single-stage filter time constant is 1 s and the filter cor- tal signal controller is used to generate the PWM test
ner frequency is 0.16 Hz. If the PWM frequency is 16 Hz, waveforms. The timers in this microcontroller are 16 bits
then the filter corner frequency is 100 times lower than the with a prescalar divider. This provides a lot of flexibility
PWM frequency and the attenuation is 100 (40 dB) for a in generating the test waveforms. There are two PWM
November 2011 – Issue 256

Figure 2—The filter board

www.circuitcellar.com • CIRCUIT CELLAR® 19


2011-11-014_Ludington_Layout 1 10/11/11 12:55 PM Page 20

circuits, OC1 and OC2, which are Listing 1—Code for Microchip Technology’s dsPIC30F2011 microcontroller
output on pin 10 and pin 15, respec-
tively. The PWM signals are sent to a #include “p30F2011.h”
Microchip Technology TC4427A
_FWDT(WDT_OFF);
dual MOSFET driver. The output _FOSC(CSW_FSCM_OFF & FRC); //FRC directly
FETs in this driver have low on-
resistance to VSS and VDD and are nor- int main(void)
mally used to drive large-capacitive {
IFS0bits.T2IF = 0; //clear interrupt flag
loads. In this application I am using IEC0bits.T2IE = 1; //set interrupt enable bit
this capability to provide a low-
resistance source with matched PORTC = 0x0000; //Set PORTC output
delay times to the PWM filters. Also, TRISC = 0x1FFF; //Set PORTC pin directions
the resistance values of the two out- OC2CON = 0x0000; //Set OC2 parameters
put FETs are closely matched which OC2RS = 0x0000; // :
will minimize offset voltages in the OC2R = 0x0000; // :
filtered output. OC2CON = 0x0006; //Use Timer2
The outputs of the dual driver go TMR2 = 0; //Timer2 = 0
to connector J7 and also to the inputs PR2 = 49999; //Timer2 period
of two single-stage filters consisting T2CON = 0x8000; //Timer2 on
of resistor R6 and capacitor C7 for
while(1)
the first filter and resistor R5 and {
capacitor C6 for the second filter. }
These filter outputs are connected to
the inputs (at pin 3 and pin 5) of two return 0;
}
buffer amplifiers in a Microchip
Technology MCP607 dual-opera- void __attribute__((interrupt)) _T2Interrupt(void)
tional amplifier. {
The on-board filter circuits (see PORTCbits.RC14 = 1; //Turn on marker pulse
OC2RS = 9000; //Set OC2 duty cycle
Photo 1) were used in the initial test- IFS0bits.T2IF = 0; //Clear interrupt flag
ing, but as the PWM frequency was PORTCbits.RC14 = 0; //Turn off marker pulse
lowered to improve accuracy, these }
single-stage filters did not provide
enough filtering and a separate cir- SOFTWARE DESIGN of the program is used to change the
cuit board with a three-filter stage The software code used in the clock frequency. The internal oscilla-
was added (see Figure 2). The input dsPIC30F2011 microcontroller to tor in the dsPIC30F2011 microcon-
for this filter comes from the OC2 evaluate the performance of the troller nominally runs at 7.37 MHz
PWM circuit (J7, pin1) in Figure 1 PWM voltage reference is shown in and the instruction clock is the
into another MOSFET driver U1 in Listing 1. The board I was using did oscillator divided by four. The PR2
Figure 2. This driver uses a more pre- not have any interfacing circuits, so variable sets the Timer2 period and
cise reference voltage provided by a for these first tests, I hard coded val- determines the number of steps in
Linear Technology LT1236 voltage ues into the program and recompiled the PWM waveform (PR2 + 1). The
reference chip. The driver output on them whenever I needed to change T2CON variable, which sets the
pin 7 of U1 goes to the three-stage the PWM waveform or clock fre- T2CON register, includes bits to set
filter that consists of resistors R3, quency. In the future, I plan on the prescalar division ratio and lower
R4, and R5 and capacitors C1, C2, using a printed circuit board (PCB) the Timer2 clock relative to the
and C3. The output of the filter is that includes a PS/2 keyboard inter- instruction clock. The MSb of the
buffered by a Linear Technology face and a serial port connection to T2CON register turns Timer2 on or
LTC1151 op-amp which has very low the computer. off. The PORTCbits.RC14 variable
offset voltage. The _FOSC macro at the beginning in the interrupt routine is used to
turn a pulse on and off every time
the Interrupt routine is called. The
November 2011 – Issue 256

length of time spent in the interrupt


Oscilloscope Frequency counter routine can be determined by meas-
uring the pulse width on an oscillo-
scope or frequency counter.
PWM Generator
Filter board 6.5-Digit voltmeter
Figure 3—Voltage reference
board
VOLTAGE REFERENCE TESTING
evaluation test setup The setup for testing voltage reference

20 CIRCUIT CELLAR® • www.circuitcellar.com


69_Layout 1 8/31/2010 2:24 PM Page 1

! " %%# ! ! * *%('

www.DevtoolsXpress.com

Pick a Tool.
Any Tool.
Find the Right Development Tool, Compare it to Other Tools, Evaluate It,
and Buy It from Digi-Key Tools Xpress -- Without Leaving Our Site.

The Digi-Key Tools Xpress Digi-Key Tools Xpress, engineered


intuitive research engines are by Embedded Developer, is the
used by engineers worldwide to only site in the industry where
locate, compare and evaluate engineers can quickly find,
hardware or software compare and buy the leading
development tools. development tools.

Compare before you buy: tools are


listed side-by-side, with features and
performance specs, availability, and prices,
so you can make an educated decision!

FIND. COMPARE. BUY.


2011-11-014_Ludington_Layout 1 10/11/11 12:55 PM Page 22

FPGA/CPLD Stamp Module PWM Parameters* Data


PLCC68 Series Expected Measured Full-scale
Easy and Quickly Mountable Module PR2 OC1RS #Steps VREF
voltage voltage error %
FPGA Module PLCC socket mountable 4 1 5 5.00057 1.00011 0.93039 1.4
‡,2V(([WHUQDOFORFNLQSXWV
49 10 50 5.00086 1.00017 0.99322 0.14
DUHDYDLODEOH)
‡9VLQJOHSRZHUVXSSO\ 499 100 500 5.00089 1.00018 0.99939 0.016
RSHUDWLRn(9ROWDJHFRQYHUWHUVIRUDX[LOLDU\ 4,999 1,000 5,000 5.00099 1.0002 1.00006 0.0028
SRZHUVXSSO\DUHEXLOWLQ)
‡6HSDUDWHGVXSSO\LQSXWVSRZHU,2GULYHUV 49,999 10,000 50,000 5.00089 1.00018 1.00009 0.0018
‡-7$*VLJQDO * Timer2 clock = 1.827 MHz
‡$OO3/&&VHULHVKDYHFRPPRQSLQ
DVVLJQPHQW Table 1—Full-scale error versus number of PWM steps
‡9HU\VPDOOVL]H [>PP@)
‡5R+6FRPSOLDQFH
‡0$'(,1-$3$1 performance is shown in Figure 3. The voltage was first measured. Then an
oscilloscope and frequency counter expected output voltage based on
XILINX PLCC68 Series were used during the initial debug of that measured value, PR2 and
XP68-01 Spartan-6 PLCC68 FPGA Module the circuits to verify correct operation OC1RS, was calculated and com-
and during the performance testing to pared to the measured PWM output
XC6SLX16-2CSG225C
16Mbit Configuration SPI-ROM verify that the PWM and rate matched voltage. The first performance evalu-
Two User LEDs
the PR2 and OC1RS parameters for ation I performed used a fixed low-
One User Switch(Slide)
RoHS compliant the selected voltage output. resolution five-step PWM period
The main instrument used for (PR2 = 4), a minimum-pulse width
XP68-02 Spartan-3AN PLCC68 FPGA Module
evaluating performance was a (OC1RS = 1), and varied the clock
XC3S200AN-4FTG256C Datron 1081 digital multimeter with rate into the PWM generator. At
FPGA internal configuration ROM a full scale count of 1,999,999. This higher clock rates, the filtered out-
Two User LEDs
RoHS compliant
enables the use of just one voltage put voltage (nominally 1 V) was not
scale (10 V) to measure both the that precise. The precision increased
PWM reference voltage and the as the clock rate was lowered (the
ALTERA PLCC68 Series derived output voltage with seven whole data set is not shown here,
digits displayed. Thus, the full 5 V is except for one value which is the
AP68-01 MAX II PLCC68 CPLD Module
displayed along with showing the first entry in Table 1).
EPM240F100C5N digit. For the second test, I fixed the
EPM570F100C5N The LT1236 voltage reference with- PWM clock rate at 1.827 MHz (the
External Clock inputs
RoHS compliant out any adjustment had a no-load out- dsPIC30F2011 internal RC clock
put voltage of approximately 5.0015 V. rate divided by four) and changed the
AP68-02 MAX V PLCC68 CPLD Module I loaded the output with an 832-Ω PR2 and OC1RS values to maintain
resistor and the voltage dropped to a nominal 1-V PWM output while
5M570ZF256C5N about 5.00085 V and drifted between increasing the resolution. This data
External Clock inputs
On-board Voltage regulator
5.00057 and 5.00099 V with time and is shown in Table 1. Similar results
RoHS compliant room temperature changes. to the first test were obtained. As
When data was taken, the reference the pulse width and period were
AP68-03 Cyclone III PLCC68 FPGA Module

EP3C5U256C8N
EP3C10U256C8N Nominal voltage Expected voltage Measured voltage Full­scale error (%)
4Mbit Configuration ROM
Two User LEDs 0.5 0.500085 0.49999 0.0019
One User Switch(Slide)
RoHS compliant
1 1.00017 1.00006 0.0022
1.5 1.500255 1.50018 0.0019
Over 100 varieties of FPGA/CPLD
boards are available. 2 2.00034 2.00018 0.0032
2.5 2.500425 2.50027 0.0031
November 2011 – Issue 256

3 3.00051 3.00035 0.0032


See all our products at: 3.5 3.500595 3.50044 0.0031
www.hdl.co.jp/CC/ 4 4.00068 4.00052 0.0032

HuMANDATA LTD. 4.5 4.500765 4.50062 0.0029


E-mail: [email protected] * 50,000 PWM steps
Fax: 81-72-620-2003
Table 2—PWM voltage reference performance data*

22 CIRCUIT CELLAR® • www.circuitcellar.com


2011-11-014_Ludington_Layout 1 10/11/11 12:55 PM Page 23

increased (lower effective PWM David Ludington ([email protected]) is a retired electrical engineer with
rate), the accuracy of the filtered experience in low-noise analog design and infrared system design. He earned a
output voltage increased. BSEE at Michigan State University and an MSEE at Syracuse University.
The final performance test results
are shown in Table 2. Here the PWM
clock is 1.827 MHz and the PR2 peri- SOURCES
od is 49,999. The OC1RS variable was 1081 Digital multimeter
changed to generate different output Datron Connection | www.datronconnection.com
voltages and evaluate performance LT1236 Precision reference and LTC1151 op-amp
across the output voltage range. Linear Technology Corp. | www.linear.com

ACCURACY & PERFORMANCE dsPIC30F2011 Digital-signal controller, TC4427A dual MOSFET driver,
The data in Table 1 and Table 2 and MCP607 dual-operational amplifier
show that a programmable voltage Microchip Technology, Inc. | www.microchip.com
using a PWM digital-to-analog con-
verter (DAC) can be highly accurate.
The full-scale error of the output volt-
age is less than 0.004% over the entire
voltage range. With a 5-V reference
and 50,000 PWM steps, the minimum
step size is 100 µV. Any voltage
between 0 and 5 V with 100-µV reso-
lution can be obtained simply by
changing the OC1RS variable to a
value between 0 and 49,999. Thus, for
a low cost, you can add a high-preci-
sion programmable voltage reference
generator to your collection of test
instruments.
The only negative is that to achieve
this accuracy and resolution, the PWM
rate is only 36.5 Hz. This means that
to get greater than 100 dB of attenua-
tion in the filter requires multiple
stages and large-value components. In
the future, I plan to investigate imple-
menting the PWM generator in a
FPGA. Since almost any modern FPGA
can be clocked well above 100 MHz,
the digital delays and rise/fall times
should be less than from a microcon-
troller which is clocked at a lower rate.
This should enable a higher PWM
clock frequency than 1.827 MHz and
PWM rate of 36.5 Hz while still giving
the performance shown in Table 2.
This two-part article has demon-
strated that PWM can be used to
generate an accurate programmable
voltage reference of less than 0.01%
full-scale accuracy. The present data
November 2011 – Issue 256

shows that the output voltage is still


a little lower than the expected volt-
age. I hope to investigate this error
in future work. I also have several
ideas on improvements to minimize
capacitor leakage and increase the
PWM rate. I

www.circuitcellar.com • CIRCUIT CELLAR® 23


2011-11-016_Phillips_Layout 1 10/11/11 1:42 PM Page 24

F EATURE
ARTICLE by Garret Phillips, Matthew Kinne, and Nick Annetta (USA)

Auditory Navigator
You can build an auditory navigation system that mimics a natural biological function
to guide a human. This innovative design uses a GPS, a digital compass, and a
microcontroller to generate sound based on the direction a user must turn in order
to face a determined direction.

N avigation in the past has primarily relied on the


use of a map, a compass, or another device that
must be visually interpreted. This project demonstrates the
ability to navigate a user based on synthesized directional
audio that enables the user to move to a known location
time and varied in amplitude to give the user the sensation
that the noise is coming from the target location.

THEORY & DESIGN


Sound perceived by the human ear includes a mixture
without the use of a visual aid (see Photo 1). The module of several spatial auditory cues such as pinna response,
uses a global positioning system (GPS), a digital compass, interaural time delay (ITD), and shoulder echo. When
and an Atmel ATmega32 microcontroller to generate sound creating 2-D sound, only the ITD needs to be replicated
based on the direction a user must turn in order to face a because it is the feature that enables humans to track
determined direction. A schematic is shown in Figure 1. sound across the horizon. The ITD is defined as a phase
Once the GPS has a lock, the system calculates the angle shift that occurs as a sound reaches the left ear and the
to the destination using the current latitude and longitude right ear at different times.[1] The phase shift is based
data. The compass then determines which direction the upon the position of the sound source relative to the lis-
user’s head is facing relative to magnetic North. These two tener and the diameter of the user’s head. If the speed of
angles are used to find the final direction (angle) relative to sound is approximately 13.2”/ms and the user’s head is
the user’s direction and produce a sound relative to the dif- 6.2” wide, then the maximum interaural delay would be
ference. The left and right sound channels are delayed in about 463 µs.[2] The maximum delay would occur if the

a) b)
November 2011 – Issue 256

Photo 1a—The final device doesn’t look too pretty, but it worked great. b—Notice the push buttons and LCD screen attached right to the top
of the device making it compact and easy to use.

24 CIRCUIT CELLAR® • www.circuitcellar.com


2011-11-016_Phillips_Layout 1 10/12/11 1:56 PM Page 25

sound source were posi-


tioned 90° from the
user’s nose.
The equation for calcu-
lating the phase difference
based upon the position of
the sound source is shown
in Figure 2. The quantities
v and h are the speed of
the sound in air and the
width of the observer’s
head, respectively.[3] The
angle is taken with respect
to the nose of the observer.
The amplitudes of the
sound waves between the
two ears are varied to
recreate the head shadow
that occurs at the ear
opposite from the sound
source. The head shadow
has a higher attenuation
at frequencies greater than
1 kHz. The PWM is run-
ning at 62,500 samples per
second, which is an out- Figure 1—The schematic includes an Atmel ATmega32 microcontroller, a GPS, a compass, and supporting
put frequency of at about circuitry. The entire device runs off a 9-V battery, which is regulated down to 5 V. A couple of general-
244 Hz for an 8-bit DAC. purpose amps are used to control the volume in each ear.
Therefore, the attenuation
should only be 2 to 3 dB.[4] the user hears the sound pulses. Once ATmega32. Timer1 on the device
Figure 3 shows a high-level diagram the GPS has a lock, the system deter- was used to control the timing of the
of the system. Upon initial startup, the mines the bearing (angle from true function and three general-purpose
user selects from a number of prede- North) the user must travel to get to input/output (GPIO) pins were used
fined locations through the use of an the destination. This angle is compared for the controls. A compare interrupt
LCD screen. We use a GPS and a digi- with the compass output and a sound was used to generate the clock and
tal compass to determine at what angle is made based on which direction the data. This enabled the
user must turn to face the final transmission/receive rate to be set at
location. The sound consists of a fine resolution resulting in the
North short pulses of different ampli- fastest possible operation. The clock
Target tudes that are delayed between signal was generated at twice the
Soun
directi d
on
location the right and left side to give data rate so data could be clocked on
θ
the effect of direction. both the rising and falling edge. We
ec tion B ear wanted to keep this function as gen-
Dir pass] [GP ing
[Co
m S] HARDWARE eral as possible in case we needed to
The digital compass module use it for future projects.
we used was a Hitachi HM55B To get data, the ATmega32 pulses
from Parallax, mainly because the Enable bit high for two clock
it was around from previous cycles, then sends 0b0000 on the
projects. The communication shared data_in and data_out line.
θ = ωh sin θ/V between this device was done After another enable toggle, 0b1000
with three wires (clock, data, gets sent to the compass signifying a
November 2011 – Issue 256

and enable) in a SPI-like fash- “start measurement” command. The


h ion. The communication is ATmega32 then sends 0b1100 and
based on the Basic Stamp reads in 4 bits waiting for the data con-
Figure 2—The compass and GPS data are used to function SHIFTIN/SHIFTOUT, version to be done. When the compass
determine an angle from true North. The phase dif- which is a two-wire communi- sends back 0b1100, the data is ready.
ference equation is also shown, which is determined cation. The challenge was to The ATmega32 then clocks in 22 bits
by the width of a human head. implement this in C for the (11 for x value, and 11 for y value) of

www.circuitcellar.com • CIRCUIT CELLAR® 25


2011-11-016_Phillips_Layout 1 10/11/11 1:42 PM Page 26

Get desired location


The data from the RMC
sentence is written to a
User Find direction to destination
interface string buffer. Knowing the
Direction Find direction relative to user Make analog Produce sound to user
format of the RMC sen-
calculator
tence, we use the sscanf
Difference Audio LP Filter
GPS in directions synthesizer
Headphones function to extract the lon-
LP Filter
Compass
gitude and latitude. The
Get current location
Build soundwaves digitally
longitude and latitude are
Get current direction
sent in the format
DDMM.MMMM where DD
Figure 3—The flow is straightforward starting with the GPS data, followed by the compass data, and finally
out to the headphones. is in degrees and
MM.MMMM is in minutes.
We parse the data and recal-
two’s complement data most-significant bit (MSB) first. culate the values in terms of only degrees. It should also be
After formatting the data to get the proper sign, the arctan- noted that when writing to the string buffer, we ignored deci-
gent of x/–y is used to get the resulting angle (from magnet- mal points due to difficulties with sscanf reading in floating-
ic North). This is then converted from radians to degrees point numbers on the microcontroller. In order to compen-
and compensated for the difference between true and mag- sate for this, we scaled the longitude and latitudes appropri-
netic North (subtracting 12° where we are, in Ithaca, NY). ately during the conversion into degrees and then radians.
The whole function takes 60 ms to run. We determined this The following equation was used to calculate the direction
was fast enough compared with how quickly the human from the user’s current location to the final destination:
head can turn.
 sin(∆long) × cos(lat2), cos(lat1) × sin(lat2) −
θ = atan2  
 sin(lat1) × cos(lat2) × cos(∆long)
GPS COMMUNICATION
We chose the Parallax PMB-248 GPS receiver because it where lat1 = current latitude, lat2 = target latitude, and
was relatively inexpensive and was readily available. We dlon = difference in current and target longitude.[5]
used interrupt-driven serial communication over the
USART to receive data from the GPS receiver. The GPS SOFTWARE
receiver outputs NMEA sentences approximately once a The directional “beeps” the user hears are short bursts
second at 4,800 bps. An example of one packet of NMEA (approximately 20 ms) that are sine waves with varying
sentences is shown in Figure 4. amplitudes produced at 244 Hz. Direct digital synthesis
There are several cases of redundant data between (DDS) is used to create these sine waves through the use
NMEA sentences and, for the purposes of this project, we of pulse-width modulation (PWM) on the ATmega32. The
only need one set of longitude and latitude. We decided to amplitudes of the sine waves are also ramped linearly
only read in the recommended minimum content (RMC) from zero to full scale (and vice versa on the other end)
sentence as a string and then extract the longitude and lati- in an attempt to reduce the high-frequency “pop” that is
tude from that string. generated from a sharp transient edge.
We use the USART character-ready interrupt which trig- The PWMs from Timer0 and Timer2 are used to generate
gers as soon as a full character is received by the USART sound pulses. Each timer is set to operate in fast PWM mode
buffer. Once a character is ready in the USART buffer, the with a prescaler of one, giving the PWMs a sample rate of
ISR writes the character to a string buffer and enters a state 62,500 samples per second. The overflow interrupts of each
machine. The state machine successively checks for the timer are used to update the output compare registers
characters that are expected to be seen at the beginning of (OCRs). The OCR indicates the top value or the value of the
the RMC sentence. If the program does not receive the timer counter (TCNT0) that causes another interrupt.
expected header characters, it returns to the beginning of Initially, Timer1 of the ATmega32 was used to generate
the state machine. If the input characters are $, G, P, R, M, two PWM waveforms. The idea was that since Timer1 has
and C in succession, the program records the rest of the sen- two output compare registers, it should be able to generate
tence as data. The sentence is terminated with \n. two PWMs. Timer1 was able to generate two PWMs, but
since OCR1A was used as the top value and
the PWM waveforms were not unique, the
$GPGGA,144739,4251.9960,N,07806.0827,W,1,04,5.6,1898.0,M,34.5,M,,*61 outputs of OCR1A and OCR1B toggled when-
November 2011 – Issue 256

$GPRMC,144739,A,4251.9960,N,07806.0827,W,1908.5,270.0,050510,5,E,A*2F ever the overflow interrupt was triggered.


$GPGSV,8,1,32,01,12,205,-18,02,43,251,14,03,08,022,-22,04,05,271,00*75 Using two timers prevented the overflow
$GPGSV,8,2,32,05,78,032,45,06,83,236,48,07,81,084,47,08,64,206,33*71 interrupt from toggling both pulses and also
$GPGSV,8,3,32,09,90,086,52,10,42,202,13,11,26,284,-4,12,88,117,51*6C enabled one timer to be used as a clock based
$GPGSV,8,4,32,13,90,027,52,14,68,030,37,15,78,143,44,16,60,220,30*7E on when an interrupt was triggered.
The DDS process consists of a sine function
Figure 4—Example of a packet of NMEA sentences quantized into a 256-entry table and a ramp

26 CIRCUIT CELLAR® • www.circuitcellar.com


2011-11-016_Phillips_Layout 1 10/11/11 1:42 PM Page 27

Sine versus linear delay


500 ms

400 ms
Sine delay
300 ms Linear delay

200 ms YE AR

100 ms

0 ms
Delay
–100 ms PicoScope® 4262
HIGH-RESOLUTION OSCILLOSCOPE
–200 ms

A Digital Oscilloscope for the Analog World


–300 ms

PICOSCOPE 4000 SERIES


–400 ms

–500 ms
0˚ 50˚ 100˚ 150˚ 200˚ 250˚ 300˚ 350˚ 400˚
Sound source angle

Figure 5—These are the two different delay functions used. The idea was to get more infor-
mation to the user in the small angle facing forward.

table to linearly increase or decrease user bases his heading upon. Sound
wave amplitude. Two more tables were sources extending beyond ±15 degrees

16 bit
used to represent the phase offset and do not have to be as accurate because
amplitude of the wave for a given angle the user will intuitively turn his head
representing the sound location. These to gain a more accurate indication of
tables are precomputed to prevent the location of the sound source. The
extra computation during execution. difference between increasing the
Low noise f Two channels
The phase offset table is used to rep- phase linearly versus sinusoidally can
16 MS buffer f 16-bit resolution
resent the delay that is present at each be seen in Figure 5. By using a linear 10 MS/s sampling f 5 MHz bandwidth
degree. It was constructed to achieve model, as opposed to a sinusoidal Advanced digital triggers
no offset at a zero-degree heading (the model, we gain better resolution in Low-distortion signal generator
Arbitrary waveform generator
source is directly in front of the user) the ±15° range that is most important.
USB powered
and maximum offset at 90° or 270°. If
the sound source is behind the user, INTEGRATION & TIMING
then the channel of the ear furthest Timing the entire system was a Analyze:
from the source will be fully delayed, challenge as the data from the GPS t"VEJP
encouraging the user to turn his or her module was continuous and the t6MUSBTPOJD
head to better discriminate the loca- amount of data received from it t7JCSBUJPO
tion of the sound. depended on how many satellites were t%JTUPSUJPO
We mimic the head shadow by differ- locked on. This meant that we had to t/PJTF
ing the amplitude of the sound waves receive GPS data, get the compass
t1PXFS4VQQMJFT
between the two ears so that full inten- data, do the calculations, and output
t"OZUIJOH8IFSF
sity is delivered when the user faces the the audio all before the new GPS
source with a 0° difference. As the user packet was received. The three parts
)JHI"DDVSBDZJTB.VTU
rotates away from the source direction, (GPS, compass, and audio) were all
the amplitude of the PWM wave chan- run off of separate interrupts that each
nel furthest from the source is reduced had their own timer. They were all
while the closer channel maintains full staggered from one another so they
intensity. would not overlap.
November 2011 – Issue 256

According the equation in Figure 1, We start the timing on the first


the phase difference between the ears packet received from the GPS and let
should vary sinusoidally. However, for the USART interrupt run until the Call Us At:
this project, the phase difference entire RMC sentence is received.
varies linearly. Accuracy is most Once the RMC sentence is received,
1-800-591-2796
important for angles directly in front we turn off the USART interrupt so
of the user because that is what the we don’t interrupt all the characters of
www.picotech.com/pco460

www.circuitcellar.com • CIRCUIT CELLAR® 27


2011-11-016_Phillips_Layout 1 10/11/11 1:42 PM Page 28

screen and push buttons. Once the GPS got a satellite lock,
users understood that they needed to follow where the
beeps were coming from with almost no instruction.
The device was tested on multiple students with the final
test directing Dr. Bruce Land, a senior lecturer in Electronics
and Computer Engineering, from the Engineering Quad to
the Big Red Barn—approximately 0.4 miles (see Photo 2).
Without giving him instruction as to how the device worked,
he was able to get within a meter of the desired location. The
end point was apparent to him because the device began to
circle around the desired location. Videos of his voyage can
be found on the ECE 4760 course website (see Resources).

FOLLOW THAT SOUND


The inspiration for this project was the idea that we could
mimic a natural biological function in order to guide a
human in a way that is simple for the user to understand,
without requiring any thinking to distract the user from
other tasks. The hope was that the user would instinctively
Photo 2—Dr. Bruce Land on his trek to an unknown destination.
understand what the system was trying to communicate.
We’re happy to note that he got within a meter or so of the actual
location. From the looks we received from other students, we nick- We were pleased to see that exact outcome when testing
named the device “the nerd helmet.” the system. This was best exemplified by a student who
happened to be passing us by outside while we were holding
the device. When he inquired about it, we simply told him
the other NMEA sentences. We then enable the inter- to put it on (see Photo 3). Without giving him any context
rupts for the compass function which takes approximate- of the situation, he immediately turned and pointed to
ly 60 ms. As soon as the compass function ends, the where the sound was coming from, even though we never
sound function and its interrupts are run. The sound mentioned that there was a direction that he should be try-
function will vary in length based on its output, but it ing to find. It just seemed like his natural instinct to
should never take more than 150 ms. We then repeat the respond in the way that he did.
compass and sound functions again before turning on the
USART interrupt, which will wait for the next RMC sen-
tence. Running the compass and sound functions twice a)
leaves enough time for the USART to be enabled before
the next RMC sentence arrives. This also enables two
sound pulses per second, which is more than enough to
get a good sense of direction.
We used two active low-pass filters to produce the two
lines of audio signals from the two PWM outputs. We
made the filters active so they could drive the headphones.
The wire routing was kept as compact as possible, meaning
that data lines ran close to the audio, introducing a lot of
noise. Using a custom printed circuit board (PCB) could
remedy the problem, but that was out of the scope of this
project. A potentiometer was used on each channel for the
user to calibrate the volume upon start-up, ensuring equal b)
volumes when pointing to the destination. Also, an LCD
screen was used to select the initial destination. This was
done with three buttons: Screen up, Screen down, and
Select. These were implemented active low with a 10-kΩ
pull-up resistor and a 330-Ω resistor current protection.
November 2011 – Issue 256

TESTING & RESULTS


The results of the project were successful. A GPS pro-
gram on a smartphone was used to get desired GPS coordi-
nates that were then programmed into our device. This
enabled the user to select between a few different points Photo 3a—Two students are using the GPS to direct a random stu-
around the Cornell campus through the use of the LCD dent (b) who is wearing the “nerd helmet.”

28 CIRCUIT CELLAR® • www.circuitcellar.com


2011-11-016_Phillips_Layout 1 10/11/11 1:42 PM Page 29

Moving forward, it’s easy to imagine that many different features could be Wireless…
without
added to this, one being a more pleasing sound, such as a prerecorded voice.
Also, waypoints could be added, as currently, the user is directed “as the crow
flies.” It is also possible to add a vertical axis that would enable the user to
hear sound in three dimensions, not just two. Our sound model currently lim-
its us to the 90°-to-270° range for the heading. Although it is not necessary, it
the high
would be an interesting but challenging improvement to add a complete 360°
range. With a larger budget and more time, we would use a faster microcon- power
troller to make the sound interval faster and smoother so the user can move
faster and receive updates more quickly. I consumption!
Garret Phillips ([email protected]) received a BS in Microelectronic Engineer-
ing from Rochester Institute of Technology and an MEng in Electrical Engineering
from Cornell University. He is an analog IC design engineer at Intel in Chandler,
AZ. Garret’s technical interests involve designing against non-ideal processing
effects in tomorrow’s CMOS technologies. In his spare time, he enjoys home
brewing and developing embedded systems.

Matthew Kinne ([email protected]) is a Cornell University graduate, embedded


programmer hobbyist, and devoted runner.
Not all wireless applications
Nick Annetta ([email protected]) earned a Bachelor’s degree from University of require a robust power
Pennsylvania and a Master’s degree from Cornell University, both in Electrical supply. That’s where Anaren
Engineering. He designs medical devices at Battelle and is a devoted pasta eater. Integrated Radio (AIR)
modules come in!
> Industry’s easiest, most cost-
PROJECT FILES
To download the code, go to ftp://ftp.circuitcellar.com/pub/Circuit_Cellar/
effective RF implementation
2011/256. > Low-power RF solution
> Virtually no RF engineering
REFERENCES experience necessary
[1] L. Rayleigh, “On Our Perception of Sound Direction,” Philosophical
Magazine, 1907.
> Tiny, common footprints
> Pre-certified/compliant:
[2] National Aeronautics and Space Administration, “Speed of Sound,”
FCC, IC, ETSI (as applicable)
www.grc.nasa.gov/WWW/K-12/airplane/sound.html.
> Choice of modules based
[3] University of California Davis, Department of Electrical and Computer
on TI CC11xx and CC25xx,
Engineering, “Psychoacoustics of Spatial Hearing,” http://interface.cipic.
low-power RF chips:
ucdavis.edu/sound/tutorial/psych.html.
433MHz, 868MHZ (Europe),
[4] F. Zeng, A. Popper, and R. Fay, Cochlear Implants: Auditory Prostheses 900MHz, 2.4GHz
and Electric Hearing, Springer, 2004.
To learn more, write
[5] Movable Type Ltd., Movable Type Scripts, “Calculate Distance, Bearing [email protected], visit
and More Between Latitude/Longitude Points,” www.movable-type.co.uk/ www.anaren.com/air,
scripts/latlong.html. or scan the QR ONLY

RESOURCE
code with your
smart phone.
$ 99
9
FOR 10K OR
MO RE!
Cornell University, School of Electrical and Computer Engineering, ECE
4760: Designing with Microcontrollers Final Projects, http://people.ece.
cornell.edu/land/courses/ece4760/FinalProjects/#s2010.
November 2011 – Issue 256

SOURCES
ATmega32 Microcontroller 800-411-6596
Atmel Corp. | www.atmel.com www.anaren.com
In Europe, call +44-2392-232392
Hitachi HM55B Compass module graphical viewer software and PMB-248 Available from:
GPS receiver
Parallax, Inc. | www.parallax.com

www.circuitcellar.com • CIRCUIT CELLAR® 29


2011-10-015_Ottaviani_Layout 1 10/11/11 1:45 PM Page 30

F EATURE
ARTICLE by Guido Ottaviani (Italy)

Sound Tone Detection


with a PSoC (Part 1)
Analog Signal Management
The first part of this two-part series details the hardware part of an audio sensor. You
learn how to mount the component to a printed circuit board (PCB) and configure the
internal hardware modules to manage an analog signal.

M y Rino robotic platform is continuously evolving.


Being a development platform it will, perhaps,
never be completed (www.guiott.com/Rino/index.html).
As shown in my “Robot Navigation and Control” article
series (Circuit Cellar 224 and 225, 2009), the platform can
The PSoC is quite different from the usual microcon-
troller, CPU, or FPGA. It flashes a program inside to per-
form some tasks but it’s not just a microcontroller. It
mixes different electronic functional blocks, but it’s not
an FPGA. Its unique feature is that it has the potential to
autonomously navigate in an unknown environment. In “A modify an analog signal keeping it analog and the charac-
Sensor System for Robotics Applications” (Circuit Cellar 236, teristics of the analog blocks can be modified on-the-fly
2010), I explained how to build a dedicated subsystem to by the program. You have the alternative to use a digital-
discover an obstacle on a robot path and find some targets signal controller to sample your analog signal and apply
using popular sensors readily available on the market. Now
I want to focus on a specific kind of sensor, the most com-
plicated one for people who are used to designing digital cir-
cuits: the audio sensor. Its design requires a good knowledge
about analog circuits. Fortunately, modern op-amp chips
help a lot in this type of design, reducing the complexity
and instability typical of such circuits. But, you still need a
good background in both practical and theoretical analog
issues to avoid unwanted results. Once more, evolving tech-
nology helps us.
Cypress Semiconductor developed a programmable sys-
tem-on-chip (PSoC) that contains several analog and digi-
tal blocks that easily connect together (see Photo 1). There
are many “bricks” representing different kinds of func-
tions and, like a Lego system, you have to arrange them in
order to have a circuit that transforms the analog signal
according to your needs. You still need some knowledge
November 2011 – Issue 256

about analog electronic circuits; you must know the theo-


ry behind them. But, if you don’t have enough practice
building these kinds of circuits, you can still tackle such a
project. You can use point and click instead of a soldering
iron, you don’t need to test many discrete passive compo-
nents on a perfboard. You can simply reprogram your Photo 1—Cypress Semiconductor’s PSoC and its programmer used
PSoC until the goal is achieved. in the real circuit

30 CIRCUIT CELLAR® • www.circuitcellar.com


2011-10-015_Ottaviani_Layout 1 10/11/11 1:45 PM Page 31

some mathematical transformations


a) b)
on it. But, you still need amplifica-
tion, mixing, filtering, and amplifi-
cation of the previous signal before
sending it to an ADC for processing
the signal by software. Often, a
PSoC can do all this (and more) for
you. The analog blocks are really
analog! They are real operational
amplifiers; they are not a software
simulation of an analog behavior or
a mathematical elaboration. The
only digital stuff is that the capaci-
tance can vary using switched
capacitors technique. Adjusting the
switching frequency and/or duty
cycle, you can modify the capaci-
tance, and therefore the parameters
Photo 2a—You can buy a full evaluation kit with everything needed to start experimenting. b—Or
of the analog blocks, without adding
you can buy the less expensive miniprogrammer to use with your own prototyping or final board.
external components. Looking at the In both kits, there is a Cypress Semiconductor CY8C29466-24PXI PDIP PSoC device sample,
electrical characteristics on the which is perfect for our purposes.
datasheets, you can find the same
parameters of a normal op-amp
datasheet: GBP, noise factor, common-mode rejection minimum goal, and I added some more functionality that
ratio, and so on. I’ll describe in this article.
As an example, there is a module that is unique on pro- First of all, what kind of PSoC? Let’s start with the
grammable devices—an instrumentation amplifier. This is simplest and most affordable version, PSoC 1. This is an
one of the trickiest circuits to realize even with expensive easy way to start understanding this device family with-
op-amps. It requires good knowledge to obtain very high out spending a fortune. The PSoC 1 series was the first
impedance, enough bandwidth, a good common-mode series realized by Cypress and it’s evolved noticeably
rejection ratio, and everything else needed to have a good both in analog module features and in digital block avail-
measuring instrument. This is not achievable with a stan- ability. There are many devices in this series, distinct for
dard microcontroller. maximum clock frequency, RAM, and flash-memory
I don’t want to write a PSoC manual. I’m not going to quantity and for number of blocks. The latest one is the
explain every feature of PSoCs. I’ll just explain how to CY8C29x66 family—sold in different versions, from 24 to
build a tone-detector circuit with a Cypress device, 64 pin—the only series available in a PDIP version,
focusing on some specific issues I’ve found. Even if you which is good for development boards (see Photo 2).
don’t need a 4-kHz tone-detector circuit, the same basic
principles I’m going to describe can be useful for many CONNECTING BLOCKS
other types of projects. This could be considered “on-the- Every book about PSoCs starts with, “Design and care-
job training.” fully test your circuit before you start writing the code.”
It’s really true! When you build your project, after connect-
THE BASICS ing all the blocks needed, Cypress Semiconductors’s PSoC
Do you remember the circuit described in my sensor Designer integrated development environment (IDE)
board article? In an explorer robotic challenge, the robot defines the template for the program you are going to
must autonomously find some sound sources that emit a write. It collects all the libraries needed and creates the
4-kHz tone. To achieve this goal, the robot has three basic main.c file and all the “include” files with the name
microphones on three sides. The conditioning and you gave to each block. Changing the block configuration
revealing circuit is based on a quad op-amp and a tone after you have written hundreds of lines of code using
detector. There is a first stage that mixes and amplifies those names and libraries, even if possible, can be painful.
the signals coming from the microphones, an active tun- The good thing is that you can test your analog circuit
November 2011 – Issue 256

able band-pass filter, a second amplifier stage, and an without writing a line of code. Connect programmable
NXP Semiconductors NE567 tone detector. The remain- amplifiers, filters, and other blocks via the common buses
ing op-amp in the chip is used as an active virtual available and you can display the results of your work with
ground reference for all the amplifiers, enabling higher a scope after injecting the signal to the input. It’s not a
impedance for their inputs. simulation; it’s real.
At the very least, my first goal was to obtain the same If you are used to working with microcontrollers, the first
functions with a single PSoC. I reached and exceeded that approach could seem strange. You don’t have a fixed number

www.circuitcellar.com • CIRCUIT CELLAR® 31


2011-10-015_Ottaviani_Layout 1 10/11/11 1:45 PM Page 32

even only as an exercise for the brain, to


read some of the many application notes
available on Cypress’s website.

TRICKS & TIPS


Allow me to share some personal
experiences with the hope of saving
you some time and headaches. When
copying text from one window to
another, you cannot use standard ctrl-C
and ctrl-V for copying and pasting. You
must use drag-and-drop with a mouse
between tabs. Fortunately, I’m a Mac
OS X user, and drag-and-drop is more
common than copy and paste for me,
compared with Windows users. At least
at the beginning, it is highly recom-
mended to enable the “show allowed
connections” feature (right click) to
immediately know which connections
are admitted for the line or module you
are using.
Lastly, there is no big enough moni-
tor when you are working with PSoC
Designer, you have to zoom and pan
Figure 1—The “external” connections often. To navigate more easily on the
block diagram to place or connect mod-
ules and buses, you can temporary
of peripherals that can be connected to I/O pins according to switch from standard to pan-mode view with an Alt key
your needs; you have a fixed number of boxes that can be instead of clicking the menu item or using the right click
filled with any kind of functional block. In this case, the contextual menu.
limit is the number of boxes, not the number of blocks. The
blocks can be connected internally with other blocks or THE CIRCUIT
externally with I/O pins. Not every combination is possible. The “external” circuit is simply a bunch of passive com-
There are a good number of buses and boxes, but you have to ponents (see Figure 1 and Photo 3). On the microphone’s
study the right compromise between your needs and the side, there are three high-pass RC filters for DC decoupling
connections available. It can be confusing at the very begin- and low-frequency noise filtering. Three current-limiting
ning, but it becomes easier after a while. Be prepared to
spend most of your time testing different connections and
different configurations for each of the blocks before reach-
ing the optimum solution.
Every operation is performed inside PSoC Designer. You
can connect blocks, configure them, read the datasheet of
each block, write and compile your program, flash the
device, and more without going outside of the IDE. You can
also configure everything manually editing the code; after
all, it acts as a usual microcontroller with a huge number
of registers for a lot of different configurations. You have to
take care of all the compatibilities avoiding possible con-
flicts. Fortunately, PSoC Designer does all these things, cre-
ating the code for you.
November 2011 – Issue 256

At the end, you can also create an exhaustive report of the


entire configuration with the block diagram and a detailed
description for each block using the menu item “view-config-
uration datasheet.” It creates a folder (ConfigDataSheet) with
all the information and the picture for a complete documen-
tation. Many of the pictures used in this article have been Photo 3—The circuit is simple. It is easy to wire it on a small piece
automatically generated with this function. It is interesting, of perfboard.

32 CIRCUIT CELLAR® • www.circuitcellar.com


2011-10-015_Ottaviani_Layout 1 10/11/11 1:45 PM Page 33

Comparator 0-3
VC 1-3
SysCIK*2
CPU_32_KHz
Port_0_1 Port_0_2 Port_0_5 Port_0_6

0 1 2 3
Port_0_0 ACB00 ACB01 ACB02 ACB03 Port_0_2
1 1
2 PGA_pre 2 PGA_out RefMux_1
Port_0_1 Port_0_3
GAIN GAIN REFMUX
Input Input AGND_Reference
Port_0_2 AnalogBus AnalogBus Port_0_4
Select
AGND_Reference AGND_Reference
Port_0_3 Port_0_5

Port_0_4
Comparator 0

Comparator 1

Comparator 3
Comparator 2
Port_0_5 ASC10 ASD11 ASC12 ASD13
BPF4_4KHz BPF4_4KHz ADCINCVR_mes
Port_0_6 FLINL FLFBH ADC
Input Input
Port_0_7

Port_2_0

Port_2_1

Port_2_2 ASD20 ASC21 ASD22 ASC23


BPF4_4KHz BPF4_4KHz ADCINCVR_pot SCBLOCK_inbuff
Port_2_3 FLFBL FLINH ADC SCBLK
Input REFHI_ACMux
AnalogBus CompBus
AMux
AnalogBus

buf0 buf1 buf2 buf3

Figure 2—The analog blocks configuration with the connections to the internal buses and external pin drawn using PSoC Designer schematic
conventions

November 2011 – Issue 256

www.circuitcellar.com • CIRCUIT CELLAR® 33


2011-10-015_Ottaviani_Layout 1 10/12/11 1:58 PM Page 34

Software control
specific I/O pin to the spe-
cific input of the block.
P0(1)
00 Peak detector Substituting a standard
P0(3) MUX with an AMUX4 or
01
MUX BP PGA ADC Measured value
P0(7) PGA Filter AMUX8, you can dynami-
10 P0(5) P0(4) P2(2)
cally switch four or eight
11
AGND
pins toward an input dur-
Microphones
ing the execution of the
AMUX4 PGA BPF4 PGA ADCINCVR program using its API. This
7-13
module doesn’t fill up a
4 to 1
MUX block since it superimposes
AMUX4_mic PGA_pre BPF4_4KHz PGA_out ADC_mes
the function of an existing
RefMux module.
P2(0) In this configuration,
Ref Buffer ADC
MUX P0(2) Pot value (threshold)
AGND ports P0(1), P0(3) and P0(7)
AGND can be sequentially
RefMux_1 addressed to PGA_pre.
SCBLOCK ADCINCVR
PGA_pre refers to the
7-13 programmable gain ampli-
SCBLK_inbuff ADC_pot
fier (PGA). The micro-
phone’s signals need a first
Figure 3—This is equivalent to Figure 2, but it’s drawn using standard symbols. amplification before enter-
ing into the band-pass fil-
ter. The ACB00 block
resistors drive the LEDs. A Schottky diode forms a peak accepts analog type-B module, its input is internally con-
detector together with a capacitor to measure the level of nected to the AMUX4_mic and its output can be internally
sound; this kind of diode causes a lower voltage dropout connected to the analog switched capacitor block ASC10
than normal rectifier diodes. The purpose of the R5 resistor without using any bus. It is perfect for our purposes. The
is to decrease the discharge time of the C5 capacitor in characteristics of this amplifier are good for an audio-
order to enable a faster multiplexing of the three inputs. band amplifier—GBP up to 5.4 MHz for a 5-V power sup-
Those external components were chosen instead of a peak- ply in high-power mode. The gain is programmable in
detection block because all the internal available boxes are several steps from 1/16 to 48. It is amazing to me to read
busy and this three-component network is an acceptable about GBP, noise factor, bias, etc. in a programmable-
compromise. A trimmer is used to set up the threshold of device datasheet.
the analog signal that triggers digital out. A trimmer? Why Using an amplifier with a software programmable gain
a trimmer when you can use an up/down digital circuit enables us to realize an automatic gain control, expanding
with an LED bar indicator of the position? Because it’s the dynamic of the amplification chain. This is another
much simpler. Sometimes I’m lazy. feature not present in the op-amp version of this circuit.
Filtering capacitors and sockets complete the “bill of BPF4_4KHz refers to the band-pass filter. This is a
materials.” The real complexity is in the “internal” part of
the circuit, as expected using this PSoC device. Let’s
describe every single block and connection.

ANALOG BLOCKS
Figure 2 shows the analog blocks configuration with the
connections to the internal buses and external pins drawn
using PSoC Designer schematic conventions. Figure 3
shows the equivalent schematic diagram drawn using
standard symbols.
The AMUX4_mic block is one of the improvements with
respect to the older op-amp version. In that one, the micro-
November 2011 – Issue 256

phones were all mixed in one single input, not enabling the
identification of the sound source direction. With a multi-
plexer, we can use a single chain of filtering and amplifica-
tion, assigning it to one microphone at a time.
All the analog continuous blocks (first row) are connected Photo 4—You can use the filter design to write down all the values for
to the external world through a standard MUX or a combina- all the registers involved in your filter. Simply right click on a filter
tion of multiplexers. With PSoC Designer you can address a block to pop up the contextual menu.

34 CIRCUIT CELLAR® • www.circuitcellar.com


2011-10-015_Ottaviani_Layout 1 10/11/11 1:45 PM Page 35

Photo 5—The graph captured by the DSO in Spectrum Analyzer


mode, the function-generator window that sweeps a signal in the
audio band, and a terminal window with the debugging values sent
by the PSoC via the UART port. The background shows the PSoC
Designer window with the project used for this test.

switched capacitor module that fills up four blocks. The out-


put of BPF4_4KHz goes to AnalogBus 1 and out to Port_0_5.
The Port_0_5 pin is internally connected also to AInMux_2
and routed to PGA_out for the final amplification.
These are the most interesting kind of modules. With
switched-capacitor amplifiers you can build fully analog fil-
ters with the same characteristics of classic filters (e.g.,
Butterworth and Bessel).
Second-order filters fill up two switched-capacitor analog
blocks (ASD and ASC). Fourth-order filters fill up four
blocks. Remember, there are some connection constraints
that limit the number of practicable filters. Only second
and third rows accept switched-capacitor blocks. Only the
first and third columns can be connected to an ACB block,
the only one that enables connection to the world external
to the device.
Not every filter topology is available on every PSoC 1
family. For example, Cypress’s eight-pin CY8C27143-
24PXI PSoC device, even with 12 analog blocks, admits
only BPF2 and LPF2 filters. All available filters topology
are band pass of second order (BPF2), band pass of fourth
order (BPF4), elliptical low pass of second order (ELPF2),
elliptical low pass of fourth order (ELPF4), low pass of sec-
ond order (LPF2), and low pass of fourth order (LPF4).
We need some basic theory about the switched-capaci-
tor technique to understand what we are going to do.
Switched cap blocks use the same op-amp used in the
continuous analog blocks. This op-amp then has some
November 2011 – Issue 256

capacitors driven by switching signals placed in feedback,


input, and output positions to serve various functions
such as integrators, summers, and filters. The timed
switching signals give the capacitors the ability to func-
tion the same as a resistor would in the circuit. The value
of the capacitance along with the speed of the switching
enables the user to vary the correlating resistance value.

www.circuitcellar.com • CIRCUIT CELLAR® 35


2011-10-015_Ottaviani_Layout 1 10/11/11 1:45 PM Page 36

This is the heart of the switched-capacitor technology. Since


switching is involved, the output signal you would expect
isn’t continuously present and must be sampled at specific
times in order to see the correct signal. The construction of
the PSoC switched-capacitor blocks enables you to process
these signals easily in filters and put them out to the analog
output buffers or use the blocks as analog-to-digital convert-
ers without being a switched capacitor expert.
Once more, you can write down all the values for all
the registers involved in your filter or use the practical
filter design wizard by right clicking on a filter block to
pop up the contextual menu (see Photo 4). This wizard
suggests the capacitance values needed, after entering the
characteristics of the filter you are going to realize. The
resulting filter frequency response is shown in both theo-
retical and effective form. As happens in classical discrete
component filters, you have to slightly adjust values to
obtain the better compromise on frequency bandwidth, Photo 6—With the scope placed on Port_2_2, you can see the signal.
phase, and amplitude flatness. The configuration is the same as in Photo 5, with the DSO in Time
One of the important things to note about designing a Domain mode (oscilloscope).
filter is that the cutoff frequency of the filter is based on
the clock frequency being sent to the analog columns with the DSO in Time Domain mode (oscilloscope). The
that contain the filter. The filter design wizard does not sampling frequency of the switched capacitor block is clear-
set up resources to generate this frequency for you. It ly visible, as previously described.
simply tells you which frequency is important. The spec- RefMux_1 refers to the analog virtual ground reference.
ified frequency must be sent to all switched-cap blocks This is routed to AnalogOutBuf_3 in order to obtain an
used in the filter. You will be required to create a clock AGND virtual ground reference for the inputs. It is
using digital resources to send to the analog column. connected to them through a 1-MΩ resistor. Another inter-
This clock can come from timers, counters, and so on. If esting module available on PSoC devices, this enables the
the clock is attainable by using the VC1, VC2, or VC3 generation of a virtual ground with a level between VDD
signals, you can reserve your digital blocks for other and VSS. Anyone who has been involved in analog circuit
uses. Since there are limits on what clocking frequencies design with a single power supply knows how much care
can be set to the blocks, there are limits on what fre- must be dedicated to this part of the circuit. A bad design
quencies you are able to choose for your filters. That is can damage the signal introducing distortion or noise. A
the reason why you won’t find a high-pass filter design in passive network virtual ground reference can lower down
the PSoC. Unfortunately, this is the nature of switched- the input impedance at unacceptable values.
capacitor designs. Studying several application notes, something caught my
Photo 5 shows the response, in the frequency domain, of attention. They always use a resistor between inputs and
the realized band-pass filter. The screenshot shows the graph AGND reference. Why? All analog blocks should be auto-
captured by the DSO in Spectrum Analyzer mode, the func- matically referenced to AGND internally, what is the pur-
tion-generator window that sweeps a signal in the audio pose of that resistor? On a classic op-amp there is always
band, and a terminal window with the debugging values sent some feedback resistor to the input that brings it to the
by the PSoC via the UART port. The background shows the right bias. A switched-capacitor amplifier input, decoupled
PSoC Designer window with the project used for this test. with a capacitor to the external circuit, is really floating
Another PGA of the same type is PGA_out. This one with the risk of having an unwanted DC bias or amplifying
amplifies the signal at the out of the BPF4_4KHz. It is also a noise. It needs a resistor between each input pin and the
software controlled, which enhances the dynamic of the virtual ground reference to fix the bias.
entire chain even more. AGND reference can be realized in different ways. As in
PGA_out is the output that is connected to AnalogOut- normal op-amp, when no more pins are available on your
Buf_2 and routed to Port_0_4. The filtered signal is there- device, you can use a voltage divider with two resistors
fore available on Port_0_4. Port_0_4 is connected to and a capacitor from VDD (a Cypress Semiconductor
November 2011 – Issue 256

Port_2_2 through a Schottky diode and a capacitor in order AN16833 PSoC). In application note AN2247, Cypress
to rectify the 4-kHz signal. The DC signal out of the recti- simply uses an unused OutBuff connected to an output
fication circuit on Port_2_2 is routed to ADCINVR_mes to pin. If a block and a pin are available, the best way is what
measure via software the level of the 4-kHz signal present you can see on this circuit: configuring a RefMux with
at the input. AGND as input and OutBuff as output to an external pin,
With the scope placed on Port_2_2, you can see the signal this one becomes a clean and stable AGND reference for
(see Photo 6). The configuration is the same as in Photo 5, all of the circuit.

36 CIRCUIT CELLAR® • www.circuitcellar.com


63.qxp 1/7/2009 3:20 PM Page 1
2011-10-015_Ottaviani_Layout 1 10/11/11 1:45 PM Page 38

GIO GIE GIO GIE


7 0 7 0 7 0 7 0
RI0[0]
Port_0_0 Port_0_0
RI0[1]
Port_0_1 RI0[2] Port_0_1

Port_0_2 RI0[3] Port_0_2

Port_0_3 BC0 Port_0_3

Port_0_4 Port_0_4
1 DBB00 DBB01 DBB02 2 DBB03
Port_0_5 ADCINCVR_mes ADCINCVR_mes ADCINCVR_mes ADCINCVR_pot Port_0_5
CNT PWM16_LSB PWM16_MSB CNT
Port_0_6 Port_0_6

Port_0_7 Port_0_7

Port_1_0 Port_1_0

Port_1_1 RO0[0] Port_1_1

Port_1_2 RO0[1] Port_1_2


RO0[2]
Port_1_3 Port_1_3
RO0[3]
Port_1_4 Port_1_4

Port_1_5 12CHW RI1[0] Port_1_5

Port_1_6 RI1[1] Port_1_6


RI1[2]
Port_1_7 12CHW Port_1_7
RI1[3]
Port_2_0 BC1 Port_2_0

Port_2_1 Port_2_1
DBB10 DBB11 DBB12 DBB13
3 Port_2_2
Port_2_2
ADCINCVR_pot ADCINCVR_pot TX8
Port_2_3 PWM16_LSB PWM16_MSB TX8 Port_2_3

Port_2_4 DIGITAL_OUT Data clock out_ Port_2_4a

Port_2_5 LED_3 Output Port_2_5

Port_2_6 LED_2 Port_2_6


RO1[0]
Port_2_7 LED_1- Port_2_7
RO1[1]
RO1[2]
RO1[3]

RI2[0]
RI2[1]
RI2[2]
RI2[3]

BC2

2 DBB20 DBB21 DBB22 DBB23


HB_Tmr HB_Tmr
TIMER16_LSB TIMER16_MSB
CompareOut

TerminalCountOut

Figure 4—Digital blocks diagram

SCBLK_inbuff, the generic SCBlock, is just used as a buffer placement is not trivial, not every connection is possible.
with a gain of one to connect the external Port_2_0 with There are several restrictions depending on the placement
ADCINCVR_Pot ADC. This is a trick that popped up after of the block and sometimes some external links are need-
hours of tests on how to connect the port on which the trim- ed, involving an analog bus. But it’s really versatile. Unlike
mer is with an ADC that can only be placed on a fourth col- classic op-amps, you can also have two inverting inputs.
umn because the other columns are already busy. It was also ADC_mes are, of course, mixed blocks. Part of their
a good exercise for understanding an SCBlock. I had under- function is in the analog section and part is in the digital
valued this generic block because it was too “generic,” and section. There are many different kind of ADCs available
also because the datasheet is too poor. on a PSoC 1. Choosing the one right for your purposes can
After looking at application note AN16833, where a four- be tricky. Fortunately, Cypress’s documentation is exhaus-
channel mixer with independent adjusting for each channel tive with datasheets and a lot of application notes. Dis-
is realized with a single PSoC 1, I found the AN2223 that cussing in detail the reasons for choosing one or the other
better explains this module, with relations to standard op- is beyond the scope of this article. For this purpose, an
November 2011 – Issue 256

amp characteristics. It’s very useful. It’s a real op-amp, pro- ADCINVR with 11-bit resolution is the right compromise
grammable in several different modes. between needs and block occupation.
Someone once said, “For those who are really adventur- ADCINCVR_mes is used to read the input signal as
ous, Cypress has created the generic switched cap block. aforementioned. The ADCINCVR_pot is used to convert
This block gives you a visual configuration of all the set- the position of a trimmer in order to manually (and option-
tings of a switched capacitor block to allow you to create ally) set a threshold for the trigger part of the circuit.
your own module easily.” It’s partially true, indeed. The According to the formulas in the datasheet, both types

38 CIRCUIT CELLAR® • www.circuitcellar.com


39_Layout 1 10/06/11 12:03 PM Page 1

hot
Turn a

idea into a
cool
solution.
DesignSpark chipKIT Challenge ™

Contest launches November 28, 2011!


Challenge your talent against other engineers worldwide to produce
an energy-efficient design solution using the free DesignSpark PCB
software and Microchip’s chipKIT™ development board.
Achieve the most energy-efficient design and you could win a share
of $10,000!
Plus, keep the DesignSpark community regularly informed through
posts on the DesignSpark Project Pages and your updates will make
you eligible for Community Choice Awards and random prize drawings!

FREE chipKIT™ Max32™ development kit for qualified engineers.

Visit www.chipkitchallenge.com
for complete rules and to see if you qualify for a
FREE ChipKIT™ Max32™ development kit.*
*Subject to availability.

IN ASSOCIATION WITH:

chipKIT™ is a registered trademark of Microchip Technology Inc. Max32™ is a registered trademark of Digilent, Inc.
2011-10-015_Ottaviani_Layout 1 10/11/11 1:45 PM Page 40

of ADCINCVR_ perform a full measure in 1.7 ms with a the cathode will switch it on. In both cases, the “LED_On”
4.8-MHz clock (VC1). These parameters are chosen to instruction is used to switch the LED on.
have an integration time that filters out some undesired The I/O ports can be used even if they are not connected
signals. A spreadsheet for calculating parameters is avail- to a block, after all, this is a microcontroller too. A pin
able on the Circuit Cellar FTP site. configured as “StdCpu” can be used in the program using a
Like any other analog circuit, and because the maxi- mnemonic name.
mum possible amplification gain is quite high, it is highly Every line can be configured in different modes, which
recommended to have a very clean power supply to avoid enables a lot of flexibility. They accept Strong-high,
amplification of noise that could interfere with the real Strong-low, High-impedance, Pull-up, Pull-down, Open-
signal. A dedicated linear-voltage regulator or an LC low- drain-high, and Open-drain-low modes. Almost everything
pass filter could be used to filter out undesired signals, pri- is possible, even configuring a pin in both Input and Out-
marily if the sound circuit is on the same power line of put mode. This requires good practice with PSoC that can
digital circuits. be achieved in the field or by a carefully reading many
application notes.
DIGITAL BLOCKS In a single PSoC family, there are many kinds of different
Figure 4 shows the digital blocks diagram. These mod- devices with a different number of I/O pins, but all with the
ules are probably more familiar to standard programmable same number of analog and digital blocks. All other pins can
device users. The diagram also uses not so standard con- be used as input/output like any standard microcontroller.
ventions to show how the digital modules are connected to All the outputs can directly drive devices that require sev-
the internal buses or to the external pins. This is due to eral milliamps, such as LEDs or something similar.
the “not so standard” way that Cypress approaches this EzI2Cs refer to the I2C communication module. This
issue and to the huge amount of possible connections the doesn’t fill up a box, you have just to assign a clock and
PSoC has. This could be a little bit confusing for designers data line to a couple of pins to start using this protocol.
used to working with other kinds of microcontrollers but, The basic circuit described above performs a basic
after some practice, it quickly becomes easy to manage. task, but this approach simplifies much of the design if
Some boxes in the diagram are filled with the digital compared with an equivalent fully analog circuit. In this
counterpart of the ADCs. article, there is a full description of how this specific
The HB_Tmr is a 16-bit timer. It fills up two boxes board works, but there is also most of the information
because it is a 2-B timer. It is the base clock for all of the you need to start using PSoC devices when developing
timings in the program. Its timing is: similar circuits. The complete and up-to-date PSoC
Designer project is available on my Google Code space.
SysClk 24 MHz
VC1 5 5
VC2 = = = = 320 kHz HARDWARE OR SOFTWARE?
15 15 15
 1 
It may sound bizarre defining software to hardware dif-
Timer Period =  × (PeriodRegister + 1) = ferences in a device completely configured through a com-
 VC2 
0.000003125 × (3,199 + 1) = 10 ms
puter. You are changing some physical parameters via a
graphical user interface (GUI) on a computer window. In
TX8 refers to the serial transmission module. It enables the same way you can change the flow of a program with a
transmission via the UART of the analog values read from conditional jump, you can optimize the phase response of a
various inputs. It can be useful for debugging purposes using Butterworth filter—without a screwdriver on a trimmer or
standard ASCII characters to a serial console or, using any a solder iron on a capacitor—just with mouse and key-
kind of protocol (e.g., dsNav communication), it could be board. And it is not a simulation, it is real world.
used to interface other boards alternatively to I2C port.1 But let me be conservative to better explain this innova-
It is notable that even only the TX part of the UART tive device. Let’s use traditional terms. In the first part of
module can be used if no data has been received, as in our this article series, I described the hardware part of the proj-
case. This saves a box and an I/O pin that can be used for ect, how the component can be mounted on a printed cir-
other purposes. cuit board (PCB) or on a development board, and how the
Here is some information about digital OUTs. To drive internal hardware modules can be configured to manage
an LED or a generic I/O it is highly recommended to use an our analog signal in order to be useful for our needs.
LED module. This doesn’t fill up a box, it is just a kind of Now you have the correct signal at a correct level.
library that correctly drives the I/O port. It can be found What can you do with it? Let’s apply some “real” soft-
November 2011 – Issue 256

under the MiscDigital section. Not using this module ware, at least according to the traditional description of
requires a direct control of the port using the shadow regis- this term.
ters. The module can be configured in Active High or In the second part of this series, I’ll describe the software
Active Low mode. The first mode must be used when the capabilities of the PSoC 1 device and how to use them to
cathode of the LED is connected to VDD and a high level measure the level of the signal, expand the dynamic of the
on the anode will switch it on. The second mode requires amplifying chain, and reliably share this information in
an LED with the anode connected to VSS and a low level to several different modes with the external world. I

40 CIRCUIT CELLAR® • www.circuitcellar.com


2011-10-015_Ottaviani_Layout 1 10/12/11 2:00 PM Page 41

Guido Ottaviani ([email protected])


has made electronics and ham radio ———, “Robot Navigation and Control (Part 2): Software Development,“ Cir-
his hobby since the “tube times.” He cuit Cellar 225, 2009.
turned the hobby into a job working ———, “A Sensor System for Robotics Applications,“ Circuit Cellar 236,
as an analog and digital developer for 2010.
several years for an Italian communi-
cation company. Many years ago, a SOURCES
big change made him a technical CY8C29x66, CY8C29466-24PX, CY8C27143-24PXI, AN1683, and AN2223
manager at a company that develops PSoCs, CY3210-PSoCEval1 and CY3217-MiniProg1 evaluation kits, and
and manages graphic, pre-press and PSoC Designer (IDE)
press systems, and technologies for Cypress Semiconductor Corp. | www.cypress.com
a large Italian editorial group that pub-
lishes sports newspapers and maga- NE567 Tone detector
NXP Semiconductors | www.nxp.com
zines. Some years ago, he got the
scope and the soldering iron out of NEE
the drawer to make autonomous Knowl
robots. Currently, Guido is an active industr
member in various Italian robotics don’t ju
groups who shares his experiences need-to
with other self-professed “electronics covere
addicts” and evangelizes amateur staff re
robotics.
Netwo
Build a
by Tho
Circui
PROJECT FILES Thom
To download the “ADCINVRcalc ning (I
.xls” spreadsheet for the calculation tem. T
of parameters, go to ftp://ftp.circuit interac
cellar.com/pub/Circuit_Cellar/ useful
2011/256. zone a
Schedu
REFERENCE
[1] dsNav Communication, Tempe
www.guiott.com/Rino/Command by Bria
Circui
Descr/Protocol.htm.
Brian
contain
RESOURCES enterin
Cypress Semiconductor Corp., separat
“PSoC 1 Overview,” 2011, peratur
www.cypress.com/?id=1573. ture, P

———, Cypress PSoC 1 Applica-


tion Notes Database, www.
cypress.com/?app=search&searc
hType=keyword&keyword=&rt
ID=76&id=1573&applicationID
=0&l=0.

Google, Explorersound, a PSoC-


based system for 4-kHz tone
November 2011 – Issue 256

decoder, http://code.google.com/p/
explorersound.

G. Ottaviani, “Robot Navigation


and Control (Part 1): Construct a
Navigation Control Subsystem,”
Circuit Cellar 224, 2009.

www.circuitcellar.com • CIRCUIT CELLAR® 41


2011-10-017_Valens_Layout 1 10/11/11 1:58 PM Page 42

F EATURE
ARTICLE by Clemens Valens (France)

Super Arduino
oof
es Getting Started with the chipKIT Max32
Art
If you’re looking for more computing power on an Arduino-compatible
microcontroller board, Digilent’s chipKIT Max32 may be just what you
need. Digilent integrated a compiler, linker, and programmer for the
Microchip Technology PIC32 processor used on the chipKIT boards into
the Arduino IDE. Read on to find out more.

I f you’re interested in microcontrollers, you’ve probably


heard of Arduino—maybe you’ve even worked with it. If
you have, you may have run into the limits of this friendly
8-bit platform and wished for more computing power, mem-
ory, or I/O pins. This is, of course, easily possible, since
Max32. Mechanically, the Uno32 is compatible with the
classic Arduino Uno and the Max32 is compatible with the
Arduino Mega, the longer version of the standard Arduino.
Note that Digilent made the boards rectangular by straight-
ening the strangely shaped short edge of the Arduinos so
there are microcontroller boards galore, but at the cost of they are slightly larger. (I will offer a Max32 board to the
learning new tools. Or so it was until recently, when Digi- person who can tell me the real reason why the Arduino
lent introduced its solution for those who want more power boards are not rectangular.) I don’t think this will be a
without changing tools. Its chipKIT Max32 offers 32-bit problem for anyone.
computing power and some 80 I/O pins while being compat- The rest of this article will concentrate on the Max32.
ible with the Arduino environment (see Photo 1). Here we go!
There have been other attempts at making 32-bit Arduino-
compatible boards, but (as far as I know) these attempts only THE BOARD
achieve Arduino form-factor compatibility, not tools com- The Max32 comes as a red four-layer PCB in a little
patibility. Some of these boards are supported by software mainly red and white box without anything else, no USB
libraries that offer Arduino-like functionality and syntax, but cable, no documentation, just a URL. For those who do
they need a different compiler and use other firmware load- not know the Arduino Mega dimensions by heart: the
ing techniques. Digilent has taken Arduino compatibility a board measures 4” × 2”. Three sides of the board are lined
step further by integrating the compiler, linker, and program- with connectors, like an Arduino Mega, except that the
mer for the Microchip Technology PIC32 processor
they use on their chipKIT boards into the real
Arduino 0022 integrated development environment
(IDE). (For more information, refer to the sidebar,
“Introducing the PIC32.”) From an Arduino IDE point
of view, the chipKITs are just targets, listed together
with the classic 8-bit Arduino boards. Digilent even
went so far as to create a website with a URL ending
in .cc like Arduino (see Resources). Also, in the spirit
November 2011 – Issue 256

of Arduino, the chipKIT is completely open source


and hardware. The hardware design files (Eagle
schematic and PCB files) are available for download
and the software is all open source. Unlike Arduino,
the chipKIT printed circuit board (PCB) is a four-layer
board, so few people will be tempted to roll their own.
There are two chipKITs: the Uno32 and the Photo 1—Digilent’s chipKIT Max32

42 CIRCUIT CELLAR® • www.circuitcellar.com


2011-10-017_Valens_Layout 1 10/11/11 1:58 PM Page 43

connectors for the digital pins 0 to 13 (Arduino speak) are the board. Don’t forget to select the Max32 board from the
double-row on the Max32. You will find digital pins 70 to 85 Tools, Board menu and set the serial port properly (Tools,
on the extra contacts. On the USB and power connector side Serial Port). Once done, the BlinkWithoutDelay example
there is room for a Microchip Technology ICSP connector. (File, Examples, Digital) should work without modification,
This connector has the special Sparkfun “out-of-line” place- just click the Upload button to see the green LED LD4 start
ment of the pins so that a pin header will make good contact to flash at a rate of 0.5 Hz.
even without being soldered.
Powering the board can be done through the USB con-
nector or using the power barrel jack that will enable INTRODUCING THE PIC32
input voltages up to 15 V. Jumper JP1 lets you bypass the When asked about 32-bit microcontrollers most peo-
5-V regulator, so be careful what you do here or you may ple will first mention ARM, then some ARM-core
blow out some chips. When you power a virgin board, you implementers such as Atmel, STmicroelectronics, or
will notice an annoyingly bright red LED next to the NXP and only a few will think about Microchip.
power jack indicating that the 3V3 line has a voltage on it Although it’s true that many mobile phones are built
and a green LED (LD4) blinking at some 3 Hz. on ARM technology, a lot of other common electronic
The Max32 is hardly more than a breakout board for the devices (i.e., digital cameras and printers) contain
100-pin PIC32 processor that is mounted close to the center MIPS-based processors. Now, I haven’t done any seri-
of the board with a power supply and a USB serial port on ous checking on this, but it is said that there are far
the side. The 32-bit PIC32 compares pretty well to ARM’s more 32-bit MIPS processors out there than there are
Cortex-M3 (see Sidebar). The board sports the largest PIC32 ARM processors. Therefore, having some MIPS experi-
device currently available, Microchip Technology’s ence is a good thing for any serious microcontroller
PIC32MX795F512L. This chip sits in a 100-pin package and enthusiast and Microchip Technology’s PIC32 is an
features 512 KB of flash memory with 128 KB of RAM and excellent platform to get started.
runs from an 80-MHz clock. It has USB on-the-go (OTG), an There are currently five families: 3xx, 4xx, 5xx, 6xx,
Ethernet MAC, and two CAN controllers. and 7xx (see Table 1). The 3xx and 4xx are considered
You are familiar with the hardware. Now let’s take a general purpose, whereas the other three have more
look at the software. peripherals like CAN or Ethernet and can have more
RAM. The devices are based on a 32-bit MIPS MK4
THE IDE core with a five-stage pipeline and support clock fre-
As I mentioned in the introduction, programming the quencies up to 80 MHz. A maximum performance of
board is done using a modified Arduino IDE that you can 1.56 DMIPS/MHz (Dhrystone 2.1) is claimed, which is
download as a free archive from Diligent’s website. slightly better than an ARM Cortex-M3 that can do
Installing the 128-MB file is simple. You only have to 1.25 DMIPS/MHz, according to ARM.
unpack it to a convenient place on a convenient disk on All families have up to 512-KB flash memory plus
your computer. Unpacked, it takes up some 480 MB of disk 12-KB boot memory and up to 32 KB RAM for the
space. To start the IDE, launch the executable mpide.exe in 3xx/4xx devices or up to 128 KB for the 5xx/6xx/7xx
the root of the IDE’s folder. The IDE is cross platform and devices. They feature all the peripherals you would
will work on Windows, Linux, and MacOS, although you expect from this kind of microcontrollers (serial ports,
might have to install Java first. PWM, ADC, etc.) but they also have multiple direct
By basing the Max32 on the Arduino IDE, the people at memory access (DMA) channels.
Digilent saved themselves a lot of documentation writing. The families come in two “sizes,” 64 pin (H suffix)
Indeed, all you need to know to install and get started with or 100 pin (L suffix). Note that a 121 XBGA package
Arduino is explained in detail on Arduino’s website. You contains a 100-pin device. The PIC32s are pin compat-
can also go to the website with your questions about the ible with some PIC24 and dsPIC devices, so they inte-
programming language syntax. grate nicely in Microchip’s big microcontroller family
At the time of this article, the latest version of the IDE is and development tools (MPLAB). A lot of software
0022 (mpide-0022-chipkit-win-20110619, to be precise), the libraries are available on the website and a dedicated
same as the current official Arduino IDE. According to Digi- website exists for sharing PIC32 projects
lent, this IDE is exactly the same as the official Arduino (www.mypic32.com). Datasheets and other documen-
IDE except that it has been extended with a PIC32 compil- tation can be accessed at www.microchip.com/pic32.
er/linker and libraries and it can be used to program 8-bit
November 2011 – Issue 256

Family USB OTG CAN Ethernet RAM


Arduino boards, too. Of course I tried this only to discover
3xx – – – Up to 32 KB
that my Arduino clone, a Seeed Studio Seeeduino v1.1, was
4xx 1 – – Up to 32 KB
not recognized: invalid device signature. This board works
5xx 1 1 – Up to 128 KB
perfectly fine with the official Arduino 0022 IDE.
6xx 1 – 1 Up to 128 KB
After installing the IDE and hooking up the Max32 to the
7xx 1 2 (1 for 764) 1 Up to 128 KB
computer, you can try the tools by compiling one of the
simple examples included with the IDE and uploading it to Table 1—The five Microchip Technology PIC32 families

www.circuitcellar.com • CIRCUIT CELLAR® 43


2011-10-017_Valens_Layout 1 10/11/11 1:58 PM Page 44

If you get this far without any prob- September 2010.) Therefore, I modified
lems, you’re ready to develop real appli- the old etherShield library to use the
cations for the Max32. So read on, Arduino SPI library instead, and I test-
because there will be some hurdles you ed this in the real Arduino IDE before
may want to be aware of. trying it in the Max32 IDE.
This introduced new problems
PORTING A SHIELD because the SPI library references pin
Flashing an LED is nice, but not very functions that the Max32 compiler did
satisfying. That’s why I went on to try not like. This turned out to be caused
out my Arduino Ethernet shield (a by the fact that my library was written
shield is an extension card for an in C and compiled as such, whereas the
Arduino board) on the Max32. This pin functions and the SPI library are
shield is based on Microchip Technolo- written in C++. Files with the extension
gy’s ENC28J60 stand-alone Ethernet .c are compiled as C. Files with the
controller with SPI. I know, the PIC32 extension .cpp are compiled as C++. So,
has an Ethernet MAC inside, but I did- back to the Arduino IDE it was for port-
n’t have a shield handy with an Ether- Photo 2—Digilent’s chipKIT Max32 IDE showing ing the complete etherShield library to
net PHY and RJ45 connector. Digilent a #define to remove AVR-specific code C++ and testing it. This is not very diffi-
proposes such a shield (that includes cult to do, but you may have to watch
some other things as well), but I didn’t have the time to out for compiler directives such as #extern “C” { … } hid-
order one and wait for it to arrive. Besides, now I had a good den in unexpected places. After this last modification, my
opportunity to check out the Max32’s compatibility. As you etherShield library compiled without errors in the Max32
will see in what follows, it’s not completely compatible.... IDE and for the Max32 board. But did it work?
My old Ethernet shield—I will call it “etherShield” from No. Of course not. This did not really come as a surprise
now on to distinguish it from the new official Arduino as I had already spotted SPI problem posts on Digilent’s
W5100-based Ethernet shield—is supported by a library and website. But, the optimist in me kept hoping.
some examples. This shield and code work perfectly fine on The main problem is incompatibility of Max32 I/O pins
my Seeeduino. Therefore, the first step was to install this with AVR I/O pins. The Arduino digital pins 10 to 13 have
library in the Max32 IDE (in the folder “libraries\”) and see if SPI capability and pins 10 and 11 can also do PWM. The
it would compile. As you might expect, the answer was, no. reason for this combination is simply the way the AVR I/O
The reason was not so much the code itself, but the fact that pins were laid out by Atmel. The PIC32 combines func-
the compiler didn’t seem able to find anything to compile. tions in a different way on its I/O pins and there are no
According to the Digilent website, where some things about exact equivalents for these AVR pins. Digilent has chosen
porting Arduino code are explained, libraries are supposed to to give priority to the PWM functions as they are used by
be handled the same way as Arduino does, but clearly not in Arduino’s analogWrite functions, meaning that they could
my case. When I put the library in the folder only connect part of SPI port 2 to these pins. However,
“hardware\pic32\libraries\” (where you find the same items they did find a way to connect SPI port 1 in an Arduino-
as in the folder “libraries\”), the compiler did find the code, compatible manner by using the Arduino ICSP connector
but produced many errors and a warning saying that the which is connected to the same signals as the pins 10 to 13
code contained AVR-specific code. (Arduino boards are based (see Photo 3a). I had never considered this connector as
on Atmel’s AVR processors.) Great! Now I had clue. part of a compatible shield, and I am in good company. But
The first thing you have to do when porting Arduino Seeed Studio, the maker of my etherShield, had put an
libraries is to get rid of the references to program memory. ICSP pin header on the shield in the right place. Replacing
With an AVR, some special compiler directives are needed it by a female header on the solder side only took a few
for accessing constants (e.g., strings, tables) located in pro- minutes and restored SPI compatibility with the Max32. To
gram space. This is unnecessary for the PIC32 and these prevent conflicts on pins 11 to 13 (MOSI, MISO, and SCK) I
directives have to be removed. To keep your code Arduino simply removed these pins from my shield (see Photo 3b).
compatible, it may be better to #define them away (see Now it would work, right?
Photo 2). You can use the macro _BOARD_MEGA_ defined by Wrong. At this point, I fired up the oscilloscope because
the Max32 IDE to do this (confusing, one would have I suspected compatibility issues between the SPI protocol
expected something like _BOARD_MAX32_). Do the same for as produced by the PIC32 and the one accepted by the
November 2011 – Issue 256

the AVR-specific #include directives. ENC28J60. Notably, the clock speed was worrying me a
This may not be sufficient. In my case, it wasn’t, because bit. The scope proved me right, because where the Arduino
the library may also refer to AVR registers that the PIC32 managed to reach a clock speed of about 610 kHz, the PIC32
doesn’t have. The SPI driver for the ENC28J60 Ethernet was blasting away at 20 MHz. According to the ENC28J60
chip did this, probably because it is relatively old and the datasheet, this should be okay, but a later experiment when
SPI library that is now part of the Arduino IDE did not exist all was finally working showed me that 2.5 MHz was a more
yet when it was written. (It appeared only in version 0019, realistic value. For now, I just reduced the PIC32’s clock

44 CIRCUIT CELLAR® • www.circuitcellar.com


2011-10-017_Valens_Layout 1 10/11/11 1:58 PM Page 45

a) b) Photo 3a—A close-up of the SPI


connection between the ether-
Shield and the chipKIT Max32.
b—These are modifications I
made to the etherShield. NEE
Knowl
industr
don’t ju
need-to
covere
staff re

Netwo
Build a
by Tho
speed to an Arduino-like value: 625 kHz. With this change, The only thing I haven’t completely cleared up yet is Circui
the shield still didn’t work, but I felt like I was getting close. the issue of where to put your own libraries. After think- Thom
Nowadays, even the lowest budget digital oscilloscopes ing hard and experimenting a bit, I settled on the ning (I
can record traces, including my $318 25-MHz Atten assumption that all files containing PIC32-specific code, tem. T
ADS1022C digital storage oscilloscope. This useful func- such as low-level drivers, must be placed in the folder interac
useful
tion showed me that there was a polarity/phase issue “hardware\pic32\libraries\” including the files that need
zone a
between the SPI clock and data lines. By carefully compar- these files. All other files, including the examples that use
Schedu
ing transitions, I discovered that the shield needed SPI the library, must be placed in the folder “libraries\” to
mode 1 on the Max32 whereas it used mode 0 on the ensure that they are recognized by the IDE as examples. I Tempe
Arduino. Did that mean that the shield was now finally by Bria
working? It did. Phew. Refer to Photo 4. Author's note: You can download the code associated with Circui
this article at www.elektor.com/110661. Brian
USE AVAILABLE RESOURCES contain
Digilent has done a decent job of porting the PIC32 to Clemens Valens ([email protected]) is Editor-in-Chief of the enterin
the Arduino IDE. Although they did not achieve 100% French edition of Elektor. He has more than 15 years of experi- separat
compatibility, they definitely tried hard and managed to peratur
ence in embedded systems design. Clemens is currently inter-
ture, P
get pretty close. It’s safe to assume that simple Arduino ested in sound synthesis techniques, rapid prototyping, and the
shields with simple libraries respecting Arduino coding popularization of technology. Go to C
rules and style will be easily portable, although you may and mo
run into some of the problems I encountered. The more
complex shields exploiting AVR subtleties will definitely RESOURCES
be more difficult and may require solid PIC32 knowledge. chipKIT, http://chipkit.cc.
To make your life simpler, try to use the functions avail-
Microchip Technology, Inc., PIC32 Design Community,
able in Arduino libraries as much as possible, and let Digi-
www.mypic32.com.
lent do the hard work for you.
Digilent has started keeping a list of known-to-work SOURCES
shields, so look there first before starting a project yourself. Arduino 0022 IDE and Arduino Ethernet shield
Updates to the Max32 IDE correcting some of the issues Arduino | http://arduino.cc.
mentioned in this article may be expected, so make sure
you always use the latest version. Cortex-M3 Processor
ARM Ltd. | www.arm.com

ADS1022C Digital storage oscilloscope


Atten Group, Inc. | www.attenelectronics.com

chipKIT Uno32 and Max32


Digilent, Inc. | www.digilentinc.com
November 2011 – Issue 256

PIC32 and PIC32MX795F512L Microcontrollers,


ICSP connector, and ENC28J60 stand-alone Ethernet
controller
Microchip Technology, Inc. | www.microchip.com

Photo 4—The result of a successful port: I can now connect to a Seeeduino v1.1
little web browser running on the chipKIT Max32. Seeed Studio | www.seeedstudio.com

www.circuitcellar.com • CIRCUIT CELLAR® 45


2011-11-006-Novacek_Layout 1 10/11/11 2:16 PM Page 46

T HE CONSUMMATE ENGINEER by George Novacek (Canada)

Shielding and Transfer


Impedance
Electromagnetic interference (EMI) and electromagnetic compatibility
(EMC) issues should be at the top of your list of concerns when designing
both prototypes and finished systems. A clear understanding of shielding
and transfer impedance, along with some careful planning, will help lead to
a successful design.

O ur world is permeated by electromag-


netic (EM) fields. These fields are both
man-made and due to natural forces in the uni-
verse. Man-made fields are the result of the oper-
ation of electrical equipment, some intentionally
EM & SE
EM fields are made up of two elements: elec-
trical and magnetic. This time we will focus on
the effects of the electrical component, which is
the most common source of interference.
(e.g., by transmitters), others unintentionally as a Shielding interconnecting wires and cables is
by-product of the equipment operation. usually the only effective way to reduce the
From high school physics, we know that induced interference. Shielding effectiveness (SE)
electrical energy will be induced in a conductor is one method of choice. SE is a measure of the
exposed to an EM field. If the conductor also unwanted signal attenuation in decibels (dB)
carries a useful signal, the induced energy will which helps us to evaluate the circuit suscepti-
corrupt. It may even obliterate this signal. We bility to interference. Figure 1 shows the results
must, therefore, protect the integrity of signals of attenuation versus frequency measure-
by reducing the effects of the EM fields. ments on a single- and a double-braided cable

–20

–40

Attenuation (dB)

–60

–80
November 2011 – Issue 256

–100

Single braid Double braid

–120
01

02

03

04

05

06
+

+
E

E
1.

1.

1.

1.

1.

1.

Frequency (kHz)

Figure 1—Shielding efficiency

46 CIRCUIT CELLAR® • www.circuitcellar.com


2011-11-006-Novacek_Layout 1 10/11/11 2:16 PM Page 47

as performed in a lab. 10,000

For better understanding, imagine


you work in a darkroom. The EMI is 1,000
an outside light and the shielding is an
incompletely opaque window. You are Aluminum/Mylar foil

interested in determining how opaque 100


the window must be or how many
Single braid Optimized
such windows need to be stacked up single
braid
to block enough light to prevent dam- 10
age to a photographic material. As Surface transfer
impedance
Double
shown in Figure 1, SE is frequency (IZTI mΩ/m)
braid
dependent. A single-braided cable pro- 1
vides only about 26 dB (20×) attenua-
Triax braid
tion at 10 MHz and a measly 20 dB
(10×) from about 100 MHz up. This is 0.1
3 braid + 2 MuMETAL
something to keep in mind when work- (Super screen)
ing with fast computer interfaces and
analog circuits even if their bandwidth
0.01
is limited to a low frequency range, 2 braid + MuMETAL
(Super screen)
such as audio. Figure 1 also exhibits res- Solid
copper
onance around 30 MHz, which is often screen
0.001
seen with shielded cables. 102 103 104 105 106 107 108
Frequency (Hz)

ESTABLISHING SE Figure 2—Transfer impedance of various cables versus frequency


Manufacturers of shielded wires and
cables rarely provide SE data, as it is Schelkunoff. It is a parameter that is shield by a current transformer, which
dependent on installation. However, intrinsic to the cable shield and noth- is a standard piece of equipment for
their cables usually comply with some ing else. For the past several decades, any company that performs conducted
industry standard, so their parameters transfer impedance ZT has been the susceptibility and emission tests. The
will be essentially the same as for all method preferred by electromagnetic current will induce a small voltage
cables in their category. Figure 1 is compatibility (EMC) engineers to between the shield and the center con-
typical of what can be expected. address EMC issues. ductor. The voltage is measured and
To establish the SE of a cable by ZT enables you to calculate the volt- the transfer impedance, normalized to
measurement is a challenge requiring age developed on the shielded conduc- 1-m length, can be calculated:
a well-equipped RF lab with an ane- tor as a result of the current flowing on
choic chamber. Worse, the test results the outer surface of the shield. This is VO  Ω
ZL =  
of the same sample performed in a lab due to current coupling through the ISHIELD × l  m 
may vary significantly due to the test shield thickness plus leakage induc-
configuration. In real-life applications, tance through the braid holes. When a VO is the voltage induced between the
the experienced SE may, once again, solid metal conduit is used, with inside conductor and the shield over
be different from the test, as it is increasing frequency the diffusion length l. l is the length of the test
affected by installation. quickly becomes immeasurable due to cable in meters. ISHIELD is the current
Here, transfer impedance ZT comes skin effect. Figure 2 shows ZT for differ- injected into the shield.
to the rescue. The concept was intro- ent types of shields, including a con- If the cable is terminated at both
duced in the mid 1930s by S. A. duit, called solid copper screen. You can ends with loads ZL1 and ZL2, both
see that ZT decreases—there- equal to the cable characteristic
fore the SE increases—with the impedance, each end will show VO,
increasing quality of the braid. which is one half of the fully induced
EM Wave
ZT parameter of a specific voltage. Therefore:
INTERNAL shielded cable or wire is also
difficult to obtain from the 2 × VO  Ω 
November 2011 – Issue 256

ZT =  
VSHIELD manufacturer, but once again, ISHIELD × l  m 
ZL1 Z L2
standardization comes to the
V
ISHIELD
O
rescue. Also, measuring trans- The manner in which the shield is
fer impedance ZT of a given electrically terminated also affects the
shielded cable is easier than final value of ZT. The shield termina-
measuring SE (see Figure 3). A tion methods range from the excellent
Figure 3—Transfer impedance calculation current is injected into the 360° termination to very poor pigtails.

www.circuitcellar.com • CIRCUIT CELLAR® 47


2011-11-006-Novacek_Layout 1 10/11/11 2:16 PM Page 48

This impedance, usually determined that a specific 4-m cable with a shield
empirically, needs to be added to ZT. current of 30 mA from 0.5 MHz to
Figure 2 shows typical values of some 400 MHz must cause no upset to an
commonly used cables. embedded controller.
ZT below certain frequency—100 kHz Let’s say a single-braid cable, such as
for most cables—remains constant, as it RG58, is used and you want to know
is merely the shield’s ohmic resistance, the interfering voltage reaching the
which can be easily measured. This equipment at 15 MHz. Figure 2 indi-
changes at higher frequencies due to cates that the cable’s ZT at 15 MHz is
the leakage inductance LT between the about 0.15 Ω/m. With 30 mA flowing
braid and the inner conductor. The through its 4-m shield, the voltage
inductance is usually determined induced on the center coax wire VO
empirically as well, based on the kind will be:
of braid and its weave. A good single-
layer braid typically has a leakage VO = ZT × 1 × I =
inductance LT of about 1 nH/m. As a 0.15 × 4 × 30 × 10–3 =
result, above some frequency, 100 kHz 18 mV
typically, the transfer impedance
becomes a complex number: If the cable is terminated at both ends
by 50-Ω resistors, load (the controller
ZT = RSHIELD + jωLT input) ZL will see:

What does all this mean in practical VO × 50 Ω 18 mV


VL = = = 9 mV
terms? Here is an example: Referring to ( 50 Ω + 50 Ω ) 2
Figure 3, shield current is determined
based on the installation and the illu- of the interfering 15-MHz signal. If the
minating e-field. Below 400 MHz, how- load impedance ZL2 is much higher
ever, the hardware designer doesn’t than ZL1—a more common situation,
have to worry about the field strength. say 5-kΩ—the voltage VL seen by the
The maximum shield current to be controller will be:
encountered (300 mA is considered to
be the highest for rugged equipment), VO × 5 kΩ
VL = ≈ 18 mV
is provided in the specification by the ( kΩ + 50 Ω)
5
system EMC engineers who select
proper values based on standards, the This is the level of interference your
installation, the harness length, and circuits must tolerate without losing
the intended operating environment. data. You may ask why we need to
For instance, the specification states terminate the shield at both ends? If

NEED-TO-KNOW INFO
Knowledge is power. In the computer applications industry, informed engi-
neers and programmers don’t just survive, they thrive and excel. For more
need-to-know information about some of the topics covered in this article,
the Circuit Cellar editorial staff recommends the following content:

Killing the EMI Demon
by Norman Rogers
Circuit Cellar 146, 2002
Emissions regulations can make it expensive to get your microprocessor
boards to the market. In an effort to help us reduce EMI testing costs, Nor-
November 2011 – Issue 256

man reveals the EMI reduction tricks Rabbit Semiconductor developed for
its second-generation processor. Topics: EMI, FCC, Rabbit 3000, Frequency,
Harmonic, Pulses, Clock, Power Supply, Bus, Spectrum Spreader, OFDM

Go to Circuit Cellar’s webshop to find this article and more: www.cc-
webshop.com

48 CIRCUIT CELLAR® • www.circuitcellar.com


2011-11-006-Novacek_Layout 1 10/11/11 2:17 PM Page 49

we terminate it at only one end, there


should be no shield current flowing
and thus no voltage developed as the ®
result. This reasoning is true for low
frequencies. But, when the cable
Computing/HMI Serial I/O
length exceeds one tenth of the wave-
length of the interfering field frequen-
cy, or the shield impedance is high
(cheap cable), the voltage will build up
Compact Ethernet data acquisition
along the cable length and capacitively modules support PoE.
couple to the inner conductor. There-
fore, long cables should have shielding Easily connect I/O to your network with Sealevel’s new eI/O™
grounded at both ends at least, better family of Ethernet data acquisition modules. eI/O provides system
in regular intervals along their length. designers with a compact, cost-effective solution for monitoring and
It is not uncommon to see double- control with optically isolated inputs and Reed or Form C relays.
braided cables with one shield ground-
ed at both ends and the other at only
eI/O Solutions Offer:
one end.
Š 9-*73*9433*(9*)K
EMC: MYTH VERSUS REALITY Š 4744<*7*)
EMC is often viewed as some kind Š &7.*9>4+K43+.,:7&9.438
of black magic. But, like everything
Š .*1)*24;&'1**72.3&114(08
else, it is subject to the strict laws of
physics. The practical problem is Š  &.147&11 4:39*8.,3
DC or PoE Powered
that it is next to impossible to define
all parameters affecting EMC issues. Power over Ethernet (PoE 802.3af) devices receive power and data
Therefore, our calculations have to on one cable and eliminate the need for additional power supplies.
rely on approximation and experi-
*&)>+47 7&.124:39.3,N*K24):1*8.3(1:)*&7*24;&'1*
ence. For design of EMC protection,
referring to Figures 1 and 2 will be 51&89.((1.59-&983&584394!22 7&.1G
quite sufficient to get you started.
With a healthy safety margin, your
design will be successful with the
first test. I

George Novacek ([email protected])


is a professional engineer with a degree in
Cybernetics and Closed-Loop Control. Now
retired, he was most recently president of
a multinational manufacturer for embed-
ded control systems for aerospace appli-
cations. George wrote 26 feature articles
for Circuit Cellar between 1999 and 2004.

RESOURCES
O. Hartal, Electromagnetic
Compatibility by Design, R&B
Enterprises, 1993.

M. Mardiguian, “Differential
sealevel.com > [email protected] > 864. 843. 4343
Transfer Impedance of Twisted
Pairs,”Interference Technology,
2010, www.interferencetechnology
.com/uploads/media/TDG10_ Learn more about eI/O Data Acquisition Modules at
Mardiguian_01.pdf. sealevel.com/cir/eio or scan this QR code with your
smart phone.
© 1986-2011, Sealevel Systems, Inc. All rights reserved.
www.circuitcellar.com • CIRCUIT CELLAR®
Engelberg_Layout 1 10/11/11 2:39 PM Page 50

QUESTIONS & ANSWERS


Embedded Design Theory & Practice
An Interview with Shlomo Engelberg
Shlomo Engelberg has been a member of the faculty of Jerusalem College of Technology’s
department of electronics since 1997. His research interests include the theory of ordinary
and partial differential equations, control theory, signal processing, instrumentation, and
measurement. Shlomo has written five articles for Circuit Cellar and is the editor-in-chief
of the IEEE Instrumentation and Measurement Magazine. In September 2011, I spoke with
Shlomo about his background in mathematics, engineering, and teaching. We also discussed
a few of his passions—most notably, math, teaching and explaining things, programming
microcontrollers, and Analog Devices’s microcontrollers and digital signal processors.
—Nan Price, Associate Editor

NAN: Where do you live and work? What city, country? within a few blocks of one another.

SHLOMO: I live in Bet Shemesh, Israel, and my primary NAN: How long have you been designing microcontroller-
job is in Jerusalem. based systems? What was your first design?

NAN: Do you spend part of the year in the United States? SHLOMO: I have been working with digital signal
processors (DSPs) and microcontrollers since the mid-
SHLOMO: I usually visit the United States a couple of 1990s. The first time I worked on a microcontroller proj-
times a year. During the summer, my family and I gener- ect I was part of a team developing a tool that would
ally spend about a month measure the constituent
visiting my parents in Far parts of fresh milk.
Rockaway, a neighborhood
in New York City. “When I was department chair, I NAN: You’ve been involved
always had a ’scope near at hand. I at the Jerusalem College of
NAN: You have a PhD in love math, but sometimes math is Technology department of
Mathematics. That means not enough, and I just have to see electronics for a number of
you spent a lot of time hit- years—first as a lecturer
ting the math books. So,
something actually work. I have a and most recently as an
when did you first become bit of equipment at home, and from associate professor. You
interested in electrical time-to-time I try to get my 14-year- also run a lab at Bar Ilan
engineering and how did old interested in working with University. What courses
you learn so much about microcontrollers. ” do you currently teach and
the field while studying where do you teach them?
mathematics?
SHLOMO: I enjoy teaching a wide variety of courses. I am
SHLOMO: Actually, I started off in electrical engineer- currently teaching an electronics course for computer engi-
November 2011 – Issue 256

ing. I earned a Bachelor of Engineering and a Master of neering students at the Jerusalem College of Technology.
Engineering from the Cooper Union (in Manhattan, Next semester I will be teaching a linear systems course at
NYC). Toward the end of my time as an undergrad, I the Jerusalem College of Technology and a microprocessor
realized that I wanted to study more mathematics. I lab at Bar Ilan University. In the spring, I will be teaching
went to NYU’s Courant Institute for my graduate work an introduction to control theory at Bar Ilan University.
in mathematics. During the 10 years I was studying in (I’ll be on sabbatical from the Jerusalem College of Tech-
college and graduate school, the schools I studied at were nology in the spring; otherwise, I would be teaching more.)

50 CIRCUIT CELLAR® • www.circuitcellar.com


Engelberg_Layout 1 10/11/11 2:39 PM Page 51

NAN: What are your main areas of interest and research at Though I do not believe that either of the projects you men-
this time? tion are still in use, I am currently working with a police
officer on ideas that will hopefully enable the police to veri-
SHLOMO: My research interests include the theory of fy that recordings were made when they were claimed to
ordinary and partial differential equations, control theory, have been made.
signal processing, instrumentation, and measurement.
I am currently working on coding theory, and I spend a NAN: Tell us about the microprocessor laboratory at the
fair amount of time Jerusalem College of
working on instrumen- Technology and Bar
tation and measure- Ilan University.
ment issues. (I am the
“When I look at the projects in my book,
editor-in-chief of the The ADuC841 Microcontroller Design SHLOMO: I used to
IEEE Instrumentation Manual: From Microcontroller Theory to run the microprocessor
and Measurement Mag- Design Projects, I see the history of the lab at the Jerusalem
azine, and that takes up subjects I was working on during the College of Technology.
quite a bit of my time.) Now I am loosely asso-
years the book was written. I had a good
I am also working on a ciated with the lab, but
set of simple experi-
time working on all of the projects and I I do not run it. At Bar
ments/demonstrations hope that my readers enjoy them too.” Ilan University, I am in
to accompany the elec- charge of a lab course
tronics course I am that is required of all
teaching. I enjoy trying students in the school
to present things in a way that helps people understand of engineering. On average, about 100 students pass
what I am trying to get across, and I hope that these through the lab each year. Teaching that course and run-
demonstrations help me achieve that goal. ning the lab have taught me quite a bit about managing a
large lab course. The first thing I learned is that it is impor-
NAN: In addition to teaching, you’ve also done a fair tant to have good staff members. Thankfully, the lab has
amount of writing. In fact, Circuit Cellar has published always been blessed with many excellent staff members.
five of your articles and will soon be publishing a book
you authored. In 2003, we ran your article “Spread Spec- NAN: Analog Devices’s microcontrollers figure promi-
trum: Theory and Practice” (Circuit Cellar 156), which nently in several of the projects you described in your
was designed to help readers comprehend the science Circuit Cellar articles. For example, the ADuC812 was
behind spread-spectrum techniques. Tell us how you featured in “Digital Watermarking.” It was also highlight-
came to write about that subject. ed in “Pseudo-Random Noise Theory and Applications”
(Circuit Cellar 171, 2004), which focused on building an
SHLOMO: At the time I wrote the article, I was working ADuC812-based noise-generation system that produces
on the mathematical theory of spread spectrum. (I pub- noise on demand. “Signal Processing with the ADuC812”
lished an article about spread spectrum in an academic (Circuit Cellar 174, 2005) details an alternative to digital
journal at about the same time as the article in Circuit processor chips, which can be difficult to interpret and
Cellar.) Though I love mathematics, I also like to see how low on peripherals. Why the these microcontrollers?
things work. Getting a simple version of spread spectrum
to work in a DSP-based system led to my Circuit Cellar SHLOMO: The reasons for using the ADuC812 and the
article which was written with Elihoshua Shekalim. ADuC841 are connected to my love of the 8051 and my
desire to have an onboard analog-to-digital converter (ADC)
NAN: Some of the projects in your articles have been and digital-to-analog converter (DAC) on the microcontroller
influenced by a member of the Israeli police force. In I use in the lab. I have used some of Analog Devices’s DSPs
“Digital Watermarking” (Circuit Cellar 183, 2005), you too, and I generally enjoyed the experience.
discuss a method for marking files for authentication and
security. In “Voice Changer Technology” (Circuit Cellar NAN: Your forthcoming Circuit Cellar book, The ADuC841
187, 2006), you describe a system that can detect when Microcontroller Design Manual: From Microcontroller The-
someone is using a voice changer. Tell us about those ory to Design Projects, is based on a lab you teach. What
November 2011 – Issue 256

two designs and how they came to fruition. Are they still compelled you to write the book? What can readers expect
in use? to learn?

SHLOMO: Over the years, I have done a fair amount of work SHLOMO: I love to explain things, and in this book I do my
with members of the Israeli police force. (Several of the best to explain 8051-based microcontrollers to my students
Jerusalem College of Technology’s graduates are police offi- and readers. The book has a set of labs designed to familiar-
cers who do engineering work for the police department.) ize the reader with the 8051 and several experiments that

www.circuitcellar.com • CIRCUIT CELLAR® 51


Engelberg_Layout 1 10/11/11 2:39 PM Page 52

introduce the reader to using the onboard ADCs and bit of equipment at home, and from time-to-time I try to
DACs. It also has a wide assortment of more advanced get my fourteen-year-old interested in working with
projects. microcontrollers.
When I look at those projects, I see the history of the
subjects I was working on during the years the book was NAN: What embedded-design-related projects are you
written. I had a good time working on all of the projects currently working on or planning? What can you tell us
and I hope that my readers enjoy them too. about them?

NAN: Are there any other “go-to” microcontrollers that SHLOMO: I have an industrial job that may be starting
you like? soon. Other than that, I generally make changes to my
microcontroller labs each year. As I try to never to give stu-
SHLOMO: Not really. I am hoping to start a project with a dents a lab that has not been thoroughly tested, making the
new (and much more powerful) microcontroller soon, but I changes takes a fair amount of time. Luckily, I really enjoy
haven’t started the project yet. programming microcontrollers.

NAN: Are you a do-it-yourselfer—meaning, do you have a NAN: As a professor, you have an interesting insight into
workspace at home where you work on projects in your what excites future engineers. What are the hot topics
free time? Or do you do most of your engineering at the currently captivating your students? Robotics? FPGAs?
university? Digital signal processing? Rapid prototyping (e.g.,
Arduino)?
SHLOMO: I do most of my engineering work in my
SHLOMO: I have a hard time generalizing here. I know
office at the Jerusalem College of Technology. Even when
what I am interested in and I try to interest my students in
I was department chair, I always had a ’scope near at
areas that I think are interesting and important.
hand. I love math, but sometimes math is not enough,
Right now, I have students working on digital signal
and I just have to see something actually work. I have a
processing topics. One of the students is work-
ing on implementing a pretty new and “hot”
[Book Excerpt] technique known as compressive sensing using
an ADuC841. That is a nice combination of a
The ADuC841 Microcontroller Design Manual mathematically sophisticated topic, some prac-
From Microcontroller Theory to Design Projects tical microcontroller work, and some MATLAB
by Shlomo Engelberg programming.

The main prerequisite for reading this book is a basic knowl- NAN: Last question. Let’s say you had as much
edge of programming. The labs in this book will, hopefully, time as you wanted to work on any embedded-
help the reader learn how to program in assembly language. design project you wanted. Call it your “dream
They are not designed to teach programming from the ground project.” What would it be?
up. Some of the later labs require some knowledge of electrical
engineering. At Bar Ilan University, the lab is given to students SHLOMO: I have a dream project, but it will
in the first semester of their third year. A couple of years in an probably seem a bit odd to most people. I seem
electrical engineering program should be sufficient to allow a to be surrounded by heaters and air condition-
student to understand the more electronics-oriented of the ers that claim to maintain a space at some
later labs. desired temperature. I ought to be able to set
Students entering the microprocessor lab often have no expe- the temperature as I please and walk away for
rience doing very low-level coding, and many of the students six months and return to a pleasantly cool
have grown up using desktop PCs running various operating home. Actually, I would never leave my air
systems. People who are accustomed to using such computers conditioner unsupervised for days or weeks.
are apt to think of computers as capricious and hard to under- My dream project is to put together a
stand. This book’s goal is to demonstrate that if you consider a heater/air conditioner, a network of sensors,
simple microcontroller, it is possible to see exactly why the and, possibly, fans that would all be controlled
microcontroller does what it does. In the space of one semes- by a microcontroller and that would actually
November 2011 – Issue 256

ter, of about 10 labs, it is possible to become sufficiently famil- keep a room at 20°C if that’s what was request-
iar with the Analog Devices ADuC841 to feel that you truly ed of it. In this fantasy, I would be able to set
understand it and many of its capabilities. the temperature once and be certain that, winter
or summer, any time I walked into my house
This book is slated for publication by Circuit Cellar in late 2011, the temperature would be just what I asked for.
early 2012. Someday, I hope to actually have the time to
design and build such a system. I

52 CIRCUIT CELLAR® • www.circuitcellar.com


53_Layout 1 10/06/11 2:50 PM Page 1
2011-11-013-Martin_Layout 1 10/11/11 2:59 PM Page 54

L ESSONS FROM THE TRENCHES by George Martin (USA)

Design Development (Part 4)


Processors, Power, and Interfacing
The first three parts of this series covered the processes for designing and
viewing schematics and using unified modeling language (UML) to design a
new product. Now it’s time for a detailed look at processors, power, and
interfacing to the transducers.

I n this series of articles, I have described the


process of designing a product from scratch.
Part 1 set up the required documents and a list
of requirements. Part 2 refined the requirements
approach. So, with little or no input, let’s just go
with an Ethernet interface. Speed is sufficient
and we can get power over Ethernet. It might be
too much to ask that the batteries run the unit
and presented a first pass at the hardware while that unit is communicating over Ethernet.
design. Part 3 presented a unified modeling lan- Low-cost CPUs are available with Ethernet inter-
guage (UML) diagram for the software. In each faces built in. Be careful when you select a CPU,
part, I described what we knew about the proj- as some have little of the hardware built in
ect and what could be worked on, leaving areas while others have everything except the connec-
in question for a later date. This is an example tor and magnetics.
of the “mañana design approach” at work. I This leaves several hundred—if not several
read about this a long time ago and can find no thousand—devices to choose from. The power
reference to it now. I find it a useful approach the CPU consumes is the next area I would
when there are a lot of unanswered questions. explore. If we select a 3.3-V device, the power
Now, I’m not claiming credit for the mañana will be less than a 5-V device. I believe we can
design approach, so if you like it, it’s yours. get a 16- or 32-bit device with RAM and flash
I left the CPU, battery, memory card, and memory built in. The operating speed is proba-
power supply for a later date because not bly not important for data logging but may
enough was known about these topics to do a show up when we’re running the Ethernet
design. Well, the future is now. It’s time to interface. I would look for the ability to pro-
make some decisions. gram in C and a great integrated development
environment (IDE). When we analyze power
CPU consumption we need to look at two distinct
Our system is a battery-powered data logger. areas. The first is sleeping. The CPU is in a
From our other requirements we find that the Low-power mode and waiting for an event to
November 2011 – Issue 256

CPU needs to have two I2C ports, one for the sen- wake it up and start running. The second is
sors and one for the SD memory card. Also, mod- power consumed when running and how fast
ern CPUs have USB and Ethernet built in. With- the CPU operates. The sleeping power is
out a firm requirement in the specifications or straightforward and probably a number right
any input from the customer, I would go with out of a datasheet. The second is more compli-
Ethernet as an interface. Connecting to the world cated. The calculation is to take the power
via the Internet would be a more universal when running multiplied by the time the CPU

54 CIRCUIT CELLAR® • www.circuitcellar.com


2011-11-013-Martin_Layout 1 10/11/11 2:59 PM Page 55

is running. So a faster, more power- batteries to fail (go boom). There’s


consuming CPU may have a lower Running From Flash: no need for us to take on those prob-
Current Consumption 80 mA
operating power if it gets the work lems. If I do a quick search for bat-
VDD = 3.3 V
done faster. Code = while(1){} executed in flash teries on Digi-Key’s website, I see
Let’s say that wake up, gather data, Peripherals = All ON the available technologies are alka-
save to memory card, and go to sleep System Clock = 50 MHz (with PLL) line, lithium, nickel cadmium, nick-
Temp = 25°C
are our normal operations and we do el-metal hydride, zinc, and lead acid.
that every 6 s. This is the same analy- Sleep Mode One could make a career—perhaps
sis we did for sizing the memory in Current Consumption 8 mA even several careers—out of battery
my previous article. If the CPU ran for VDD = 3.3 V design and selection. Let’s just
Peripherals = All clock gated
1 s out of the 6 s then we could take: assume that alkaline is not recharge-
System Clock = 50 MHz (with PLL)
Temp = 25°C able and lead acid may tip over and
( operating power + sleeping power × 5) spill. This would just eliminate
6 Deep Sleep Mode these from consideration. I know
Current Consumption 550 μA
and get the average power. And, as that both types of batteries have
Peripherals = All OFF
we operate faster, the contribution of System Clock = IOSC30KHZ/64 their applications.
the operating power becomes less of Temp = 25°C When looking for a battery, you
the total power. I expect the opera- need to consider capacity in ampere
tion will consist of waking up the Figure 1—Data from Texas Instruments’s hours (Ah), voltage (V), discharge
sensors, taking readings, and writing Stellaris datasheet rates in amps (A), and shelf life usual-
the data to the memory card. We ly in years. Some batteries have a
could probably double buffer the data so that waking up high capacity, large discharge rates, and a short shelf life.
the sensors and reading the sensors would run concurrently These would be good for power tools that are recharged
with writing the previous readings to the memory card. every evening. At the other end of the spectrum are batter-
And, if this CPU took 1 s out of 6 s to do the work ies with a low discharge rate and long shelf life (seven
described above, we would have: years). These are good to back up the clock in your PC.
For our application, I would look for a battery with a
(80 mA + 5 × 0.55 mA) = (80 mA + 2.75 mA) capacity of 5,000 mAh (10 days of operation as the calcula-
6 6 tions currently stand), discharge rates from 0.08 to 8.00 A,
82.75 mA voltages of 4 to 6 V, and a shelf life or self-discharge rate of
= = 13.79 mA
6 at least one month.
At 3.3 V, that’s 45.5 mW and 24 hours of operation is This search came up with a Panasonic nickel-metal
1092.17 mW (i.e., 24 × 45.5) hours per day. If the CPU did hydride battery pack. It isn’t hazardous and doesn’t require
its work in 0.5 s, we would have: special disposal, except in California. I would, however,
responsibly recycle any used up batteries. The specific rat-
(80 mA + 11 × 0.55 mA ) = (80 mA + 6.05 mA) ing of this battery pack is 3.6 V with 3,500-mAh capacity.
12 12
This battery is made up from individual cells. If we ever
86.05 mA
= = 7.17 m need more (or less) capacity or voltage, it’s straightforward
12
to select a different battery pack using the same internal
At 3.3 V, that’s 23.7 mW and 24 hours of operation is technology.
567.93 mW (i.e., 24 × 23.7) hours per day. So, faster CPUs I believe the size of this battery pack is 2.4” × 4” × 1.3.”
can sometimes consume less power overall. So, when we size the case, we will need to have room for
I had the Texas Instruments Stellaris datasheet handy, so I the battery.
started there (see Figure 1). Let’s look at Freescale Semicon-
ductor’s K60 Kinetis ARM Cortex-M4 microcontroller. This MEMORY CARD
version has all the features we will need. It claims less than A lot has been written about SD memory cards and sev-
500 nA in Stopped mode and 200 µA/MHz in Run mode. Say eral articles have appeared in Circuit Cellar. I went to the
we run at 20 MHz. That’s 4 mA at, say, 3.3 V for 13.2 mW website and did a search on “SD Memory cards.” There are
for full-power operation—not much different than the Texas enough results in that search to fill up several days of read-
Instruments microcontroller. I would also recommend look- ing. Basically, the SD card looks like a SPI device at power
ing at the new Renesas offerings. up. We have reserved one complete SPI interface in the
November 2011 – Issue 256

microcontroller for the interface to an SD card. It would be


BATTERY great if we had a file system that could be called up rather
Let’s jump to the battery to see what this calculated that designed from scratch. So, go back to CPU selection
power consumption means. I’d like to select a battery and add a requirement of SD interface code. As I was look-
that can be removed and connected to a separate charging ing through the Circuit Cellar discussion groups, I came
device. That way we are not trying to build battery charg- across a reference to Brush Electronics. They have code for
ers. They have been known to catch fire and also cause an SD card file system. Their code is for the PIC CPU. If

www.circuitcellar.com • CIRCUIT CELLAR® 55


56_Layout 1 09/27/11 11:43 AM Page 1

BOARDS, BOOKS, DVDs AND MORE AT WWW.ELEKTOR.COM/SHOP

Elektor Shop
The world of electronics
at your fingertips! Bestseller!

W ! Free mikroC compiler CD-ROM included

Controller Area Network


NE Projects
The aim of the book is to teach you the basic
principles of CAN networks and in addition the
development of microcontroller based
projects using the CAN bus. You will learn how
to design microcontroller based CAN bus
nodes, build a CAN bus, develop high-level
programs, and then exchange data in real-
time over the bus. You will also learn how to
build microcontroller hardware and interface
it to LEDs, LCDs, and A/D converters. This book
comes complete with a free CD-ROM.

260 pages • ISBN 978-1-907920-04-2 • $47.60

ore
This book and m
are available at
m/books
www.elektor.co
Books

LabWorX: Straight from the Lab to your Brain

Mastering the I²C Bus


User: “Computer, turn on hall lights” _ Computer: “Hall lights on”
Mastering the I²C Bus is the first book in the Lab-
Design your own PC Voice Control System WorX collection. It takes you on an exploratory
Don’t you feel it’s just about time we could simply talk with computers and get them to handle journey of the I²C Bus and its applications.
some of the everyday house automation tasks - lights, doors, gates, curtains, televisions, Besides the Bus protocol plenty of attention is
music and other domestic appliances? Or even make the information super-highway slicker given to the practical applications and designing
by talking with you and telling you about the information you requested to be retrieved from a solid system. The most common I²C compatible
the web? Think of all the time and inconvenience you could save - no more need to install chip classes are covered in detail. Two experimen-
yourself at a desk and fumble about with keyboard and mouse. Well now you can! This book tation boards are available that allow for rapid
guides you through practical speech recognition, speech annunciation and control of really prototype development. These are completed
useful peripherals. If you are interested in the practical technology of interfacing with by a USB to I²C probe and a software framework
machines using voice, such as talking with your own PC, then this book is your guide. to control I²C devices from your computer.

Approx. 216 pages • ISBN 978-1-907920-07-3 • $47.60 248 pages • ISBN 978-0-905705-98-9 • $47.60

Prices and item descriptions subject to change. E. & O.E

ELEK US1110 CCshop.indd 80 17-08-2011 09:29:48


57_Layout 1 09/27/11 11:49 AM Page 1

CD/DVD-ROMs

Bestseller!
Elektor’s Components Database
Elektor OSPV USB Long-Term
CD ECD 6 The Elektor Wheelie, which we launched a
This CD-ROM gives you easy access to design while ago, has been adopted by schools and
Weather Logger
data for over 70,000 components! The pro- private individuals who want to gain a This stand-alone data logger displays pressure,
gram package consists of eight databanks thorough understanding of the technology temperature and humidity readings generated
covering ICs, transistors, diodes and opto- behind self-balancing vehicles. This new Elek- by I2C bus sensors on an LCD panel, and can run
couplers. A further eleven applications cover tor OSPV is based on the same concept, but for six to eight weeks on three AA batteries.
the calculation of, for example, zener diode with the difference that it’s for indoors, it’s The stored readings can be read out over USB
series resistors, voltage regulators, voltage easy to steer, it’s light and foldable and…it’s and plotted on a PC using gnuplot. Digital
dividers and AMV’s. A colour band decoder open source. You can configure or modify it to sensor modules keep the hardware simple and
is included for determining resistor and induc- suit your wishes. This self-balancing vehicle is no calibration is required.
tor values. All databank applications are fully perfect for factory halls, warehouses, hospitals
interactive, allowing the user to add, edit and and schools. Check www.elektor.com/ospv for +ITOFPARTSINCL0#" CONTROLLER HUMIDITY

complete component data. This CD-ROM is a further information! SENSORANDAIRPRESSURESENSORMODULES

must-have for all Electronics enthusiasts!


Art.# 100888-73 • US $50.20
+ITOFPARTS
ISBN 978-90-5381-258-7 • $40.20
Art.# 110320-91 • $1570.00

Elektor is more
than just your favorite
electronics magazine.
Bestseller! It’s your one-stop shop
Circuits, ideas, tips and tricks from Elektor for Elektor Books,
CD 1001 Circuits CDs, DVDs, Pico C Meter
This CD-ROM contains more than 1000 circuits, Kits & Modules Even upmarket digital multimeters boasting a
ideas, tips and tricks from the Summer Curcuits built-in capacitance meter are useless if you
issues 2001-2010 of Elektor, supplemented and much more! want to check out tiny capacitances like 2.7 pF
with various other small projects, including all
www.elektor.com/shop or 5.6 pF. Usually, you’re tied to a lowest mea-
Kits & Modules
circuit diagrams, descriptions, component lists suring range of 2000 pF, which is a good laugh
and full-sized layouts. The articles are grouped to RF designers and radio amateurs. Although
alphabetically in nine different sections: audio at 3.5 digits the DMM’s resolution is 1 pF, any
& video, computer & microcontroller, hobby & measurement below 200 pF or so will produce
modelling, home & garden, high frequency, coarse if not ridiculous results. Pico C does a far
power supply, robotics, test & measurement better job. Beating many DMMs hands down,
and of course a section miscellaneous for this little instrument easily measures capaci-
everything that didn’t fit in one of the other Elektor US tances down to fractions of a picofarad.
sections. Texts and component lists may be PO Box 180
searched with the search function of Adobe Vernon, CT 06066 +ITOFPARTSINCL%LEKTOR0ROJECT#ASE
Reader. USA PROGRAMMEDMICROCONTROLLER ,#$AND0#"
Phone: 860-875-2199
ISBN 978-1-907920-06-6 • $55.70 Fax: 860-871-0411 Art.# 100823-71 • $118.40
E-mail: [email protected]

ELEK US1111 CCshop.indd 81 12-09-2011 16:18:43


2011-11-013-Martin_Layout 1 10/11/11 2:59 PM Page 58

V3.3 V3.3 Group 1 Cellar 254, 2011.) We


clearly have to balance
D?
Battery in 3.3 V Out In Out each decision off all the
BB Enable
D Schottky Group 1En
Enable datasheets of all the inte-
BT? Enable
Battery High-side switch
grated circuits in our
Buck-boost regulator V3.3 Group 2 design. The power sup-
D? ply/battery combination
GND_DIG
In Out
In Out needs to meet the require-
D Schottky
Group 2En ments of the most restric-
Enable
Low drop-out regulator
High-side switch tive device in our design. It
Power requirements TBD
PCB requirements TBD
may pay to reevaluate our
Power supply
initial parts selections now
Figure 2—Power supply schematic that we are more educated
about our design.
you’re going to use a PIC, then you’re all set. If not, then
you’ll need to keep looking, write one yourself, or purchase THE POWER SUPPLY DESIGN
one and modify it. This last process might not be too diffi- Let’s try a first pass at the power supply design and see
cult since it’s a simple SPI interface. Perhaps just the low- what happens. Let’s assume we use the battery pack that
level code (code that touched the hardware) needs to be is 3.6 V nominal. That’s 4.2 V (i.e., 3 × 1.4) maximum
rewritten. and 3.3 V (i.e., 3 × 1.1) minimum if you look at the dis-
We have to select connectors, decide if the user will have charge curve.
access to the card, and determine what size cards to sup- Other buck-boost controllers to consider include Analog
port. But for now, let’s stop here. I’m sure more questions Devices, which has the ADP2504/2504, and Linear Tech-
will come up as we move through the design. nology, which has the LTC3440. Both of these devices can
handle our input voltage range and can produce a 3.3-V
POWER SUPPLY output. Their prices are less than $3 at the 1,000-piece
We need a power-supply design that will take the 3.6-V level. They both require an external inductor and several
nominal battery output and make 3.3 V for the circuitry. other components. Both have efficiencies in the 90% range.
That’s easy. Just put in a low drop-out (LDO) regulator and I would be cautious about basing too many decisions on
we’re all done. Hold your horses. It’s never that simple. If this efficiency number at this point in the design process.
we look at the discharge curve for the battery we see 3.6 V And, both manufacturers offer evaluation boards for the
for 80% of its life and less than that for the other 20%. I devices. Using the evaluation boards you can be up and
think we need to extract that remaining 20%. One choice running with little effort on your part.
would be to use a four-cell pack. Digi-Key supplies a four- The CPU (yet to be selected) will have the capability to
cell pack that gives 4.8 V at 6,500 mAh: Panasonic’s nickel go into a low-power mode. What we need is for it to be
metal hydride batteries. So, that’s the simple solution. It able to turn off power to the other devices in the system.
costs more money and is a larger size. The boss won’t be Shutting them down would save considerable power. The
happy; neither will the customer. cost will be in the switching circuitry that actually shuts
Another solution is to lower our operating voltage. This is them down and the power lost during the wake-up time
probably a good approach. I’m finding many of the modern for these devices. If we shut down the accelerometer, we
chips will work from 3.3 V down to 2.2, 2, or even 1.8 V. So, won’t get any readings. So, that device may need to be
if this is your choice, you need to take a look at all the continuously powered.
datasheets and see if the components will run with that low Looking for a high-side switch, I did another search on
of a power-supply voltage. Digi-Key’s website. I found several devices. Among them,
Another choice is a buck-boost regulator. When the bat- ON Semiconductor’s NCP380 single-channel current-limit-
tery voltage is higher than 3.3 V, the regulator reduces that ing power distribution load switch. This device has several
voltage to 3.3 V (buck). When the battery voltage is less uses (current limiting) but it has an enable input. When
than 3.3 V, the regulator increases the battery voltage that input is low, the device output is disabled. This input
(boost). Texas Instruments’s UCC2942 buck-boost con- is meant to be driven from a TTL or CMOS signal. So, we
troller is one such device. This IC takes battery voltages as could have one of these switches for each device or group
low as 1.8 V and as high as 8 V and will produce a 3.3-V of devices we want to control.
November 2011 – Issue 256

regulated output. The advantage is that we could use the Now we have to look at the datasheets for the devices
smaller/lower-cost three-cell battery. The disadvantage is and see what happens when we shut down the power. For
that this device is complex to use and generates switching example, if we shut down each device one by one will the
noise. That switching noise needs to be eliminated for the serial bus we are using for communications still work?
analog measurement portion of our design. Details like these will keep the unit from working the way
This certainly looks like chaos. (Refer to my article, we want it to.
“Design Development (Part 4): Software Design,” Circuit Let’s consider one more optimization we could make.

58 CIRCUIT CELLAR® • www.circuitcellar.com


2011-11-013-Martin_Layout 1 10/11/11 2:59 PM Page 59

When we are powered down, the current draw will be very George Martin ([email protected]) began his career in the
little, so little that we could shut down the buck-boost regu- aerospace industry in 1969. After five years at a real job, he
lator and save more power. We could do this with a com- set out on his own and co-founded a design and manufactur-
parator and feed back to the buck-boost controller. But, there ing firm (www.embedded-designer.com). His designs typically
may be an even easier approach. If the CPU goes into Low- include servo-motion control, graphical input and output, data
power mode and then shuts down the buck-boost regulator, acquisition, and remote control systems. George is a charter
we would save the power required to run that regulator. But, member of the Ciarcia Design Works Team. He is currently
eventually, the power on the CPU and any capacitors working on a mobile communications system that announces
attached would be used up. How about connecting a diode highway info. He is also a nationally ranked revolver shooter.
directly from the battery to the CPU? This would work to
supply that low-power mode. Well, that’s acceptable, but
when the battery pack is fully charged, I think the voltage RESOURCES
would be too high. So, how about a LDO regulator with a Brush Electronics, www.brushelectronics.com.
blocking diode on its output that would only supply power Panasonic Industrial Co., “Nickel Metal Hydride Batter-
in the low-power operating mode? ies: Individual Data Sheet,” 2005, http://panasonic.com/
I’ve implemented this approach in the power supply industrial/includes/pdf/Panasonic_NiMH_HHR650D.pdf.
schematic (see Figure 2). All the Enable signals come from
the CPU. With all Enables off, the LDO regulator is supply- SOURCES
ing power to the CPU and other sensors that are powered. ADP2504/2504 Buck-boost DC-to-DC converter
It’s not very efficient, but it should be a low power draw. Analog Devices, Inc. | www.analog.com
The Schottky diodes are added to isolate the two main reg- K60 Kinetis ARM Cortex-M4 microcontroller
ulators. These introduce additional voltage drop (loss) in Freescale Semiconductor, Inc. | www.freescale.com
the power supply. Linear Technology has an application
note that describes how to turn a MOSFET into a low-loss LTC3440 Buck-boost DC/DC converter and LTC4411
diode. It also offers LTC4411, which is a 2.6-A, low-loss, 2.6-A low-loss ideal diode in ThinSOT
ideal diode in ThinSOT that uses that technique. Linear Technology Corp. | www.linear.com
I have not shown where I would place the capacitors in NCP380 Power distribution switch
this design. And I have not shown any filtering on the ON Semiconductor | www.onsemi.com
power supply. I think we will need both. We have devices
that are converting the physical parameters into digital sig- Nickel metal hydride battery pack
nals. And you may think we don’t have to worry about Panasonic Industrial Co. | www.panasonic.com
noise in the power supply. Well, I bet we do. I would con- Stellaris MCU Family and UCC2942 buck-boost controller
sider putting the filtering into the power supply. I believe Texas Instruments, Inc. | www.ti.com
the filtering we need is to eliminate the switching frequen-
cy that the buck-boost regulator has introduced.

THE SCIENCE OF DESIGN NEED-TO-KNOW INFO


Is product design a science or an art form? I think it’s a Knowledge is power. In the computer applications
science. It should be a science. But as you see from what industry, informed engineers and programmers
we’ve just been through, there are a lot of subjective deci- don’t just survive, they thrive and excel. For more
sions you need to make as you design a product. In a for- need-to-know information about some of the topics
mer life, while working with Steve Ciarcia at an aerospace covered in this article, the Circuit Cellar editorial
company, we watched as the system engineers would do staff recommends the following content:
the system design. That would result in a document —
Battery Analysis
describing all the functional components of a product with
Build an MCU-Based Analyzer Unit
specific performance numbers attached when required.
by Richard Pierce
That was—and is—clearly a scientific process. In the com- Circuit Cellar 254, 2011
mercial field, we need to move more rapidly with not all Battery ratings aren’t always accurate. In fact,
requirements and design questions answered, and that is many batteries don't meet their rated capacities.
considerably more art than science. In the end, a good prod- This microcontroller-based battery analyzer enables
uct must work and meet the requirements of the market. I you to sort the good from the bad. It’s designed for
November 2011 – Issue 256

hope you enjoyed the past few articles. I’ll return to more use with single-cell li-ion batteries with a nominal
specific topics, but I’ll use what we’ve just been over as I 3.7-V rating, and you can use it with various cell
design new systems. In fact, I’m starting two new designs Topics: Battery, Li-ion, MCU, Analyzer

this week. Let me know how you approach system design
Go to Circuit Cellar’s webshop to find this article
and I’ll share it with our readers. Next time, I’ll present an
and more: www.cc-webshop.com
article on A/D converters, switching power, supply noise,
and filters. I

www.circuitcellar.com • CIRCUIT CELLAR® 59


2011-11-007_Wotiz_Layout 1 10/11/11 3:56 PM Page 60

E mbedded Unveiled by Richard Wotiz (USA)

Ionization Detectors

It’s time for a look inside a curious type of sensor that’s used to bridge the
gap between electricity and particle physics. This article covers a family of
devices that measures ionizing radiation.

W elcome back to Embedded Unveiled!


This month we’ll journey inside
an unusual type of sensor that’s used to bridge
the gap between electricity and particle
physics. There are many types of detectors
electric field between a pair of electrodes that
attracts these charged particles before they
recombine, causing a current to flow.

CATCHING RAYS
that use the principle of ionization to measure Three related types of ionization detectors
a variety of physical or chemical phenomena. are used for measuring radioactivity. They all
I’ll take a look at one family of devices that use a sealed metal container with a pair of elec-
measures ionizing radiation. Then I’ll peek trodes. Often the container itself acts as one of
inside an ionization smoke alarm to see how the electrodes. There is also a window that’s
it works in the presence of varying amounts transparent to the particular type of radiation
of smoke. Don’t worry, no build-
ings were harmed in the creation
of this column!
First, here’s a quick lesson on
the physics behind an ionization
detector. There are many meth-
ods of producing ions, both natu-
rally occurring (such as light-
ning), and man-made (such as a
particle accelerator). A positive
ion is created when an atom or
molecule loses an electron, giv-
ing it a net positive charge. The
negatively charged free electron
can then combine with another
atom or molecule, creating a neg-
November 2011 – Issue 256

ative ion. Since opposite charges


attract, positive ions and either
negative ions or free electrons in
close proximity will be drawn
together and recombine, neutral- Photo 1—The inside of a smoke detector with the ionization chamber
izing each other. The ionization removed. You can see the test button at the top of the printed circuit board
detector works by creating an (PCB) and the alarm sounder mounted to the top cover at the far left.

60 CIRCUIT CELLAR® • www.circuitcellar.com


2011-11-007_Wotiz_Layout 1 10/11/11 3:56 PM Page 61

not depend on the energy of


+V
the incoming particle; it can
only be used to count parti-
+V cles. This process results in
the familiar clicking sound
produced by a Geiger counter
Sleep that has an audio output.
Control logic
Ionization chambers are
REF commonly used in smoke
+
Sense Detect LED alarms that you can buy for

your home. But instead of
measuring external radiation,
Test Horn
the chamber contains a weak
+ radioactive source to create
Ionization Guard
chamber
– its own stream of ions. It’s
+V also open to the outside air,
so smoke can enter and
Battery
affect the movement of the
ions. This changes the cur-
rent flow through the cham-
Figure 1—The key components of the smoke detector. The sense input circuitry and control logic are ber’s electrodes, which
contained within a single integrated circuit. sounds the alarm.

being measured. When a radioactive particle enters the SMOKE ALARMS


container, it may collide with an atom of the gas that is The first battery-powered smoke alarms appeared on
inside. If the particle has enough energy, it will knock off the market in 1969, but they didn’t come into widespread
an electron, ionizing the atom. use in the U.S. until the following decade.[1] That’s when
The key difference between the detector types is the the national building codes first included a requirement
range of electrode voltages. The simplest, but also the for smoke alarms in new homes, and Underwriters Labo-
least sensitive, is the ionization chamber. It can operate ratories first developed standards for them. As a result,
on a voltage as low as a few volts. When ions are created manufacturing of smoke alarms jumped from an estimat-
in the chamber, the electric field between the electrodes ed 50,000 units in 1971 to more than one million by
will draw positive ions to the negative electrode and nega- 1974, increasing to more than 10 million annually by the
tive ions to the positive electrode. This movement, called mid-1980s.[2]
drift, is proportional to the strength of the electric field. It Photo 1 shows the inside of a typical ionization smoke
is a slow phenomenon, typically less than 1 m/s. The alarm. I was quite surprised when I first opened one up; I
drift causes a current to flow that’s proportionate to the was expecting to see a bit more complexity. It turns out
number of ions reaching the electrodes. The current can almost all of the circuitry is contained in a single IC, in this
be very small, typically in the picoampere range, so you case a Microchip Technology RE46C152 low-power CMOS
need a sensitive amplifier with extremely high input ionization-type smoke detector IC. Figure 1 shows a simpli-
impedance. This is not difficult with modern FETs, but in fied schematic of the unit. The ionization chamber has
earlier days, you’d need an expensive electrometer to get a
meaningful signal.
The second type of detector is known as a proportional
counter. The physical construction is similar to an ioniza-
tion chamber, but it uses a higher voltage. This causes an
avalanche effect, where a free electron is accelerated
enough by the electric field to knock off more electrons
from additional atoms. The avalanche eventually dies out
on its own. This results in an amplification effect, which
produces an output signal that’s proportional to both the
November 2011 – Issue 256

electrode voltage and the energy of the radioactive particle


that started the process.
The last type, which is the most sensitive, is the Geiger-
Müller tube. Like the proportional counter, it depends on
the avalanche effect. But the voltage is set high enough so Photo 2—The bottom of the PCB. Part of the board is covered in
that the entire gas volume in the container will ionize with beeswax to protect the high impedance paths from contamination
each incoming particle. Therefore, the output signal does that could lead to excessive leakage current.

www.circuitcellar.com • CIRCUIT CELLAR® 61


2011-11-007_Wotiz_Layout 1 10/11/11 3:56 PM Page 62

three electrodes, which enables the sense signal


Unipolar Bipolar
to be measured independently from the chamber region region
supply current. The chamber’s output impedance
is high enough that even the slightest leakage
current will shift its voltage level. To combat Open
− + –
slots –
this, the adjacent pins on both sides of the IC’s –
sense input are guard pins, which are outputs +

driven to the same level as the input. This mini- – + –
Metal
– Sense
container
mizes leakage across the IC package. The input
pin itself isn’t connected to the printed circuit +V
+ – +
board (PCB); rather it is bent upward and soldered – + –
– + Am-241
directly to the chamber’s sense pin. If you look
closely near the bottom right corner of the IC in
Photo 1 you can see a solder blob where I unsol-
dered the pin from the chamber. The rest of the Figure 2—The ionization chamber contains a small radiation source to ionize the
circuitry isn’t quite as high impedance as the air inside. The ions are drawn to the opposite polarity electrode, causing a small
sense input, but it can still be affected by humidi- current to flow.
ty or dust settling on the PCB. Photo 2 shows the
bottom of the board covered in beeswax, which is
much less expensive than a conformal coating, but still the proper equipment to find out. In any case, that would
does the job. only reduce the saturation current, which wouldn’t change
how the chamber operates.
IONIZATION CHAMBER There are two basic configurations for an ionization cham-
Figure 2 is a diagram of the ionization chamber. The ber. In a bipolar chamber all of the air is ionized, so both
radioactive source is specified on a label on the smoke positive and negative ions are present throughout its vol-
alarm as 0.9 microcuries (µCi) of Americium-241 (Am-241), ume. A unipolar chamber is designed so the radiation source
which emits a constant stream of alpha particles. The par- only ionizes part of the air. The rest of the chamber will
ticles have an energy of 5.486 × 106 electron volts (eV), only contain ions of a single polarity that have been pulled
which will travel up to 4 cm in air. Alpha particles are the there by the electric field. A space-charge region, acting as a
largest and slowest type of radioactive particle and can be boundary layer, will form between the two areas. This will
stopped by a sheet of paper. But, their large size also gives enable ions to travel to the unipolar area at a relatively con-
them enough mass to impart significant energy to whatev- stant rate if the chamber is being operated at saturation. The
er they may bump into, which makes them extremely dan- term “unipolar” may seem a bit misleading since the cham-
gerous to come in contact with. I was careful to take prop- ber does contain both positive and negative ions, but it
er safety precautions when removing the chamber from the refers to the fact that part of the chamber farthest from the
PCB for the photo. I then replaced it right away without radiation source only contains ions with one polarity. In
disassembling it any further. both chamber types, ions will be attracted to uncharged
The maximum current that can flow through the cham- smoke particles if they are present and will attach them-
ber is given by:[3] selves to the smoke. The charged smoke particles move
E  much more slowly than the ions, which will cause a reduc-
IS = e  m  F Q S, where: tion in current flow in the chamber. The unipolar chamber
 Ei 
is more sensitive to smoke density, and less affected by envi-
IS = chamber saturation current (amps)
ronmental changes and air movement.[4]
e = charge of an electron = 1.6 × 10 −19 C
The geometry of the chamber I examined appears to be
E m = ionizing particle energy = 5.486 × 106 eV designed to have a unipolar region, since the sense elec-
Ei = ion pair formation energy ≈ 14 eV for air (nitrogen and oxygen) trode partially shields the alpha source so it’s not exposed
F = efficiency factor of radioactive source (assume 1.0) to the entire chamber volume. In operation, no appreciable
3.7 × 1010 current flows to the sense input, so the sense electrode
nizing particles per second per curie =
Q = ion
s will take on an intermediate voltage between the other
Ci two electrode voltages. When smoke enters the chamber,
S = source activity = 0.9 × 10−6 Ci it will have a much greater effect on the unipolar region,
November 2011 – Issue 256

This gives a saturation current of 2.1 nA. The chamber is since its supply of ions is limited by the ion flow across
supplied from the 9-V battery through a 1-M resistor, so the boundary layer. This will cause a larger voltage drop
the chamber is being operated at saturation. I used an effi- between the sense electrode and the positively charged
ciency factor (F) of 1.0, which assumes that there isn’t any metal container. The sense voltage will decrease by an
filtering of the alpha particles. It’s possible that the source amount that’s approximately proportional to the smoke
includes a thin layer of gold foil to reduce the particle concentration times the average particle size, eventually
energy, which would reduce F, but I don’t have access to triggering the alarm.

62 CIRCUIT CELLAR® • www.circuitcellar.com


12_Layout 1 09/07/11 1:34 PM Page 1
2011-11-007_Wotiz_Layout 1 10/11/11 3:56 PM Page 64

After leaving the unit in the refriger-


ator overnight, I found the Sense sig-
nal had dropped slightly to 5.07 V
from its nominal room-temperature
value of 5.30 V. Next, I subjected the
alarm to the high-humidity environ-
ment of a hot shower, but I didn’t see
any measurable change in the output.
I didn’t have any practical way to test
it at varying pressures—I could only
imagine trying to explain to airport
security why I was carrying a disas-
sembled smoke alarm and some test
equipment onto an airplane!
Residential smoke alarms like the
one I tested are calibrated at the fac-
tory and are designed to stay within
specifications for their 10-year oper-
Photo 3—The system’s response to a small puff of smoke. The scope’s sampling rate is too
slow for the REF amplitude to be accurate, but you can see the periodic sampling every ating lifetime. Their performance is
1.59 s until SENSE drops low enough to trigger the alarm. specified by the UL217 standard (see
Resources). I noticed that the units I
examined each had a different resis-
TESTING tor value installed at a particular location on the PCB that
At this point, I wanted to try out the smoke alarm for affected the REF voltage level. That’s to compensate for
myself. I opened one up that still had its ionization cham- unit-to-unit variations in the ionization chamber’s out-
ber intact, disconnected the piezo beeper, and connected put. Smoke alarms designed for non-residential buildings
some wires to the Guard and REF pins. That way I could are subject to more stringent accuracy and testing specifi-
look at the detection comparator signals while it was oper- cations, both at manufacture and during their lifetime,
ating. Since the Guard pin is driven to the same level as and are evaluated using the UL268 standard. They’re
the Sense input, it enables me to monitor the chamber’s required to have regular testing to confirm that their sen-
voltage without putting any additional loading on its high- sitivity is within range, rather than just a simple Go/No-
impedance output. Photo 3 shows the system responding to go functional test.[5] To get this level of accuracy and sta-
a small puff of smoke. The comparator status is checked bility, the alarms have two identical ionization chambers.
about every 1.5 s until smoke is detected. Then it’s repeat- One is exposed to smoke and the other is protected so
edly checked until the smoke clears. While the alarm is smoke can’t enter. The alarm is triggered when the volt-
sounding, the LED blinks once per second. You can see age difference between the two chambers exceeds a set
small blips on the Sense signal as the battery voltage dips threshold. Any environmental or lifetime-related drift
slightly with each blink. You’ll also
see a corresponding gap in the REF
signal, since the comparator isn’t
checked during the blink to avoid a
false reading.
Photo 4 is a closeup of the alarm
trigger point. You can see the REF
signal more clearly as it gets enabled
by the Sleep signal to take a meas-
urement about every 40 ms. The
smoke alarm also has a hush feature
that temporarily silences a false
alarm. It works by reducing the REF
signal by about a volt, which makes
November 2011 – Issue 256

the alarm less sensitive without


entirely disabling it.
I wanted to see how sensitive the
ionization chamber was to changing
environmental conditions, since it
can be affected by temperature, Photo 4—A closeup of the alarm trigger point. Note the 187-mV hysteresis on the REF signal
humidity, and atmospheric pressure. under the cursors. The horizontal scale is 50 ms per division.

64 CIRCUIT CELLAR® • www.circuitcellar.com


2011-11-007_Wotiz_Layout 1 10/11/11 3:56 PM Page 65

will affect both chambers equally and will only have a


minimal effect on the alarm’s sensitivity.
I hope you’ve enjoyed this journey into the world of
NEED-TO-KNOW INFO
Knowledge is power. In the computer applications
smoke and physics. I certainly have a new appreciation for
industry, informed engineers and programmers don’t
all the research that’s gone into fire detection in the past just survive, they thrive and excel. For more need-
50 years, as well as what really happens when I hear that to-know information about some of the topics cov-
unmistakable beeping sound. I ered in this article, the Circuit Cellar editorial staff
recommends the following content:

Richard Wotiz has been taking products apart ever since he A Look at “Battery-in-a-Chip” Technology
was old enough to pick up a soldering iron. He’s been helping by Tom Cantrell
others put them back together since 1991, when he started Circuit Cellar 228, 2009
Got Energy? Energy harvesting is all the rage,
his design consulting business. Richard specializes in hard-
but like a real harvest you need a place to store
ware and software for consumer products and children’s toys.
the crop. This month, Tom introduces the next
He can be reached at [email protected]. advance in thin-film rechargeable lithium battery
technology: a battery-in-a-chip. Topics: Battery,
Enerchip, Li-on, CBC050, Charge, Supercap,

REFERENCES
Capacity, CBC-EVAL-08, Ez430-RF2500, Energy
Harvesting NE
[1] R. Bukowski et al., “Performance of Home Smoke — Know
Alarms: Analysis of the Response of Several Available Self-Powered Solar Data Logger indus
by Abigail Krich just s
Technologies in Residential Fire Settings,” NIST
Circuit Cellar 198, 2007 know
Technical Note 1455-1, National Institute of Stan-
Abigail designed a microcontroller-based, self- in thi
dards and Technology, 2008. powered solar data logger that uses a photodiode mend
to measure solar insolation levels. The system
[2] R. and G. Mulholland, “Smoke Detector Design converts the analog signal to a digital value that’s Netw
and Smoke Properties,” NBS Technical Note 973, stored in flash memory. Topics: Solar, Data Log- Build
National Bureau of Standards, 1978. ger, Insolation, Photovoltaic, ATmega32, STK500, by Th
Photodiode, ADC, LCD Circu
[3] C. Litton, “Optimizing Ionization-Type Smoke — Tho
Detectors,” Fire Technology, Vol. 15 No. 1, 1979. iEthernet Bootcamp (ITAP
Get Started with the W5100 easy-t
by Fred Eady into a
[4] A. Scheidweiler, “Physical Aspects of Ionization
Circuit Cellar 208, 2007 matio
Chamber Measurement Techniques (Unipolar and
Are you ready to join the Ethernet revolution? If Topic
Bipolar Chambers),” Fire Detection for Life Safety, so, it’s time to start working with WIZnet’s W5100 noid,
Proceedings of a Symposium, National Research hardwired TCP/IP embedded Ethernet controller. In
Council (U.S.) Committee on Fire Research, 1975. this article, Fred helps you get started on your first Temp
W5100-based design. Topics: W5100, Ethernet, by Br
[5] National Fire Protection Association, “NFPA 72: TCP/IP, PPPoE, Development Board, PIC18LF8722, Circu
National Fire Alarm and Signaling Code,” 2010. PICC-18 C Compiler, MPLAB Bria
— conta
RESOURCES Multifunctional Wireless Alarm ing a
R&E International, a Subsidiary of Microchip Technol- by Carl Smith rate c
Circuit Cellar 194, 2006 tures
ogy, Inc., “RE46C152: CMOS Ionization Smoke Detec-
Carl’s multifunctional wireless alarm system
tor ASIC with Interconnect, Timer Mode, and Tone
can monitor everything from the doors to the
Select” Product Specification, 2009, ww1.microchip. sump pump in your house. The system features
com/downloads/en/DeviceDoc/22175A.pdf. an MC13192 SARD board and several wireless
sensors. When the alarm is activated, simply
Underwriters Laboratories, “UL217: Single and Multi- place a call to your house to obtain a status
ple Station Smoke Alarms,” 2006. report. Topics: Alarm, Wireless, MC13192 SARD,
MC9S08GT, Garage Door, Water Level, Phone,
November 2011 – Issue 256

———, “UL268: Smoke Detectors for Fire Alarm Temperature, DTMF, Emic, CH1837A, SSI204,
Systems,” 2009. MPX2010GS, Accelerometer, MMA1260D

Go to Circuit Cellar’s webshop to find these articles
SOURCE
and more: www.cc-webshop.com
RE46C152 CMOS Smoke detector IC
Microchip Technology, Inc. | www.microchip.com

www.circuitcellar.com • CIRCUIT CELLAR® 65


2011-11-002-Bachiochi_Layout 1 10/11/11 3:25 PM Page 66

F ROM THE BENCH by Jeff Bachiochi (USA)

Fly-By-Wire Wheelchair (Part 1)


Beyond Normal Joystick Control
Joystick-controlled motorized wheelchairs are useful to those with mobility
issues. But what if a user doesn’t have the dexterity required to control a
joystick? You can add the circuitry in this design to a commonly used
non-bus-type motorized wheelchair to override joystick control.

M any aging Americans use motorized


wheelchairs to help them stay
active in their communities. Joint replacement
is becoming commonplace. It is no longer
futuristic to expect that we may one day order
nudge forward, backward, left, or right applies
a small amount of power to each wheel-driv-
ing motor. Corresponding larger movements
(from center) increase this power, just like

up a replacement part from the local organ


farm. I’m talking about growing organs not
harvesting used ones. In this scenario, death
might only come by accident rather than from
a worn out or diseased body part. While this
probably won’t happen within my lifetime, I
can remember when going to the moon
seemed impossible.
Those members of society who were born
mobility challenged or have become so as the
result of an accident can benefit from the use of
motorized wheelchairs. According to a study ini-
tiated by the Christopher & Dana Reeve Founda-
tion, there are nearly one in 50 people living
with paralysis of some kind—approximately six
million people. [1] While those with the incapaci-
ty to walk or stand unassisted can gain a level of
freedom from the use of motorized wheelchairs,
there is a subgroup that cannot use the standard
user interface: the joystick.
November 2011 – Issue 256

Most motorized wheelchairs require


arm/hand dexterity to move a joystick as the
only input to motor control. Joystick opera-
Photo 1—Jet 3 Ultra motorized power wheelchairs, a
tion provides both a gas pedal and steering
popular alternative to the manual wheelchair, give
wheel in a single control. The XY joystick is users with limited capabilities the ability to address the
auto centered meaning, if untouched, it world with minimal assistance. (Photo courtesy of Pride
returns to a centered Off position. A slight Mobility Products Corp.)

66 CIRCUIT CELLAR® • www.circuitcellar.com


2011-11-002-Bachiochi_Layout 1 10/11/11 3:25 PM Page 67

stepping on the accelerator. Direc-


tional movement determines the
polarity of the voltage to each motor
as well as a power relationship
between the motors permitting direc-
tional control, like a steering wheel.
Users who are unable to move the
joystick may as well have an unpow-
ered chair. There are manufacturers
that specialize in alternative input
devices; however, these are not neces-
sarily wheelchair manufacturers. As
third-party enablers, they must align
themselves with chair manufacturers
that have designed their systems with
proprietary architectures, much like a
car manufacturer having its own pro-
prietary bus. (Refer to my series
“Vehicle Diagnostics,” Circuit Cellar
251–253, 2011.) This month’s project
uses a popular non-bus-type motorized
wheelchair and show how you can add Photo 2—The VR1 controller is encased on a single PCB in the armrest of the power chair.
some circuitry to override the normal Visual cues come from the surface-mount LEDs. Gold-plated push button contacts provide
joystick control. targets for several buttons on the rubber keypad. A 2 × 4 shrouded connector connects to
the only external device, a commercial joystick.
COMMERCIAL JOYSTICK
The rugged frame of Pride Mobili-
ty’s Jet 3 Ultra Motorized Power centered stick output. voltage outputs from some external
Wheelchair houses DC motors and While this joystick is available in source can be substituted for the on-
batteries and offers a strong and sta- XYZ format, the VR controller uses an board joystick outputs. A switch input
ble mount for the padded driver’s seat XY implementation. The joystick will force the outputs to a centered
(see Photo 1). It uses a PG Drives requires a regulated 5-V supply. Idle position. This “emergency” input will
Technology VR1 controller mounted (centered) output is 0.5 of VCC. A cen- have a unique side effect; see if you
in the chair’s armrest. All drive and ter-referenced voltage, as well as dual- can imagine what this would be.
control circuitry is contained on a voltage outputs for each axis, are My first thoughts were to add some
single printed circuit board (PCB). As available at the (1 mm on center) relays that would switch between the
you can see in Photo 2, the push but- shrouded eight-pin connection header. main joystick outputs and some other
ton (contacts) and LED status are The manufacturer repeatedly notes alternate. Not only might this put an
integrated on the PCB. The remain- the need for safety precautions (those excessive draw on the 5-V power
ing I/O is a PG Drives JC2000 series of the system architecture) to pre- available, but the break-before-make
off-the-shelf joystick that plugs onto vent unwanted movement. Of prime (BBM) action of the contacts may add
the PCB. importance is a way to disable move- a glitch to the VR1 processor that
I can see why this product is chosen ment if necessary. Beyond the emer- may be seen as a error or malfunc-
for tough environment applications gency situation, the system should tion. So, this design developed into an
where precision fingertip control, safe- carefully monitor all inputs for dis- analog-to-digital (ADC) front end and
ty, and long trouble-free life are pri- crepancies. If the redundant axis out- a digital-to-analog (DAC) rear end.
mary requirements. The rubber-boot- puts of the joystick don’t remain Initial operation is just to measure
ed joystick handle is self-centering within 5.6% of each other, joystick the joystick outputs and verify the
and requires a minimum amount of action should be disabled. This may values. Once the joystick is moni-
force to bring it to its maximum limit also include a power-up to check tored correctly, the second phase
of ±20° (vertically and horizontally). that the joystick is not producing would be to reproduce the joystick
November 2011 – Issue 256

The use of Hall effect sensors provides anything other than a centered (and voltages using the DAC outputs for
a non-contact design that yields idle) output. the VR1. Without putting unneces-
extreme life expectancy. Dual outputs sary limits on what may be used as an
for each axis provide redundant infor- FORTUNE TELLING external device to take command of
mation that can be used to determine This project reroutes the joystick the chair, I decided to use the basic
failure issues. A center tap reference outputs so they can be disconnected serial port available on the microcon-
output offers a way to compare for a from the chair’s controller. Alternate troller to provide the means of taking

www.circuitcellar.com • CIRCUIT CELLAR® 67


2011-11-002-Bachiochi_Layout 1 10/11/11 3:25 PM Page 68

Figure 1—I used a small microcontroller that provides four A/D inputs (to convert the joystick’s output voltages to a digital values) and twin
D/As (to convert digital values back into four voltage outputs) as well as a serial communications interface. A switch contact input can provide
D/A data forcing their voltage outputs to 0.5 of VCC (centered joystick).

over control (more on this later). sine/cosine relationship. However, the is indicated by the amount.
The Hall-effect sensors are the direction and distance of travel may As discussed earlier, with a noise
largest contributor to noise on the be confined by some mechanical lim- factor of 40 mV, there isn’t much
outputs of the joystick. If we assume its to the joystick’s movement. There sense in using any resolution less than
a full output swing of 5 V, the Hall- are other potential patterns that may 40 mV when the noise alone can vary
effect noise is ±20 mV or 0.04 V/5 V be used in order to modify the axis this much. While the resolution of the
(0.8%). An 8-bit ADC has a resolu- outputs in relationship to one another. microcontroller’s ADC is 10 bits, you
tion of about 0.019 V (over a 5-V By creating a shaped hole or gate in a can just use the upper 8 bits of the
range) so it would be plenty adequate. plate that the joystick sticks up conversion and still have a resolution
The microcontroller I used for this through you can limit the joystick’s that is less than half that of the noise
project has a 10-bit ADC, which is travel in many ways. The circular pat- (19 mV). The 8-bit conversion values
fine. In fact, I can probably toss away tern (just mentioned) is the most for each of the joystick’s voltage out-
some resolution. We’ll see. On the widely used. A square- or diamond- puts can be transmitted out of the
output side, I will be using external shaped hole yields square and triangle serial port as four two-digit hexadeci-
DACs as they are available with out- relationships that are 90° out of phase. mal values (X1X2Y1Y2) followed by a
put amplifiers that can supply some While these patterns limit only the fifth pair and a <CR> (carriage return).
output drive. The interface to the maximum excursions, they can be Using ASCII characters instead of
DACs is SPI, as shown in Figure 1. used in situations that require a non- binary data enables the transmission
The Microchip Technology MCP4922 linear relationship. Other shapes may string to be viewed. The fifth pair con-
DACs I selected have a reference include a vertical or horizontal slot to stitutes a control value. If nothing
input that can be scaled by 2×. This limit the joystick to a single axis. Or else, it can indicate the status of the
could be used to keep the DAC refer- X or “+” slots where the axis are “emergency switch.” This makes each
November 2011 – Issue 256

enced to that of the joystick actual required to move together or alone. transmission string 11 bytes long with
reference value, but I didn’t use this As previously mentioned, the idle a fixed format.
as all the circuitry would be running position is centered and produces Before the microcontroller can redi-
from the same supply (reference). equal voltages of 0.5 of VCC on each rect control from the onboard joy-
When you think of a joystick’s trav- axis. As the joystick is moved further stick to some external device, let’s
el, you probably think a circular maxi- away from idle, toward its mechanical set up some basic criteria. If the
mum path. The axis outputs follow a stop, it’s like stepping on the gas. This “emergency input” is closed, then

68 CIRCUIT CELLAR® • www.circuitcellar.com


41.qxp 1/7/2009 3:07 PM Page 1
2011-11-002-Bachiochi_Layout 1 10/11/11 3:25 PM Page 70

the microcontroller will send idle voltage values to the dongle I made using KC Wirefree’s KC-21 Bluetooth data
DACs (as input to the VR1). If the on-board joystick is module right onto the JP2 6-pin connector (see Photo 3).
moved off center, the microcontroller will send its out- This makes for a quick wireless serial interface that isn’t
put voltages to the DACs (as input to the VR1). External permanently attached to any prototype. Since my desktop
data must be received at a sustained periodic rate for at and laptop have Bluetooth dongles, I can quickly connect
least 1 s for it to be sent to the DACs (as input to the to projects. If I run a terminal program on my PC I will be
VR1). Deltas in DAC data can be limited (ramped up or able to see the streaming data output by my circuit, which
down) so as not to exceed a safe acceleration. is monitoring the joystick.
Viewing a list of numbers jumping around isn’t exactly
COMMAND STREAM
We begin by monitoring
the onboard joystick’s out-
A2D Interrupt Timer Interrupt Main
put via the serial port. Conversion finished 100 ms
With a transmission string
of 11 characters multiplied N

by 10 strings per second Save conversion Create transmission string TICK = 1?


Increment channel Load string into TX Buffer
that’s 110 characters or
Begin new conversion Enable TX interrupt
Y
1,100 bps, for a minimum TICK = 1
TICK = 0
transmission rate of about
1,200 bps. (I chose 38,400, N
Channel Return
for no particular reason.) centered?
Y

I consciously left off any Emergency


N input?
drivers on the schematic
serial interface, which JOY = 0 JOY = 1 N
allows for more possibili- Y

ties. One of the unique fea- JOY = 1?

tures of this UART is the Return


N
ability to configure the N
TTL serial interface as EXT = ?
either the normal logic Y
high idle or an inverted
logic low idle format. Set all D/A Set all D/A Set all D/A
outputs from outputs from outputs to
Most of the execution joystick values external values centered
takes place in Interrupt rou-
RX Interrupt
tines. Refer to Figure 2. Character received
Notice that the main loop
Set all DAC
is only responsible for set-
ting the DAC outputs. All N
CharacterCount
other functions take place >10? Goto main
within individual inter-
Y
rupts. Received communi- Y
Character legal?
cation data is not buffered, TX Interrupt
Transmitter empty
so it must be taken care of N
as it arrives. A/D conver- Character = CR?

sions proceed in the back- N


Y Y
ground with an interrupt TX Buffer
EXT = 0
taking place upon the com- Save all temp data as
empty?

pletion of a conversion. external data and EXT = 1


N
Every TICK all joystick
Save temp data
channels have been con- and increment Send character from Disable TX
the TX buffer interrupt
verted, a data string is CharacterCount = 1 CharacterCount
November 2011 – Issue 256

transmitted, and the DACs


are updated. This process
then begins another round Return Return
of ADC conversions and
the Main loop is again Figure 2—The interrupt routines handle the gathering and distribution of data from the joystick and
waiting for a TICK. between the microcontroller and the communication channel. The Main loop just has to wait for its flag
I can plug a Bluetooth (TICK) to set the DACs depending on state of the Emergency switch, JOY, and EXT.

70 CIRCUIT CELLAR® • www.circuitcellar.com


2011-11-002-Bachiochi_Layout 1 10/11/11 3:25 PM Page 71

exciting, so let’s create a and X2) data values and


more expressive display. horizontal (Y1 and Y2) data
Using Liberty BASIC, a values. These become off-
Windows-based BASIC pro- sets from home for the joy-
gramming language, I can stick knob. Depending on
create a simple graphic the scale in your applica-
image of a joystick and tion, you may need to
show knob position based apply a gain factor to keep
on the data being received this offset value within the
from the circuit. Referring range of the graphic box. In
to Photo 4, you can see my case, I used none as the
both a visual representation amount to pixel conversion
of the joystick’s present of 1:1 was acceptable.
position as well as the Y Each time a set of data is
(vertical) and X (horizontal) received, the knob drawing
axis values received via routine is called up to
Bluetooth connection. Photo 3—The joystick normally interfaces to the VR1 with a 0.1” 2 × 4 replace the current knob
square pin header. This photo shows the project circuitry connected to location with the new
VISUAL DISPLAY the joystick as well as a KC Wirefree Bluetooth dongle used for wire- location based on the
less communication to any Bluetooth device.
Simple drawing com- newly received data. By
mands enable a base graph- beginning this routine at
ic to be displayed consisting of circle The serial receiving portion of this the home position and moving the
commands that draw a filled in (red) application must parse the incoming pen to the new location, the stem of
circle along with some concentric data looking for 11-byte strings ter- the joystick is drawn from the center
(black) rings (see Photo 4). Drawing minated with a <CR>. Once each to the new position. Then a circle-
commands are pen based. Think of string that is stripped off is format filled command completes the knob
this like a pen plotter. You can move verified, the individual conversion located at the new position. The joy-
the pen around and raise (to move values are converted into vertical (X1 stick position is based on a single set
without drawing) and lower it (to
draw). Everything here is based on
“home,” which in this graphic exam-
ple is the center of the drawing space
(graphic box). This basic graphic will
be permanent, while the knob of the
joystick wants to be able to move
around. Therefore, it must be erased
and redrawn for each frame (new
position).
The knob position is based on two
things, home and the data being
received. To move relative to home,
we need to know where home is. If
we issue the Home command, we can
then query this location to get a ref-
erence point in X (horizontal pixels
from the left side of the graphic box)
and Y (vertical pixels from the top of
the graphic box). There is some
debate on how the actual data should
be presented (sent). The two basic
alternatives are the actual ADC con-
November 2011 – Issue 256

version values (simplest) and a direc-


tion and amount from center or idle
(requires conversion). Since I’m a
presentation kind of guy, I chose to
send the actual conversion values and
pack them into a single string to sim-
plify transmissions.

www.circuitcellar.com • CIRCUIT CELLAR® 71


2011-11-002-Bachiochi_Layout 1 10/12/11 2:06 PM Page 72

———, “Vehicle Diagnostics (Part 3): ISO 15765-4 (the


CAN Protocol),” Circuit Cellar 253, 2011.

Liberty BASIC, www.libertybasic.com

SOURCES
KC-21 Bluetooth data module
KC Wirefree | www.kcwirefree.com

MCP4922 DAC
Microchip Technology, Inc. | www.microchip.com

VR1 Joystick module and JC2000 joystick


PG Drives Technology, Inc. | www.pgdt.com

Jet 3 Ultra motorized power wheelchair


Pride Mobility Products | www.pridemobility.com

Photo 4—To verify A/D conversion through the communication chan-


nel, this PC application shows the joystick position based on
NEED-TO-KNOW INFO
Knowledge is power. In the computer applications
received data. Its position should follow that of the physical joystick
industry, informed engineers and programmers
for both sets of outputs.
don’t just survive, they thrive and excel. For more
need-to-know information about some of the topics
covered in this article, the Circuit Cellar editorial
of X and Y positions. A pull-down menu enables the user
staff recommends the following content:
to select between the two sets of outputs. They should —
be about the same if all is working well. Programmable Power
Build a Simple USB DAC
WHAT’S NEXT? by Yoshiyasu Takefuji
Next month I’ll finish up this project with a closer look Circuit Cellar 213, 2008
at the DAC operation, and I’ll solve the mystery use of the Yoshiyasu describes the step-by-step construction
emergency input. If you have some time to roam around of a simple USB DAC around an ATtiny45 and a
the Internet, Google “power chairs” to see what’s going on MAX517. You can use the system as a programmable
in the industry. You’ll be surprised to find just how sophis- power supply. Topics: USB, DAC, ATtiny45, NRZI,
WinAVR, MAX517, AVR-USB, GNU C, Protocol
ticated these rigs are becoming. I
Stack, Device Driver

Jeff Bachiochi (pronounced BAH-key-AH-key) has been writing for Bluetooth-Based Display for GPS Data
Circuit Cellar since 1988. His background includes product design by Jay Carter
and manufacturing. You can reach him at jeff.bachiochi@imaginethat Circuit Cellar 190, 2006
now.com or at www.imaginethatnow.com. Jay interfaced a Wintec Bluetooth module to an
LCD and a PIC16F88, which connects to a miniature
Bluetooth GPS receiver. The display shows the date,
time, speed, direction, location, and number of the
PROJECT FILES satellites used by the GPS receiver. Topics: Bluetooth,
To download the code, go to ftp://ftp.circuitcellar.com LCD, PIC16F88, GPS, Nemesis, Athena, BASIC
/pub/Circuit_Cellar/2011/256. —
Joystick Technology
REFERENCE by Jeff Bachiochi
[1] Christopher & Dana Reeve Foundation, Paralysis Circuit Cellar 176, 2005
An analog joystick would be a great addition to
Resource Center, www.christopherreeve.org/site/
some designs, but space limitations could present a
c.mtKZKgMWKwG/b.5184189/k.5587/Paralysis_Facts
problem. Fortunately, new devices like the JS1100AQ
__Figures.htm five-position joystick navigation switch can help you
November 2011 – Issue 256

solve the space problem. Topics: Joystick, JS1100AQ,


RESOURCES Analog, Digital, DS1869, PIC16F505, MCP42xxx,
J. Bachiochi, “Vehicle Diagnostics (Part 1): The CAN Resolution, PIC10F20x, PIC16C57
Protocol and OBD-II,” Circuit Cellar 251, 2011. —
Go to Circuit Cellar’s webshop to find these articles
———, “Vehicle Diagnostics (Part 2): Pre-CAN Proto- and more: www.cc-webshop.com
col Standards,” Circuit Cellar 252, 2011.

72 CIRCUIT CELLAR® • www.circuitcellar.com


73_Layout 1 09/27/11 12:19 PM Page 1

Abo Plus Anzeige USA 110706.indd 1 14-07-11 09:48:01


crossword_Layout 1 10/11/11 3:41 PM Page 78

1 2

6 7

10

11

12 13 14

15

16

17

Across Down
3. Not visual 1. An arrangement of units
4. The foundation of an application 2. Decreases vibration
5. An online seminar 6. The amount of times a component is unsuccessful
7. A series of lines of code [two words]
8. A device used to increase power 11. A circuit with two stable states
November 2011 – Issue 256

9. Fast movement, a sequence or course 13. Changes analog to digital and vice versa
10. A barrier of conductive or magnetic matter 14. Below
12. LCD [three words]
15. IP [two words]
16. A unit of measurement
17. A plan or specification The answers will be available in the next issue and at
www.circuitcellar.com/crossword.

74 CIRCUIT CELLAR® • www.circuitcellar.com


IB_256_Layout 1 10/12/11 2:18 PM Page 75

I DEA
BOX
THE DIRECTORY OF
PRODUCTS AND SERVICES

AD FORMAT: Advertisers must furnish digital files that meet our specifications (www.circuitcellar.com/advertise). ALL TEXT AND OTHER ELEMENTS MUST
FIT WITHIN A 2" x 3" FORMAT. E-mail [email protected] with your file or send it to IDEA BOX, Circuit Cellar, PO Box 180, Vernon, CT 06066.
For current rates, deadlines, and more information contact Peter Wostrel at 800.454.3741, 978.281.7708 or [email protected].

The Vendor Directory at www.circuitcellar.com/vendor/


is your guide to a variety of engineering products and services.

! "#
*" #
& * $ % &%

% # + % ' ( !)%" #!) %&"

November 2011 – Issue 256

www.circuitcellar.com • CIRCUIT CELLAR® 75


IB_256_Layout 1 10/11/11 3:49 PM Page 76

Add High-Current Peripherals


to Your Instrument

INTEGRATED
PLCs with Integrated Ethernet

L PWM Driver Wildcard interfaces high current


motors, heaters, pumps, fans etc to your
instrumentation or automation project
L 4 or 8 channels of up to 5A current drive
L Fast PWM switching
L 4 channels of current sensing with user-
configurable gain
L Field connections to a standard 24-pin
header or to solder holes
L Software to easily configure period, duty
cycle, active state, and resolution of each
PWM output
-OSAIC)NDUSTRIES)NC
tel: 510-790-1255 fax: 510-790-0925
WWWMOSAIC INDUSTRIESCOM New FMD88 -10
and FMD1616 -10
Integrated Features :
microEngineering Labs, Inc. - ETHERNET / Modbus TCP/IP
- 16 or 32 digital I/Os
www.melabs.com 888-316-1753 - 10 analog I/Os
- RS232 and RS485
PICBASIC PRO™ Compiler USB Programmer for - LCD Display Port
- I/O Expansion Port
Bridges the gap between ease PIC® MCUs - Ladder + BASIC Programming
of use and professional level
results. The simplicity of the $89.95
(as shown)
language allows both hobbyist
engineer to master
and it $229 and $295
quickly, but the engineer RoHS before OEM Qty Discount
appreciates what’s happening Compliant
under the hood. This is a true compiler that
produces fast, optimized machine code Programs PIC MCUs including low-voltage (3.3V) devices.
Includes Software for Windows 98, Me, NT, XP, and Vista.
that's stable and dependable. tel : 1 877 TRI-PLCS
November 2011 – Issue 256

With Accessories for $119.95:


Supports: web : www.tri-plc.com/cci.htm
Includes Programmer, Software, USB Cable, and
More than 300 PIC® Microcontrollers Programming Adapter for 8 to 40-pin DIP.
Direct Access to Internal Registers
In-Line Assembly Language TRIANGLE
Interrupts in PICBASIC and Assembly See our full range of products, including RESEARCH
Built-In USB, I2C, RS-232 and More
books, accessories, and components at: INTERNATIONAL
Source Level Debugging in MPLAB
PICBASIC PRO™ Compiler $249.95 www.melabs.com

76 CIRCUIT CELLAR® • www.circuitcellar.com


IB_256_Layout 1 10/11/11 3:49 PM Page 77

Microcontrollers
xMCF51AC256
xMCF51CN128
MaxSonar
Perfect for OEMs & Engineers
xMCF51JM128
xMCF51QE128 XL-MaxSonar-EZ
xMC9S08AC128 ‡ High acoustic power
xMC9S08JM64 ‡ Real-time calibration
‡ Tiny size
Modules xMC9S08QE128 ‡ $39.95 USD qty. 1
xBluetooth GREAT For: MaxSonar-WR (IP67)
xRS-232 xProjects
‡ Industrial packaging
‡ Weather resistant
xUSB xBreadboards ‡ Standard ô´ILWWLQJ
xRF xExperiments ‡ $99.95 USD qty. 1
x2 x 20 LCD
x4 x 4 Keypad x
x
Labs LV-MaxSonar-EZ
xMotor Control Prototypes ‡ Power-up calibration
‡ Smallest MaxSonar
xReal Time ‡ Low power, 2.5V-5.5V
Clock Kits Available ‡ $29.95 USD qty. 1
xPower Supply MaxSonar-WRC (IP67))
Learn about BASIC ON BOARD ‡ Compact packaging
‡ Weather resistant
‡ Quality narrow beam
ATRIA Technologies Inc. ‡ $99.95 USD qty. 1
www.AtriaTechnologies.com www.maxbotix.com

C
Des
Fro

Rese
spac
Cella
New

Strategi
978.281
peter@s
www.smm

CROSSWORD ANSWERS from Issue 255 1 2 3

T I M E S T A M P
Across Down
4 5

N I D L
1. TIMESTAMP—The time recorded by a com-
6

2. INTERFACE—Device used to con- T C V A R I A B L E


puter (not real time) [two words] nect a computer to a network E R G A
6. VARIABLE—Opposite of constant 3. MICROSECONDS—µs R
7
O I S
7. RSSFEED—Used to automatically distribute 4. DIGITAL—Electronic, mathematical F R S S F E E D T
8
T

frequently updated information [two words] 5. LEASTSIGNIFICANTBIT—LSB A


9 10
E A U S
S C R I P T L P I
10. SCRIPT—A sequence, instructions [three words] C V
E E O L G
11. PULSEWIDTHMODULATION—PWM [three 8. UPLOAD—Sends local data to a
R N O N
words] remote system 11 12
O N
P U L S E W I D T H M O D U L A T I
13. PUSHBUTTON—Mechanism for controlling 9. VERSION—Abbreviated as “V”; usu- I S I D F
mechanical and electronic devices [two words] ally there is more than one O N I
16. SIGNAL—A time-varying or spatial-varying 12. MINUS—Take away
November 2011 – Issue 256

13

N P U S H B U T T O N C
quantity 14. FIELDBUS—Family of protocols for
14

F S A
17. HENDRIKLORENTZ—Dutch physicist who real-time distributed control
15 16

I W S I G N A L
first quantified the Lorentz force [two words] 15. WEBSITE—Frequently ends with
17

H E N D R I K L O R E N T Z T
18. SYSTEMONCHIP—Merges computer com- “com” or “org” L
18
B B
ponents into one IC chip [three words] D S Y S T E M O N C H I P
19. ROOTMEANSQUARE—RMS [three words] B I T
U T
19

S R O O T M E A N S Q U A R E

www.circuitcellar.com • CIRCUIT CELLAR® 77


78_Layout 1 10/06/11 2:53 PM Page 1

The “Must Have” reference for


loudspeaker engineering professionals.

Home, Car, or Home Theater!


Back and better than ever, this 7th edition
provides everything you need to become a
better speaker designer. If you still have a
3rd, 4th, 5th or even the 6th edition of the
Loudspeaker Design Cookbook, you are
missing out on a tremendous amount of
new and important information!
Now including: Klippel analysis of drivers,
a chapter on loudspeaker voicing, advice
on testing and crossover changes, and so
much more! Ships complete with bonus CD
containing over 100 additional figures and
a full set of loudspeaker design tools.
A $99 value!
Yours today for just $39.95.

Shop for this book, and many


other Audio Amateur products,
at www.cc-webshop.com.
79-advertiser's index_PB_Layout 1 10/12/11 2:21 PM Page 79

I
Page
NDEX OF
ADVERTISERS
Page Page Page
16 2012 International CES 56, 57 Elektor 11, 13 Imagineering, Inc. C2 NetBurner

14 Abacom Technologies, Inc. 73 Elektor 76 Ironwood Electronics C4 Parallax, Inc.

76 All Electronics Corp. 10 EMAC, Inc. 77 Jeffrey Kerr, LLC 27 Pico Technology Ltd.

29 Anaren 21 Embedded Developer 17, 33 JK microsystems, Inc. 35 Pololu Corp.

10 AP Circuits 41 ExpressPCB 75, 77 JK microsystems, Inc. 48 Saelig Co., Inc.

71 ARM 33 ezPCB 5 Labcenter Electronics 49 Sealevel Systems

77 Atria Technologies, Inc. 75 FlexiPanel Ltd. 76 Lawicel AB 2, 3 Technologic Systems

1, 78 Audio Amateur C3 FTDI Chip 77 Maxbotix, Inc. 77 Tern, Inc.

15 Comfile Technology, Inc. 12 GHI Electronics LLC 76 MCC, Micro Computer Control 76 Triangle Research, Inc.

75 Custom Computer Services, Inc. 17 Grid Connect, Inc. 76 microEngineering Labs, Inc. 9 WIZnet Co., Inc.

75 Decade Engineering 22 Humandata Ltd. 76 Mosaic Industries, Inc.

39 DesignSpark chipKITTM Challenge 37, 69 IC Bank 7 Mouser Electronics, Inc.

P REVIEW
Theme: Programmable Logic
of December Issue 257
A TTENTION A DVERTISERS
January Issue 258
Deadlines
Space Close: Nov. 10
The (VI)sualizer: A Smart Electronic Load
Materials Close: Nov. 17
Sound Tone Detection with a PSoC (Part 2): The Software
Sleep-Stage Alarm Clock Theme
Embedded Applications
THE CONSUMMATE ENGINEER EMI and Data Integrity
Bonus Distribution
November 2011 – Issue 256

FROM THE BENCH Fly-by-Wire Wheelchair (Part 2): Programming and Operation International CES, DesignCon
EMBEDDED IN THIN SLICES Getting Started with Embedded Linux (Part 2): Choosing
Call Peter Wostrel
a Platform for Your System now to reserve your space!
ABOVE THE GROUND PLANE Stepper Motor Drives (Part 3): Torques 800.454.3741 or 978.281.7708
e-mail: [email protected]
THE DARKER SIDE CE Marking: A Process to Ensure Product Conformity

www.circuitcellar.com • CIRCUIT CELLAR® 79


Steve_256_Layout 1 10/11/11 3:53 PM Page 96

PINTERRUPT RIORITY
by Steve Ciarcia, Founder and Editorial Director

To 4G or Not to 4G?
W hile I don’t do as much hands-on design work these days as I used to, it’s hard to avoid the impact of changing
technology coming from the world of smartphones and wireless gadgets. It was just a short time ago that I jumped onto
mobile broadband. Now I can’t live without it. Of course, the unique difference between discussing the latest technology at
Circuit Cellar and a newspaper, for example, is that ultimately, the depth of discussion here is about implementing the
technology, not just becoming an end user of it.
It’s time for embedded system developers to start thinking about how to take advantage of the newly emerging mobile
broadband fourth generation (4G) capabilities, which offer on the order of 100 Mbps download bandwidth and a cleaner
“flat-IP” (Internet Protocol) architecture. Frankly, I’m having a hard time imagining embedded applications that need that
kind of raw bandwidth—after all, even a high-definition video signal fits into about 25 Mbps—but I’m sure they must be
out there.
In any case, there seem to be two standards that are being widely deployed, at least in the United States: mobile
WiMAX (e.g., Sprint, Clearwire) and 4G Long-Term Evolution (LTE) (e.g., AT&T and Verizon). The latter isn’t really up
to 4G speeds yet; it’s more like a 3G-plus (it’s also been called 3.9G). The only difference moving forward will be an
increase in performance. WiMAX is being developed by the non-profit WiMAX Forum, an organization of network
operators and component and equipment vendors. LTE is being developed by the 3rd Generation Partnership Project
(3GPP), a collaboration among telecommunications associations, which are themselves groups of manufacturers and
standards bodies.
It’s interesting to note that the two standards have arrived at the 4G arena from different directions. LTE is just what it
says, the evolution of the cellphone network from 2G and 3G with steadily increasing bandwidth available to the end user,
currently peaking out at around 42 Mbps. On the other hand, WiMAX was originally conceived as a fixed, point-to-point
wireless service with bandwidth up to 1 Gbps, for “backhaul” Internet access in places where wired service isn’t economi-
cal. The extension to mobile WiMAX is a relatively recent addition. In mobile applications, some reduction in bandwidth is
required in order to accommodate issues such as variable path lengths and Doppler shifts, as well as the lack of directivi-
ty (and gain) in the antennas. So, the effective throughput is on the order of 100 Mbps.
A handful of module manufacturers have jumped on the 4G bandwagon to date, including Novatel Wireless and Sierra
Wireless. Both companies offer modules that support both standards and all of the frequency bands currently in use, so there
doesn’t seem to be any issue with building hardware that’s fairly network-agnostic. This will be important moving forward
since, although WiMAX currently has the lead in terms of deployment, LTE, with the support of two large carriers, will quickly
catch up. It’s pretty clear that both technologies will remain important for end-user devices for the foreseeable future.
And it really isn’t an either/or question anyway, at least not the way VHS and Beta was back in the 1980s. In this case,
end users don’t need to make an investment in a library of physical media, which is what forced everyone to make a
choice before. With 4G, the radio part of the module is almost completely defined by software, so there’s no recurring cost
penalty for supporting both standards—just the nonrecurring cost of developing the firmware. This also makes the hard-
ware relatively future-proof as well, as long as the issue of deploying firmware updates is taken into consideration.
There will certainly be a plethora of 4G products in the pipeline. A significant one right now is the 4G “hotspot”— a sim-
ple router with two wireless interfaces that functions as a bridge between the metropolitan-area 4G network and a local-
area Wi-Fi network. NetComm and NETGEAR offer products like this. This is a quick way to set up a proof-of-concept for
any new 4G application ideas you may have.
November 2011 – Issue 256

As originally conceived, 4G is intended to be “MAGIC” (i.e., mobile multimedia, anytime or anywhere, global, integrated,
and customized) and I hope it is. If that remains true, I may also get my wish. I’m sure there will be many products I can’t
possibly conceive, but I only want one ASAP! Paying for a dozen individual broadband subscription fees (house, phones,
cars, etc.) is absolutely driving me nuts! I just want one decent mobile 4G hotspot so I can at least get some of their
hands out of my pocket.
[email protected]

80 CIRCUIT CELLAR® • www.circuitcellar.com


C2_Layout 1 09/08/11 1:28 PM Page 1

1
- Ê
Ê/
 Ê
-
/Ê

1- Ê
Ó°äÊ
ˆÊ
ëii
` Ê
Q{näLˆÌ
ÃÉÃ

̜
ÊÈ
˜}i
É`Õ>
ɵÕ>`Ê
V…>˜˜i
Ê
ˆ
˜`i«i˜`i˜Ì
ÊV
œ˜ v
ˆ
} ÕÀ
>L
iʫ
>À>
i
É
ÃiÀ
ˆ
>Ê
ˆ
˜Ìi
Àv
>Vi
1,/
É/É
-*
ÉÓ
Ê
EÊ«>À

i
Ê
"

1
- Ê

Ê 
-9
ÜÜܰ
v
Ì̀ˆ
V…ˆ
«°
Vœ“
C4_Layout 1 10/07/11 10:12 AM Page 1

You might also like