100% found this document useful (1 vote)
51 views84 pages

Circuit Cellar #294 2015 01

Uploaded by

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

Circuit Cellar #294 2015 01

Uploaded by

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

EMBEDDED APPLICATIONS

JANUARY 2015
circuitcellar.com ISSUE 294
CIRCUIT CELLAR | ISSUE 294 | JANUARY 2015

ENGINEER A GESTURE-
CONTROLLED SYSTEM
OBJECT TRACKING
WITH A WEBCAM
RESOLUTION SCALING
& BUTTON INTERFACE
FINGER SLEEVES FOR
MOUSE CONTROL
IMAGE ACQUISITION
& PROCESSING
Q&A: 3-D Printed Robotics Virtual Instrumentation |
Tips for Measuring Small Currents | Build a Duodecimal Clock | The Twin-T
circuitcellar.com

Oscillator Configuration EMI Causes & Issues | Universal Motor Control |


Adaptive Apps for Energy Conservation | DIY Current Flow Monitor
The Future of Electrical Engineering
MIXED SIGNAL
OSCILLOSCOPES
4 ANALOG + 16 DIGITAL CHANNELS
RAPIDLY DEBUG COMPLEX MIXED SIGNAL DESIGNS
• USB 3.0
• ULTRA DEEP MEMORY
• SEGMENTED MEMORY
RAPID
• RA
R PID TRIGGERS

INCLUDES AUTOMATIC MEASUREMENTS, SPECTRUM ANALYZER, SDK,


ADVANCED TRIGGERS, COLOR PERSISTENCE, SERIAL DECODING
(CAN, LIN, RS232, I²C, I²S, FLEXRAY, SPI), MASKS, MATH CHANNELS,
ALL AS STANDARD, WITH FREE UPDATES . 5 YEAR WARRANTY

3204D MSO 3205D MSO 3206D MSO 3404D MSO 3405D MSO 3406D MSO
Channels 2 analog, 16 digital 4 analog, 16 digital
Bandwidth 60 MHz 100 MHz 200 MHz 60 MHz 100 MHz 200 MHz
Buffer memory 128 MS 256 MS 512 MS 128 MS 256 MS 512 MS
Max. sampling rate 1 GS/s
Signal generator Function generator + Arbitrary waveform generator
Digital inputs 100 MHz max. frequency, 500 MS/s max. sampling rate

Call:1.800.591.2796 www.picotech.com/pco534
2 CIRCUIT CELLAR • JANUARY 2015 #294

ELECTRICAL ENGINEERING IN 2015 & BEYOND


I typically use this space to present each edition’s content in chronological order. But
this month, I’ll begin by focusing on the issue’s last section, which features the thoughts
Issue 294 January 2015 | ISSN 1528-0608
and prognostications of several well-known engineers about the future of embedded
CIRCUIT CELLAR® (ISSN 1528-0608) is published monthly by: systems technology and electrical engineering. The feedback we received was informative
and thought provoking. Turn to page 79 to read the responses from Steve Ciarcia, Ed
Circuit Cellar, Inc.
111 Founders Plaza, Suite 300
Nisley, David Tweed, Ken Davidson, George Novacek, Robert Lacoste, and Chris Coulston.
East Hartford, CT 06108 In 2015, we intend to widen our areas of coverage by actively engaging engineers
around world and requesting articles on cutting-edge technologies. In the next few
Periodical rates paid at East Hartford, CT, and additional offices.
One-year (12 issues) subscription rate US and possessions issues, you’ll see articles on topics such as reverse engineering, robot system design, and
$50, Canada $65, Foreign/ ROW $75. All subscription orders maximum power point tracking for fixed impedance renewable energy sources.
payable in US funds only via Visa, MasterCard, international
The January issue features a variety of projects and tutorials related to embedded
postal money order, or check drawn on US bank.
applications. I encourage you to read each article and send us your thoughts and ideas.
SUBSCRIPTIONS
We start with an interview with roboticist Joel Gibbard, who created the Dextrus robotic
hand. He tells us about his design process, including his use of 3-D printing.
Circuit Cellar, P.O. Box 462256, Escondido, CA 92046
On page 16, Shlomo Engelberg, Ahron Emanuel, and Dvir Ophir detail how to build a
E-mail: circuitcellar@pcspublink.com
virtual instrument to characterize enhancement mode N-channel MOSFETs. They explain
Phone: 800.269.6301
how to design a single-stage amplifier around the transistor.
Internet: circuitcellar.com
Turn to page 24 to learn how Alex Leung and Miles Pedrone designed and constructed a
Address Changes/Problems: circuitcellar@pcspublink.com
microcontroller-based webcam mouse. The system enables you to scroll and click through
Postmaster: Send address changes to programs by tracks the movement of your fingers in the air.
Circuit Cellar, P.O. Box 462256, Escondido, CA 92046 Do you ever need to measure currents lower than what the average hand-held
multimeter can handle? If so, consider replicating David Ludington’s project, which extends
ADVERTISING a hand-held’s current measurement range to nanoamps and picoamps.
Strategic Media Marketing, Inc. Devlin Gualtieri’s duodecimal design is a two-digit clock that only an engineer would
2 Main Street, Gloucester, MA 01930 USA
love (p. 40). He built the clock with a PIC micrcontroller, PIC Basic Pro, and a Lumex display.
Phone: 978.281.7708
For those who enjoy DIY audio, we have the Twin-T Oscillator, an audio oscillator and
Fax: 978.281.7706
stereo VU meter design by Larry Cicchinelli (p. 46). The easy-to-use unit combines a
E-mail: circuitcellar@smmarketing.us
Advertising rates and terms available on request.
calibrated audio source with a level display.
New Products:
On page 52, George Novacek presents the second article in his series, “Essential
New Products, Circuit Cellar, 111 Founders Plaza, Suite 300 Electromagnetic Compliance.” He covers the causes of electromagnetic interference (EMI).
East Hartford, CT 06108, E-mail: newproducts@circuitcellar.com In “Brute-Force Universal Motor Control,” Ed Nisley presents an innovative motor
controller design (p. 56). Safety and simplicity were key factors in the project.
HEAD OFFICE
For her Green Computing article this month, Ayse Coskun examines how adaptive
Circuit Cellar, Inc. 111 Founders Plaza, Suite 300 software applications can help engineers meet performance and power goals (p. 62). The
East Hartford, CT 06108
Phone: 860.289.0800 idea is to combine application tuning and power management procedures to increase
energy efficiency.
COVER PHOTOGRAPHY Jeff Bachiochi’s contribution this month is a primer in current tracking (p. 66). He writes
Chris Rakoczy, www.rakoczyphoto.com about how he engineered a handy display system for monitoring a vehicle’s current flow.
SPECIAL THANKS — On behalf of the entire Circuit Cellar team, I’d like to thank Debbie
COPYRIGHT NOTICE Lavoie for her 13 years of service and dedication to our company and its customers. We wish
Entire contents copyright © 2014 by Circuit Cellar, Inc. All her a happy retirement!
rights reserved. Circuit Cellar is a registered trademark of
Circuit Cellar, Inc. Reproduction of this publication in whole C. J. Abate
or in part without written consent from Circuit Cellar, Inc. is
prohibited. cabate@circuitcellar.com

DISCLAIMER

Circuit Cellar® makes no warranties and assumes no


responsibility or liability of any kind for errors in these
programs or schematics or for the consequences of any
THE TEAM
such errors. Furthermore, because of possible variation in
the quality and condition of materials and workmanship of EDITOR-IN-CHIEF (Green Computing), Bob FOUNDER
reader-assembled projects, Circuit Cellar® disclaims any
responsibility for the safe and proper function of reader- C. J. Abate Japenga (Embedded Steve Ciarcia
assembled projects based upon or from plans, descriptions, or
information published by Circuit Cellar®. ART DIRECTOR in Thin Slices), Robert PROJECT EDITORS
The information provided by Circuit Cellar® is for educational
KC Prescott Lacoste (The Darker Chris Coulston, Ken
purposes. Circuit Cellar® makes no claims or warrants that
Side), Ed Nisley (Above Davidson, and David
readers have a right to build things based upon these ideas ADVERTISING COORDINATOR
under patent or other relevant intellectual property law in
Kim Hopkins the Ground Plance), Tweed
their jurisdiction, or that readers have a right to construct or
operate any of the devices described herein under the relevant George Novacek (The
patent or other intellectual property law of the reader’s PRESIDENT CUSTOMER SERVICE
Consummate Engineer), Debbie Lavoie
jurisdiction. The reader assumes any risk of infringement Hugo Van haecke
liability for constructing or operating such devices.
and Colin O’Flynn
© Circuit Cellar 2014 Printed in the United States COLUMNISTS (Programmable Logic in
Jeff Bachiochi (From the Practice)
Bench), Ayse K. Coskun
circuitcellar.com 3

OUR NETWORK

SUPPORTING COMPANIES
Accutrace 7 Jeffery Kerr, LLC 75

All Electronics Corp. 75 Lauterbach GmbH 45

Anaren 9 MaxBotix, Inc. 75

AP Circuits 39 microEngineering Labs 76

Custom Computer Services 75 MyRO Electronic Control Devices, Inc. 76

Elprotronic, Inc. 43 NetBurner, Inc. C2

EMAC, Inc. 39 Pico Technology, Ltd. 1

Front Panel Express 21 Reach Technology, Inc. 75

GHI Electronics, LLC 27 R.E. Simth, Inc. 15

Humandata, Ltd. 37 Saelig Co., Inc. 21

IAR Systems 19 Scidyne 76

Imagineering, Inc. C4 Technologic Systems 23, 33

Ironwood Electronics 15 Triangle Research International, Inc. 76

NOT A SUPPORTING COMPANY YET?


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 • JANUARY 2015 #294

CONTENTS JANUARY 2015 • ISSUE 294

EMBEDDED
APPLICATIONS

WEBCAM MOUSE PROJECT

 CC COMMUNITY FEATURES
06 : QUESTIONS & ANSWERS 16 : Virtual Instrumentation
3-D Printed Robotics Innovation A Tool for Characterizing NMOS Transistors
An Interview with Joel Gibbard By Ahron Emanuel, Shlomo Engelberg, & Dvir Ophir
Dextrus robotic hand designer tells us about his work How to build a virtual instrument to characterize
with prosthetics, 3-D printing, and more enhancement mode N-channel MOSFETs (NMOSs)

24 : Webcam Mouse
INDUSTRY & ENTERPRISE By Alex Leung & Miles Pedrone
11 : PRODUCT NEWS A microcontroller-based webcam mouse design that
tracks a user’s finer movements
15 : CLIENT PROFILE
Labcenter Electronics (Newmarket, Ontario, Canada) 30 : Measuring Small Currents
By David Ludington
Use simple circuits to extend the current measurement
of hand-held multimeters

40 : Build a Duodecimal Clock


By Devlin Gualtieri
A do-it-yourself, PIC-based two-digit clock any
engineer would love

46 : The Twin-T Oscillator Configuration


An Audio Oscillator and Stereo VU Meter
By Larry Cicchinelli
A single battery-powered instrument for performing
significant audio circuit testing and debugging

DESIGNING THE DEXTRUS ROBOTIC HAND


circuitcellar.com 5

CONTENTS

DIY TWO-DIGIT DUODECIMAL CLOCK INNOVATIVE MOTOR CONTROL

COLUMNS TESTS & CHALLENGES


52 : THE CONSUMMATE ENGINEER 77 : TEST YOUR EQ
Essential Electromagnetic Compliance (Part 2)
A Look at EMI Causes and Signal Types 78 : CROSSWORD
By George Novacek
An examination of EMI causes and an explanation of the
difference between DM and CM signals TECH THE FUTURE
79 : The Future of Electrical Engineering
56 : ABOVE THE GROUND PLANE Several prominent Circuit Cellar contributors share their
Brute-Force Universal Motor Control thoughts on the future of electrical engineering
By Ed Nisley
An innovative quiet motor controller design

62 : GREEN COMPUTING
Adaptive Applications for Energy Efficiency
By Ayse K. Coskun
Power management with adaptive software
applications that can dynamically tune themselves

66 : FROM THE BENCH


Current Tracking
How to Monitor Current Flow Under Various
Operating Conditions
By Jeff Bachiochi
The design and construction of a display for monitoring
a vehicle’s current flow

BUILD A BATTERY STATUS MONITOR


@editor_cc
@circuitcellar circuitcellar
6 CIRCUIT CELLAR • JANUARY 2015 #294

QUESTIONS & ANSWERS

3-D Printed Robotics Innovation


An Interview with Joel Gibbard
Joel Gibbard created the Detrus
robotic hand and founded the
Open Hand Project. In this
interview he tells us about
his interests in robotics,
prosthetics, 3-D printing, and
more.
COMMUNITY

CIRCUIT CELLAR: Give us some background. starting to come out when I was about 6 or 7
Where do you live? Where did you go to years old. I think from ages three to 15 every
school? What did you study? single birthday or Christmas present was a
new Lego set. To this day, I still think Lego is
JOEL: I was born in Bristol, UK, and grew the best tool for rapid prototyping in the early
up in that area. Bristol is a fantastic place stages of an idea.
for robotics in the UK, so I couldn’t have
had a better place to start from. There’s a CIRCUIT CELLAR: Tell us about your first
lot to engage children here, like the highly design/some of your early projects. Do you
popular @Bristol science museum. I studied have any photos or diagrams?
for a degree in Robotics at the University of
Plymouth, which encourages a very practical JOEL: The earliest project I remember working
approach to engineering. Right from the on with my father was a full-scale model of
first year we were working with electronics, the space shuttle complete with robotic arm
robotics, and writing code. and fully motorized launch pad. When on the
launch pad it was almost my height. I think
CIRCUIT CELLAR: When did you first start my father took having kids as an opportunity
working with robotics? to get back into making things. We also made
a Saturn 5 rocket, Sydney Harbour Bridge and
JOEL: The first robots I ever made were using Concorde. One of my first robots was this
the Lego MINDSTORMS NXT robotics kits. little guy shown in the photo below. It had
I was very lucky because these were just tracks, a double-barreled gun on one arm, a
If you do, than we
will match the price
AND give you $100
towards your
next order!

THERE ARE NO GAMES INVOLVED IN OUR PRICING

Our Capabilities:
From same day quick turn prototype to production in under 10 days
Full CAD and CAM review plus design rule check on ALL �erber �les
Materials: Fr4, Rigid, Flex, Metal Core (Aluminum), Polymide, Rogers, Isola, etc.
HDI Capabilities: Blind/Buried Mocrovias, 10+N+10, Via-in-Pad Technology,
Sequential Lamination, Any Layer, etc.
Our HDI Advantage: Direct Laser Drilling, Plasma De-Smear Technology, Laser
Microvia, Conductive Plate Shut.
Take the Accutrace Challenge and see WHY OUR PRICING CANNOT BE BEATEN

www.PCB4u.com sales@PCB4u.com
8 CIRCUIT CELLAR • JANUARY 2015 #294

QUESTIONS & ANSWERS

pincer on the other, and a submarine on the


back, just in case. I think I was about eight
years old in this photo.

CIRCUIT CELLAR: You originally developed


the Dextrus robotic hand while you were
at the University of Plymouth. Why did you
design the system? How has its development
progressed since the original concept?

JOEL: I have a sketchbook of around 10 to 20


inventions that are options for the next thing
I want to make. This grows faster than it
shrinks. One day I was thinking about what
to make next and the thought occurred to me
that if I were to lose my hand, I wouldn’t be
able to make anything. So it made the most
sense to design a hand to have just in case.
Once I have that, heaven forbid I need to; I
could use it to then make a better hand, and
COMMUNITY

so forth, until I have a robot hand that is as


good as a human hand. It sounds ridiculous,
but that was enough motivation for me to
make the first one.
After posting the project on YouTube, I
received comments from people asking to
have the designs to make their own, which
wasn’t really possible, since it was such a
one-off prototype. But I thought it was a good
idea. Why not make an open-source hand?
After that, I looked more into prostheses and
discovered that this is really necessary and
people want it.

CIRCUIT CELLAR: The Dextrus incorporates


3-D printed parts. How does the 3-D printing
factor in your design? Does it make each
hand customizable?
Early Dextrus design
JOEL: 3-D printing is essential to the design.
Many of the parts have cavities inside them,
which wouldn’t be possible to make using
injection molding. One would have to make the
parts in two halves then glue them together,
which creates weak points. With 3-D printing,
each part is one solid piece with cavities for
the tendons to slide through.
Customization is a great area to explore
in the future. It’s quite easy to modify things
like the length and shape of the fingers while
maintaining the functionality of the hand. In
the not-too-distant future, I could envisage
an amputee 3-D scanning their remaining
hand and sending the scan to me. I could
then reverse it and match their Dextrus hand
(approximately) to the dimensions of their
other hand.

CIRCUIT CELLAR: There are three types of


Dextrus robotic hands: The Dextrus, the
Dextrus EMG, and the Dextrus Research. Can
3-D printed Dextrus hand you describe the differences?
circuitcellar.com 9

QUESTIONS & ANSWERS

JOEL: They have the same basic design and


components. The Dextrus and Dextrus EMG
are exactly the same, but the EMG comes with
all of the extras that enable someone to use
it as a myoelectric prosthesis. The Dextrus
Research has a number of differences that
result in a more robust (but more expensive
and heavier) hand. It has steel ball bearings
instead of nylon bushes and is printed with
denser plastic. It also comes with everything
you need to use it straight out of the box (e.g.,
a power supply).

CIRCUIT CELLAR: You founded the Open


Hand Project (www.openhandproject.org)
as a result of your work on the Dextrus
robotic hand. Describe the project and its
purpose.
Dextrus Research fingers
JOEL: The aim of the Open Hand Project is

COMMUNITY
to make advanced prosthetic hands more
accessible to amputees. It has the potential
to revolutionize the prosthetics industry At the moment, it uses electromyographical
by trivializing the cost of prosthetics (to signals, which sound advanced but are
insurance companies). I also hope that it actually 50-year-old technology and don’t
will help to advance prosthetic hands. If the give complex functionality like individual
hardware is much less expensive, we can finger movement. If the hardware is
start to focus on the human robot interface. inexpensive, then money can instead be
10 CIRCUIT CELLAR • JANUARY 2015 #294

QUESTIONS & ANSWERS

JOEL: National Instruments has been great


since I’ve left the company. I explained what
I wanted to do, and it was fully supportive.
To get the equipment, all I had to do was
ask! It really does live up to its reputation of
being one of the best places to work. I hope
that I’ll be able to repay them with business
in the future. If I’m successful, then I’ll be
able to buy equipment for future projects.

CIRCUIT CELLAR: Why did you decide to use


crowd funding for this project?

JOEL: I wanted to keep everything open


source for this project. Investors don’t want
to fund an open-source project. You have no
leverage to make money and your ideas will
be taken and used by other people (which
is encouraged). For this reason, only people
who are genuinely interested in the vision
COMMUNITY

of the project will want to invest, and that’s


just not something that will make a company
money. Crowdfunding is perfect, because
people appreciate how this can help people
and they’re willing to contribute to that.
I believe that everyone should have
access to public health care and that your
level of care should not be dependent on the
size of your wallet. Making prosthetics open
source will be a step in the right direction,
but this model does not have to be limited to
prosthetics.
Take the drugs industry for example.
Drugs companies work off patents, they have
to patent their drugs in order to make back
the millions of dollars they spend developing
them and end up charging $1,000 for a pill
that costs them $0.01 to make in order
to cover all of their costs. If the research
was publicly funded and open source,
The Dextrus design process the innovations in this industry would be
dramatically accelerated and once drugs
were developed, they could be sold more
cheaply, if sale of the drugs was government
spent on operations to tap into the nervous regulated, the price could be controlled and
system and then the hand can literally be the money could go back into funding more
a direct replacement for the human hand. developments.
You’ll think about moving your hand and
the robotic hand will do exactly what you’re CIRCUIT CELLAR: What’s next for the
thinking. If done correctly, you’ll also be able Dextrus?
to feel with it. We’re talking Luke Skywalker
Star Wars tech. It exists now, but is not yet JOEL: There are a few directions I’d like this
fully tested and proven. project to go in. First and foremost is the
development of low-cost robotic prostheses
CIRCUIT CELLAR: Prior to venturing out for adults. After this, I’d like to look into
on your own, you were an Applications partial amputations and finger prostheses.
Engineer at National Instruments (NI). I’d also like to try and miniaturize the hand
Although you are no longer working for so that children can use it as well.
the company, it is backing the Open Hand
Project by providing test and measurement
equipment. How did NI become involved in
the project?
circuitcellar.com 11

PRODUCT NEWS

REJUVENATED ARBITRARY/FUNCTION WAVEFORM GENERATOR LINE


B&K Precision announced that it rejuvenated the 4075B specific points in an arbitrary waveform, users can benefit
Series of arbitrary/function waveform generators with higher from the instrument’s fully programmable markers, which
frequency ranges, increased arb memory, and a color LCD. allow the unit to generate a positive TTL level signal at a
The new 4075B Series offers six new models that directly specified waveform address.
replace the previous 4075 line with single- and dual-channel The 4075B Series provides eight full memory banks per
30-MHz (4075B/4078B) and 50-MHz models (4076B/4079B) channel for user-defined arbitrary waveforms and 49 locations
along with two additional single- and dual-channel 80-MHz to store/recall instrument settings. Arbitrary waveforms can
models (4077B/4080B). Each model can generate arbitrary be created from the front panel or loaded using B&K’s free
waveforms with 14-bit amplitude resolution, a 200-Msps WaveXpress waveform editing software. WaveXpress is a
sample rate, and up comprehensive stand-
to 16,000,000 points alone application that
(depending on model). offers several waveform
These instruments are editing tools for users
ideal for use in electronic to easily create and
design, sensor simulation, load complex arbitrary
and functional test. waveforms onto the AWG

INDUSTRY & ENTERPRISE


Designed with a dual via the SCPI-compatible
technology architecture, USBTMC or GPIB (50 and
the 4075B Series 80 MHz models only)
combines the benefits interface on the rear.
of traditional DDS Other features of the
(direct digital synthesis) 4075B Series include
technology and a true AM/FM/FSK modulation
AWG (arbitrary waveform schemes, linear and
generator). DDS allows standard sine, square, and triangle logarithmic sweep, and built-in overvoltage and short circuit
waveforms to be generated with great frequency resolution protection for resistive and capacitive loads on all inputs and
at a low cost while the true AWG architecture implements outputs to prevent accidental damage to the instrument.
custom arbitrary waveforms with a point-by-point design. Available immediately, B&K Precision’s 4075B Series
This design significantly minimizes jitter and improves signal products are all backed by a standard 3-year warranty and
integrity of the arbitrary waveform. listed at the following prices ranging from $1,495 (Model
Similar to their predecessors, the new 4075B Series 4075B) to $3,690 (Model 4080B).
generators offer a menu-driven front panel keypad with
rotary encoder knob and convenient range selection buttons B&K Precision
to make adjustments quickly and easily. Additionally, all www.bkprecision.com
models provide multi-unit/channel synchronization and
external triggering capabilities. For precise triggering at

LOW-JITTER 1.25-GSPS CLOCK OPTIMIZES JESD204B SERIAL INTERFACE


FUNCTIONALITY IN GSPS DATA CONVERTER APPLICATIONS
Analog Devices recently introduced the AD9528 JESD204B a divider phase-select function that serves as a jitter-free,
clock and SYSREF generator defined to support the clock coarse timing adjustment in increments that are equal to half
requirements for long-term evolution (LTE) and multicarrier the period of the signal coming from the VCO output. The
GSM base station designs, defense electronics systems, RF SYSREF signals each have additional phase offset capability
test instrumentation, and more. According to Analog devices, making it easy to dial-in the optimal arrival time at each
the JESD204B interface was developed “to address high- target device.
data rate system design needs, and the AD9528 clock device The AD9528 can be designed into wideband RF data
contains functions that support and enhance the unique acquisition applications with ADI’s AD9680 dual-channel, 14-
capabilities of that interface standard.” The AD9528 provides bit, 1.0-GSPS JESD204B A/D converter.
a low-power, multi-output, clock distribution function with The AD9528BCPZ costs $8.25 in 1,000-piece quantities.
low-jitter performance, along with an on-chip, two-stage PLL The evaluation board costs $190.
and VCO. The on-chip VCO tunes from 3.6 to 4.0 GHz.
When connected to a recovered system reference clock Analog Devices
and a VCXO, the AD9528 generates 12 low-noise outputs with www.analog.com
a range of 1 to 400 MHz and two high-speed outputs at up
to 1.25 GHz. The frequency and phase of one clock output
relative to another clock output can be varied by means of
12 CIRCUIT CELLAR • JANUARY 2015 #294

PRODUCT NEWS

EXTENDED DISTANCE MODULES


SUPPORT WISA WHOLE HOUSE AUDIO
SPECIFICATION
Summit Wireless, a division of Summit Semiconductor (from
Portland, Oregon), supported the Wireless Speaker and Audio
(WiSA) Association demonstrations at the CEDIA Expo 2014 in
September. During the show, WiSA announced new multi-zone
requirements and feature set for simultaneous support of both
wireless home theater playback and multi-zone stereo audio
streams. WiSA compliant systems should be able deliver high
resolution, uncompressed audio, up to 100 m line of sight or 20 to
40 m through walls.
Summit Semiconductor confirms availability of new extended
distance transmit and receive modules for those multi-zone home
theater and whole home audio applications with support to the
WiSA Association’s updated compliance and interoperability test
INDUSTRY & ENTERPRISE

specification. The new extended distance modules come pre-certified by


WiSA members recognize the growth of whole house stereo country and are backward compatible to the prior generation of
audio solutions in the market place and the practical need to Summit’s home theater wireless modules. Engineering samples
keep system cost down for mass market acceptance. With the for the new extended distance modules are available from
new extended distance radio capabilities, a single system will also Summit Semiconductor.
provide consumers with a WiSA-compliant home theater system “We’re excited to offer the new extended distance modules
and a whole house system. in support of the WiSA Association’s multi-zone and whole house
The new Summit Semiconductor modules can transmit initiative,” says Tony Parker, vice president of marketing, Summit
high quality, uncompressed audio up to 100 m line of site. Semiconductor. “This is a perfect tool for audio products that
When integrated in an AVR, audio hub, HDTV, Blu-ray player or need high resolution multi-channel audio, but want to appeal to
gaming console, a single transmit module can manage up 32 a broader base as a multi-media whole house platform. Products
speakers, and 8 different zones with separate volume control such as a HDTV, AVR/Pre-amp, game console, soundbar and HTiB
while simultaneously supporting both home theater and multi- can benefit significantly from adding these modules to their
zone audio transport. For example, during the CEDIA Expo the designs.”
WiSA Association demonstrated a wireless 5.1 home theater
system with Summit’s extended distance modules that will also Summit Semiconductor
simultaneously transmit a separate stereo pair with different www.summitsemi.com
content to a separate location.

