Tuesday, December 10, 2024

Bandgap Reference

Does the bandgap reference really have anything to do with the silicon bandgap voltage?

The basic idea of the bandgap reference is to obtain a low temperature coefficient voltage source by cancelling the negative temperature coefficient of the diode forward voltage with the positive temperature coefficient of differential $V_{be}$.   The difference of the $V_{be}$ of two different size but otherwise identical bipolar transistors is $\Delta V_{be} = k T /q \ln \eta$ (PTAT), where $\eta$ is the current density ratio, k=1.38e-23, q=1.6e-19.  The diode voltage tempco is about -2mV/°C; to match that, $k/q \ln \eta $ = 2m, so $\Delta V_{be}$ = 600mV at the room temp.  And the diode voltage at the room temp is also about 600mV.  So the output is about 1.2V, which they say is close to the silicon bandgap voltage (1.166V at 0K).  But the essential scheme does not really seem to depend on it.

Update:

Recently I watched a lecture by A. Paul Brokaw,  "A Transistor Voltage Reference, and What the Band-Gap Has To Do With It", 1989.  He gave the clearest explanation that I've ever seen.  PTAT ($\Delta V_{be}$) and CTAT ($V_{be}$) with the right proportion add up to the constant reference, and at 0K, PTAT is 0V and $V_{be}$ is equal to the bandgap voltage.

VG0 is the silicon bandgap voltage, Vbeo is the base-emitter voltage at temperature To. 


Thursday, December 5, 2024

Logarithmic Amplifier Compensation

A logarithmic amplifier is based on the exponential relationship between the collector current and the base-emitter voltage.  It is also an opamp circuit that has a gain in the feedback path, so a unit-gain stable opamp may not be stable.  It is necessary to add phase compensation.

Here is the simple logarithmic amplifier circuit and we derive the loop gain,

We will use OP-41 as the opamp. OP-41 has a typical DC gain of 134dB and gain-bandwidth product of 500K (ω1 = 3e6).  That puts the dominant pole at about 0.1Hz.  A high order pole above 1MHz leads to a phase margin of about 77 degrees.  This is typical of an internal dominant pole compensated opamp.  As we can see the loop gain plot is shifted up, the phase margin is reduced.

We place a capacitor across the collector and the emitter as compensation.  The capacitor adds a lag network.

With the zero a decade below the cross over frequency (Rs C > 3us), this results in an improved phase margin (back to near the unit-gain phase margin).

We have ignored the junction capacitance from the npn transistor.

We compare these with simulations.  We model the opamp as a two-pole transfer function.  The input current is 1mA.  The feed back has a gain of 40 or 32dB.


The phase margin is 8° without compensation and 50° with a 22n cap.  The zero and the pole are at the estimated location of 7.2KHz and 280KHz.

The compensation can be improved, which we will discuss in a later time.

Tuesday, December 3, 2024

Pen Drawing Tablet

XP-Pen Star G640 drawing tablet, 6x4", 8192 pressure levels, battery free stylus with two push buttons, resolution of 5080 LPI, for $25

It works on the electromagnetic induction principle.  

From the teardowns that other people have shown on the internet, the stylus is entirely passive with a coil and capacitors, that would exclude any encoding scheme.  The working hypothesis is that the tablet will transmit a signal to excite the LC tank, the LC tank oscillates and signals get picked up by the tablet.  The working area of the tablet is a PCB with horizontal and vertical traces.  The position of the stylus is calculated perhaps by centroiding on the signal strength.

The pressure level is transmitted probably by frequency modulation.  There is a ferrite on the rod that the nib is attached and the rod is pushed on a spring.  The pressure on the nib moves the ferrite relative to the coil, changing the resonant frequency.  And pressing the button connects additional capacitor to the tank, also altering the frequency.

We will try to verify the working principle without disassembling the stylus or the tablet.  We will use a simple wire loop to pick up the signals.

Without the stylus on the tablet, we pick up some signal from the tablet.   It is possibly just a 500KHz square wave ac-coupled.

 When the pen is on the tablet, we see the oscillating LC signal. 


We can take a close look at the frequency of the oscillation,

Zooming in at the peak, we can see the difference in the rising envelop when the tablet is driving and the falling envelop when the stylus is free oscillating.

