Circuit Cellar #294 2015 01
Circuit Cellar #294 2015 01
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
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
DISCLAIMER
OUR NETWORK
SUPPORTING COMPANIES
Accutrace 7 Jeffery Kerr, LLC 75
EMBEDDED
APPLICATIONS
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
CONTENTS
62 : GREEN COMPUTING
Adaptive Applications for Energy Efficiency
By Ayse K. Coskun
Power management with adaptive software
applications that can dynamically tune themselves
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!
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
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
PRODUCT NEWS
PRODUCT NEWS
PRODUCT NEWS
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
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
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
RS485/422/232/TTL
ASC24T IBS485HV
RS232<=>RS485 ATE Converter 5 Port Isolated
RS485 Repeater
$349.00
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
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.
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,
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
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
Pricing starts at
$168 $129
Qty 100 Qty 1
Series start at
$369
Qty 100
$409
Qty 1
TS-TPC-8390-4800 Rear View TS-TPC-8390-4800 Angled View Guaranteed available until 2025
L
D
NA
N
LI
E
GG
PE
GI
RI
RU
LO
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.
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
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
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
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 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
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
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
$134
Qty 1
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
L
D
NA
N
LI
E
GG
PE
GI
RI
RU
LO
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
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)
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
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.
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
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.
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
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.
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
SOFTWARE
The source code for the duodecimal clock,
FEATURES
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.
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.
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.
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
Essential Electromagnetic
Compliance (Part 2)
COLUMNS
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
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
Brute-Force
Universal
Motor Control
COLUMNS
By Ed Nisley (US)
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
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.
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
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
×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
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.
circuitcellar.com
66 CIRCUIT CELLAR • JANUARY 2015 #294
Current Tracking
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
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
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
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
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.
Larry Cicchinelli
whether you know nothing about the language or you have used it before. The only
Item #: CCVAULT
www.circuitcellar.com
4
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.
CC SHOP
ADVANCED CONTROL
ADVANCED CONTROL ROBOTICS HANNO SANDER
PARALLAX PROPELLER
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,
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
AT T Technologies
CELL
GR ER
UDP Streaming | Converti
AR
n| HCS Testing |
circuitcellar.co m
TE LYZ
SU
Impedance Matching
E 27
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
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
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
978.281.7708
- Smallest IP67 sensor in size
- 1cm resolution
- Automatic calibration
- Ideal for outdoor UAV use
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.
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
TEST YOUR EQ
Contributed by David Tweed
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
www.circuitcellar.com/subscription
78 CIRCUIT CELLAR • JANUARY 2015 #294
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
STEVE CIARCIA: Frankly speaking, if I was smart enough to accurately predict the future, I wouldn’t be doing
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.)
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.
ENCLOSURES
Imagineering
Winner
Family Enterpreneurship
Award 2014
www.PCBnet.com
847-806-0003 sales@PCBnet.com
Certified Woman-Owned Small Business