ULTRA-THIN 1.8-MM, 3A MICROMODULE REGULATOR


Linear Technology Corp. recently announced the LTM4623 controllers, and 40-to-100-Gbps network equipment.
3A µModule (micromodule) step-down regulator in an The LTM4623 solution fits in a 0.5 cm2 dual-sided PCB
ultrathin 1.8-mm profile LGA package with only a 6.25 mm or less than 1 cm2 on a single-sided PCB. The circuit only
× 6.25 mm footprint. With solder paste, the package height requires one input capacitor and one output capacitor, a
is less than 2 mm, meeting the height restrictions of many resistor to set VOUT, and a small capacitor for VOUT tracking
PCIe, Advanced Mezzanine Cards and soft-start. With an auxiliary
(AMC) for AdvancedTCA carrier 5-V bias, the LTM4623 operates
cards in embedded computing from input supplies as low as
systems. The small size and low 2.375 V. The operating efficiency
height allow the LTM4623 to be for converting 12 VIN to 1.5 VOUT
mounted on the backside of the and 3.3 VOUT at 3A is 80% and
PCB, freeing space on the topside 88%, respectively. Power loss
for components such as memory for 12 VIN to 1.5 VOUT is 1.1 W,
and FPGAs. resulting in only a 24°C rise
The LTM4623 operates from in junction temperature. The
4-to-20-V input supplies and LTM4623 is rated for operation
precisely regulates an output from –40°C to 125°C.
voltage from 0.6 to 5.5 V with One thousand-piece pricing
1.5% maximum total DC output starts at $6.05 each.
voltage error. Application
examples include ultra- Linear Technology
dense data storage, gateway www.linear.com
circuitcellar.com 13

PRODUCT NEWS

ARM-BASED EMBEDDED POWER FAMILY


FOR SMART MOTOR CONTROL
Infineon recently announced an ARM-based Embedded
Power family of bridge drivers offering an unmatched level of
integration to address the growing trend towards intelligent
motor control for a wide range of automotive applications.
The Embedded Power family offers 32-bit performance in an
application space that it is typically associated with 16-bit.
Sample quantities of the first members of the Embedded Power
family are available for the TLE987x series for three-phase
(brushless DC) motors and the TLE986x series for two-phase
(DC) motors. 5.4 V up to 28 V. An integrated charge pump enables low-voltage
Infineon combined its proprietary automotive qualified operation using only two external capacitors. The bridge drivers
130-nm Smart Power manufacturing technology with its feature programmable charging and discharging current. The
vast experience in motor control drivers into the new, highly patented current slope control technique optimizes the system
integrated Embedded Power family, available in a standard QFN EMC behavior for a wide range of MOSFETs. The products can

INDUSTRY & ENTERPRISE


package of only 7 mm × 7 mm in dimension. Where previous withstand load dump conditions up to 40 V while maintaining
multi-chip designs needed a standalone microcontroller, an extended supply voltage operating down to 3.0V where the
a bridge driver, and a LIN transceiver, automotive system microcontroller and the flash memory are fully functional.
suppliers now benefit from motor control designs of minimum The TLE987x series of bridge drivers addresses three-phase
external components count. The newly released Embedded (BLDC) motor applications such as fuel pumps, HVAC blowers,
Power products reduce the component count down to less than engine cooling fans, and water pumps. It supports sensor-less
30, thus allowing integration of all functions and associated and sensor-based (including field-oriented control) BLDC motor
external components for the motor control in a PCB area of applications addressed by LIN or controlled via PWM.
merely 3 cm². As a result, the Embedded Power family enables The TLE986x series is optimized to drive two-phase DC
the integration of electronics close to the motor for true motors by integrating four NFET drivers. The TLE986x series is
mechatronic designs. suitable for applications such as sunroofs, power window lifts
Both the TLE987x and TLE986x bridge drivers use the ARM and generic smart motor control via NFET H-Bridge.
Cortex TM-M3 processor. Their peripheral set includes a current Engineering samples of the TLE987x and TLE986x bridge
sensor, a successive approximation 10-bit ADC synchronized drivers in a space-saving VQFN-48 package are available with
with the capture and compare unit (CAPCOM6) for PWM volume production planned to start in Q1 2015. For both series,
control and 16-bit timers. A LIN transceiver is integrated to there are several derivatives available, differing for example in
enable communication to the devices along with a number system clock (24 MHz or 40 MHz) and flash sizes.
of general-purpose I/Os. Both series include an on-chip
linear voltage regulator to supply external loads. Their flash Infineon
memory is scalable from 36 to 128 KB. They operate from www.infineon.com

NEW FREQUENCY-PROGRAMMABLE,
NARROW-BAND TRANSMITTER
RF module designer and manufacturer Lemos International/
Radiometrix recently launched a new range of flexible,
frequency-programmable, RF power adjustable radios. The new
NTX2B Transmitter offers industry-leading true Narrow-Band
FM performance. It is available on user/factory-programmable
custom frequencies between 425 and 470 MHz. Superseding the the transmitter to be operated down to 2.9 V and up to 15-V
popular NTX2, the new transmitter offers greater stability and voltage supply at a nominal current consumption of 18 mA and
improved performance due to VCTCXO reference. The NTX2B less than 3 µA in power-down mode, which can be enabled
provides users with the ability to dynamically reprogram within 5 ms. NTX2B can transmit both digital and 3-VPP analog
the module via the microcontroller UART to other channel signals. Offering greater range than wideband modules, the
frequencies in the band or store new frequency/power settings transmitter can be paired with the new NRX2B receiver for a
on EEPROM. usable range of over 500 m, which is ideal for performance-
The standard NTX2B version is a 10-mW, 25-kHz narrow- critical, low-power wireless applications, including security,
band Transmitter with data rates up to 10 kbps and is available sensor networks, industrial/commercial telemetry and
on 434.075 and 434.650 MHz European SRD frequencies and remote control.
25 mW on 458.700 MHz for the UK. The NTX2B is also available
with 12.5- or 20-kHz channel spacing for licensed US FCC Part Lemos
90 or legacy European Telemetry/Telecommand bands. The www.lemosint.com
NTX2B features an internal LDO voltage regulator that enables
14 CIRCUIT CELLAR • JANUARY 2015 #294

PRODUCT NEWS

PIC32MX1/2/5 MICROCONTROLLERS FOR EMBEDDED CONTROL & MORE


Microchip Technology’s new PIC32MX1/2/5 series enables a PIC32, the MPLAB ICD3 in-circuit debugger, and the MPLAB REAL
wide variety of applications, ranging from digital audio to general- ICE in-circuit emulation system also support the series.
purpose embedded control. The microcontroller series offers a The PIC32MX1/2/5 Starter Kit costs $69. The new
robust peripheral set for a wide range of cost-sensitive applications PIC32MX1/2/5 microcontrollers with the 40-MHz/66 DMIPS speed
that require complex code and higher feature integration. option are available in 64-pin TQFP and QFN packages and 100-
The microcontrollers feature: pin TQFP packages. The 50-MHz/83 DMIPS speed option for
this PIC32MX1/2/5 series is expected to be available starting in
• Up to 83 DMIPS performance late January 2015. Pricing starts at $2.75 each, in 10,000-unit
• Scalable memory options from 64/8-KB to 512/64-KB quantities.
flash memory/RAM
• Integrated CAN2.0B controllers with DeviceNet addressing Microchip Technology
support and programmable bit rates up to 1 Mbps, along www.microchip.com
with system RAM for storing up to 1024 messages in 32
buffers.
• Four SPI/I2S interfaces
• A Parallel Master Port (PMP) and capacitive touch sensing
INDUSTRY & ENTERPRISE

hardware
• A 10-bit, 1-Msps, 48-channel ADC
• Full-speed USB 2.0 Device/Host/OTG peripheral
• Four general-purpose direct memory access controllers
(DMAs) and two dedicated DMAs on each CAN and USB
module

Microchip’s MPLAB Harmony software development framework


supports the MCUs. You can take advantage of Microchip’s
software packages, such as Bluetooth audio development suites,
Bluetooth Serial Port Profile library, audio equalizer filter libraries,
various Decoders (including AAC, MP3, WMA and SBC), sample-
rate conversion libraries, CAN2.0B PLIBs, USB stacks, and graphics
libraries.
Microchip’s free MPLAB X IDE, the MPLAB XC32 compiler for

NEW FULLY DIFFERENTIAL


AMPLIFIERS (FDAs)
Texas Instruments has announced two new fully
differential amplifiers (FDAs) intended to improve
performance in radar and test and measurement
equipment and wireless base stations. The LMH3401
and LMH5401 FDAs provide DC-coupled applications
with high-quality AC performance to improve system
capabilities. They offer a higher bandwidth and slew
rate, as well as lower distortion than existing ADC
drivers.
The LMH3401 delivers 7 GHz of –3-dB bandwidth
at 16-dB gain, a high slew rate of 18,000 V/µs, and
low harmonic distortion of –77 dBc at 500 MHz. The
LMH5401 can be configured for 6 dB of gain or more,
delivering 6.2 GHz of -3 dB bandwidth at 12-dB gain.
The LMH3401 and LMH5401 are available in a 14-
pin, 2.5-mm × 2.5-mm QFN package. The LMH3401
costs $8.95 and the LMH5401 coss $7.95 in 1,000-unit
quantities.

Texas Instruments
www.ti.com
circuitcellar.com 15

CLIENT PROFILE

Labcenter Electronics
www.labcenter.com
Newmarket, Ontario, Canada
CONTACT: Don Jackson, don.jackson@labcenter.com

FEATURED PRODUCT: Proteus Design Suite Version 8—


Proteus Design Suite is a PC-based CAD tool that includes
Schematic Capture (ISIS), Microprocessor Simulation
(VSM) Advanced Simulation (ASF) for graphing of mixed
mode designs and PCB Layout (ARES).

WHY SHOULD CC READERS BE INTERESTED? The


Proteus Design Suite integrates Schematic Capture,
Circuit Simulation and PCB Layout. Circuit simulation is

INDUSTRY & ENTERPRISE


of the full schematic, including microprocessors from
many of the major vendors, including, Microchip, Atmel, SPECIAL OFFER: Proteus Version 8 Offer for Circuit
TI, ARM7, Cortex, etc., as well as analog and digital Cellar—Save 10%. Use Promo Code CCIPRF2015 when
devices. Items such as LCDs, GLCDs, switches, and placing your order. Offer expires March 31, 2015.
sensors are all simulated and operate in the schematic
just as they would in a circuit on your work bench.
During the simulation the user can interact with the Circuit Cellar prides itself on presenting readers with information
design, stop, single step the code in the micro to verify about innovative companies, organizations, products, and services
its function. Debugging tools such as I 2C and SPI are relating to embedded technologies. This space is where Circuit
included. The PCB Package is easy to use, and intuitive. Cellar enables clients to present readers useful information, special
Proteus is an excellent tool for rapid design. deals, and more.

RS485/422/232/TTL
ASC24T IBS485HV
RS232<=>RS485 ATE Converter 5 Port Isolated
RS485 Repeater
$349.00

$45.00 board only Enclosur es, Cables,


Power Supplies and Other
Accessories

INTRODUCING THE SMFCOMX!


• Extended Distance Units
• Converters • Serial to Digital I/O
• Repeaters • Large Multi-Drop Networks
• Multi-Repeaters
• Custom Units &
• Hubs
Smart Units

P
• Fiber Optics RoHS
• Isolators • Industrial, 3.0 KV Isolation
Call the RS485 Wizards
513-874-4796
www.rs485.com
16 CIRCUIT CELLAR • JANUARY 2015 #294

Virtual
Instrumentation
A Tool for Characterizing
NMOS Transistors
FEATURES

You can build a virtual instrument to characterize enhancement mode N-channel


MOSFETs (NMOSs). This article details the process, as well as how to design a single-
stage amplifier around the transistor. All you need is a PC running MATLAB, an Analog
Devices ADuC841 microcontroller, and a little hardware.

By Ahron Emanuel, Shlomo Engelberg, and Dvir Ophir (Israel)

A s the years go by, more and more test and


measurement instrumentation is “virtual
instrumentation”—that is, instrumentation
voltage less the threshold voltage, V t, and that
the gate voltage is at least V t above the source
voltage. In this mode, the relation between
implemented in part by a general-purpose the current passing from the drain to the
computer.[1] We decided to design and source and the voltage drop between the gate
build a simple piece of equipment, a virtual and the source is often taken to be:
instrument, to characterize enhancement
k 'N ( v GS − VT ) 2
mode n-channel MOSFETs (NMOSs) and i DS =
2
to design a simple single-stage amplifier
around the now well-characterized transistor. However, the extent to which this equation
We made use of a PC running MATLAB, an actually describes the relation between the
Analog Devices ADuC841 microcontroller with voltage drop from the gate to the source
programs written in its assembly language, and the current flowing from the drain to the
and assorted hardware. The experience was source depends on the precise nature of the
pleasant, and the results were both good and MOSFET transistor.
interesting. By making a sequence of well-chosen
measurements, we measured the two
SIMPLE TRANSISTOR MODEL parameters we needed, the threshold voltage,
When implementing an NMOS-based V t, and K n’, for two different types of MOSFETs.
amplifier, you generally want the transistor to
operate in its saturation mode. To operate a HARDWARE (FIRST PART)
transistor in this mode, you must make sure Considering the way an NMOS transistor
that the drain voltage is at least the gate is assumed to operate, the circuit in
circuitcellar.com 17

Figure 1 should provide an easy way to FIGURE 1


measure the threshold voltage, V t . How When VDD is greater than the
should the circuit operate? By tying the gate VDD transistor’s threshold voltage, Vt, the
and drain together, we should be guaranteed gate-source voltage ought to equal the
threshold voltage.
that the transistor is either saturated or cut
off. Assuming that the voltage applied to

FEATURES
the drain, V DD, is greater than the threshold
voltage, the transistor remains saturated
until the source voltage, the voltage on the
capacitor, rises to V DD – V t . At that point, the
transistor is cut off, current stops flowing,
and the voltage on the capacitor is fixed at
V DD – V t . The voltage drop from the gate to
the source—which is tied to the capacitor—is
exactly V t , and we have a really nice way
of measuring the threshold voltage. At
first, we thought that we had taken care DAC
of measuring the threshold voltage in a
really nice way. As we’ll see in a little while,
it is not always quite this simple, and the
measurement must be performed using a ADC
different technique, which we describe in
the next section.

HARDWARE (SECOND PART) FIGURE 2


Our second measurement circuit is This simple circuit for making
shown in Figure 2. We have the ADuC841’s measurements enables you to
digital-to-analog converter providing the calculate the both kn’ and Vt.
circuit’s drain voltage. By connecting the
drain to the gate, we guarantee that when relation between the gate-source voltage and
the voltage drop from the gate to the source, the drain current becomes exponential. In
v GS, is greater than the threshold voltage this region, you find that[2]:
the transistor should be operating in its vGS

saturation mode. When v GS is at or below i DS = k nVT


the threshold voltage, the transistor should
be cut off and no current should flow. In If you plot the square root of the drain
principle, by measuring the current through current against the gate-source voltage, you
and the voltage drop on the resistor, it should
be easy to measure V t and K n’.
In fact, taking the square root of the
current-voltage relation, we find that:
k 'N ( v GS − VT )
i DS =
2
We find that the square root of the drain
current is related to the gate-source voltage
in a linear way; two measurements of iDS and
v GS should suffice to give us V t and K n’.
We made many measurements, we plotted
the square root of the drain current against
the gate-source voltage, and we expected to
see a near-perfect straight line. We did not
(see Figure 3)!

THEORY TO THE RESCUE


When you take a more careful look at a
MOSFET’s modes of operation, you find that
there is “room” for one more mode between
saturation and cutoff. When the gate-source
voltage is near the threshold but below it, the FIGURE 3
transistor is not actually cut off—the drain A plot of the square root of the drain current as a function of the gate-source voltage. Note that the plot only
current does not drop to zero. Instead, the appears linear for voltages somewhat greater than 2 V.
18 CIRCUIT CELLAR • JANUARY 2015 #294

should find that for relatively large values square root of iDS against the gate-source
of the voltage the plot looks linear while for voltage was linear over the range of currents
small values of the voltage the plot looks more and voltages that we measured.
“exponential.” That is what we found (see
Figure 4 and Figure 5). Additionally, we made OUR VIRTUAL INSTRUMENT
our measurements on a BS170 power TMOS To organize our analysis and design efforts
FEATURES

transistor, and these do not behave precisely in the most effective way—in order to build our
the way small-signal NMOS transistors do. virtual instrument—we designed a MATLAB-
We made measurements on a small-signal based system to control the ADuC841, to
transistor too. In that case, the plot of the analyze the results of the measurements
made by the ADuC841, and to design and test
a simple amplifier. The final implementation of
the circuit used to characterize the transistor
is shown in Figure 6.
By measuring the voltages above and
below the “upper” 330-Ω resistor, we can
calculate the current through the resistor,
which is iDS. Using the measured values of
iDS and the values of the gate-source voltage,

ABOUT THE AUTHORS


Ahron Emanuel (ahronemanuel@gmail.com)
received his Bachelor’s degree in Electronics
Engineering from the Jerusalem College of
Technology – Machon Lev. He currently holds
a position as an electronics engineer, and
his interests include analog electronics and
communications.

Shlomo Engelberg (shlomoe@jct.ac.il) re-


ceived his Bachelor’s and Master’s degrees
in Engineering from The Cooper Union and
FIGURE 4
his PhD in Mathematics from New York Uni-
A plot of the square root of the drain current as a function of the gate-source voltage for voltages somewhat
above 2.2 V. versity’s Courant Institute. He is an associ-
ate professor in the Electronics department
of the Jerusalem College of Technology –
Lev Academic Center and is the author of
many articles and several books, the lat-
est of which are Digital Signal Processing:
An Experimental Approach (Springer, 2008)
and ADuC841 Microcontroller Design Man-
ual: From Microcontroller Theory to Design
Projects (Circuit Cellar, 2011). Shlomo’s re-
search interests include applied mathemat-
ics, instrumentation and measurement, sig-
nal processing, coding theory, and control
theory.

Dvir Ophir (dvir.ophir@gmail.com) is cur-


rently completing a BS degree in Electron-
ics Engineering at the Jerusalem College
of Technology – Machon Lev. He currently
holds a position as a security engineer and
consultant with hands-on experience in the
fields of information security and network-
ing. Dvir’s interests include application se-
FIGURE 5
A plot of the logarithm of the drain current as a function of the gate-source voltages for voltages below the
curity and programming.
threshold voltage, Vt.
20 CIRCUIT CELLAR • JANUARY 2015 #294

FIGURE 6
This is the final measurement circuit.
In order to use voltages of up to ±10 V
without using an additional power
supply, we used a MAX681 +5 to ±10-V
voltage converter. T1 is the transistor
being examined, the device under test
FEATURES

(DUT). The voltage output by DAC0


is doubled by a simple noninverting
amplifier, and T1’s drain voltage is
halved before being passed to the
ADuC841’s A/Ds. By making use of
this circuit, we are able to make our
measurements with voltages larger
considering the square root of iDS for large the second window, the ADuC841 outputs a
than would be possible with the much
simpler circuit of Figure 2.
values of the gate-source voltage and the sinewave to the amplifier and measures the
logarithm of iDS for small values of the gate- amplifier’s response. It also calculates the
source voltage, and making use of linear amplifier’s gain (see Figure 9).
regression in each region separately, we
have MATLAB estimate the values of the THE DEVIL IS IN THE DETAILS
parameters that characterize the transistor In implementing our virtual instrument,
in each régime. we designed a simple communication
Our system makes use of a MATLAB-based protocol for use the PC and the ADuC841.
graphical user interface (GUI) designed We’ll now describe the protocol and its
using the MATLAB GUIDE program. The GUI implementation.
enables you to run all measurement and In our virtual instrument, the ADuC841
view all results using two MATLAB-generated acts as a slave to the PC. The control channel
windows. The first window allows MATLAB, is the connection between the PC’s UART and
the user, and the ADuC841 to analyze a the ADuC841’s UART. When designing the
transistor (see Figure 7). communications protocol—in choosing which
After analyzing the transistor, you click ASCII codes to send between the ADuC841
on the Design Amplifier button at the bottom and the PC using the control channel—we
of the first window. MATLAB then opens a chose to restrict ourselves to using easily
second window and enables you to give design readable ASCII codes—either numbers or
criteria for a common source amplifier. capital letters. The sixteen ASCII codes
MATLAB designs the amplifier and tells you corresponding to the characters 0,…, 9, A,…, F
what values of R I and R D to use in order are reserved for use as digits in hexadecimal
to implement the amplifier (see Figure 8). numbers, and the control codes transmitted
After the you inform MATLAB that you have by the ADuC841 are characters that cannot
finished putting together the amplifier and appear as digits in a hexadecimal number.
connecting it to the ADuC841’s DAC and ADC Upon receiving the ASCII code for G (short
by pressing the Generate Wave button in for Go) from the PC via the UART, for example,

FIGURE 7
The “analysis” window. The plot on
the left shows iDS plotted against vGS.
The middle plot shows the square
root of the drain current plotted
against the gate-source voltage. The
magenta line is the best linear fit to
the measurements in that region. (The
user chooses the starting point of the
region.) The plot at the right shows
the best linear fit to the plot of the
logarithm of the drain current as a
function of the gate-source voltage.
Note that at the lower right there is
a button labeled “Design Amplifier.”
Hitting that button causes MATLAB
to allow the user to define a common
source amplifier around the now well
characterized transistor.
circuitcellar.com 21

TRANSLATING VALUES
There is a neat trick for performing the number-to-ASCII conversion. (We are not
sure of this trick’s origin. We’d love to hear from anyone who saw it long ago and can

FEATURES
us more about it.) One starts by defining an array in the 8051 family microcontroller’s
code segment using the following command:

HEX_NUM: DB ‘0123456789ABCDEF’

Following the conventions that now seem to be pretty standard for 8051 family
assemblers, this command cause an array whose values are the ASCII values of the
characters within the single quotes to be stored in the code segment (assuming that
that is the segment in which you are working). To convert a number between 0 and
15 to the relevant ASCII value, you now need only store the value to be converted in
the accumulator, A, and the location of the array HEX_NUM in the data pointer, DPTR.
You then give the single command MOVC A, @A+DPTR. This command uses the current
value of the accumulator, the value you are looking to translate into an ASCII value, as
an offset and reads the relevant value of the array into A (thus overwriting the value
you wanted to “translate” with the correct translation). Thus, if A starts off with a 5, it
ends up with the sixth element of the array (as there is an element with a zero offset)—
which is just the ASCII value of 5, and all of this takes place without any hard work on
the part of the programmer.
22 CIRCUIT CELLAR • JANUARY 2015 #294

FIGURE 8 the ADuC841 starts making measurements.


A common source amplifier with When it finishes making the measurements,
a current mirror used as a current
it transmits them to the PC, once again using
source for the transistor. The two
the UART. Each measurement takes up a
user-tunable resistors are RI and RD.
total of 2 bytes at the ADuC841’s side—and
Setting RI sets the bias current.
the 2 bytes are translated by the ADuC841
FEATURES

into four 4-bit nibbles. Each nibble is then


looked upon as a single hex digit and is
converted into the ASCII value of the related
digit. That is, the number zero is translated
into the ASCII value of the character 0, the
number 10 to the ASCII value of A, and the
number 15 to the ASCII value of F. (Refer
to the “Translating Values” sidebar for some
interesting details about this process.) The
ASCII values are then transmitted to the PC.
Because all of the ASCII values correspond to
human-readable characters, it is possible for
a person to look over the UART traffic (using
a simple program such as HyperTerminal)
and determine whether or not the system is
working sensibly.
After the PC running MATLAB receives the
measurements, MATLAB allows you to guide
it in the characterization of the transistor.
You can then specify an amplifier. As we
explained previously, MATLAB takes your
specs and tells you how to build the amplifier.
When you indicate to MATLAB (through the
GUI) that the amplifier is all hooked up
and ready to go, MATLAB sends the ASCII
code for “H” to the ADuC841 via the UART.
MATLAB then transmits a series of numbers
FIGURE 9
to the ADuC841—numbers that contain the
An idealized signal identical in amplitude to the signal input to the amplifier, but whose phase has been
adjusted to be the same as the (assumed) phase of the output (in blue) and the output of the amplifier (in
values to be sent to the ADuC841’s DAC to
red). In reality, only one period of the output was measured. To make the display more pleasing to the eye, test the amplifier. The ADuC841 then outputs
the same plot is repeated four times. When this window opens, the user inputs the power supply voltage and the values to the amplifier, measures the
the peak-to-peak voltage of the input. The user then clicks on “Calculate Resistors.” MATLAB then designs response of the amplifier, and sends the
a common source amplifier. The values of the two user-tunable resistors are then added to the window (in measurements back to the PC (once again
the upper-middle portion of the window). After tuning the resistors and hooking everything up properly, encoding each nibble as the ASCII value of
the user clicks on “Generate Wave” at which point MATLAB causes the ADuC841 to output a sinewave to the one of the 16 characters 0,…, 9, A,…, F).
amplifier and to measure the response. The ADuC841 passes the measurements back to MATLAB (using its Finally, MATLAB displays the output of the
UART), and MATLAB generates the plots displayed above.
amplifier.
It’s amazing what you can do with a
[2] Wikipedia, “MOSFET,” http://en.wikipedia. microcontroller and MATLAB. We wrote
org/wiki/MOSFET. simple routines for MATLAB and the ADuC841,
designed a relatively small amount of
RESOURCE hardware, and used the MATLAB GUI design
tool—the GUIDE—to develop a virtual
Analog Devices, “ADuC841: Precision Analog Mi-
instrument to characterize a MOSFET and
crocontroller: 20 MIPs 8052 Flash MCU + 8-Ch
design a common source amplifier on the
12-Bit ADC + Dual 12-Bit DAC,” 2003, www.
basis of that characterization. We found that
analog.com/en/processors-dsp/analog-
circuitcellar.com/ccmaterials the system works nicely, and in the process
microcontrollers/aduc841/products/product.html. of designing and implementing the system,
we learned a lot about transistors, the design
REFERENCES SOURCES of GUIs, and virtual instruments.
[1] Wikipedia, “Virtual In- ADuC841 Microcontroller
Authors’ Note: We gratefully acknowledge the
strumentation,” http:// Analog Devices | www.analog.com
help provided to us by Professor Aryeh Weiss
en.wikipedia.org/wiki/
of Bar Ilan University.
Virtual_instrumentation.
MATLAB
MathWorks | www.mathworks.com
DESIGN YOUR SOLUTION TODAY
CALL 480-837-5200

