Download as pdf or txt
Download as pdf or txt
You are on page 1of 84

EMBEDDED DEVELOPMENT

AUGUST 2014
circuitcellar.com ISSUE 289
CIRCUIT CELLAR | ISSUE 289 | AUGUST 2014

Protect Your Electronics Explore how electromagnetic shielding


can defend against RF radiation
Tips for shield experiments,
3-D printed shields, and
using magnetic shields

EIM Bootcamp | Q&A: Embedded Systems Training Expert


circuitcellar.com

Digital Pulse Generator | Battery Charge Control | MCU-Based ECG System


Linux Application Design | Implement a Soft-Core Processor |
Fixed Resistors | IR Transmission & Formats Self-Reconfiguring Robotics
2 CIRCUIT CELLAR • AUGUST 2014 #289

EDITOR’S LETTER

Issue 289 August 2014 | ISSN 1528-0608

CIRCUIT CELLAR® (ISSN 1528-0608) is published monthly by: EE PROJECTS, TIPS, & INSIGHT
Circuit Cellar, Inc.
111 Founders Plaza, Suite 300
I’m pleased to note that this issue is one of our most diverse to date. We cover a wide
East Hartford, CT 06108 range of technologies and topics from pulse generation to FPGAs to embedded Linux to self-
reconfiguring robots at MIT. After you get through this issue, I encourage you to share your
Periodical rates paid at East Hartford, CT, and additional offices.
One-year (12 issues) subscription rate US and possessions thoughts with our staff and followers via social media (Twitter: @circuitcellar and Facebook:
$50, Canada $65, Foreign/ ROW $75. All subscription orders www.facebook.com/circuitcellarmagazine).
payable in US funds only via Visa, MasterCard, international
On page 8 we run an interview with Victoria, BC-based professional engineer Jason Long,
postal money order, or check drawn on US bank.
who founded Engenuics Technologies in 2010. His innovative contribution to the industry is
SUBSCRIPTIONS
an embedded systems hardware training program, which he describes in his interview.
Interested in a digital pulse generator? Brian Beard explains how he built a microcontroller-
Circuit Cellar, P.O. Box 462256, Escondido, CA 92046
based fully digital pulse generator that’s accurate, programmable, and stable (p. 20).
E-mail: circuitcellar@pcspublink.com
Turn to page 28 for the second part of Steve Hendrix’s “Personal Solar Power Setup”
Phone: 800.269.6301
series. In Part 1, he introduced his system. This article focuses on battery charge control.
Internet: circuitcellar.com
We’re always on the lookout for innovative healthcare-related electronics projects. On
Address Changes/Problems: circuitcellar@pcspublink.com
page 36 we present one of the best projects we’ve seen in several months. Sean Hubber and
Postmaster: Send address changes to Crystal Lu present their microcontroller-based electrocardiography (ECG) system.
Circuit Cellar, P.O. Box 462256, Escondido, CA 92046 Check out Bob Japenga’s article on Linux system configuration if you want a break from
hardware design projects—or if you’re a Linux buff (p. 42). Bob looks a different ways to
ADVERTISING configure a Linux system. He covers BusyBox, web servers and server-side support, and
Strategic Media Marketing, Inc. more.
2 Main Street, Gloucester, MA 01930 USA
On page 46, Colin O’Flynn touches on the topic of implementing a soft-core processor
Phone: 978.281.7708
inside an FPGA. He notes that recent releases have made developing and customizing
Fax: 978.281.7706
these processors easier than ever.
E-mail: circuitcellar@smmarketing.us
Advertising rates and terms available on request.
You know everything there is to know about resistors, right? We think there’s always
New Products:
more to learn. This month, George Novacek tackles the subject of fixed resistors (p. 56).
New Products, Circuit Cellar, 111 Founders Plaza, Suite 300 Circuit protection is an important topic for engineers and seasoned pros alike. As you
East Hartford, CT 06108, E-mail: newproducts@circuitcellar.com know, electromagnetic shielding protects against RF radiation. But adding shielding isn’t
always easy. Robert describes some shielding experiments and shares his results (p. 60).
HEAD OFFICE
Flip to page 66 to read Part 1 of Jeff Bachiochi’s new series on “IR Remotes.” This month
Circuit Cellar, Inc. 111 Founders Plaza, Suite 300 he introduces IR formats and then focuses on the topic of remote transmission.
East Hartford, CT 06108
Phone: 860.289.0800 We wrap up this issue with Kyle Gilpin’s presentation on self-reconfiguring robotic
systems and M-Blocks (p. 80). He describes some of
COVER PHOTOGRAPHY the amazing technologies engineers are working on
Chris Rakoczy, www.rakoczyphoto.com in MIT’s Distributed Robotics Lab. The nearby photo
shows two different views of M-Blocks.
COPYRIGHT NOTICE

Entire contents copyright © 2014 by Circuit Cellar, Inc. All


rights reserved. Circuit Cellar is a registered trademark of
C. J. Abate
Circuit Cellar, Inc. Reproduction of this publication in whole
or in part without written consent from Circuit Cellar, Inc. is cabate@circuitcellar.com
prohibited.

DISCLAIMER

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
THE TEAM
such errors. Furthermore, because of possible variation in
the quality and condition of materials and workmanship of EDITOR-IN-CHIEF PRESIDENT FOUNDER
reader-assembled projects, Circuit Cellar® disclaims any
responsibility for the safe and proper function of reader- C. J. Abate Hugo Van haecke Steve Ciarcia
assembled projects based upon or from plans, descriptions, or
information published by Circuit Cellar®. MANAGING EDITOR PUBLISHER PROJECT EDITORS
The information provided by Circuit Cellar® is for educational
Mary Wilson Don Akkermans Chris Coulston,
purposes. Circuit Cellar® makes no claims or warrants that
Ken Davidson,
readers have a right to build things based upon these ideas ASSOCIATE EDITOR ASSOCIATE PUBLISHER
under patent or other relevant intellectual property law in
Nan Price Shannon Barraclough David Tweed
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 ART DIRECTOR COLUMNISTS CUSTOMER SERVICE
jurisdiction. The reader assumes any risk of infringement KC Prescott Debbie Lavoie
liability for constructing or operating such devices. Jeff Bachiochi, Ayse K.

© Circuit Cellar 2014 Printed in the United States ADVERTISING COORDINATOR Coskun, Bob Japenga, Robert
Kim Hopkins Lacoste, Ed Nisley, George
Novacek, Colin O’Flynn
circuitcellar.com 3

US/UK
Don Akkermans
+31 46 4389444
OUR NETWORK
d.akkermans@elektor.com

ELEKTOR LABS
Wisse Hettinga
+31 46 4389428
w.hettinga@elektor.com

GERMANY
Ferdinand te Walvaart
+49 241 88 909-17
f.tewalvaart@elektor.de

FRANCE
Denis Meyer
+31 46 4389435 SUPPORTING COMPANIES
d.meyer@elektor.fr

NETHERLANDS 12th Int'l SoC Conference 77 Ironwood Electronics 79


Harry Baggen
+31 46 4389429
h.baggen@elektor.nl 2015 International CES 53 Labcenter Electronics 1

SPAIN
Eduardo Corral Accutrace 7 Lauterbach GmbH 27
+34 91 101 93 95
e.corral@elektor.es
Advanced Micro Circuits 78 MaxBotix, Inc. 79
ITALY
Maurizio del Corso
+39 2.66504755 All Electronics Corp. 78 microEngineering Labs, Inc. 79
m.delcorso@inware.it

SWEDEN CadSoft Computer GmbH 39 Mouser Electronics, Inc. 17


Wisse Hettinga
+31 46 4389428
w.hettinga@elektor.com
Custom Computer Services 78 MyRO Electronic Control Devices, Inc. 78
BRAZIL
João Martins
+31 46 4389444 Elektor 22, 23 NetBurner, Inc. C2
j.martins@elektor.com

Elektor 71 Pico Technology Ltd. C3


PORTUGAL
João Martins
+31 46 4389444
j.martins@elektor.com EMAC, Inc. 19 R.E. Smith, Inc. 49

INDIA
Sunil D. Malekar ExpressPCB 55 Reach Technology, Inc. 78
+91 9833168815
ts@elektor.in
Flash Memory Summit 59 Saelig Co., Inc. 19
RUSSIA
Nataliya Melnikova
+7 965 395 33 36 Hot Chips Symposium 45 Technologic Systems 9, 11
elektor.russia@gmail.com

TURKEY Humandata, Ltd. 33 TechTools 79


Zeynep Köksal
+90 532 277 48 26
zkoksal@beti.com.tr IAR Systems 31 Triangle Research International, Inc. 79

SOUTH AFRICA
Johan Dijk Imagineering, Inc. C4
+31 6 1589 4245
j.dijk@elektor.com

CHINA
Cees Baay NOT A SUPPORTING COMPANY YET?
+86 21 6445 2811
ceesbaay@gmail.com Contact Peter Wostrel (circuitcellar@smmarketing.us, Phone 978.281.7708, Fax 978.281.7706)
to reserve your own space for the next edition of our members’ magazine.
4 CIRCUIT CELLAR • AUGUST 2014 #289

CONTENTS

AUGUST 2014 • ISSUE 289

EMBEDDED
DEVELOPMENT

DIY DIGITAL PULSE GENERATOR

CC COMMUNITY FEATURES
06 : CC WORLD 20 : Build a Digital Pulse Generator
By Brian Beard
08 : QUESTIONS & ANSWERS An accurate DIY microcontroller-based digital pulse
Embedded Systems Training Expert generator for your workbench
By Nan Price
An interview with an engineer who launched an 28 : Personal Solar Power Setup (Part 2)
embedded systems hardware training program Battery Charge Control
By Steve Hendrix
Battery charge control options for sharing the load
INDUSTRY & ENTERPRISE between a utility and the solar power system
16 : PRODUCT NEWS
36 : Hands-On Electrocardiography
19 : CLIENT PROFILE By Sean Hubber & Crystal Lu
Total Phase (Sunnyvale, CA) An ECG system to extract a heart’s electrical output

COLUMNS
42 : EMBEDDED IN THIN SLICES
Linux System Configuration (Part 2)
Linux Application Design
By Bob Japenga
Options for selecting the packages to install on your
system and more

46 : PROGRAMMABLE LOGIC IN PRACTICE


Build a SoC Over Lunch
By Colin O’Flynn
Getting started with a simple soft-core processor
ARM-BASED DEVELOPMENT BOARD
circuitcellar.com 5

CONTENTS

DIY SHIELDING FOR ELECTRONICS

MICROCONTROLLER-BASED ECG SYSTEM

56 : THE CONSUMMATE ENGINEER


The Humble Resistor (Part 1)
TESTS & CHALLENGES
Fixed Resistors 74 : CROSSWORD
By George Novacek
An introduction to fixed resistors, resistor selection, 75 : TEST YOUR EQ
and power dissipation
TECH THE FUTURE
60 : THE DARKER SIDE
Shielding Experiments 80 : Self-Reconfiguring Robotic Systems
By Robert Lacoste and M-Blocks
How shielding protects against RF radiation By Kyle Gilpin
A look at the future of self-reconfigurable robot
66 : FROM THE BENCH development and applications
IR Remotes (Part 1)
Remote Transmission
By Jeff Bachiochi
Accumulate and recognize an IR remote transmission

SELF-RECONFIGURING ROBOTS

FIXED RESISTORS 101 @editor_cc


@circuitcellar circuitcellar
6 CIRCUIT CELLAR • AUGUST 2014 #289

CC WORLD

EIM “BOOTCAMP”
By C. J. Abate

Several weeks ago, Elektor International Media (EIM)


staffers from around the globe met up in the Netherlands
for a corporate “bootcamp.” The agenda: take a day to step
away from engineering, circuit testing, editing, and writing
to assess the company’s current offerings (magazines,
books, kits, etc.), discuss the needs of members, and plan
for the future. While every EIM staffer was not present, a
few dozen were in attendance. Thus, the event comprised
staffers from Elektor magazine, Circuit Cellar magazine,
Elektor.Labs, audioXpress magazine, Voice Coil magazine,
EIM management, and EIM’s customer service teams. What
follows are some key conclusions taken from the event.

MEMBER FOCUS
Each year, EIM runs comprehensive member surveys will work to engage the
COMMUNITY

in order to gauge what readers and customers want. We’ll next generation of young
continue to do this, but also engage our community more engineers more actively
often in a variety of places: online via social media and in than ever via social
person at industry events. The goal: more interaction with media, video, and more.
members and thus enhanced offerings in the near future.
E-LEARNING
SHARE KNOWLEDGE & EXPERTISE The message from
EIM has electrical engineering, audio engineering, and our community is clear:
programming experts around the globe working on content offer more e-learning
for Circuit Cellar magazine, Elektor magazine, Elektor. opportunities. We intend
Labs, Voice Coil magazine, and audioXpress magazine. to do this. In addition to
We currently share content between brands (e.g., we our currently scheduled
occasionally publish relevant electronics tips from Circuit webinars and technical
Cellar in Elektor.) Moving forward, we’ll work even harder videos, we will focus on
to share relevant content between brands. The goal is to developing a more robust
enrich the experiences of our members diverse content. e-learning offering. In
fact, we’ve already begun!
REACH & INSPIRE Stay tuned.
An important short-term goal is to reach and inspire
young engineers. Many of our current members have been
reading EIM’s magazines, such as Circuit Cellar, Elektor, and
audioXpress, since their early teens. Moving forward, we
8 CIRCUIT CELLAR • AUGUST 2014 #289

QUESTIONS & ANSWERS

Embedded Systems
Training Expert
An Interview with Jason Long
Professional engineer Jason Long worked as an embedded systems designer
for more than a decade. In 2010 he founded Engenuics Technologies. Jason
lives in Victoria, BC, where he continues growing his company alongside the
MicroProcessor Group (MPG) embedded systems hardware teaching program
he developed in 2000.—Nan Price, Associate Editor
COMMUNITY

NAN: In 2010 you founded your company and my ability to speak in public if I was going
Engenuics Technologies (www.engenuics. to have any luck with a career outside of a
com) based on the success of the cubicle, let alone survive an interview to get a
MicroProcessorGroup (MPG) program. Give job in the first place. The combination of these
us a little background. How did the MPG two things was the perfect excuse/opportunity
begin? to start up the MPG to ensure I kept learning
by being accountable to teach people new stuff
JASON: MPG started way back in 2000 at the each week, but also to gain the experience of
University of Calgary when I was doing my delivering those presentations.
undergraduate studies. I figured out that I was blown away when there were almost
embedded systems was exactly what I wanted 30 people at the first MPG meeting, but I
to do, but struggled to find enough hands- was ready. Two things became very clear
on learning in the core curriculum programs very quickly. The first was that, to be able to
to satisfy this new appetite. I was involved teach, you must achieve a whole new level of
in the university’s Institute of Electrical and mastery about your subject, but it was also
Electronics Engineers (IEEE) student branch, okay to say, “I don’t know” and find out for
where someone handed me my first Microchip next week. The second was that I could, in
Technology PIC microcontroller and ran a few fact, get my nerves under control as long as I
lunchtime tutorials about getting it up and was prepared and didn’t try to do too much.
running. I wanted more, and so did other I’m still nervous every time I start a lecture,
This ARM-based development board is people. even 14 years later, but now I know how to
made by Jason’s company, Engenuics I was also very aware that I needed to use those nerves! The best part was that
Technologies. drastically improve my personal confidence people really appreciated what I was doing
and perhaps were a bit more tolerant since
MPG is free. I found a love for teaching that I
didn’t expect, nor did I get how rewarding the
endeavor would be.
When I was wrapping up the ninth year of
the program, I considered giving it one more
year and then calling it quits. I took a moment
to look back at what the program was when
I started and where it had come to—it had
indeed evolved a lot, and I figured I had put
in about 2,000 h by this point. It seemed like
a waste to throw in the towel. I also looked
at the relationships that had come from the
program, both personally and professionally,
and realized that the majority of my career
and who I had become professionally had
really been defined by my work with MPG. But
the program—even though it was still just in
DESIGN YOUR SOLUTION TODAY
CALL 480-837-5200

TS-4900 Computer Module Touch Panel Computers


1.2GHz i.MX6 w/ WiFi & Bluetooth Panel Mount or Fully Enclosed

pricing
starts at
series
$134 starts at

qty 1 $ 369
$ 99 qty 100
qty 100
$ 409
qty 1
1.2 GHz Single or Quad Core Cortex A9 ARM CPU
Up to 2 GB DDR3 RAM and 4 GB eMMC Flash
Wireless 802.11 b/g/n and Bluetooth 4.0
1x Gigabit Ethernet, 1x PCI Express Bus
1x mSD slot, 1x SATA II, 1x USB Host, 1x USB OTG
70x DIO, 4x I2C, 1x I2S, 2x SPI, 2x CAN
-40 to +85C Industrial Temperature Range
Features can include:
Runs Linux 3.10, Debian, Ubuntu, Yocto, QT, OpenGL
5-inch, 7-inch and 10-inch touchscreens
Coming Soon: QNX, Android and Windows Support
Fanless operation from -20 to +70C
Up to 1.2GHz ARM CPU
Computer-on-Modules
Up to 2GB RAM, 4GB eMMC Flash
State of the Art Embedded Design
2x microSD with DoubleStore
TS-4740: High Capacity FPGA and Gigabit Ethernet 2x Ethernet, 2x USB Host
TS-4600: 450MHz low cost w/ 2 Ethernets CAN, RS-232, SPI, I2C, DIO
TS-4710: Up to 1066MHz PXA168 w/ video 1x RS485 Two-Wire Modbus
TS-4720: Like TS-4710 + 4GB eMMC Flash & 2 Ethernets Optional cellular, WIFI & XBEE radios
TS-4200: Atmel ARM9 w/ super low power Supports Android and Linux w/ fast boot times
TS-4800: 800MHz FreeScale iMX515 w/ video Headphone connector and speaker

We’ve never Embedded Support every Unique embedded


discontinued a systems that step of the way solutions add
FE

L
D

NA
N
LI

GE

PE

GI

product in 30 are built to with open value for our


NG

RI
RU
LO

years endure source vision customers


10 CIRCUIT CELLAR • AUGUST 2014 #289

QUESTIONS & ANSWERS

and find students of the same mindset I was


in when I started MPG? They could lead the
program at different universities and develop
those infinitely valuable communication and
leadership skills that MPG fosters, except
they’d have the advantage of not having to
put in hundreds of hours to write all of the
material. Even if groups of people weren’t
playing with MPG, individuals could make use
of the technical resource on their own and we
could have a solid online community. I also
wanted to keep students engaged beyond the
single year of their engineer degrees in which
MPG existed.
I didn’t fully know how I was going to
execute this plan, but perhaps I had earned a
bit of karma because a few serendipitous things
happened just three weeks after I incorporated
Engenuics Technologies. My phone rang, and
it was Dynastream Innovations, a Calgary
COMMUNITY

MicroProcessorGroup (MPG) Level 2 Calgary—was too big to keep as a side project. company that developed the ANT+ protocol that
focuses on application development. I had $10,000 in inventory to support the competes with Bluetooth Low Energy (BLE).
development boards, and although all monies They had just interviewed three students who
stayed in the program, there were thousands brought their MPG development boards with
of dollars exchanging hands. This was a them to show off the ANT radio that was on the
business waiting to happen, though I had board that they knew how to run. Dynastream
never thought of myself as an entrepreneur. I had just discovered MPG, and they were blown
was just doing stuff I loved. away.
Around the same time I discovered To wrap up this long story, Dynastream
SparkFun Electronics, and more importantly, I understood the objectives and the potential of
discovered the story of how the company got MPG immediately and wanted more. I figured
started by Nathan Seidie. That story begins out how to achieve my plan of growing MPG into
almost exactly how MPG began, but clearly a resource that students would have through
Nathan is a lot smarter than I am and has built their entire degree program and shared that
an amazing company in the same time it took with Dynastream. Dynastream became my
me to get to this point. I feel quite disappointed first customer that sponsored a very intensive
when I think about it that way, but thankfully four months of my time to develop MPG Level
I don’t think it’s too late to do what I should 2 in time for the upcoming fall school term.
have done a long time ago. I hope to meet Now MPG had the continuity it was looking
Nathan one day, but even if I don’t, I consider for and Dynastream had access to a trusted
him a mentor and his story provides validation resource of students who proved that they had
that the MPG platform and community may be incredible interest, ability, and commitment to
able to grow and be sustainable. working with embedded systems.
I think MPG/Engenuics Technologies can These are exactly the people who
find similar success as SparkFun. We can do Dynastream wants to hire, and MPG exposes
that without ever having to compete against them without ever having to go through the
SparkFun because what we do is unique regular (and horrible) process of filtering
enough. There might be a bit of overlap, but resumes and spending days in job interviews
I’m always going to try to complement what trying to figure out if there is a match.
SparkFun does rather than compete against Dynastream’s continued support of the
it. We simply become another resource to program four years later tells me it’s working
feed the voracious and infinite appetite for for them. There are nearly a dozen companies
information from students, hobbyists, and in Calgary now that sponsor MPG to support the
engineers. Win-win is always the way to go. initiative and take advantage of the resource.
I decided I should grow the program There’s no reason why this can’t be replicated
instead of ending it, so I started Engenuics in every city in North America, right?
Technologies, which would be built on the
decade of MPG experience plus the decade NAN: What other products/services does
of embedded design experience I had from Engenuics Technologies provide?
the industry. It seemed like a pretty solid
foundation on which to start a company! JASON: I describe Engenuics Technologies
Surely I could promote all of the content as a four-tier company as there are three
DESIGN YOUR SOLUTION TODAY
CALL 480-837-5200

TS-7670 Industrial Computer TS-7250-V2 Embedded Board


GPS & Cellular Modem to Track Assets High Performance & Industrial Grade
pricing starts at
Backwards Compatible with TS-72xx
$168 $129
qty 1 qty 100
pricing
shown w/ starts at
optional
micro $199
SD Card qty 1

$165
qty 100

low cost plastic


enclosure available

Features: Features:
454MHz ARM CPU 1x USB Host Up to 1GHz ARM CPU 2x USB Host
Up to 256MB RAM 4x DIO, 2x CAN 512MB RAM 1x USB Device
2GB NAND Flash 2x COM, 1x RS-485 4GB eMMC Flash 6x Serial Ports
2x mSD Card Socket 1x Battery Backed RTC 2x SD Card Socket 75x DIO, 1x CAN

1x 10/100 Ethernet 1x Temperature Sensor 2x 10/100 Ethernet 1x PC/104 Connector

Benefits: Benefits:
Low power with 10mW sleep state Hardware Flexibility with On-board FPGA

-40 to +85C, 100% soldered-on components Several control I/O interfaces

Easy development w/ Debian and Linux 2.6 Launches your application in under a second

Boots quickly to your Embedded Application Easy development w/ Debian and Linux 2.6

Guaranteed available until 2025 High Data Reliability with DoubleStore


Coming Soon: -40 to +85C Industrial temperature range
TS-7680 like TS-7670 w/ WiFi & Bluetooth

We’ve never Embedded Support every Unique embedded


discontinued a systems that step of the way solutions add
FE

L
D

NA
N
LI

GE

PE

GI

product in 30 are built to with open value for our


NG

RI
RU
LO

years endure source vision customers


12 CIRCUIT CELLAR • AUGUST 2014 #289

QUESTIONS & ANSWERS

significant aspects of the do it. We specialize in getting those to market


business in addition to MPG. The quickly but also training these people to be
main purpose of the company is able to do it themselves. Our culture is very
to fill a gap in the industry for adept to these kinds of relationships. We’ve
specific training in embedded taken dozens of products from conception
systems. There is very little through to production.
formal training to be found for We have also commercialized some little
low-to-mid-level embedded gadgets and tools that have come out of
hardware and firmware necessity in our own designs. My personal
development and quality/value is favorite is an instant serial cable tester that
often hit or miss. From teaching lets you check if you’ve got a null modem cable
for 10 years while being an and also verifies all the conductors. You’ll really
embedded designer for the same appreciate this one if you’ve ever wasted an
amount of time, I felt like I had afternoon debugging an UART driver that won’t
the right skills to create great transmit only to discover you unknowingly
training. I had already created a grabbed a null modem cable.
LabVIEW course that I delivered MPG has led us to scour the globe to find
This instant serial cable tester is one
internally for a company while great quality bench tools that students can
of Engenuics Technologies’s designs— I worked there, and people were blown away afford and we’re happy to pass that educational
by the quality and content. I saw a huge need pricing on to everyone. For too long we didn’t
COMMUNITY

and a favorite of Jason’s.


to develop embedded-specific training to help even advertise this stuff outside of MPG. One
new graduates transition to the industry as day I looked at my list of finished goods and
well as junior engineers who were lacking in realized our product line had close to 50 items,
some fundamental engineering knowledge. many of which a few people have discovered
We have an embedded boot camp course and absolutely love us for providing. Did I
that is about 20% hardware and 80% firmware mention I’m not a very good entrepreneur?
focused, which I think is essential for new We add new stuff all the time, and we’re also
engineering graduates getting into embedded open to suggestions on handy little tools that
design. Though the course is based specifically may exist as breadboard hacks on your bench
on a Cortex-M3 development board, we ensure but would benefit thousands of engineers who
that we focus on how to learn a processor so need to solve the same problem.
the knowledge can be applied to any platform. All of this makes up what I consider to be a
Engenuics Technologies has several courses very solid business plan (as every entrepreneur
now and we continue to offer those periodically surely says about their own business plan).
though never as often as we would like, as we’ve Finally we’re taking the time to properly spread
become too busy with the other parts of the the word and offer what we do to the huge and
company. We finally got an office last August hungry market out there.
with an onsite training room, which makes the
logistics much easier, and we’re ramping up NAN: You’ve run an MPG course every year
the frequency of the programs we offer. at the University of Calgary. Do you consider
I would love to establish the trust in the this course introductory or is it designed for
industry so Engenuics Technologies would be more experienced engineering students?
the first place that an engineer would look
if they wanted to learn a new processor or JASON: I consider MPG as the start of the
specific technology (e.g., ultra-low-power ANT bridge to the industry. I assume the second-
radios). I’m not talking a day-long marketing year students who start MPG Level 1 barely
session of fluff. We do week-long, intensive, know what a resistor actually does and I ensure
hands-on development that will just about that they get that kind of information. I have
make your brain explode. Our classes are never interviewed new EE grads who couldn’t tell me
more than six people, so it is very personal. what a pull-up resistor is, and I’ll bet 95% of
We recognize that getting an industry them couldn’t explain a decoupling capacitor.
training company stabilized is going to take That’s just wrong. There are endless online
some time. So meanwhile, we are paying the discussions about this from people all over
bills by doing contract design. Through a great North America. The industry keeps calling on
network and trusted relationships, we work on academia to fix this, but an engineering degree
some pretty great projects for companies. This is already packed as it is. Plus, not every student
started with our immediate contacts, but has cares about embedded systems or how to
spread nicely through referrals and even some solder. I think it really comes down to industry
random people who have found us online. stepping up to offer the resources (not just
There seems to be an infinite number of money—they need to get their people involved)
people or small companies that want to create to make niche programs like MPG—but that’s a
an embedded design but need some help to whole other story and maybe a TED talk.
circuitcellar.com 13

