Circuit Cellar November 2011
Circuit Cellar November 2011
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
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
www.circuitcellar.com
C2a_Layout 1 09/08/11 1:30 PM Page 1
Personality Blades
Prototype Blade (P/N NBPKBP-100CR)................................ $25 ea.
Create your own Personality Blade
NTP Server with GPS Blade (P/N NBPKX500-100CR) ........... $99 ea.
Network Time Protocol (NTP) server
Precision GPS time reference
/
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ÃÃLiÊi}iiÀ}Ê>ÀÌViÃÊ«ÀiÃiÌ}ÊÛiÌÛi]ÊÊ
Ài>ÜÀ`Ê>Õ`ÊiiVÌÀVÃÊ>««V>ÌÃÊÊ>`Ê«ÀiVÌÃ
UÊÊ/
ÀÕ}
Ê>`Ê
iÃÌÊÀiÛiÜÃÊ>LÕÌÊ«À`ÕVÌÃÊ
Ì
>ÌÊÜÊLÀ}ÊÞÕÀÊ>Õ`ÊiÝ«iÀiViÃÊÌÊ
iÜÊiÛiÃÊ
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
TS-TPC-7390
7” Color Touch Panel Computer
New Products
TS-WIFIBOX-2
A Complete Solution for 802.11g WiFi Applications
$ 185
qty 1
series
starts at
TS-SOCKET Macrocontrollers
$ 92
qty 100
Jump Start Your Embedded System Design
55 mm / 2.165 in.
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
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]
INSIDE ISSUE
18
256
High-Accuracy Voltage Reference
Using PWM (Part 2)
Hardware Design
David Ludington
November 2011 • Analog Techniques
24 Auditory Navigator
Garrett Phillips, Matthew Kinne, and Nick Annetta
42 Super Arduino
Getting Started with the chipKIT Max32
Clemens Valens
DesignSpark chipKIT Challenge Primer Tone Detection p. 30
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
Scan Here
to Watch Video
Mouser and Mouser Electronics are registered trademarks of Mouser Electronics, Inc.
NPN256_Layout 1 10/11/11 11:49 AM Page 8
austriamicrosystems
www.austriamicrosystems.com
8
NEW PRODUCT NE WS
CIRCUIT CELLAR® • www.circuitcellar.com
NPN256_Layout 1 10/11/11 11:49 AM Page 9
Atmel Corp.
www.atmel.com
NPN
ZZZ:L]QHW7HFKQRORJ\FRP
L(WKHUQHW:)DVW63,(WKHUQHW&RQWUROOHU
+DUGZLUHG7&3,3)DVW(WKHUQHW0$&3+<
+LJK6SHHG6HULDO3HULSKHUDO,QWHUIDFH63,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
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
Since 1985
OVER
24
YEARS OF
SINGLE BOARD
SOLUTIONS
Fairchild Semiconductor
www.fairchildsemi.com
NPN
November 2011 – Issue 256
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 4—How does Twinax, a form of shielded twisted pair, address some of the shortcomings of coax?
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)
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
F EATURE
ARTICLE by David Ludington (USA)
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
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
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
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.
EP3C5U256C8N
EP3C10U256C8N Nominal voltage Expected voltage Measured voltage Fullscale 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
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
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.
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.
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
–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
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).
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.
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
F EATURE
ARTICLE by Guido Ottaviani (Italy)
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
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
Figure 2—The analog blocks configuration with the connections to the internal buses and external pin drawn using PSoC Designer schematic
conventions
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.
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.
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_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
RI2[0]
RI2[1]
RI2[2]
RI2[3]
BC2
TerminalCountOut
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
hot
Turn a
idea into a
cool
solution.
DesignSpark chipKIT Challenge ™
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
decoder, http://code.google.com/p/
explorersound.
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.
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
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
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
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
–20
–40
Attenuation (dB)
–60
–80
November 2011 – Issue 256
–100
–120
01
02
03
04
05
06
+
+
E
E
1.
1.
1.
1.
1.
1.
Frequency (kHz)
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.
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:
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
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
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.)
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
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
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
Elektor Shop
The world of electronics
at your fingertips! Bestseller!
ore
This book and m
are available at
m/books
www.elektor.co
Books
Approx. 216 pages • ISBN 978-1-907920-07-3 • $47.60 248 pages • ISBN 978-0-905705-98-9 • $47.60
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 +IT OF PARTS INCL 0#" CONTROLLER HUMIDITY
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 +IT OF PARTS INCL %LEKTOR 0ROJECT #ASE
Reader. USA PROGRAMMED MICROCONTROLLER ,#$ AND 0#"
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]
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.
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.
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
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.
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
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.
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
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
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
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
SOURCES
KC-21 Bluetooth data module
KC Wirefree | www.kcwirefree.com
MCP4922 DAC
Microchip Technology, Inc. | www.microchip.com
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.
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].
! "#
*" #
& * $ % &%
INTEGRATED
PLCs with Integrated Ethernet
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
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
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
I
Page
NDEX OF
ADVERTISERS
Page Page Page
16 2012 International CES 56, 57 Elektor 11, 13 Imagineering, Inc. C2 NetBurner
76 All Electronics Corp. 10 EMAC, Inc. 77 Jeffrey Kerr, LLC 27 Pico Technology Ltd.
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.
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
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]
1
- Ê
Ê/
Ê
-
/Ê
1- Ê
Ó°äÊ
Ê
ëii
` Ê
Q{näLÌ
ÃÉÃ
RÊ
Ì
ÊÃ
}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