Touch Panel Computers TS-7670 Industrial Computer


Panel Mount or Fully Enclosed GPS & Cellular Modem to Track Assets

Pricing starts at
$168 $129
Qty 100 Qty 1

Series start at
$369
Qty 100

$409
Qty 1

low cost plastic


enclosure available

Features can include: Features:


5, 7, and 10 Inch Touchscreens 454MHz ARM CPU 1x USB Host
Fanless Operation from -20 ºC to 70 ºC Up to 256MB RAM 4x DIO, 2x CAN
Up to 1 GHz ARM CPU, 2 GB RAM, 4 GB eMMC Flash
2GB NAND Flash 2x COM, 1x RS-485
Ethernet, USB, DIO, CAN, RS-232, Modbus, SPI
2x mSD Card Socket 1x Battery Backed RTC
Optional Cellular, WiFi and XBee Radios
1x 10/100 Ethernet 1x Temperature Sensor
Supports Android & Linux with Fast Boot Times
Benefits:
Low power with 10mW sleep state

-40 to +85C, 100% soldered-on components

Easy development w/ Debian and Linux 2.6

Boots quickly to your Embedded Application

TS-TPC-8390-4800 Rear View TS-TPC-8390-4800 Angled View Guaranteed available until 2025

We’ve never Embedded Support every Unique embedded


discontinued a systems that step of the way solutions add
FE

L
D

NA
N
LI

E
GG

PE

GI

product in 30 are built to with open value for our


NG

RI
RU
LO

years endure source vision customers


24 CIRCUIT CELLAR • JANUARY 2015 #294

Webcam Mouse
This article presents the
FEATURES

construction of a webcam
mouse system, which is
a pointing device with
webcam-color-tracking-
based movement control.
The system includes three
finger sleeves. The webcam
tracks the movement of the
user’s colored right-hand
finger. The user’s other
fingers are for clicking and
scrolling.

By Alex Leung & Miles


Pedrone (US)

W hile enrolled in Cornell University’s


ECE4760 course, we were tasked with
designing and building a microcontroller-
that a webcam mouse—that is, a pointing
device with webcam-color-tracking-based
movement control—would be the perfect
based device of our choosing. After some project (see Photo 1). In this article, we’ll
brainstorming and research, we decided detail the project from start to finish.

HIGH-LEVEL OVERVIEW
At a high level, the mouse consists
of five main components: three finger
sleeves, a webcam, an Atmel ATmega1284
microcontroller, an on-off switch, and a
MATL AB interface (see Figure 1). Each
finger sleeve is fixed with a button, and
one of these sleeves is fitted with red
tape for color tracking by the webcam.
The buttons, which are wired to the
microcontroller, provide left click, right
click, and scrolling functionality.
Device operation begins with the finger
sleeves and the webcam. The computer-
connected webcam is mounted in a
convenient location. A user wearing the
finger sleeves moves a finger with red tape
in the webcam’s field of view. The webcam
tracks the centroid coordinates (x and y) of
the red tape as it moves in its field of view
through a MATLAB interface. It sends the
coordinates to the microcontroller via serial
PHOTO 1
The webcam mouse consists of finger sleeves, a webcam, an ATmega1284 microcontroller, an on-off switch,
communication. Upon receiving the data,
and a MATLAB interface. the microcontroller scales the coordinates
circuitcellar.com 25

to the computer screen’s resolution and FIGURE 1


encapsulates the coordinates along with The webcam mouse system is
built around an ATmega1284
the button status variables into a packet PC USB
microcontroller. Each finger sleeve
sent back serially to MATLAB.
is fixed with a button, and one of
Lastly, MATLAB unpacks the packet and these sleeves is fitted with red tape
Webcam
interfaces with the computer with cursor for color tracking by the webcam. The

FEATURES
movement, button clicks, and scrolling ATMega1284
buttons enable clicking and scrolling.
GND
as one would expect of a normal mouse. RightClick
The left-click button is wired to Pin
The on-off switch is for turning cursor B.1, the scroll button is wired to Pin
movement off if the user wants to type on Scroll B.2, and the right-click button is
the keyboard without the annoyance of a wired to Pin B.3.
B3
moving cursor. All button functionality is LeftClick B2
B1
still on even if the switch is turned off. On-Off switch
B0

FINGER SLEEVES & BUTTONS


The three finger sleeves are each fitted
with a push button and are used to perform A. Bhargav Anandon.[1] The first step is to
a different mouse function: left click, right get a snapshot of the current frame from
click, and scroll. You can use more finger the videoinput object and flip the image
sleeves fitted with push buttons to add even along the y-axis so that the snapshot is a
more functionality to the webcam mouse, mirror image to what the webcam is seeing.
but for our purposes, we decided to stick To track the red objects in real time, you
with basic functionality for proof of concept. have to subtract the red component from
The pointer finger and the middle finger of the grayscale image to extract the red
the right hand was used for left click and components in the snapshot. A 5 × 5 median
scroll, respectively, and the pointer finger filter is used to filter out the noise. You then
of the left hand was used for right click. convert the resulting grayscale image into a
The sleeve on the pointer finger of the right binary image by setting a threshold for 0s
hand was also fitted with a piece of red tape and 1s. We experimented heavily with this
for the webcam object tracking. This layout threshold in order to ensure that we were
is what made intuitive sense for us but the only finding the object that we wanted to
functionality of the push buttons and the track. Next, you can analyze the binary data
finger location of the sleeves can easily be to find and label the connected components
changed to your liking. that represent red objects in the snapshot.
The push buttons are four-lead push At the end of all of this image processing, you
buttons that short diagonal leads together
when the button is pressed. One lead is
connected to the active-low Pins B.X and
lead diagonal from that one is wired to
ground. The left-click button is wired to Pin
B.1, the scroll button is wired to Pin B.2, and
the right-click button is wired to Pin B.3.

WEBCAM & OBJECT-TRACKING


Real-time image acquisition from the
webcam is achieved with MATLAB code
based on code from Jeremy Lecoq of www.
MATLABtips.com. To communicate with the
webcam and begin the image processing,
you must first set up a videoinput object
for the webcam and a timer object that will
call an image-processing function every
millisecond at a fixed rate of execution.
Once the two objects are created, you can
start them and then begin to delve into
defining the function that will encompass
the object-tracking.
Object-tracking is carried out by
calculating and extracting connected
components from the webcam image (see PHOTO 2
Photo 2). The code shown in Listing 1 is Red-object tracking in MATLAB. The software finds red objects in the image frame and calculates the unscaled
borrowed from an open-source project by mouse coordinates.
26 CIRCUIT CELLAR • JANUARY 2015 #294

and the TRT UART for serial communication,


data = flipdim(getsnapshot(vid),2);
create the semaphores, and start the two
diff_im = imsubtract(data(:,:,1),rgb2gray(data));
tasks. Additionally, for the buttons, you should
diff_im = medfilt2(diff_im, [5 5]);
set Port B to be inputs and enable the pull-up
diff_im = im2bw(diff_im,0.2);
resistors to make the pins active low.
diff_im = bwareaopen(diff_im,16);
The first TRT task deals with the
bw = bwlabel(diff_im, 8);
FEATURES

serial communication with MATLAB, on-


stats = regionprops(bw, ‘Centroid’);
off functionality, scroll detection, and the
resolution scaling of the received coordinates.
The x- and y-coordinates received from the
LISTING 1
MATLAB object tracking are read in using the
This code performs the image
acquisition, image processing, and
have found all the significant red objects in fscanf command and scaled to determine
red object tracking. A connected the snapshot. The last step is to extract the the absolute cursor position on the computer
component method is used to find all x- and y-coordinates of the centroid of the according to the following formula:
the red objects in the image. red object and send the coordinates through PC resolution
serial communication to the ATmega1284 float tmp_ {x , y} = × {x, y} _recv
Webcam resolution − 20
microcontroller to be scaled. int abs_ {x , y} = tmp_ {x , y}
To enable serial communication between
MATLAB and the microcontroller, a serial The floats are used in order to preserve
object must be created for the COM port. the precision of the calculations and then
For seamless communication, we set the they are cast into integers for simple serial
parity bit to none, the flow control to none, communication. The webcam resolution is
and the data rate to 9,600 bps for the serial reduced by 20 pixels in order to more easily
object. Now, sending data is as simple as allow cursor movements around the edges
calling fprintf() and passing the coordinates of the screen. If this were not done, then
as parameters. moving the cursor to the edge of the screen
would require moving your finger to the
RESOLUTION SCALING & BUTTON edges of webcam’s field of view, which could
INTERFACE prove difficult to track. The next part of this
The ATmega1284 microcontroller runs the task is to detect the direction of scrolling
Tiny Real Time (TRT) kernel, developed by Dan if the scroll button is pressed. In order to
Henriksson and Anton Cervin, which schedules do so, you can store the previous calculated
two real-time tasks. One task is for resolution y-coordinate and compare it to the newly
scaling, scroll detection, on-off functionality, calculated to determine if the scroll
and serial communication. The other task is direction is in the upwards direction or the
for user-button-press interfacing. The kernel downwards direction. We decided on a delta
enables you to run these tasks concurrently threshold of 10 pixels to prevent unintended
and also allows the use of semaphores to fluctuations in direction, setting a direction
protect shared resources between the tasks. variable to 1 if the change in position is at
In the main() function of the microcontroller’s least +10 pixels and setting the bit to –1 if
C code, you should initialize the TRT kernel the change is at least –10 pixels. If the scroll
button is not pressed, then the variable is
set to 0 and scrolling should stop.
The final part of this task is to encapsulate
ABOUT THE AUTHORS
the newly calculated absolute coordinates
Alex Leung (apl58@cornell.edu) graduated from Cornell University in May and the scroll direction along with the
2014 with a major in Electrical and Computer Engineering and a minor in button click variables (which we’ll describe
Computer Science. His interests include embedded systems, software devel- shortly) into a packet that is then serially
opment, and program management. communicated back to the MATLAB interface
using fprintf() for cursor movement, clicks,
and scrolling. Before sending the packet,
Miles Pedrone (mcp97@cornell.edu) studied Electrical and Computer Engi-
though, the on-off switch is checked to see
neering at Cornell University and graduated in May 2014. He is pursueing
if it is on (i.e., Pin B.0 is low). If so, then the
his interests in computer architecture, analog circuit design, and physical
packet contains a 1 for the on-off enable bit.
design at IBM.
If not, then it contains a 0. Figure 2 shows

FIGURE 2
The layout of the packet sent from the
microcontroller to MATLAB. The packet X-Coordinate Y-Coordinate On-Off Enable Left click Right click Scroll command
encapsulates the absolute coordinates,
Integer (16-bit) Integer (16-bit) Integer (16-bit) Integer (16-bit) Integer (16-bit) Integer (16-bit)
on-off bit, left-click bit, right-click bit
and scroll bit.
28 CIRCUIT CELLAR • JANUARY 2015 #294

FIGURE 3 click button is released (Pin B.1 is high), which


Finite-state machine for the button- unsets the left-click variable back to 0 and the
press interface. State 0 is the initial
current state transitions back to state 0. In
state and states 1, 2, and 3 are State 1
d similar fashion, if scroll button is pressed,
entered when a left-click, scroll, and se
right-click has occurred, respectively. 1
p re
s
then a scroll variable is set to 1 and the FSM
t to
n
transitions to the state 2 until the button is
Bu
FEATURES

d
lea
se released. Finally, if the right-click button is
re
tto
n
1 pressed, then a right-click variable is set to 1
Bu and the FSM transitions to state 3 and waits
there until the button is released.
Button 2 pressed
This setup only allows one button to
State 2
State 0 be pressed at a time, ensuring correct
Button 2 released functionality of the mouse clicks. Ultimately,
the click variables are encapsulated by the first
Bu
task and are transmitted serially to MATLAB.
tto
n3 The scroll variable is unique in the sense that
pr
Bu
tto
es
se it enables scroll detection calculations to be
d
n3
re done in the other task if this variable is set.
lea
se
MOUSE CONTROL
d State 3

The webcam mouse system requires


interfacing with the actual cursor, clicks, and
scrolling on the computer. To do so, you can
the packet’s layout. use two Java libraries—Robot and Event—that
The second TRT task captures all of the run natively within MATLAB. The libraries
user button presses and presents the data in enable you to create a Robot object that can
a format that can easily by packaged and sent directly carry out cursor movement, button
by the first task. The task uses a very simple clicks, and scroll commands.
finite-state machine (FSM) to handle the three We included the mouse control function
different button presses and uses a single state calls within the same image-processing
variable to keep track of the current state (see function that we described in the Webcam
Figure 3). Initially, the current state is set to & Object-Tracking section of this article.
state 0, where the task is waiting for a button The first steps are to create a Robot object
press. If the left-click button is pressed (Pin and receive and unpack the packet sent by
B.1 is low), then a left-click variable is set to the microcontroller containing coordinate,
1 and the FSM transitions to the state 1. The click, and scroll data. Once the data has been
state machine stays in this state until the left- unpacked, you should check the on-off enable
bit of the packet. If it is high, then cursor
movement is enabled and the Robot object
calls the mouseMove() function with the
x- and y-coordinates from the packet as its
REFERENCE
parameters. If the bit is low, then the cursor
[1] A. Bhargav Anand, “Tracking Red Col- does not move.
or Objects Using MATLAB,” www.mathworks. The button control interface is
com/MATLABcentral/fileexchange/28757-track- implemented using a similar FSM to the
ing-red-color-objects-using-MATLAB. one used on the microcontroller. A state
variable keeps track of the current state
and is initially in state 0. If the left-click
SOURCES variable is 1, denoting the left-click button
circuitcellar.com/ccmaterials was pressed, then the Robot object invokes
ATmega1284 Microcontroller
the mousePressed() function for a left-
Atmel | www.atmel.com
click event and the FSM transitions to state
RESOURCES
1. Once the left-click variable goes back to 0,
D. Henriksson and A. Cervin, MATLAB you know that the button has been released
Tiny Real Time, www.control.
MathWorks | www.mathworks.com and thus you can call the mouseReleased()
lth.se/Staff/AntonCervin/tiny- function and move back to state 0. The
realtime.html. state’s transitions and function calls are
the same for right-click, except the state
J. Lecoq, “Real-Time Pro- transitions to state 2 when the right-click
cessing in MATLAB,” variable is set and the mousePressed()
www.MATLABtips.com/ and mouseReleased() functions are called
realtime-processing/. for a right-click event.
circuitcellar.com 29

The scroll event handling is more involved ensure that there are no other red colored
than the simple click events. If the scroll objects in view of the webcam and make
variable is set to 1, then the Robot object sure to not wear red!
calls the mouseWheel() function with a
parameter of 1 to scroll one notch in the FUTURE IMPROVEMENTS
upwards direction and then switches to state In conclusion, we would have to say that

FEATURES
3. If the scroll variable is set to –1, then the we accomplished all that we initially set out
Robot object calls the mouseWheel() function to accomplish with this project. We were able
with a parameter of –1 to scroll one notch in to design and build a device that is practical
the downwards direction and then switches in day-to-day life and had fun during the
to state 3. In state 3, if the scroll variable is whole process. With every design, however,
1, then mouseWheel(1) continues to be called. there is always room for improvement and
If the variable is –1, then mouseWheel(–1) I will lay out some ideas that we had for
continues to be called. The FSM only extensions.
transitions out of state 3 if the scroll variable The big improvement that we would
has a value of 0, meaning the scroll button like to make to our webcam mouse is
has been released. This completes the mouse wireless transmission. The current design
control portion of the webcam mouse and is overridden with wires that are clumsy,
completes the project. annoying, and frustratingly limiting. In the
future, we hope to wire all the buttons to
RESULTS a separate microcontroller connected to a
Once you have have a working webcam radio transmitter. A radio receiver would
mouse, the cursor movements should be connected to the original microcontroller
be relatively responsive to your finger and then the two microcontrollers could
movements and the button clicks and communicate wirelessly. This would eliminate
scrolling should interface seamlessly. the long wires between the finger sleeves
The precision and accuracy of the cursor and the microcontroller and allow for mouse
movements will depend on your webcam’s control from greater distances.
and PC’s resolutions. Webcams with higher Instead of using the color red to track
resolutions would provide much better an object, an infrared LED and a webcam
precision and accuracy than those with equipped to receive infrared input data
lower resolutions since the calculations to would have made for a more robust design
determine the absolute coordinates will have as it would work in a wider variety of
less of a correcting factor. environments. The limitations of ensuring
We found the use of the finger sleeves that the only red object in the webcam’s field
fitted with the push buttons to be refreshingly of view is the red tape is a big annoyance
natural to use for both mouse control and and one that is very off-putting to users.
typing compared the use of gloves fitted The use of an infrared LED and webcam,
with the push buttons, which was our initial however, would mitigate this limitation and
idea. The finger sleeves leave the finger prove to be a much better design.
tips exposed, allowing for a more natural The design that could truly be the
feeling when typing. The covered finger biggest improvement and prove to be highly
tips of gloves made typing feel awkward functional would be to eliminate the need
and uncomfortable. Additionally, the finger for the microcontroller and instead interface
sleeves can easily be moved to different all the clicks and scrolls through pattern or
fingers to allow for a more personalized color recognition with the webcam. Detecting
experience that better fits your needs and clicks and scrolls through the webcam could
preferences in terms of button functionality. possibly be carried out by flashing certain
All in all, we found the finger sleeves to be the colors or patterns in the view of the webcam
better design choice and hope that you do to. and utilizing the object-tracking formula that
One problem that we found with our we are already using. Since the resolution
design arises in cases where there are scaling can also be done in MATLAB, there
multiple red objects in the webcam’s field would be no need for the microcontroller,
of view. When tracking red objects, the allowing for a purely wireless webcam mouse
code prioritizes the components by their design. This design is the most interesting to
location in the field of view. Objects with us out of the ones proposed and we hope
lower coordinate values are given higher to continue researching and experimenting
priority and, as a result, the webcam mouse with this in the future.
would prioritize this object over the red Overall, this project was an awesome
tape object on the finger sleeve. The cursor experience and definitely a satisfying one at
would instead follow this object instead that. A video and more information about the
of your finger. One way to remedy this is design is available at http://bit.ly/1tHx2jr.
30 CIRCUIT CELLAR • JANUARY 2015 #294

Measuring
Small Currents
FEATURES

Most inexpensive hand-held multimeters


have measurement ranges from several amps
to single-digit milliamps. While generally
handy, such meters are insufficient for
sensitive current measurements. This project
extends the current measurement range
from milliamps down into the nanoamp and
picoamp range with simple, low-cost circuits.

By David Ludington (US)

M ost inexpensive hand-held multimeters


have current measurement capability.
The measurement range for these meters
recommended circuit component and layout
techniques will be provided. Finally, two of
the circuits will be discussed that were built
extends from several amps down to single- and tested to demonstrate the desired goal of
digit milliamps and sometimes into the measuring nanoamp and picoamp currrents.
microamp range. While this measurement
capability is sufficient for many applications, CURRENT SOURCES
there are times when more sensitive current Figure 1 shows several types of current
measurement is required. There are meters sources. Figure 1a is the symbol of what
available which measure much lower levels electrical engineers call an ideal current
of current, but these meters are also more source. It can have any level of current at the
expensive and are often dedicated to just this output and the output impedance is infinite.
one measurement function. The result is that the output current is not
The goal of this article is to extend the affected at all by the characteristics of the
basic hand-held current measurement measurement circuit. Of course no actual
range from milliamps down into the current source is ideal, but this is still a useful
nanoamp and picoamp range with relatively concept for approximating actual circuits
simple, low-cost circuits. First, I’ll describe and is used as a source in circuit simulation
several types of current sources with their programs such as PSPICE.
relevant performance characteristics that Figure 1b shows a current source which
affect measurement circuits. Then, I’ll uses semiconductor transistors (either bipolar
present practical circuits that deliver high or FET). In this circuit, the output impedance
performance at low cost. Each of these circuits is not infinite but can still be quite high
will be analyzed to determine what level of (megohms). This means that varying voltages
measurement performance can be expected. at the collector of the bipolar transistor or
General design issues common to all of the drain of the FET transistor have little effect on
circuit techniques will also be discussed and the output current as long as the voltage is not
circuitcellar.com 31

large enough to affect transistor operation. FIGURE 1


a) b) c) The current sources: ideal (a),
Figure 1c is the least ideal of the current
semiconductor (b), and resistive (c)
sources. The current is generated by the
voltage difference across the resistor R2.
Any measurement voltage developed by
the measurement circuit directly affects

FEATURES
the voltage difference across the source
resistor. This changes the current that is
measured which can result in measurement
error. Having said that, Keithley Instruments
in Low Level Measurements Handbook (6th
edition, page 2-20) uses this current source The voltage that is developed across the
model in defining what they call the feedback load resistor is called the burden voltage. For
ammeter (also transimpedance amplifier). It a current source that is nearly ideal (such as
may well be that, in real-world circuits, this the transistor source), the burden voltage has
model is the one that describes the majority relatively little effect on the current being
of practical applications. measured unless it is large enough to change
Although the current sources just the internal working of the current source. For
described are not part of the measurement resistive current sources, the burden voltage
circuit itself, it is helpful to understand their can directly interact with the current source
limitations so that the measurement circuits and give erroneous current readings. This
can be designed to disturb the current source occurs because the load resistor becomes
as little as possible. In this way, measurement part of the current generating resistance
error is minimized. which reduces the current. To minimize this
interaction, the load resistor should be much
CURRENT MEASUREMENT smaller that the output resistance of the
CIRCUITS current source. The corresponding burden
In the past, current was measured voltage will then also be small.
directly with a moving coil meter. Now using When a simple hand-held voltmeter is
semiconductor technology, voltage is the used, the measured voltage cannot be too
parameter that is measured directly. The small because these meters rarely measure
current to be measured is first converted to a below 1 mV. Thus, a compromise is needed
voltage by flowing through a load resistor. The between measurement accuracy and a low
resultant voltage is then measured and along voltage burden.
with the load resistor is used to calculate the
input current.
Figure 2 and Figure 3 show several a) b) c)
circuit techniques which are used to convert
current to a voltage. Figure 2 shows the
basic techniques, while Figure 3 shows
modifications to two of these basic circuits,
which give more accurate results and extend
the measurement range. The symbol for the
input current used in these circuits is the same
as the symbol for the ideal current source
used in Figure 1; but in this case, it is used to
show where the input current connects to the
measurement circuit and can represent any FIGURE 2
of the described current sources. Current measurement circuits: resistive (a), transimpedance (b), and integrator (c)

RESISTIVE CIRCUIT
Figure 2a is the least complicated of the
a) b)
measurement circuits. In this circuit, the
current source is connected to one end of
the load resistor R1 and the other end of the
resistor is connected to ground or some other
reference point. The voltage developed across
this resistor is measured with the voltmeter and
used to calculate the input current. This circuit
FIGURE 3
is very simple and is often used on the spot with
Modified current measurement
an available resistor for quick measurements at circuits: modified resistive (a) and
the workbench or in the field. modified transimpedance amplifier (b)
32 CIRCUIT CELLAR • JANUARY 2015 #294

Effective Because VOUT is zero, the leakage current


Current to be Load Resistor going into the hand-held voltmeter is zero
Measurement and the finite input impedance (10 MΩ) of the
measured (µA) R1 (Ω)
Resistance (Ω) meter does not affect the measurement. Even
1,000 50 50* when VOUT is not exactly zero, the leakage
current is still small. For example, for VOUT
100 500 500*
FEATURES

< 5 mV, the leakage current will be less than


10 5,000 5,000* 500 pA. This gives measurement accuracy of
1 50,000 50,251 1% or better for input currents greater than
50 nA. Since the resistor R1 in this modified
0.1 500,000 526,316
circuit is not developing a burden voltage,
0.01 5,000,000 10,000,000 the resistor value is decoupled from the
input current and can be any practical value
TABLE 1 depending only on the maximum voltage of
Resistor Values versus Input Current for Resistive Circuit. (*Rounded off value. Less than 0.1% error.) the power supply.

TRANSIMPEDANCE AMPLIFIER
Figure 2b shows the circuit for a
Most hand-held meters have a 10-MΩ transimpedance amplifier. This is perhaps the
input impedance on the voltage scale. The most versatile of the current measurement
load resistor R1 will be in parallel with the circuits in that it can cover a large current
meter impedance and needs to be selected measurement range using a simple circuit. In
appropriately to give the desired equivalent this circuit, the output from the current source
measurement resistance. An example in is connected to the negative input of the
Table 1 shows the resistor values needed operational amplifier while the positive input
to give a measurement voltage of 50 mV of the amplifier is connected to a reference
for the given currents. This fairly low voltage. This reference voltage is typically the
value of measurement voltage significantly circuit ground when there are bipolar power
decreases the burden voltage while at the supplies and some intermediate voltage when
same time providing enough voltage to give there is a single power supply.
measurement accuracy on the order of 10%. The inputs of an operational amplifier
When making a current measurement with have very high input impedances (greater
the resistive circuit, it is always a good idea than 1 GΩ) so that little current goes into
to try several resistors of different values to the amplifier. Thus, the input current drives
see what voltage results. If changing resistor the negative input toward one of the power
values by a certain amount changes the supply voltages depending on the polarity
measurement voltage by the same amount, of the input current. This causes a voltage
then the source current is not being affected difference between the amplifier inputs
by the measurement (burden) voltage. In which is then amplified with the large
this case you can use the higher value of internal open loop gain of the amplifier. As
resistance to get more output voltage and a result, the amplifier output voltage moves
more measurement accuracy. Conversely, in a direction to provide current through
if the corresponding measurement voltage resistor R2 which is opposite to the input
increases less than the amount of the resistor current. Equilibrium is achieved when the
value change, the source current is being amplifier output voltage is such that the
affected by the measurement circuit and the current through R2 is equal in magnitude
smaller resistor value should be used. to the input current. With an ideal amplifier
A small modification to the circuit as shown and no offset voltage, this results in 0 V at
in Figure 3a gives improved performance by the negative terminal matching the voltage
removing the burden voltage at the expense at the positive terminal. Only the value
of adding a variable power supply. This can of resistance R2 and the amplifier output
be particularly useful as a quick measurement voltage are needed to determine the input
tool using an available workbench power current. Since we know the resistance value
supply. The power supply is adjusted until and can measure the output voltage, we can
VOUT is 0 V. The value of the current is then calculate the current through R2 which will
obtained by dividing the measured value of equal the magnitude of the input current.
the power supply voltage by the resistance Since there is no burden voltage, the
R1. In this way the burden voltage is removed input current is not affected by the value of
and the load resistor can be increased so that the feedback resistor R2 or the magnitude
the power supply voltage can be greater than of the output voltage. The output voltage is
50 mV. This will give more accuracy in the constrained by the power supply voltages,
measurements. but in principle there is no constraint on the
DESIGN YOUR SOLUTION TODAY
CALL 480-837-5200