QUESTIONS & ANSWERS

Back to MPG, I also assume that students have interviews, by the way—that’s fun.
a)
taken at least one C programming course and While we’re doing the hardware, students are
can tell me what 0xE is in decimal and binary or learning to speak the jargon of embedded systems
at least use Windows calculator to figure it out. and gain confidence with what they’re working on.
However, if they can’t, it’s all written in my notes, It is fundamentally different than a core course
which are open source and freely available on our because they’re doing it to feed an interest and
MPG website. to see something work, not because they need
I want everyone to feel comfortable and a good mark for their GPA. This transformation
to ask the “stupid questions” in the very safe from a shy, totally uniformed student who doesn’t
environment that MPG provides. So yes, in many know what PCB stands for, to a confident, capable,
ways MPG is introductory, but what we get into young engineer excited about blinking LEDs is one
quickly surpasses the depth of what a student of the most profound things I witness every year. I
will experience from their core courses because wish there was a way to equate a monetary value
we drill a narrow hole straight down to exactly to that growth so students could really understand
the information we need to make a processor the value of MPG. After all these years, I’ve found
work. Since everything is written down (and that it clicks with a lot of them three to five years
with the intent of one day being as complete after they graduate.
and comprehensive as the Khan Academy, which Anyway, after the hardware is done, Level 1 is
provides “a free world-class education for anyone then all about using the main peripherals you find
anywhere”), it’s truly a resource that can be on any microcontroller: general-purpose input/

COMMUNITY
leveraged by anyone at any time. Even I reference output (GPIO) to work with LEDs and buttons,
my own notes when it has been a while since PWM, UART, and a touch of I²C to get the LCD
I’ve worked with a particular piece of code or working. We also give students some code to use
hardware. the onboard ANT radio to do neat things in the
exercises. We’re finishing up a new demonstration
NAN: What can attendees learn from the MPG project that the “hammies” out there might love:
course? a Morse code messenger and trainer. By the time
this is in print we should be pretty close to having
JASON: I would sum up the written course material that going.
as everything I’ve learned in the industry for 14 Level 2 takes all of those drivers and hammers
years written down complimented with about in the concept of an API and writing code into an
50,000 lines of commented code examples. If you existing framework. The whole program focuses
studied it all and learned everything, then you on designing and implementing a simple version of
would know everything I know about embedded Pong that is played over the ANT radio. It’s pretty
systems. Well, maybe not everything—I’m challenging to build something that complex in
probably about three years behind in my notes. the time we have, so what we end up doing keeps
I always wish I could teach all of that content to changing each time the program runs. We run
students, but as an extracurricular program, which bare metal—no OS—so people really see what
usually sits on top of five or six core curriculum has to happen to make a multitasking system. I
courses each term, what we can do in MPG is a tiny have a plan for a whole new MPG program that
subset. Once MPG Level 2 came along, we were able incorporates FreeRTOS.
to get much further, especially with the new Atmel That’s the technical side of MPG, but now
boards introduced last year that gave both Level that I really “get” this program I’ve realized that
1 and Level 2 the same base platform and have the technical side is like 10% of the value that
onboard J-Links, thanks to recently getting Segger students earn. MPG is designed now to work with
onboard with MPG. students through their entire undergraduate
We do soldering at the start of both Level 1 and degree program and then keep them engaged
Level 2. I’m talking real soldering, not massive and (and supported) in their careers. Learning to
obsolete through-hole parts. The MPG development communicate and mentor are what it’s really all
boards come about 90% populated, but students about, but as I said earlier, this intangible aspect
still put on around 40 components including 0603 of MPG takes a while to realize.
passives and ICs as small as TSSOPs. Don’t forget that this is all free for students.
A lab tech once told me I should use bigger We charge for the development boards to cover
parts or at least make extra-large pads to make it their cost, though they’re discounted from what
easier. That is so fundamentally wrong to me and individuals would pay because of the industry
I’ll never do it. I’ve taught 10-year olds to solder sponsorship of MPG. As the program grows, we’ll
0603s—it takes a bit of time, but then they can do reduce this further and enhance things like our
it no problem. Okay, some students never get it, bursary program and soldering competitions. It
but neither do some practicing engineers and they would be really nice to actually cover some of our
know it, and who cares? Knowing what we can’t labor costs in creating new content and delivering
do so we can seek help is just about as good as MPG, as that’s still all out of pocket. I figure I’m in
being able to do it. I make engineers solder during for about $250,000 worth of time since I started
14 CIRCUIT CELLAR • AUGUST 2014 #289

QUESTIONS & ANSWERS

MPG, but I have absolutely no regrets and no list is getting done as I can hire more people
intention on slowing down due to the intrinsic to pick away at it. I see my passion spreading
value of the effort. to others and of course there are thousands of
equally passionate people doing this stuff who I
NAN: What type of work did you do prior to can’t wait to meet, help, and learn from.
Engenuics Technologies?
NAN: You earned your BSEE from the
JASON: My entire career has been defined University of Calgary in 2002. Can you
by my involvement with MPG. My job out of describe any of the projects you’ve worked
school was a dream-come-true as I was doing while you were there?
firmware and hardware right away with a
company called BW Technologies. I got that JASON: The professors at the U of C were a
job because of an MPG contact and because I phenomenal bunch and it was a privilege to
actually had a solid skill set that could be put get to know them and work with them during
to work immediately. The most fortunate part my undergraduate studies. I remain in contact
of belonging to that company was establishing with many of them, and several are very good
my relationship with the owners and managers friends. Aside from blinking some LEDs on
who were brilliant people, technically and with breadboards, the first complicated device I
the business. They were very open about what built was an attempt at the IEEE Micromouse
was going on and would talk about it if you competition. That proved to be a little much
COMMUNITY

Jason helped develop tracking devices


like this Loner safety-monitoring were interested. and my robot never did do anything beyond go
device (SMD) when he worked at I left BW Technologies when a team lead forward, sense a wall, and then back up.
BlackLine GPS. position came up (through my network thanks I originally thought I would base MPG
to MPG, of course) at General Dynamics (GD) around building robots, but that proved
Canada, though I continued to stay in touch impossible due to cost. Building a robot is
with BW Technologies. I loved the opportunity still on my bucket list. I’ll likely get there once
to lead a team and I loved the military aspect my two boys are old enough to want to build
of what GD did, but I didn’t like not doing robots. I continue to fantasize about building
design while I was there. Fortunately, MPG an autonomous quadcopter that can deliver
kept me engaged technically—that’s actually beer. I better get busy on that before its
when I decided to change the program from commonplace!
PIC to ARM and step things up. Our IEEE student branch had a Protel 99
GD was a really great experience. It seemed SE license and somehow I learned how to
to take forever to dig in there, but eventually design PCBs. The first board I designed was
my team was very successful and I loved what a binary clock that I still use. I then did a
we were doing. However, I made a difficult PIC programmer and later I built a combined
choice to leave after just two years to go to development board and programmer for MPG.
BlackLine GPS. BlackLine was a startup that I also designed the PCB for our fourth-year
was discovered by some ex-BW Technologies Capstone design project, which initially was a
guys who invested and re-assembled a lot of very boring implementation of a phase-locked
the core BW team. They went public, pushed loop, but became a lot more fun when I decided
out some sweet products, and are now doing to make it programmable with a keypad and
really well. I was there for four years but was an LCD. I brought all these things to my BW
actually working two jobs as I was ramping up Technologies job interview and proudly showed
Engenuics on evenings and weekends. I felt them off. For any students reading this, by
ready to finally give my own company a go full the way, landing your first engineering job is
time, and BlackLine was really supportive. probably 5% technical, 10% GPA, and 85%
So just like that, a decade had gone by enthusiasm and demonstrated interest and
where I was always doing embedded design achievement. It’s really boring to interview
but also always teaching and growing MPG, and someone who has done nothing extracurricular.
somehow I wound up with my own business.
It seemed like an 80-h work week was pretty NAN: How long have you been designing
common (I once did four 120-h weeks in a row), embedded systems? When did you become
so it’s like I earned 20 years of experience in interested?
that time. People in the industry were always
very interested in MPG and impressed by the JASON: My dad was a high school science
effort, which really helped me grow my network teacher and my mom was a nurse, so I didn’t
of people. Despite approaching burnout a few have a lot of technical influence growing up.
times, I continue to love embedded design and I loved talking physics with my dad, and I’m
will be very surprised if I ever leave the field. one of the few engineers who can cook (thank
What’s most exciting now is that as the Engenuics you, mom).
Technologies team grows, my very long “to-do” Aside from really liking LEGO and
circuitcellar.com 15

QUESTIONS & ANSWERS

dismantling anything electronic (without a) b)


ever a hope of putting it back together but
always wondering what all those funny looking
components did), I barely demonstrated any
interest in EE when I was young. But somehow
I figured out in grade 12 that EE was probably
what I should study at university.
I’m sure I still had visions of being a video
game designer, but that nagging interest in
learning what those funny components did
steered me to EE instead of computer science. It d)
wasn’t until my second year at university when
someone gave me my first PIC microcontroller c)
that I really knew that embedded was where
I needed to be. That someone was a student
named Sean Hum, a brilliant guy who is now an
associate professor at the University of Toronto.

NAN: Are you currently working on or


planning any projects?

COMMUNITY
JASON: I add to my “to-do” list almost every JASON: I particularly like the 2.4-GHz radio While studying at the University
day. My main focus right now is to grow MPG (I technologies that hold the potential to really of Calgary, some of Jason’s first
would love to talk to any student or professional make our environment interactive and embedded designs included a
programmable phase-locked loop
about getting this going in your community) intelligent. I think the world needs more
Capstone project (a), a robot built for
and the Engenuics Technologies product line. intelligence to address the wasteful nature
an IEEE Micromouse competition (b),
I’m aggressively pursuing some grants to of what we have become whether it is by an MPG development board (c) and a
get going on a few new products that I think actively doing something like turning the binary clock (d).
have some potential—those are secret, though lights or heat off when we’re not around,
nothing that will change the world and they or by simply making us more aware of our
are unlikely to put the valuation of Engenuics surroundings. I love ANT+ and am just getting
Technologies in the billions any time soon. into BLE—obviously, smartphone integration
We’re just wrapping up work on a customer will be critical.
project for a Wi-Fi/general packet radio service I think technology will drive change in
(GPRS) updateable LED message sign. These education and I hope to see (and perhaps be a
things are very cool, and I’m going to buy a driving force behind) a more cohesive existence
bunch once they’re in production to be a core between academics and the industry. I hope
part of the MPG “franchise” network since MPG becomes a model to the industry of what
they can be all over the world and updated in can be achieved with not a lot of financial
unison over the air via a browser. There seems resources, but has immense payback for
to be infinite potential applications for this employees who become mentors and students
thing from fast-food restaurants and lotteries, who can connect with the industry much
to banks and tradeshows. I’m always excited earlier and thus get more from their degree Here is a larger view of the robot
(and terrified) to see one of my designs come programs and graduate with substantially Jason built for an IEEE Micromouse
to market. There are also more gadgets to higher capabilities. competition.
build and a long list of courses to finish and
start delivering.
I have six-month and 2.5 year-old boys who
are definitely projects in progress. I recently
registered a domain and a Facebook page
called embeddad.com. Now I have a whole
new to-do list of projects that let me continue
to feed my need for embedded design while
still pursing some work-life balance with my
family. I hope to share those and connect with
other engineer dads out there just to show off
some geeky stuff we do with our kids. I love to
enable people and if I can help you make your
kid’s day by putting flashing blue and red LEDs
on a toy police car, then you bet I will.

NAN: Which new technologies excite you?


16 CIRCUIT CELLAR • AUGUST 2014 #289

PRODUCT NEWS

RN4020 BLUETOOTH SMART MODULE


Microchip Technology recently announced its first Microchip also recently announced the RN4020 Bluetooth
Bluetooth 4.1 Low Energy module, the RN4020. The Low Energy PICtail/PICtail Plus daughterboard (part number
integrated Bluetooth Low Energy (BTLE) stack and on-board RN-4020-PICtail). The board enables code development via
support for the common SIG low-energy profiles speeds USB interface to a PC, and over the on-board In-Circuit
time to market, while ensuring Bluetooth compatibility, Serial Programming interface for Microchip’s PICkit or
eliminating expensive certification costs, and reducing MPLAB REAL ICE tools.
development risks. The module comes preloaded with the The RN4020 Bluetooth Low Energy Module is available for
Microchip Low-energy Data Profile (MLDP), which enables $6.78 each in 1,000-unit quantities. The RN4020 Bluetooth
you to stream any type of data across the BTLE link. Low Energy PICtail/PICtail Plus daughterboard costs $49.
As a stack-on-board module, RN4020 can either connect
to any microcontroller with a UART interface or operate Microchip Technology, Inc.
standalone for basic data collection and communication, www.microchip.com
such as a beacon or sensor. This standalone operation is
facilitated by Microchip Technology’s no-compile scripting,
which allows module configuration via a simple ASCII
command interface. Neither tools nor compiling are required.
INDUSTRY & ENTERPRISE

The designers of cost-sensitive embedded applications


are looking for turnkey solutions that make it easy to add
the low-power consumption and simplicity of Bluetooth LE
connectivity, which enables several years of operation from
a single battery and has a large installed base of compliant
smartphones, tablets and computers. The RN4020 Bluetooth
LE Smart module includes all of the hardware, software, and
certifications that you need to easily add this low-energy
connectivity to any design, while easing End Product Listing
(EPL) via QDID Bluetooth compatibility testing. All of the
programmable profiles are stored and selectable on the
module, including Microchip Technology’s flexible MLDP and
the common Bluetooth SIG low-energy profiles. In addition
to common public profiles, private services can be created
via the ASCII command interface. The RN4020 also provides
a built-in PCB antenna with 7-dBm transmit power and a
receive sensitivity of –92.5 dBm in a compact form factor of
only 11.5 × 19.5 × 2.5 millimeters.

TRACE32 TOOL QUALIFICATION SUPPORT KIT


The Lauterbach recently announced a Tool Qualification Support Kit for the TRACE32
code coverage analysis. The qualification toolkit was designed to help customers facing the
many challenges of software development for safety-related systems to
complement the tool qualification when TRACE32 is selected as preferred
solution for trace-based code coverage analysis. It aims to meet the
requirements for the development of avionic and automotive applications
in compliance with DO-178C and ISO 26262.
The TRACE32 Tool Qualification Support Kit is provided as prefabricated
package containing documents and a test suite for the validation of
TRACE32. In the upcoming months, the scope of the test suite will be
continuously extended to provide support for various platforms.

Lauterbach
www.lauterbach.com
mouser.com
The Newest Products for Your Newest Designs®

ORE.

The widest selection


of the newest products.

Authorized distributor of semiconductors


and electronic components for design engineers.

Mouser and Mouser Electronics are registered trademarks of Mouser Electronics, Inc. Other products, logos, and company names mentioned herein, may be trademarks of their respective owners.
18 CIRCUIT CELLAR • AUGUST 2014 #289

PRODUCT NEWS

FAST QUAD IF DAC


The AD9144 is a four-channel, 16-bit, 2.8-GSPS DAC that
supports high data rates and ultra-wide signal bandwidth to
enable wideband and multiband wireless applications. The
DAC features 82-dBc spurious-free dynamic range (SFDR) and
a 2.8-GSPS maximum sample rate, which permits multicarrier
generation up to the Nyquist frequency.
With –164-dBm/Hz noise spectral density, the AD9144
enables higher dynamic range transmitters to be built. Its
low SFDR and distortion design techniques provide high-
quality synthesis of wideband signals from baseband to
high intermediate frequencies. The DAC features a JESD204B
eight-lane interface and low inherent latency of fewer than
two DAC clock cycles. This simplifies hardware and software
system design while permitting multichip synchronization.
The combination of programmable interpolation rate, high
sample rates, and low power at 1.5 W provides flexibility
INDUSTRY & ENTERPRISE

when choosing DAC output frequencies. This is especially


helpful in meeting four- to six-carrier Global System for
Mobile Communications (GSM) transmission specifications The DAC is supported by an evaluation board with an
and other communications standards. For six-carrier GSM FPGA Mezzanine Card (FMC) connector, software, tools,
intermodulation distortion (IMD), the AD9144 operates at 77 a SPI controller, and reference designs. Analog Devices’s
dBc at 75-MHz IF. Operating with the on-chip phase-locked VisualAnalog software package combines a powerful set
loop (PLL) at a 30-MHz DAC output frequency, the AD9144 of simulation and data analysis tools with a user-friendly
delivers a 76-dB adjacent-channel leakage ratio (ACLR) for graphical interface that enables users to customize their
four-carrier Wideband Code Division Multiple Access (WCDMA) input signal and data analysis.
applications. The AD9144BCPZ DAC costs $80. The AD9144-EBZ and
The AD9144 includes integrated interpolation filters with AD9144-FMC-EBZ FMC evaluation boards cost $495.
selectable interpolation factors. The dual DAC data interface
supports word and byte load, enabling users to reduce input Analog Devices, Inc.
pins on lower data rates to save board space, power, and cost. www.analog.com

NEW STM32 MICROCONTROLLER DESIGN TOOLS


New STM32 microcontroller design tools from STMicroelectronics bring the efficiency of the STM32Cube software
platform, and the convenience of STM32Nucleodevelopment boards, to projects targeting STM32 F3 mixed-signal and STM32
F0 entry-level devices. For STM32 F31 and STM32 F02 devices, the latest STM32CubeF3 and STM32CubeF0embedded software
provides free and ready-to-use dedicated middleware stacks, such as touch-sense and USB libraries, and a collection of
drivers for STM32 peripherals through the Hardware Abstraction Layer (HAL) that simplifies porting of applications from
one STM32 series to another. Using this embedded software with the latest version of the STM32CubeMX PC-based tool,
developers can configure the microcontroller with graphical wizards, and simply click to generate initialization C-code that
can be used directly in many popular third-party development tools.
The new software joins similar STM32Cube platforms released earlier in 2014 for STM32 F4, F2 and L0 series, which
simplify project starts and include hundreds of code-usage examples.
STM32Nucleo development boards are also now available for the STM32 F3 (NUCLEO-F302R8) and STM32 F0 lines (NUCLEO-
F072RB) to assist early application development, leveraging the large ecosystem of Arduino application shields as well as
dedicated ST extension boards. STM32Nucleo boards provide access
to all device I/Os and integrate an ST-Link debugger/programmer,
saving the need for a separate debug probe. Last but not least,
the STM32Nucleo boards are mbed-enabled, which means they
can be directly connected and run through the online development
environment at mbed.org.
The STM32Nucleo boards start at $10.32. For further information
on STM32Nucleo boards, go to www.st.com/stm32nucleo. To download
STM32Cube software free of charge, go to www.st.com/stm32cube.
.
STMicroelectronics
www.st.com
circuitcellar.com 19

CLIENT PROFILE

Total Phase, Inc.


www.totalphase.com
735 Palomar Avenue, Sunnyvale, CA 94085

CONTACT: stephen@totalphase.com

FEATURED PRODUCTS: The Aardvark I2C/SPI Host Adapter is


a fast and powerful I2C bus and SPI bus host adapter through
USB, allowing a developer to interface a Windows, Linux, or
Mac OSX PC via USB to a downstream embedded system
environment and transfer serial messages using the I 2C and sale terminals, our users have leveraged our technology
SPI protocols. Part Number: TP240141 (www.totalphase.com/ for unprecedented visibility into closed systems for over a
products/aardvark-i2cspi/) decade. Not only do you get visibility into your system, you

INDUSTRY & ENTERPRISE


can address a device at the chip level regardless of how it was
The Komodo CAN Duo Interface is a powerful two-channel USB- programmed. Once you have the information unlocked, feed
to-CAN adapter and analyzer. The Komodo interface is an all- your IoT solution and complete the circuit. Close the loop by
in-one tool capable of active CAN data transmission as well using our programming tools to enhance your embedded IoT
as nonintrusive CAN bus monitoring. Part Number: TP360110 solutions. Build solutions in IoT today.
(www.totalphase.com/products/komodo-canduo/)

WHY SHOULD CC READERS BE INTERESTED? Intelligent Circuit Cellar prides itself on presenting readers with information
visibility into embedded systems means business. Unlock your about innovative companies, organizations, products, and
infrastructure and stretch your investment into the Internet services relating to embedded technologies. This space is
of Things (IoT). Discover new ways to unlock your data on where Circuit Cellar enables clients to present readers useful
formally closed systems. From unlocking a city bus to point of information, special deals, and more.

Wide Temp. Panel PC


PPC-090T
l Vortex86DX2 933MHz Fanless
l Up to 1GB of Onboard Memory
l Low Power Consumption
l 2 RS232/422/485 serial ports
l 3 USB 2.0 Host Ports
l 10/100 BaseT Ethernet
l PS/2 KB port, Audio Out
l Compact Flash Slot / SD Slot / SATA
l 9 inch 1024 x 600 WSVGA TFT LCD
l Resistive Touch Screen
l DC-IN +12VDC / +24VDC
l IP65 Front Panel
l Wi-Fi (Optional)
l Giga Ethernet (Optional)
l Wide Temperature (Optional) 3.xx KERNEL

The PPC-090T comes ready to run with the Operating System installed on flash
disk. Apply power and watch the Linux X-Windows desktop user interface appear
on the vivid color LCD. Interact with the PPC-090T using the responsive integrated
touchscreen. Everything works out of the box, allowing you to concentrate on your
application rather than building and configuring device drivers. Just Write-It and
Run-It... Pricing starts at $495 for Qty 1.
http://www.emacinc.com/sales/cc9

Since 1985
OVER
29
YEARS OF

EQUIPMENT MONITOR AND CONTROL


SINGLE BOARD
SOLUTIONS

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


20 CIRCUIT CELLAR • AUGUST 2014 #289

Build a Digital
Pulse Generator
FEATURES

This microcontroller-based, fully digital pulse


generator will be a welcome addition to any
electronics workbench. The device’s accuracy,
stability, and programmability are ideal for use
with many new projects.

By Brian Beard (US)

O ver the years I have designed and


built many of the instruments on my
electronics bench. Until recently, I was using
My design goals were to have a fully digital
pulse generator with a setting range of eight
orders of magnitude, a digital display, and
a pulse generator I built as an undergrad simple controls—both manual and RS-232. I
decades ago. The generator used a cross- decided to stick with a 5-V logic level output
coupled Texas Instruments 74123 dual that could be externally translated to other
retriggerable monostable multivibrator voltage levels, if necessary.
rotary switch to select the capacitors for the
time constants, and potentiometers for fine THE CIRCUIT
tuning. Unfortunately, it tended to drift and had Photo 1 shows the mid-level Microchip
a limited nonlinear adjustment range and noisy Technology PIC16F87 microcontroller I used
switches. I decided it was time to build a new to control the pulse generator. The PIC16F87
pulse generator that solved these problems has 4,096 words of program memory, 368
and would be easy to use. bytes of RAM, 256 bytes of EEPROM, a UART,
circuitcellar.com 21

a 16-bit counter, and an internal oscillator.


Figure 1 shows the microcontroller and RS-232
interface schematics. The PIC16F87 oscillator
runs at 4 MHz but the time reference for the
pulse generator is an external 10-MHz crystal
oscillator stable to ±100 ppm or better. The

FEATURES
10-MHz oscillator produces a 100-ns resolution
for the pulse generator; and long pulse lengths
require a long count.
Many chips would be needed to achieve
a pulse range spanning eight orders of
magnitude—at least eight decade counters
plus latches and multiplexors for the high
(Logic-1) and low (Logic-0) count values. It
looked like it would take too many chips for
what was supposed to be a simple project.
Then I found LSI Computer Systems’s
LS7366R 32-bit quadrature counter chip
with SPI. The LS7366R (U6) counts down the
output’s Logic-0 portion and U7 counts down
the Logic-1 portion (see Figure 2).
The chips are programmed to operate in
a non-quadrature single-cycle downcounter
mode. In this mode, the chip counts down
to zero at which point it pulses the DFLAG
output low (for one 10-MHz clock cycle) then
waits until the INDEX input goes low. This
means the minimum count for each chip is
2 (1 and 0) or 200 ns. When the INDEX goes
low, the chip reloads the counter and begins
to count down.
PHOTO 1
Connecting each chip’s DFLAG output to An internal view of the assembled pulse generator
the INDEX input on the other chip ensures
that only one chip is active at any time. When
the Logic-0 downcounter (U6) reaches zero time a setting changes. Once programmed,
it pulses its DFLAG output, which sets the the counters will automatically generate the
output flip-flop (U8b) and reloads the Logic-1 output pulse train.
downcounter. The Logic-1 downcounter (U7) The pulse generator’s digital display is
then counts down to zero at which time provided by a 2 × 16 LCD module. Most small-
it pulses its DFLAG output, which clears character displays require an 8-bit parallel
the output flip-flop (U8b) and reloads the interface and some control lines. However,
Logic-0 downcounter for another cycle. The the PIC16F87 is already using most of its
PIC16F87 has to program the counters each I/O pins for RS-232 and SPI. Fortunately, an

FIGURE 1
The Microchip Technology PIC16F87
microcontroller and RS-232 interface
BOARDS, BOOKS, DVDs AND MORE AT WWW.ELEKTOR.COM/STORE

Elektor.STORE
The world of electronics
at your fingertips! Bestseller!

W !
E
Learning to Fly With Eagle

N Eagle V6
Getting Started Guide
The book is intended for anyone who wants an
introduction to the capabilities of the CadSoft’s
Eagle PCB design software package. The reader
may be a novice at PCB design or a professional
wanting to learn about Eagle , with the inten-
tion of migrating from another CAD package.
After reading this book while practicing some
of the examples, and completing the projects,
you should feel confident about taking on more
challenging endeavors. This book is supplied
with a free copy of Eagle on CD-ROM for
MS Windows, Linux and Mac.

208 pages • ISBN 978-1-907920-20-2 • $47

ore
This book and m
are available at
m/store
The Ultimate Guide!
www.elektor.co
The LTspice IV Simulator
LTspice IV is one of the most extensive SPICE simulators currently available, with over 1.5 mil- The RPi in Control Applications
Books

lion users worldwide. It is completely free, allowing you to work with an unlimited number of
Raspberry Pi
nodes, components and simulations. So much so, that many of the features on LTspice IV con-
tinue to go unexplored and unexploited and, unfortunately, literature and technical documen-
Hardware Projects
tation are hard to come by. Recently made available in the Elektor Store, The LTspice IV This book is about the Raspberry Pi computer
Simulator book is the ultimate guide to LTspice IV. In a sturdy, hard-cover format, The LTspice and its use in control applications. Dogan
IV Simulator describes the operation of the program, all available commands, the various Ibrahim explains in simple terms, with exam-
editors, dealing with SPICE models, the use of non-linear components and more. Perhaps ples, how to configure the RPi, how to install
the most robust piece of literature on the topic, The LTspice IV Simulator is more than just a and use the Linux operating system, how to
manual. It also offers a variety of tips, methods and examples, all carefully illustrated using write programs using the Python program-
almost 500 drawings, diagrams and screenshots on high-quality paper. The book is designed ming language and how to develop hardware
so that it is suitable for both beginner and veteran SPICE users. based projects.

