Friday, September 19, 2025

NVMe Speed Test

 The computer peripheral bus is eventually settled on PCIe and one small form factor expansion card is M.2 which provides up to 4 PCI express lane.   NVMe SSDs are now widely used and getting inexpensive.  Coming in size 2280/60/42/30.  M Key.


- Patriot Memory P310 NVMe PCIe M.2 Gen 3 x4 480GB $29.49 (6 cents/GB) 11/24

- Patriot Memory P310 NVMe PCIe M.2 Gen 3 x4 240GB $18.99 (8 cents/GB) 10/24

- Western Digital WD Blue Gen 3 x4 M.2 2280 500GB $49.99 (10 cents/GB) 6/22

- Lexar E-series 64GB Micro SD 100MB/s U3, A1,  $6.13 (10 cents/GB) each (for a pack of 3) in 10/24, 

- UGREEN 10Gbps M.2 NVME to USB3.3 Gen 2 $15.99 in 11/24

- ORICO M.2 NVMe USB3.1 Gen 2 (10Gbps) $18.99 in 6/22


ORICO + Patriot 480GB + Macbook Pro Linux

gnome-disks benchmark, 100MB 100 Samples
Average Read 458.4 MB/s
Average Write 417.6 MB/s
Average Access time 0.22 msec

dd if=/dev/zero of=/media/davex/Pat480G/dump.bin bs=1G count=100 status=progress
107374182400 bytes (107 GB, 100 GiB) copied, 1696.78 s, 63.3 MB/s

dd of=/dev/null if=/media/davex/Pat480G/dump.bin bs=1G count=100 status=progress
107374182400 bytes (107 GB, 100 GiB) copied, 242.579 s, 443 MB/s


UGREEN + Patriot 480GB + Macbook Pro Linux

exFAT

dd if=/dev/zero of=/media/davex/PAT480GXFAT/dump.bin bs=100M count=4K status=progress
429496729600 bytes (429 GB, 400 GiB) copied, 956.569 s, 449 MB/s

sudo dd if=/dev/sdd of=/dev/null bs=100M count=4K status=progress
429496729600 bytes (429 GB, 400 GiB) copied, 974.971 s, 441 MB/s

UGREEN + Patriot 480GB + PC Windows 10

exFAT

winsat disk -drive d
> Disk  Random 16.0 Read                       215.03 MB/s          7.8
> Disk  Sequential 64.0 Read                   642.06 MB/s          8.2
> Disk  Sequential 64.0 Write                  661.92 MB/s          8.2
> Average Read Time with Sequential Writes     0.190 ms          8.6
> Latency: 95th Percentile                     0.321 ms          8.8
> Latency: Maximum                             0.610 ms          8.9
> Average Read Time with Random Writes         0.192 ms          8.9

UGREEN + Patriot 240GB + Macbook Pro 

gnome-disks benchmark, 100MB 100 Samples
Average Read 458.5 MB/s
Average Write 420.8 MB/s
Average Access time 0.08 msec

dd if=/dev/zero of=/media/davex/Pat240G/dump.bin bs=1G count=100 status=progress
107374182400 bytes (107 GB, 100 GiB) copied, 718.181 s, 150 MB/s

dd of=/dev/null if=/media/davex/Pat240G/dump.bin bs=1G count=100 status=progress
107374182400 bytes (107 GB, 100 GiB) copied, 242.159 s, 443 MB/s


ORICO + Patriot 240GB + Macbook Pro Linux

NTFS

dd if=/dev/zero of=/media/davex/Pat240G/dump2.bin bs=100M count=1K status=progress
107374182400 bytes (107 GB, 100 GiB) copied, 811.527 s, 132 MB/s

ext4

sudo dd if=/dev/zero of=/media/davex/Pat240G/dump.bin bs=100M count=1K status=progress
107374182400 bytes (107 GB, 100 GiB) copied, 240.032 s, 447 MB/s

tr '\0' '\377' < /dev/zero | sudo dd of=/media/davex/Pat240G/dump2.bin bs=100M count=1K status=progress iflag=fullblock
107374182400 bytes (107 GB, 100 GiB) copied, 261.163 s, 411 MB/s

sudo dd if=/dev/random of=/media/davex/Pat240G/dump2.bin bs=100M count=1K status=progress
107374182400 bytes (107 GB, 100 GiB) copied, 429.978 s, 250 MB/s

exFAT