TS-7250-V2 Embedded Board TS-4900 Computer Module


High Performance and Industrial Grade 1 GHz i.MX6 with WiFi & Bluetooth
Pricing Starts At
$165
Qty 100
Pricing Starts At
$199 $99
Qty 1
Qty 100

$134
Qty 1

Available with TS-ENC720 enclosure


(Shown with optional microSD card)
Features: 1 GHz Single or Quad Core Cortex A9 ARM CPU
Up to 1 GHz ARM CPU 2x USB Host Up to 2 GB DDR3 RAM and 4 GB eMMC Flash

512 MB RAM 1x USB Device Wireless 802.11 b/g/n and Bluetooth 4.0
4 KLut FPGA, 1x Gigabit Ethernet, 1x PCI Express Bus
8 or 17 KLut FPGA 6x Serial Ports
1x mSD slot, 1x SATA II, 1x USB Host, 1x USB OTG
2x SD Card Socket 75x DIO, 1x CAN
70x DIO, 4x I2C, 1x I2S, 2x SPI, 2x CAN
2x 10/100 Ethernet 1x PC/104 Connector
-40 ºC to 85 ºC Industrial Temperature Range
Runs Linux 3.10, Debian, Ubuntu, Yocto, QT, OpenGL
Benefits:
Coming Soon: QNX, Android and Windows Support
Hardware flexibility with on-board FPGA

Several control I/O interfaces

Launches your application in half a second

Easy development w/ Debian and Linux 3.14

High data reliability with 2 GB SLC eMMC flash

-40 ºC to 85 ºC industrial temperature range Available w/ TS-TPC-8390 Available w/ TS-8150


Touch Panel Computer PC/104 Development Kit

We’ve never Embedded Support every Unique embedded


discontinued a systems that step of the way solutions add
FE

L
D

NA
N
LI

E
GG

PE

GI

product in 30 are built to with open value for our


NG

RI
RU
LO

years endure source vision customers


34 CIRCUIT CELLAR • JANUARY 2015 #294

TABLE 2 capacitor C1.The switch S1 is used to short out


Resistor values for nominal input Input Current Resistor Value
the capacitor at the start of a measurement
currents and VOUT = 1 V 1 mA 1 kilo (103) ohm so that the output is at a known voltage. When
1 µA 1 meg (106) ohm the switch is opened, the capacitor begins to
1 nA 1 gig (109) ohm charge. The output voltage becomes more
positive or negative depending on the polarity
1 pA 1 tera (1012) ohm
FEATURES

of the input current and changes at a rate


determined by the current magnitude and the
capacitance value.
value of the feedback resistor. Table 2 shows The instantaneous relationship between
R2 resistor values for several nominal input voltage and current is given by Equation 1.
currents for an output voltage (VOUT) of 1 V.
As seen in Table 2, the resistor values get  dv  [1]
i = C 
quite large for small currents. These large  dt 
value resistors are expensive and are often
also physically large. Also, circuit constraints If the current source is a constant current
like stray capacitance can have an appreciable into the negative input of the amplifier, the
effect on the circuit when the resistor value output voltage must keep changing to generate
is large. a current to balance the input current. A DC
There are two ways to reduce the resistor input current generates a voltage ramp at the
value required for a particular input current. amplifier output. The ramp rate depends of
One way is to allow smaller voltages than the magnitude of the input current and the
1 V to represent the input current. This is value of the integrating capacitor.
acceptable as long as all anomalous voltages There is always bias current at the
in the circuit due to circuit imperfections are amplifier input which will add or subtract
calibrated out. This calibration can be either from the input current. Even if there is no
physical using potentiometers to cancel offset current input, this bias current will slowly
voltages. Alternatively, data calibration can be drive the amplifier output toward one of the
used by measuring the output voltage without power supply rails depending on current
the input current and then subtracting that polarity. The switch S1 is turned on to shunt
data from the output voltage with the input this current to the amplifier output when
current. Thus, as the input current (and the amplifier is not making a measurement.
corresponding output voltage) are reduced, To start a measurement, S1 is turned off
the measurement voltage will still have and samples of the rising (or falling) output
sufficient accuracy. voltage are collected until the end of the
The second way to measure lower values measurement period. Then the input current
of current with a lower resistor value is to is calculated from the ramp rate and the
use the modified transimpedance amplifier capacitor value.
shown in Figure 3b. Here, the output voltage For most current ranges I do not see
is reduced by the voltage divider consisting that the integrator circuit has any particular
of R3 and R4 before driving the feedback advantage over the transimpedance amplifier,
resistor R2. If the feedback resistor here is but there are certainly some disadvantages.
the same as the feedback resistor without the One disadvantage is that for a DC current
divider, the current flowing to the negative input, the output voltage does not settle to
input terminal will be less than before. The some fixed value but is continually moving.
internal gain in the amplifier will make the This makes it difficult to obtain the value of
output voltage larger to compensate. For a the measured current with a simple voltmeter
voltage division of 10, the input current is 10 in real time. The data must be collected over
times lower for the same output voltage as some measurement time. This data is used to
before. One caution: although this circuit does calculate the slope in order to determine the
give flexibility in the design, care is needed measured current.
because there is an amplifier voltage gain If a single capacitor is used to cover a fairly
equal to the divider ratio. The internal offset wide range of currents, then the higher end
voltage and noise voltage of the amplifier are of the current range will result in a very fast
multiplied by this amplifier gain along with ramp time for a small capacitor or the low end
the current signal. of the current range will result in a very long
ramp time if the capacitor is large. There may
INTEGRATOR be some advantages for the integrator circuit
Figure 2c shows the integrator circuit over a limited current range for very small
for measuring current. In this circuit, the currents (less than 1 pA). In this case, we are
feedback resistor R2 of the transimpedance trading the inconvenience of the integrator
amplifier is replaced by an integration measurement time against the circuit design
circuitcellar.com 35

issues of very large resistors (100–1,000 GΩ) current adds or subtracts from the input
for the transimpedance amplifier. current. For modern amplifiers used in these
circuits, the offset voltage is fairly low (150
DESIGN ISSUES µV – 2 mV) while bias and offset currents can
There are circuit design issues that are vary by several decades (10 fA to 100 pA)
common to all of the detection methods: depending on the particular amplifier design

FEATURES
leakage current (circuit board, load resistor, and intended application. Amplifiers with
and capacitor); offsets (voltage and current); low offset voltage tend to have higher bias
capacitive coupling; thermoelectric EMF; currents and amplifiers with low bias current
and tribocharging. I’ll address each issue tend to have higher offset voltages.
separately in the following sections. Capacitive Coupling: Extraneous signal
Leakage Current: There are two types currents can be injected into the current
of circuit board leakage, volume leakage measurement circuits through capacitive
through the circuit board and surface leakage coupling. This can occur in two ways, as
between conductive traces on the top and shown by Equation 2.
bottom surfaces. Leakage through the board
d ( CV ) C ( dv ) V ( dC ) [2]
comes from the volume resistivity which is i = = +
an intrinsic parameter of the board material. dt dt dt
Normally for the common board material FR4 In the first term on the right-hand side,
this resistivity is quite high, but it can be the capacitance is fixed and the voltage is
lowered due to moisture. Surface resistivity is varying. In the second term, the voltage is
also high but can be lowered by contamination fixed and the capacitance varies. In the circuit
on the surface caused by dirt, moisture, design phase, the capacitance is usually
solder, flux or even oils from fingerprints. assumed to be constant or only changing
If there is a leakage path from the negative slowly such as with changes in temperature
input of the amplifier to nearby voltages, and the second term is zero. However, during
the resulting current will be included in the circuit operation on the bench, the voltage
measurement causing an error. across the stray capacitance may be relatively
There can also be leakage between the constant but the capacitance can change due
leads of the load resistor or between the leads to motion near the circuit board. The human
of the capacitor which is in parallel with the body usually has some voltage on it due to
load resistor. This comes from contamination static electricity. When there is movement
on the surface of the parts themselves and is and the circuit is not shielded, coupling can
similar to the surface leakage of the circuit occur if the capacitance between the body and
board. This component leakage will act like the circuit changes. These signals are small,
a resistor in parallel with the load resistor but can be detected if the circuit resistance
and change its value. Thus, the calculation of is large and/or there is a lot of voltage gain.
the input current will be in error. This might Thermoelectric EMF & Tribocharging: When
be acceptable if the equivalent load resistor different metals are in contact (e.g., copper,
could be calibrated. However, the leakage tin, and solder), there are small thermoelectric
resistance could easily change over time or voltages (µV), which are present at these
with other operating conditions and would junctions. If the junction temperatures are
not be predictable. Having a physically larger the same, then these voltages cancel out in
component can help in reducing the leakage by the circuits. If the components are placed
having a greater distance between the leads. such that there are temperature gradients,
As an example, in one of my projects I then these thermoelectric voltages do not
was using a 10-GΩ resistor and some of the cancel.
readings did not seem correct. Moisture caused Tribocharging occurs when conductors
by humidity in the room was suspected. The are physically rubbed against insulators and
problem was cured by blowing dry nitrogen a current is generated. This often occurs in
across the resistor surface evaporating the coaxial cables when the cables are moved or
ABOUT THE AUTHOR
moisture. flexed. For most applications at microamps
Offset Voltage & Bias Current: Another levels and above, these induced currents David Ludington is a re-
design consideration is the voltage offset, do not present a problem. However, when tired electrical engineer
current offset, and bias current of the measuring smaller currents (nanoamps and with experience in low-
amplifiers used in the transimpedance and below), care must be taken to minimize noise analog design and
integrator circuits. These offsets and bias cable and wire movement to keep these tribo infrared system design.
current affect the amplifier in different ways. currents small. He earned a BSEE at
The voltage offset develops a burden voltage Michigan State Universi-
at the negative input of the amplifier if the HARDWARE DESIGN & TESTING ty and an MSEE at Syra-
positive input of the amplifier is connected In Figure 2 and Figure 3, I described three cuse University.
to ground while the offset current and bias types of basic current measurement circuits
36 CIRCUIT CELLAR • JANUARY 2015 #294

and R8 are installed and there is attenuation


of 100 in the current generation section and
a gain of 100 in the transimpedance amplifier
section.
Although the circuit in Figure 4 is valid to
demonstrate current measurement capability,
FEATURES

it is “cheating” a bit in the following sense. In


actual practice, the current generating part of
the circuit (VIN and R4 through R6) would not
usually be on the same circuit board as the
current measuring part, but would be some
distance away and connected with wires or
coaxial cable. These wires or cable could have
interfering signals on them and, as shown in
Figure 4, would go directly to the negative
input of the amplifier (pin 2). I mention this
because a demonstration circuit like Figure
4 needs additional design to make it rugged
enough for a laboratory instrument.
In this demonstration circuit, I selected R4
+ R6 equals R7 + R9, so that the designed
FIGURE 4 voltage gain of the amplifier and current
Transimpedance Amplifier Demo (resistive, transimpedance, and integrator) source is minus one (VOUT = –VIN). I
Board and two modifications (resistive and measured a number of 10 megohm resistors
transimpedance). I will now narrow the scope and selected two that were matched closer
for design and demonstration by building and than 1%.
testing the modified resistive circuit and the The first task in setting up the circuit
modified transimpedance amplifier. for data collection is removing the amplifier
The modified transimpedance amplifier has offset. This is done by removing the input
all the benefits of the basic transimpedance voltage VIN and shorting the circuit input
amplifier circuit with some additional to ground. (Remember, for the first data
flexibility in choosing feedback resistor collection, R5 is not in the circuit and the short
values. The demonstration circuit for this is needed.) Then P2 is adjusted for minimum
configuration is shown in Figure 4. Resistors output voltage.
R4, R5, and R6 are the current source and After the initial voltage offset correction,
the rest of the circuit is the transimpedance I started adjusting the input voltage and
amplifier plus compensation for voltage measuring the output voltage. I immediately
offset and bias current. Resistors R8 and R9 saw that the output voltage was not quite
are a voltage divider, which determines the the same as the negative of the input voltage
amplifier gain and lets the amplifier measure and at first, I thought the voltage offset was
smaller currents with a reduced feedback done incorrectly. Upon further reflection,
resistor R7. Potentiometer P1 adjusts a voltage I saw that the voltage difference |VOUT| –
which is divided and generates a bias current |VIN| was increasing with increasing input
compensation through R3. Potentiometer P2 voltage. This behavior is not like a constant
adjusts a voltage which is divided and becomes voltage offset but more like a gain variation.
the offset voltage compensation. Capacitor C1 In fact, there was no problem, the circuit
provides compensation for input capacitance was behaving properly. The data showed that
at the negative input of the amplifier U1. current generation resistor and the feedback
Capacitors C3 through C9 provide decoupling resistor had been matched to 0.2% giving a
of the +5 V and –5-V power supply voltages. gain slightly larger than –1.
For initial testing and the first data collection, This illustrates one practical aspect of
R5 and R8 are not installed and the amplifier testing. When building a demonstration
gain is –1. For the second data collection, R5 circuit, choose simple gain ratios (i.e., unity

(|VOUT| Nominal Input Nominal Output


VIN VOUT
– |VIN|)/|VOUT| Current VIN/R6 Current VOUT/R7
+0.511 –0.512 0.2% 50 nA –50 nA
+1.001 –1.003 0.2% 100 nA –100 nA
+1.501 –1.504 0.2% 150 nA –150 nA
TABLE 3
Data with negative unity amplifier gain +2.021 –2.025 0.2% 200 nA –200 nA
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(External clock inputs are available) Voltage converters for auxiliary power supply
3.3V single power supply operation Very small size (25.3 x 25.3 [mm])
Separated power supply: Core, I/O
JTAG Signals (TCK, TMS, TDI, TDO)
All series have the same pin assignment
HUMANDATA
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 : 5CEBA4U15C8N FPGA : 5CEBA4U15C8N FPGA : EP3C25U256C8N
FRAM 3.3V single power supply operation 3.3V single power supply operation
3.3 V single power supply operation On-board oscillator, 50MHz On-board oscillator, 50MHz
On-board oscillator, 50MHz Configuration Device Configuration Device
Configuration Device 8 Layers PCB 8 Layers PCB
8 Layer PCB Board size : 25.3 x 25.3[mm] Board size : 25.3 x 25.3[mm]
Mountable on 68pin IC socket Mountable on 68pin IC socket Mountable on 68pin IC socket
RoHS compliant RoHS compliant RoHS compliant

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

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

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

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


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

VIN VOUT |VOUT| – |VIN| Nominal Input Current of approximately 100 at the input and an
amplifier gain of approximately –100 at the
+0.5006 –0.5008 0.0002 0.5 nA output. The data shows that VOUT again
+1.001 –1.002 0.001 1.0 nA equals –VIN, but the current into the amplifier
+1.505 –1.506 0.001 1.5 nA (from the voltage at the left hand side of R6
divided by R6) is 100 times lower.
+2.002 –2.003 0.001 2.0 nA
FEATURES

Since there is attenuation in the current


generation and gain in the amplifier (from two
TABLE 4 gain) and precision components. It is certainly resistive dividers), there is potential for either
Data with amplifier gain of –100 true that any combination of input voltage and more or less gain mismatch than before. With
current generation resistor could be used for the resistors selected, it appears from the
testing. But, by using the values as described, third column of data in Table 4 that the gain
testing is simplified. It is easy to visually matching is actually improved and what is
observe the raw data and see that something left is a voltage offset or some combination of
does not appear correct. In this case, I was gain error and offset. It appears to be mostly
quickly able to conclude that the circuit was voltage offset which is not surprising since
performing as expected and in addition, there the residual offset from the initial adjustment
were no stray currents affecting the output has been amplified 100 times.
voltage (at least at this level of input current).
Table 3 shows data with resistors R5 and MODIFIED RESISTIVE
R8 removed from the circuit. The input current DEMONSTRATION
generation section consists of Vin and R4 + Figure 5 shows the schematic of the
R6 and the total feedback resistance consists modified resistive demonstration board. The
of R7 + R9. Since R4 and R9 are 1000 times power supply PS1 and resistor R1 simulate the
smaller than R6 or R7, only R6 and R7 are input current source while power supply PS2,
used in the current calculations. The data was resistor R2, and the voltmeter are the current
collected by first adjusting the input voltage measuring circuit. First PS1 is adjusted to
Vin. The input current was then calculated generate some value of current through R1.
from Vin divided by R6. This current causes a Then PS2 is adjusted to make VOUT = 0. PS2
measurable voltage VOUT. The output current is then measured and the input current is
is then calculated by dividing the output calculated using PS2 and R2. The capacitor C1
voltage VOUT by feedback resistor R7. If the is optional and can be added to provide filtering
magnitude of the output current matches the of the input current if desired. As shown, PS1 is
input current, then the current measurement positive and PS2 is negative which represents
part of the circuit is correctly measuring a positive input current. Reversing these
the input current without additional stray voltages would give a negative input current.
currents. Table 5 shows the data when PS1 is adjusted
In Table 4, resistors R5 and R8 are for various input levels and PS2 is adjusted to
now in the circuit. There is an attenuation drive VOUT near 0 V.
The power supplies PS1 and PS2 are
Input Current (nominal) 40-V Lambda supplies with multi-turn
PS1 PS2 VOUT potentiometers for the voltage adjustment.
|PS2|/R2 Even so, it was hard to adjust the supplies
+0.501 –0.498 0.001 50 nA for millivolt precision. Resistive dividers
+1.001 –0.998 0.001 100 nA consisting of 16.6- and 1.6-kΩ resistors were
added at the power supplies to reduce the
+1.501 –1.498 0.001 150 nA sensitivity of the voltage adjustment. For
+2.001 –1.999 0.001 200 nA example, for the 2-V input at R1, PS1 was set
at about 22.5 V.
TABLE 5 After setting PS1, I adjusted PS2 so that
Data from modified resistive demo circuit VOUT was near 0 V. With enough effort, I
could have achieved zero volts on VOUT,
but I choose to have some small reading
instead. With only a 31/2 digit meter, the last
digit displayed is single-digit millivolts and
the meter reads zero if the voltage is really
near zero and also if there is poor electrical
contact. (This happened during testing.)

CIRCUIT REVIEW
FIGURE 5 In this article, I’ve shown that you can
Modified Resistive Demo Board use relatively simple circuits such as those
circuitcellar.com 39

in Figure 2 and Figure 3 to extend the The usual procedure is to describe the basic
current measurement of hand-held meters resistive circuit, discuss its limitations, and
to measure smaller currents. The resistive move on to the transimpedance amplifier.
circuit in Figure 2a is most valuable for One feature of this circuit is that it does
quick measurement at the bench or in the not have a high gain active amplifier directly
field. The circuits in Figure 2b and Figure 2c in the signal path. Thus, higher resistor

FEATURES
have more general use. The transimpedance values do not cause any circuit instability.
circuit has application across a wide In addition, capacitance from the current
measurement range while the integrator source does not cause problems. In fact,
is more specialized and would probably be it may be desirable to intentionally add
used only for very small currents (picoamps capacitance at VOUT to filter the current
and below). source. As the current is reduced, it may be
The modified current measurement advantageous to buffer VOUT with an active
circuits in Figure 3 give improved circuit to keep any loading of the meter from
performance at little additional cost or affecting the measurement.
complexity. The modified transimpedance When evaluating these two demonstration
circuits in Figure 3b and Figure 4 have shown circuits, there did not seem to be much
measurement into the picoamp range with a interference from external noise sources
feedback resistor of just 10 MΩ with VOUT (at least at the level of currents measured).
at 0.5 V. The measurement range could Interference would likely increase at lower
be extended with either larger feedback current levels and trade-offs between
resistors or lower output voltages. feedback resistor value, amplifier gain
The modified resistive circuits of Figure and output voltage would need to be made
3a and figure 5 are of particular interest to to achieve the most benefit with the least
me. I was quite pleased with the performance complicated circuit.
of this circuit and how easy it is to control. Finally, I have not worked with the
I have not seen this simple extension of the integrator circuit (see Figure 2c). It would be
basic resistive circuit described in any of the interesting to see just how small of a current
articles I have read on measuring current. could be measured with this circuit.

Wide Temp. Panel PC


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

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

Since 1985
OVER
29
YEARS OF

EQUIPMENT MONITOR AND CONTROL


SINGLE BOARD
SOLUTIONS

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


40
FEATURES CIRCUIT CELLAR • JANUARY 2015 #294

Build a Duodecimal Clock


Programmers and embedded circuit designers know that decimal is not the
preferred number system for digital devices. Binary, octal, and hexadecimal
numbers rule the day, so they’re comfortable using strange number systems.
Clocks are essentially duodecimal, or base-12, devices. Here’s a design for a two-
digit clock that only an engineer would love (and know how to read).

By Devlin Gualtieri (US)

M any years ago, when people still wore


wrist watches as functional devices and
not as jewelry, I read an article written by
someone whose (mechanical) wristwatch
had failed. This guy was an “efficiency
expert,” so he did a study to see whether
A A he should buy a new watch. He found that
F B F F wherever he went, there was always a
10 nearby wall clock, or someone who could
G G tell him the time. He decided that buying
E C E E
a wristwatch was not necessary, but he
bought one just the same.
Wristwatches have fallen out of favor
FIGURE 1 because everyone now carries a cellphone
A A
Representing 10 and 11 on a that doubles as an extremely accurate
seven-segment display. The “t” F F F B
timepiece. I find that it takes quite a bit
representations are somewhat 11 longer for me to read the time on a cellphone
abstract, but they can’t be confused G G G
than a wristwatch; but, just like the efficiency
with other characters. The last E C E E
pictured in each category are my D D D expert, I don’t need to use my cellphone
choices, since they’re easiest to read. clock that often.
circuitcellar.com 41

FIGURE 2
This is the duodecimal clock’s
circuitry. One nice thing about most
embedded systems projects is that the
software allows reduction in hardware
complexity. The particular displays
used were green Lumex LDS-AA12RI

FEATURES
displays.

TIMEKEEPING WITH MCUS station where I worked for a short time had
Digital timekeeping has supplanted another way of accurate timekeeping. It
mechanical timekeeping not simply because subscribed to the Western Union time service
it’s usually more accurate, but because which transmitted a synchronizing pulse, on
it’s inexpensive. Digital alarm clocks are the hour every hour, over a telephone line to
available everywhere for about $10. You can a less-expensive pendulum clock.
build the clock in this article for a few dollars Today, even your telephone caller
more, but with a larger share of satisfaction. ID box has a clock synchronized by a
Many years ago, I started designing with telephone line, and most computers use
Microchip Technology PIC microcontrollers. Network Time Protocol (NTP) signals to
Since I now have the necessary tools for synchronize their clocks to within a few
PIC development, it would be hard for me tens of milliseconds. Global positioning
to change. Fortunately, there’s no reason system (GPS) receivers can determine the
for change, since PIC microcontrollers are time to within 100 ns. Light travels just
adequate for most embedded designs, and 100′ in that time interval.
they’re quite inexpensive. This design uses At a human level, how much time
the PIC16F630 microcontroller. accuracy do we need? When I see that it’s
PIC microcontrollers have a built-in a few minutes before, or after, the hour, I
oscillator with about a percent accuracy, think “two o’clock.” Likewise, when someone
which is reasonable for many embedded asks me for the time, they expect an answer
applications. This accuracy comes from
digitally trimming an internal resistor-
capacitor oscillator on the chip. One percent
accuracy is not adequate for a clock, since
that would be a quarter of an hour’s error
each day.
It is possible to use an inexpensive
32.768-kHz tuning fork crystal with a PIC.
This frequency is useful for clocks, since
a power of two will divide this frequency
to 1 Hz. However, this slow clock rate
prevents rapid computation and some useful
functionality, so I didn’t use such a crystal
in this circuit. Instead, I used a half-sized
10.000-MHz TTL canned oscillator. Canned
oscillators are easy to use, highly accurate,
and not too expensive.

HOW MUCH ACCURACY?


As you can imagine, timekeeping is very
important in broadcasting. In my younger
days, in the 1960s, I had a summer job at
a television station. The control room had PHOTO 1
a very expensive-looking pendulum clock The seven-segment LED displays were mounted on the foil side of a single-sided circuit board. I used single-
that synchronized other clocks in the station. row, in-line sockets to facilitate soldering. The sockets also elevated the displays above the circuit board and
The time was accurate to about 1 s. A radio the SMT resistors placed beneath the displays.
42 CIRCUIT CELLAR • JANUARY 2015 #294

like, “about quarter after two” or “five


minutes before two”—not hours, minutes
and seconds.
Since our hours are divided into 12
intervals, what accuracy would we get if
we divided the minutes in an hour into 12
FEATURES

portions as well? Sixty divided by twelve is


five, so we would know the time at a worst-
case to ±2.5 minutes. This, as my building
contractor father would say when excavating
the foundation for a house, is “close enough
for digging.”

