每一个工程师都明白项目并不总是按照计划进行的。Ed的目标是建立一个数据收集电路板,它能够自动测绘一块太阳能板,在几天的过程中记录这块板的输出,然后把结果和他手动收集的数据作比较。不幸的是,他遇到了一些问题。请您阅读本文,来了解为什么你应该一直有一块大小合适的电路板。
PCB Layout, Inductor Saturation, and Other Troubles
Every engineer knows projects don’t always work out as planned.
Ed’s goal was to build a data collection board that could
automatically characterize a solar panel, record the panel’s output
over the course of several days, and then compare the results to
his manually collected data. Unfortunately, he experienced some
problems. Read on to learn why you should always have a
proper-sized board.
Steve Ciarcia’s fundamental requirement for my columns, right from
the first issue, has always been that the projects must work. If I
didn’t build it and verify the results, I couldn’t write about it.
With that in mind, the plan for this column started simply enough:
build a data collection board that could automatically characterize
a solar panel, record the panel’s output over the course of several
days, then compare the results to my manually collected data. Along
the way, I would describe the analog circuit problems that come
with low-level measurements near digital circuitry.
As Publius Syrus put it back in the day, “Homo semper aliud,
fortuna aliud cogitat,” which my atrophied Latin translates as “Man
always has intentions, but Fortune intends otherwise.” The Yiddish
equivalent has more punch: “If you want to make God laugh, tell Him
your plans.”
Basically, the board I designed not only didn’t work, it resisted
some protracted debugging. Rather than bluff my way through, I’ll
begin by describing what I wanted to accomplish, then explore what
went wrong. You’ll certainly learn something along the way; perhaps
what you shouldn’t do in similar circumstances.
In my next column, you’ll see how to get it right. Honest, Steve!
THE BIG PICTUREAs you saw in my February 2009 column, characterizing a solar panel
requires measuring the panel’s voltage while applying a known load
(“Solar Measurements,” Circuit Cellar 223). My manual measurements
used voltmeters, ammeters, and a pair of old potentiometers,
so automating the process requires putting those functions on a
circuit board under computer control.
Figure 1—As with most analog circuits, getting anything done requires plenty
of parts. The boost circuitry on the left runs the panel at its
optimum current, while the current sink on the right dissipates the
collected power as heat in the load transistor. The Arduino
microcontroller, represented by the four connectors at the top,
provides PWM voltage setpoints to control the booster and load,
then reads analog data from the sensors. This circuitry does not
match that shown in Photo 1 for reasons described in the text.
To that end, the schematic in Figure 1 has three main sections: a
microcontroller interface, a constant-current load, and a
boost-mode switching converter. Careful inspection of the small
circuit board clamped in Photo 1 shows that the board, an early
prototype, doesn’t quite match the schematic.
Photo 1—The solar data collector fits atop an Arduino Diecimila
microcontroller board. The spillover on the solderless breadboard
shows that not everything works correctly the first time.
The PC board plugs directly atop an Arduino Diecimila
microcontroller board through a quartet of pin strips. The
Diecimila features an Atmel ATmega168 microcontroller with digital
and analog I/O, a regulated power supply, and a USB serial
interface to a host PC. The open-source Arduino IDE runs on both
Windows and Linux, with support for several different boards and
chips.
The two op-amps on the right side of the schematic form a
voltage-to-current converter that acts as a variable load for the
solar panel. The current through Q2, a Darlington power transistor,
matches the voltage produced by the ATmega168, with an overall gain
of 100 mA per volt. R12A and R12B, which form a 0.5-Ω
current-sensing resistor, set that gain along with the 20:1 voltage
gain in U4. U3 forces Q2 to sink enough panel current to make the
feedback voltage match the control input voltage.
My panels can produce, at most, a few hundred milliamps in full
sunlight and, with a peak power output around 1 W, that power
transistor won’t get very hot at all. Characterizing a larger panel
would require a far more robust active load, which I’ll leave as an
exercise for the interested reader.
The Arduino board runs with VCC = 5 V and its ADC inputs must not
exceed that level, so the resistor pair R18-R19 presents 25% of the
panel voltage to the microcontroller. The R16-R17 pair does the
same thing to the transistor ’s collector voltage. The open-circuit
voltage of both my panels is under 10 V, but the booster circuit
described below can reach nearly 20 V, so some headroom is in
order.
Characterizing the panel requires applying a series of load
currents and measuring the resulting panel voltages. This circuit
can ’t quite produce a true shortcircuit load, because the voltage
drop across D1, plus Q2 ’s saturation voltage,plus the voltage
across the current-sensing resistors, adds up to about a volt, but
there ’s a way around that.
As you saw in December, the power drawn from a solar panel depends
on the incident illumination and the load current. One specific
current extracts the maximum power from the panel for a given
illumination level: drawing a higher or lower current produces less
power. Because solar power is so hard to come by, there’s a strong
motivation to always run the panel at its Maximum Power Point.
The standard solution requires a DC/DC converter drawing whatever
current will produce the maximum power at whatever voltage the
panel supports, while producing a more-or-less constant output
voltage. That “raw DC” feeds the application circuit’s power
supply, much as line voltage feeds an ordinary PC.
For example, an 80-W solar panel might produce 4.5 A at 18 V in
full sunlight. That current will decrease as the illumination
changes, so the MPP controller must adjust the current going into
the DC-to-DC converter, while maintaining a constant output voltage
by tweaking the duty cycle. That requires monitoring the actual
panel current and output voltage while adjusting the switching
levels, a process known as MPP tracking.
The simple boost-mode converter circuitry on the left side of
Figure 1 can do exactly that, albeit on a small scale and with
relatively low efficiency. Transistor Q1 switches current through
inductor L1 and then dumps it into C3 through D1. The Maxim
Integrated Products MAX4372T high-side current amplifier has a gain
of 20 to produce
1 V/100 mA of panel current, the pair of comparators in U2 set the
high and low current limits, and a simple R-S flipflop built from
the NAND gates in IC 1 turns Q1 on when the current falls below the
minimum and off when it exceeds the maximum.
The firmware can read the panel voltage and current through the
microcontroller’s analog inputs, compute the corresponding power,
then set the high- and low-current limits to bracket the MPP and
regulate the output voltage. As you might expect, there are all
manner of patented MPP tracking schemes.
It’s worth mentioning that MPP tracking can’t produce something
from nothing. A load that exceeds the solar input power will draw
down the boosted DC supply from the panel, simply because there’s
not enough power available to support the output. The load must be
smart enough to adapt itself to varying power inputs: full power in
full sun, reduced power on overcast days, and sleep mode overnight.
Boost-mode converters have an obvious failure mode that’s often not
obvious until the smoke appears. Notice what happens should Q1 stay
on for a protracted time: a high-power solar panel will roast
R14A-B, L1, and probably Q1. A real-life implementation must
include an interlock that holds Q1 off until the firmware gains
control and sets the appropriate current limits, but I’ll leave
that as another exercise for the interested reader.
Pop Quiz: design such an interlock. Hint: a charge pump from a
program-toggled bit may be helpful.
However, the firmware can turn Q1 on, measure the panel’s
short-circuit current, then turn Q1 off before the smoke appears,
particularly for the low-power panels in my collection.
So that was the plan: characterize the panel using the current
sink, warm up Q2 by running the panel at its MPP, and dump its
measurements through the USB serial port to the host PC. What could
possibly go wrong?
CURRENT SINKHOLEThe single biggest mistake I made was attempting to squeeze
everything into the same board footprint as the underlying
Diecimila microcontroller. That size works perfectly well for
digital projects, as shown by the many Arduino “shields,” but poses
problems for two-layer analog circuit boards. As you can see in
Photo 1, the hulking inductor really takes over the board and
forces the remaining parts away from their microcontroller
connections.
The natural layout put the solar panel input (at the blue terminal
block) on one end of the board and the current-sink transistor on
the other, forcing return current from R14A-B to travel the length
of the board past all of the op-amps and comparators. Although I
poured a copper ground plane into all the unused areas and stitched
the top and bottom planes together, the effective resistance was
high enough to induce offset and feedback voltages where they did
the most damage.
I added a husky 16-AWG shunt wire directly from the resistors to
the terminal block that somewhat reduced the problem. Despite that,
I simply couldn’t stabilize the currentsink op-amps, which
continued to oscillate regardless of their compensation. I finally
switched to LM324 op-amps, which have a much lower gain-bandwidth
product, and moved the whole assembly to a solderless breadboard.
Surprisingly, it worked fine, regardless of my usual dislike of
that method of construction.
Figure 2—The upper trace shows the voltage at the top of R29/R30, the 0.5-Ω
current-sense resistor, tracking the 0- to 3-V control input in the
lower trace. Turning on peakcapture mode reveals the hash generated
by the microcontroller through the power supply. The middle trace
in each screen is the current feedback voltage from U4.
The oscilloscope screenshot in Figure 2a shows the current sink in
operation. The low-pass filtered PWM signal in the bottom trace
ramps from 0 to 3 V, which is precisely matched by the
current-feedback signal from U4 in the middle trace. The actual
voltage across R12A-B in the top trace, however, wears some fur
throughout its entire range.
Switching to peak-detect mode reveals over 50 mVPP of noise on the
signal. That noise turns out to be high-frequency digital hash from
the microcontroller that’s entirely unrelated to its PWM outputs.
Much the same noise appears on the other two traces, where it’s
barely visible as a slight thickening at 1 V/div.
Isolating digital and analog circuitry on a single board requires
careful attention to power distribution and grounding. The Arduino
Diecimila +5-V regulator supplies power to both the ATmega168 chip
and the analog circuitry, with ground return paths through only
three pins in the pin header strips. Although the Diecimila board
has plenty of gridded areas, its compact layout chops up the ground
connections.
My layout didn’t fare much better. While I managed a broader
connection between the ground pins on each side of the board, that
lower impedance simply routed more digital hash from the Arduino
board through my circuitry.
My revised layout will use a somewhat larger board that puts the
relatively high-current areas outside the Diecimila footprint
and the relatively delicate circuitry in a separate ground area.
I’ll also regulate 9- and 5-V supplies from a wallwart transformer,
with a single-point ground connection to the Arduino. That should
reduce much of the hash and stabilize the op-amps.
MPP LETDOWNThe boost-mode DC-to-DC converter on the left side of Figure 1
stores energy in inductor L1 when transistor Q1 is on, then dumps
that energy into C3 when Q1 switches off. The microcontroller can
set the minimum and maximum inductor current limits to bracket the
Maximum Power Point current, so that the average current is
reasonably close to the ideal value.
The voltage across an inductor is proportional to the derivative of
the current through it, according to the familiar equation:
When Q1 is on, it applies essentially the full panel voltage across
L1, with the DC current limited only by the panel’s power output
and the current-sensing resistors. The current should therefore
increase at a rate set by the equation:
Figure 3a—The simulated booster circuit ramps between 100 and 200 mA at the
di/dt rate set by the 17.4-mH inductor. b—The oscilloscope
screenshot shows something’s amiss: the actual inductor current has
abrupt peaks due to core saturation. Trace 3 shows that the MAX4372
current amplifier can’t keep up with the core flux collapse.
The Spice simulation in Figure 3a shows the results for a 17.4-mH
inductor. The inductor current rises from 100 to 200 mA in about
300 μs, showing that the applied voltage is:
When Q1 opens, the inductor current charges C3 as it declines
toward the lower current setpoint. Because the output voltage
changes only slightly, the current decreases nearly linearly.
I picked 17.4 mH because that matched the inductance of a
common-mode power choke I found in my parts heap. In normal use, a
common-mode choke has two windings connected to the AC line input
so that the circuit’s load current produces opposing magnetic
fields; with no net field, the normal-mode current sees essentially
zero inductance. Common-mode signals, usually caused by electrical
noise, produce fields that don’t cancel and therefore encounter an
inductance that tends to filter out the noise.
The two windings each had 4.2 mH of inductance, so their series
connection was 17.4 mH; remember that inductance varies as the
square of the number of turns. The windings appeared to be 20-AWG
copper, suited for currents of several amps. The ferrite core was a
pair of C-shapes with a small gap, so I assumed saturation wouldn’t
be a problem with a few hundred milliamps of DC current.
The scope shot in Figure 3b shows the catastrophic error in that
assumption. The upper trace actually consists of two overlaid
traces: the differential voltage measured across R14A-B and the
output of U1. The lower trace is the base drive signal from IC1C.
I set the current limits to 50 mA and 300 mA, but the current
obviously isn’t changing linearly. The current rises more-or-less
linearly to about 60 mA, skyrockets to the 300-mA peak, and
collapses almost instantly when Q1 switches off.
Eyeballing the flattest part of the curve, roughly the first half
of the lower part marked by the cursors, where the slope seems to
be:
Applied through a 17.4-mH inductor, that gives a voltage of about
14 V, more than a factor of three higher than the 4 V I was
carefully using. Obviously, the inductor isn’t working nearly as
well as I expected.
Oops!
My February 2008 column described how to measure transformer core
characteristics and that technique works equally well for chokes
and inductors (“Transformers,” Circuit Cellar 211). I set that
circuit up again and found that the choke core began saturating at
about 8 kG, roughly what you’d expect for ungapped ferrite.
Evidently that gap was much smaller than the visible line led me to
believe.
The test setup showed that a mere 50 mA through both windings in
series pushed the core into saturation, which roughly agrees with
Figure 3 and shows that the choke is completely useless for this
application.
In retrospect, none of this is surprising. In its original
application the choke windings must support the expected load
current, but equal current in the opposed windings produces no net
magnetic flux in the core. The only commonmode current comes from
line noise, but most applications shouldn’t see that much CM signal
in the first place. Finally, a ferrite core provides useful
inductance at much higher frequencies than laminated silicon steel
and doesn’t need an explicit gap for this application.
As an interesting sidelight, the MAX4372T high-side current
amplifier has a –3 dB bandwidth of about 275 kHz. That would
suffice for the original design with its relatively slow ramps, but
falls behind the core flux collapse when Q1 switches off, as shown
by that perfect straight-line declining at about 12 kA/s from the
peak.
Although the booster circuit did work, sort of, it’s certainly not
operating according to the original design.
CONTACT RELEASEYou can generally recover from one blunder and a few minor goofs on
a prototype circuit layout, but two big ones means it’s time for
another revision. With better power supplies, a different layout,
and a beefier inductor, I’ll be able to talk about what works,
rather than what didn’t.
All that sounds remarkably like a plan, though. We shall see!
Ed Nisley is an EE and author in Poughkeepsie, NY. Contact him at
ed.nisley@ieee.org with “Circuit Cellar” in the subject to avoid spam filters.
PROJECT FILESTo download the additional files, go to
ftp://ftp.circuitcellar.com/pub/Circuit_Cellar/2009/225.
RESOURCESArduino project,
http://arduino.cc.
E. Nisley, “Transformers,” Circuit Cellar 211, 2008.
SOURCESGnuplot Plotting utility
Gnuplot |
www.gnuplot.infoLTspice IV Design simulator
Linear Technology Corp. |
www.linear.com/designtools/software/ltspice.jspArduino Diecimila Microcontroller
SparkFun Electronics |
www.sparkfun.com/commerce/product_info.php?products_id=666