At pressure level 0, the frequency is about 506KHz, and at the max pressure of 8192, the frequency is about 530KHz.  So the circuitry has a resolution of 3Hz.  When the upper button is pressed, the frequency is 484KHz, and the lower button 464KHz.  And the frequency changes from there if pressure is applied while the button is pressed.

We can make a circuit model and run simulation to compare with the measurements.


We will design a frequency to voltage conversion circuit to extract the pressure level in a future blog.

The stylus is detected with the tip about 1cm above the tablet; there is some hysteresis on that distance.  Placing the stylus flat lengthwise on the tablet  does not work, but vertically flat widthwise works.  This is a little curious; perhaps the excitation is only generate by traces in one direction.  It may be a deliberate design choice, because the stylus can be left on the tablet without affecting other pointing devices.

When we place a ferrite toroid around the stylus, the tablet can register button clicks with buttons being click.  This implies that the presence of the ferrite toroid lowers the resonant frequency to be in the range of that of button click.

Thursday, November 21, 2024

NVMe on Raspberry Pi 5

Raspberry Pi 5 introduced a PCIe connector (16-pin 0.5mm FFC) in the place of the under-utilized display connector.  Now it is possible to use an NVMe SSD.  It would require a PCIe to NVMe adapter, which can be purchased for about $7 and comes with a board to mount an M.2 M-key NVMe SSD for size 2230/2242/2280 and a flexible flat cable to connect to RPi 5.  
Download the OS image.  xzcat | dd to the disk.  Two partitions are created and take up about 14GB.

The default EEPROM `BOOT_ORDER=0xf416`, the boot order should be NVMe, SD Card, USB.  But it still boots the SD card first.  With the SD card out, the RPi 5 boots from the NVMe.  The root partition is near full.  Use parted and resize2fs to grow the root file system.

A sustained read/write speed is 390MB/s read and 440MB/s write, which is better than the USB NVMe adapter 260MB/s read and 380MB/s write, but not dramatically.

The RPi 5 PCIe is rated for Gen 2 one-lane; the maximum throughput is 500MB/s.  

In config.txt, add `dtparam=pciex1_gen=3` to enables PCIe Gen 3 (1GB/s).  The reliability of the Gen 3 operation is not guaranteed, but it appears to work well.  The read speed is increased to 850 MB/s; the write speed is largely unchanged.  The disk is rated at up to 1700MB/s for sequential read and up to 1000MB/s for sequential write.  So the read speed is close to the bus speed, but the write speed is under performing.

The board averages about 1.2A/5V during writing.  The average idle current is 0.7A (without SSD, 0.6A).  With the NVMe SSD, the Raspberry Pi 5 does not shut down completely, still drawing 170mA despite of setting POWER_OF_ON_HALT=1 and WAKE_ON_GPIO=0 (without SSD, 4mA).

The PCIe interface appears to have some interference on the WiFi signal.  This FFC has no ground plane, which probably radiates more. The on-board WiFi has trouble picking up relatively weak signals.  Other people have reported similar issue.  The WiFi does work when it is close to the router. 

Thursday, October 31, 2024

Nano Ammeter

One of "self-explanatory" circuits in AoE2 is a nano-ammeter circuit; no explanation is given.  I doubt it is really self-explanatory to a beginner.

This circuit appears to originate from PMI's OP-41 datasheet.  (PMI is Precision Monolithics, Inc which later became a part of Analog Devices.)  OP-41 is a JFET input opamp with very low input bias (5pA @ 25C) in the inverting configuration as a logarithmic amplifier.  (OP-41 also tauts the excellent CMRR of over 100dB for a FET input opamp.)  Q1 and Q2 are matching transistors.  Their current ratio is the exponential of the difference in Vbe. If the difference in Vbe is proportional to the temperature, the current ratio is constant.  Since the Q1 base is grounded, the difference in Vbe is just the Q2 base voltage.  The resistor divider provides the Q2 base voltage that is proportionally to the temperature, as the bandgap reference subtracts the diode connected Q3 to produce a voltage is approximately proportional to Vt (although there is more complex 2nd order temperature dependency).   How good is the approximation?   We can run a Spice simulation stepping the temperature.  The Q3 current is about 65uA at -55C and 115uA at 125C and approximately linear  I (uA) ~ 0.28 * T (K) . 


The trimmer adjusts the full scale value of the current meter. 

Also the compensation network requires some explanation, which is deferred to a separate discussion.