dd if=/dev/zero of=/media/davex/PAT240GXFAT/dump2.bin bs=100M count=1K status=progress
107374182400 bytes (107 GB, 100 GiB) copied, 250.026 s, 429 MB/s

dd if=/media/davex/Pat480G/Lux2e/Lux2e.vdi of=/media/davex/PAT240GXFAT/Lux2e/Lux2e.vdi bs=100M status=progress
124962996224 bytes (125 GB, 116 GiB) copied, 422.505 s, 296 MB/s

UGREEN + Patriot 240GB + Raspberry Pi 5

exFAT

dd if=/dev/zero of=/media/davex/PAT240GXFAT/dump2.bin bs=100M count=1K status=progress
107374182400 bytes (107 GB, 100 GiB) copied, 415.082 s, 259 MB/s

dd of=/dev/null of=/media/davex/PAT240GXFAT/Lux2e/Lux2e.vdi bs=100M count=1K status=progress
124962996224 bytes (125 GB, 116 GiB) copied, 327.183 s, 382 MB/s

Patriot 240GB + Raspberry Pi 5 (nvme)

exFAT

dd if=/dev/zero of=/media/davex/PAT240GXFAT/dump2.bin bs=100M count=1K status=progress
107374182400 bytes (107 GB, 100 GiB) copied, 297.226 s,  361 MB/s

dd of=/dev/null of=/media/davex/PAT240GXFAT/Lux2e/Lux2e.vdi bs=100M count=1K status=progress
124962996224 bytes (125 GB, 116 GiB) copied, 278.538 s, 449 MB/s


UGREEN + Patriot 240GB + Jetson Nano

exFAT

dd if=/media/davez/PAT240GXFAT/Lux2e/Lux2e.vdi of=/dev/null bs=100M status=progress
124970336256 bytes (125 GB, 116 GiB) copied, 561.616 s, 223 MB/s

dd of=/media/davez/PAT240GXFAT/dump.bin if=/dev/zero bs=100M count=1K status=progress
107374182400 bytes (107 GB, 100 GiB) copied, 1405.02 s, 76.4 MB/s


UGREEN + WD 500GB + Macbook Pro 

ext4

gnome-disks benchmark, 100MB 100 Samples
Average Read 456.6 MB/s
Average Write 329.8 MB/s   (start off at 420 MB/s , drop to 260 MB/s after half way)
Average Access time 0.21 msec

sudo dd if=/dev/zero of=/media/davex/SYSTEM/dump.bin bs=100M count=1K status=progress
107374182400 bytes (107 GB, 100 GiB) copied, 401.139 s, 268 MB/s


WD 500GB + Raspberry Pi 5 (nvme)

ext4

sudo dd if=/dev/zero of=/media/davez/SYSTEM/dump.bin bs=100M count=1000 status=progress
104857600000 bytes (105 GB, 98 GiB) copied, 321.092 s, 327 MB/s

sudo dd of=/dev/null if=/media/davez/SYSTEM/dump.bin bs=100M status=progress
104857600000 bytes (105 GB, 98 GiB) copied, 116.73 s, 898 MB/s


The file format block size has a significant effect on the speed; it is a tradeoff between the speed and disk space utilization.

Friday, August 29, 2025

Boltpower K-3 Jump Starter

 Product specifications (on the case):

    Capacity: 12000mAh
    Lifecycle: above 1000 times
    Output: 12V
    USB Port: 5V 2.1A/1A
    Input: CC/CV 15V/1A
    Starting Current: >200A
    Peak current: 400A(<3s)
    LED life: 100,000H
    LED: 1W
    LED lumen: 86LM
    Operating Temperature: -20C - 60C
    Fully charge time: about 3 hours
    Size: 185x83x43mm
 