744 pages • ISBN 978-3-89929-258-9 • $67 290 pages • ISBN 978-1-907920-29-5 • $54

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


Books

110 Elektor Editions, Over 2500 Articles New!


MIFARE and Contactless Cards in Application DVD Elektor
RFID 2000 through 2009 Android Breakout Board
MIFARE is the most widely used RFID tech- This DVD-ROM contains all circuits and pro- The FTDI FT311D is a flexible bridge that
nology, and this book provides a practical jects published in Elektor magazine’s year can interface your circuit to an Android
and comprehensive introduction to it. Among volumes 2000 through 2009. The 2500+ smartphone or tablet. This Elektor Android
other things, the initial chapters cover phy- articles are ordered chronologically by release Breakout Board offers options for seven
sical fundamentals, relevant standards, RFID date (month/year), and arranged in alphabet- digital outputs, four PWM outputs, asynchro-
antenna design, security considerations and ical order. A global index allows you to search nous serial and I2C and SPI interfaces. The
cryptography. The complete design of a read- specific content across the whole DVD. Every board is compatible with Android 3.1 (Ho-
er’s hardware and software is described in article is printable using a simple print func
func- neycomb) or higher (Android Open Accessory
detail. The reader’s firmware and the asso- tion. This DVD is packed with ideas, circuits Mode should be supported).
ciated PC software support programming and projects that are ideal for any electronics
Ready-built module
using any .NET language. enthusiast, student or professional, regardless
of whether they are at home or elsewhere. Art..# 130516-91 • $41
484 pages • ISBN 978-1-907920-14-1 • $68
ISBN 978-1-907920-28-8 • $121

Elektor is more
than just your favorite
electronics magazine.
It’s your one-stop shop
for Elektor Books,
CDs, DVDs, E-Lock
Kits & Modules The E-Lock chip allows you to connect your
A Highly Practical Guide control system to the ‘Network of Networks’
and much more!
Process Measurements and monitor and control it from anywhere on

with C# Applications www.elektor.com/store or around the globe using your computer, ta-
Kits & Modules

blet or smartphone. This completely assem-


This book introduces PC based measurement bled module is able to establish a secure
systems and software tools for those needing to connection over the Internet (TCP/IP) using
understand the underlying principles or apply the Transport Layer Security (TLS) encryption
such techniques. C# was chosen to give readers protocol. The chip also offers a 7-line GPIO
immediate, practical experience with a pro- (general purpose input/output), four 16-bit
minent programming language. C-Sharp has ADC channels, one 12-bit DAC and one I2C bus
a wide support base and is a popular choice for Elektor US that allow control and communication with
engineering solutions. The basics of measure- 111 Founders Plaza, Suite 300 other peripheral devices.
ment and data capture systems are presented, East Hartford, CT 06108
and examples of software post-processing. USA Ready-built module
Phone: 860.289.0800
144 pages • ISBN 978-1-907920-24-0 • $39 Art.#130280-91 • $150
Fax: 860.461.0450
E-mail: order@elektor.com
24 CIRCUIT CELLAR • AUGUST 2014 #289

P2SIR_Select signal goes low. The SPI_


Clock signal clocks data out of the shift
register. The inverted output is used because
the shift register data is inverted again by the
open-drain NAND gate (U11c). An open-drain
output is required because SPI_In is a wire-
FEATURES

ORed signal. Four of the eight parallel inputs


are used to read the front-panel switches.
Many of my bench instruments are
powered by an external 9-VDC, supply so I
designed the pulse generator the same way.
Figure 5 shows the Motorola 78S40 universal
switching regulator subsystem designed to
deliver 5 VDC at up to 100 mA.

PULSE GENERATOR OPERATION


Photo 2 shows the manual pulse generator
controls. The Square/Pulse toggle selects the
operating mode. When power is applied with
the toggle in the pulse position, the initial
FIGURE 2
This schematic shows the clock reference and pulse generation circuitry in an LSI Computer Systems
display will be that shown in Photo 3b. This
LS7366R quadrature counter. display shows that the pulse width (Logic-1)
is 0.5 ms and the pulse spacing (Logic-0) is
0.5 ms. The LCD cursor will be on the first
8-bit parallel output port can be connected digit of the time value in the line chosen by
to the SPI bus using an STmicroelectronics the Line Select switch. The blinking cursor is
74HC4094 8-bit serial-to-parallel shift latch moved one digit to the right by pressing the
register with tri-state outputs. The LCD ADV (digit advance) push button. The cursor
module interface is reduced to the already will move from the seconds (left-most) to
existing SPI bus plus four control lines (see the hundreds-of-nanoseconds (right-most)
Figure 3). The LCD’s contrast is controlled position as the ADV push button is depressed.
by potentiometer VR1. The LCD module is When the cursor is on the right-most digit, the
illuminated by LED backlights. R8 sets the next ADV depression will move the cursor to
current to the LED backlights. the left-most digit on the same line. Toggling
The PIC16F87’s I/O lines were also saved the Line Select switch will move the cursor to
by implementing a SPI 8-bit parallel input port the same digit position on the other line.
with two NAND gates and a Texas Instruments The value under the cursor can be
74HC165 8-bit parallel-input/serial-output incremented by pressing the INC push button.
shift register. Figure 4 shows the circuit. The Values wrap around from 9 to 0 without a
shift register’s parallel load occurs when the carry to the next higher digit. Whenever the
INC push button is depressed the output
waveform (OUT) changes to reflect the values
shown on the display. The other switches all
change the display but do not change the
output waveform. For example, a 1-ms pulse
repeated once a second would be set as 1 =
0001.0000 ms, 0 = 0999.0000 ms.
Photo 3a shows the initial display that
appears when the mode toggle is changed to
Square. This display shows that the period (P)
is 1 ms and the frequency (F) is 1,000 Hz.
The LCD cursor will be on the first digit of the
frequency value. The Line Select switch has
no effect in this mode. The ADV push button
functions the same way it does in the Pulse
mode.
Pressing the INC push button increments
the value under the cursor. Because the
Square mode produces a square wave (50%
duty factor) the minimum change in period
FIGURE 3
is 200 ns: 100 ns for Logic-1, and 100 ns for
The SPI-to-LCD module Logic-0. Due to the discrete step size, not
circuitcellar.com 25

every frequency value is attainable. Every


time the INC push button is depressed the
digital pulse generator will compute the
attainable frequency closest to the new
setting and update the counters and display
to the computed value. The counter values

FEATURES
that determine the output waveform are only
changed when the INC push button is pressed.
Changing from one mode to another does not
alter the output waveform. In fact, changing
modes from Pulse to Square is a convenient
way to see a waveform’s overall period and
pulse repetition frequency.
Consider the previous example of a 1-ms
pulse repeated once a second. In Pulse mode,
this would be set as 1 = 0001.0000 ms, 0
= 0999.0000 ms. Toggling to Square mode
would change the display to P = 01000.0000
ms, F = 0000001.00 Hz without changing the FIGURE 4
This SPI input port reads the front-panel switches.
output.
Host communication mode is entered
by connecting an RS-232 cable between
the pulse generator and a host computer’s
COM port. A terminal program must be
operating on the host to communicate
with the pulse generator. When the pulse
generator senses an RS-232 connection at J2
it tries to synchronize baud rates with the
host. The pulse generator waits to receive a
Return (Enter) character at 1,200 bps. If it
receives any other character (e.g., a return
at another baud rate) it doubles its own
baud rate and waits for another return at
the new baud rate. If it reaches 19,200 bps
without receiving a return it cycles back to
1,200 bps. To synchronize the digital pulse
generator with the host’s baud rate, you
simply press Return (Enter) repeatedly until
the digital pulse generator sends the menu
screen (see Figure 6).
Menu options are selected by typing the FIGURE 5
corresponding single number or character. The power supply circuitry
Any other entries will be ignored and the
menu will be displayed again. In the following
examples the text sent by the pulse generator
is italicized, the text entered by the user is
bold. Time values are entered in microseconds
or milliseconds. Microseconds are specified
by entering the number with a u or U suffix.
Milliseconds are specified with an m or M
suffix. Frequency values are entered in hertz
with an h or H suffix:

0 Set low (0) time—In this example, the


Logic-0 time is set to 9.25 ms. The output
waveform will not be changed until option 4
is selected.
?0
Low time = 9.25 m

1 Set high (1) time—In this example, the PHOTO 2


Logic-1 time is set to 750 µs. The output The pulse generator’s front panel
26 CIRCUIT CELLAR • AUGUST 2014 #289

frequency can be seen by selecting option


a)
3. The output waveform will not be changed
until option 4 is selected.
?2
Frequency = 2000 h
FEATURES

3 Show settings—This option enables you


to see the specified settings. The settings
shown here are internally consistent but are
not related to other examples shown in this
article.
?3
Low time = 10.0000 ms
b) High time = 0.2499 ms
Period = 10.2499 ms
Frequency = 97.56 Hz

4 Update counters—This option


simultaneously updates the Logic-1 and
Logic-0 counters—or as close to simultaneous
as is possible addressing two SPI chips.
?4 Ok

5 Store powerup settings—This option


writes the current Logic-0 and Logic-1 pulse
settings to the PIC16F87’s internal EEPROM.
When power is applied to the digital pulse
PHOTO 3 generator, it reads these values from the
a—In the square mode display, the P line is period and the F line is frequency. b—In the pulse mode display, EEPROM and uses them to initialize the
the 1 line is Logic-1 time and the 0 line is Logic-0 time. counters.
?5 Ok

waveform will not be changed until option 4 6 RC servo—This option configures the
is selected. output pulse train for control of a radio control
?1 (RC) servo. RC servos rotate in response
High time = 750 u to a variable pulse width signal. The pulse
width begins at 1.5 ms, which corresponds
2 Square wave—In this example, the to the center of rotation. The minimum and
specified frequency is 2 kHz. The pulse maximum pulse widths for this routine are
generator will compute the frequency 0.86 and 2.14 ms, respectively. The Logic-0
closest to the specified frequency. The actual or pulse spacing time is fixed at 28.5 ms.
Pressing the l or L key decreases the pulse
width causing the RC servo to rotate left.
Pressing the r or R key increases the pulse
PROJECT FILES PIC16F87 Microcontroller width causing the RC servo to rotate right.
The decrease/increase step size is 10 ms.
Microchip Technology, Inc. | www.microchip.com
Pressing the escape key returns the Host
menu screen. In the example shown here the
78S40 Universal switching regulator L key was pressed two times:
subsystem ?5
Motorola/ON Semiconductor | www.onsemi.com Enter L, R, ESCape to abort.
1.50
1.49
circuitcellar.com/ccmaterials
74HC4094 Shift latch register 1.48
STmicroelectronics | www.st.com
X Exit—This option terminates the Host
SOURCES Communication mode and returns to the
74123 Rotary switch and 74HC165 shift
LS7366R 32-bit Quadrature Manual Control mode.
register
counter ?x
Texas Instruments, Inc. | www.ti.com Disconnect RS-232 cable.
LSI Computer Systems, Inc. |
C Command line—The command line
www.lsicsi.com
interface can be used in two ways. First, it
circuitcellar.com 27

ABOUT THE AUTHOR


Brian Beard (bbbeard73@verizon.net) was just starting out as an electrical engineer when the first microprocessors were devel-
oped. He has been an electronics designer and an Assembly-level programmer ever since. Brian has worked for the government,
in industry, and in academia. Outside his full-time job near Silver Spring, MD, he designs project kits (www.lucidtechnologies.
info) and consults on programming and microcontroller systems.

FEATURES
can be used from a terminal program for
FIGURE 6
manual input without displaying the entire Digital Pulse Generator, Firmware 2.03
These are the choices in the menu
main menu. Second, it can function as the 0 Set low (0) time
screen sent by the digital pulse
control interface for a custom computer 1 Set high (1) time generator.
program on the host. 2 Square wave
Each command is specified by a single 3 Show settings
ASCII command character sent to the pulse 4 Update counters
generator following the > prompt. Command 5 Store powerup settings
characters may be lower or upper case, but are 6 RC servo
always echoed as upper case. All characters C Command line
sent to the pulse generator, except (CR), X Exit
are echoed back to the host. For commands ?
that require data (e.g., setting pulse times
or frequency), the data must follow the
command character and be terminated by The digital pulse generator’s accuracy,
a (CR). The acceptable formats for entry stability, and programmability make it ideal
of pulse time and frequency are identical to to simulate timing and stimulus signals when
those used with the main menu. prototyping new projects. The digital pulse
If the character sent to the pulse generator generator program is available on Circuit
following the prompt is not recognized as Cellar’s FTP site.
a valid command character, a (NAK)(CR)
(LF)> sequence wilfdl be sent to the host. If
an error is found in the numeric data following
a command, an error message will be sent
followed by a (NAK)(CR)(LF)> sequence. TRACE 32 ®
The command is ignored whenever a (NAK)
is returned instead of an (ACK).

PULSE GENERATOR FIRMWARE


I used the PIC Assembly language to
write the pulse generator’s firmware. Two
parts of the program were particularly
challenging. The first was parsing the input
string variations possible for milliseconds,
microseconds, and hertz. The second was
creating all the 32-bit math routines—
addition, subtraction, multiplication, division,
BCD-to-binary, and binary-to-BCD—needed
for display and to set the LS7366R counters.

AN IDEAL SOLUTION
The pulse generator has proven to be a
great addition to my electronics workbench. I
used variable RC time constants to set my old
pulse generator’s timing—switches selected
the capacitance and potentiometers set the
resistance. Whenever I needed a precise pulse
train I had to hook up an oscilloscope to
measure the pulse generator’s output, and
then it would drift over time! Thanks to the
totally digital design of the digital pulse
generator I no longer need an oscilloscope to
confirm its output and its settings don’t drift.

advertisement_arm-overview.indd 1 03.06.2014 11:48:51


28 CIRCUIT CELLAR • AUGUST 2014 #289

Personal Solar Power Setup (Part 2)


Battery Charge Control
FEATURES

The first article in this series introduced a solar power


system that provides reliable backup and reduces utility
power usage. This article focuses on the battery charge
control and options for easily sharing the load between
the utility and solar power.

By Steve Hendrix (US)

T he first part of this article series discussed


the solar panel characteristics, mounting
details, batteries, and interconnect wiring for
PWM controllers. During the bulk charge
phase, they simply connect the panels directly
to the batteries. A lead-acid battery acts like a
my solar power system (see Photo 1). This constant-voltage device. Within limits, it holds
article will provide more detail about charge a given voltage at its terminals. On the other
control, conversion to useful power, and safely hand, the panels follow a curve that looks
sharing the load between the commercial like what is shown in Figure 2. If you simply
utility power and solar power. Figure 1 shows connect a panel directly to a battery, the panel
an overall block diagram of a typical solar voltage will be forced to match the battery
photovoltaic (PV) system for reference. Part voltage and the current at that point on the
1 covered most of the top half of this figure; curve will be delivered to the battery. As the
now I’ll delve deeper into charge control and battery voltage rises, the panel walks up the
the bottom half of the figure. curve and the current gradually reduces.
When the voltage reaches the setpoint, the
BATTERY CHARGING charge controller goes into PWM, pulsing the
PHOTO 1 The charge controller can actually current on and off to hold the battery at the
Solar panels mounted on a south- dominate the overall system efficiency. A soak charge setpoint. The effect is to move
facing roof are shown. Note the 4“ carefully designed charge controller can the average panel current down to whatever
gap under the bottom of each. This
efficiently match various combinations of will maintain the desired battery voltage
enables rainwater, leaf litter, and balls
PV panels and batteries. A simple charge while raising the panel voltage.
to pass under the panels rather than
accumulating. The upper brackets on
controller combined with mismatched panels This particular panel’s maximum power
each panel are sized to hold the panels and batteries can result in a lot of wasted point (MPP) is about 16 V and 11.5 A, yielding
at 50º to horizontal. The rows are power and excess heat. 184 W. When you begin charging with the
spaced to avoid shading one another The commercial charge controllers I battery down to around 11 V, you pull the
even during the winter solstice. purchased for my 12-V system are very simple panel to 11 V and 12.7 A, yielding 140 W.
circuitcellar.com 29

FIGURE 1
My personal solar power system
includes photovoltaic (PV) panels,
Photovoltaic Interconnect/ Interconnect/
Charge control Batteries interconnect/protection, batteries,
(PV) panels protection protection
wiring, and power.

FEATURES
Utility power Interconnect/ Interconnect/ Household wiring
Inverter
protection protection

Thus, you give away almost 25% of the controlled. Figure 3 shows a basic step-down
possible power due to the mismatch. In PWM architecture. Some specific numbers will help
mode, depending on the required current, make the discussion more concrete. Suppose
you similarly fall off well away from optimum you have 20 V coming in with 1 A available and
efficiency. This system works, but the loss of you wish to turn that into 10 V at 2 A. Switch
efficiency just doesn’t sit right with me. S1 is turned on for approximately 1 µs to get
I have a lot of experience designing the current flowing. Then it turns off for 1 µs
switch-mode power supplies, especially before repeating the cycle. Current during
buck converters. Such converters efficiently the “on” time is 2 A, but the average is 1 A
trade voltage for current, or vice-versa, so it due to the 50% duty cycle. But wait—current
seemed a natural fit here. I’ll provide a quick cannot change instantly, so the current must
review to describe the basic operation. keep flowing. Two amps of current × the
Some think of a switch-mode converter (theoretically) infinite resistance of the switch
in terms of impedance matching as in RF; yields a whole bunch of volts.
another view is to see it as a low-pass filter for In practice, this would produce arcing
a PWM stream. Both views are useful at times, or destroy the switch. Adding D1 enables
but I prefer to think of it in simple mechanical the current to be pulled from ground during
terms. An inductor acts like a “flywheel” for the off time. During the 50% off time, 2 A is
current. It produces “inertia” in current flow. drawn through D1. C1 smooths out the current
Current cannot change quickly in an inductor, bursts so the solar panels see a relatively
so you can apply pulses of power to “spin up” steady load. Thus the inductor supplies 2 A
the flywheel and the current flow will remain to the load continuously at 10 V, while the
reasonably constant. supply sees an average load of 1 A at 20 V. C2
The basic architecture can step voltage smoothes out any voltage alterations caused
either up or down, depending on how it’s by changes in the load current relative to

Photovoltaic (PV) panel V-I Curve

25 V

20 V

200 W
50 W
100 W 150 W
15 V

10 V

FIGURE 2
The voltage-current curve for a 200-W
panel is shown. Note the open circuit
5V
(0-A) voltage is about 21 V, the short
circuit (0-V) current is about 13 A, and
the maximum power is near 11.5 A
and 16 V. The concave curve family
0V
0A 1A 2A 3A 4A 5A 6A 7A 8A 9A 10 A 11 A 12 A 13 A 14 A marks lines of constant power at
50–200 W.
30 CIRCUIT CELLAR • AUGUST 2014 #289

dithering about that. If the movement


decreased the power to the batteries, I moved
back to the previous operating point.
However, the real world intruded rudely
upon my grand plans. The inductor must
conduct the full battery current essentially
FEATURES

continuously, so the wire in its windings must


be pretty heavy. At the same time, with a
large voltage difference between input and
output, a high inductance is needed to keep
FIGURE 3 the current running smoothly, which requires
A simplified switch-mode controller uses an inductor as a “flywheel” and switches the input power at less a lot of turns. The required inductor becomes
than 100% of the duty cycle. The result is that the output current is higher than the average input current pretty big and expensive.
while the voltage is lower. Modifications of the switching and control arrangements can result in higher, The required inductance can be reduced by
lower, or even opposite sign output voltages. increasing the switching frequency. Then the
non-ideal characteristics of switch (S1) rear
the inductor current. The feedback path in up. The best switch here is a big field-effect
the diagram adjusts the switching control to transistor (FET). The FET must be physically
maintain a particular desired voltage. big to handle the amount of current and to
None of these components are ideal, so dissipate the resulting heat. The physical size
there are losses. However, efficiencies of 95% increases the amount of stored charge that
or better are feasible with careful design and must be pushed into or out of the gate to
good components. In particular, D1 can be switch from on to off. Regardless of the drive
replaced with a switch for better efficiency arrangement, it takes some nonzero time to
but more complexity. You can modify the pump charge into or out of the gate. During
switching and control arrangements to this transition time, the FET must spend a
produce a higher voltage at a lower current measurable amount of time in an unsaturated
than the input or a negative output voltage. state This “partially on” period results in
Converters are available as ICs, including considerable heat in the FET.
S1 as an internal transistor. For higher To see why, consider the “off” case.
power, controller chips enable you to add a Suppose you have a panel with a 60-V open
big external transistor, often with a heatsink, circuit voltage and a 10-A short circuit
so you can control substantial amounts of current. With the switch off, the current is
current. I considered using such a chip. zero (60 V × 0 A = 0 W). Now consider the
The control logic in these chips is designed “on” case. Real FETs come remarkably close
to maintain a constant output voltage, to the zero resistance ideal. The ones I chose
without regard to input parameters. Instead, claim a maximum 65 mΩ when saturated.
you want to control the conversion to hold the Passing 10 A, 6.5 W of heat is generated, but
solar panel at the knee of its curve (a.k.a., the only during the “on” part of the cycle. With
MPP). This feature is commonly known as MPP an appropriate heatsink, they are rated for
tracking (MPPT) in many available controllers. nearly 300 W, so there appears to be plenty
This type of control can be done in of margin.
firmware. I used the PWM hardware built But wait—let’s see what happens during
into a Microchip Technology PIC18F97J60 switching. Maximum power dissipation occurs
microcontroller to attempt to build this kind of at the “halfway” point of the switching, when
switch-mode controller. My grand ambitions there is 150 W (i.e., 30 V x 5 A). With a basic
were a unit with four channels, each of which driver circuit, you can get through this linear
accepts up to 15 A between 12 and 100 V and zone in around 100 µs. So this is a trivial
converts that efficiently to charge 12-, 24-, amount of energy—if you only switch once.
or 48-V batteries. Control logic would sense However, if you want to switch at 5 kHz, you
voltage and current on the solar panel side actually end up spending most of your time in
as well as on the battery side, expanding the the linear region, giving away nearly 150 W
feedback path shown in Figure 3. as heat that must be dissipated, and not as
Most of the time, I want to pull maximum power going into the batteries.
available power from the solar panels. Control Here is the fundamental tug-of-war
for each channel is separate and updated in between the inductor, which is pulling
round-robin fashion in the firmware. I simply for a faster switching frequency and
dither the duty cycle while monitoring the the switch, which is pulling for a slower
power provided by the panels. When a dither switching frequency. My solution ultimately
in one direction (increase or decrease in duty compromised: I used three inductors in
cycle) produced a power gain in the battery, series to get sufficient inductance along with
I kept the new operating point and continued a beefed-up driver circuit to get through the
EXPLORE
C-RUN FOR ARM
Runtime Analysis Simplified

C-RUN is a high-performance runtime analysis add-on


product, fully integrated with world-leading
C/C++ compiler and debugger tool suite
IAR Embedded Workbench.

C-RUN performs runtime analysis by monitoring application


execution directly within the development environment.
The tight integration with IAR Embedded Workbench
improves development workflow and provides each developer
with access to runtime analysis that is easy-to-use.

www.iar.com/crun
32 CIRCUIT CELLAR • AUGUST 2014 #289

linear region more quickly. I also reduced So far the webpages are display-only,
the allowable difference between the input although I hope to have a password-protected
and the output voltage to reduce the cost of ability to adjust configuration via a webpage
building the controller. soon. For the time being, there is also a Telnet
One hazard is often overlooked when interface that enables me to not only adjust
designing a switch-mode controller for low all configurable items, but also to capture a
FEATURES

current and voltage, but is nontrivial at running text file with historical data for offline
these power levels. Being the paranoid sort, analysis. I hope to add live graphs of current
I had a circuit breaker between the controller and voltage and so forth in the future.
output and the battery. My intent was to be In summary of charging, my goal was to
able to feed 20 A per channel to the battery, have the solar panels operate at—or at least
so I installed 20-A circuit breakers. I ran close—to their MPP while efficiently delivering
out of those and installed a 15-A breaker the resulting energy into the batteries.
on one channel knowing that in my early However, I also wanted the charge controller
experiments I would only achieve about 10 A to limit the delivered power to prevent
anyway. However, one sunny day I was offsite overcharging. For typical lead-acid batteries,
but monitoring the controller via its Ethernet this requires three phases as described in
interface from a work site. The controller was Part 1 of this article series: a bulk charge,
working superbly! I was seeing the current where all the current that can be mustered
ramp up to nearly 20 A per channel as the sun is delivered, terminating when the battery
moved into a good position. Then suddenly voltage rises to a predetermined level; a soak
there was no response. charge, where the battery is held at that
Later investigation showed that the circuit voltage; and finally a float charge, where the
breaker had tripped. Remember that the battery is held at some slightly lower voltage
inductor will not permit current to change while delivering whatever current is required
instantaneously. Question: What voltage do by other loads.
you get with 20 A flowing through the now- My system has seen three different types
open circuit breaker? Answer: A whole bunch! of controllers. The 12-V system uses a simple
Although I had foreseen this scenario and PWM architecture to load the panels down to
provided a surge suppressor on the output, the battery voltage and to reduce current as
it was not up to the task. The resulting needed. The switch-mode controller is more
high voltage went pretty much anywhere it elaborate and runs the panels at maximum
wanted and destroyed the board. Any further power while delivering just the right voltage to
experiments in this direction will include maximize the battery’s charge rate. The most
much more substantial surge protection! recent controller could be considered a very
My next controller iteration was less slow PWM controller. It was also designed as a
ambitious, with eight channels but no part of the overall system, wherein the panels
attempt at voltage conversion. Simple on/off are inherently matched to the batteries being
switching works to track the correct charging charged.
ABOUT THE AUTHOR voltages, but I have retained the ability to
Engineering consultant monitor operation via the Ethernet. If you INVERTER
are interested, e-mail me and I can provide All that work up to now has resulted in a
Steve Hendrix (steve
access to the controller on the Internet. As I lot of energy stored in batteries. So how do
hx@hxengineering.com),
wrote this article, I was typing offsite, but still you get it out and make it useful? If you’re
CFIAI, lives with his wife
monitoring the bright autumn sun via Internet. in a boat or motor home, you may have 12-V
Kathy and five children
The controller I designed and am currently loads and can use it directly. As in Part 1, I
near Cuyahoga Valley using is on a 3“ x 5” PCB with eight channels cautioned you to make any connections to
National Park in Ohio that can handle up to 100 V in and out and up batteries through an appropriate protective
and runs Hx Engineer- to 22 A per channel. A Microchip Technology device. Even a quick accidental touch on a
ing, LLC. Steve has de- PIC18F97J60 microcontroller is at the heart wire that can deliver a few thousand amps
signed software and of the controller. It provides an Ethernet can ruin your day.
hardware for a wide interface, 16 channels of analog inputs, and In the home, 12-V loads are less common.
range of projects: Space a multitude of other I/O. Each channel is Back when high-brightness LEDs first came
Station Freedom, vibra- individually programmable as to the battery out, I designed a PCB to use 12 V and run five
tion analysis, IEEE-488 type and voltage (e.g., lead-acid 12 V, lead- or six LEDs at a constant current. Today you
bus hardware, biomed- acid 48 V, etc.). I modified a sample application can just go to your local electronics store and
ical sensing, industrial provided by Microchip Technology to yield an purchase them, of course. I installed them
instrumentation, photo- HTML page showing each channel’s voltage, at the top and bottom of the stairs, outside
therapy equipment, and current, and charging status. I also built in the the bedrooms, outside the bathrooms, and
safety gear for facility ability to eavesdrop on an RS-485 or RS-232 so forth. Those have been off only twice in
personnel. line so I could pick up and display information the past dozen years or so, when I made
from my inverter, which I will describe later. upgrades to the system. And I’m currently
Easy and Quickly Mountable on 68-pin IC socket
Stamp size FPGA/CPLD Module PLCC68 Series
PLCC68 series is a very small size FPGA & CPLD Module designed to be
used with 68-pin IC socket. It's very convenient to use on universal
boards.
PLCC68 series requires only single 3.3V power supply.
The pin assignments are the same for all series. I/O power supplies are
separated in two banks (A and B, 25 I/Os each).
50 I/Os Very small size (25.3 x 25.3 [mm])
(External clock inputs are available) Separated power supply: Core, I/O
3.3V single power supply operation JTAG Signals (TCK, TMS, TDI, TDO)
Voltage converters for auxiliary All series have the same pin assignment
power supply Mountable on IC socket
[USAGE EXAMPLE]

