Professional Documents
Culture Documents
Circuit Cellar 2014 - 08
Circuit Cellar 2014 - 08
AUGUST 2014
circuitcellar.com ISSUE 289
CIRCUIT CELLAR | ISSUE 289 | AUGUST 2014
EDITOR’S LETTER
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
DISCLAIMER
© 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
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
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
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
EMBEDDED
DEVELOPMENT
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
CONTENTS
SELF-RECONFIGURING ROBOTS
CC WORLD
EIM “BOOTCAMP”
By C. J. Abate
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
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
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
L
D
NA
N
LI
GE
PE
GI
RI
RU
LO
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
$165
qty 100
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
Benefits: Benefits:
Low power with 10mW sleep state Hardware Flexibility with On-board FPGA
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
L
D
NA
N
LI
GE
PE
GI
RI
RU
LO
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
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
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.
PRODUCT NEWS
Lauterbach
www.lauterbach.com
mouser.com
The Newest Products for Your Newest Designs®
ORE.
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
CLIENT PROFILE
CONTACT: stephen@totalphase.com
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.
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
Build a Digital
Pulse Generator
FEATURES
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.
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
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
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:
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
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).
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.
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
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
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)
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.
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
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
Buy now
and
upgrade for free!
w w w. c a ds o f t u s a . co m
40 CIRCUIT CELLAR • AUGUST 2014 #289
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
Linux System
Configuration (Part 2)
Linux Application Design
The Linux system can be configured in many ways.
This article examines some options, including
COLUMNS
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
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
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
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.
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
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
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;
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 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;
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
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
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
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
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
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.
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
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.
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
REGISTER ONLINE
www.FlashMemorySummit.com
Readers of Circuit Cellar Magazine: Enter priority code SPGP for a $100 discount.
60 CIRCUIT CELLAR • AUGUST 2014 #289
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
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
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.
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
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
IR Remotes
(Part 1)
Remote Transmission
COLUMNS
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)
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 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
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.
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
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
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
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
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!
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
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
ncreasing
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. . .
Keynote Speakers
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
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
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
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
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
www.PCBnet.com
(847) 806-0003 • sales@PCBnet.com