Measured total weight: 384g, battery pack weight: 266g (138 x 42 x 28 mm, cell 128 x 42 x 6 mm).  Compared with a 22.2V 1300mAh, (65A (50C) continuous, 104A burst discharge) battery pack weighs 207g (1.42" x 1.07" x 4.12"),  12000mAh claim seems highly exaggerated; in the same density, it would be about 3300mAh.  A range of 638g to over 820g for 12000mAh 3S battery pack is reported by an internet search.  The most generous explanation is 12000mAh is total of 3 cells, which would imply 4000mAh in the ballpark of something reasonable.  If it does indeed produce 200A, it would be 4000mAh at the 50C discharge rate.  Also one search result for the marking on the battery cell "LPB 7442125" is a LiPo cell  of  3.7V/3300mAh (7 x 42 x 125 mm), which is in line with our estimate.  A further comparison, a 11,600mAh (3.7V) power bank is 336g (case included).
 
After some years, but not too many uses, it started bulging in the middle and the casing cracked.  Not surprisingly it is caused by the swollen LiPo battery pack.

 

  
Removing 4 screws with a size 1 Philips screwdriver to open the casing.  The battery pack is secured to the case with an adhesive strip.

 The charging controller is MP26123 (QFN16), a switching battery charger, which supports 2 or 3-cell battery pack with charging current up to 2A. One thing to notice is that the electronics does not have access to the cell voltages, which implies that cell balancing is not done by the the main PCB.  Perhaps there is something inside the battery pack. 
 
There are two other switching regulators, as evident in the two inductors, 6.8uF and 330uF, for the USB 5V and the other constant current drive for the 1W LED respectively.  One of the USB connectors has resistors on the signals to indicate higher current.  One component is identifiable, EMB20P03G, which is a P-channel MOSFET, 30V, 10A, 20mOhms in the SO-8 package.  U7 is suspected to be a microcontroller, which would decode the push button, and control the 4 LED indicators and the LED light pattern. 
 
We are going to something dangerous: deflate the battery pack.  There are a plenty of warnings on the internet of not puncturing the battery pack; but they are really about shorting the cell layers.  If we are careful only to pierce the package not cells, we can release the gas not damaging the cells.  Inside the pouch is a stack of thin layers, copper foil coated with graphite (anode), electrolyte (lithium salt in organic solvent) in the gel form saturating the separator, aluminum foil coated with lithium compound (such as lithium cobalt oxide, cathode). Puncturing the separator shorts the anode and the cathode which generates heat and can ignite the flammable electrolyte.  It is also warned that the gases are toxic; it appears that the main gas is CO2, O2, but there are also CO and others, so well ventilated area is required.  First we discharge the battery as much as possible by turning on the LED light; the LED shuts off at around 9.8V.  The voltage will drift back up a little.
 
Removing the wrapper reveals the three swollen battery pouches.
 

 
 We poke a small hole almost horizontally to the pouch, but not touching the lithium ion cell stack and after squeezing out the gases, we seal the hole quickly with Kapton tape.  Then we wrap them back together.  The seal is probably not perfect; that could affect the battery cells, such as drying up the electrolyte, but we don't expect it to work for too long or use it for high discharging.  I did smell some odor when the gases were released. 
 
 We now charge the battery pack with 15V/1A.  We should expect about 2-3 hours of charging time if there is still significant capacity left.   It took 4 hours for the LED indicator to stop blink.  The end voltage is 12.54V; the charging effectively stopped after 3 hours and probably transitioned from constant current to constant voltage after 2 hours.  We'll run a discharge time to confirm the capacity using the USB current meter; we use an LED light that draws 0.5A from 5V.  When fully discharged (at shutoff), the voltage is 9.9V and the measured capacity is 15,800mWh.  Assuming 15% loss, that puts the capacity at 1670mAh, perhaps 40 to 50% of the original capacity.

Tuesday, May 13, 2025

USB current/energy meter

$4.79 (+shipping and tax for $7.23 total) Shenzhen Rongbo Jiachuang Technology Co, before the tariff was imposed on the Chinese goods.


The device draws about 22mA by itself.  There is 0.2-Ohm resistance between the input and the output.  The current measurements seem to have about -10mA offset, which is a large error in the low current measurements; above 200mA, the measurement error is less than 5%.  It may have calibrated at around 0.5A, the common USB port current.

Fluke 87USB meter
0.0070.00
0.0310.02
0.0390.03
0.0630.05
0.0990.09
0.1420.13
0.2050.20
0.4670.47
0.9030.92
1.4381.47
2.1462.17

The DC voltage measurements have 30-40mV offset and gets worst at higher voltage (the spec is +/-0.5%).  The AC RMS voltage measurement has a bandwidth greater than 3000Hz.  And there is some sort of data manipulation, the voltage measurements do not update consistently.

It is a good enough for casual USB power measurements.


Friday, May 9, 2025

MicroPython On STM32F429 Discovery

We try out MicroPython on STM32F429 Discovery kit.  We pull the MicroPython v1.25.0 source code from github.  

First `make -C mpy-cross` to build MicroPython cross compiler.

Then in ports/stm32, `make BOARD=STM32F429DISC submodules` to pull in libhydrogen, micropython-lib and stm32lib.  

We need the GNU compiler  arm-none-eabi-gcc; we use GCC version 13.3.1  from STM32CubeIDE 1.18.1.  `make BOARD=STM32F429DISC` to build.  The size of the firmware is about 320KB.  STM32F429 has 2MB Flash.

We use stlink to flash; we build stlink v1.8.0 from the source.   We need to specify the USB device ID, `export STLINK_DEVICE="0483:374b"` and `make BOARD=STM32F429DISC deploy-stlink` to download.  openocd can also be used.

Connect to the STLINK USB serial port with minicom -D /dev/ttyACM0

>>> MicroPython v1.25.0 on 2025-04-24; F429I-DISCO with STM32F429

Type "help()" for more information.

We can turn on the red LED with pyb.LED(1).on().

Connecting to the micro USB port, we get another serial device /dev/ttyACM1 and a storage device of 240KB.  There is one 112KB FAT partition on the storage device; the partition has the python scripts, 'boot.py' and 'main.py', which are executed at the start.  We can edit the files (like printing a message) and CTRL-D to restart.  We can the output.   Connecting to /dev/ttyAMC1, we also get a REPL console.  The output goes to both serial ports.

Next we want to do something with the 3-axis gyro (I3G4250D) and the 240x320 LCD (ILI9341).

Friday, April 11, 2025

A Portable LED Lamp

 A foldable LED lamp that is powered by USB costs as little as $3-4.  The overall design seems relatively pleasing; the foldable and adjustable features are practical.  One single touch button controls three levels of brightness and three light color temperatures.  We take a look at its electronics.

5V comes in from the micro USB connector and goes through a diode.  There is an unidentifiable IC driving two what appear to transistors (likely NPN) and receiving a capacitive touch button input.  There are unpopulated footprints, possibly for the battery powered variant. There are total 32 LEDs on two PCB strips, with two different types of white LEDs, warm and cool installed next to one another.  The brightness control is probably through PWM.   With the base resistors of 3300 Ohms, each transistor perhaps runs at about 120mA driving 16 LEDs, only 7.5mA per LED, which seems a little low.  The LED forward voltage is perhaps 3.4V; the dissipation of each transistor is 120mW, which is tolerable for a SOT23 package.  We'll take a few measurements to check our speculations.





We measured the outputs from the IC (using AN8008 multimeter's frequency and duty measurement function), and found the PWM frequency to be 20KHz and the duty cycles of 10%, 40%, and 99% for the three brightness settings respectively.

Thursday, March 20, 2025

Howland Current Source Impedance

 Here we derive the source impedance of the Howland current pump.  The ideal current source impedance is infinity.  The Howland current pump is depended on resistor matching.  We consider the effect of mismatch on the source impedance.

The source impedance is R3/mismatch, a result is given in AoE3, which appears to err on which resistor R3 refers to.

Assume the resistors are 0.1%.  The worst case source impedance is 250 times of  R3 in the diagram.  For small current on the order of 1mA, R3 is on the order of 5KOhms, the source impedance is about 1MOhms worst case, compared with LT3092, which has an output impedance of 100MOhms at 1mA and 2MOhms at 10mA.  

In the so-called "improved" Howland current source, a buffer is inserted to have a separate resistor to set the current.  We can similarly derive the output impedance.
If we assume R1=R2=R3=R4=Rs, the output impedance is Rs/(2*tol), which is twice as large as before.

Sunday, March 16, 2025

A Current Source Circuit

 As an application example, the data sheet of a shunt voltage reference presents an 1mA precision current source as shown here, 

Normally, the negative feedback forces the input terminals of the opamp to be the same voltage and the output applies 2.5V across 2.49K to generate 1mA current to the load.

 However, it is possible for this circuit to get stuck at the 0V.   Note that the negative rail of the opamp is at the ground in the single supply configuration.  With both opamp inputs at 0V, the offset voltage of the opamp causes the output to go to ground.  This is a stable operating point if the offset voltage and the gain are in the right range.

If the opamp's negative rail is a negative voltage, the output saturates at the negative rail, the negative input is clamped at one diode above and the positive input would be more positive (except for certain loads) which would force the opamp out of saturation.

Is there a way to keep the circuit from settling in this undesirable operating point?  One way is to inject some voltage on the opamp's positive input (diode blocking it after it is unstuck).  The voltage divider can be adjust to minimize the error current.  But invariably an error current (a few microamps)  would go into the load if it has to operate over temperatures and a wide range of loads.