Thursday, October 3, 2024

Quotes

"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)

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.
- ????

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

Sunday, September 29, 2024

Common Emitter Frequency Response using EET

Even the simple common emitter circuit can result in some pretty complicated expression for the frequency response. The inclusion of a single element, the base-collector capacitance, introduces much complexity.  This circuit is analyzed in detail by most of the textbooks, including Gray & Meyer's.  None of them makes use the EET.  We give a derivation using Middlebrook's EET to see if the analysis is simplified.


 We work out the factor involving Cf,


This is a little bit less work than the more direct method,

The two methods produce the same expression, so using EET does not give more insight.  

The base-collector capacitor results in an additional pole and a right-hand side zero and shifts the dominant pole.  The dominant pole can be approximated from the input capacitance and the Miller capacitance.


Wednesday, September 25, 2024

Useful Circuits with Two Transistors

The preeminent circuit designer Barrie Gilbert asks "How many distinctly different and really useful circuits can be made with two transistors, anyway?"  and his answer "about twenty-four" (Williams, Analog Circuit Design, p179).  Let's see what they might be.  It is perhaps subjective to tell what is useful or different.  Also what type transistors, BJT, JFET, MOSFET?  Same circuit configuration with different type of transistors should not be considered distinct. What about other circuit elements?  Assume the passives, resistors, capacitors, inductors, are OK, but what about diodes? And what about a multi-emitter/collector transistor or a dual-gate MOSFET?  Is it considered one transistor or multiple transistors?

A single transistor has three basic amplifier configurations; it can also be configured as a diode, and the emitter-base junction also makes a somewhat usable Zener diode.  A JFET makes a good current source (current regulating diode).



Monday, September 23, 2024

Input Impedance of a Bipolar Transistor Bias with Feedback

AoE shows a bipolar transistor bias circuit using feedback from the collector.  AoE2 and AoE3 show the identical circuit, but they differ in the values of the input impedance: AoE2 states 300 Ohms and AoE3 200 Ohms.  We would like to analyze the circuit to see why the value has changed.  Here the base bias is established by a resistor from the collector, which has the effect of negative feedback: a high bias lowers the collector voltage that reduces the base voltage.  


Here we estimate the collector current to be about 1mA.  The input impedance is about 200 Ohms for a beta of 100; it does not exceed 225 Ohms as the beta goes to infinity.  So it seems justified that AoE3 makes the correction.   Even when the temperature varies, the input resistance stays relative constant.  For example, if T = 100C, VT = kT/q = 32mV, but because Vbe decreases with increasing temperature, the emitter current also goes up, Vbe = 0.4V, Ie = 1.34mA, gm is still around 1/25 A/V.


Wednesday, September 18, 2024

N Light Switches

AoE2 has an exercise asking readers to wire up N switches that any one of the switches can turn on or off a light bulb.   It comments that every electrician knows how to do this, but few electronic circuit designers do.  Given the hint that it requires 2 SPDT and N-2 DPDT switches, it is not hard to do.


This exercise is retained in AoE3.

Tuesday, September 17, 2024

A Current Source Circuit from AoE-X

H&H show a clever current source circuit and challenge readers to prove the circuit works especially without using two of the constraints.

It is a circuit of an opamp driving a bipolar transistor.  The base current of the bipolar transistor would normally cause an error.  Here the error is compensated.  The base current is sensed with the base resistor kR1; the emitter voltage is Vin with the differential voltage added using a circuit configuration resembling a difference amplifier.

Note that the current through R1 is the sum of the collector current, the base current and the current through R2, which the last two are the current through kR1.  The derivation makes no use of the constraints on the resistors.  The base current compensation is strictly accurate (assuming ideal opamp).

Friday, August 2, 2024

Home Lab On the Cheap

Computer: Raspberry Pi 4B ($50), Atomic Pi ($35), OrangePi Prime ($35)
Atomic Pi only has 2GB RAM, which limits its use; but it is PC compatible.  It is usable with a decent USB drive.  Raspberry Pi 4B is usable.  They all can run KiCad for PCB design.  Atomic Pi can run LTSpice.

Multimeters: ANENG AN8008 DMM ($20), ST213 Clamp meter ($20),  Cen-Tech/HaborFreight multimeter ($5), LCR-T4 ($6)
AN8008 gives pretty good voltage and resistor measurement but the current measurement is not reliable at high range. Cen-Tech's current measurement is good enough.  And ST213 is for high current.  LCR-T4 is also good for verifying component values and the firmware is open source.