ALTERA Series
Cyclone V PLCC68 FPGA Module Cyclone V PLCC68 FPGA Module Cyclone III PLCC68 FPGA Module
AP68-06 Series AP68-06Z Series AP68-04 Series
FPGA : 5CEBA2U15C8N FPGA : 5CEBA2U15C8N FPGA : EP3C25U256C8N
5CEBA4U15C8N 5CEBA4U15C8N 3.3V single power supply operation
FRAM 3.3V single power supply operation On-board oscillator, 50MHz
3.3 V single power supply operation On-board oscillator, 50MHz Configuration Device
On-board oscillator, 50MHz Configuration Device 8 Layers PCB
Configuration Device 8 Layers PCB Board size : 25.3 x 25.3[mm]
8 Layer PCB Board size : 25.3 x 25.3[mm] Mountable on 68pin IC socket
Mountable on 68pin IC socket RoHS compliant Mountable on 68pin IC socket RoHS compliant RoHS compliant

Cyclone III PLCC68 FPGA Module MAX V PLCC68 CPLD Module MAX II PLCC68 CPLD Module
AP68-03 Series AP68-02 Series AP68-01 Series
FPGA : EP3C10U256C8N CPLD : 5M570ZF256C5N CPLD : EPM240F100C5N
3.3V single power supply operation 3.3V single power supply operation EPM570F100C5N
On-board oscillator, 50MHz Board size : 25.3 x 25.3[mm] 3.3V single power supply operation
Configuration Device Mountable on 68pin IC socket Board size : 25.3 x 25.3[mm]
8 Layers PCB 4 Layers PCB Mountable on 68pin IC socket
Board size : 25.3 x 25.3[mm] 4 Layers PCB
Mountable on 68pin IC socket
RoHS compliant RoHS compliant RoHS compliant

XILINX Series
Spartan-6 PLCC68 FPGA Module Spartan-3AN PLCC68 FPGA Module Spartan-6 PLCC68 FPGA Module
XP68-03 Series XP68-02 Series XP68-01 Series
FPGA : XC6SLX45-2CSG324C FPGA : XC3S200AN-4FTG256C FPGA : XC6SLX16-2CSG225C
3.3V single power supply operation 3.3V single power supply operation 3.3V single power supply operation
on-board oscillator, 50MHz on-board oscillator, 50MHz on-board oscillator, 50MHz
Configuration Device Board size : 25.3 x 25.3[mm] Configuration Device
Board size : 25.3 x 25.3[mm] 6 Layers PCB Board size : 25.3 x 25.3[mm]
6 Layers PCB Mountable on 68pin IC socket 6 Layers PCB
Mountable on 68pin IC socket Mountable on 68pin IC socket
RoHS compliant RoHS compliant RoHS compliant

We also have many other products Universal board for AP/ XP PLCC68 Module
All stocked items are ready to be JTAG-BUFFER Circuit / JTAG Connector
shipped immediately ZKB-092 Power input :
DC5V/2.1[mm] Jack / Terminal Block
RoHS compliant 3.3V Power Circuit
Technical documents are available for free before purchasing Power Switch / Power LED
Board size : 4.528"x 6.102" (115 x 155 mm)

See all our products, A/D D/A conversion board,


HuMANDATA LTD. boards with USB chip from FTDI and accessories at :
TEL:+81-72-620-2002(Japanese)FAX:+81-72-620-2003(Japanese/English)
E-Mail : s2@hdl.co.jp URL : http://www2.hdl.co.jp/en/ www.hdl.co.jp/CC/
34 CIRCUIT CELLAR • AUGUST 2014 #289

building a set of LED-based window candles sinusoidal output. For example, a DC motor
to run from 12 V. I want to mount them so could turn an alternator to produce AC. As
I can leave them in place year-round in the a bonus, it could provide complete galvanic
windows. They too will run directly from 12 V, isolation between the DC and the AC sides.
although I will have a switch for them. However, such a scheme has many drawbacks
What about common household appliances? (e.g., wear of moving parts, maintenance
FEATURES

My goals were to “go green” by taking some requirements, and noise), so it is typically
loads off the grid and to have reliable backup used only in specialized situations.
power to essential loads for outages. I grew A commercial inverter usually takes in 12,
up in a house with a sump pump and that 24, or 48 VDC. Thus the desired output voltage
was always the first “emergency” when the goes above and below the input voltage and
power went out; all the more so because it half the time is opposite polarity. Adding a few
was usually during a storm with torrential more switches to Figure 3, along with more
rains. Thus, when we built our current house, complex control logic, enables this topology
I insisted on downhill footer drains (i.e., no to produce a voltage that is above, below, or
sump pump!) of opposite polarity to the input. You can then
For an outage of more than 1 or 2 h, my command a target voltage that tracks the
next priorities were the refrigerator and deep desired waveform. With many small steps per
freezer, which require a solid 120 VAC at 60 Hz cycle, it’s relatively easy to filter the “jaggies”
and a clean sine wave. (Note: My supplemental and produce a nice clean sinusoid that should
write up on “Experiences with Inverters” is make any AC device happy. This waveform
available on Circuit Cellar’s FTP site.) comes with no moving parts.
The least expensive inverters, which are
typically rated for only a few hundred watts, MIXING COMMERCIAL AND
produce a square wave at 60 Hz. They use a SOLAR POWER
standard up-switcher to generate 120 VDC You must pay attention to safety issues
and then alternate its polarity to produce a when mixing solar power and commercial
60-Hz square wave. This output works, but it power under one roof. Building and electrical
is rich in harmonic content. The sharp edges codes vary from place to place, so please do
and harmonic content tend to make motors your own due diligence in investigating the
buzz, generate excessive heat, and generally local rules or taking advice from a local expert.
sound unhappy. You probably don’t want to try to power your
Next up were the “modified sine wave” entire neighborhood. More importantly, if
inverters. These were only slightly better, utility power goes out, that poor utility worker
creating something that more closely swaying on the pole up there in the driving
approximates a sine wave by producing a rain has every reason to believe that there’s
higher DC voltage, but switching it positive, no power there. You do not want to create a
then off, then negative, then off, and then safety issue for the utility worker!
starting over. The result looks like a square The simplest way to guarantee separation
wave with an extra step every time it passes of the two systems is physical. You can run new
through zero. It is better and relatively wiring for 120-/240-VAC loads or you can pull
inexpensive, but it is still not suitable for most a wire out of the entrance panel and move the
motorized devices. entire existing circuit to a new panel installed
Finally there are “true sine wave” inverters. expressly for solar power. This approach is
These are more complicated (and expensive), clean and safe. It has the drawback of being
but produce a waveform very close to a perfect a bit more work to transfer that circuit back
sinusoid and essentially indistinguishable to commercial power in case of a failure
from good-quality commercial power. There anywhere in your solar power setup.
are several ways to convert a DC input to a My approach was a little more elaborate.
I ran a couple of separate circuits that power
certain specific loads and installed a transfer
switch per circuit that enables me to choose
PROJECT FILES SOURCES solar or utility power for each circuit at the
MS-PAE Series inverter/charger and ME-ARC flip of a switch in the utility room. Whatever
remote control transfer switch you use, it must meet three
specific criteria, in addition to anything else
Magnum Energy, Inc. | www.magnumenergy.
required for your local building codes: First,
com
it must be rated for the voltage being used.
Second, it must be rated for the load current
PIC18F97J60 Microcontroller or higher. Third, and most importantly, it
Microchip Technology, Inc. | www.microchip. must be the break-before-make type. As
circuitcellar.com/ccmaterials
com the switch is thrown, it must break one
circuitcellar.com 35

contact before it connects the other. There switch back to battery power when enough
must never be a connection, even during is available. I have it wired into its own 120-
transition, between the switch’s two arms. /240-VAC 30-A circuit and I’ve programmed it
I personally use an ohmmeter to check this to use up to 25 A. If the battery voltage drops
before installing a given switch. Also note below as 46 V, it cuts over to utility power,
that electrical codes in most places forbid drawing 25 A and using anything not needed

FEATURES
any device that breaks the neutral conductor, for the loads to recharge the batteries.
which must run continuously at all times back When the batteries rise to 50 V through any
to the entrance panel. You can purchase an combination of solar and utility power, it
automatic transfer box that will automatically returns to normal inverter operation.
switch over to backup power, but with that For the worst-case scenario of a winter
approach I couldn’t tinker with it! storm that knocks out utility power for several
You can also purchase an inverter rated days while burying the solar panels under a
for “grid-tie” operation intended to be wired couple feet of snow, I still have that generator
directly into your entire home’s wiring and it in the garage. It will feed into the inverter
will synchronize itself to the grid. Whatever as “utility” power and can power essential
power is produced by the inverter is subtracted loads. It will continuously run at an efficient
from that coming from utility power. If your full-power load, recharging the batteries as
load is light and the inverter is producing more power is available. Therefore, I can have
than you are using, it will feed power onto the continuous power to the essential loads while
grid, in theory running your meter backward. running the generator for only an hour or two
You may need to make special arrangements per day, which greatly reduces noise, odor,
with your electric company for this type of and fuel consumption.
operation, and you may or may not be able This unit also has an optional Magnum
to actually have the power company pay you Energy ME-ARC remote control head that
for electricity, but you can certainly reduce came with enough cable to just comfortably
your own electric bill this way. A significant reach my desk, so I can monitor its operation
drawback of this type, for my purposes, is and make adjustments without even getting
that the inverter automatically shuts off upon up. The remote head uses a standard RS-
loss of utility power. It must do so to meet the 485 protocol. I contacted Magnum Energy
safety requirements (remember that utility with little hope of actually getting any
worker out there climbing the pole?). This in information on a proprietary protocol. Much
turn means the inverter cannot supply backup to my surprise, the company responded with
power during an outage. Some models may a full technical document I was able to use.
permit some sort of override, but I was not My charge controller is designed to eavesdrop
able to find one. on the RS-485 protocol and extract complete
My big Magnum Energy MS-PAE Series information on battery current and voltage,
48-V inverter has several clever features to load current and voltage, and utility current
simplify the entire issue of utility power vs and voltage, as well as several internal
solar. Lest I sound like an advertisement here, temperatures. My charge controller then
I will point out that I have no relationship with summarizes that information and presents it
the manufacturer other than as a satisfied as part of a webpage.
customer! This inverter has served me well,
living up to its full ratings on a few occasions BUILD IT YOURSELF
when I accidentally applied more simultaneous This two-part article has covered all
loads than I intended. It handled everything aspects of implementing a practical solar PV
gracefully without complaint, even when the power system for a home or small business.
air conditioner, refrigerator, and deep freezer Length restrictions have limited the amount
were already running when the well pump of detail I could include, but I hope you
kicked on with its big surge load. now know what questions to ask yourself
In addition to the full 120-/240-VAC output, and have some considerations for potential
this inverter also features a 120-/240-VAC vendors as you contemplate building your
input. Upon defined conditions, the inverter own system.
can switch from using the 48-VDC battery I’m often asked how much this setup
power to using utility or generator power. The actually reduces my electric bill. I always
switch can be conditioned upon either time answer “not enough to pay for the system for
or battery voltage. When it switches to utility a very long time,” at today’s utility rates.
power, it uses a relay to feed utility power However rates are moving inexorably upward
directly through to the loads with negligible and I can feel that I’m doing something to
losses. In addition, it can use whatever reduce fossil fuel usage. Besides, when the
power is left over, up to a predefined limit, to power goes off for an extended time, the
recharge the batteries and can automatically system will pay for itself very quickly!
36 CIRCUIT CELLAR • AUGUST 2014 #289

Hands-On Electrocardiography
FEATURES

This microcontroller-based electrocardiography (ECG) system enables you to view your heart’s
waveform on a mini TV. The system includes a circuit, hardware, and a voltage limiter.

By Sean Hubber and Crystal Lu (US)

W e designed
electrocardiography
and
(ECG)
built an
system
that extracted the heart’s electrical output.
amplification could be made to produce a
readable ECG signal. The first stage is the
conditioning stage, which ensures user safety
This hardware combined with a MathWorks through DC isolation by initially connecting
MATLAB function can be used to accurately the dry electrode signals directly to capacitors
measure a person’s heart rate. From this and resistors. The capacitors help with DC
starting point, we used an Arduino Due isolation and provide a DC offset correction
microcontroller board to develop a battery- while the resistors limit the current passing
operated packaged product that provides through. This input-conditioning stage is
you with a safe and easy way to view your followed by amplification and filtering that
heart’s waveform on a mini-TV screen (see yields an output with a high signal-to-noise
Photo 1). The project was done as part of ratio (SNR). After the circuit block, the signal
Cornell University’s Electrical and Computer is used by MATLAB and voltage limiter blocks.
Engineering 5030 Bioinstrumentation course. Directly after DC isolation, the signal is sent
This article details the underlying circuitry, into a Texas Instruments INA116 differential
the MATLAB function we used, and how the amplifier and, with a 1-kΩ RG value, an initial
Arduino and mini-TV were used to display gain of 51 is obtained. The INA116 has a
the waveform. Figure 1 shows the overall low bias current, which permits the high-
system’s main components. impedance signal source. The differential
amplifier also utilizes a feedback loop, which
THE CIRCUIT prevents it from saturating.
Figure 2 and Photo 2 show the system’s Following the differentiation stage, the
main circuit, which is separated into several signal is passed through multiple filters and
stages to ensure that retrieving the signal receives additional amplification. The first is
would be user-safe and that sufficient a low-pass filter with an approximately 16-Hz
circuitcellar.com 37

cutoff frequency. This filter is primarily used


to eliminate 60-Hz noise. The second filter is
a high-pass filter with an approximately 0.5-
Hz cutoff frequency. This filter is mostly used
to eliminate DC offset. The total amplification
at this stage is 10. Since the noise was

FEATURES
significantly reduced and the SNR was large,
this amplification produced a very strong
and clear signal. With these stages done, the
signal was then strong enough to be digitally
analyzed. The signal could then travel to both
the MATLAB and voltage limiter blocks.

MATLAB
To use MATLAB on the signal produced by
the circuit you must first connect the device to
the computer. The packaged product contains
a phone jack that is connected to the circuit
block’s output. We used this jack to feed
the signal to the computer using a National
Instruments NI USB-6008/6009 USB device.
Once the device is connected the MATLAB
program can be used to analyze the signal.
The program starts by running a few
initialization steps before entering the data PHOTO 1
reading and display section. These initialization The black box contains the circuit and microcontroller. The mini-TV is on top, the bars on the sides are used
steps include initializing variables used in the to hold it and read the hand voltage. The power switch is on the front along with the output jack.
program, defining the input device, setting
up the GUI, and initializing the plots and data
collection.
Most of the variables are set to values
that produce the best results, while others User’s
Circuit
Voltage
Arduino Due
hands limiter
are just initialized to 0 or empty vectors. It is
important to note that the bpmstaticprev
(1/s between the previous two beats) and
bpmstring (location in time of all previous MATLAB
Mini-TV
display
beats) variables are initialized to 80. This tells
the program that initially heart rates near 80
are reasonable. If the subject has a heart rate
much less than or much greater than 80, the
program will readjust accordingly. FIGURE 1
Once the GUI is initialized, the plots of the The electrocardiography (ECG) system includes a circuit, an Arduino Due microcontroller board, a mini-TV
ECG waveform, the Pan-Tompkins plot, and display, MATLAB programming language, and a voltage limiter.

FIGURE 2
This schematic shows the conditioning
stage, the differential amplifier, and
the filtering stages.
38 CIRCUIT CELLAR • AUGUST 2014 #289

the first plot. After this, the program begins


collecting and displaying data and results.
Until the user presses the Quit button, the
program continuously loops through a while
loop collecting and displaying data.
There are several important steps in the
FEATURES

loop. The first step is sampling the data from


the input device. Once this sample is captured
it is placed at the end of the vector of values
to be displayed. This vector is then shifted
to the left, dropping the number of values
equal to the size of the samples that were at
the front. The vectorized signal then passes
through a low- and a high-pass filter. These
filters’ cutoff frequencies can be set in the
GUI. The filtering process produces transients,
which are removed so they do not interfere
with beats per minute (BPM) calculations.
Finally, the vector is multiplied by 10 times
the absolute value of itself, which is a manual
amplification. This amplification makes the
signal more visible on the plot, which makes
it easier to do threshold adjustments.
To determine the location in time of the
beats, the program takes the processed signal
and runs the Pan-Tompkins algorithm on it.
This requires two simple steps. The first step
is to square the signal so it consists of only
positive values. The second step is to convolve
it with a rectangle. The result of this process
is a much smoother waveform that can be
used to determine each of the heart beats’
locations. The user sets the threshold to find
each heart beat’s rising edge. It is important
that this threshold is high enough so that only
the rising edges of real heart beats will cross
it, but low enough so that “weaker” beats will
still reach it. Once the heart beats’ locations
were determined, we ran them through our
PHOTO 2 the threshold line are initialized. The Pan- heart rate calculating algorithm to determine
The circuit block was built on a board Tompkins plot is a processed version of the the heart rate in BPM.
designed in ExpressPCB.
original signal that makes it much easier to The heart rate calculating algorithm was
obtain a threshold. In the last step before by far the most difficult piece of the program
the data collection and the display begin, the to write. The algorithm was run only once
program begins continuously sampling the every 0.5 s or every fifth time through the
input device. The program initially pauses for while loop. The first step was to compute
1 s so enough data can be collected to build bpmstatic from the period of the two most

ABOUT THE AUTHORS


Sean Hubber (sjh234@cornell.edu) is from Missoula, MT. He studied Electrical and Computer En-
gineering at Cornell University and graduated in 2014. In Septemeber 2014 he plans to begin a
career in computer science as a software developer with Epic Systems in Madison, WI.

Crystal Lu (csl84@cornell.edu) graduated from Cornell University with an ME in Systems Engi-


neering (2014) and a BS in Electrical and Computer Engineering (2013). She works at Orbital
Sciences Corporation in Dulles, VA, as a systems engineer in the Fault Detection, Isolation, and
Recovery group for the Cargo Resupply Mission. Her interests include satellite systems and con-
sumer electronics.
Get ready for

Buy now
and
upgrade for free!

Valid for new license purchases only.


Terms & Conditions: www.cadsoftusa.com/conditions-freeupgrade

w w w. c a ds o f t u s a . co m
40 CIRCUIT CELLAR • AUGUST 2014 #289

recent beats. Once this was determined,


a) it was compared to the most recent valid
heart rate calculation, which was stored as
bpmstring(end). If it was near enough to
this value (heart rates do not change rapidly)
then it was considered valid and added to the
FEATURES

bpmstring vector, which contains all “valid”


heart rate readings. If the new bpmstatic
value was not close enough to the previous
value then the last value in bpmstring was
taken as the heart rate and added back to the
bpmstring vector. Finally, if the BPM reading
was outside the range [30,180], it was tossed.
Once a “valid” heart rate was determined
and added to the bpmstring vector, the
heart rate’s output value was calculated by
averaging the last 20 values in bpmstring.
The number of values used can be increased
to provide a more stable reading or decreased
to produce a reading more responsive to
rapid heart rate changes. Finally, the heart
rate reading is displayed on the GUI.
b) Once the heart rate has been determined,
the program plots the updated versions of the
ECG waveform, the Pan-Tompkins waveform,
and the threshold waveform. The user can
suppress this update by pressing the Pause
button. The real-time display can be resumed
by pressing the Pause button again. The
program then updates the current time
(rounded to the nearest second) during which
the program has been running.
The filter adjustments built into the GUI
enable the user to customize the filter cutoffs.
Photo 3a shows the MATLAB display with no
filter adjustment. Photo 3b shows the signal
from the same person after adjusting the
filters.
Finally, the index is increased by the size
of the sample so timekeeping is consistent.
There is a pause so each loop takes exactly
100 ms (this value is determined by the
realtime variable, which also determines
PHOTO 3
the sample size). The program will continue
a—This is the MathWorks’s MATLAB display with no filter adjustment. The red line shows the filtered
waveform signal. The blue line shows the Pan-Tompkins waveform. The dotted teal line shows the threshold.
looping through this process until the user
b—After adjusting the filter cutoff frequencies the signal is much cleaner. presses the Quit button, at which time the
program exits the loop, closes all figures, and
deletes the input device.

THE VOLTAGE LIMITER


The circuit block’s output can have values
anywhere between –9 and 9 V. The Arduino
Due only accepts a limited range of inputs.
After rigorous testing, we determined that
the Arduino Due would crash when given an
FIGURE 3
1.5 V input voltage outside the 0.5-to-1.5-V range.
Two diodes are used to limit voltage.
The voltage limiter uses two diodes to limit
Differential the voltage, one leads to a 1.5-V node, the
Arduino
Amplifier
microcontroller other leads from a 0.5-V node (see Figure 3).
Circuit
This prevents any voltages above 1.5 or below
0.5 V 0.5 V from reaching the Arduino Due. The
circuit’s resistor limits the current that is
circuitcellar.com 41

seen by the Arduino Due. Following the block


diagram, the voltage limiter block’s output Due pin 36 -> 3k3 resistor -> Video In
becomes an input to the Arduino Due block. Due pin 37 -> 1k6 resistor -> Video In
Due pin 38 -> 820R resistor -> Video In
THE ARDUINO DUE Due pin 39 -> 390R resistor -> Video In
We used the Arduino Due to convert the Due pin 40 -> 200R resistor -> Video In

FEATURES
heartbeat waveform to an NTSC signal that Due pin 41 -> 100R resistor -> Video In
could be used by a mini-TV. The Arduino Due Due pin GND -> Video GND
continuously sampled the input provided
by the voltage limiter at 240 sps. Similar to
MATLAB, the vectorized signal was shifted FIGURE4
left to make room at the end for the most This is the connection between the Arduino Due and the mini TV.
recent sample. This provided a continuous
real-time display of the incoming signal.
Each frame outputted to the mini-TV contains
two waveforms. One has a 1-s screen width
and the other has a 5-s screen width. This
enables the user to see a standard version (5
s) and a more zoomed in version (1 s). Each
frame also contains an integer representing
the program’s elapsed time. This code was
produced by Cornell University professor
Bruce Land.

MINI-TV DISPLAY
Finally we’ve reached the end of the block
diagram. Here, the mini TV receives a signal
from the Arduino that tells it what to display.
We attached the Arduino connected to the
NTSC TV in accordance with the Arduino Due’s
video graphics array (VGA) library read me PHOTO 4
(see Figure 4). The resistors are connected to Here is the device in action. The top line (green) has a 1-s time base. The bottom line (yellow) has a 5-s
Video In via a 100-µF capacitor that provides time base.
AC coupling.

TAKE HEART
The final product of this project is a mobile
display of one’s heartbeat (see Photo 4). The
system is packaged in a box. A switch on the PROJECT FILES SOURCES
bottom is used to turn the system on and Arduino Due
off. The mini-TV is placed on the top of the
Arduino | http://arduino.cc
box with the handlebars on either side. This
enables you to easily switch the device on and
then place your hands over the bars to see ExpressPCB software
your heart reading on the screen. ExpressPCB | www.expresspcb.com
Because of the limited voltage range on
the input and substantial baseline wander in
most peoples’ signals, we were unable to circuitcellar.com/ccmaterials MATLAB programming language
accurately compute a person’s heart rate on MathWorks, Inc. | www.mathworks.com
the Arduino Due. To compensate for this, the
RESOURCES
final product contains an output port that is
B. Land, “Using the Arduino NI USB-6008/6009 Bus-powered
connected to the output of the differential
DUE,” Cornell University School multifunction DAQ USB device
amplification circuit, before it is voltage
limited. This port can be used to sample the of Electrical and Computer National Instruments Corp. | www.ni.com
signal into MATLAB, where a program we Engineering 5030, 2013.
wrote (which is available on Circuit Cellar’s INA116 Differential amplifier
FTP site) can accurately compute BPM and the S. Hubber and C. Lu., “Hands
user can further view and manipulate the Texas Instruments, Inc. | www.ti.com
On ECG,” Cornell University
signal. School of Electrical and
Computer Engineering 5030,
2013.
42 CIRCUIT CELLAR • AUGUST 2014 #289

EMBEDDED IN THIN SLICES

Linux System
Configuration (Part 2)
Linux Application Design
The Linux system can be configured in many ways.
This article examines some options, including
COLUMNS

BusyBox, web servers and server-side support,


mail servers, time server interfaces,
secure networking, graphics libraries,
and browsers.

By Bob Japenga (US)

L et’s start with some definitions. In


Part 1 of this article series I talked
about configuring the kernel. The kernel is
discuss the kinds of packages you may want
to include in your system.

the nerve center of a Linux system (i.e., the WHAT ARE YOUR OPTIONS?
OS). But the OS needs applications to do real One of the reasons my company uses
work. You need web servers, user interfaces, Linux is because of the vast array of packages
I/O processing, and other logic encapsulated available. Several times our customers have
in applications to do the actual work. asked: “Can you …?” You can fill in the blank.
After you configure and build the kernel, And many times, because of the packages
applications need to be selected and then built available, we can say yes.
for your particular kernel and processor. Linux One example involved creating a virtual
provides many open-source applications to display. One of our customer’s customers
help fulfill your design. As a system designer, wanted to control our embedded device from
you need to choose which applications you a PC as if they were in front of the device’s
want to go into your embedded system. Of touchscreen. Voila. An open-source package
course, if your processor is infinitely fast and has already been designed to do just that.
has an unlimited amount of RAM and flash Let’s look at some of the options you
memory, you can just skip this article. Others have as a system designer in open-source
may need to learn more. packages for embedded Linux.
Applications are put together in a
“package.” Packages are assembled in what BUSYBOX: THE SWISS ARMY
is called a “distribution.” You may have heard KNIFE OF PACKAGES
of Ubuntu or Fedora. These are collections BusyBox is one package that is used in a
of packages (one or more applications) and lot of embedded systems that are concerned
a kernel put together as one unit called a about resources. BusyBox puts a lot of (more
Linux distribution. For example, my company than 250) tiny UNIX/Linux applications into
recently started a project for a customer one small executable. For example, typical
and wanted to know what they were using networking applications such as File Transfer
for Linux (i.e., tools being used, kernel Protocol (FTP) and Telnet are included
version, and applications running). When the in BusyBox. Common file manipulation
customer told us they were using an Ångström applications such as “cp” (copy a file),
distribution, we knew what they had (more on “cmp” (compare), and “more” are included.
Ångström next time). In this article, I want to BusyBox can be configured to delete some
circuitcellar.com 43