NUMERICAL REPRESENTATION
Seven-segment LED displays are common
circuit items, and this clock has a two-digit
LED display. One digit is for hours, and the
other digit is for the twelfth fraction of the
hour. It’s straightforward to display the
numbers, zero through nine, on a seven-
PHOTO 2 segment display, but 10, 11, and 12 pose a
You can see the connection between PCB halves using right-angle IDE connections. You can also see the slight problem. The problem of the twelfth
mounting of the seven-segment displays on the foil side of the PCB.
hour disappears when we use zero for that
digit. This convention is familiar to most
technical people.
In the hexadecimal convention, 10 is
ABOUT THE AUTHOR
represented by an “A,” and 11 is represented
Devlin Gualtieri received his PhD in Solid State Science and Technology from by a “B.” A capital letter “A” is easy to show on
Syracuse University in 1974. He had a 30-year career in research and tech- a seven-segment display, but a capital letter
nology at a major aerospace company and is now retired. Devlin writes a “B” looks just like an eight. As a compromise,
science and technology blog at www.tikalon.com/blog/blog.php. He has pub- we could use a lowercase “b,” instead.
lished two science-fiction novels, as well as books about science and math- We could also use a capital “E,” for 11,
ematics. Visit www.tikalonpress.com for more information. but having an “E” follow an “A” disturbs
my hexadecimal sensibility. Although I’m
not dyslexic, when I see a “b” on a seven-
segment display, I think “six.” Another
common notation, which I learned in my
elementary school “new math” courses, is to
use “t” for 10 and “e” for 11. Figure 1 shows
possible number representations for ten and
eleven, including the ones I chose for this
clock.

CIRCUIT DESIGN
One way to minimize I/O pin count in a
microcontroller circuit is to use multiplexing
whenever possible. If we were to drive each
seven-segment display and their decimal
points individually, we would need 16 output
pins. If we multiplex, we need just nine; that
is, eight for the segments and decimal point,
and one extra for the digit select.
The segments on the displays need a
reasonably high current, and they also need
about 4.5 V drive. That’s because they’re 1″
displays with two LEDs connected in series
for each segment. For this reason, the
display chips are driven from a 12-V supply,
and the microcontroller interfaces with two
PHOTO 3 7406 TTL open-collector inverter/driver
This is the component side of the clock. From this vantage point, you can see how the right angle connection chips. Green displays were used, but other
is made. The seven-segment displays and current-limiting surface-mount resistors are on the foil side. colors are available.
circuitcellar.com 43

Digit select is easily accomplished with Calculation of Interrupt Overhead Operations


two transistors, also driven by sections
of a 7406. The 5-V power for the PIC movwf wsave ; Set up for interrupt 4
microcontroller and the clock oscillator is swapf STATUS, W 4
derived from a voltage regulator powered by
the 12-V supply. A 12-V “wall wart” is a safe clrf STATUS 4

FEATURES
and convenient way to power this circuit, movwf ssave 4
which is shown in Figure 2. The maximum
movf PCLATH, W 4
current draw for my circuit was 250 mA. The
circuit has two buttons for setting the clock movwf psave 4
by ramping the digits up or down.

CIRCUIT ASSEMBLY BCF T1CON,0 ; Clear bit zero to stop timer 4


I hate surface-mounted devices as much MOVLW D'220' ; Load timer1 low byte 4
as anyone else, but sometimes they’re
important for a compact circuit board layout, MOVWF TMR1L ; 4
even when used sparingly. For example, MOVLW D'11' ; Load timer1 high byte 4
0-Ω SMT resistors act as nice jumpers over
conductor traces when you decide to use a MOVWF TMR1H ; 4
single-sided circuit board. BSF T1CON,0 ; Start timer1 4
In my circuit board layout, I used eight
SMT resistors as current-limiters for the
seven-segment LED displays and their Operations = 48
decimal points. This freed a lot of board
clock cycles = 192
space to make a more compact circuit. The
1206 size resistors used are easier to handle
than the smaller sizes SMT resistors seen on TABLE 1
most circuit boards. Calculation of interrupt overhead

CONNECT WITH

Circuit
Cellar
For people who are passionate
about hardware and software design,
embedded development, and computer
applications. Awesome projects,
industry news, trivia challenges,
and more!

Connect.
Follow us on Twitter. Like us on Facebook.

circuitcellar.com
@circuitcellar
@editor_cc circuitcellar
44 CIRCUIT CELLAR • JANUARY 2015 #294

board will function without cutting. Photo 3


shows the component side of an assembled
board with the right angle connection.

SOFTWARE
The source code for the duodecimal clock,
FEATURES

written in PIC Basic Professional, is available


on the Circuit Cellar FTP site, along with hex
files for using the code without a compiler.
The software also serves as a tutorial on how
to use timer interrupts with a PIC and how
to multiplex a digital display. Interrupts are
one of the most complex things in embedded
systems programming. However, once you
learn how to use them, they facilitate many
projects.
The PIC16F630’s 16-bit timer/counter
(Timer 1) is incremented by the system clock
through a 1:8 prescaler. In this mode with
a 10-MHz clock, the longest interrupt period
is slightly longer than 0.2 s. With a proper
preload of the timer registers, we can make
FIGURE 3 that exactly 0.2 s. Since our lowest digit
This is the measured error, about a minute per week, of my clock. It is the best that can be expected from increments every 5 minutes, or 300 s, we
the crystal oscillator. Tweaking the software won’t give better results. need to count 1,500 interrupt cycles between
digit increments.
As a practical matter, if you load a 0.2-s
Another method I used to make a more period into the timer, you’ll get a clock that
compact circuit is to mount the seven-segment runs a few seconds slow each hour. Why
LED displays on the foil side of the single- should that be? The reason is that the timer
sided circuit board. This was accomplished registers need to be loaded before each
by soldering some single-row, in-line sockets timer cycle. The code to do that, along with
onto the board and plugging-in the displays, other code that precedes this in the interrupt
as shown in Photo 1. This made soldering routine, adds to the overall delay between
a lot easier. You can probably trim some IC interrupts. You need to make the timer a
sockets to make equivalent sockets, perhaps little faster to compensate. Table 1 shows a
bending the leads for soldering. calculation of the overhead operations used
The circuit is laid out on one single-sided in the interrupt code.
board. I’ve designed a gap into the circuit The timer load for a period of 0.2000 s
board layout to allow it to be sawed into with our 10-MHz clock is 3036 (0BDC), but
two boards connected by right angle electrical this must be changed to 3077 (0C05) for
contacts. I used portions of a single-row right 0.1998688 s. With that change, the clock is
angle IDE connector, as shown in Photo 2, to accurate to about a minute per week. This is
make the right angle connection, but the consistent with the precision of the crystal
oscillator, which is specified as 10.000 MHz.
Since our digital readout shows the time
to ±2.5 minutes, that’s enough accuracy.
CMOS Microcontrollers,” DS40039F, 2010, Tweaking the software won’t really help,
ww1.microchip.com/downloads/en/DeviceD- since we’re limited by the timekeeping of the
oc/40039F.pdf. crystal oscillator and the resolution of the
timer register, which is just 16 bits. Changing
SOURCES the timer preload by one bit from 3077 to
LDS-AA12RI Display 3078 results in a time change of almost half
a minute per day.
Lumex | www.lumex.com
Figure 3 shows the measured error
circuitcellar.com/ccmaterials of my clock. The error was measured as
PIC16F630 Microcontroller follows. The clock was set just as the hour
Microchip Technology | www.microchip.com changed on the clock maintained by the
REFERENCE US Naval Observatory (http://tycho.usno.
Microchip Technology, navy.mil/simpletime.html). Then, whenever
PIC Basic Pro I remembered, I would note the time
“PIC16F630/676 Data Sheet:
14-Pin, Flash-Based 8-Bit microEngineering Labs | www.melabs.com difference at some subsequent roll-overs of
circuitcellar.com 45

FEATURES
PHOTO 4
My clock is mounted in a custom case. Note the AM/PM dot and the seconds flashing dot. The time setting buttons are mounted at the rear of the enclosure, but you could place
them anywhere. A green filter increases the digit contrast.

the last digit of the duodecimal clock. The


measured error, at least for the particular
crystal oscillator in my circuit, was about
TRACE 32 ®
a minute per week. The deviation of points
from the straight line likely arises from room
temperature variation.
To multiplex the display digits, we just
quickly switch between the data for one and
the other, inserting some code to look for
button presses that indicate that the user
is trying to set the time. There are other
expected niceties, like a flashing display at
power failure, an AM/PM indicator, and a
seconds flasher.
To get the most accuracy when setting
the clock, you should set the last digit when
the time is 2.5 minutes before the next
5-minute mark; for example, set the clock
for 2:15 (duodecimal 23) when the actual
time is 2:12:30. Setting this way ensures
that the clock is always within two and a half
minutes of the actual time.

READY TO GO
All parts for the duodecimal clock are
readily available from a variety of sources. If
you’re up to the challenge, you can even
produce your own circuit board, as I have.
After a while, you’ll be able to read any of
the times displayed in Photo 4 without
hesitation.

advertisement_arm-overview.indd 1 08.10.2014 11:03:14


46 CIRCUIT CELLAR • JANUARY 2015 #294

The Twin-T Oscillator Configuration


An Audio Oscillator and Stereo VU Meter
FEATURES

The Twin-T Oscillator is an audio oscillator


and stereo VU meter design. The easy-
to-use unit combines a calibrated audio
source with a level display.

By Larry Cicchinelli (US)

S ince retiring last


year, I have provided
technical help at a local
educational radio station.
One of my tasks is to
PHOTO 1
repair some audio modules
The front panel of the oscillator/volume unit (VU) meter contains
from an older console. To all the necessary controls.
repair these circuits, I used a function generator
that I built as an audio source (see “DIY Function
Generator,” Circuit Cellar 270, 2013). I can
vary the required audio signal’s frequency and
amplitude and use an oscilloscope to view the ensure a constant level over a range of power
output. However, it’s not easy for non-technical supply voltages. The circuit I implemented
staff members to use these instruments. maintains its output level over a range of at
I was only going to build the audio source. least 6 to 15 V. Below 6 V, the output begins to
When I thought about how I would use the unit, distort if you have full output voltage (0 dBu).
it occurred to me that the device should have a The modification consists of two antiparallel
display. I decided to design and build an easy-to- diodes in the feedback loop. The idea came
use unit that would combine a calibrated audio from a project on DiscoverCircuits.com (see
source with a level display. Then, I would have a Resources). The project designer also indicates
single, battery-powered instrument to do some that the diodes reduce distortion.
significant audio circuit testing and debugging. Figure 1 shows the oscillator’s schematic.
Photo 1 shows the completed unit’s front panel. Header H1 and diode D1 enable you to have two
power sources. I installed a 9-V battery and
TWIN-T OSCILLATOR snap connector in the enclosure as well as a
The oscillator uses the well-known Twin-T connector for external power. The diode enables
configuration with a minor modification to the external source to power the unit if its
circuitcellar.com 47

voltage is greater than the battery. Otherwise


1
the battery will power the unit. The oscillator frequency =
draws about 4 mA so it does not create a large
(2 × π × Rx × Cx )
battery drain. I decided to simplify the necessary parts
The standard professional line level is 4 dBu, by paralleling resistors and capacitors shown
which is 1.228 VRMS or 3.473 VPP into a 600-Ω in Figure 1 so the circuit uses a single value

FEATURES
load.[1] The circuit values enable you to use R18 for the capacitors and resistors.
to calibrate it, so the maximum output can be R5 and R15 create a bias voltage, which
set to the 4-dBu level. A 7.7 (3.473/0.45) gain is enables the op-amp to operate as if it were
required to provide 4 dBu at the transformer. powered by positive and negative supplies.
Using the resistors shown in Figure 1, R18 Originally, I had the low side of T1’s primary
varies the gain of U1.2 from about 4.3 to 13. connected to this bias voltage. However, this
You may need to use different resistor values caused more current to flow through R15,
for R18, R19, and R20 to achieve a different which raised the bias voltage causing the
maximum level. If you prefer to use 0 dBm (0.775 sine wave’s positive peaks to be clipped to the
VRMS into 600 Ω) instead of 4 dBu, you should supply voltage. I decided a better solution was
change R20 to about 5 kΩ to give R18 a range to ground the primary via a capacitor. A 10-µf
more closely centered on a 4.87 (2.19/0.45) gain. capacitor has a 16-Ω reactance at 1 kHz. It is
The R20’s value shown in Figure 1 will probably low enough relative to the transformer’s 600
work, but the required gain is too close to the Ω that it does not cause a problem.
minimum necessary for comfort. If you need the oscillator to work at a
Most schematics for a Twin-T oscillator will lower frequency, you may want to increase
show the combination of R3 and R4 as a single the C8’s value. This is not strictly necessary
resistor of value Rx/2. They will also show the since the unit is built for a single frequency. You
combination of C1 and C2 as a single capacitor of can also calibrate the output voltage and adjust
value Cx × 2. These values lead to the following the calibration for the capacitors’ reactance.
formula: Note: A 1-µf capacitor has a 160-Ω reactance

FIGURE 1
The Twin-T oscillator’s
schematic shows the
connections.
48 CIRCUIT CELLAR • JANUARY 2015 #294

FIGURE 2
With the VU meter, the standard
professional line level is 4 dBu, which
equals 1.228 VRMS, which equals
4.474 VPP. Adjust R14 with the 4-dBu
input so only LED7 illuminates.
FEATURES

at 1 kHz. I try to remember this whenever I Digi-Key does not normally carry them. I
work with audio circuits so I can easily calculate used the Sw6 to enable the left-channel phone
the capacitor’s reactance. For instance, a 5-µf connectors to carry both the left and right
capacitor at 10 kHz has an approximate 3.2-Ω channels to the VU meters. In this case, they
(i.e., 160/5 × 10) reactance. Conversely, a 1-µf would obviously be unbalanced.
capacitor has a 1,600-Ω reactance at 100 Hz
(i.e., 0.1 kHz). VU METER
The bias circuit’s bypass capacitor is actually The basic VU meter circuit is for a single
higher than necessary for a 1-kHz oscillator. channel. However, I designed a circuit board
However, I decided to use a value of 100 µf in with two of them side-by-side for stereo
case someone builds the circuit and modifies operation. Because the two circuits are
the Rx and Cx values so a lower frequency is completely isolated, the board can be cut in half
generated. and mounted so that the displays can also be
I used a transformer in the output for one above the other rather than side by side.
complete isolation. It enables the output to be Figure 2 shows a single circuit schematic. As
either balanced or unbalanced. There are two with the oscillator, the circuit has a transformer
ABOUT THE AUTHOR attenuation pads, 20 and 40 dB, which can be so the signal can be either balanced or
Larry Cicchinelli received used to reduce the level to that of a microphone. unbalanced. Unlike the oscillator, it has a 600-Ω
a BSEE from the Drex- The attenuator resistors are in the unbalanced fixed-input impedance.
el University Institute of “T” configuration and are calculated for a 600- There is a single-stage amplifier with a
Technology in 1969 and a Ω load. toggle switch enabling you to have three gain
MSES from Pennsylvania I used eSSB Hi-Fi Audio’s online calculator values: 0 db (×1), 10 db (×3.16) and 20 db (×10).
State University in 1981. to derive the values. I chose the unbalanced To save on circuit design and components, the
He worked for Ford Mo- configuration since the system is completely gain with the switch in the center position is 20
tor from 1967 to 2000, isolated via the transformer. It enabled me to db. I also used a DPDT toggle switch so a single
which includes the 30 use a simpler switching circuit. There is also switch can operate both left and right channels.
a switch that enables you to select either, or The switch can be mounted on or off the circuit
years he spent designing
neither, of the two load resistors. I used 600 Ω board. You can run wires to the switch location
and building test equip-
and 10 kΩ. on the second VU meter circuit from pads on
ment for the automotive
Two more switches expanded the device’s the circuit board, which are designated as H2.
electronics industry. Lar-
feature set, in conjunction with the volume unit Similar to the oscillator, I used a voltage
ry was a technical support (VU) meter. I used Sw5 to temporarily connect divider to create a bias voltage of half the
manager for Digi Interna-
the tone generator to either the left or right supply voltage. This bias is needed only for the
tional, Rabbit Brand, from
channel so I could test the system. However, amplifier stage. I used the second half of the
2000 to 2012. He also au-
the bill of materials (BOM) calls for a standard dual op-amp as a precision rectifier. The diode
thored the book, Assem-
double-pole, double-throw (DPDT) switch with in the output ensures that the capacitor does
bly Language Essentials
the center off. not discharge when the output voltage goes
(Circuit Cellar, 2011).
I used a switch from my junk box and it lower than the peak. Resistor R12 limits the
is a momentary, or spring-return. However, current required from the op-amp to charge
CC Vault
Unlock the power of embedded design.

This pocket-sized vault comes fully loaded with every issue of Circuit Cellar
magazine and serves as an unparalleled resource for embedded hardware
and software design tips, schematics, and source code.

From green energy design to ‘Net-enabled devices, maximizing power to


minimizing footprint, CC Vault* contains all the trade secrets you need to
become a better, more educated electronics engineer.

A vault of need-to-know information in the fields of embedded


hardware, embedded software, and computer applications

*CC Vault is a 16-GB USB drive.

Order yours today! cc-webshop.com


50 CIRCUIT CELLAR • JANUARY 2015 #294

is a logarithmic scale generally covering the –20


to 3 VU range. To make the unit more useful for
pro audio applications, I shifted the scale to the
–16 to 7 dBu range. Potentiometer R14 enables
you to calibrate the unit. By changing the gain
of either op-amp stage, you can shift the range
FEATURES

higher or lower. However, the span will always


be 23 dB.
Two other devices similar to the LM3916
could also be used. The LM3915’s outputs are
in 3-dB steps. The LM3914 has linear outputs.
Either device may be substituted for the LM3916
if you need a display other than a VU meter.
You will probably need to tweak some of the
resistor values to get your desired range. The
specifications for all three devices are available
on TI’s website.
All three devices enable two modes of
operation for the display: dot or bar. I usually
use the bar mode since it is easier to read.
However, in this case I used the dot mode since
it uses less current. There is a way to use the
bar mode with less current but it requires at
least a 20-V power supply.
I used a cardboard spacer to get the LEDs
to sit at the correct height above the board. The
spacer is about 5” long so it spans the width of
both displays and it is 15 mm high. I determined
FIGURE 3 the capacitor as well as affecting the response the height by measuring the distance from the
The chassis wiring includes
time. PCB to the base of the Switch 1 handle. The
several connectors for each
I used the well-known Texas Instruments spacer fits between the legs of all the LEDs.
circuit.
(TI) LM3916 for the display driver. This IC has Some packages contain 10 LEDs with various
10 outputs for driving LEDs, which duplicate color combinations. However, I designed the
most of a standard VU meter’s labeled values. It circuit to use discrete LEDs so I could select the
colors. The circuit board is designed so the LEDs
are 0.2” apart. The board with two circuits on
it has 0.4” between the most-significant left-
channel LED and the least-significant right-
eSSB Hi-Fi Audio, www.nu9n.com.
channel LED. If you need a wider range VU
A. Morris, “Twin-T Oscillator,” http://discover- meter, see my article “Calibrated Decibel Meter
circuits.com/Andy/Twin-Toscillator.pdf. Design,” Circuit Cellar 236, 2010 or visit my
OSH Park, www.oshpark.com website (www.qsl.net/k3pto).

Texas Instruments, Inc., www.ti.com THE CHASSIS


Wikipedia, “Line Level,” http://en.wikipedia. The unit I built has several connectors for
org/wiki/Line_level. each of the circuits to accommodate different
circuitcellar.com/ccmaterials audio inputs and outputs. I used XLR-3 and RJ45
REFERENCE connectors and 0.25” and 0.125” stereo jacks
for balanced inputs and outputs. However, both
RESOURCES [1] Wikipedia, “Line level,” http://en.wikipedia.
the 0.25” and 0.125” stereo jacks will work with
org/wiki/Line_level
L. Cicchinelli, “DIY Function mono plugs since they will ground what would
Generator,” Circuit Cellar have been the ring connection. I also used RCA
270, 2013. SOURCES connectors for unbalanced circuits. I know it
———, “Calibrated Decibel PCB design software seems like a lot, but I encounter all of these
Meter Design,” Circuit Cellar DipTrace | www.diptrace.com when working with various audio systems.
236, 2010. Sometimes it may be easier to just use adapter
LM3916, LM3915, and LM3914 Circuits cables but I have found that the appropriate
———, K3PTO Published Arti- Texas Instruments, Inc. | www.ti.com adapter is not always available. Since I used
cles, www.qsl.net/k3pto. a plastic enclosure, I was not concerned with
DiscoverCircuits.com, http:// ground isolation for any of the connectors.
discovercircuits.com/Andy/ Unless you are familiar with some of the
Twin-Toscillator.pdf. more recent professional consoles, you will be
circuitcellar.com 51

surprised at the inclusion of the RJ45s. Many


audio consoles are now using them for line-level
signals. Figure 3 shows Pin 1 and Pin 2 are the
left channel and Pin 3 and Pin 6 are the right
channel.
Just a note about XLR sockets used for the

FEATURES
VU meter. If you use the ones listed on the BOM,
you may want to remove the retaining clip sot
that any connector you insert will not get stuck
permanently. The clip can be removed from the
back by pulling it out with a pair of pliers. You
may also need to insert a small screwdriver
blade from the front to help release the clip.

CONSTRUCTION NOTES
The PCBs are mounted to the top of the box.
All the I/O connectors are mounted to the four
sides of the bottom. There are several mounting
holes on each PCB but I only used two on the
oscillator and two on the pair of VU meters.
The calibration potentiometers and I/O
headers should be mounted on the bottom of
the PCBs for easy access. I also mounted the
transformers on the bottom sides so the space
between the board and the box top’s underside
only needs to accommodate the height of the
switches.
Although the transformer has a 1:1 turn
ratio, the resistance of the two sides is different.
I used the higher resistance side (about 60 Ω)
as the primary. The switches and most of the
remaining components are on the top sides.
Templates to drill the required holes in the PHOTO 2
top are included with the build files. These The Twin-T oscillator and dual VU meter contain separate circuit boards.
two files must be opened with DipTrace, a PCB
design software, to get the printout at the I have been using these connectors for quite
proper size. a few years and they have proven to be quite
There are files with labels so you can make useful—especially when I have to disassemble
an overlay for each PCB. There is also a PDF file a system!
with individual labels for each of the controls. I now have a crimp tool for the pins.
The dimensions on the templates are there just Previously, I used a small pair of long-nose
to ensure your printout is the correct size. I pliers for crimping. It took me a few tries to
created separate files for the oscillator and VU master it, but I was able to finish fairly quickly.
meter to properly space them for the enclosure Both the headers and the housings need to be
(see Photo 2). cut to the appropriate lengths for the various
If you use the same enclosure I did, you header locations. I typically use diagonal
may need to cut down the two center posts on cutters to cut the headers and a hobby or utility
the top used to attach the top to the bottom. knife to cut the housings.
Depending on exactly where and how you The consolidated BOM indicates the
mount the boards, they may interfere with number of parts to purchase for this project.
mounting the oscillator PCB to the top. The individual BOMs indicate the number of
All the headers are optional. You can just connectors after they are cut to size. I did not
as easily solder wires into their pads for the use the connectors for the power connections
interconnections. I like to use the headers, (H4) or Sw1 (H2) between the two VU meter
pins, and pin housings because they enable me sections. I just soldered jumpers between the
to easily connect and disconnect the boards locations.
during assembly and later for debugging. My source for this project sells three copies
When purchased in quantity, enough of a PCB at $5/in2. This is the lowest cost
for 100 connections, the additional cost is supplier I have found. All the design files (e.g.,
approximately $0.18 per connection. If you the schematics and related build files) are
purchase just enough for this project, the available on my website, www.qsl.net/k3pto.
cost is approximately $0.27 per connection.
52 CIRCUIT CELLAR • JANUARY 2015 #294

THE CONSUMMATE ENGINEER

Essential Electromagnetic
Compliance (Part 2)
COLUMNS

A Look at EMI Causes & Signal Types


Last month, George introduced the topics of EMC and electromagnetic
forces. In this article, he details the causes of electromagnetic interference
(EMI) and explains the difference between differential mode (DM) and
common mode (CM) signals.

By George Novacek (Canada)

W hat are the causes of electromagnetic


interference (EMI)? Common sources
are discontinuous waveforms (e.g., a square
dB/dec slope toward lower frequencies. It is
easier to reduce the spectrum at the source
than to try to suppress it later.
wave) rich in harmonic frequencies. All PCB traces make good radiators (antennas)
digital signals belong there, such as clocks at a quarter wavelength (λ/4) and its odd
and pulse-width modulated (PWM) signals, multiples, such as 3λ/4, 5λ/4, and so forth. A
switching power supplies, and so forth. PCB trace merely 50 mm long can resonate at
Consider a computer clock. As I mentioned around 1.5 GHz. Odd multiples of the quarter
in my December 2013 article, “Impedance wavelength can cause resonances at higher
Matching” (Circuit Cellar 281), a square wave frequencies as well. They are the cause of
comprises odd harmonics. A crisp clock, for overshoot and ringing of waveforms, leading
example, is required for reliable operation to interference emissions and a potential loss
of digital circuits. It needs to contain at of the signal integrity.
least eleven harmonics. Figure 1 is a non-
dimensional illustration of the spectrum of a DESIGN FOR COMPATIBILITY
typical 50% duty cycle square waveform. Designing for electromagnetic
Notice that, typically, the amplitude of the compatibility, in general terms, requires
harmonic frequencies falls at a rate of –20 addressing of three basic areas: the source
dB per decade (dB/dec). At some frequency, of the threat, the victim of that threat, and
the slope increases to –40 dB/dec. That a coupling path for the threat to reach the
frequency is determined by the rise and victim.
fall times of the pulses. Consequently, the We can view the EMC implementation
spectrum of a 50-MHz clock with very fast from two perspectives. From the victim’s
rise and fall times can extend well into the standpoint, the threat comes from the
gigahertz region. operating environment. A system specification
This is why some communication protocols defines the levels of threat and the victim’s
(e.g., ARINC429) typically used in avionics, susceptibility (also called immunity) the design
where minimizing EMI is critical, use a must comply with. From the environmental
trapezoid wave shape with defined rise and standpoint, the specification establishes the
fall times. This moves the onset of the –40- maximum threat the equipment is allowed to
circuitcellar.com 53

generate by radiated or conducted emissions


of unwanted frequencies. +5

How does a threat couple to the 0

victim? First, there are couplings through −5

common impedances, provided by common −10

conductors, such as power leads, grounds, −15 −20 dB/dec

shields, and so forth. It gets worse at higher −20


−40 dB/dec
frequencies due to the skin effect causing Magnitude (dB) −25
−30
increased resistance of the return path as
−35
well as increased inductive impedance. This is
−40
why woven straps (see Photo 1) with very low −45
impedances are used for grounding. Figure 2 −50
is an example of common impedance coupling

