Search This Blog

Saturday, August 31, 2019

USB meter modding - Part 1

USB meters can come in handy for measuring the voltage and current. While they may have 3 digits display, some of them do not actually have the resolution nor are calibrated.

This is a mod for a $2 USB meter to to improve on the resolution and accuracy closer to my digital multimeter with the added bonus of much lower voltage drops. My modifications and calibration (part 2) makes up for the loose tolerance parts.

Modded meter reads 13mA (3mA for the LCD meter + 10mA for serial dongle)
The LCD meter cannot see the dongle even though the current is within range.
I have decided to modify one for an impulsive weekend project. It is a KW203 from a few years ago for about $2. The ones I saw are overpriced ($10-$20) and you can get really fancy LCD ones for about $3.

It uses a SO18 wide package, so a replacement microcontroller can be fitted within the footprint.  It is simple enough that the I/O mappings can be traced.

PCB with microcontroller removed.
The current measurement is done with a 0.01R sampling resistor placed in the ground connection between the input and the USB connectors. A SOT23-5 opamp in a non-inverting configuration provides 48X gain.
The amount of voltage drops is lower than the average multimeter.

The voltage measurement is done with a voltage divider of 15K in series and 2K to ground.  There is a ceramic capacitor in parallel to provide the low impedance for the ADC.

There is a group of 5 resistor footprints behind the "Charger" USB connector.  They are to provide the "Charger" voltage divider for Android/iOS charger.

There are foot prints for a couple of SOT23 sized trimpots for both measurement, but they are bypassed with a couple of 0 ohms resistors jumpers instead.

There is a MD78U30 3V LDO to provide a 3V rail for the microcontroller as the meter is supposed to be able to handle 3.2V - 10V.  There is a small 10uF tantalum bulk decoupling cap on the output rail. There are no additional decoupling caps provided.

Cheat sheet I used for wiring up the microcontroller
The two IC are the old and the replacement microcontroller.  I have decided to use the STM8S008F3 as it has just the right number of I/O needed: 14 I/O for driving the 6 digits multiplexed 7-segment LED display and 2 ADC inputs for the measurements. If I scale the input correctly, the 10-bit ADC, I should be able to get close to 3-digit resolution.  I am using oversampling to improve on the resolution, but the actual resolution depends a lot on the noise floor and type.

There are a few gotchas:
  • PB4, PB5 are "True" Open drain pins, so they can only be used for the common cathode and not the segments. PA1, PA2 are standard GPIO vs the rest of the HS (High Sink), so those segments might be slightly dimmer. 
  • There are no series resistors, so the LED is current limited by the GPIO driver resistance.  The power rail is set at 3V which helps a bit. The LED switching can affect the ADC reading as the ADC has no internal reference and use the power rail as reference.
  • There are 3 ceramic caps for this part. VCAP is the 1.8V decoupling cap for the internal regulator, and one for the 3V rail. The NRST can probably be ignored, but I connected it per datasheet  recommendation.
  • There are no spare I/O. The SWIM pin is also used in driving the first digit and its GPIO function is disabled when the debugger is connected.
  • The 7 segment display only have decimal point at the first digit.
  • The grounding isn't good and 4-wire connection isn't used at the sampling resistor which can affect the linearity at higher currents.
The part is small enough to fit within the footprint. This is a quick and dirty hack, so I am not going to make a custom flex PCB at OSH Park and wait for it.

Replacement microcontroller soldered
I soldered in the microcontroller with some fine magnetic wires and even wired in the required capacitors on top of the chip.  The extra wires are the SWIM, NRST pins for the hardware debugger/programmer.

Test display
After a bit of debugging, I got the timer IRQ to turns on the column driver and dumps out the corresponding digit stored in the buffer at a refresh rate of ~59Hz.

So far the I/O seems to be going to the right places and the hardware debugger works. The current drawn is about 10.5mA.

Project file: https://github.com/FPGA-Computer/USB-Voltage-Current-Meter

  • I found a KW203 reverse engineering article here after my mod.
  • There are also panel meter with a STM8.
  • I have seen one of the more LCD fancy one last week and it seems to be using a 20-pin TSSOP microcontroller. 




This one might have a STM8S003 and a 4 pin programming connector.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.