of these applications if space or simplicity language program. When we started the


is appropriate. We reduced BusyBox to just project I was warned that serving webpages
a handful of commands on one tiny Linux in C was going to be difficult. But we just
system. With some distributions you can didn’t have the flash memory resources. Now
configure BusyBox to build some “real” UNIX/ I can truly say that the server-side software
Linux applications and delete them from was ugly. Most of you won’t be limited like we
BusyBox. were. However, if you are somewhat limited
There is one thing you should be aware you should choose one language you will use
concerning BusyBox. BusyBox commands are to serve webpages.
not always exactly the same as the standard
UNIX/Linux documentation. Generally they MAIL SERVERS
eliminate certain features rather than We did a Linux project replacing an
changing the core operation. The first time I embedded 8088 with a fax modem on an

COLUMNS
used BusyBox on a project, I found that many industrial control. Whenever the system
things I wanted to do were not present. Some needed to sound an alert, it would fax the
just required recompiling and rebuilding details to everyone on the list. We convinced
BusyBox. Sometimes they were not present our customer that e-mailing would be a much
at all. So beware. better way to go. Adding e-mail support to
Linux is trivial. As with setting up a web
WEBSERVERS AND SERVER-SIDE server, with mail servers you can go with
SUPPORT the standard full-featured mail server (called
Since you are using Linux, you most likely the SMTP server) or there are various small-
have a networked system. If you want to be footprint mail servers.
able to browse to the device (we usually use
this for configuring the system) or you want TIME SERVER INTERFACE
to respond to HTTP queries from a host, you One of the common problems we face
will need a web server. Your system uses a when we create “headless” designs (i.e.,
web server to deliver web content via the when there is no user interface) is how to set
Internet. As a system designer you have a lot the time and date. There is a Linux package
of options. that solves your problem. The Network
Apache—Apache is the grandfather of all Time Protocol (NTP) enables your device to
Linux web servers. Approximately 60% of continuously connect to a time server and
all web content on the Internet is handled keep your time and date current. It works
by Apache servers. Apache is a completely much like what you have on a Windows PC.
full-featured web server with more options
than I could describe in several articles. With SECURE NETWORKING
this functionality comes significant resource When we started designing networked
usage. Some estimates recommend 400 MB systems, security was not at the top of our
of RAM and hundreds of megabytes of disk priority list. Now, customers no longer want
space. It is so configurable, hard statistics Telnet (an unsecure way of connecting to your
are not available about how much memory device). They demand Secure Shell (SSH),
Apache uses. We used Apache once on an which is just Telnet over a secure network. By
embedded system that had a gargantuan incorporating the OpenSSL package (which we
amount of memory. are all familiar with because of the HeartBleed
Lighttpd—We have used Lighttpd on many virus), you can add a secure layer to all of your
of our embedded designs. Requiring less network communications. Generally, adding
than a tenth of the resources of Apache, it OpenSSL is not enough since you will have
supports almost all of the features we have to provide some mechanism to handle the
ever needed to design web-based embedded encryption keys (encapsulated in certificates).
systems. Again, the Linux open-source community will
Server-side languages—You need some provide that for you.
kind of server-side support language to serve
most modern webpages. If your device is going GRAPHICS LIBRARIES
to serve anything but a simple webpage, you Many Linux systems that we build
should include one or more of the following have some sort of GUI. With any graphical
languages: PHP, Perl, Python, Ruby, Java, or interface, you need the graphical libraries
Tcl. These languages are resource hogs on to easily design a snazzy user interface. The
very small embedded systems. granddaddy of Linux graphics libraries is the
On one project, using PHP would have X.Org Foundation’s X Window System. The
taken 8 MB of flash memory. On this system, first UNIX system I ever worked with included
which had 16 MB of RAM and 32 MB of flash this library. It is large and sometimes painfully
memory, we served webpages with a C slow. GTK+ is a faster and smaller-footprint
44 CIRCUIT CELLAR • AUGUST 2014 #289

option. We have used it on several NetFront NX. It is said to be “extremely”


systems and were well satisfied. QT optimized for embedded platforms. Nintendo
is a smaller and faster library, but my 3DS and Playstation 3 Internet browsers use
company does not have any experience this platform. Unfortunately, I do not have
using it. licensing information or any experience
We have done a few designs using it.
where the user interface is a browser
interface. This requires the system MISCELLANEOUS PACKAGES
to have a browser and a web server. There are a wide range of other packages
Instead of designing widgets and to suit many different needs. cURL is a
gadgets from scratch, draw upon the powerful command-line tool for sending all
vast number of webpage designs in the kinds of data over the Internet over a variety
world and point your browser to the of protocols. We have used cURL in a several
COLUMNS

device’s link local address. settings where we wanted to communicate


ABOUT THE AUTHOR over the Internet via a shell script rather than
BROWSERS programmatically.
Bob Japenga has been
Whether you browse to your own How can I discuss packages without
designing embedded web server (as described earlier) or talking about package managers? A
systems since 1973. In 1988, enable your user to browse externally mechanism for managing the versions
along with his best friend, he (we have only done this on one of your packages is built into the fabric of
started MicroTools, which spe- embedded system), you need to choose Linux. It seems as if each distribution has its
cializes in creating a variety of at least one browser package. The own package manager with its own nuances.
real-time embedded systems. common options we have used include Simply stated, it is a powerful way to safely
With a combined embedded Chromium (why it is not called Chrome and automatically update your applications
systems experience base of is an interesting story for another day), and packages in the field. That said, we have
more than 200 years, they love Firefox, and Midori. Chromium uses a never used a package manager to control
to tackle impossible problems lot of resources, but it is well known. the updating of our proprietary code on
together. Bob has been award- We found Firefox to be unstable on the an embedded system. It seems as if our
ed 11 patents in many areas of one platform on which we ran it. Midori customer’s requirements for security, the
embedded systems and motion is a fast and lightweight option. It is website, version control, or something else
control. You can reach him at part of the Raspberry Pi distribution. prevents us from using a package manager
rjapenga@microtoolsinc.com. We have limited experience using it. in our embedded system.
There is a commercial browser Perhaps you have successfully used a
specifically designed for small package manager on an embedded system.
embedded platforms: NetFront and E-mail me what you did and how you did it.
We have tried a few times to use them to
prevent us from reinventing the wheel for
Lighttpd, www.lighttpd.net. software updates, but we have always been
stymied.
Midori, www.midori-browser.org. Another package we use on some of
our systems is a database programming
MySQL, www.mysql.com. language called SQL. If your design requires a
distributed and relational database, you may
The Network Time Protocol (NTP), www.ntp. want to look into SQL. Several different SQL
circuitcellar.com/ccmaterials
org. packages are available. We have used MySQL,
RESOURCES which is a full-featured implementation and
The OpenSSL Project, www.openssl.org. SQLite, which is a somewhat “lite” version
The Apache Software Founda-
tion, www.apache.org. of MySQL. By adding this package to your
QT Project, http://qt-project.org. toolkit you add all of the power of a managed
The Ångström Distribution, relational database.
SQLite, www.sqlite.org.
www.angstrom-distribution.
org. KNOW YOUR OPTIONS
Ubuntu, www.ubuntu.com. Configuring Linux involves configuring and
BusyBox, www.busybox.net. building the kernel, selecting the packages
Wikipedia, “Heartbleed.” you want installed in your system, and then
cURL, http://curl.haxx.se. building them into a file system image. This
X.Org Foundation, www.x.org/wiki. article provided you with information about
The Fedora Project, https:// some of your options (in thin slices of course).
fedoraproject.org. Part 3 of this article series will discuss the
SOURCE
options you have for building this vast array
NetFront
The GTK+ Project, www.gtk. into a workable Linux system.
ACCESS Co., Ltd. | www.access-company.com
org.
26
ADVANCE PROGRAM
August 10-12, 2014
A Symposium on High-Performance Chips
Flint Center for the Performing Arts-Cupertino,CA
http://www.hotchips.org
HOTCHIPS brings together designers and architects of high-performance chips,software, and systems. The tutorial and
presentation sessions focus on up-to-the-minute developments in leading-edge industrial designs and research projects
Register now by going to https://www.123signup.com/register?id=drvzv
Tutorial 1: Emerging Trends in Hardware Support for Security Organizing Committee
• Security Overview Princeton Chair
• Mobile HW Security ARM Krste Asanovic UC Berkeley
• Secure Systems Design AMD Vice Chair
Sunday
August 10

• Hardware Assists for Introspection Intel Fred Weber


Finance
Tutorial 2: Internet of Things Lily Jow HP
• Powering the Internet of Things TI Advertising
• Ultra-Low-Power Design Approaches for IoT National University of Singapore Don Draper Oracle
• Connecting the IoT Qualcomm Sponsorship
• IoT Systems Architecture: It’s not just “Embedded with a Radio” ARM Amr Zaky Invensense
Publications
High-Performance Computing Randall Neff
• SX-ACE Processor: NEC's Brand-New Vector Processor NEC Press
• SPARC64 XIfx: Fujitsu’s Next-Generation Processor for HPC Fujitsu Ralph Wittig Xilinx
• Anton 2: A 2nd-Generation ASIC for Molecular Dynamics Simulation D.E. Shaw Research Registration
Monday
August 11

Charlie Neuhauser Neuhauser


Keynote 1 Power Constraints: From Sensors to Servers Associates
Michael Muller ARM Location Services
John Sell Microsoft
Mobile Processors
Allen Baum
• NVIDIA’s Tegra K1 System-on-Chip NVIDIA Volunteer Coordinator
• Applying AMD’s “Kaveri” APU for Heterogeneous Computing AMD Gary Brown Tensilica
• NVIDIA’s Denver Processor NVIDIA Webmasters, IT
Technology Kevin Broch
• HBM: Memory Solution for Bandwidth-Hungry Processors SK Hynix Inc Production
• Improved 3D chip stacking withThruChip Wireless Connections ThruChip Communications Lance Hammond
• CMOS Biochips for Point-of-Care Molecular Diagnostics Insilixa Mike Albaugh
ARM Servers Keith Diefendorff
• The AMD Opteron “Seattle”: A 64b ARM Dense Server Processor AMD Steering Committee
• ARM Next-Generation IP Supporting LSI’s HIgh-End Networking ARM, LSI Logic Chair
Alan Jay Smith
• X-Gene2: 28nm Scale-Out Processor Applied MIcro Committee Members
FPGAs Allen Baum
• Design of a High-Density SOC-FPGA at 20nm Altera Don Draper Oracle
• A Reconfigurable Fabric for Accelerating Datacenter Services Microsoft Pradeep Dubey Intel
• Xilinx FPGAs Case Study: High capacity and Performance 20nm FPGAs Xilinx Lily Jow HP
John Mashey Techviser
• SDA: Software-Defined Accelerator for Large-Scale DNN Systems Baidu John Sell Microsoft
High-Performance ASICs Keith Diefendorff
• Hardware-Accelerated Text Analytics IBM Program Committee
• Myriad2 “Eye” of the Computational-Vision Storm Movidius Program Co-Chairs
• Goldstrike 1: A 1st Generation Cryptocurrency Processor for Bitcoin Mining Cointerra Sam Naffziger AMD
• RayChip: Real-Time Ray Tracing Chip for Embedded Applications Guri Sohi U. Wisconsin
Tuesday

Committee Members
August 12

Keynote 2 The Internet of Everything: What is it? What’s driving it? Forest Baskett NEA
What comes next? Pradeep Dubey Intel
Rob Chandhok Qualcomm John Davis Microsoft
Alan Jay Smith UC Berkeley
Dense Servers and Server Technology Steve Miller NetApp
• SCORPIO: 36-Core Shared-Memory Processor with a Coherent Mesh MIT Subhasish Mitra Stanford
• Unchaining the Datacenter with OpenPOWER: Reengineering a Server Ecosystem IBM Stefan Rusu Intel
• Oracle’s Next-Generation SPARC Cache Hierarchy Oracle Tom McWilliams BayStorage
• Atom C2000 Microserver: Power-Efficient Datacenter Processing Intel Behnam Robatmili Qualcomm
Ralph Wittig Xilinx
Big-Iron Servers Mike Taylor UCSD
• Performance Characteristics of the POWER8 Processor IBM Bill Dally NVIDIA
• Next Generation Oracle Sparc Processor Oracle Founder Bob Stewart SRE
• IvyBridge Server: Delivering Performance from Workstations to Mission Critical Intel
HOTCHIPS is accepting poster submissions by July 15 from both industry and academia. Accepted student poster
submissions will be considered for travel assistance. The best student poster will receive the Best Student Poster Award.
Warthman
Associates
Technical Writers
www.warthman.com

A Symposium of the Technical Committee on Microprocessors and Microcomputers


of the IEEE Computer Society and the Solid-State Circuits Society
46 CIRCUIT CELLAR • AUGUST 2014 #289

PROGRAMMABLE LOGIC IN PRACTICE

Build a SoC Over Lunch


COLUMNS

Implementing a soft-core
processor inside an FPGA is not a new
concept. Recent releases have made developing and customizing these processors easier than ever, to the point
of enabling code compilation from an Arduino IDE. This article explains how you can use an FPGA to develop a
simple custom PWM peripheral for the processor.

By Colin O’Flynn (Canada)

I n a previous article, I introduced the


Xilinx’s Zynq programmable device with
dual hard-core ARM processors, which I used
you haven’t used Arduino, don’t let the hype scare
you. You are really programming in regular C/
C++ code, so if you’re already experienced with
to design a system-on-a-chip (SoC) solution. embedded design you won’t have any problems.
(Refer to my article “All-Programmable SoC One advantage of the Arduino environment is
Solution,” Circuit Cellar 285, 2014.) In this there are many useful libraries you can utilize.
article, I’ll introduce a much smaller and There is no need to write your own SPI, EEPROM,
lower-power option you can use: a simple or UART driver, for example. But I’m getting
soft-core processor. Xilinx aficionados might ahead of myself. First let’s discuss why you want
assume this will be either the MicroBlaze or a soft-core processor.
PicoBlaze devices, which are part of the Xilinx
ecosystem. But I’m actually going to discuss KILLING ME SOFTLY
another device. Soft-core processors are convenient
Alvaro Lopes’s ZPUino is an open-source because they have customizable designs. For
design, which is interesting since it can be example, you can choose two or five UARTs,
programmed from an Arduino environment. If or even interface directly to tailored FPGA
circuitcellar.com 47

peripherals. Interfacing to custom peripherals even easier, and then adds a modified version
is one of the best aspects of adding a soft- of the Arduino IDE, which can compile code
core processor, since some configuration for the ZPU. To store program code, the
is often required for any peripheral. It can ZPUino comes with a loader to program a
be difficult to write a large state machine to connected SPI flash device. Figure 1 shows an
handle this, but it only takes a few minutes to example package of the ZPUino core as used
write a simple C program. The combination of by Gadget Factory’s ZPUino Arduino Papilio
a processor with custom peripherals is often (ZAP) release, which I will discuss next.
referred to as a SoC. The ZAP release packages the ZPUino with
Considering FPGAs’ (relatively) high cost, a clone of Atmel’s AVR 8-bit microcontroller
you may question why you would not just use a and includes an interesting “graphical
physically separate microcontroller. Powerful configuration” utility to add peripherals
microcontrollers with various peripherals cost to either core. It even adds support for an

COLUMNS
just a few dollars and typically have complete open-source logic analyzer (called SUMP),
development environment support. As I’ll which enables you to have an integrated
demonstrate, a soft-core processor is still a logic analyzer (ILA) core inside your design!
useful asset since it can more tightly integrate The ZAP release targets two Gadget Factory
with FPGA logic. So let’s start by looking at FPGA boards and works “out of the box” when
the ZPUino’s pedigree to better understand targeting these boards.
how it was developed. In this article I’ll be discussing the ZAP
release, since it provides the highest level of
ZPU CHILDREN integration. It’s important to realize that the
In the beginning, there was the ZPU, which ZAP release is built on a collection of other
is an open-source lightweight 32-bit CPU open-source tools. Thus you can use the ZAP
design from Zylin Consulting. The ZPU uses system to learn about the ZPU core. You can
the “WISHBONE” bus standard to interconnect later move on to your own design based on
with the CPU core and peripherals. For open- the “original” ZPU core, if you wish.
source peripherals (e.g., those posted at
opencores.org), the WISHBONE standard is MOPED OR MOTORCYCLE?
probably the most widely used. The ZPU has The ZPUino design is sufficiently speedy,
GCC support. If you have some experience which enables you to perform some real
with embedded development you will probably tasks on it. I ran my example implementation
be quite happy. There is even support for the on a Xilinx Spartan-6 LX9 MicroBoard at 96
eCos RTOS if you want a little more structure MHz, so you certainly aren’t limited to only
for your program on top of the ZPU. simple configuration tasks. It may be easier
The ZPUino is based on the ZPU. The ZPUino to perform protocol decoding on the ZPUino.
takes a version of the ZPU core, modifies it Fairly complex triggering tasks can be
slightly, packages it with some simple default done within the ZPUino. However, be aware
features and peripheral options to make life that the ZPU core isn’t designed for high

ZPUino core

Stack (BRAM)
Zylin Computing
Mux ZPU 32-Bit core

Memory
arbitrator
I/O Controller
Interrupt FIGURE 1
controller
Alvaro Lopes’s ZPUino processor is
ROM System based on Zylin Computing’s ZPU
DMA Wishbone I/O Wishbone
(Instructions) memory extreme core. The ZPUino adds several
ZPUino processor useful peripherals, including the logic
Bootloader mux
to automatically load code from SPI
flash into synchronous dynamic RAM
Bootloader Memory
(SDRAM) via the bootloader. This
code arbitrator is required for a system capable
of booting without any special
SDRAM UART
SPI Driver GPIO configuration. Instructions and data
Controller Driver
Wishbone Wishbone Wishbone are stored in the external SDRAM
slots slots slots
in this example. It’s possible to use
SPI
SDRAM Chip EEPROM internal Block RAM (BRAM) inside
Interface ports (no logic) the FPGA for code and data storage
instead.
48 CIRCUIT CELLAR • AUGUST 2014 #289

PHOTO 1
This is Gadget Factory’s LX9 Board
(left) with the LogicStart MegaWing
(right). The two boards plug together
during operation. A Xilinx Spartan-6
LX9 along with synchronous dynamic
RAM (SDRAM), SPI flash memory, and
a USB interface is present on the main
LX9 board. The LogicStart adds the
seven-segment LED displays, LEDs,
and the ADC used in this example.
The video graphics array (VGA)
output isn’t used, but it would add
another example of a useful specialist
hardware peripheral you can include
COLUMNS

with the system-on-a-chip (SoC).

performance; instead it is intended to have PAPILIO PRO DEMO BOARD


sufficient performance for most general- If you want to follow along, I’m using
purpose tasks. a different LX9 board from my previous
If you know you’re going to be performing articles. Photo 1 shows the board I’m using
tasks that require a higher-performance here, which is Gadget Factory’s Papilio Pro
core, your time would be better spent along with its LogicStart MegaWing. The main
learning a different soft-core processor FPGA board has a Spartan-6 LX9, synchronous
(e.g., Xilinx’s MicroBlaze, which targets dynamic RAM (SDRAM), a SPI flash memory
higher-performance users). As an example, chip, and a USB interface. The LogicStart
the Dhrystone MIPS (DMIPS) benchmark is MegaWing features I am going to use include
often used for embedded processors. The its eight switches, eight LEDs, four seven-
MicroBlaze core on a Spartan-6 is capable segment displays, and SPI-connected ADC.
of 150 to 200 DMIPS. By comparison, my You could modify this example to run with
tests showed the ZPUino clocking in around another board (e.g., the Avnet LX9 Microboard,
14 DMIPS. Of course many applications don’t which I used in previous articles). I’ll take full
need high performance and ZPUino’s lower advantage of the Gadget Factory LX9 board’s
area and simpler configuration is of far extra I/O pins for the example application
greater importance. So, if the ZPUino sounds presented here.
good to you, how do you get started?
SEARCHING FOR A PROBLEM
Considering the number of solutions that
need problems, I decided to try and give you a
SPI more realistic problem that is best solved with a
ADC Logic
Driver
Eight-channel
soft-core processor. FPGAs have an abundance
PWM of I/O drivers, so I decided to create a very
I/O-heavy example. In particular I’m going to
use the device as a display board, since the
LogicStart MegaWing add-on has several LEDs
User interface logic Seven-segment driver with additional seven-segment displays.
I’d like to drive the four seven-segment
displays on the board and drive all eight LEDs.
That alone is a simple task any microcontroller
could handle. But I also want to provide brightness
control through PWM on every channel. This is
GPIO
still within the realm of microcontrollers, but I’d
Serial port
be starting to tax the available number of PWM
channels on most devices.
The FPGA has no problem. I could have driven
32 or 64 separate channels if I wanted, it would
FIGURE 2
I used a soft-core processor inside an FPGA to create this PWM system. Blocks are implemented with a
have just meant adding more PWM controllers.
combination of hardware peripherals and software running on the processor. See text for a description of Figure 2 shows a block diagram of the
the program flow. system (including FPGA blocks). The SPI-
circuitcellar.com 49

PHOTO 2
The Arduino IDE with Gadget Factory’s
ZPUino Arduino Papilio (ZAP) provides
a simple development to program the
soft-core processor.

COLUMNS
RS485/422/232/TTL
CONNECT WI TH ASC24T IBS485HV

Circuit
RS232<=>RS485 ATE Converter 5 Port Isolated
RS485 Repeater
$349.00

Cellar $45.00 board only Enclosur es, Cables,


Power Supplies and Other
Accessories

For people who are passionate


INTRODUCING THE SMFCOMX!
about hardware and software design,
embedded development, and computer • Extended Distance Units
applications. Awesome projects, • Converters • Serial to Digital I/O
industry news, trivia challenges, • Repeaters • Large Multi-Drop Networks
and more! • Multi-Repeaters
• Custom Units &
Connect. • Hubs
• Fiber Optics
Smart Units
Follow us on Twitter. Like us on Facebook.
• Isolators • Industrial, 3.0 KV Isolation
circuitcellar.com Call the RS485 Wizards
@circuitcellar 513-874-4796
@editor_cc circuitcellar www.rs485.com
50 CIRCUIT CELLAR • AUGUST 2014 #289

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.numeric_std.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;

library board;
use board.zpu_config.all;
use board.zpuino_config.all;
use board.zpupkg.all;
use board.zpuinopkg.all;
COLUMNS

entity MISC_zpuino_wb_pwm is
port (
wishbone_in : in std_logic_vector(61 downto 0);
wishbone_out : out std_logic_vector(33 downto 0);
fastclk_in : in std_logic;
pwm_out : out std_logic_vector(7 downto 0)
);
end entity MISC_zpuino_wb_pwm;

architecture behave of MISC_zpuino_wb_pwm is

component PWM is
port (
clk : in std_logic;
PWM_in : in std_logic_vector (7 downto 0);
PWM_out : out std_logic
);
end component;

signal selected: std_logic;

signal wb_clk_i: std_logic; -- Wishbone clock


signal wb_rst_i: std_logic; -- Wishbone reset (synchronous)
signal wb_dat_i: std_logic_vector(31 downto 0); -- Wishbone data input (32 bits)
signal wb_adr_i: std_logic_vector(26 downto 2); -- Wishbone address input (32 bits)
signal wb_we_i: std_logic; -- Wishbone write enable signal
signal wb_cyc_i: std_logic; -- Wishbone cycle signal
signal wb_stb_i: std_logic; -- Wishbone strobe signal

signal wb_dat_o: std_logic_vector(31 downto 0); -- Wishbone data output (32 bits)
signal wb_ack_o: std_logic; -- Wishbone acknowledge out signal
signal wb_inta_o: std_logic;

--signal PWM_Accumulator : std_logic_vector(8 downto 0);


signal PWM0_Setting : std_logic_vector(7 downto 0);
signal PWM1_Setting : std_logic_vector(7 downto 0);
signal PWM2_Setting : std_logic_vector(7 downto 0);
signal PWM3_Setting : std_logic_vector(7 downto 0);
signal PWM4_Setting : std_logic_vector(7 downto 0);
signal PWM5_Setting : std_logic_vector(7 downto 0);
signal PWM6_Setting : std_logic_vector(7 downto 0);
signal PWM7_Setting : std_logic_vector(7 downto 0);

begin
-- Unpack the wishbone array into signals so the modules code is not confusing.
wb_clk_i <= wishbone_in(61);
wb_rst_i <= wishbone_in(60);
wb_dat_i <= wishbone_in(59 downto 28);
wb_adr_i <= wishbone_in(27 downto 3);
circuitcellar.com 51

wb_we_i <= wishbone_in(2);


wb_cyc_i <= wishbone_in(1);
wb_stb_i <= wishbone_in(0);

wishbone_out(33 downto 2) <= wb_dat_o;


wishbone_out(1) <= wb_ack_o;
wishbone_out(0) <= wb_inta_o;
-- Finish unpacking Wishbone signals.

selected <= ‘1’ when wb_cyc_i=’1’ and wb_stb_i=’1’ else ‘0’;

wb_dat_o(31 downto 8) <= (others => ‘0’);

COLUMNS
process(wb_clk_i)
begin
if rising_edge(wb_clk_i) then
wb_ack_o<=’0’;
if selected=’1’then
if wb_we_i=’1’ then

case wb_adr_i(4 downto 2) is


when “000” =>
PWM0_Setting <= wb_dat_i(7 downto 0);
when “001” =>
PWM1_Setting <= wb_dat_i(7 downto 0);
when “010” =>
PWM2_Setting <= wb_dat_i(7 downto 0);
when “011” =>
PWM3_Setting <= wb_dat_i(7 downto 0);
when “100” =>
PWM4_Setting <= wb_dat_i(7 downto 0);
when “101” =>
PWM5_Setting <= wb_dat_i(7 downto 0);
when “110” =>
PWM6_Setting <= wb_dat_i(7 downto 0);
when “111” =>
PWM7_Setting <= wb_dat_i(7 downto 0);
when others =>
null;
end case;

end if;
wb_dat_o(7 downto 0) <= (others => ‘0’);
wb_ack_o <= ‘1’;
end if;
end if;
end process;