COLUMNS
−55
through return paths to ground. −60
It is often incorrectly assumed that 1 3 5 7 9 11 13 15 17 19 21 23
grounds and power rails have zero impedance. Harmonic frequency number
Careful system architecture and PCB layout
are needed for return paths to minimize noise
and avoid issues such as parasitic oscillations. FIGURE 1
Normalized spectrum of a square wave (e.g., clock) signal
One common coupling path is via electric
field (E) caused by stray capacitances. The
stray capacitance causes a noise current to SIGNAL MODES
be injected into the victim circuit: Interference signals occur in a differential
mode (DM) or a common mode (CM). DM
dVSIGNAL
ICOUPLED = CSTRAY × signals occurring on the send and return
dt conductors are in opposite polarity, such as
The higher the rate of change of the noise on power distribution or unbalanced signal
voltage (dV/dt), the stronger the coupling and, lines. CM signals are of the same polarity,
thus, the coupled current will be. Assume the measured with respect to some reference
victim’s impedance Z V is much smaller than point. This is illustrated in Figure 3. Sensor S1
the coupling impedance ZC . That is: has a balanced output which is connected to
1
an operational amplifier U1. For the moment,
Z V  ZC = ignore that the wires are twisted and that the
2πfCSTRAY
cables are shielded. We’ll return to it later.
And the physical size of the circuit is The balanced signal from sensor S1 will
<< λ/6. Also assume a presence of a 100- be seen at the positive and negative nodes
MHz, 5-V squarewave in the vicinity. A stray as a DM signal—that is, a voltage difference
capacitance of merely 0.1 pF will cause 310
µA of noise to flow in the victim.
Magnetic field (H) coupling induces noise
voltages in the affected circuits. Similar to E
coupling:
dISIGNAL
VCOUPLED = −M STRAY ×
dt
This is valid for the victim’s impedance:
1
ZV 
2πfM STRAY PHOTO 1
This grounding strap has very low impedance at frequencies in the tens of gigahertz range
And the physical size of the circuit is
<< λ/6. A mutual inductance of only 10 nH
will induce 630 mV of a 100-MHz, 100-mA
squarewave in the victim. OUT 1 2 3 IN
Most interference contains both electric
and magnetic components, generating an R1A I1 R2A I2 R3A I3
electromagnetic (EM) field. Coupling of the E V1A =
V2A = R2A × (I2A + I3A) V3A = R3A × I3A
R1A × (I1A + I2A + I3A)
component through stray capacitances and
coupling of the M component through stray G
inductances are the sources of radiated
and conducted emissions causing higher
susceptibility (or lower immunity) in victim FIGURE 2
circuits. Common impedance coupling through ground connection
54 CIRCUIT CELLAR • JANUARY 2015 #294

between the nodes. It will be amplified by the in Near M Field. An unbalanced line with the
U1 gain. Should the S1 interface be irradiated send and return wires running in parallel,
by an EM-field, the same CM interference will even when the wires are very close, forms
be induced in the send and the return wires. a loop, which is susceptible to the magnetic
Ideally, both leads will carry an identical field. Twisting the wires makes the interface
interference signal. The DM signal will be act like many small loops, and the opposite
superimposed on the CM interference. As long interference voltages in the adjacent loops will
as the input magnitude does not exceed the cancel each other for effective suppression of
amplifier’s common mode input range, the U1 magnetic interference.
output will be the amplified DM signal only. Clearly, CM and DM interference signals
The interference will be suppressed by the are bad news. They need to be suppressed to
amplifier’s common mode rejection (CMR) minimize the emissions of and susceptibility
characteristics. In reality, because the signals to the EMI. First, shared conductors must
COLUMNS

will not be perfectly balanced, the shielding have minimal impedance. This is achieved
ABOUT THE AUTHOR won’t be 100% effective, the CMR won’t be by bus bars, ground straps, and ground
infinite, and some parasitic DM interference planes. The power distribution conductors
George Novacek is a will occur and will have to be suppressed, need to be by-passed with capacitors. The
professional engineer usually by filtering. send and return leads should be twisted or
with a degree in Cyber- Sensor S2 is not balanced. An irradiation at least as close to each other as possible.
netics and Closed-Loop will cause a DM voltage to develop between Interfaces should use shielded, twisted pairs.
Control. Now retired, the two leads due to current flowing through Currents always flow through the paths of
he was most recently S2 and other components to ground. the least impedance. Minimizing the return
president of a multina- Shielding effectiveness of coax in Far EM Field path’s impedance minimizes stray coupling.
tional manufacturer for is predictable, but special considerations may Whenever possible, floating devices should
embedded control sys- be required for shielding of low frequencies be bonded to a grounded, common chassis.
tems for aerospace ap- CM interference in floating circuits can be
plications. George wrote reduced by CM chokes (also called baluns), as
26 feature articles for shown in Figure 4.
U1
Circuit Cellar between +
1999 and 2004. Con-
S1

SUPPRESSION
tact him at gnovacek@ CM chokes are frequently used in radio
frequency (RF) circuits for impedance
nexicom.net with “Cir-
matching, but they are also used to suppress
cuit Cellar”in the sub-
CM EMI. In Figure 4, the switch mode regulator
ject line. S2 +
generates, by its very nature, a lot of high-

U2 frequency common mode noise on the power
supply lines. Inserting a common mode choke
Internal ground with a few capacitors as shown will greatly
FIGURE 3
DM and CM signals have different
reduce the EMI reaching the common DC
impacts on EMC. power distribution.
Capacitors C1 and C4 serve to suppress the
differential noise. Capacitors C2 and C3 (also
Common mode choke
called Y capacitors) suppress the common
mode noise by returning it back to the
C2
source. The noise current flows through the
Battery
+ C4 Switch mode hot and return wires in the same direction.
C1 power supply
The common mode choke, essentially a 1:1
C3 transformer, inverts the phase of the noise in
the return paths. This causes the noise in the
two leads to be out of phase and thus cancel
each other out.
FIGURE 4 Using metal ground planes in design, such
Principle of using a common mode choke to suppress conducted EMI as PCB ground planes or metal shields, is very
beneficial for the EMI suppression. The planes
provide much lower impedance than just
RESOURCES
conductors, in addition to reflecting incident
K. Armstrong, Interference Technology Webinars,
EM waves and thus reducing coupling.
www.interferencetechnology.com/webinar-series/
In the next installment of this series we’ll
discuss the practical EMC requirements for
O. Hartal, Electromagnetic Compatibility by Design,
electronic instruments and systems.
R&BV Enterprises, 1993.

circuitcellar.com/ccmaterials
Verilog HDL
With the right tools
such as this book,

designing a microprocessor
can be easy.
Microprocessor Design Using
Okay, maybe not easy, but certainly Verilog HDL will provide you
with information about:
less complicated. Monte Dalrymple • Verilog HDL Review

has taken his years of experience • Verilog Coding Style


• Design Work
designing embedded architecture • Microarchitecture
and microprocessors and compiled • Writing in Verilog
• Debugging, Verification,
his knowledge into one comprehensive and Testing

guide to processor design in the • Post Simulation and more!

real world.

Monte demonstrates
how Verilog hardware
description language
(HDL) enables you to
depict, simulate, and
synthesize an electronic
design so you
can reduce your workload
and increase productivity.

cc-webshop.com
56 CIRCUIT CELLAR • JANUARY 2015 #294

ABOVE THE GROUND PLANE

Brute-Force
Universal
Motor Control
COLUMNS

This month, Ed constructs a quiet motor controller for his wife’s


sewing machine, with both safety and simplicity in mind, and
explores voltage, resistance, and current controls.

By Ed Nisley (US)

C ontemporary motor controllers combine


high-speed microcontrollers
switching transistors to precisely regulate
with
the coil generates a Lorentz force to spin the
motor shaft. Either the coil or the magnets
may rotate with the motor shaft: traditional
the winding voltage and current. In contrast, DC motors have rotating coils, while stepper
I’m exploring a solution that uses a simple motors have rotating magnets. A mechanical
transistors with continuous current in order or electronic commutator switches the
to avoid the acoustic noise generated by a direction of the current as the shaft rotates
rapidly switched supply. As you saw in my to produce a net torque in one direction.
November 2014 column, a transistor operating The “universal” motor used in Mary’s
in its linear region experiences a surprising Kenmore Model 158 sewing machine
amount of stress and, consequently, the has no magnets. Instead, it generates a
design requires a much larger device than magnetic field from current passing through
those found in switching supplies. stationary windings in the motor case. That
In this column, I’ll explain several control same current also passes through the rotor
techniques, then look at the circuitry driving windings, with a carbon-brush commutator
the hulking ET227 transistor and monitoring reversing its direction to maintain the proper
the motor current. Along the way, you’ll see magnetic field orientation. As a result, a
why I had to build a metal-enclosed case universal motor can run from an AC or DC
before taking any measurements. power source: back when electricity was
new, that was truly magical.
VOLTAGE VS. CURRENT CONTROL The torque in a DC motor will be more-
A DC motor immerses a coil of wire in or-less linearly related to the winding
the magnetic field created by permanent current, because the magnets produce a
magnets, so that a current passing through constant field. However, the torque in a
circuitcellar.com 57

universal motor varies as the square of the


current, because both the winding and rotor
magnetic fields depend on the same current.
That means a small change in the current
produces a large change in the motor’s
output torque.
Figure 1 in my November 2014 column
shows the linear relationship between the
applied DC voltage and the motor speed, with
the two straight lines representing different
loads on the motor shaft: it draws 500 mA
when unloaded and 700 mA while spinning
the sewing machine shaft. For a given load,

COLUMNS
however, the current varies only about 10%
across the entire speed range.
You can see why a constant-voltage
source works well for a universal motor: with
a fixed load, changing the voltage changes
the speed in a very predictable manner.
Changing the load will also change the motor
speed, but the controller simply supplies
whatever current the motor requires to
support the new load at the original voltage.
This is a stable situation, even without shaft
PHOTO 1
speed feedback. A case harvested from an obsolete Dell GX270 PC holds all of the motor controller circuitry and provides an
The original foot pedal controlled the ATX power supply. The AC Power Interface components mount on a polycarbonate sheet across the front of
universal motor’s speed by inserting a the chassis at the top of the picture, with the Low Voltage Interface components in the left rear. I bent the
resistance to absorb the difference between bulky power harness out of the way for this picture.

FIGURE 1
The AC Power Interface components operate at 120 VAC, with optical and relay isolation from the rest of the circuitry. An interlock switch disables the relay when the chassis lid
opens, but you must treat all the components as adversaries armed with lethal weaponry.
58 CIRCUIT CELLAR • JANUARY 2015 #294

PHOTO 2 the power line voltage and the motor’s


This prototypting board holds the
terminal voltage at any given speed. Because
relay that disconnects the line voltage
the current varies as the square root of the
when the clamshell case opens, the
optoisolator and PNP current amplifier
load, the motor voltage remains nearly
(on the heatsink), and the ferrite constant with small load variations and the
toroid that senses the motor current. resistance acts as a simple voltage-mode
The ribbon cable in the background controller.
carries the front-panel LED and switch Controlling the speed of a universal
connections under the prototyping motor by adjusting its current, however,
board to the Low Voltage Interface faces a serious challenge: the square-law
board. relationship works the wrong way. A simple
experiment with a constant-current bench
power supply showed that reducing the
COLUMNS

current by just 30 mA caused the motor to


coast to a stop and increasing it by 30 mA
revved it up to full speed. That came as no
surprise, because the power supply adjusted
the voltage to whatever the motor required
at the new current setting, producing either
a stall or a runaway. In effect, open-loop
current control isn’t stable.
Fortunately, this sewing machine has
a response time measured in seconds,
not milliseconds, so I thought a current-
mode controller using feedback from the
motor speed could be stable enough for my
purposes. After all, tweaking the control
algorithms should be a simple matter of
software.

ISOLATING THE HARDWARE


Unlike most projects seen in these pages,
the hardware in Photo 1 can kill you: the
red stripes on the big heatsink serve as a
reminder that it operates at power-line
voltages. I won’t go into construction-level
detail, but keep in mind that low-voltage
hookup wire isn’t appropriate for power-line
hardware, the components must be firmly
mounted, and fuses aren’t optional.
Rather than build an enclosure from
scratch, I harvested the case from an old
Dell GX270 PC. The gray plastic clamshell
isn’t particularly pretty, but the interlocking
sheet metal box inside provides a completely
grounded enclosure with an ATX power
supply, a front-panel power button, LED
PHOTO 3 indicators, a pre-punched rear panel, and
The Low Voltage Interface board handles power supply control, the front panel, the LED current sink, and many useful hardware gadgets.
the optoisolator driver, with the Arduino Pro Mini providing the control logic. Most of the pins on the ATX The schematic in Figure 1 shows the
connector at the right aren’t used. AC Power Interface with the power-line
components, most of which mount directly
on a 6-mm polycarbonate sheet attached to
the aluminum tray that originally supported
the GX270’s system board. The remainder fit
FIGURE 2 on the prototyping board shown in Photo 2,
The ET227 transistor has hFE < 10, so with the fuseholder firmly glued to the ATX
an MJE2955 PNP transistor boosts the
power supply case. A 10-pin header carries
optoisolator’s output to get enough
the wires, all with 300 V insulation, from
gain. Two different optoisolators
produced dramatically different
the prototyping board to the Low Voltage
results; I used the SFH6106-2 in the Interface board shown in Photo 3.
final circuit. The power line’s hot lead passes through
circuitcellar.com 59

a relay that disconnects it when the


clamshell case opens. That reduces the risk
of electrocution, but I still obey the “keep ABOUT THE AUTHOR
one hand in your pocket” rule while working Ed Nisley is an EE and author in Poughkeep-
inside the open case.
sie, NY. Contact him at ed.nisley@pobox.com
The bridge rectifier converts the AC line
with “Circuit Cellar” in the subject line to avoid
voltage into pulsating DC, allowing the ET227
spam filters.
NPN transistor to regulate the motor current.
As a result, the GNDPWR node shown in the
schematic does not correspond to the power
line’s neutral conductor: clipping a scope
probe’s ground lead to GNDPWR will produce
the horrible smell of charred insulation and,

COLUMNS
most likely, destroy the probe. You must
power this circuitry through a line isolation
transformer before attaching any test that the op amp and transistor convert to
equipment. a current through the optoisolator LED. The
The ET227 attached to the back of the 2N3904 transistor has a DC current gain over
large heatsink in Photo 1 requires about 100 50, so the error due to the base drive current
mA of base current to control 1 A of motor in the sense resistor amounts to less than
current. That’s far more than the optoisolator 2%.
can provide, so the MJE2955 PNP transistor The 3.3 kΩ emitter resistor sets the gain to
acts as a current amplifier with a gain of 3.3 V/mA and limits the maximum current to
about 100, drawing current from an isolated 1.5 mA with a 5-V input. Because the end-to-
+5 V supply. Because the ET227 base runs end gain from the DAC to the motor depends
at about 900 mV, the MJE2955 will dissipate strongly on the transistor temperatures,
nearly half a watt and requires the small however, I added the slit ferrite toroid and
heatsink appearing just to the left of the Hall effect sensor represented at the bottom
ET227 heatsink in Photo 1 and on the right
in Photo 2.
The graph in Figure 2 shows the end-
to-end current gain for two different
optoisolators from my parts collection, with
a safe 10 VDC applied to the ET227 collector.
Although the datasheets claim that the two
optoisolators should have similar current
transfer ratios, the nearly 4:1 ratio between
the two barely falls within their specification
limits. It’s also entirely possible that these
surplus parts don’t match their specifications
or that they’re incorrectly marked. As always,
FIGURE 3
one careful measurement trumps a thousand
The MCP4725 DAC provides a ripple-free voltage output that controls the optoisolator LED current. The
assumptions! 3.3-kΩ sense resistor sets the scale at 0.33 mA/V, so that 3.3 V from the DAC will produce a motor current
The motor draws about half an amp just over 1 A.
to turn the sewing machine shaft and its
locked-rotor current peaks around 3 A,
corresponding to LED currents between 800
µA and 1.5 mA in the SFH6106-2 optoisolator.
Photo 2 shows the four-pin DIP optoisolator
in an 8-pin DIP socket; the two optoisolators
have different pinouts, so I wired the socket
to accommodate either IC while running the
tests.

CURRENT DRIVER AND MONITOR


Figure 3 shows the circuit driving the
optoisolator LED; these parts live on the Low
Voltage Interface prototyping board in Photo
3. Although I’ve used Arduino PWM “analog” FIGURE 4
outputs with RC filters in previous projects, The differential amplifier removes the VCC/2 offset from the Hall effect sensor output and scales the motor’s
an Adafruit MCP4725 12-bit I2C DAC breakout maximum current to the Arduino’s 5 V ADC input range. The diodes clamp the op amp output between 0 V
board produces a ripple-free 0 to 5 V DC output and 5 V to avoid damaging the ADC input.
60 CIRCUIT CELLAR • JANUARY 2015 #294

of Figure 1 to directly measure the output


ADCvalue = (word)analogRead(PIN_PEDAL); current with complete galvanic isolation.
DACvalue = map(ADCvalue,0x0100,0x03ff,0x0800,0x0fff); Photo 2 shows the toroid, nestled in a 3-D
printed holder, with the sensor IC in the slit.
dac.setVoltage(DACvalue,false); I used a pair of 25 turn windings in
parallel to double the copper cross-section
LISTING 1 without having to bend thicker wire around
This Arduino code converts 10 bits of ADC input into 12 bits of DAC output through a linear mapping. It’s the fragile ferrite. The windings are 24 AWG
not suited for production use, because it imposes a high minimum current with the pedal fully released. enameled wire, so their parallel equivalent is
21 AWG, with about 13 mΩ total resistance.
The normal motor current will be about 1 A
and, with 13 mW dissipation, heating won’t
pose a problem.
COLUMNS

The differential amplifier circuit in


Figure 4 removes the Hall effect sensor’s
VCC /2 offset and scales the result so that the
motor’s locked-rotor current will correspond
to about 5 V at the Arduino’s ADC. The
two Schottky diodes on the op amp output
ensure it won’t apply voltages beyond the
supply limits to the ADC input; although the
Arduino has input protection circuitry, it’s
Good Practice to not depend on it.
A 3-D printed bracket firmly attaches
the ATX connector to the prototyping board
for secure access to its control signals and
supply voltages. Although I don’t have room
here to describe the circuitry or firmware,
the GX270’s front panel power button works
as before: push to turn on, push again to
turn off. The yellow LED behind the button
glows to indicate that the power supply is
plugged in, the green power LED lights when
PHOTO 4
the ATX power supply turns on, and the hard
The top trace shows the output of the Hall effect sensor monitoring the motor current, with the differential drive LED glows when the relay connects the
amplifier removing the VCC/2 offset and scaling it to 1.9 V/A = 525 mA/div. The bottom trace comes from AC line voltage to the motor driver.
a Tektronix Hall effect current probe at 200 mA/div. The flat tops in both traces match at just over 800 mA. The heatsink beside the ATX connector
cools an LM317 voltage regulator that drops
+12 V to +7 V for the Arduino, dramatically
reducing the thermal stress on its tiny SMD
regulator.
In addition to the ATX connector, a
PROJECT FILES ” http://softsolder.com/2014/08/14/ separate wire harness originally powering
gapped-ferrite-toroid-5-a-calculations/. the GX270’s graphics hardware now lights
several LED strips that brighten the sewing
———, “Universal Motor Control vs. Transistor machine’s work area. Those lights put a
SOA,” Circuit Cellar 292, 2014. constant minimum load on the power supply,
although it seems perfectly stable with
Universal AC-DC Motors, https://en.wikipedia. almost no load at all.
org/wiki/Universal_motor. The yellow and orange wires entering
Photo 3 from the lower right deliver the
circuitcellar.com/ccmaterials
analog voltage from the foot pedal position.
Although that signal should control the
SOURCES
RESOURCES motor speed, I ran some open-loop tests
MCP4725 DAC Breakout board
E. Nisley, “Current Sensing: before building the speed and shaft position
Adafruit Industries | www.adafruit.com/
Powered Iron Toroid,” http:// sensors.
products/935
softsolder.com/2014/09/18/
current-sensing-pow-
SS49E Hall effect sensors
OPEN-LOOP MOTOR POWER
ered-iron-toroid/.
Honeywell | http://sensing.honeywell.com/
The snippet of Arduino code in Listing 1
product-page?pr_id=36526
converts ADC input values into DAC output
———, “Gapped Ferrite values using the linear map() function. The
Toroid: 5 A Calculations, dac.setVoltage() function comes from
circuitcellar.com 61

the Adafruit MCP4725 support library and


hides the complexity of the hardware I 2C
interface. This code, embedded in a trivial
main loop, updates the motor current every
600 µs.
The Hall effect sensor I described in the
November column produces a nicely shaped
voltage-versus-position output that’s well
suited for a closed-loop controller that forces
the motor speed to match the pedal position.
It works poorly with an open-loop current
driver, because the loaded motor doesn’t
start turning until it sees about half an amp

COLUMNS
and reaches full speed at 1 A.
The pedal signal ranges from about 1 V
to 4.5 V across the full range of pedal travel.
The map() function translates the ADC values
into output voltages between 2.5 V and 5 V,
using the 12 bit format expected by the DAC.
As a result, the motor driver applies half an
PHOTO 5
amp to the motor with the pedal released, so
Applying a heavy load to the motor while increasing the current limit produces rising motor torque. The
that it starts smoothly with minimal pedal lower trace scale is now 500 mA/div, with the motor current limit at just under 2 A for the last half-cycle.
motion.
Pop Quiz: Verify the current. Hint: Figures
2 and 3.
Although the pedal runs the motor see the similarity with the upper trace.
through its entire speed range, burning 50 The LM324’s 1-MHz gain-bandwidth
W in the ET227 transistor with the motor product translates to about 300 kHz
stopped makes no sense as a long-term bandwidth with a voltage gain of about
solution! Obviously, a closed-loop controller 3, so it shows less detail than the 10 MHz
can reduce the current to 0 A when the pedal bandwidth of the Tektronix current probe. I
position calls for 0 RPM, then increase the will probably add a zero-crossing line voltage
current as needed. detector so the firmware can lock the current
With that in mind, Photo 4 shows two samples to the incoming waveform, although
views of the current with the motor running extracting the minimum and maximum
at nearly full speed. The top trace is the values may be a simple matter of software.
current sensing op amp, scaled to 525 mA/
div, derived from the Hall effect sensor in CONTACT RELEASE
the gapped toroid. The bottom trace is a The next step, of course, will be adding
Tektronix Hall effect probe, scaled at 200 sensors to the sewing machine to close
mA/div, clamped around one of the wires in the loop between pedal position and motor
the motor cable. Both traces show about 800 speed. After that, stopping the motor with
mA in the motor and, by fiddling with the the needle either fully up or fully down should
scope trace gain and offset, I can make them be straightforward.
exactly overlay each other. Unlike logic-level projects that can live on
It’s easy enough to hold the sewing a solderless breadboard, this one requires
machine at a constant speed, but lightly building some substantial hardware before
touching the handwheel increases the load you can do anything else. I don’t have a
on the motor, reduces its speed, and can stall complete construction guide, because your
the motor without a corresponding increase components will certainly differ from mine,
in pedal pressure. That’s unlike the behavior but you can download my Kicad schematics
of the original carbon-disk rheostat, which and Arduino firmware from the Circuit Cellar
doesn’t have a tendency to stall at the FTP site as a starting point.
slightest provocation: there’s a distinct
difference between voltage-mode and
current-mode drive for a universal motor!
Photo 5 shows the current increasing
as the pedal moves downward, with a fairly
heavy load applied to the handwheel. The
current reaches nearly 2 A, with the motor
running slower than in Photo 4. The lower
trace scale is now 500 mA/div and you can
62 CIRCUIT CELLAR • JANUARY 2015 #294

GREEN COMPUTING

Adaptive Applications
for Energy Efficiency
COLUMNS

It is possible to design adaptive software applications that can dynamically tune


themselves for meeting performance or power targets. This article demonstrates
that coordinating such application tuning with other system power management
methods significantly improves energy efficiency compared to solutions contained
within solely application or system level.

By Ayse K. Coskun (US)

M ost power management today is


performed “externally” to
applications in computer systems. For
user
application to have the capability to alter a
set of its parameters at runtime in response
to changing system status and constraints.
example, the operating system may monitor This second requirement clearly indicates
the processor usage and initiate a runtime that the software developer should code such
management policy accordingly. Such policies adaptation capability within the application.
typically change the number of active cores
and/or the voltage and frequency setting of ADAPTIVE APPLICATIONS
the processor cores. As another example, In my research lab at Boston University,
many computing systems include controllers in order to create adaptive applications, my
embedded in the processor hardware for students and I used the previously proposed
monitoring temperature or power draw, and PowerDial framework.[1] PowerDial system
then, reduce the voltage and frequency if the first identifies a set of application parameters.
system reaches undesired temperature or It then uses these parameters as a runtime
power values. control knob to adjust the trade-offs between
The way the application software (i.e., performance and accuracy. PowerDial relies
userspace applications) are programmed and on the Application Heartbeats API, which
managed, however, significantly affect the dynamically reports performance and accuracy
performance and power as well. It is indeed at runtime to enable adjusting the application
possible to design the applications such that parameters to meet desired constraints.[2] The
they can “self-adapt” to dynamically changing API also allows users to dynamically input their
power or performance constraints. Dynamic performance and accuracy targets while the
updates to constraints may occur because application is running.
of electricity cost or battery management The application parameters that can
policies, or because of changing user demands be tuned vary depend on the specific
and environmental conditions. application and should be determined by the
Achieving self-adaptive application design programmer. For example, the configuration
requires a framework that can monitor parameter could be how many Monte Carlo
the system and communicate the system simulations are performed per swaption in a
status (e.g., power, temperature, or CPU finance application, which motion estimation
usage statistics) and constraints to the user algorithm is used or the encoding quality in
application. Adaptation also requires the a multimedia application, or the number of
circuitcellar.com 63

results returned in a web search application.


