This is only a preview of the August 2025 issue of Silicon Chip. You can view 46 of the 104 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Articles in this series:
Articles in this series:
Items relevant to "Modules: Thin-Film Pressure Sensor":
Articles in this series:
Items relevant to "USB-C Power Monitor, Part 1":
Items relevant to "RP2350B Development Board":
Items relevant to "Mic the Mouse":
Items relevant to "Ducted Heat Transfer Controller Part 1":
Purchase a printed copy of this issue for $13.00. |
USB--C
USB
Part 1 by Tim Blythman
Power Monitor
It is always handy to know what voltage and current a USB device is using. Now that USB-C
is prevalent, it’s time for a USB-C Power Monitor. It can be used for all modern USB-C
devices, as well as legacy USB devices, with the right adaptor.
T
here are many situations where it’s
helpful to see how much power
or current a USB device is drawing,
or what voltage is being applied to
it. This design makes that very easy,
and it works with virtually all modern
USB-C devices.
Say you have a fast charger and a
smartphone or tablet that’s capable of
fast charging. While the situation is
getting better, there are cases where
they are incompatible and will not
actually fast charge, or will, but only
at a modest rate. With this device, you
can see exactly how much power is
being transferred.
Another situation is if you are developing a USB device and you want to
see how much power it draws when
performing certain functions, or
whether it’s correctly signalling the
power supply to give it a certain voltage or amount of power.
Ideally, you want a compact device
that can just be plugged between two
devices, with a screen to show the voltage, current, power, energy and more.
That’s exactly what this device is.
It doesn’t even matter which way
around you connect it – it can monitor
current and thus power flow in either
direction! It doesn’t need an external
power supply, either. Its controls are
simple yet intuitive; it uses just three
pushbuttons and an OLED screen.
A bit of history
This project is, in a sense, an update
of the USB Power Monitor from the
December 2012 issue (siliconchip.au/
Article/460). It was a small PCB with
a USB-A plug at one end and a USB-A
socket at the other.
This allowed it to be fitted inline at
any place you might connect a USB-A
plug, including a computer or USB
power supply.
That USB Power Monitor displayed
information on an LCD screen, such
as the USB bus voltage and current
drawn at the socket, as well as calculating power. It took its power from the
USB supply upstream of the current
measuring shunt, and could measure
down to 1μA.
An update published in the Circuit
Notebook section of the October 2013
issue (siliconchip.au/Article/4999)
added the ability to measure energy
consumption by accumulating the
power usage over time. This update
did not require any changes to the
hardware; it was a simple firmware
upgrade.
While the earlier Monitor can still
be useful, its legacy Type-A connectors rule out the option of working
with newer USB 3.x features, such as
Power Delivery (PD) or SuperSpeed
USB data transfer.
USB-C is now very widespread. We
have recently switched to using USB-C
sockets on practically all projects that
need a USB connection. Last year,
USB-C was legislated in the European
Union as the standard charging port
for mobile phones and similar gadgets.
The demand for higher currents,
higher voltages and the consequent
higher power levels means that a
USB-C Power Monitor is necessary
for some scenarios. USB-PD (power
delivery) is currently rated to provide
up to 48V at 5A, well beyond what the
older USB Power Monitor can tolerate
or measure.
Of course, legacy USB 2.0 devices
with the older USB-A and USB-B connectors can work with the newer Monitor with simple adaptors. However,
there is a lot more to the USB-C Power
Monitor than just adding USB-C connectors to the older design!
We’ll describe some of the technical
features that apply to USB-C and how
they have affected our design. If you
Short-form Kit (SC7489, $60): this kit includes all the non-optional parts listed except the case, lithium-ion cell
and glue. It will also include the FFC (flat flexible cable PCB) for joining the two PCBs.
38
Silicon Chip
Australia's electronics magazine
siliconchip.com.au
Features & Specifications
● Main screen reports current, voltage, power, energy (in J or Wh) & time
● Configuration channel (CC) status screen
● All 24 USB data lines pass through
● Self-contained with 400mAh rechargeable lithium battery
● Internal battery means no extra load on the USB circuit under test
● Compact case is only 80 × 40mm
● Automatic offset trimming
● Voltage measurements: up to 60V with 10mV resolution
● Current measurements: up to ±5A with 1mA resolution; 10μA resolution below
~25mA
● Power: up to 300W with 1mW resolution (limited by V and I)
● Energy: up to 999999J (1mJ resolution) or up to 999Wh (10μWh resolution)
● Battery consumption: <20mA, giving 20 hours of usage per charge
● Sleep mode: <10μA drawn from battery, less than typical self-discharge
want more background on USB technology, we have a panel listing several
Silicon Chip features and projects that
involve USB on a more technical level.
Early USB was simple
The original USB 1.0 specification
dates back to 1996, and uses much the
same hardware and electrical arrangement as the later USB 1.1 and USB
2.0 standards. Two conductors (Vbus
and GND) are provided for a nominal 5V power supply. Another two
conductors (D+ and D−) providing a
bi-
directional differential signalling
pair. A separate shield connection is
also present.
These connections are carried
through the original USB Power Monitor, with only the Vbus line interrupted
by a current measuring shunt. All these
earlier specifications have been carried
forward into the newer versions of the
USB specifications, although many
aspects are now considered ‘legacy’.
The design of the plugs and sockets
enforced upstream and downstream
ends. Assuming the standards have
been followed, this means that current
can only flow one way, and thus the
USB Power Monitor’s simple design
only needed to handle current flowing in one direction.
The supply voltage was fixed at a
nominal 5V, meaning that it could
directly power a 5V microcontroller
without even needing a regulator. In
fact, all the ICs on the original USB
Power Monitor run directly from the
USB 5V supply.
Given USB’s broad usage as a power
supply and for charging, it was also
useful when no USB communication
takes place. For example, you could
siliconchip.com.au
use it to check how much current a
mobile phone used while charging.
The USB-C standard
USB-C is a 2014 design that allows
all USB protocols, so far up to USB4,
to be transmitted. Importantly, USB-C
only specifies things like the connectors and cables; it permits many other
protocols aside from USB. Some other
communication technologies that can
be carried over USB-C include Thunderbolt, PCIe, HDMI and DisplayPort
(including digital video & audio).
The USB-C connector is symmetrical and can be inserted in two ways (no
more fumbling to figure out the right
way!). It can also be used at both ends
of a cable, so the cable itself does not
enforce an upstream or downstream
end; current and data can flow either
way in a USB-C cable. In fact, USB-C
allows the power source or sink role
to be separate from the USB host or
device function.
USB-PD (USB power delivery) provides a means to negotiate voltages
up to 48V and currents up to 5A. So
clearly, there are many factors that
need to be considered in designing a
USB-C capable power monitor.
Because of all these features, a
USB-C receptacle can have up to 24
conductors, plus a shield. Some of
these are symmetrically arranged
duplicates. For example, there are
four ground pins and four Vbus pins
to share the current load, as shown in
Fig.1. The plug is mirrored relative to
the socket.
In the receptacle, there are two each
of the D+ and D− legacy USB data pins.
There are four more differential pairs,
two in each direction. These are the
same pairs that were introduced with
USB 3.0, and the blue-coloured connectors that marked the new SuperSpeed transfer rate.
The four remaining conductors are
for signalling related to USB-C’s features. The two CC (configuration channel) lines are the channel over which
USB-PD communication takes place.
Our article “How USB Power Delivery works” (July 2021; siliconchip.au/
Article/14919) gets into the details of
the power delivery protocol.
There are now chips specifically
designed to handle USB-PD communications, and these are often found in
the so-called ‘trigger’ or ‘decoy’ modules that can request a specific voltage
using USB-PD’s digital signalling. The
photo overleaf shows an example of
such a module.
Early versions of USB-PD supported
up to six power profiles at various currents and voltages of 5V, 12V or 20V.
Subsequent revisions added support
for 9V, 15V, 28V, 36V and 48V. A more
recent protocol, known as PPS (Programmable Power Supply), allows
voltages to be requested up to 21V
in 20mV steps and current limits in
50mA steps.
Fig.1: USB-C’s design incorporates rotational symmetry, removing the need
to flip the connector like earlier USB plugs/sockets. This requires extra
conductors, with many being duplicated. The configuration channel lines
provide cable rotation detection for correct operation.
Australia's electronics magazine
August 2025 39
The main PCB of
the Power Monitor
connects to the
USB Breakout
board using a
flexible PCB
(FFC).
A typical USB-PD trigger
board has a USB-C socket, a USBPD interface IC and an output connector.
This example sets the requested PD voltage by solder
jumpers; some can be controlled digitally, with an I2C
serial interface or similar.
The simplest signalling is done via
pullups and pulldowns on the CC lines
with specific resistor values; this can
be used to offer or request the legacy
5V supply voltage. We have used this
arrangement in our projects using
USB-C sockets for 5V power.
Fig.2 shows the basic arrangement
using the resistor-based signalling,
which is quite simple and elegant.
Only one CC line is typically connected through in a cable; this allows
both devices to determine the orientation of the conductors if the cable has
been flipped.
The source will only apply Vbus if
it sees that a sink has connected with
the correct pulldown resistance. The
pulldown can be applied by a simple
resistor to ground, so the signalling
will work even on a device that has
no power to begin with.
Cleverly, Vbus switching can be
achieved by not much more than a
logic-
level P-channel Mosfet. The
Mosfet’s gate is pulled up until a sink
is connected, switching the Mosfet off.
The sink’s Rd resistor pulls the gate
low and turns the Mosfet on, allowing the source to provide current to
the sink.
The current that the source applies
to the CC line also encodes a Vbus current capacity, and the sink can detect
this by the voltage across the Rd resistor on the CC line. This allows sink
devices to limit their current draw to
what the source can provide.
The second CC conductor can
40
Silicon Chip
also supply power to the electronics
embedded in an ‘e-marked’ cable. In
this role, it is known as Vconn, indicated by the resistors labelled Ra in
Fig.2.
E-marking involves embedding a
chip inside the cable. One use of such
a chip is to indicate to the source that
the cable can handle 5A. Any cable
that is not identified as such is limited to 3A. The CC lines are also used
to communicate other USB-C features,
such as support for alternative modes.
Finally, there are the two SBU (sideband use) lines, which are used by an
audio adaptor accessory mode and the
USB4 protocol. It’s also possible to use
them for a specific custom purpose
through USB-PD negotiation.
In summary, USB-C offers a lot more
variety in voltages, currents and protocols than the legacy standards and connectors. So the USB-C Power Monitor
has more to do than just measure the
current and voltage.
We need to be able to measure voltages up to 48V and monitor currents
up to 5A in either direction. There are
signals, such as those on the CC lines,
that we can monitor for connectivity
and possibly take control of.
We considered including a USB-PD
chip to allow monitoring of the power
delivery communications, but ultimately decided against doing so. Most
of these chips are in leadless packages
(eg, QFN) that are difficult to solder.
We also thought it would be best
to avoid a situation where multiple
chips are trying to communicate over
the same configuration channel bus,
lest that lead to improper voltages
being requested, potentially causing
damage to equipment connected to
the Monitor.
USB-C specifications
It is an unfortunate fact that the
USB-C Power Monitor (or any design
like it) cannot meet the USB-C specifications. As you can see from the
photos, it has a USB-C socket at one
end and a USB-C plug at the other. As
such, it is effectively a USB-C extension cable.
Such cables are simply forbidden by the specification. Consider
what would happen if a 5A e-marked
cable were connected to a 3A extension cable. The signalling for the 5A
cable would be passed through the 3A
cable, and the source would behave as
though both cables are capable of 5A
when they might not be.
Extension cables also diminish the
signal integrity due to the extra junctions between the plugs and sockets
and the cable length. This means that
the higher speed communications are
more likely to be compromised.
Fig.2: the basic signalling used on the CC lines requires sources and sinks to
use specific resistor values (or current sources/sinks) to determine rotation
and the current required. Before a source can apply power on Vbus, it must
detect that a sink is correctly connected.
Australia's electronics magazine
siliconchip.com.au
Providing two USB-C sockets on the
Monitor (effectively turning it into a
cable joiner) would be possible, but
would result in much the same concerns.
The specification also allows cables
to omit some internal conductors,
since the cable orientation sensing can
deal with that scenario. Connecting
two such cables with a joiner could
result in some signals not being passed
through at all.
We performed several speed tests
with different devices through our
Power Monitor, comparing the performance between having the Monitor inline or not. We did not find a
device for which it made a difference.
It takes some powerful gear to run the
high-speed (many GHz) tests needed
to validate USB 3.2 communication,
and we do not have access to such
test equipment.
However, by making the USB-C
Power Monitor as short as practically
possible, we minimise the possibility
of introducing signal integrity problems. Still, we cannot guarantee they
can’t happen.
So, while the USB-C Power Monitor can’t comply with the USB-C
specifications, we have worked hard
and performed some thorough testing
to ensure that it works with as many
devices as possible.
Circuit details
The circuit shown in Fig.3 is split
over two PCBs joined by a 7-pin header
(CON4) at each end. The smaller PCB
(inside the dashed box) has a USB-C
plug (CON1) and a USB-C socket
(CON2). All the Vbus and GND connections are joined at each end to simplify routing; this is actually required
in the USB-C specification.
Apart from a few, all the other lines
are connected straight through, forming the forbidden USB-C extension
lead. The Vbus, CC1 and CC2 lines
each have a resistor between CON1
and CON2. The 15mW shunt resistor
in series with Vbus is for measuring
the current flow.
The resistors inline with CC1 and
CC2 allow us to determine the source
and sink nature of whatever is connected to CON1 and CON2. The extra
resistance is about the smallest we
could use to reliably detect that difference, while being low enough to
not affect the CC detection thresholds
according to the specifications.
siliconchip.com.au
Parts List – USB-C Power Monitor
1 double-sided green PCB coded 04102251, 78 × 11 × 0.8mm
1 double-sided black PCB coded 04102252, 80 × 40 × 0.8mm
1 flat flexible PCB (FFC) coded 04102253, 18 × 40mm
OR 5cm of 7-way ribbon cable
OR 30cm of light-duty flexible cable
1 80 × 40 × 20mm enclosure [Hammond 1551KBK, Altronics H9004]
1 small lithium-ion rechargeable pouch cell with protection circuitry [Altronics S4723]
1 Amphenol 12401981E412A straddle-mount 24-pin USB-C plug (CON1)
[DigiKey, Mouser]
1 Würth 632723100011 24-pin SMT+through-hole USB-C socket (CON2)
[DigiKey, Mouser]
1 5-pin header, 2.54mm pitch (CON3; optional, for ICSP)
1 USB-C SMD power-only socket (CON5) [GCT USB4135 or equivalent]
1 M2016/0806 size 4.7μH 1A inductor (L1) [Murata LQM2MPN4R7NG0L]
1 128×32 pixel 0.91-inch I2C OLED module (MOD1)
3 Adafruit 5410 reverse-mount SMD tactile switches (S1-S3) [DigiKey, Mouser]
1 tube of neutral-cure silicone sealant or similar flexible adhesive
1 piece of foam-cored double-sided tape (to secure BAT1)
Würth 632723300011 is an alternative but it might be harder to solder
🔸
🔸
Semiconductors
1 PIC16F18146-I/SO 8-bit micro programmed with 0410225A.HEX, SOIC-20 (IC1)
1 INA296A3 or INA282 current monitor, SOIC-8 (IC2)
1 AD8541A or NCS325 rail-to-rail CMOS op amp, SOT-23-5 or SC-70-5 (IC3)
1 MCP73831T-2ACI/OT Li-ion charge regulator, SOT23-5 (IC4)
1 MCP16252T-I/CH boost regulator, SOT-23-6 (REG1)
1 3mm bi-colour red/green LED (LED1)
1 BAT54C common-cathode schottky diode, SOT-23 (D1)
Capacitors (all SMD M2012/0805 size X7R ceramic)
5 10μF 16V
5 100nF 50V
Resistors (all SMD M2012/0805 size ⅛W, 1% unless noted)
2 1MW
1 22kW
2 220W
1 390kW
3 10kW
1 100W
1 150kW
6 5.1kW
1 10W
1 120kW
2 1kW
1 15mW M6331/2512 size 3W
Articles on USB technology
If you wish to delve into the technical details of USB, the following Silicon
Chip articles may be of interest:
● USB: Hassle-Free Connections To Your PC by Peter Smith (November
1999): siliconchip.au/Article/4436
● The History of USB by Jim Rowe (June 2021):
siliconchip.au/Article/14883
● How USB Power Delivery (USB-PD) works by Andrew Levido (July 2021):
siliconchip.au/Article/14919
● El Cheapo Modules: USB-PD chargers by Jim Rowe (July 2021):
siliconchip.au/Article/14920
● El Cheapo Modules: USB-PD Triggers by Jim Rowe (August 2021):
siliconchip.au/Article/14996
The following projects may also be of interest:
● USB Power Monitor by Nicholas Vinen (December 2012):
siliconchip.au/Article/460
● USB Cable Tester by Tim Blythman (November & December 2021):
siliconchip.com.au/Series/374
● USB-C Serial Adaptor by Tim Blythman (June 2024):
siliconchip.au/Article/16291
Australia's electronics magazine
August 2025 41
Typical currents in the CC lines are
in the hundreds of microamps (from
source current Ip to sink resistor Rd),
so the drop across the 220W resistors
is in the tens of millivolts. This is the
precision of the voltage thresholds in
the specifications.
When a CC line is allocated to a
Vconn role, it can supply 5V power
at up to 200mA to electronics in an
e-marked cable. Clearly, 220W is too
high to allow 200mA to be passed successfully, although our testing didn’t
find any cables that had problems
with this.
A typical e-marked cable will try
to source Vconn from both ends of the
cable using diodes or similar to prevent Vconn being carried through the
cable. So if you run into problems,
try reversing the Monitor; that should
allow Vconn to be sourced from the
other end.
CON4 breaks out the important signals back to the main PCB for monitoring. There is a ground connection, and
two wires for Vbus, CC1 and CC2, fed
from each side of their respective resistors. CON4’s connections are arranged
symmetrically so that the entire PCB
can be rotated 180°.
This means that if you prefer the
USB-C plug on the left and the USB-C
socket on the right, you can wire the
boards in this fashion during the construction phase.
Main circuit
A microcontroller is required to
make measurements and drive the
display to report them. We’re using
an 8-bit PIC16F18146 (IC1), since it
has some useful internal peripherals,
including a 4.096V reference, an 8-bit
buffered digital-to-analog converter
(DAC) and a 12-bit analog-to-digital
converter (ADC).
IC1 has the usual 100nF bypass
capacitor on its power and ground
pins (1 and 20 respectively). A 10kW
resistor pulls up the MCLR pin (pin
4) to allow normal operation, unless
a programmer is connected at ICSP
header CON3. Pins 1, 4, 18, 19 and 20
are taken to CON3 for programming
and debugging.
Pins 11, 12 and 13 connect to tactile switches S1, S2 and S3. They are
configured with internal pullups, and
the micro detects the pin level changing to low when the switch is pressed,
closing the circuit to ground. A pinchange interrupt allows the micro to be
42
Silicon Chip
woken up from deep sleep by pressing
any of the switches.
These 8-bit PICs have a good output
pin drive strength and so can directly
power other circuit elements, allowing them to be switched off when the
Monitor needs to be in low-power
sleep mode.
Pin 16 powers OLED module MOD1,
a 128×32 pixel monochrome display,
so it can show a few lines of text or
similar. IC1’s pins 14 and 15 provide
a bit-banged I2C serial interface to control the OLED. IC1’s pin 2 is used to
provide power to IC2 and IC3, as well
as to control the ENABLE pin on REG1.
With both pin 2 and pin 16 low
and the microcontroller in low-power
sleep, only IC1 and REG1 draw power
from BAT1. The nominal 5V rail falls
slightly below the cell voltage (because
of the diode and resistor). The greatest current draw is the 6μA flowing
through REG1’s feedback divider, with
IC1 and REG1 drawing less than 1μA
each, for a total under 8μA.
Analog circuitry
IC2 is a current shunt monitor that
amplifies the voltage across the 15mW
current measuring shunt connected
via CON4. It has a gain of 50, so its
output voltage is 0.75V for every amp
through the shunt.
IC2 is equipped with two reference
inputs (REF1 and REF2); the output
voltage is offset against the average of
the voltage at these two pins. The twopin reference feature makes it easy to
set up a mid-rail reference for bidirectional current sensing, although we
don’t use that here.
Instead, we feed both reference pins
with a voltage supplied from pin 17
of IC1. This is derived from an 8-bit
DAC connected to a 4.096V internal
reference. By setting the DAC, we can
change the IC2 reference to be anywhere between 0V and 4.096V.
This allows us to nearly double the
span available for readings. For currents in one direction, we set the reference to near (but not quite) 0V and
we have almost 4V of range, allowing
up to 5A to be measured. If the current reverses direction, the reference
is taken near 4V, allowing similar magnitudes to be measured in the opposite direction.
IC3 is a single op amp configured to
amplify the output from IC2 (relative
to the same reference) by a factor of
100. The 100nF capacitor across the
Australia's electronics magazine
Fig.3: the circuit is split into two
sections connected by CON4s; one
section has a USB-C plug (CON1)
and a USB receptacle (CON2), wired
straight through apart from some
resistors. The other section has
microcontroller IC1, which measure
voltages, currents and so forth and
displays them on the OLED module.
feedback resistor provides low-pass
filtering of the amplified signal. IC1’s
pin 9 is used for ADC readings of the
low range (amplified) voltages from
IC3, while pin 3 samples the higher
range voltages directly from IC2.
The ADC peripheral can perform
differential readings, so the reference
is simply used as the second channel
for these readings. This scheme gives
us more dynamic range to accurately
read currents in both directions over
the two ranges.
The 150kW/10kW divider connected
to one of the Vcc pins of CON4 is
used for measuring the Vbus voltage.
The 100nF capacitor on its lower leg
provides a lower source impedance
to charge up pin 10’s ADC sampling
capacitor. With a 4.096V reference,
the divider allows up to 65V to be
measured, comfortably above the 48V
siliconchip.com.au
currently allowed by the USB-C specification.
CC sensing
The remaining resistors are used to
drive and sample the two CC lines.
Normally, pins 5, 6, 7 and 8 are set as
analog inputs to monitor the state of
the CC lines. The series 5.1kW resistors do not noticeably affect the sensed
voltage when these pins are inputs.
The state of the pins can determine
what current the source can provide.
By monitoring for the slight voltage
difference across the 220W resistors,
it can also determine which end is
the source and which end is the sink.
The 5.1kW resistors also allow the
USB-C Power Monitor to behave as
a power sink by driving one or more
of these pins to a low logic level
(0V). This allows you to check the
siliconchip.com.au
capabilities of a source, even if a sink
is not connected.
It is only a very limited use of the
CC signalling. But USB-C now allows
scenarios which seem improbable; for
example, a mobile phone attempting to
charge a laptop computer. So we think
the ability to identify such situations
could be helpful.
Power supply
One interesting problem is that we
realised a USB-C cable does not always
provide power, even if it is connected
to a suitable source such as a computer
or power supply. Thus, we needed a
way to power the USB-C Power Monitor independently.
We chose to use a lithium-ion
rechargeable battery (BAT1). This has
the advantage that the power supply is
decoupled from the USB-C circuitry,
Australia's electronics magazine
and the USB-C Power Monitor does
not load the circuit under test, apart
from a voltage divider totalling 160kW,
which draws about 31μA at 5V.
We used similar circuitry to our
other recent projects that include a
Li-ion cell. The most recent was the
Compact OLED Clock and Timer (September 2024 issue; siliconchip.au/
Article/16570).
In this case, 5V power for charging
comes in via CON5, a power-only
USB-C socket with the 5.1kW resistors necessary to identify it as a power
sink. The MCP73831 charger, IC4, has
a 10μF smoothing capacitor on its
input pin and another on its output
to the battery.
The MCP73831 monitors the
charging current and voltage of BAT1
and provides a multi-stage charging
regime. It has a status output and the
August 2025 43
The Breakout PCB is used to provide the USB connections and will be described in more detail in next month’s issue.
charging current can be programmed.
All in a tiny 5-pin SOT-23 package!
The charge current is set to 45mA
by the 22kW resistor connected to IC4’s
pin 5 (PROG). The STAT pin drives
one side of bicolour LED1; it is low
during charging and is high when it
is complete. The arrangement of 1kW
resistors allows the LED to light up
red during charging and green when
charging is complete.
Dual diode D1 is a common-cathode
schottky type. Power from the battery
and CON5 are connected to its anodes,
so there is no load on the battery when
power is available at CON5.
The remainder of the circuitry
is powered from D1’s cathode, and
because there is no draw on the battery while charging, IC4 can charge it
fully. This arrangement also means
that the USB-C Power Monitor can be
powered directly from CON5 even if
a battery is not fitted.
The cathode of D1 is connected
to MCP16252 boost regulator REG1,
which also has 10μF bypass capacitors at its input (pin 6) and output (pin
5). This part has an ENABLE input at
its pin 3. When this pin is low, the
REG1’s input is connected directly to
its output, providing a low-quiescent-
current mode with no voltage boost.
When ENABLE is taken high, the
boost regulator operates. It has internal N-channel and P-channel Mosfets.
The SW pin (pin 1) is pulled low by
the N-channel Mosfet, drawing current
through inductor L1. When this Mosfet switches off, the P-channel Mosfet
switches on, dumping current from the
inductor into the output and boosting
the voltage.
Using a Mosfet as an active switch
is more efficient than using a diode,
since there is negligible voltage drop
across the switch when it is on. The
390kW/120kW divider at the output
provides feedback for the regulator
and sets the output to a nominal 5.2V.
After the 10μF capacitor on REG1’s
output is a 10W resistor and a further
10μF capacitor to provide a degree of
filtering for the rest of the circuit. At
the circuit’s nominal 20mA draw, the
10W resistor drops about 0.2V, leaving
close to 5V.
Software
As we noted, the PIC16F18146 has
a handy set of peripherals, so we’ll
describe those next, along with some
aspects of the software operation. The
capabilities of the ADC are critical to
this project.
The PIC provides an internal reference that can be set to a nominal
1.024V, 2.048V or 4.096V, and can
be used to set the ADC scale. The
4.096V reference is used for most
of the analog readings and its measured value (in millivolts) is stored
in non-volatile memory at the time
of manufacture.
Being able to use the 4.096V range
is the main reason for the boost converter (REG1). The 4.096V reference
will not be functional if the supply is
only 3.7V, as might be the case for a
Li-ion cell that is nearly flat without
this boosting.
The analog peripheral is actually
described as an ‘Analog-to-Digital
Converter with Computation’ (ADCC)
module. It can produce a 12-bit result
and can also accumulate multiple
results. The accumulator has 18 bits, so
the software configures it to accumulate 64 12-bit results, giving a notional
18-bit result.
Since the total ADCC error is around
two bits, the lower two bits are discarded, and the software works with
convenient 16-bit numbers. It takes
about two milliseconds to perform
the 64 samples, so the processor sets
it running and uses an interrupt routine to store the readings, then commence the next sample while it continues with other tasks.
A set of 13 samples is taken in
round-robin fashion; the two current
readings are taken in differential mode
using the pin 17 VREF voltage as the
second channel. The voltages across
the 220W resistors in the CC lines are
also measured in differential mode;
this allows us to note the sign and
determine the direction that the current is flowing in those lines.
All these differential readings are
also validated by taking corresponding single-ended (absolute) readings.
For example, this allows us to detect
when the low-range current reading
approaches the rails, an indication
that we should shift the reference (by
setting the DAC) to allow more headroom or use the high-current range
instead.
A second 8-bit DAC is internally
connected to IC1’s supply. The DAC
is set to code 32, or 1/8 of the supply.
The ADCC sample of this channel uses
the 1.024V reference, meaning that we
can accurately check that the supply
voltage is high enough for the 4.096V
reference to work and that the other
readings are correct.
A timer peripheral is also used to
provide an internal clock. This is set to
The “>” button cycles through various
screens, while the up/down buttons are
used to adjust values and modes.
44
Silicon Chip
Australia's electronics magazine
siliconchip.com.au
Screen 1: the main screen reports the Vbus voltage and
current (including direction). Power and accumulated
energy are also calculated; a timer is available too.
Another screen can be used to monitor and test the
condition of the configuration channel lines.
count at an integer fraction of a second
and make the calculations easy (for an
8-bit processor) without using computationally complex floating-point values. The time each sample set takes to
complete is also recorded.
This is necessary because the most
accurate ADCC results can be achieved
when the ADCC is run from its own
internal oscillator and completely
decoupled from the micro’s other
internal clocks.
The appropriate scaling factors are
applied to provide the numerical values that are needed. Derived values
like power (current multiplied by voltage) and energy (power multiplied by
time) are also calculated. This part of
the software also sets flags indicating
which of the low or high current ranges
is valid and should be used.
These measurements continue to
run any time the micro is active and
not sleeping; the results are displayed
according to the screen that the user
has selected. The main screen, for
example, reports the same basic statistics as the older Monitor: voltage, current (now including direction), power
and total energy.
The energy totaliser is paired with
a timer; both can be started, paused
and reset together. The totaliser also
runs in the background if other screens
are selected, providing seamless operation.
Another screen allows monitoring
and control of the CC lines, while a
third can be used to put the Monitor
into low-power sleep mode or check
the battery voltage. You can also access
the configuration screens by a long
press of S3.
Most of the configuration is involved
with trimming the calibration factors
to suit the components used in a specific build, although there are also the
options to adjust the screen brightness
and choose between watt-hours (Wh)
or Joules (J) for the units displayed for
energy. We’ll look more at the user
interface later.
Hardware
The two PCBs fit into a compact 80
× 40 × 20mm enclosure; we used a
siliconchip.com.au
Hammond 1551KBK, which is available from Altronics (Cat H9004). One
PCB replaces the lid, so the final unit
is only 18mm high, but is slightly longer than 80mm because of the plug
protruding at one end.
Both PCBs require reasonably good
soldering skills to build. Fully featured USB-C plugs and sockets are
only available with very tight pin
spacings of around 0.5mm. When the
Breakout PCB is completed, it can be
tested in isolation by using it as an
extension for a USB-C cable. Thus, it
is possible to detect problems early
in the process.
The PCB hosting CON1 and CON2
must be 0.8mm thick because the plug
(CON1) is a so-called ‘straddle-mount’
that clips over the edge of the PCB. It
sounds fussy, but the mounting style
allows the part to be precisely placed
before soldering begins, and we actually found it easier to work with than
the socket (CON2).
The upper PCB is populated with
M2012 (imperial 0805) sized passives,
which are 2mm long. This is about
the minimum size we consider easy
to handle. There are a couple of SOIC
chips and a few SOT-23 variants with
three, five and six pins.
Since the top PCB is also the lid,
there are a couple of unusual constructions steps. If you have built
the likes of the Compact Clock and
Timer (or read its article), these will
be familiar.
The two PCBs must be joined with
wires. Our early prototypes used pluggable headers, but we found that these
had enough variation in resistance to
interfere with the performance of the
current-measuring shunt.
We designed a flat flexible cable
(FFC) that can be soldered to the PCBs
to give a simple and elegant connection. You can also use hookup wire
for this, or a section of 7-way ribbon
cable, if you find the FFC is too expensive or difficult to source (we’ll supply
the FFC with our kits – see the panel).
We had originally planned to use
a 10440-sized lithium-ion cell as the
battery. These are the same physical
size as a AAA cell, and there is just
enough room to fit a AAA cell holder
to allow simple and safe connection
of the cell.
However, we think that our final
design, using a small, rectangular
pouch cell like Altronics’ Cat S4723,
works better. The slim shape is a better fit for the available space, and the
nominal 400mAh capacity is higher
than we have seen in 10440 lithium
cells. This cell measures 38 × 25 ×
6mm and includes protection circuitry.
Many small pouch cells are available from various online sellers. So
you might find an alternative with
slightly different dimensions that
still fits.
Until next month
This is a very detailed project, and
we have run out of room to describe
it in this issue. The second part next
month will include the construction,
setup, calibration and use of the USB-C
SC
Power Monitor.
Silicon Chip kcaBBack Issues
$10.00 + post
$11.50 + post
$12.50 + post
$13.00 + post
January 1997 to October 2021
November 2021 to September 2023
October 2023 to September 2024
October 2024 onwards
All back issues after February 2015 are in stock, while most from January 1997 to
December 2014 are available. For a full list of all available issues, visit: siliconchip.com.
au/Shop/2
PDF versions are available for all issues at siliconchip.com.au/Shop/12
We also sell photocopies of individual articles for those who don’t have a computer
Australia's electronics magazine
August 2025 45
|