pwm0: PWM port map(clk => fastclk_in, PWM_in => PWM0_Setting, PWM_out => pwm_out(0));
pwm1: PWM port map(clk => fastclk_in, PWM_in => PWM1_Setting, PWM_out => pwm_out(1));
pwm2: PWM port map(clk => fastclk_in, PWM_in => PWM2_Setting, PWM_out => pwm_out(2));
pwm3: PWM port map(clk => fastclk_in, PWM_in => PWM3_Setting, PWM_out => pwm_out(3));
pwm4: PWM port map(clk => fastclk_in, PWM_in => PWM4_Setting, PWM_out => pwm_out(4));
pwm5: PWM port map(clk => fastclk_in, PWM_in => PWM5_Setting, PWM_out => pwm_out(5));
pwm6: PWM port map(clk => fastclk_in, PWM_in => PWM6_Setting, PWM_out => pwm_out(6));
pwm7: PWM port map(clk => fastclk_in, PWM_in => PWM7_Setting, PWM_out => pwm_out(7));

end behave;

LISTING 1
This VHDL code is a simple PWM module. Each of the eight PWM modules is manually instiated to demonstrate how to write to different registers. You can modify this to make the
number of PWM modules a simple configuration instead.
52 CIRCUIT CELLAR • AUGUST 2014 #289

connected ADC is continuously sampled and


volatile unsigned int * PWM_Base; the voltage is used to generate a bar-graph
representation with the eight LEDs. Using
void setup(){ PWM provides more flexibility than using
PWM_Base = &REGISTER(IO_SLOT(8),0); eight on/off LED states. With the PWM, your
LED can be partially on (i.e., not just at full
for (int i = 0; i < 8; i++) { brightness or completely off).
*(PWM_Base + i) = i * 32; The brightness level indicates the voltage
} being measured. If the measurement range is
} 0 to 3 V, each of the LEDs represents a 0.375-V
increment. A 1.5-V input would illuminate LEDS
1 through 4. A 1.6-V input would mean LED 5
LISTING 2
is dimly illuminated, whereas a 1.88-V input
COLUMNS

This C code shows a simple example of accessing the PWM register interface. The I/O slot number is based would fully illuminate LED 5.
on the schematic shown in Figure 3, which then is used to determine the peripheral’s base address. Writing In addition, a user interface over the serial
or reading to the peripheral is trivial, using standard pointer-type access or the REGISTER() macro. port prompts you to set the seven-segment
LED display’s value and brightness. You can

CLK CLK SPI_SCK SPI_SCK


SPI_MOSI SPI_MOSI
SPI_MISO SPI_MISO ZPUino Soft Processor - Papilio Pro - Vanilla - v1.0 TXD TXD
Author: Alvaro Lopes SPI_CS SPI_CS
RXD RXD Free sesources:
Used resources: alvie.com/zpuino
11 of 32 Block RAM (BRAM) 21-Block RAM (BRAM)
External SDRAM GPIO Pins
34% of available slices 66% of slices
DRAM_DQ(15:0) DRAM_DQ(15:0) 1 PLL (clock) gpio_bus_in(97:0)
1 of 2 PLL (clock) 8 MB of Program sode space
DRAM_CAS_N DRAM_CAS_N 2 DCM (clock) gpio_bus_out(147:0)
0 of 2 DCM (clock)
DRAM_CKE DRAM_CKE (code runs out of SDRAM)
DRAM_CLK DRAM_CLK
Clocks
DRAM_CS_N DRAM_CS_N
DRAM_RAS_N DRAM_RAS_N clk_96Mhz
DRAM_WE_N DRAM_WE_N clk_1Mhz
Visit Papilio.cc for socumentation System slock runs at 96 MHz
DRAM_ADDR(12:0) DRAM_ADDR(12:0) clk_osc_32Mhz
DRAM_BA(1:0) DRAM_BA(1:0)
DRAM_DQM(1:0) DRAM_DQM(1:0)

LED LED
Wishbone Wishbone Wishbone Wishbone Wishbone Wishbone Wishbone Wishbone Wishbone
slot 5 slot 6 slot 8 slot 9 slot 10 slot 11 slot 12 alot 13 alot 14

Wishbone empty slot Wishbone empty slot Wishbone empty slot Wishbone empty slot Wishbone empty slot

fastclk_in
pwm_out(7:0) LED_OUT(7:0)

gpio_bus_in(97:0)
MISC_zpuino_wb_pwm gpio_bus_out(147:0)
7SegAN3 WING_AL0
7SegDP WING_AL1
VGA 7SegAN2 WING_AL2
VGA_Hsync 7SegE WING_AL3
VGA_Vsync 7SegF WING_AL4
VGA_Red2 7SegC WING_AL5
VGA_Red1
VGA_Red0 7SegD WING_AL6
VGA_Green2 7SegA WING_AL7
VGA_Green1
VGA_Green0 7SegAN1 WING_AH0
VGA_Blue1 7SegG WING_AH1
VGA_Blue0 7SegB WING_AH2
7SegAN0 WING_AH3
SPI_CS WING_AH4
SPI_MISO WING_AH5
SPI_MOSI WING_AH6
Seven Segment SPI_Clk WING_AH7
dot Seg7_dot
VGA_Vsync WING_BL0
segdata(6:0) Seg7_segdata(6:0) VGA_Hsync WING_BL1
VGA_Blue0 WING_BL2
extra(31:0) VGA_Blue1 WING_BL3
VGA_Green0 WING_BL4
enable(3:0) Seg7_enable(3:0) VGA_Green1 WING_BL5
VGA_Green2 WING_BL6
Seven Segment VGA_Red0 WING_BL7

VGA_Red1 WING_BH0
VGA_Red2 WING_BH1
Audio WING_BH2
SPI ADC JoyRight WING_BH3
JoyLeft WING_BH4
SPI_MISO
JoyDown WING_BH5
miso
JoyUp WING_BH6
mosi SPI_MOSI JoySelect WING_BH7
sck SPI_CLK SW0 WING_CL0
SPI SW1 WING_CL1
SPI_CS
SW2 WING_CL2
SW3 WING_CL3
SW4 WING_CL4
SW5 WING_CL5
SW6 WING_CL6
SW7 WING_CL7
Audio
LED0
clk_96Mhz Audio
LED1
raw_out(17:0) data_in(17:0) LED2
LED3
Audio passthrough audio_out LED4
LED5
Delta sigma DAC LED6
LED7

Papilio LogicStart MegaWing Pinout

FIGURE 3
This schematic is used with the Xilinx ISE software to configure the high-level blocks of the system-on-a-chip (SoC). The MISC_zpuino_wb_pwm block is the custom eight-channel
PWM engine. Listing 1 provides the source code.
IF “EXPECT THE UNEXPECTED” WEREN’T SO EXPECTED,
WE’D SAY THAT’S EXACTLY WHAT TO EXPECT.
The 2015 International CES.® Four days of business, innovation
and exactly what you didn’t expect. Register at CESweb.org.

JAN. 6-9, 2015


LAS VEGAS, NEVADA
CESWEB.ORG
#CES2015
54 CIRCUIT CELLAR • AUGUST 2014 #289

ABOUT THE AUTHOR


C o l i n O ’ F l y n n ( c o f l y n n @ n e w a e.c o m ) h a s b e e n b u i l d i n g a n d b re a k i n g e l e c t ro n i c
devices for many years. He is currently completing a PhD at Dalhousie
University in Halifax, NS, Canada. His most recent work focuses on embed -
d e d s e c u r i t y, b u t h e s t i l l e n j o y s e v e r y t h i n g f r o m F P G A d e v e l o p m e n t t o h a n d -
soldering prototype circuits. Some of his work is posted on his
website at www.colinoflynn.com.
COLUMNS

also use this serial interface to read the state Selecting your “board” defines the base
of the eight switches on the board. With that system file. An option called “Burn Bootloader”
background in mind, let’s start looking at how programs the FPGA bitstream. By default, this
to perform this design. will also program it into the SPI flash on the
board (i.e., you only have to run the “burn
THE ZAPpy IDE bootloader” once and then every time you
One wonderful thing about the ZAP system power on the board it will automatically load
is how easy it is to get started. You simply the FPGA bitstream).
download a ZIP file with everything in it, If you aren’t familiar with Arduino, the
extract it somewhere, and run the Arduino process of compiling the source code is called
IDE binary. The ZIP file is less than 200 MB, “verifying” it. Once the code compiles, you can
compared with the multi-gigabyte Xilinx select the “upload” option, which programs
Software Development Kit (SDK) you need the code into the SPI flash memory on the
to develop with the MicroBlaze device. If you board and loads it into SDRAM.
want to modify the FPGA portion you need With the ZPUino, code runs from SDRAM
to have Xilinx ISE installed, but presumably on the Papilio Pro board. When the FPGA
you’ve already committed to that during your powers on it will automatically load the code
FPGA work! from SPI flash memory into the SDRAM and
Photo 2 shows the IDE. From this IDE you begin executing. The ZAP tools manage this
can select which FPGA “base system” file you for you. A single SPI flash memory is used
wish to program, as it ships with a few that for the FPGA bitstream and software code
have standard peripherals present. You’ll storage. Now that you know how the system
probably want to modify these to add your works, let’s delve into the FPGA itself.
own peripherals, which is something I’ll be
doing in this article. REMODELING THE FPGA
Soft-core processors are nothing new. But
the ZAP system uses Xilinx ISE’s schematic
entry mode to provide a graphical method
of adding peripherals to the base system to
configure your SoC. This provides an excellent
Zylin Computing, “Zylin ZPU,” http://
higher-layer view of your system, and you
opensource.zylin.com.
can easily link a VHDL or Verilog block into a
schematic symbol. Thus the schematic entry
OpenCores.org, “SoC Interconnection:
is only used for high-layer development. The
Wishbone,” www.opencores.org.
real work is still done with standard VHDL or
circuitcellar.com/ccmaterials
Verilog code.
SOURCES Figure 3 shows a schematic of my base
AVR Microcontroller system from the Xilinx ISE, which includes
RESOURCES a special PWM block that implements eight
Atmel Corp. | www.atmel.com
A. Lopes, “ZPUino,” www.alvie. PWM channels. This PWM block is connected
com/zpuino. to a specific wishbone “slot.” You can refer to
Papilio Pro FPGA and LogicStart MegaWing
Gadget Factory, LLC | www.papilio.cc this wishbone slot from your software code,
C. O’Flynn, “All-Programmable which then provides a simple mapping of your
SoC Solution,” Circuit Cellar peripheral to the software code.
Zynq platform device, Spartan-6 LX9
285, 2014. Listing 1 shows the interior of the PWM
MicroBoard, MicroBlaze soft processor,
PicoBlaze microcontroller, and Xilinx block. Each PWM channel has a different
ProgrammableLogicInPractice. register that sets the PWM duty cycle. You
Software Development Kit (SDK)
com. can see how easy it is to add new registers to
Xilinx, Inc. | www.xilinx.com
circuitcellar.com 55

the block. Of course you can easily interface As always, the complete projects
to a device such as a Block RAM (BRAM) by including step-by-step details are available
simply deciding which high-level bits within at ProgrammableLogicInPractice.com. You’ll
your peripheral address space will select also want to see details of the ZAP software
the BRAM and then connecting the low-level release posted on the Gadget Factory’s
address bits to the BRAM device. Because the website, since many useful tutorials and other
processor has a 32-bit data bus, the address documentation are available.
increases by 0x04 each time. The two low Remember the best method of cementing
level bits are always “00” when performing a your knowledge is through experience, so go
32-bit read or write. Now that I’ve explained forward and design your own specialist
how to add a custom peripheral, let’s drive peripherals for the soft-core processor. You
that peripheral from the software to perform may be pleasantly surprised to discover how
something useful. easy it is and how many applications you

COLUMNS
suddenly find for your new soft-core
SOFTWARE DEVELOPMENT processor.
The custom peripherals simply get mapped
into your processor address space. This
means writing to or reading from a register is
just like accessing a peripheral in your “usual”
microcontroller or SoC device. You simply
have a base address of the peripheral and an
offset to the specific register of interest.
Listing 2 shows a code snippet that writes
a different value to each PWM register. The
REGISTER() macro provides access to a
specific register that you can read or write,
based on an I/O slot number and an offset.
You can also use this to get the base address
(as I’ve done in Listing 2) and then use
pointer math to access that.
The I/O slot number is determined
from Figure 3, which was the graphical
configuration of the system using ISE. You’ll
most likely want to write a separate class for
your peripheral, where the I/O slot number is
simply configured when you initialize the class.
The provided examples show how this is done.
The seven-segment driver is a good example
of a simple class using such a strategy.
Again, if you aren’t already familiar with
the Arduino environment, you can effectively
consider it writing regular C/C++ with only a
few minor changes. It’s hard to beat in terms
of quickly getting an example compiled and
loaded into real hardware. It only takes a few
minutes to program a FPGA base system along
with a processor program. For development
you’ll find it faster to avoid programming the
SPI flash memory with your new program.
Instead only load it into RAM, which takes just
a few seconds. This is done by holding down
shift while running the upload command.

I REJECT YOUR
MICROCONTROLLER AND
SUBSTITUTE MY OWN
If you haven’t used soft-core processors, I
hope this article has introduced an easy way
to get started. If you already have some FPGA
designs, you may find that a simple soft-core
processor is just what your design needs for
some configuration or housekeeping tasks.
56 CIRCUIT CELLAR • AUGUST 2014 #289

THE CONSUMMATE ENGINEER

The Humble Resistor (Part 1)


Fixed Resistors

Resistors are the most common parts in


electronic circuits. This article provides an
overview of fixed resistors and touches on
COLUMNS

their values and power varieties.

By George Novacek (Canada)

E lectrical resistance is omnipresent.


Every circuit exhibits it, whether
it’s due to the presence of resistors or
in American- and European-style diagrams.
In the latter, the decimal point is omitted,
such that 0.3 Ω would be written as 0R3, 3.3
inherent characteristics of components Ω = 3R3, 1.5 kΩ = 1k5, 0.1 MΩ or 100 kΩ =
and conductors. Negative resistance is also M1 or 100 k, 2.2 MΩ = 2M2 and so forth. (A
recognized, but this is not a topic for this similar notation is used for capacitors.)
article. Figure 1 shows the American (a) or
International Electrotechnical Commission RESISTOR VALUES
(IEC) (b) symbols schematic diagrams use to Resistors come in standard values that
represent resistors. Photo 1 shows a variety are related to their tolerances (custom values
of different through-hole fixed resistors. could be ordered for a price). For example,
When a resistor is connected to a voltage 10% resistors have 12 values fitting into a
source, a current with a magnitude related to decade (e.g., 10 Ω to 100 Ω). Consequently, the
the voltage by Ohm’s law: series is called E12. To refresh your memory,
V the values are listed in Table 1. Successive
I= values in a series are related approximately
R
by a factor:
flows through it. The current is expressed
in amperes, while voltage is a potential n
10
difference across the resistor terminals in
volts. The resistance R is expressed in ohms. where n = 12, 24, 96, or 192, respectively. The
In addition to the ohm (Ω), common E24 series is used for 2% and 5% resistors
resistance units include milliohm (1 mΩ = 10 –3 (see Table 2). Table 3 lists 1% resistors,
Ω), kilohm (1 kΩ = 103 Ω), and megohm (1 MΩ which come in E96 series.
a) = 10 6 Ω). In circuit analyses it is sometimes Most of the time digital projects can be
convenient to use a reciprocal of resistance accomplished with 5% (i.e., E24 resistor
called conductance: values), occasionally requiring 1% values). In
b) 1 series E192, 0.1%, 0.25%, and 0.5% values are
G=
R available with 192 values per decade. Unless
you work with precision analog circuits, you
FIGURE 1 In Europe conductance is referred to as are not likely to need those.
These symbols denote (a) American Siemens or, mostly in English texts, as mho (1 Present-day resistor manufacturing
or (b) International Electrotechnical S = 1 mho = 1 Ω–1). technology is so refined and economical
Commission (IEC) resistors. Resistor values are also written differently that 10% tolerance resistors have almost
circuitcellar.com 57

disappeared from the marketplace. This has


not always been so. There were times when—
mainly due to the cost—20% devices had to be
used. Because resistor manufacturers tested
and categorized their production runs into
tolerance bands, only values between ±10%
to ±20% of the nominal could be found in
a 20% resistors batch (i.e., 80 to 90 Ω and
110 to 120 Ω for the specified 100 Ω). It was
often necessary to use an ohmmeter to select
matching resistors. Paradoxically, it was
beneficial to the quality of designs. Engineers
had to work hard to make their circuits accept

COLUMNS
wide tolerances and minimize the need for
precise values as much as possible.

SELECTING RESISTORS
Many characteristics must be considered
when selecting resistors for specific functions.
The most common ones are resistance, its
PHOTO 1
tolerance, and power dissipation. I try to resistors become hot, their resistance may
Various fixed resistors are shown.
minimize the use of resistors with values change, and the reliability will diminish. I
that are not above 1. With the exception of derate resistors to operate at no more than
one project, I never had to exceed 10 MΩ. 50% of their power rating.
High resistance values in conjunction with Engineers must also consider all the
input capacitances of active components desired characteristics such as temperature
(e.g., MOSFETs) create low-pass filters and coefficienct, working voltage, and through-
limit bandwidth. Worse, their values are hole or surface mount device (SMD). My
susceptible to PCB leakage due to humidity, favorite resistors are metal film, type ERL.
moisture ingress, dirt, and so forth. If you
need resistors larger than 1 MΩ, be careful POWER DISSIPATION
with the layout. Make sure the PCB is well Power dissipated by a resistor is calculated
cleaned after the assembly and conformally as:
coated to ensure long-term stability. V2
Most microelectronic circuits are quite P = I2 × R = I × V =
R
happy with 0.125-to-0.5-W resistor power
ratings. It is a bad idea to use resistors where V is the voltage across the resistor,
rated close to their in-circuit dissipation. The I is the current flowing through it, R is the

TABLE 1
10 12 15 18 22 27 33 39 47 56 68 82 Resistor values are related to their
tolerances. These are the E12
resistance series values.
10 11 12 13 15 16 18 20 22 24 27 30 TABLE 2
33 36 39 43 47 51 56 62 68 75 82 91 E24 resistance series values are
shown.

10 10.2 10.5 10.7 11 11.3 11.5 11.8 12.1 12.4 12.7 13


13.3 13.7 14 14.3 14.7 15 15.4 15.8 16.2 16.5 16.9 17.4
17.8 18.2 18.7 19.1 19.6 20 20.5 21 21.5 22.1 22.6 23.2
23.7 24.3 24.9 25.5 26.1 26.7 27.4 28 28.7 29.4 30.1 30.9
31.6 32.4 33.2 34 34.8 35.7 35.6 37.4 38.3 39.2 40.2 41.2
42.2 43.2 44.2 45.3 46.4 47.5 48.7 49.9 51.1 52.3 53.6 54.9
56.2 57.6 59 60.4 61.9 63.4 64.9 66.5 68.1 69.8 71.5 73.2
75.0 76.8 78.7 80.6 82.5 84.5 86.6 88.7 90.9 93.1 95.3 97.6

TABLE 3
These are the E96 resistance series values.
58 CIRCUIT CELLAR • AUGUST 2014 #289

resistance, and P is the dissipated power in Metal film resistors, available as SMDs
watts. The total amount of energy dissipated and through-hole, have been quite popular.
over time is: Their bodies are usually coated with nickel
chromium (NiCr) into which—similar to
t2
carbon composition resistors—a helix is cut.
W= ∫ v (t ) i (t ) dt
t1
Metal film resistors are available with 0.5%,
1%, 2%, and sometimes 10% tolerances.
and the average power dissipated over a Metal film resistors have very low noise,
specific period is: about 20 dB below that of thin film devices. A
typical temperature coefficient is between 50
t2
1 and 500 ppm/°C and they have a maximum
P =
t2 − t1
× ∫ v (t ) i (t ) dt
t1
100-to-500-V working voltage.
Wire wound resistors are made, as
COLUMNS

This means that many resistors can, in a the name implies, by winding a wire (e.g.,
pulse, dissipate large power many times their nichrome) around a nonconductive body. These
ABOUT THE AUTHOR rating. The maximum pulse dissipation is resistors can operate at high temperatures
George Novacek is a often specified, but it is crucial to check the and dissipate a lot of power. Some wire
professional engineer high voltage rating as well. wound resistors are attached to a heatsink
with a degree in Cyber- My engineers once substituted momentarily for better heat dissipation (see Photo 1).
unavailable carbon film resistors we used in They can be built with 0.005% tolerance, a
netics and Closed-Loop
lightning protection circuits with metal film 3 ppm/°C temperature coefficient, and can
Control. Now retired, he
resistors, without checking their maximum withstand 5,000 V of electrostatic discharge
was most recently pres-
voltage rating. The resulting fireworks in (ESD). They have parasitic inductance larger
ident of a multinational
the course of lightning susceptibility tests than other technologies, but this can also be
manufacturer for em- were spectacular. The second controller a benefit as mentioned above.
bedded control systems was refitted with high-voltage wire-wound
for aerospace applica- resistors. Their performance was superior THICK AND THIN FILM
tions. George wrote 26 to the original carbon film, also due to their RESISTORS
feature articles for Cir- parasitic inductance. In non-critical applications, carbon
cuit Cellar between 1999 resistors may be printed directly on a PCB.
and 2004. Contact him RESISTOR VARIETIES Thick and thin film resistors are seen mainly
at gnovacek@nexicom. Carbon composition resistors are an as SMDs. The chief difference between thick
net with “Circuit Cel- old technology. Their long-term stability is and thin film resistors is the manufacturing
lar”in the subject line. poor and, because of their noise, they are process. Thick film is typically 10 to 50
unsuitable for low-signal applications. But µm, while thin film is 10 nm to 2 µm. In
their working voltage can be around 500 V. manufacturing, thick film is fabricated by silk
In my first semester at university, we were screening conductive and resistive materials
given blank carbon resistor bodies. We used a in a pattern on a substrate. The resistors are
machine similar to a lathe to cut a helix into designed to be on the low side and are then
their resistive surface to make resistors of laser trimmed for the required value.
given values. Getting anywhere close to ±20% Thin film resistors are fabricated by
of the desired value was quite a feat. Yet, this etching conductive and resistive materials
is how resistors were made in factories, then previously vacuum deposited on a substrate
sorted and marked with values. and then laser trimmed. In general, thin
Carbon film resistors are made by film resistors perform better than their
depositing carbon film on an insulating thick film, less expensive counterparts. Their
substrate. Their working voltage ranges up temperature coefficient is about 5 ppm/°C
to about 1,000 V and their noise is much compared with 50 ppm/°C for thick film
lower than that of their carbon composition resistors. They can withstand 2,500 V ESD as
predecessors. Because of their high pulse opposed to 2,000 V for thick film resistors and
stability, they are popular in transient their noise is about –40 dB (i.e., 1%) of thick
protection circuits. film resistors. Thin film resistors can be built
with 0.05% tolerance, thick film resistors can
be built with 0.5%.
RESOURCES I discussed the most common resistors.
TT Electronics, plc, “Ultra High Value Resistors,” There are also many “exotic” types, such as foil
2011. resistors, glass-encapsulated ultra-high value
resistors with values up to 100 TΩ (1014 Ω),
Vishay, “Metal Film Resistors, Military/Estab- carbon pile , water, grid, and others, which are
lished Reliability, MIL-PRF-39017 Qualified, too specialized to discuss at this time. In Part 2
Type RLR,” ERL (Military RLR), 2012. of this article series, I’ll discuss variable
circuitcellar.com/ccmaterials resistors.
Flash enables new designs in consumer,
computer, and enterprise products.
Are you struggling with crucial Solid State Drive (SSD) decisions? Can SSDs resolve your application bottlenecks?
How can you maximize SSD performance? Flash Memory Summit will explore new frontiers in enterprise storage
and help you make the right choices. Summit topics include:
Solid state drives • Enterprise storage • All-flash disk arrays • Controllers
PCIe SSDs/NVMe • Application acceleration • 3-D flash • Market research
Security • Standards • Interfaces • Cloud computing • Consumer/mobile applications
Embedded applications • Data recovery/erasure
Plus Keynotes by NetApp, Samsung, Microsoft, Dell, SanDisk, IBM, Diablo,
Marvell, Fusion-io, PMC-Sierra, Nimbus, Cadence

August 5 -7, 2014


and next year:
August 11-13, 2015
Santa Clara Convention Center
Santa Clara, CA
Don’t miss this important event!

REGISTER ONLINE
www.FlashMemorySummit.com
Readers of Circuit Cellar Magazine: Enter priority code SPGP for a $100 discount.
60 CIRCUIT CELLAR • AUGUST 2014 #289

THE DARKER SIDE

Shielding Experiments
Electromagnetic shielding protects
against RF radiation. However, adding
shielding is not as easy as it sounds.
This article describes some
shielding experiments and
encourages readers to conduct
a few tests of their own.
COLUMNS

By Robert Lacoste (France)

W elcome to the Darker Side. This column