Is it then sufficient to rely on such self-
adaptive applications to tune the software? It
turns out that one can achieve much better
energy efficiency trade-offs by coordinating
application-level adaptation with other
power management mechanisms external to
the application (which I call “system-level”
policies in this article).
Figure 1 demonstrates the potential
benefits of such coordination on a server that
has an AMD Opteron 6172 processor. The
figure shows the power and performance (i.e.,

COLUMNS
seconds spent for processing each frame)
results for the x264 benchmark from the
PARSEC suite for three cases, where we used
adaptive capabilities only at the application-
level (Application Only) using the PowerDial
framework, only at the system-level (System
Only) using hypervisor-level management, VMware ESXi and manages the resource FIGURE 1
and at both application and system level usage of virtual machines (VMs) to maximize Power and performance tradeoff
(Coordinated). Application-level decisions the performance while meeting the power space for various adaptive techniques.
Coordinating application-level and
have limited impact on power consumption of and user-defined application performance
system-level management achieves
this application, but they provide the ability constraints. vCap is designed to closely
better performance (fewer seconds
to adjust the performance for a wide range of follow power constraints and to meet target per frame) for a given power cap.
potential targets. On the other hand, system- performance by utilizing the system-level
level decisions have significant impact on resource usage control knobs (i.e., changing
power consumption, while providing a the CPU resource limits and the number of
narrower performance range compared to the active cores).
adaptive application. Coordinating the system vCap receives both power and performance
and application level adaptability provides feedback and estimates the performance-
the best performance-power trade-off among power trade-offs at runtime to make
these cases. The rest of this article elaborates decisions. Based on the given power and
on how to design such a coordinated power performance constraints, vCap first estimates
management system. the minimum number of active cores that are
required to meet the power constraints and
POWER MANAGEMENT IN THE packs the application’s threads on to a smaller
HYPERVISOR number of virtual cores to reduce the power
There are several mechanisms in computing consumption. vCap then utilizes CPU resource
systems for power and performance limit control knobs in the hypervisor to fine-
management, as I briefly discussed above. tune the performance and power trade-offs.
These include hardware controls (voltage- CPU resource limits are available on most
frequency scaling, clock-gating, etc.), OS- virtualization solutions and essentially limits
level knobs (such as scheduling, allocation, or the CPU time of the VMs through time slicing.
FIGURE 2
initiation of frequency control through Linux
utilities such as cpufreq), and also hypervisor COORDINATED MANAGEMENT Adapt&Cap reads Heartbeat values
and power measurements, and then
controls. In this article, the system-level In my lab, we designed the coordinated chooses the amount of CPU resources
policy mainly refers to performing resource management strategy, Adapt&Cap, on top of required and the best application
management through the hypervisor in a the vCap framework.[4] Adapt&Cap essentially state.
virtualized server. A coordinated management
system, however, can be constructed with Adapt and cap engine

other types of system-level power managers


Check:
as well. Determine best • App. heartbeat
In my November 2013 article, “Application- app. configuration • Power

Aware Power Capping” (Circuit Cellar 280), I Power cap


Compute
Set:
discussed how to bring application-awareness RCAP
• CPU limits
• App. state
into power capping by monitoring hardware
performance counters in native servers or
Heartbeat rate
hypervisor metrics in virtualized servers. VM VM VM
vCap is a dynamic power capping framework Hypervisor
CLIMIT, StateAPP[n]

we designed in my lab for virtualized Power readings


environments.[3] vCap is built on top of
64 CIRCUIT CELLAR • JANUARY 2015 #294

of the application within the code and


3.0
Server with an 8-core Intel Xeon E5-2603 CPU chooses the maximum-performance state
Server with a 12-core AMD Opteron 6172 CPU among these for measurement purposes.
2.5
Based on the measurements at this highest
performance state, it then derives the
2.0
dynamic power consumed per heartbeat,
Normalized
performance
1.5
and the CPU resource used per heartbeat,
assuming that the power and performance
1.0
are linearly correlated.
After deriving the power-performance
0.5
Default App Performance relationship of an application at its best
performing configuration, Adapt&Cap checks
0 the power and performance constraints to
COLUMNS

×264 Bodytrack Swaptions Jacobi adjust the CPU usage limits (C limit) and to
make thread allocation decisions. Climit refers
to the maximum amount of CPU resources
FIGURE 3 extends the capabilities of vCap by taking that will not violate the power constraints.
Performance results for Adapt&Cap advantage of the performance optimization Based on the Climit, one can then derive the
under dynamically changing power capabilities of self-adaptive applications. minimum number of active cores that can
constraints. Adapt&Cap improves the
Figure 2 illustrates the overall flow of the provide enough CPU resources to meet the
performance up to 2.7× under given
Adapt&Cap framework. The framework computed Climit .
power constraints compared to a
system-level policy (i.e., vCap), which
accepts two types of constraints either from Adapt&Cap fine-tunes its decisions using
is shown as the default system in the the user for performance (i.e., heartbeat rate) periodically collected feedback. For example,
figure. or from the system administrator for power if the power tracking error is larger than an
(i.e., power cap). Both power consumption acceptable threshold (e.g., a few watts), then
and the heartbeat rates are then fed to the Adapt&Cap iteratively adjusts C limit . Similarly,
closed-loop controller to adjust and tune its for performance control, Adapt&Cap gets
decisions. the performance requirement as an input,
Adapt&Cap consists of three major and computes the necessary amount of CPU
steps: configuring the adaptive application; resources that will meet the performance
controlling the power consumption; and constraints.
meeting performance constraints. Each
adaptive application (using PowerDial EXPERIMENTS
framework) comes with built-in state tables, In my lab, we implemented the coordinated
which include various combinations of the management scheme discussed above on an
application parameters. As a first step, AMD 12-core Magny Cours (Opteron 6172) and
Adapt&Cap discovers the adaptive states also on an eight-core Intel Xeon E5 (2603).
We virtualized both servers with VMware ESXi
5.1 hypervisor and created VMs with Ubuntu
Server 12.04 guest OS.
As I mentioned above, we utilized the
[2] H. Hoffmann, J. Eastep, M. D. Santam- Application Heartbeats API to measure the
brogio, J. Miller and A. Agarwal, “Application application-specific performance metrics.
Heartbeats: A Generic Interface for Specifying We measured the system power by using
Program Performance and Goals in Autono- a Wattsup PRO power meter with a 1-s
mous Computing Environments,” Proceedings sampling rate. To evaluate the coordinated
of the 7th International Conference on Auto- management technique, we used three self-
circuitcellar.com/ccmaterials nomic Computing (ICAC), 2010. adaptive applications that are generated by
PowerDial[1] (x264, bodytrack, swaptions)
REFERENCES [3] C. Hankendi. S. Reda, A. K. Coskun, “vCap: and one generated by loop perforation
[1] H. Hoffmann, S. Sidiro- Adaptive Power Capping for Virtualized Serv- (Jacobi).
glou, M. Carbin, S. Misailovic, ers,” Proceedings of IEEE International Sym- Figure 3 evaluates Adapt&Cap under
A. Agarwal, and M. Rinard, posium on Low Power Electronics and Design dynamically changing power caps and
“Dynamic Knobs for Respon- (ISLPED), 2013. compares the performance of Adapt&Cap
sive Power-aware Comput- with vCap, which is also an adaptive power
ing,” Proceedings of the Six- [4] C. Hankendi, H. Hoffmann, and A. K. Co- management technique but runs the default
teenth International Confer- skun, “Adapt&Cap: Coordinating System and (non-adaptive) versions of the applications.
ence on Architectural Support Application-level Adaptation for Power Con- For each server, we create separate
for Programming Languages strained Systems.” To appear in IEEE Design & power cap traces, as the power ranges
and Operating Systems (AS- Test, 2015. of these two systems vary significantly.
PLOS), 2010. Coordinating self-adaptive applications with
system-level management in Adapt&Cap
circuitcellar.com 65

improves the performance up to 2.7× when


compared to running the default application
with vCap. Depending on the available ABOUT THE AUTHOR
application configuration parameters
and the underlying hardware platform, Ayse K. Coskun (acoskun@bu.edu) is an assistant
performance improvements show significant professor in the Electrical and Computer
variation. However, Adapt&Cap consistently Engineering Department at Boston University.
outperforms the vCap and provides 1.72× She received MS and PhD degrees in Computer
performance improvements on average. Science and Engineering from the University of
California, San Diego. Coskun’s research interests
IMPROVED EFFICIENCY include temperature and energy management,
With an increasing degree of heterogeneity 3-D stack architectures, computer architecture,
in today’s data centers, it has become and embedded systems. She worked at Sun

COLUMNS
essential to design adaptive systems as Microsystems (now Oracle) in San Diego, CA,
well as self-adaptive applications to meet prior to her current position at BU. Coskun
the power and performance goals. System- serves as an associate editor of the IEEE
level adaptations are necessary to manage Embedded Systems Letters.
the power consumption more effectively,
while application-level adaptations enable
autonomous performance optimization at
runtime. However, the interplay between We implemented Adapt&Cap on two
power and performance motivates designing multicore servers. We saw that unifying
coordinated power management techniques system and application-level adaptability
that integrate both application and system either significantly improves performance
level management mechanisms. for a given power cap or reduces the power
The Adapt&Cap framework my students consumption by over 20% for a given
and I designed in my research lab combines performance target when compared to
application and system-level adaptation solely system-level or application-level
capabilities to improve the energy efficiency. adaptations.

Sign up for the


FREE Circuit Cellar Newsletter!
You’ll receive electrical engineering tips,
interesting electronics projects, embedded
systems industry news, and exclusive product
deals via e-mail to your inbox on a regular
basis. If you’re looking for essential electrical
engineering-related information, we’ve got
you covered: micrcontroller-based projects,
embedded development, programmable
logic, wireless communications,
robotics, analog techniques, embedded
programming, and more!

Subscribe now to stay up-to-date with


our latest content, news, and offers!

circuitcellar.com
66 CIRCUIT CELLAR • JANUARY 2015 #294

FROM THE BENCH

Current Tracking

How to Monitor Current Flow Under


Various Operating Conditions
COLUMNS

Jeff’s motorcycle didn’t come with a gauge or


indicator light for tracking its battery’s status.
Recently, after breaking down on the road, he
set out to build and install a display for monitoring
current flow under various operating conditions.

By Jeff Bachiochi (US)

O perating current can reflect a circuit’s


health. Too much (or too little) circuit
current can indicate problems. Beyond the
Kris, for a jump. After throwing the charger
on the battery, I started thinking about what
had happened. Was it the heat? Old battery?
obvious short- or open-circuit conditions, I believe it was too many starts, with too few
currents can indicate direct ratios, such miles between them, to adequately recharge
as amplifier gain, charging rate, or heat the battery.
production. While many needs can be met by There are no gauges or idiot lights that
measuring unipolar currents, sometimes we would have alerted me to my impending
need to know about currents that can pass in doom. So I decided to look into a display
either direction. This usually comes into play that would enable me to monitor the flow of
when we have some storage device that will be current under various operating conditions.
used to save excess energy and also provide In my search, I found small combination volt/
energy as needed. Keeping track of currents current meters that measured only unipolar
flowing into and out of the storage device can currents, so I dug around in IC inventory
assure that there is always sufficient energy and came up with a Microchip Technology
for the designed task. If we can’t at least put TC7107A dual-slope ADC with integrated
back the amount of energy we use, then the 3.5-digit, seven-segment (or LCD) drivers.
supply will dwindle until the task can’t be It’s been around for years and was designed
supported. for 9-V battery operation. Since I would use
On a particularly hot day this summer, the bike’s battery as the supply, this meant
I decided to tackle an entire list of errands that measurements would need to be within
that had been piling up. And it turned out the common-mode 5-V supply (VCC). An
to be a great excuse to take my ‘85 Honda inverter circuit would create a –5-V supply
VT1100 Shadow motorcycle out for some so that I could in fact measure positive and
cruising. After visits to a post office, a bank, negative currents. The measurement would
and a few stores, the bike’s battery gave up be referenced to battery ground. Figure 1 is
the ghost. Luckily, I was able to call my son, my circuit.
circuitcellar.com 67

The references for TC7107A can be set for That meant that measuring the charging
anywhere between 200 mV to 2 V (full-scale current through the 100-A sensor would be
display of 1999). I used the lower value to lost in the noise, especially if the display must
keep the sensing drop to a minimum. Using use a 200-A (199.9) scale. Thus, it’s best to
a 10-mΩ resistor will drop 200 mV at 20-A separate these two currents. With the way
current. I expected normal currents to be most vehicles are constructed (grounded
considerable less that this. I thought it best frame), I had to do high-side current
to do some experimentation since I couldn’t monitoring. So, I knew the present apporach
find any reference in my bike’s shop manual. I wouldn’t work.
attached this circuit and my multimeter across
the current sense resistor placed between the SIDE BY SIDE
battery’s negative terminal and the frame Low-side (ground) current sensing is
(ground) to measure the drop. When I turned easily accomplished since the common mode

COLUMNS
on the ignition, I read approximately –45 voltage is low around ground. It’s tough to
mV or 9 A. I thought that seemed high, but separate the cranking currents on vehicles
I guess 100 W isn’t unreasonable with three when all the returns go through the frame
headlamps. When I engaged the starter, I saw without running a separate high current
the display peak and the multimeter showed line from the starting motor to the negative
a measurement relating to over 100 A during terminal on the battery. On the high (positive)
the initial cranking, not to mention the smell side, the starter current separates at the
of paint being burnt off my sensor rated for 20 starting solenoid. This is a good point to use
A! Idling current after the engine had started to keep tabs on both currents.
showed a positive charge rate of about 2 A, so To handle the high-side sensing, I used
I know the alternator is operating properly. a Maxim MAX4069 bidirectional high-side
Hmm. To safely withstand the cranking current-sense amplifier and reference. Refer
current, I had to use a 100-A sense resistor. to the block diagram in Figure 2. I chose this

FIGURE 1
The TC7107A used as a high-current, bidirectional, low-side current meter for measuring ±20 A. The derived, negative voltage, inverter allows negative voltages to be measured by
the ground referenced 5-V power supply that starts as 12 V from the bike’s battery. The TC7107A circuit is powered by the motorcycle’s 12-V battery. The circuit uses four single
digit displays. The first is used for its “1” digit and negative sign “-” (3.5 digit display).
68 CIRCUIT CELLAR • JANUARY 2015 #294

20-A current through 0.002 Ω will drop ±40


2.7 to 24 V
mV. After the gain of 50, this will present
Load
a ±2 V offset to the reference. This means
From battery VCC that when no current is flowing, the device
charger RS+ + MAX4069 outputs 2.5 V. This voltage output increases
RSENSE CSA
Out To ADC or decreases depending on the direction
RS−

current flows through the sensor.
Gain select GSEL For high starting currents, the 100-A
+
OA current sensor is used (off of the starting
Shutdown
VREF − REFOUT
R1 solenoid) and we don’t need to worry about
*SHDN 1.23 V
+ ADJ measuring current in both directions. Note
GND R2 that 100 A through the 0.0005-Ω sensor will
drop 50 mV. The gain of 50 brings this up to
COLUMNS

2.50 V. To prevent full scale from encroaching


on the rails of the MAX4069, the reference is
lowered to the minimum 1.23 V. This means
FIGURE 2 device for a few reasons. First, it operates a voltage output of 1.23 V will indicate no
Block diagram of the high-side current with a supply of up to 24 V. The voltage current and an output of 3.75 V (i.e., 1.23 V +
sensor. This Maxim device has a
output can be referenced to a voltage of from 2.50 V) will indicate 100 A.
50/100 times amplifier will output a
1.23 to 4 V. It also has a selectable gain of
voltage referenced to user set point
(between 1.23 and 4.00 V) that will
50 or 100. I can use the same device/circuit MICRO TIME
allow you’re A/D converter to measure to measure both sensors, the 100 A starting Whereas the TC7107A drove individual
currents above and/or below the current through a 0.0005-Ω sensor, and the seven-segment LEDs, I could’ve gotten away
reference. 20-A bidirectional operating/charging current with a much smaller microcontroller if I had
through a 0.002-Ω sensor. used a multiplexed arrangement. While I could
For bidirectional currents the reference have used 32 I/O pins to drive all the segments
voltage is set to 2.5 V. With the GSEL input of four individual displays, I’d had my eye
grounded the internal gain becomes 50. A on a Microchip Technology PIC16F1829LIN

FIGURE 3
Schematic of the MAX4069 high-
side sensor used as the front end of
a conversion and display circuit. The
PIC16F1829 micro used in this circuit
has a 5-V regulator built in and is
used to drive a multiplexed four-digit
LED display. The conversion routine
is designed to display the current
through flowing through a pre-
selected current sensor. A negative
display indicates drawing from the
battery, while a positive display shows
a net charging current.
circuitcellar.com 69

microcontroller, which has only 20-pins, so DAC voltage, the most significant bit (MSB)
I had to go with a quad-multiplexed display, stays a 1; otherwise, it gets changed to a 0, and
the Lumex LDQ-N516. The display required then the next bit is set to a 1. This produces a
only 12-I/Os, but there was a catch. I had to new DAC voltage and the comparison begins
add a transistor to drive each digit’s common. again. This continues 10 times, once for each
It was a small price to pay for reducing the bit of resolution. The final DAC value is used
required resources. as RESULTH:L, the 16-bit result register. The
I drove the segments from the 10-bit value in this register can be configured
PIC16F1829LIN, which has a built-in voltage as the MSB (bits 15:6) or LSB (bits 9:0) of the
regulator. It accepted a supply of 7 to 30 V. register pair.
The regulated 5-V output can be connected to While the values will be between
VDD to operate the core. This eliminates the 0000000000 and 1111111111, these values
need for a separate regulator since we will be will have different meaning depending on

COLUMNS
running the whole circuit from the +12-VDC what we are measuring. When the sensor and
bike battery. Once the display is connected, reference values are installed for measuring
there is but a single I/O leftover, and this will ±20 A, we will need to do some value
be the analog input from the MAX4069 (see manipulation to get a number that makes
Figure 3). sense to display. Photo 1 shows how the
Let’s look first at the A/D converter. This 10- circuit is used for three applications. While
bit converter uses successive approximation special low-value current-sensors are used
to determine an input’s value. The circuit uses with the MAX4069 for measuring currents,
an internal DAC to create a series of reference battery voltage is measured with a simple
voltage guesses starting with 1000000000. If voltage divider without the need for the
the unknown input voltage is greater than the MAX4069.

PHOTO 1
The original prototype circuit (based on the TC7107A) will measure currents with the sensor referenced to the circuit ground (low-side
sensing). A different approach must be taken to measure high-side currents.
70 CIRCUIT CELLAR • JANUARY 2015 #294

Current through Value output 10-bit Binary Decimal Offset Gain Decimal
Sense Resistor by MAX4069 Value from A/D Value (–512) (× 65/10) Point
+20 A 4.00 V B’1100110010’ 818 306 1989 19.89
0A 2.50 V B’1000000000’ 512 0 0 0.00
–20 A 1.00 V B’0011001101’ 205 –307 –1995 –19.95
Current through Value output 10-bit Binary Decimal Offset Gain Decimal
Sense Resistor by MAX4069 Value from A/D Value (–252) (× 195/100) Point
100 A 3.73 V B’1011111100’ 764 512 998 99.80
50 A 2.47 V B’0111111010’ 507 254 496 49.60
0A 1.23 V B’0011111100’ 252 0 0 00.00
COLUMNS

Voltage 10-bit Binary Decimal Offset Gain Decimal


Battery Voltage
Divider Value from A/D Value (n/a) (× 225/100) Point
15 V 3.25 V B’1010011001’ 666 666 1498 14.98
7.5 V 1.62 V B’0101001101’ 333 333 749 7.49
0V 0V B’0000000000’ 0 0 0 00.00

TABLE 1 The TC7107A used individual seven- segment current to 10 mA, then the device
The first set of data shows the
segment LEDs for each of four digits, for a total handling the common cathode current will
conversion of bidirectional operating
of 23 I/Os. The new circuit uses a multiplexed need to handle 80 mA. Most microcontrollers
current to display value in amperes.
The second set of data shows the
array of digits to reduce the number of can handle sourcing 10 mA for the segment
conversion of unidirectional cranking interconnections necessary. Multiplexing is a but not sinking 80 mA, so we need to control
current to display value in amperes. sharing of some common connections. For a the digit’s common anode connection through
The last data set shows the conversion common anode display, the eight LED anodes a transistor beefy enough to handle this
of battery voltage to display value in of each digit (seven segments plus decimal potentially larger current.
volts. point) are internally connected together, one
common anode connection for each digit. Like TIME SHARE
segments (i.e., all the decimal points) from In this case, a “time share” isn’t some
each digit are connected together to form vacation spot you might share with others;
a segment (decimal point) cathode. Driving but the idea is the same. Each of the four
the decimal point cathode high through a digits are assigned a time slot—four digits,
series current limiting resistor will enable the four slots. In round-robin fashion, the four
decimal point of each digit to illuminate when common cathode transistors are turned on
the digit’s common anode is pulled to ground. during their time slots. They get to be on
If each of the four digit anodes are grounded, only a quarter of the time. If each time slot
all four decimal points illuminate. is 1 s, then each digit gets powered for 1 s
That’s fine if we want all decimal points to and then go silent for 3 s. As the slot time
be on. To turn off a decimal point, we must duration decreases, the chase sequence will
remove the ground from that digit’s common sequence faster and faster, until it literally
anode. Since potentially all eight segments becomes a blur. Our persistence of vision
could be on, the total current through a digit’s makes it look like all digits are constantly on.
common anode will be eight times the current The total time period for this magic to happen
of a single segment. If we’ve limited the is approximately 50 Hz.
The application uses a timer to set this
rate. The periodic interrupt routine does two
things. First, it controls each digit’s common
cathode transistor. A digit register holds the
present digit (0–3) that is being enabled. Each
interrupt this register is incremented, which
ABOUT THE AUTHOR directs the program flow to disable the last
Jeff Bachiochi (pronounced BAH-key-AH- digit and enable the new digit. This gives
key ) h a s b e e n w r i t i n g f o r C i rc u i t C e l - each digit a chance to show off its segments.
lar since 1988. His background includes Since each common cathode segment
product design and manufacturing. You has its own driver, a micro output, all like
can reach him at jeff.bachiochi@imagine segments are enabled via a single bit, as
thatnow.com or at www.imaginethatnow.com. are the other seven segments. In the same
fashion, each digit can be enabled by applying
circuitcellar.com 71

a logic high to its sinking transistor’s base


(grounding the digit’s common anode). Four
digit registers hold the current digit value
required for a digit display. A look-up table
translates the digit value 0–9 to a segment
value required to illuminate the appropriate
segments for that digit. The trick is to change
the data on the 8 output bits every time we
change time slots. During time slot 0 (digit 1
is enabled), the data for digit 1 is placed on
the outputs, driving all of the segments on all
digits to that particular data pattern. Since
only digit 1 is enabled at this time, the other

COLUMNS
digit’s segments won’t illuminate this pattern.
In a perfect environment, you would
merely output the digit’s byte to an
output port and all the segments would be
orderly connected to the associated bits.
However, often times, things aren’t so
logically connected (to the point of having
to spread the bits out on different ports).
The PIC16F1829LIN microcontroller has two
6-bit ports. So the digit register can’t be
directly written on a single output port, the PHOTO 2
register must be dissected and the bits used use the 8 × 8 multiply routine to get a 16- Here you see a number of different
to configure separate output ports. Here the bit result. The 16/16 routine is then used to capacity current shunts used in this
segment and digit enables are combined and divide by 10 for a a result from 0–1999. Below project. The SMT circuit was sized to
fit behind the quad digit multiplexed
written to PORTA and PORTC for each time is a maximum input calculation that enables
display (except for some mounting
slot interrupt. you to see how close you can get.
holes). I’ll be using three different
A 10-value look-up table allows a digit value colored displays here if I decide to
(0–9) to be used as an offset into the segment • A/D maximum value for 5-V input = 1,023 mount these locally into the left side
values needed to display digits. There are • 20 A will provide maximum value of 4 V battery cover.
many other seven-segment combinations that • A/D value for 4-V input = 818 (4/5 × 1,023)
might be used besides the digits 0–9. I use • Perform offset calculation: 818 – 512 =
the center of three the horizontal segments 306
for the negative sign. A four-digit bipolar • Perform gain calculation: 306 × 65/10 =
display is limited to ±0–1999, whereas a 1,989
(positive) unipolar display can make use of all
digit segments from 0–9999. Note that 20 A produces a display value of
1,989. If you add a decimal point, the display
FIXED POINT CALCULATION will read 19.89 (amperes). This is pretty darn
I admit it. Floating-point calculations close to 20.00, so you can see that we haven’t
are better handled in C or some higher- lost much accuracy by using two fixed-point
level language. Whenever I need to do some routines and limiting the resolution to an
computations in assembler, I limit this to 8-bit conversion.
simple fixed-point canned routines. Using Why not choose a 16/8 divide routine and
fixed-point routines requires a much smaller save even more? I chose the 16/16 because I
footprint. You can really pare these down to didn’t care that it has to chug a little longer to
practically nothing. For this project, I needed get the result since I knew I’d need a 16/16 in
only two, a multiply two 8-bit values and a the next step. Plus, I thought it better to waste
divide two 16-bit values routines. a little time than add additional routines. It
For bipolar use, the 10-bit A/D input is was a trade-off, but isn’t everything?
referenced to 2.5 V. This makes the MSB of Now that you have a number, you can
its conversion value the polarity indicator. display what you need to convert it into
To get an absolute value once you know the individual digits for the display. Potentially,
polarity, you need to subtract an offset of 512 a 16/16 division could have a 16-bit result.
(half of 1,024). To this offset adjustment, I This could be five decimal digits. You can get
apply a gain of 6.5 (see Table 1). Since I’m these five digits by dividing by 10,000, 1,000,
not dealing with floating-point math, I needed 100, and 10, with the remainder as the fifth
to do some scaling. Multiplying by 6.5 is the digit. As you’ve seen with this application,
same as multiplying by 65 and then dividing you only need four significant digits, so you
by 10. If I limit the offset value to 8 bits, I can can eliminate the divide by 10,000 step.
72 CIRCUIT CELLAR • JANUARY 2015 #294

The resulting four digits are then used in state by the total cell voltage. Published
the look-up table to determine the segment discharge curves will be a good indication
configuration for that particular digit. Then, of battery state. Of course this is based on
when the time interrupt occurs a write of a new battery, not necessarily one that has
the appropriate values to the two ports will been in use for a number of years.
display the calculated result to the measured The initial idea for this project was to be
current. able to keep track of discharge energy vs.
High current shunts are very bulky charge energy. While general operating
as they must be able to withstand great condition can be determined by monitoring
currents without melting down. The photo in these two currents and battery voltage, it
Photo 2 shows my SMT circuit and a number does not give any real running tally of power
of different current shunts I used in this used vs. power returned. To do this we would
project. Note most shunts have four contact need to do some real-time calculations on
COLUMNS