Soldering Station: TS100 solder iron ($40 with coupon), Chandler Tools heat gun HG603D ($24), PCB Holder fixture ($4)
TS100 is pretty decent.  There is an open-source version of the firmware. It is portable with a battery pack.   I also got 3 more soldering iron tips for about $4 each: TS-KU, TS-JL02, TS-C1 in addition to TS-D24.  The 320W heat gun with two speeds works well.  The PCB holder works for small boards.  A Harbor Freight "Helping Hand" with two alligator chips and a magnifier is somewhat usable after I secured the base with a plate. 

Caliper: iGaging EZCal digital caliper ($29)
It has a nice large display and works except for the battery life.  It is relatively a little pricey.

Scale: Digital Jewelry Scale ($4)
200g range, 0.01g resolution.  It seems accurate.  Good for weighing small components.

Rotary Tools:  HarborFreight Chicago rotary tool set ($5)
This is a cheap tool, barely usable.  I power it with a variable voltage power adapter to make it somewhat usable.

Lights: Desk lamp with magnifier
It had a fluorescent lamp, but burnt out.  I installed 10 1W LEDs.  It works very well.

Hand Tools: Set of pliers, wire strippers, set of small screw drivers, nibbler, diagonal wire cutter, tweezers, 6" ruler in SAE and metric ($3 for 2), Dental picks and mirror ($6)
A Harbor Freight 16 in 1 electronic repair kit was inexpensive ($5) and usable.  A small diagonal wire cutter is very nice to have. 

Monday, July 15, 2024

ANENG ST213 Clamp Meter

For a total of $20.57, I received the ANENG ST213 Smart Digital Clamp Meter in 4 days (not bad for free delivery from China).  I have an ANENG AN8008 multimeter, which I have been generally pleased with.  I want to add a clamp meter to my measurement tools.