is devoted to “black magic” subjects, but
this month I will discuss a topic even more
wire) can conduct the perturbations quite
easily and would render a shield useless. Try
separating the power supplies, using batteries
obscure than usual: shielding. Of course I am if possible. Try adding some ferrite clamps
talking about electromagnetic shields, nothing on all wires. Try adding filtering capacitors
related to armors or Arduino extensions. on all interconnecting wires. Is the problem
Assume you are suffering from interference diminished at all? If yes, it will be a good idea
between two electronic systems, an offender A to solve these conducted perturbations at
and a victim B. If you ask for advice you will least as a first step. You may also try to shield
usually get an answer such as, “Easy, just add the interconnecting cables before blaming the
some shielding!” But is it so easy? board, as a cable is a very good antenna. (Refer
to my article “Cable Shielding Experiments,”
IS A SHIELD REQUIRED? Circuit Cellar 219, 2008.)
Adding a shield on an electronic device If you are sure that the issue is a radiated
could be a good advice, but I encourage coupling between the two systems, what
you to double check all other solutions first. do you do next? Before dealing with board
Why? Because shielding is always complex shielding I encourage you to try to either
and expensive as I will explain in a minute. reduce the perturbations radiated by the
Moreover, it simply may not solve the problem. offender or to increase the victim’s immunity.
A shield protects against RF radiation. How? Try to reduce the amplitude of the
Therefore you must verify that the offender’s signals, as it will make them more
perturbation is indeed radiated from system harmless. You can also increase the impedance
A to system B. This may not be the case if of the noisy signals still on the offender’s side.
there is any wire between the two systems. Reciprocally, try to increase the amplitude of
For example a common power supply (e.g., the victim’s signals, as it will make them more
circuitcellar.com 61

resistant. Also try to reduce the impedance


of all susceptible signals. Adding a 100-Ω
resistor to ground can be magical.
The last common trick is to reduce the
edge rates of all digital signals (e.g., by using a
slower digital technology), as it will drastically
limit their harmonics. Recently one of my
colleagues reduced the harmonics radiated
by a 13.56-MHz power amplifier by 10 dB by
adding a small resistor between a fast logic
driver and the power MOSFET’s gate.
Now assume that everything else failed
and you will need to add a shield on either

COLUMNS
the offender A or the victim B. Theoretically,
both solutions provide the same result.
Shielding the offender is cleaner for the other
potential victims, whereas shielding the
victim may be a better idea if other source
of perturbations can appear in the vicinity.
So this choice will be design-dependent. Of
course you can also shield both, but it will be
twice as expensive.

SHIELD EFFICIENCY
What can you reasonably expect in terms PHOTO 1
of noise reduction with a shield? Plenty of I designed a test PCB using only a 50-Ω microstrip track terminated on a 50-Ω resistor to ground. This
“shield efficiency calculators” are available makes a low-cost wideband test antenna.
online (see Resources). Such tools provide the
theoretical attenuation at a given frequency build my PCBs, so the track width for 50-Ω
for a given sheet of metal. Theory is great, impedance was 3 mm.
but real life is always a little trickier. Such a microstrip circuit acts as a
I will share some experiments I’ve done. very wideband antenna, even if it is a low-
The idea was to build a simple test setup to efficiency antenna. It could be used to either
measure some typical shields’ actual efficiency. generate perturbations by connecting it to
But how do you define “efficiency?” I stayed a signal source, or to measure the received
as close as possible to real-life situations
and assumed that two configurations were
representative. HP 71200C Spectrum analyzer
First, the offender and victim could be very
close to each other. For example, this appears
if the two subcircuits are on the same PCB. In
that case, the coupling is usually either purely
magnetic or is a close-field electromagnetic
coupling. Track RF
The second common configuration is when out IN

the two systems are a couple of meters away.


In that case, the coupling is usually a classic
far-field electromagnetic type and the theory
is simpler. HP8447F HP8447D
Let’s start with the close-field case. How Amplifier Amplifier

can the actual efficiency of a given shield IN1


0.1 to 1,300 MHz
26 dB OUT1 IN1
0.1 to 1,300 MHz
26 dB OUT1
in such a situation be measured? First I IN2 0.009 to 50 MHz OUT2 IN2 0.1 to 1,300 MHz OUT2
needed to experiment with a “typical” set of 28 dB 26 dB

offenders and victims. I etched two identical


test PCBs. Each circuit included a 5-cm long
Shield under test
50-Ω microstrip track terminated with a
50-Ω resistor to ground. Remember that a Test PCBs with microstrip antenna
microstrip is a track of a precise width on the
PCB’s top side and a full ground plane on the
FIGURE 1
bottom side. (Refer to my article, “Microstrip The test setup included two test PCBs side by side. One PCB was driven by a tracking RF generator and the
Techniques,” Circuit Cellar 223, 2009.) I used other was connected to a spectrum analyzer’s input to measure the received signal strength. Using two
a standard, 1.6-mm thick FR4 substrate to amplifiers improved the dynamic range.
62 CIRCUIT CELLAR • AUGUST 2014 #289

perturbations on the victim side using a


spectrum analyzer. I added an SMA connector
on the PCB’s bottom side to easily connect to
the RF source or analyzer. Then I added some
holes to fix a shield, an extra ground plane
on the top layer everywhere except inside
the shielded area, and plenty of ground vias
(see Photo 1). I used Labcenter Electronics’s
Proteus tool suite to develop the computer-
aided design (CAD) file. (The file is available
for download on Circuit Cellar’s FTP site if you
would like to rebuild it.)
To have a complete test setup I then
COLUMNS

positioned both boards face to face, around


20 cm from each other. I connected them
to my trusty old Hewlett-Packard HP71200C
spectrum analyzer, which is available in my
company’s lab. This equipment includes a
Hewlett-Packard HP70300A tracking generator
PHOTO 2 module, which transforms it into a scalar
The test setup is shown. network analyzer. The tracking generator
provides a test carrier signal aligned with the
frequency measured by the analyzer. It may
a)
be more difficult, but you could use any RF
signal generator and a standard spectrum
analyzer to make the same measurements.
The test procedure is simple: Start with
the two boards face to face without any shield.
Sweep the offender’s signal frequency from 1
MHz or so to the desired upper frequency (e.g.,
1 GHz). Measure how much power is received
on the victim’s side at each frequency. This
is your reference. Then add a shield on one
of the boards and do the measurement
again in the same conditions. The difference
between the two measurements will give the
attenuation provided by the shield, which will
be frequency-dependent. Figure 1 shows the
overall test setup. I just added some extra
amplifiers to increase the measurement
sensitivity. Photo 2 shows the actual
experiment.

b) 3-D PRINTED SHIELDS


I recently received my first 3-D printer,
a MakerBot Replicator 2X. This experimental
printer is a dual-head unit that is optimized
for acrylonitrile butadiene styrene (ABS)
filaments. ABS is a little less common than the
usual poly lactic acid (PLA) used on low-cost
3-D printers, but I ordered this configuration
assuming it would enable me to build more
robust parts.
What about trying to use a 3-D printer to
manufacture a shield? The idea may seem
silly since ABS—like nearly all plastics—is
nonconductive, but I wanted to give it a try.
My first idea was use a standard ABS filament
PHOTO 3 to 3-D-print a shield and then use a conductive
a—Looking at a 3-D printer in action is a hypnotic experience. b—I used a MakerBot Replicator 2X paint to paint it. This type of paint is indeed
3-D printer to build this acrylonitrile butadiene styrene (ABS) shield, which is shown after I applied the often used to “shield” plastic enclosures and
electromagnetic (EMC) paint on the inside. I always wondered if it was really effective.
circuitcellar.com 63

This test was a good way to find out.


Using the 3-D printer to design and
manufacture the ABS shield took me less than
1 h. I simply used a common CAD Drawing
Exchange Format (DXF) to export the outline
of the required shield from my PCB CAD tool.
Then I launched Punch!CAD Labs’s ViaCAD
3-D design software. I imported the DXF file,
extended it to a 3-D object, and exported the
corresponding stereolithography (STL) file.
The last steps were to import the STL file
from MakerBot’s software, click on “print,”
and voila! (The files are available at Circuit

COLUMNS
Cellar’s FTP site.)
Photo 3a shows the printer working.
I used two layers of Kontakt Chemie’s EMI-
35 electromagnetic (EMC) paint to paint the
inside of the resulting part (see Photo 3b.)
The result is pretty nice, but what about its
RF performance?
Photo 4 shows the results of the test
using the previously explained procedure. I
measured an attenuation of about 10-dB in the
PHOTO 4
lowest frequencies, up to 150/180 MHz. This is
This plot shows the measured signal strength with the conductive acrylonitrile butadiene styrene (ABS) shield
actually not too bad as a 10-dB attenuation (yellow) as well as the reference signal with no shield (blue). The shield efficiency is the difference between
means that 90% of the perturbations are no both curves. In this plot it is around 10 dB up to 150 MHz but virtually zero above that frequency.
longer transmitted. However, the attenuation
was close to 0 dB for frequencies above this
limit and up to 2 GHz at least. Why? This is ground plan (i.e., I created a continuous
probably because the EMC paint I used is not solder joint all around it). Photo 5 shows the
efficient for high frequencies. So, EMC paint results. I used the same test configuration to
can solve your problem, if you are just looking measure the shield effectiveness again (see
for a couple of decibels of improvement, but Photo 6). I measured a 20-dB attenuation in
use this paint with caution. low frequencies, 25 to 30 dB from 400 MHz to
I wanted to give 3-D printed shields another 1.5 GHz, and around 20 dB at 2 GHz.
chance, so I bought a roll of conductive ABS How do you interpret these results? First,
filaments. These are plastic with some very using a metallic shield is obviously far better
limited conductivity (some kilo-ohms per
centimeter) but I thought it could slightly
improve the shielding effectiveness. I used
these filaments to print another part, added
two layers of EMI-35 paint to be safe, and
retested it. The resulting performance
was not significantly better than with the
standard ABS filament (still around 10-dB
attenuation up to 200 MHz or so), but close
to zero above that limit. I assume this is due
to the “conductive” plastic’s high resistance. I
suppose this material could be interesting for
electrostatic dissipation, but I need to wait
for improved conductive filaments before
using them for RF.

USING METALLIC SHIELDS


What about trying a standard metallic
shield? What efficiency could you expect? I
grabbed an off-the-shelf shield and soldered
it on the victim’s test board. First, I just
soldered the shield through its six pins. The
measured attenuation, which was around 15
to 20 dB, was quite deceptive. Then I took PHOTO 5
the time to properly solder the shield to the A metallic shield can provide improved attenuation, as long as it is properly soldered.
64 CIRCUIT CELLAR • AUGUST 2014 #289

frequencies? This was probably because the


coupling was then more magnetic than EMC,
and a non-ferromagnetic metal doesn’t stop
magnetic coupling.

FAR-FIELD COUPLING
After performing these experiments in
near-field conditions, I wanted to check if these
measurements were more or less consistent
with far-field conditions. Fortunately, I have
access to an anechoic chamber, which is ideal
for these kinds of measurements. An anechoic
chamber basically emulates an “open-field”
COLUMNS

situation, as if you were testing an RF device in


the middle of nowhere. There are no external
perturbations and no signal reflections on
the walls, just a clean line of sight path. I
installed one of the test PCBs in the chamber,
connected it to a RF generator set to a 1-GHz
continuous wave, and measured the 1-GHz
signal received by a test antenna three meters
away (see Photo 7). This gave me a reference
PHOTO 6
level. Then I added a metallic shield on the
Here is the received signal strength with the metallic shield (yellow), compared with the reference signal with
PCB and measured the signal’s attenuation.
no shield (pink). The blue curve shows the minimum detectable signal and was measured with a 50-Ω load in
place of the transmitting PCB. A 20-to-30-dB attenuation is measured for all frequencies up to at least 2-GHz.
I got an attenuation of about 20 dB. This
was roughly consistent with the close-field
measurements; remember that I got around
than using a conductive paint, especially at 25 dB. Next I replaced the metallic shield with
high frequencies. Then even a metallic shield the 3-D-printed conductive ABS shield. This
is not perfect. Achieving a 20-dB attenuation time I measured a 10-dB attenuation.
(i.e., 99% of the perturbations are blocked) How does this fit with near-field
is easy when the shield is properly soldered, measurements? Remember that the
but going higher is not trivial. And shield conductive ABS shield provided nearly no
soldering must always be done on all its attenuation at 1 GHz at close distance, but
sides, not just through its legs. Why was it still reduced the far-field signal by 10 dB.
the measured shield efficiency lower in low Why? Honestly, I don’t have a clear answer.
I guess this is due to the quite complex
behavior of near-field coupling. Perhaps this
shield still perturbates the wave propagation
PROJECT FILES Circuit Cellar 223, 2009. through its electric component even if it
doesn’t change magnetic close-field coupling,
LearnEMC, “Shielding theory,” www.learnemc. and this reduces the corresponding generated
com. far field by 10 dB? That’s my explanation, I
will be glad to hear yours!
SOURCES WRAPPING UP
HP71200C Spectrum analyzer HP70300A
The experiments I presented in this article
tracking generator module
don’t pretend to be science, they are just
circuitcellar.com/ccmaterials Hewlett Packard Co. | www.hp.com
experiments. Therefore they should be used
(Product now obsolete, available from distrib-
with caution. Anyway these tests show some
utors such as eBay)
RESOURCES orders of magnitude. First a well-soldered
The Clemson University Ve- metallic shield easily provides a 20-to-
Proteus Design suite
hicular Electronics Laboratory 30-dB attenuation between two circuits,
Labcenter Electronics | www.labcenter.com
(CVEL), “Shield Effectiveness except at very low frequencies and a close
Calculator, www.cvel.clemson. distance where magnetic coupling is the main
ViaCAD 3-D Design software
edu. contributor. Getting an attenuation higher
Punch!CAD Labs | www.punchcad.com
than 20 to 30 dB is significantly more difficult
R. Lacoste, “Cable Shielding as small leaks could happen everywhere.
Replicator 2X 3-D printer
Experiments,” Circuit Cellar Moreover, it is probably easier to work on
MakerBot | http://store.makerbot.com
219, 2008. the circuits themselves (e.g., reducing the
signals speeds, improving the immunity of
———, “Microstrip Techniques,” the victim, etc.).
circuitcellar.com 65

PHOTO 7
The test PCB is shown positioned in
an anechoic chamber (front), whereas
the receiving test antenna is at the
back.

COLUMNS
ABOUT THE AUTHOR
Robert Lacoste lives
in France, near Par-
is. He h as 25 years
of experience in em-
bedded systems,
analog designs, and
wireless telecommuni-
cations. A prize winner
in more than 15 inter-
national design con-
tests, in 2003 he start-
ed his consulting com-
pany, ALCIOM, to share
his passion for innova-
tive mixed-signal de-
signs. His book (Rob-
ert Lacoste’s The Dark-
er Side) was published
by Elsevier/Newnes in
2009. You can reach
him at rlacoste@alciom.
com. Don’t forget to put
“darker side” in the sub-
What about 3-D printers? They are great, will be a little more complex if you need 50-dB ject line to bypass spam
and I’m sure I will use my printer often for improvement. filters.
packaging, fixing parts, and so forth. However, Finally, as usual, I strongly encourage you
the use of conductive ABS filament alone to experiment. You probably don’t have an
doesn’t provide an effective shielding against anechoic chamber in your cellar, but your
RF fields, at least using the currently available neighbor’s field could be as adequate on a
filaments. Using conductive ABS filament and sunny day. If you don’t have an RF signal
conductive EMC paint enables better—but still generator you can easily build one. And if you
limited—results. With this solution you can don’t have a spectrum analyzer and don’t
expect around 10-dB attenuation, but nearly have enough spare time to build one, you can
no attenuation at a close distance above some still use a radio receiver or borrow one. You
200 MHz. The same result will be achieved have no excuse: you need to play with shields
by adding a couple of EMC paint layers in a to understand what’s going on. If not, well,
plastic casing. Don’t get me wrong: 10 dB is you will need to learn it the hard way the day
still a huge improvement and could solve your you have no other solution and a manager or
problem, but you need to know that your life customer is crying over your shoulder.
66 CIRCUIT CELLAR • AUGUST 2014 #289

FROM THE BENCH

IR Remotes
(Part 1)
Remote Transmission
COLUMNS

What is the difference between


By Jeff ambient IR and data-carrying IR?
Bachiochi (US) This article series describes IR and
introduces IR formats. Part 1 focuses
on accumulating and recognizing an
IR remote transmission.

W hen it comes to
audio and video
(AV) in dens, IR remote
of the Netherlands. His website, SB-Projects,
has pages devoted to IR remote control
theory and includes an abundance of various
controls still dominate. IR protocols. I’ll take a brief look at IR and
Since most AV components a simple protocol before delving into my
come with their own remote project, which begins by accumulating and
control, our homes tend to recognizing an IR remote transmission.
gather them like single socks on
laundry day. In fact, IR control can I THINK, THEREFORE IR
be found accompanying many other It may have been René Descartes who
devices (e.g., lighting, ceiling fans, and air first said this during his early work with
conditioners). It’s as if someone wants us infrared control: Infrared is that part of the
to remain seated in our comfy chairs so we electromagnetic spectrum (700 to 1,000 nm)
wouldn’t miss the latest gadget being pitched that is just above visible light (violet 380 to
to our subconscious. red 700 nm). While we can’t see it directly, we
Somewhere along the line someone have sensors that can emit and detect it. LEDs,
suggested combining multiple controls like standard diodes, use semiconducting
into a single remote. Universal remotes materials doped with impurities to create a
have been around for years. The problem p-n junction. LEDs can emit photons when
is manufacturers continue to expand IR their p and n materials have a direct band
codes for their equipment, which makes gap crystalline structure (e.g., the electron
older universal remotes incompatible. Yes, or hole can cross the gap without a loss in
some universal remote controls (URCs) are their momentum). The materials used affect
upgradeable and, as long as the data format the bandgap (voltage drop) and a photon’s
can be described in established parameters, wavelength (color) as shown in Table 1.
this solves the problem. Photo diodes and photo transistors are
Another problem is there are many semiconductor devices that convert light into
standards, and most manufacturers are current when photons are absorbed. Solar cells
keeping their cards close to their vests. The are p-n photodiodes with large surface areas
most complete information I’ve found about and slow response times. A slightly modified
IR control was collected by San Bergmans p-i-n junction improves a photodiode’s
circuitcellar.com 67

Wavelength Voltage
Color Semiconductor material
(nm) drop (∆V)
Gallium arsenide (GaAs)
Infrared λ > 760 ∆V < 1.63
Aluminium gallium arsenide (AlGaAs)
Aluminium gallium arsenide (AlGaAs)
Gallium arsenide phosphide (GaAsP)
Red 610 < λ < 760 1.63 < ∆V < 2.03
Aluminium gallium indium phosphide (AlGaInP)
Gallium(III) phosphide (GaP)
Gallium arsenide phosphide (GaAsP)
Orange 590 < λ < 610 2.03 < ∆V < 2.1 Aluminium gallium indium phosphide (AlGaInP)
Gallium(III) phosphide (GaP)

COLUMNS
Gallium arsenide phosphide (GaAsP)
Yellow 570 < λ < 590 2.1 < ∆V < 2.18 Aluminium gallium indium phosphide (AlGaInP)
Gallium(III) phosphide (GaP)
Traditional green:
Gallium(III) phosphide (GaP)
Aluminium gallium indium phosphide (AlGaInP)
Green 500 < λ < 570 1.9< ∆V < 4
Aluminium gallium phosphide (AlGaP)
Pure green:
Indium gallium nitride (InGaN) / Gallium(III) nitride (GaN)
Zinc selenide (ZnSe)
Indium gallium nitride (InGaN)
Blue 450 < λ < 500 2.48 < ∆V < 3.7
Silicon carbide (SiC) as substrate
Silicon (Si) as substrate, under development

Violet 400 < λ < 450 2.76 < ∆V < 4 Indium gallium nitride (InGaN)

Diamond (235 nm)


Boron nitride (215 nm)
Ultraviolet λ < 400 3.1 < ∆V < 4.4 Aluminium nitride (AlN) (210 nm)
Aluminium gallium nitride (AlGaN)
Aluminium gallium indium nitride (AlGaInN)-down to 210 nm
TABLE 1
The relationship between an LED’s color, wavelength, bandgap, and materials used is shown. The IR LED’s junction has the lowest voltage drop. (Information courtesy of Wikipedia,
“Light-Emitting Diode”)

response time. When a photon of sufficient carrier frequency outside the interference
energy strikes the diode, it creates an electron- band, it takes on a unique signature. An
hole pair that separates in the material under approximately 40-kHz modulation frequency
the effect of the depletion zone’s electric field, fills this requirement while staying under
thus generating a current. If the junction the phototransistor’s frequency response.
exposed to light is part of a transistor, then Early remotes used inexpensive ceramic
the current generated can be amplified by the resonators (i.e., 429/432/455 kHz) already
transistor’s beta (gain). used in intermediate frequency (IF) stages of
When an IR LED and a phototransistor are AM radios. Since an IR controller’s modulation
to be used as an IR transmitter receiver pair, was often a division of its time base, several
they must be positioned so the transmitter’s different carrier frequencies can be found.
emitted energy is sufficient to reach the receiver While the first IR receivers were made of
either directly or indirectly. For my purposes, discrete parts, today you can purchase IR
a 10’-to-20’-distance is adequate. The first demodulators that contain the photo diode
thing you may find is that a phototransistor amplifier (with automatic gain control) and
will pick up a wide range of frequencies from a demodulator in one three-pin package for
the environment (see Figure 1). At times this less than $1 (see Figure 2). Minimum (and
can be sufficient enough to corrupt the data maximum) IR bursts are recommended for
you are trying to send. these devices to operate correctly.
How can you discern the difference Return-to-zero data formats ensure that
between ambient IR and data-carrying long streams of continuous modulation are
IR? By modulating the IR data with a avoided. Pulse position modulation (PPM)
68 CIRCUIT CELLAR • AUGUST 2014 #289

FIGURE 1 any IR remote sending a transmission. This


This graph shows the response
seemed like a good place to start.
of a silicon photo diode or 0.6 A/W
I used a circuit I had previously built
transistor vs wavelength of
the incident light. The device is
0.5 A/W consisting of a 28-pin microcontroller with all
most sensitive in the 950-nm 0.4 A/W
the I/O brought out to a prototyping area. I
IR range. added an IR receiver and connected this to the
Response 0.3 A/W counter timer input on the microcontroller. I
0.2 A/W
used a Microchip Technology PIC18F26K22
microcontroller because it will run at 64 MHz
0.1 A/W with its phase locked loop (PLL). Timers 1, 3,
0 and 5 can run directly from this 64-MHz source.
400 nm 600 nm 800 nm 1,000 nm Timers 2, 4, and 6 can provide a capture signal
Wavelength from either an external rising or a falling edge.
COLUMNS

This edge can also provide an interrupt trigger.


When the IR receiver changes state—a falling
and Manchester encoding are two popular edge indicating it is seeing a mark (modulated
techniques (see Figure 3). PPM uses a single IR signal) or a rising edge indicating a space
“10“ pulse for each bit. The duration of the (loss of an IR modulation signal)—the interrupt
1 (mark or modulation ON) and 0 (space or routine is called.
modulation OFF) times are the key to the bit This input is either rising or falling. Once
value. Typically, a bit value = 0 is represented the selected edge has triggered the interrupt
by a mark and space of equal time. A bit value routine, one of the interrupt routine’s functions
= 1 has a space time of twice the mark time. must be to reconfigure the input to look for
In some cases, additional space times of three the opposite edge the next time. I know an IR
and four times the mark time can be used to transmission begins with IR modulation, so I
indicate twin data bits (see Table 2). began looking for a falling edge (mark). The IR
Manchester encoded data is determined receiver pulls its output low whenever it sees
by the state, mark, or space that is first an IR-modulated signal. When this happens,
presented in each bit time. In Table 2, a the latched count (number of 64-MHz cycles
space preceding a mark equals a bit value = 1 since the last interrupt) is saved.
and a mark before a space is a bit value = 0. If you reset the counter, all future counts
In many cases the data to be sent is will be reference to a zero starting count.
wrapped up for delivery. This wrapping is Once the modulation ceases, the mark ends
simply some leading and trailing signal that and the receiver will permit its output to
is distinctively different from the data. If you return high. Since the microcontroller’s input
could see an actual IR transmission, you would was reconfigured to look for a rising edge
see periods of modulated IR (mark) and periods during the last interrupt, the beginning of the
of nothing (space). The IR would be modulated space (idle time with no modulation) is seen
at an on/off rate of somewhere between 33 to as another interrupt. The interrupt routine
60 kHz. With a modulation rate of 40 kHz, you directs execution based on the selected edge,
might expect minimum mark and space times so you can track the mark and space counts.
of 1/10 the modulation rate or 4 kHz (250 µs). It is best to spend as little time in an interrupt
The IR receiver/demodulator removes the 40 routine as possible so it doesn’t negatively
kHz, providing an output that is low during IR affect other interrupts. I let the main loop
transmission bursts (mark). process the data collected by these edge-
triggered interrupts.
INFRA READ
So, how could you see these transmissions? STREAMING DATA
If you used one of the demodulating receivers, I’d like these counts delivered to my PC in
you could look at the device’s reaction to real time by sending the state and count out
through the microcontroller’s serial port. Going
by my earlier guesstimate of 250 µs per state,
I could send about four characters at 115,200
3
bps in that amount of time. That didn’t sound
30 kΩ good. I would need to send at least twice that.
1
So much for a real-time display.
FIGURE 2
Band At 64 MHz, each count would be
Many distributors sell inexpensive Input AGC Demodulator
and complete IR demodulators
pass approximately 15 ns/count. A 250-µs burst
in single three-pin packages. would therefore have a 250/0.015 count or
The demodulator packages are PIN
2 approximately 16,000. That’s a big number
Control circuit
usually available in 30-to-56-kHz just to indicate one bit time. I don’t need
carrier frequencies. anywhere near that kind of resolution.
When it
comes to
robotics,
the future
is now!
From home control systems to
animatronic toys to unmanned
rovers, it’s an exciting time to
be a roboticist. Advanced Control Robotics
simplifies the theory and best practices of
advanced robot technologies, making
it ideal reading for beginners and experts
alike. You’ll gain superior knowledge of
embedded design theory by way of
handy code samples, essential schematics,
and valuable design tips.

With this book, you’ll learn about:


• Communication Technologies
• Control Robotics
• Embedded Technology
• Programming Language
• Visual Debugging... and more

Get it today at ccwebshop.com.


70 CIRCUIT CELLAR • AUGUST 2014 #289

FIGURE 3
a) 00000000 1 1 1 1 1 1 1 1 1 0 1 1 0 1 0 1 0 1 00 1 0 1 0
a—This message frame uses the NEC
IR transmission protocol with pulse
position encoding. b—This message
frame uses the Philips RC5 IR
transmission protocol with Manchester
encoding.
LSB LSB LSB LSB
9 ms Address Address Command Command
4.5 ms (Logical inverse) (Logical inverse)

27 ms 27 ms

67.5 ms

b)
Bit 1 Bit 2 Bit 3 Bit 4 Bit 5 Bit 6 Bit 7 Bit 8 Bit 9 Bit 10 Bit 11 Bit 12 Bit 13 Bit 14
COLUMNS

1 1 0 0 0 1 0 1 1 1 0 1 0 1

S1 S2 T MSB MSB

Start bits Toggle Address Command


bit
5.334 ms 8.89 ms 10.668 ms

24.892 ms

Choosing a slower clock rate (1 µs) will still miss an edge, I would really miss two edges
provide plenty of resolution (250 counts per and not know it! So, I used two external
bit). I can use a word register to handle counts interrupt pins tied together instead of the
up to 64,535 (µs). If I’m not trying to display counter/timer input. I could configure the
the data in real time, I should have plenty inputs for opposite edges and therefore be
of time to store it away in a buffer for later able to detect a missing count should two of
display. The data format is 3 bytes: ASCII the same edges be stored in a row.
“M” or “S” to indicate the state, followed by a Since I plan to use the PC to display sampled
2-byte count. data, I might as well enable user input to begin
The buffer will then have to be big enough the sampling process. I like using the serial
to store at least one complete transmission. At port to aid in debugging, so it made sense to
6 bytes for each mark space pair transmitted, provide transmit and receive buffers to send
I can store a little more than 40 bursts in a and receive data in the background.
bank of RAM (256 bytes each). I would need One of the handy aspects of this
to set aside a number of banks for this buffer. microcontroller is the two-level priority for
There is a potential problem with this interrupt sources. Since my timing information
approach. I chose to use the counter timer is the most important, I don’t want any serial
for its ability to latch a timer count on edge port activity preventing the accurate timing
interrupts so I could get the fastest and of IR data. I configured the UART interrupts
most accurate counts possible. This wasn’t a as low-level interrupts. High-priority timing
big issue since I really didn’t need the high interrupts can interrupt a low-priority
resolution this provides for this particular interrupt. This way moving received characters
application. I needed to reconfigure the into the RXBuffer ensures no characters are
peripheral after each interrupt. If I were to missed, while enabling important timing
Mark Space Data routines to take over if necessary.
I used the single character “S” to begin
Duration Duration Value the sampling process. A Prompting message
is displayed; however, nothing actually begins
1 time unit 1 time unit 00
until the IR receiver sees its first IR burst
(the first falling edge is seen). At that point,
1 time unit 2 time units 01 the timer will begin and successive edges
will store the timer count, restart the timer,
TABLE 2
1 time unit 3 time units 10 and enable the sample to be stored in the
A bit value is determined by the time SampleBuffer. The routine will continue until
unit’s data value and mark and space 1 time unit 4 time units 11 the buffer is filled or the timer overflows (a
durations. lack of data). A Finished message concludes
Join the Elektor Community
Take Out a GOLD Membership Now!
Your GOLD Membership Contains:
• 8 Regular editions of Elektor magazine in
print and digital
• 2 Jumbo editions of Elektor magazine in print
and digital (January/February and July/August
double issues)
• Elektor annual DVD-ROM
• A minimum of 10% DISCOUNT on all
products in Elektor.STORE
• Direct access to Elektor.LABS; our virtual,
online laboratory
• Direct access to Elektor.MAGAZINE; our online
archive for members
• Elektor.POST sent to your email account
(incl. 25 extra projects per year)
• An Elektor Binder to store these projects
• Exclusive GOLD Membership card

ALSO AVAILABLE:
The all-paperless GREEN Membership, which
delivers all products and services, including
Elektor magazine, online only.

Take Out Your Membership Now at www.elektor.com/member


Connect with us! www.facebook.com/elektorim www.twitter.com/elektor
72 CIRCUIT CELLAR • AUGUST 2014 #289

(the first translation is mark approximately


Element Time in Microseconds 8,794 µs, so a transition is added from mark
to space)
0x4D (M) 0x22 0x55 (8,794) ¦A
1,8794<CR> ¥A
0x53 (S) 0x11 0x53 (4,435) ¦B 0,8794<CR>

(the next translation is space approximately


0x4D (M) 0x01 0x9A (410) ¦C 8,794 µs + 4,435 µs, so a transition is added
from space to mark)
0x53 (S) 0x02 0x01 (513) ¦D
0,13229<CR> ¥B
0x4D (M) 0x01 0x9A (410) ¦E 1,13229<CR>
COLUMNS

0x53 (S) 0x02 0x01 (513) ¦F (the next translation is mark approximately
13,229 µs + 410 µs, so a transition is added
from mark to space)
TABLE 3 the operation. Now that I have some data, I
This stored data is the result of need to display it. 1,13639<CR> ¥C
performing a translation and sending 0,13639<CR>
the data to the serial port for each
element.
A LOOK-SEE
In the back of my mind I kept thinking, (etc.)
“comma delimited.” The plan was to make
visual sense of the sampled data by using a 0,14152<CR> ¥D
tool (e.g., Excel) to graph the data. I found I 1,14152<CR>
was spending a lot of time trying to create
meaningful graphs when what I really needed 1,14562<CR> ¥E
was a digital storage scope display. Fortunately, 0,14562<CR>
I quickly understood I needed to provide an
additional data point for each sample. 0,15075<CR> ¥F
I had saved a state and time for each 1,15075<CR>
element and I needed the transition between
states. The C command became a translation This “C”hart data can be captured into
from the stored data to comma-delimited a file by the terminal program. (I used
plottable points. For each stored element, I SourceForge’s RealTerm.) The comma-
performed a translation and sent the data delimited format is imported with Excel, or
out the serial port. Table 3 shows the stored you can use DatPlot, a free plotting program.
data. It gets translated as: From this plot you can make out a wide header
followed by some bits and a large trailing gap
(The initial transition @ 0.0 µs from space to between the data and the start of what could
mark) be another burst (see Figure 4).
What now? How do you know what to look
0,0<CR> for and how to identify it and decode its data?
1,0<CR> In some instances, you don’t need to know
any of that. If all you want to do is reproduce
the signal, you have enough information to do
G. Dixon, “IRP Notation: Specification of IRP that. But what fun would that be? Let’s take a
Notation.” look at a few of the known formats and see if
this can be identified.
SB-Projects, “ IR Remote Control Theory,” www.
sbprojects.com. IR FORMATS
If you’ve ever used ultrasonics to measure
distances, this carrier frequency is probably
circuitcellar.com/ccmaterials SOURCES familiar to you. According to Mary Bellis’s
PIC18F26K22 Microcontroller article “History of the Television Remote
Microchip Technology, Inc. | www.microchip.com Control,” in the early 1960s Zenith’s Space
REFERENCE
Command remote control reaped the benefits
[1] M. Bellis, “History of the
RealTerm terminal program of transistor technology using ultrasonics
Television Remote Control,”
SourceForge | www.sourceforge.net to create a small hand-held and battery-
About.com.
operated remote control. More than 9
RESOURCES million ultrasonic remote controls were sold.
DatPlot, www.datplot.com. Ultrasonic remote controls ruled living rooms
circuitcellar.com 73

until the early 1980s when they were replaced


by IR remotes.[1]
Changing batteries in a remote is a nuisance
every user despises. IR transmissions should
be as short as possible to conserve precious
reserves. Understandably, the first remotes
used whatever techniques would provide the
longest life. With so many formats and no real
standards, how can you keep track of what is
out there?
You may think this has already been
done. After all, universal remotes can mimic
anything, right? All you have to do is punch

COLUMNS
in some four-digit number and your URC
knows what to do. The fact is that each URC’s
dictionary is unique. A four-digit code used in
one remote is not necessarily the right one
in another remote. However, an open solution FIGURE 4
has been implemented. The IR remote sampled for this plot is an Acer multimedia remote that came with my Acer tablet.

IRP NOTATION
In 2003 the IRP notation was developed by (_ D:5,F:8,1:2, 1,-165,_ D:5,~F:8,2:2,1,-165)+
John Fine as a way of describing IR protocols.
l l l l l l L - + = may be sent again
The IRP notation has been illustrated in great
l l l l l L - trailer = 1 * 400uS Mark and 165 * 400uS Space
detail by Graham Dixon (see Resources).
l l l l L - data = xxxxx xxxxxxxx 10
The overall structure of IRP notation l l l L - header = none
is contained in as little as three sections: l l L - trailer = 1 * 400uS Mark and 165 * 400uS Space
GeneralSpec, Bitspec, and IRStream. If l L - data = xxxxx xxxxxxxx 01
required, a fourth section may include the L - header = none
definition of any expressions previously used
in the notation. Let’s take a look at the IRP
notation for a Sharp device. FIGURE 5
The GeneralSpec section includes the The IRP Notation’s IRStream section provides information about each subsection.
carrier frequency (hertz default), whether
the data is presented most-significant bit or data subsection includes two transmissions
least-significant bit (default){ first, and any with differing data in each (see Figure 5). ABOUT THE AUTHOR
basic time unit (microsecond default). This Note the data designations D:5, F:8, and J e f f B a c h i o c h i ( p ro -
section is surrounded by {}: 1:2. The letters are an indication of some nounced BAH-key-AH-
variable or expression (:) of a particular bit key) has been writing
{38k,400} ‘ 38,000 Hz, default, 400 µs length. The number indicates a constant for Circuit Cellar since
value (:) of a particular bit length. The colon 1988. His background
The Bitspec section describes the format precedes an indicator of data size (in bits). includes product design
used to represent each bit mark and space, Most protocols can be described using this and manufacturing.
where “–” means space. This section is notation. Even though IRP offers a way for an
You can reach him at
surrounded by “<>” (with each bit separated application to evaluate the notation, it does
jeff.bachiochi@imagine
by “|”) and follows the form: not describe the actual original button code
thatnow.com or at www.
for each key on a remote. While the variable/
imaginethatnow.com.
<1,–1| ‘ bit0 = expressions in the data subsection of the
1 × 400 µs mark and 1 × 400 µs space | previously described IRStream tell you where
1,–3> ‘ bit1 = that data goes, this data needs to be defined
1 × 400 µs mark and 3 × 400 µs space somewhere. Again, there is no standard for
this. In fact, it may be harder for you to locate
The IRStream section describes the this information than to identify the format of
data for each subsection, header, data, and a particular IR transmission.
trailer. The header and trailer (when used)
are described in terms of bit(s), while the TO DO LIST
data subsection may have a combination of Fortunately, with this project once you’ve
constant:bit quantity and/or expression:bit identified the IR format, you can decode this
quantity. A preceding “~” indicates the data for various key presses. That’s what I’ll
value is complemented and “+” means the be doing in Part 2 of this article series:
transmission may be sent multiple times. identifying, decoding, and reproducing the IR
The bitstream is surrounded by “()”. This I captured and described in Part 1.
74 CIRCUIT CELLAR • AUGUST 2014 #289

CROSSWORD AUGUST 2014


The answers will be available at circuitcellar.com/crossword.

1 2

4 5

9 10 11 12

13
TESTS & CHALLENGES

14 15

16

17

18

19

EclipseCrossword.com

ACROSS
1. Ethernet at 100 Mbps DOWN
3. IC factory 2. Wafer or substrate
6. Logic gate 3. Antonym for FIFO
7. HDL created in the early 1980s by Goel and Moorby 4. Base-5
9. 0.001 inches = 25.4 what? 5. CODEC [two words]
10. Current flow over time [two words] 7. Gilbert’s static-detection device
13. Greek national soccer team manager with a degree in 8. Release heat
electrical engineering 11. Relates to touch
14. Quad, flat, ... [two words] 12. 1 watt second
16. Step-down 15. Process of purposely adding impurities
17. 0.000000000000001
18. Ground pin
19. Zero
circuitcellar.com 75

What’s your EQ? The answers to the Circuit Cellar 288


EQ are posted below and at www.circuitcellar.com/
category/test-your-eq/. You can contact the quizmasters at
eq@circuitcellar.com.

ANSWER 1
The cutoff frequencies of the two filters should be the same so
TEST YOUR EQ
that the overall frequency response when the filter outputs are Contributed by David Tweed
recombined is flat and has no phase shift. For example, if you feed the
cutoff frequency into both filters and then combine the results again,
Energizer Duracell
the output will be the same level as the input (0-dB overall gain). As
If the stereo is running for 12 h on a set of batteries, based on
long as the “order” of the two filters is the same (they have the same
eyeballing these graphs, it’s probably getting about 8 A-h of capacity
roll-off slope), the gain will be flat across the entire transition band
out of one set, so it’s drawing about 660 mA on average. Putting
of frequencies.
three sets of batteries in parallel would drop the current in each set
What’s really going on is this: A filter’s –3-dB point is where the
to about 220 mA, and it will get something closer to 12 A-h from
output has half the power of the input signal, which means that the
each set.
output voltage is 1/sqrt(2) times the input voltage. The –3-dB point
In other words, if you use, say, three sets of batteries sequentially,
is also where the output signal is phase shifted by 45°. It lags by 45°
you’ll get 36 h of playing time (24 A-h total), but if you use them in
in the low-pass filter and leads by 45° in the high-pass filter. This
parallel together, you’ll get something closer to 54 h of playing time
means that the outputs of the two filters have a total phase shift of
(36 A-h total).
90° relative to each other.
When you add two sinewaves that have the same amplitude and
a 90° phase shift, you don’t get double the voltage. You get sqrt{2}
times the voltage. You also get a waveform that has a phase midway ANSWER 3
between the two signals being added. A capacitor consists of two flat conductors separated by a dielectric.
So, the final amplitude is sqrt{2}/sqrt{2} times the original input Aluminum foil is an obvious candidate for the conductors, and either
voltage, and the final phase is midway between 45° and –45°, or 0°. waxed paper or plastic food wrap would be suitable dielectrics —
In other words, you get the original sinewave back exactly. they have similar characteristics.

ANSWER 2 ANSWER 4
In general, batteries provide greater capacity at lower average You need to do some basic calculations first. The formula for
currents. This is partly due to the battery’s internal chemistry, but capacitance is:
largely due to the simple fact that less power is wasted in the internal εR ε 0 A
resistance of the battery. C=
d

TESTS & CHALLENGES


Here are two graphs taken from two different datasheets that where:
illustrate this.
εR is the relative permittivity of the dielectric
ε0 is the permittivity of free space
A is the area of one plate
d is the separation between the plates

Let’s say you want to use 1-mil (25.4 µm) waxed paper as a
dielectric. Note that this will determine the voltage rating of the
capacitor. The dielectric strength of waxed paper is about 35-40
MV/m, so this will give you a capacitor that can theoretically handle
almost a kilovolt, but be conservative in how you use it!

The relative permittivity of waxed paper is about 3.7, the


permittivity of free space is 8.854e-12 F/m. Solve for the area
required:

C×d
A =
εR ε 0
5 µF × 25.4 µm
A= = 3.8767 m2
3.7 × 8.854 × 10 12 F/m

If you get aluminum foil and waxed paper that’s about 12” (30 cm)
wide, you can probably get an overlap of, say, 25 cm, which means
that you’ll need a length of about 15.5 m to get the area you need.
If you then roll up your capacitor (using a second layer of waxed
paper), the capacitance will be doubled, or about 10 µF. Obviously,
this will be physically rather large, more than a foot long and several
inches in diameter.
Plastic food wrap has a similar dielectric constant and dielectric
strength as waxed paper, but typically comes in a 0.5-mil (12.7 µm)
thickness. A capacitor using this would have about half the voltage
rating and about half the overall volume.
76 CIRCUIT CELLAR • AUGUST 2014 #289

CC SHOP

ADVANCED CONTROL
ADVANCED CONTROL ROBOTICS

ROBOTICS HANNO SANDER


1 ADVANCED ROBOTIC
CONTROL—NEW!
When it comes to robotics, the future
is now! This book simplifies the theory
and best practices of advanced robot
technologies by providing insight to
communication technologies, control
robotics, embedded technology,
programming, and more. Complete with
code samples, schematics, and design
tips. Great reading for beginners and
experts alike.

PARALLAX PROPELLER
Author: Hanno Sander
Item#BK-ELNL-978-0-963013-33-0

1
4

4 ADUC841 MICRO-
CONTROLLER DESIGN MANUAL
2 CC VAULT
This book presents a comprehen-
CC Vault is a pocket-sized USB sive guide to designing and program-
that comes fully loaded with ev- ming with the Analog Devices ADuC841
ery issue of Circuit Cellar maga- microcontroller and other microcon-
zine! This comprehensive archive trollers in the 8051 family. It includes a
provides an unparalleled amount set of introductory labs that detail how
of embedded hardware and soft- to use these microcontrollers’ most
ware design tips, schematics, and standard features, and includes a set
source code. CC Vault contains of more advanced labs, many of which
all the trade secrets you need to make use of features available only on
become a better, more educated the ADuC841 microcontroller.
electronics engineer! The more advanced labs include
several projects that introduce you to
Item #: CCVAULT ADCs, DACs, and their applications.
2 Other projects demonstrate some of
the many ways you can use a micro-
controller to solve practical problems.
The Keil µVision4 IDE is introduced
early on, and it is used throughout the
3 ANDROID APPS:
n Schwark Stefan Schwark

book. This book is perfect for a univer-


Android Apps PROGRAMMING STEP-BY-STEP
Stefan Schwark

sity classroom setting or for indepen-


dent study.
programming step-by-step Many smartphones and tablet com-
+ Eclipse development platform
+ JAVA object oriented programming puters are powered by an Android OS.
Author: Shlomo Engelberg
These portable devices’ speed and com-
www.elektor.com/android Item #: CC-BK-9780963013347
omputers.
puting power enable them to run appli-
hat allow
cations that would have previously re-
Android: programming step-by-step

ncreasing

quired a desktop PC or custom-designed


to be run
go. Mean-
eos – and Further information and ordering
hardware. Android Apps introduces you
f the shelf
s is easier
to the programming required to design www.cc-webshop.com
eration of
apps for Android devices. Operating the CONTACT US:
nal appli-

Android system is explained step-by- Circuit Cellar, Inc.


111 Founders Plaza, Suite 300
examples,
ight up to
n the Java step to show how personal applications
med using

can be easily programmed. East Hartford, CT 06108


USA
Author: Stefan Schwark Phone: 860.289.0800
Item #: BK-ELNL-978-1-907920-15-8 Fax: 860.461.0450
3
26.11.12 15:38
E-mail: custservice@circuitcellar.com
12th International System-on-Chip (SoC)
Conference, Exhibit & Workshops
October 22 & 23, 2014
University of California, Irvine - Calit2

www.SoCconference.com
CALL FOR SPEAKERS AND SPONSORS. . . Don’t Miss Out!
This Year’s Theme: “Innovative SoCs Empowering the Communications Market.”

Platinum Sponsors
 FinFET Technology & Design  Complex Mixed-Signal SoCs
 Analog & Mixed-Signal Designs  SOI vs. CMOS
 Sub 14nm Designs & Beyond  RF Design
 3-D ICs Designs  FPGAs –Trends & Designs
 IC Security & Challenges  High-Speed I/Os
 Multicore Software Development  Smarter Mobile Devices
 SoC Design & Verification  Multicore SoC Platforms
 Innovative EDA Tools  Network-on-Chips (NoCs)
 Complex IP Subsystems  Informative Panels
 Low-Power Techniques  IEEE Student Design Contest
 Memory Trends & Technologies  Networking Opportunities
 Table-Top Exhibit (Free Passes)  And Much More. . .

Promote Your Technology, Products & Services at


The Most Informative, Targeted & Educational
IC & IP Design Conference, Exhibit & Workshops of the Year!

Keynote Speakers

Microsemi Skyworks Solutions


Jim Aralis, Chief Technology Dr. Peter L. Gammel,    
Officer (CTO), and Vice Chief Technology Officer
President of R&D. (CTO).

The SoC Conference brings together a very targeted and sophisticated audience from leading-edge
technology companies as well as key universities for two exciting days devoted to groundbreaking
products, technologies, and business disclosures, focused exclusively on designing complex
System-on-Chip and the related technologies driving the SoC/ASIC/ASSP/FPGA/Foundry industry.

For More Information or Questions, Please Contact the SoC Conference Organizing Committee at:
SoC@SoCconference.com or (949) 851-1714

www.SavantCompany.com & www.SoCconference.com


78 CIRCUIT CELLAR • AUGUST 2014 #289

IDEA BOX the directory of


PRODUCTS & SERVICES

AD FORMAT: The Vendor Directory at


circuitcellar.com/vendor
Advertisers must furnish digital files that meet our specifications
(circuitcellar.com/mediakit). is your guide to a variety of
engineering products and
ALL TEXT AND OTHER ELEMENTS MUST FIT WITHIN A 2” x 3” FORMAT.
services.
E-mail adcopy@circuitcellar.com with your file.

For current rates, deadlines, and more information contact Peter Wostrel
at 978.281.7708 or circuitcellar@smmarketing.us.

“Your reliable
outsourcing partner”
LOW cost
with HIGH quality
PCB, PCBA and More
INSTANT QUOTE AT:
www.myropcb.com
OR CALL:
1-888-PCB-MYRO

MyRO

LEARN FPGA PROGRAMMING


USING THE ALTERA
QUARTUS II AND VERILOG
The course comes
with a Cyclone
board, as shown,
and an USB
Blaster. Also
included is a
175-page manual
containing ten
chapters that
are full of examples and tutorials. This
in-depth course is a must for the hobbyist,
as well as, for schools teaching FPGAs. The
manual is easy to understand and correct.

$55 + $12 shipping


ADVANCED MICRO CIRCUITS
443-817-2557
www.amcmicros.com
information@amcmicros.com
circuitcellar.com 79

Join The

Save 10%
Online Web-Order Code:
C311408
Valid thru September 1, 2014
HRXL-MaxSonar®-WR™
- High noise tolerance
- IP67 rated
- 1 mm resolution
- Multi-Sensor operation
- Calibrated beam pattern
- Starting at $109.95

XL-MaxSonar®-EZ™
- Great for UAV’s and robotics
- Incredible noise
immunity
- Small in size
- 1cm resolution
- Automatic calibration
- Starting at $39.95
Phone: 218-454-0766 Email: sales@maxbotix.com
www.maxbotix.com

Real $349.00
TRi
Programmable Logic Controllers from
Powerful & Easy Ladder

Logic Analyzers
+BASIC Programming
Ethernet integrated
MODBUS TCP/IP
DI/Os & AI/Os integrated with Decoders & Plug-in Kit included
• 9 to 36 Channels
• 100 Msps to 400 Msps
OEM Prices as low as $119
for full-feature Nano-10 PLC
• Store & Forward Architecture
• Real-time Smart Compression
tel : 1 877 TRI-PLCS • Plot & Measurement Features
• Powerfull Search Tools
web : www.triplc.com/cci.htm

• Plug-ins for full Custom


Protocol integration
TRIANGLE
RESEARCH
by
INTERNATIONAL
www.tech-tools.com/real.htm • (972) 272-9392

Connect
with engineers
microEngineering Labs, Inc.
www.melabs.com 888-316-1753
Programmers for Microchip PIC® Microcontrollers
seeking your PC-Tethered USB Model (shown):
design solutions. •Standalone software
•Command-line operation
Magazine, e-newsletters, •Hide GUI for automated use
•Override configuration with drop-downs
website, advertorials, and more.
RESERVE ADVERTISING Stand-Alone Field Programmer:
•Power from target device or adapter
SPACE TODAY!
•Program file stored on SD-CARD
Strategic Media Marketing, LLC •Programming options stored in file

978.281.7708
•Single-button operation
Starting at $79.95

Program in-circuit or use adapters for unmounted chips.


circuitcellar@smmarketing.us Zero-Insertion-Force Adapters available for DIP, SOIC, SSOP, TQFP, and more.
www.smmarketing.us PIC is a registered trademark of Microchip Technology Inc. in the USA and other countries.
80 CIRCUIT CELLAR • AUGUST 2014 #289

Self-Reconfiguring Robotic
Systems and M-Blocks
By Kyle Gilpin
The creation of autonomous machines capable magnetic pole. The benefit of this arrangement is that
of shape-shifting has been a long-running dream of as two modules are brought together, the magnets will
scientists and engineers. Our enthusiasm for these automatically rotate to attract. Furthermore, as one
self-reconfiguring robots is fueled by fantastic science and then two additional M-Blocks are added to form a 2
fiction blockbusters, but it stems from the potential × 2 grid, the magnets will always rotate to realign and
that self-reconfiguring robots have to revolutionize our accommodate the additional modules.
interactions with the world around us. The same cylindrical magnets that bond neighboring
Imagine the convenience of a universal toolkit that M-Blocks together form excellent pivot axes, about which
can produce even the most specialized tool on demand the modules may roll over and around one another. We
in a matter of minutes. Alternatively, consider a piece have shown that the modules can climb vertically over
of furniture, or an entire room, that could change its other modules, move horizontally while cantilevered
configuration to suit the personal preferences of its from one side, traverse while suspended from above,
occupant. Assembly lines could automatically adapt to and even jump over gaps. The permanent magnet
new products, and construction scaffolding could build connectors are completely passive, requiring no control
itself while workers sleep. At MIT’s Distributed Robotics and no planning. Because all of the active components of
Kyle Gilpin, PhD, is a Postdoctoral
Lab, we are working to make these dreams into reality an M-Block are housed internally, the modules could be
Associate in the Distributed
through the development of the M-Blocks. hermetically sealed, allowing them to operate in extreme
Robotics Lab at the Massachusetts
The M-Blocks are a set of 50-mm cubic modules environment where other robotic systems may fail.
TECH THE FUTURE

Institute of Technology (MIT)


capable of controlled self-reconfiguration. Each M-Block
where he is collaborating with
is an autonomous robot that can not only move
Professor Daniela Rus and John
independently, but can also magnetically bond with
Romanishin to develop the
other M-Blocks to form larger reconfigurable systems.
M-Blocks. Kyle works to improve
When part of a group, each module can climb over and
communication and control in
around its neighbors. Our goal is that a set of M-Blocks,
large distributed robotic systems.
dispersed randomly across the ground, could locate one
Before earning his PhD, Kyle spent
another and then independently move to coalesce into a
two years working as a senior
macro-scale object, like a chair. The modules could then
electrical engineer at a biomedical
reconfigure themselves into a sphere and collectively
device start-up. In addition to
roll to a new location. If, in the process, the collective
working for MIT, he owns a
encounters an obstacle (e.g., a set of stairs to be
contract design and consulting
ascended), the sphere could morph into an amorphous
business, Crosscut Prototypes. His
collection in which the modules climb over one another Two different views of the M-Blocks show the internal flywheel
past projects include developing (partially obscured, left and right), which is driven by the
to surmount the obstacle. Once they have reached their
cellular and Wi-Fi devices, real- brushless motor (orange, right). A self-tightening band brake,
final destination, the modules could reassemble into a
time image processing systems, driven by a servomotor horn (white, left), quickly decelerates the
different object, like a desk.
reconfigurable sensor nodes, flywheel so that one module pivots about the other using the
The M-Blocks move and reconfigure by pivoting
robots with compliant SMA cylindrical magnets held captive in the modules’ edges. A PCB
about their edges using an inertial actuator. The energy (green, left), controls the flywheel and the brake using commands
actuators, integrated production
for this actuation comes from a 20,000-RPM flywheel received from the on-board 2.4-GHz radio. On-board lithium-
test systems, and ultra-low-
contained within each module. Once the motor speed polymer batteries (not shown) provide power to each module.
power sensors. You can contact
has stabilized, a servomotor-driven, self-tightening band
him at either kwgilpin@csail.mit.
brake decelerates the flywheel to a complete stop in 15 While we have made significant progress, many
edu or kwgilpin@xcutproto.com.
ms. All of the momentum that had been accumulated in exciting challenges remain. In the current generation
the flywheel is transferred to the frame of the M-Block. of modules, there is only a single flywheel, and it is
Consequently, the module rolls forward from one face fixed to the module’s frame, so the modules can only
to the next, or if the flywheel velocity is high enough, it move in one direction along a straight line. We are close
rapidly shoots across the ground or even jumps several to publishing a new design that enables the M-Blocks to
body lengths through the air. (Refer to www.youtube. move in three dimensions, makes the system more
com/watch?v=mOqjFa4RskA to watch the cubes move.) robust, and ensures that the modules’ movements are
While the M-Blocks are capable of independent highly repeatable. We also hope to build new varieties
movement, their true potential is only realized when of modules that contain cameras, grippers, and other
many modules operate as a group. Permanent magnets specialized, task-specific tools. Finally, we are
on the outside of each M-Block serve as un-gendered developing algorithms that will allow for the coordinated
connectors. In particular, each of the 12 edges holds control of large ensembles of hundreds or thousands of
two cylindrical magnets that are captive, but free modules. With this continued development, we are
to rotate, in a semi-enclosing cage. These magnets optimistic that the M-Blocks will be able to solve a
are polarized through their radii, not through their variety of practical challenges that are, as of yet,
long axes, so as they rotate, they can present either largely untouched by robotics.
MULTIPLE PCBA
NO MORE WAITING
LINES
ACROSS THE GLOBE!
Imagineering utilizes the Jet Printer Technology which has been proven
successful in five continents. This breakthrough innovation allows us to achieve
high-precision solder deposits at speeds of more than one million dots per hour.
High-Speed Non-Contact Jetting Nozzle • Complete Volume Control • 100% Software Driven
More Components, More Possibilities • High-Performance Platform

www.PCBnet.com
(847) 806-0003 • sales@PCBnet.com

You might also like