points (two on each side). This allows your the information provided by these sensors.
point of measurement to be unaffected by any While we certainly have the computing power
drop in the high current leads. to handle the task, this may not be the place
to do it. In fact, I would like to extend the
HOUSE OF CARDS? potential of this project (at some later date)
My plan to use 12 outputs to handle the into additional areas. Here are some ideas
display was erroneous. I admit a disastrous that might be worth tossing around.
faux pas, not checking my resources. PortA.3 Two additional headlights were added to
is an input only pin. I actually only have 11 this bike, which I am beginning to believe
outputs to use. When the circuit was wired may be putting a strain on the amount of
with PA3 as a segment driver, that segment current that can be returned to the battery
could not be controlled! Duh. This small newbie (before needing to start the engine again—
mistake threatened the whole project. Luckily, short trips). There are a couple of ways to
there was a clever solution. Since the decimal improve this as a potential issue. First,
point is fixed, its drive can be from the same provide a way to turn these on and off as
output that is driving that digit. This way the needed. (They are wired to be always on, as
decimal point is enabled whenever the digit many headlights are these days.) Second,
is enabled! Did you notice that connection on there is a potential saving in substituting LED
the schematic? lighting for the incandescent bulbs. A second
area of expansion might be to display the on
IT’S ALIVE going current usage in an area better suited
With the current flow divided into two to the operator, as opposed to where its
vastly different circuits, one high-current being measured. This might be some display
short duration and the other lower current added to the handlebars, center console (gas
continuous bidirectional current, we have tank), or heads up display. This might be a
the ability to monitor the starter cranking wireless connection to the helmet.
discharge and operating discharge/charge You may have already gathered from my
currents. With the engine running there selection of micros that this particular micro
ought to be a net return of current (positive) has a built-in LIN driver. LIN is an easy-to-
to the battery to replace energy used to start use, reliable, single-wire bidirectional
the engine. Battery voltage (the third use of connection protocol used for low data rate
this circuit) will add additional information to mechatronic information. While this was first
the equation. This is best analyzed as a state developed for automobiles, it has spread into
of charge when the ignition is on but the industrial environments and remains a cost-
engine has not been started. While this state effective approach to local node connections
has some load (e.g., lights), the alternator that can extend the reach of higher-
is not trying to charge providing a “fake” throughput area networks. This project could
voltage reading. We can estimate battery easily expand using the LIN bus to distribute
control and monitoring of data to all points
of this bike. Like other projects presented
SOURCES here, what is often offered as a possible
MAX4069 Bidirectional amplifiers solution to a specific problem, can morph in
Maxim Integrated | www.maximintegrated.com a totally different direction based on input
from readers. Circuit Cellar offers readers a
PIC16F1829LIN Microcontroller unique ability. I can think of no other
Microchip Technology | www.microchip.com publication where its readers have a more
direct influence in the direction of the
circuitcellar.com/ccmaterials Series 10 editorial content. Let’s continue exploring
Ohmite Mfg. Co. | www.ohmite.com the future together.
circuitcellar.com 73

CC SHOP
Assembly Language Essentials cover4_Opmaak 1 23-2-11 14:32 Pagina 1

Assembly Language

Assembly Language Essentials


Essentials A Guide to Powerful Programming
A Guide to Powerful Programming for Embedded Systems for Embedded Systems

Assembly
You must be a well-rounded professional to excel in the ever-evolving, rapidly developing
embedded design and programming industry. Simply put, when it comes to electronics
design and programming, the more topics you can master, the more you’ll flourish at your
workplace and at your personal workbench. This shouldn’t be a surprise, as the line
between the skills of a hardware engineer and software engineer is blurring. The former

Language
should have a good grasp of programming in order to build efficient systems. The latter
should understand the details of the design (whether it’s a physical or virtual application)
for which he or she is writing code. Thus, to be successful, a modern professional
electronics engineer must have a solid grasp of both hardware design and programming.

1 CC VAULT
Assembly Language Essentials is a matter-of-fact guide to Assembly that will introduce you
to the most fundamental programming language of a processor. Unlike other resources

Essentials
about Assembly that focus exclusively on specific processors and platforms, this book uses
the architecture of a fictional processor with its own hardware and instruction set. This
CC Vault is a pocket-sized USB that
enables you to consider the importance of Assembly language without having to deal with
predetermined hardware or architectural restrictions.

comes fully loaded with every issue of


You’ll immediately find this thorough introduction to Assembly to be a valuable resource,

Larry Cicchinelli
whether you know nothing about the language or you have used it before. The only

Circuit Cellar magazine! This compre-


prerequisite is that you have a working knowledge of at least one higher-level programming
language, such as C or Java.
Larry Cicchinelli
hensive archive provides an unparalleled
Assembly Language Essentials is an indispensible resource for electronics engineering
professionals, academics, and advanced students looking to enhance their programming
skills. The book provides the following, and more:

amount of embedded hardware and


• An introduction to Assembly language and its functionality

software design tips, schematics, and


• Significant definitions associated with Assembly language, as well as essential
terminology pertaining to higher-level programming languages and computer
architecture
1 source code. CC Vault contains all the
• Important algorithms that may be built into high-level languages, but must be done
the “hard way” in Assembly language — multiplication, division, and polynomial
evaluation
trade secrets you need to become a bet-
• A presentation of Interrupt Service Routines with examples
• A free, downloadable Assembler program for experimenting with Assembly

ter, more educated electronics engineer! 7


Circuit Cellar, Inc.

Item #: CCVAULT
www.circuitcellar.com
4

2 CC 2013 CD 4 ASSEMBLY LANGUAGE


2013 was an exciting year for
ESSENTIALS
electronics engineers! The continued Looking to brush up your program-
success of open-source solutions, ming skills? Get back to to the basics
Internet of Things (IoT) revolutions, with this matter-of-fact guide to As-
and green-energy consciousness has sembly language. Perfect for advanc-
changed the face of embedded design ing students and academics, this book
indefinitely. In Circuit Cellar’s 2013 introduces you to a processor’s most
archive CD, you can find all of these fundamental programming language.
hot topics and gain insight into how It includes essential terminology per-
experts, as well as your peers, are taining to higher-level programming,
putting the newest technologies to the important algorithms that can be built
test. You’ll have access to all articles, into high-level language, a free down-
schematics, and source code published loadable Assembler program, and
2 from January to December 2013. much more.

Item #: CD-018-CC2013 Author: Larry Cicchinelli

3 MICROPROCESSOR
DESIGN USING VERILOG HDL
After years of experience, Monte
Dalrymple has compiled his knowledge
of designing embedded architecture
and microprocessors into one
comprehensive guide for electronics
engineers. Microprocessor Design
Using Verilog HDL provides you with
microarchitecture, writing in Verilog,
Verilog HDL review, and coding style
that enables you to depict, simulate,
and synthesize an electronic design on
your own.

Author: Monte Dalrymple


Item #: CC-BK-9780963013354
3
74 CIRCUIT CELLAR • JANUARY 2015 #294

CC SHOP

ADVANCED CONTROL
ADVANCED CONTROL ROBOTICS HANNO SANDER

ROBOTICS HANNO SANDER

PARALLAX PROPELLER

6 ADUC841 MICROCONTROLLER DESIGN


5
MANUAL
This book presents a comprehensive guide to design-
ing and programming with the Analog Devices ADuC841
microcontroller and other microcontrollers in the 8051
5 ADVANCED CONTROL ROBOTICS—NEW! family. It includes a set of introductory labs that detail
When it comes to robotics, the future is now! This how to use these microcontrollers’ most standard fea-
book simplifies the theory and best practices of advanced tures, and includes a set of more advanced labs, many
robot technologies by providing insight to communication of which make use of features available only on the
technologies, control robotics, embedded technology, ADuC841 microcontroller.
programming, and more. Complete with code samples, The more advanced labs include several projects that
schematics, and design tips. Great reading for beginners introduce you to ADCs, DACs, and their applications.
and experts alike. Other projects demonstrate some of the many ways you
can use a microcontroller to solve practical problems.
Author: Hanno Sander The Keil μVision4 IDE is introduced early on, and it is
Item#BK-ELNL-978-0-963013-33-0 used throughout the book. This book is perfect for a
university classroom setting or for independent study.

PROGRAMMABLE LOGIC
DECEMBER 2013
Author: Shlomo Engelberg
Item #: CC-BK-9780963013347
ISSUE 281

circuitcellar.com
CIRCUIT CELLAR | ISSUE

URE?WITH FPGAs
281 | DECEMBER 2013

RECONFIG
READY TOTIPS ENTLY
FOR WORKING CONFID Ethernet on an FPGA, &
More
Hardware Co-Simulation,

7 CIRCUIT CELLAR ISSUE


CIRCUIT

circuitcellar.c
om
CELLAR |

ANALOG TECHN
IQUES
NOVEMBER

PDFs
2013
ISSUE 280

ISSUE 280
| NOVEMB

NG
ESSI 13
ER

EFFECTI
PROC R 20 9
2013

AL BE 27
SIGN OCTO ISSUE

V
CIRCUIT E ANALOG Have you ever missed an issue of
TECHNIQ Remote data
UES gathering &
control
Circuit Cellar and didn’t know where
circ
uitc
ella
r.com
k in
side re
Loo hardw
a to find it? Grab a digital version!
g

IC
run
nin
From 1998 to the present, dive into
OG S
D L OOL more than 100 issues of embedded
Specialist
CIRC

ns | Q&A: Smart-Camera
E Further information and ordering
UIT

SoC and IoT Predictio

AT T Technologies
CELL

ng A/D Values | New Memory

GR ER
UDP Streaming | Converti
AR

n| HCS Testing |

electronics insights that you may have


| IS

circuitcellar.co m

| Embedded File Protectio

TE LYZ
SU

Impedance Matching
E 27

Host IC SBCs and STEM


son | USB Android
9|

Amplifier Class Compari


IN ANA
www.cc-webshop.com
OC
TO
BE

missed. Can you envision the evolution


R 20
13

full-duplex
data + powe
r system
and development across a decade? CONTACT US:
Innovative
With technology advancing every day, Circuit Cellar, Inc.
ns
circuit cellar.c

EE Worksp

don’t fall behind. Learn about wearable


aces | Q&A
esig 111 Founders Plaza, Suite 300
ADC & DAC : An Enginee
Calibration
Ad
| Duplex Sign r and His
Power Cap “Idea Lab
FPG
ping | Batt aling | Sola ”
om

ery Manage r Array Soft list


ment ICs | g war
ia
ggin
pec keer
wireless transceivers from Mathew East Hartford, CT 06108
Robotic Plat Hall-Effect
Sensor STest
ebu
form Tran
slation M-to
-M rac| |
ing
yT
or d A: “Na rra
tura er
r A l”CHCI harg ng
ds f
| Q& o la y ti
nt er

Laibowitz and Joseph Paradiso or a


|S rin

e dm
e tho
e s tE
g T | Rob
me
o t
xes
quip Refle | DIY
e r
Batt etal P
u id
M USA
anc
iq
yin m plifi 3-D L
adv
DIY single-board computer (SBC) from
u io A
Phone: 860.289.0800
rB Au
d JT s
s fo er |B tem
Tip ess As S ys
roc sing IL File
rop U sh
Mic Fla

E m bed
ded
Oscar Vermeulen and Andrew Lynch. Fax: 860.461.0450
78 The topics and projects are endless. E-mail: custservice@circuitcellar.com
cir
cu
itc
el la
r.c
om
circuitcellar.com 75

IDEA BOX the directory of


PRODUCTS & SERVICES

AD FORMAT: The Vendor Directory at


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

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

Connect
with engineers 4-20HR-MaxSonar®-WR™
seeking your - 4-20mA output
- High noise tolerance

design solutions. - IP67 rated


- 1.6 mm resolution
- Multi-Sensor operation
- Calibrated beam pattern
- 8Hz read rate
Magazine, e-newsletters, - End user solution
- Ideal for industrial use
website, advertorials, and more.
ReseRve adveRtising UCXL-MaxSonar®-WR™
- Great for design engineers
space today! - Multiple mounting options
- Light weight industrial sensor
Strategic Media Marketing, LLC - Incredible noise immunity

978.281.7708
- Smallest IP67 sensor in size
- 1cm resolution
- Automatic calibration
- Ideal for outdoor UAV use

circuitcellar@smmarketing.us Phone: 218-454-0766 Email: sales@maxbotix.com


www.smmarketing.us www.maxbotix.com

Stream Data
with an ICD & CCS C Compiler
for PIC® MCU Devices
- Eliminate a diagnostic serial port
& save money by streaming data
through the ICSP™ interface
- Fast and easy debugging
- Set the Serial #’s & Calibration
values in production

Download a FREE
Full Demo Today
www.ccsinfo.com/CC115
sales@ccsinfo.com
262-522-6500 x 35
PIC® MCU is a registered trademark of Microchip Technology Inc.

January_Data Stream Option 1.indd 1 11/14/2014 12:48:33 PM


76 CIRCUIT CELLAR • JANUARY 2015 #294

Join The

DIO24
DIO24--ARD
Digital Interface
for Arduino and Compatibles
▪ 24 Programmable Input/Output Channels
▪ Connect I/O Racks, LEDs, Switches, and More
▪ 85ma Sink Output Capability
▪ Uses Standard SPI Software Library Functions
▪ Jumper Selectable and Off-Board SPI Enable
▪ Long Lead Stack-Through Connectors
▪ Industrial Operating Temperature Range
▪ RoHS Compliant
Learn More Details at . . .
Call Toll-Free
1-877-SCIDYNE
(1-877-724-3963)

TRi
$20 for 5PCBs Programmable Logic Controllers
Powerful & Easy Ladder
2 layer,4x4inch, FR4(RoHS),0.063”,1oz, +BASIC Programming
2LPI,Green,1SK,Lead free HASL Ethernet integrated
Standard PCB: Promotion code: MODBUS TCP/IP
DI/Os & AI/Os integrated
CC14061
OEM Prices as low as $119
PCB & PCBA for full-feature Nano-10 PLC

tel : 1 877 TRI-PLCS


Small to Mass QTY web : www.triplc.com/cci.htm

INSTANT QUOTE AT:


TRIANGLE
www.myropcb.com RESEARCH
INTERNATIONAL
OR CALL:
1-888-PCB-MYRO

microEngineering Labs, Inc.


www.melabs.com 888-316-1753
Programmers for Microchip PIC® Microcontrollers
PC-Tethered USB Model (shown):
•Standalone software
•Command-line operation
•Hide GUI for automated use
•Override configuration with drop-downs
Stand-Alone Field Programmer:
•Power from target device or adapter
•Program file stored on SD-CARD
•Programming options stored in file
•Single-button operation
Starting at $79.95

Program in-circuit or use adapters for unmounted chips.


Zero-Insertion-Force Adapters available for DIP, SOIC, SSOP, TQFP, and more.
PIC is a registered trademark of Microchip Technology Inc. in the USA and other countries.
circuitcellar.com 77

What’s your EQ? The answers are posted at www.circuitcellar.com/


category/test-your-eq/. You can contact the quizmasters at
eq@circuitcellar.com.

TEST YOUR EQ
Contributed by David Tweed

PROBLEM 1 spacing, the capacitor has twice the


Let’s get back to basics and talk about the energy that it had to start with. Where
operation of a capacitor. Suppose you have did the extra energy come from?
two large, flat plates that are close to each
other (with respect to their diameter). If you PROBLEM 3
charge them up to a given voltage, and then What happens when a dielectric is
physically move the plates away from each placed in an electric field? Why does the
other, what happens to the voltage? What capacitance of pair of plates increase
happens to the strength of the electric field when the space between them is filled
between them? with a dielectric?

PROBLEM 2 PROBLEM 4
If you double the spacing between the plates What is the piezoelectric effect?
of a charged capacitor, the capacitance is cut
in half, and the voltage is doubled. However,
the energy stored in the capacitor is defined
to be E = 0.5CV 2. This means that at the wider

TESTS & CHALLENGES


Sign up today and SAVE 50% • Sign

Now offering student


SUBSCRIPTIONS!
When textbooks just aren’t enough, supplement
your study supplies with a subscription to Circuit
Cellar. From programming to soldering, robotics
to Internet and connectivity, Circuit Cellar delivers
the critical analysis you require to thrive and excel
in your electronics engineering courses.

www.circuitcellar.com/subscription
78 CIRCUIT CELLAR • JANUARY 2015 #294

CROSSWORD JANUARY 2015


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

2 3 4

5 6 7

8 9

10 11 12

13
TESTS & CHALLENGES

14 15

16 17

18 19

EclipseCrossword.com

ACROSS DOWN
1. Conductive cover that isolates equipment from electromagnetic 1. A filter for removing spurious noise from a power
interference supply
2. Small potentiometer for making predetermined modifications in a 4. “X”
circuit 6. Small energy source that has no effect on its directivity
3. A nonet is a grouping of what? 9. Component that bypasses another component
5. A device that prevents signal peaks from exceeding max levels 10. Semiconductor material used in solid-state diodes and
7. One cycle per second. photocells
8. Dual inline package 11. Suppress resonance
13. QC 12. 10 micronewtons
14. Non-working model of a system 15. 0.01 bar
16. 1 quadrillion bytes 17. 10–7 joules
18. Reroute a signal to a different circuit
19. Electromagnetic signals with frequency > 70 kHz
circuitcellar.com 79

The Future of Electrical Engineering


The Circuit Cellar staff thought it would be interesting to

kick off 2015 by asking serveral long-time contributors

about the future of electrical engineering and embedded

systems. Here we present the responses we received

to the following questions: What are your thoughts on

the future of electrical engineering? What excites you? Is

there something in your particular field of interest that

you think will be a “game changer”?

STEVE CIARCIA: Frankly speaking, if I was smart enough to accurately predict the future, I wouldn’t be doing

TECH THE FUTURE


all this again. ;-) Seriously, “What excites me in the future?” shouldn’t be the question I’m answering here.
Instead, it should be how much does all this embedded stuff we’re seeing and talking about today look like a
classic case of déją vu to me. Circuit Cellar started 40 years ago in BYTE to promote my enthusiasm for pro-
fessional-level DIY computer applications (albeit mostly embedded). The names have changed to Maker this
and that and Raspberry Pi whatever, but what once was, still is. Solder fumes aside, Circuit Cellar has always
been about nurturing the talented engineer who designs the game changer. (Steve is an electrical engineer
who founded Circuit Cellar in 1988.)

DAVID TWEED: Embedded technology is becoming more pervasive, appearing in more and more places in our
lives. Embedded processors have become as powerful as desktop machines were just a few short years ago,
and the their ability to connect to the world at large through high-bandwidth wireless communications has
grown to match this. This is both exciting and scary, because it becomes a powerful enabler for both posi-
tive and negative changes in how we live our lives. Take the ubiquitous “smart phone” as an example. It can
process two-way audio, video, GPS data, and an Internet connection simultaneously in real time. This enables
powerful applications such as GPS-based route finding that can give you verbal and pictorial directions to get
you where you want to go. But, as anyone who watches the popular crime drama N.C.I.S. knows, that same
technology can be used to track your phone’s location, along with everything it can “see” and “hear,” including
the phone calls you have made. While that kind of surveillance can be used it positive ways, such as to aid
you in an emergency, it can also be used to invade your privacy. Can you really be sure that everyone in law
enforcement and other areas of government has only your best interests in mind when accessing your data?
The increased power of embedded systems means that autonomous mechanisms gain capabilities they didn’t
have before. Fully-autonomous vehicles—cars, trucks, trains, and aircraft—will be able to carry people and
goods long distances over arbitrary routes. Factory automation will become more generic, because complex
general-purpose mechanisms will be as easy to use as purpose-built mechanisms that only do one thing,
because the software will manage all of the low-level details of “training” the system. Machine vision will be
an important part of this, giving the system the feedback it needs to interact with objects and people. “With
great power comes great responsibility.” This has never been more true. I’m excited by the possibilities that
increasingly powerful embedded technology will open up for us, but let’s make sure that it is used responsibly!
(David is a professional electrical engineer and long-time Circuit Cellar author and technical editor.)

ROBERT LACOSTE: I think the most significant change in embedded systems these last years is the nearly
mandatory inclusion of Internet connectivity. It’s called the Internet of Things (IoT). Just enter those three
words in Google and the 752 million results you get will show it’s a quite hot topic. When a customer meets
with us to discuss a potential new product (whatever it is), the question is no longer: “Should it be connected?”
The question is: “How should it be connected?” Having said that, the key difficulty is the long list of wireless
protocols trying to become the ubiquitous solution for IoT: Wi-Fi, Bluetooth, Bluetooth Low Energy, ZigBee,
Zwave, 6LowPan, and a hundred others. Bluetooth seems the clear winner for smartphone-based products,
but what about the other applications like home automation, logistics, smart metering, or dog tracking? Which
protocol(s) will be the winner(s)? Which one will be natively supported on our Internet access gateways or even
80 CIRCUIT CELLAR • JANUARY 2015 #294

rolled-out worldwide? Will it be Thread, sponsored by Google itself? Or will it be another derivative of Blue-
tooth, due to its huge predominance? (The overall sales of Bluetooth-capable chips already exceed four times
the human population on earth.) Or could it be one of the machine-to-machine variants of 3G/4G cellular stan-
dards being studied? Or perhaps it will be one of the solutions proposed by one of the many startups working
on the technology? Or maybe it will be a completely new protocol that we’ll invent? I don’t know the answer,
but the result will be the next game changer! (Robert is an electrical engineer and Circuit Cellar columnist. In
2003, he founded ALCIOM, an electrical engineering firm near Paris, France.)

CHRIS COULSTON: While tech will companies continue to evolve


existing technologies to offer more features, with lower power
and at a lower cost, I think that the most exciting and revolu-
tionary technology is to be found in the Internet of Everything
(IOE) concept. Hardware supporting the IOE offers up the tanta-
lizing potential to free our designs from physical interconnects,
giving our designs world wide access, allowing us to interact
with our designs in real time, and allowing our design to access
the almost unlimited diversity of services available on the In-
ternet. I am excited to explore a design space that enables me
to connect something trivial like my key-ring to the Internet.
The Raspberry Pi was the first breakthrough with companies
like Intel redefining the cutting edge with their Edison module.
There are several limiters to the IOE concept including power
consumption and standardization. As these issues are addressed, the potential of the IOE concept will only be
limited to the creativity of engineers and makers everywhere. (Chris is a professor of electrical and computer
engineering at Penn State, Behrend. He’s also technical reviewer for Circuit Cellar.)
TECH THE FUTURE

GEORGE NOVACEK: Embedded controllers are essential components of automatic systems. Without automa-
tion, many products could not even be manufactured. Machines, such as aircraft, medical equipment, power
generators, etc. could not be operated without the assistance of smart control systems. Until some, not yet
invented, technology makes electronics obsolete, the future of embedded controllers will remain bright. In the
coming years, more and more engineers will be focusing on system design, while only the brightest ones will
be developing microelectronic components for those systems—more sophisticated, more integrated, faster,
smaller, hardened to environment, consuming less power. There continues to be a trend towards universal
embedded controllers. These, equipped with the appropriate sensors and actuators and loaded with a partic-
ular application software, could be used for fly-by-wire, or for control of an industrial machinery or just about
everything else. Design engineers need to be cautious not to put powerful, yet inexpensive controllers into new
products just because it can be done. There is already a proliferation of simple consumer products equipped,
without any sensible need, with microcontrollers. This often leads to lower reliability, shorter life and, because
these products are usually not repairable, to greater cost of ownership and waste. (George is professional
engineer and Circuit Cellar columnist who served as president of a multinational manufacturer of embedded
control systems for aerospace applications.)

ED NISLEY: The rise of the Maker Movement changes everything in the embedded systems field: Makers take
control over the devices in their lives, generally by repurposing embedded hardware in ways its designers nev-
er intended. The trend becomes clear when dirt-cheap USB TV tuners become software defined radios. Embed-
ded systems must eventually sprout exposed (and documented!) interfaces, debugging hooks, and protocols,
because collaboration with Makers who want to turn the box inside-out and build something better can enrich
our world beyond measure. Excluding those people won’t work over the long term: just as DRM-encumbered
music became unacceptable, welded-shut embedded systems will become historic curiosities. You can make it
so! (Ed is an electrical engineer and long-time Circuit Cellar columnist and contributor.)

KEN DAVIDSON: Twenty-five years ago, while developing the Circuit Cellar Home Control System (HCS) II, our
group created a series of interface boards that could be placed around the house and communicate using
RS-485. Tons of discrete wire running throughout buildings was the norm at the time, and the idea of running
just a single twisted pair between units was novel and exciting. This all predated inexpensive Ethernet and
public Internet. Today, such distributed intelligence has only gotten better, smaller, and cheaper. With the
Internet of Things (IoT) everybody is talking about, it’s not unusual to find a wireless interface and embed-
ded intelligence right down to the level of a light bulb. There was an episode of The Big Bang Theory where
the guys set up the apartment lights so they could be controlled from anywhere in the world. Everyone got
a laugh when the “geeks” were excited when someone from Japan was blinking their lights. But the idea
of such embedded intelligence and remote access continuing to evolve and improve truly is exciting. I look
forward to the day in the not-too-distant future when such control is commonplace to most people and not
just a geeky novelty. (Ken is an embedded software engineer who has been contributing to Circuit Cellar for
years as an author and editor.)
When it
comes to
robotics,
the future
is now!
From home control systems to
animatronic toys to unmanned
rovers, it’s an exciting time to
be a roboticist. Advanced Control Robotics
simplifies the theory and best practices of
advanced robot technologies, making
it ideal reading for beginners and experts
alike. You’ll gain superior knowledge of
embedded design theory by way of
handy code samples, essential schematics,
and valuable design tips.

With this book, you’ll learn about:


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

Get it today at ccwebshop.com.


We bring the full range of Electronic Contract
Manufacturing services to your fingertip!

FABRICATION ASSEMBLY KEYPADS

ENCLOSURES

This is the only place where you would put all


your eggs in one basket to get fastest time to
market. From concept design to prototype to
full turnkey production on all your
electronic products.

Imagineering

Winner
Family Enterpreneurship
Award 2014

www.PCBnet.com
847-806-0003 sales@PCBnet.com
Certified Woman-Owned Small Business

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy