Thursday, September 11, 2025

Quotes

"My Favorite Programming Language is Solder."
- Steve Ciarcia
Also atrributed to Bob Pease, Terry Pratchett, and others 
  
"Every year there are 200,000 Chinese engineering graduates, and they don’t know what we know. We can solve problems they cannot.” 
- Robert A. Pease, Analog Circuits: World Class Designs, 2008
 
"... there's no patent on intellectual capability."
- Jim Williams, Interview with Bob Dobkin and Jim Williams April 19, 2006
Silicon Genesis: Oral Histories of Semiconductor Technology
 
"I may be the only person at an electronics flea market who will pay more for the busted stuff!"
- Jim Williams, The Importance of Fixing,  
The Art and Science of Analog Circuit Design

"No one believes an analysis – except the person who did it.
Everyone believes a test – except the person who did it."
- ???

‘‘The best way to predict the future is to invent it.’’
 - Alan Kay

"... true knowledge can only be acquired piecemeal, by the patient interrogation of nature."
- Edmund Whittaker, A History of the Theories of Aether and Electricity

“Successful engineering is all about understanding how things break or fail.”
- Henry Petroski

"All science is either physics or stamp collecting."
- Ernest Rutherford

"The first time you go through the subject, you do not understand it at all. The second time, you think you understand it, except for one or two small points. The third time, you know that you do not understand it, but you are so used to the subject that it does not bother you anymore."
- Arnold Sommerfeld, about thermodynamics

"those who can, do; those who can't, teach."
George Bernard Shaw, Man and Superman

"engineering ... is the art of doing that well with one dollar, which any bungler can do with two after a fashion."
- Arthur M. Wellingtony, The Economic Theory of the Location of Railways

"Engineer - the man who can do for a reasonable cost what another would expend a fortune on"
- Rutherford Aris, Vector, Tensors and the Basic Equations of Fluid Mechanics 

“In God we trust. All others bring data.”
- Bo Lojek, History of Semiconductor Engineering

"Research is when you don't know what you're doing."
- ??? 

The cheapest, fastest, and most reliable components are those that aren’t there.
- C. Gordon Bell

"When you test you find something is wrong."
- Donald Trump (May 14, 2020, about the COVID tests)

I would rather have a general who was lucky than one who was good.

- Napoleon Bonaparte

"Perfect is the Enemy of Good Enough"
- Eric Johns (October 1988), U.S. Naval Institute Proceedings: 37

“If an expert says something can be done he is probably correct, but if he says it is impossible then consider getting another opinion.”
- Richard Hamming, The Art of Doing Science and Engineering 

People who are really serious about software should make their own hardware.
- Alan Kay

The management question, therefore, is not whether to build a pilot system and throw it away. You will do that. […] Hence plan to throw one away; you will, anyhow.
- Brooks, The Mythical Man Month (Page 116)

Brooks's Law: 
Adding manpower to a late software project makes it later.
 - Brooks, The Mythical Man Month

... this was going to be one of these Onion Syndrome deals - you peel off a couple layers, and cry; then you peel off a couple more layers, and cry some more.
- Bob Pease, What's All This Ground Noise Stuff, Anyhow?

Thinking is recommended. Heck, thinking is required.
- Bob Pease, Troubleshooting Analog Circuits

... a little known tenet of precision op amp circuits: Williams's Rule.  Williams's Rule is simple: always invert (except when you can't).
- Jim Williams, Analog Circuit Design: Art, Science, and Personalities


"Any idiot can count to ONE ..."
- Quoted by Samuel Wilensky in Analog Circuit Design: Art, Science, and Personalities
(maybe attributed to Bob Wildar)

Anyone can build a bridge that stands up, but only an engineer can build a bridge that just barely stands up.
- ????

In real estate, it is location, location, location.  In mathematics, it is notation, notation, notation.
- ????

"A user interface is like a joke – if you have to explain it, it's not that good."
- ????
 
In software, debugging is harder than writing code.  If you write the code as clever as you can, then you are not smart enough to debug it.
- ????

... where there is no confusion there is no prestige.
-Linderholm, Mathematics Made Difficult

All problems in computer science can be solved by another level of indirection, except for the problem of too many layers of indirection.
-????

... practicing what was called "the mushroom theory of management." ... defined it as follows: "Put 'em in the dark, feed 'em shit, and watch 'em grow."
- Tracy Kidder, The Soul of A New Machine

Hardware eventually fails. Software eventually works.
-Michael Hartung

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.



Tuesday, January 21, 2025

NAND and NOR Flash

 The two types of flash memory devices, NAND and NOR, are familiar to people in tech.  Most people understand the difference between the two: the NAND flash memory is like a hard drive disc that is accessed sequentially and the NOR flash memory can be read randomly and is used for code execution.  Some are even aware that the NAND flash gets its name from the NAND gate and the NOR flash from the NOR gate.  Beyond that how exactly these flash memory devices work can be a little fuzzy.

Fundamentally, both types of Flash memory devices work under the same principle.  Each memory cell has an isolated floating gate to storage charges, which are programmed or erased by the hot-carrier injection and the quantum tunneling process.  The presence or the absence of charges on the floating gate changes the threshold of the transistor.  The difference lies how the cells are organized to achieve the desired the features.  Also the flash memory is erased one sector at a time while the EEPROM is erased one byte at a time.

We start with the NOR flash.  A cell is read by applying voltage to the WORDLINE, connected to the control gates of a row of transistors, from the row address decoder logic.  If the cell is written, the floating gate has negative charge and the device threshold is higher, so the channel connected to the source has higher resistance than the erased cell.  This difference can be sensed with a comparator.  Note the source of every memory cell has a connection the SOURCE node. To program a cell, a higher voltage (like 12V) is applied to the gate of the cell and a voltage (like 5V) is also applied to the drain.  The electrons flows onto the floating gate by the process of hot carrier injection, which the electrons gain enough kinetic energy from the strong electric field to overcome the bandgap of SiO2.  The cells in a sector are erased at the same time by applying a high voltage to the body well and the word lines grounded and the drain is left floating, so the electrons are removed from the floating gate through a quantum tunneling process.


The NAND flash has fewer connections.  Each memory cell only connects to the adjacent cell.  So the cells are packed more densely.  Now the question is how to read out individual cells.  The particular cell to be read has to pass information through other cells.  The key is to apply a high voltage to other cells so they act as passing transistors regardless the state of those cells.  The passing voltage is lower than the programming voltage, so the cells are not altered.  For the NAND flash, both programming and erasing are done with tunneling.  During the programming the NAND flash cell, the bit line is grounded and the source selector is turned off.

Now the question is why they are called NOR and NAND flash respectively.  If we look at the NOR and NAND gate, we only see a little superficial resemblance.  

The NOR and NAND labels do make a quick distinction of the two types of flash although the inner working has little to do with these logic gates.

The description here provides perhaps a sufficient understanding for some, while others might be curious about the details of the programming and erasing process in the device level, which we hope to explore later.