The meter looks slick and feels comfortable holding it.  It comes with one set probe and a K-type thermocouple.  The probe looks decent.  It takes two 2 AAA battery cells (not included).   If the battery voltage is less than 2.6V, the low-battery sign shows.  So NiMH batteries would have trouble staying above 1.3V per cell, but it probably still is functional at lower voltages.  Press the power button for two seconds to turn on.  The meter is in the auto mode, displaying temperature in Celsius and Fahrenheit (this is from the meter's internal temperature sensor since the thermocouple is not connected), which seems a little excessive to display the temperature so prominently when the thermocouple is not used.  There is an LED light at the top, which could be useful in the dark.

The "Smart" feature of the meter is that it tries to automatically determine what is being measured, AC/DC voltage, resistance with continuity beep, frequency and AC current.  But for resistance measurement, it is necessary to inject a signal, so the meter starts with voltage measurement and if the voltage is less than 0.5V, it switches to resistance measurement.  For low voltage measurement, it is necessary to manually select the mV measurement.  In many cases, it is probably not good to inject a signal and there is no way to manually select voltage measurement, which is the main deficiency of this meter.  And all measurements are autorange, no manual range selection.  This meter uses a single button for measurement selection and does away with the wheel, which can be a source of unreliability.

For voltage measurement, below 6V, the resolution is 1mV, which is good that the 5V circuit can be measured to 1mV unlike other meters that only go to 4V for the same resolution,  between 6V and 60V, the resolution is 10mV, and above 60V, 0.1V.  The voltage measurements generally agree with Fluke 87 DMM to 0.1-0.2%.  The accuracy holds up well above 100V.  

The resistance measurements agree with Fluke to 0.5%.  The meter beeps when the resistance is below 50Ω, which could be annoying.   Up to 0.5V could be applied.

For AC voltage, the RMS measurements seem good to 1KHz, with 3dB bandwidth around 3KHz.  The measurements agree with the Fluke to 0.6% below 1KHz.  The Fluke is still good at 10KHz with 3dB bandwidth over 100KHz.  Above 1V RMS, the frequency measurement works down to 6Hz; the resolution is 0.1Hz below 1KHz.

The main feature is the current measurement.  Below 0.3A, the current measurement is not useful; between 0.3 to 1A, the measurement error is around 10%.  Above 1A, the measurement error is about 2-3%, which is meeting the stated accuracy of +/-2.5% +/- 30 digits.  The initial offset can be nulled by pressing the REL|NCV button.  Note that it is possible to improve the low current measurements by looping the wire a few times around the clamp.  The jaw open to about 1".

For AC current measurement, the reading is 0 when the current is less than 0.6A and it is not expected to be accurate below 1A.  For a 100W light bulb, the Fluke reads 0.8A and this meter 0.63A.  When the Fluke reads 1.279A, this meter reads 1.15A, off by 10%.

It can also measure diode voltage and capacitance as well as Non-Contact Voltage (NCV) detection.  The max test voltage is 3.268V, and the max test current is about 2mA.  The test current is not constant, decreasing as the voltage increases.  The max diode voltages is about 3V, at which the applied current is about 0.16mA.  The capacitance measurements have a wider range than the Fluke, agreeing to about 5%.   The NCV detection beeps when coming near a live AC wire (>90V).   The Live wire detection uses only one probe; the actual detection threshold seems 1Vpp (tested with both probes connected).

Dipping the thermocouple into molten solder, the temperature reading is 180C, which is about the melting point of 63/37 Sn/Pb solder.

This meter may be useful around the household and for automotive work, but not that good for lab electronics, especially because it cannot be locked in the voltage mode and making low current measurements.


Friday, June 28, 2024

Damaged Current Shunt Resistor in Cen-Tech Multimeter

The 20mA range current measurement stopped working on my Cen-Tech multimeter.  The other current measurement ranges still worked.  I suspected a damaged current sensor resistor, which is about 10Ω.  I opened up the meter and quickly identified a 9Ω resistor which was measured open.  And the discoloration indicated damage, which was probably a result of overcurrent.  A nearby 1Ω resistor also showed some discoloration, but was still intact.  The resistor is of size 0805, which probably has a power rating of 1/4W or less.  So the maximum current is 167mA at this rated power.  The fuse is rated 500mA, which would not be able to protect the resistor.  Once the resistor was replaced; it worked again and was checked against a Fluke 87 multimeter, the measurements are within 20uA of each other around 20mA, or 0.1%.  When it is compared with a Fluke 87, the Fluke uses a 0.991Ω 0.1% 2.5W resistor for mA range current measurement.  The maximum current is 1.6A, which is greater than the 1A fuse rating.


Monday, April 22, 2024

EBL Gold Pro AA NiMH 2800mAh rechargeable

EBL Gold Pro AA NiMH 2800mAh rechargeable low self discharge battery (90% after 3 years) , weighs 28.90g, costs about $1.87 per cell, or 1500mAh per dollar, which relatively inexpensive compared with other brands (Amazon Basic 1290mAh per dollar, Energizer 890 mAh per dollar, Eneloop 460mAh per dollar, POWEROWL 1320mAh per dollar).

Multiple users have showed that the actual capacity of EBL 2800mAh battery is only about 2400mAh.  The discharge rates for their tests are probably high to keep the testing time short.  Here we measure the capacity by discharging it at a low rate with an 80-Ohm resistor load.  We record the voltages over time and calculate the current and integrate to get the capacity.  At the average discharge rate of about 15mA, we expect it to take 7-8 days.  First it is charged from 1.28V for about 2hrs at 0.3A to 1.440V, which drops to 1.365V after about 1 day and 1.350 after 2days without load.  Then the measurements are taken with load.  It is fully discharged in about 150hrs and the capacity is 2338mAh.  More appropriately, the capacity is 2865mWh.  (Or 2388mAh if divided by the nominal 1.2V.)  In any case, it is only about 85% of stated capacity, consistent with other user reports.  Using the measured capacity, the cost is 1250mAh per dollar, on par with the Amazon Basic.  The big brand name batteries are rather overpriced (perhaps they are better in the number of charge cycles or internal resistance).

In a real-world test, it is compared to an Energizer 800mAh AAA NiMH battery (NH12 HR03) in a wireless mouse.  The Energizer AAA battery lasted about 1 month and the EBL AA battery lasted two months; tests were run twice and the results were similar.  This would imply that the EBL AA is only around 1600mAh, which is a huge disappointment. However, a Panasonic AAA eneloop 750mAh only lasted about half a month, which is a little surprising; if this is accurate, the EBL AA would have 2800mAh as advertised.  More testing underway.