# Electronics Component Inventory

The question of how to keep track of your electronics components comes up a lot, see for example here or here.  The most frequently suggested solutions seem to be ecDB (demo available) and PartKeepr (demo currently down).  Neither has distributor integration and they both expect you to enter parts by hand.  I just don’t have the patience, so that’s a deal breaker for me.

Stupidly, I started working on my own solution.  I wrote some code (python + BeautifulSoup4) to scrape Mouser View Orders, View Order and Product Detail pages into  a Django database, and scraping Digi-Key is partially done (the two main distributors I use).  At least I can get a list of all the parts I’ve bought.  I plan to add a simple but functional front-end (web design is not my thing) and some kind of BOM support.  Get in touch if you want to help.

edit: zParts and tehologistics (on github) also possibly interesting.

# Linear Regulator

In an earlier post, I introduced a project to design a precision bench power supply.  In this post, I describe a prototype linear regulator design with constant current control.  Here is the schematic:

(Please forgive the poor artistic skills.)

The design is straightforward.  The opamp U1A regulates the voltage at the load by adjusting the gate voltage of the pass transistor Q1.  The 0.2ohm resistor R1 is a high-side current sense resistor.  The voltage across R1 is fed into a 10K/390 = 25.64 gain differential amplifier.  The opamp U1D and the transistor Q2 pull down the gate voltage to maintain the current limit.  Note, this is negative feedback, since increasing the Q2 gate voltage lowers the Q1 gate voltage and hence the load voltage.  For the prototype, I used:

• MCP4912 12-bit SPI-controlled DAC with Vref = +5V
• Q1 is a Fairchild MTP3055VL
• Q2 is a BS170
• U1 is a MCP6004 quad opamp
• it is controlled by an ATmega MCU

For what it is, the circuit seems to work nicely.  Here is an LED being driven with a 20mA constant current limit:

This circuit will require major improvements to meet the target precision and voltage range 0-30V.  The 12-bit DAC gives a resolution of ~7mA, which might be good enough.  I plan to replace the discrete differential amplifier with a TI LMP8640 High-side High-voltage Current Sense Amplifier.  A precision voltage reference will be needed for Vref.  Finally, there is the question of how to drive the high-side FET.  The MCP6004 is a single supply opamp up to +5.5V.  One option is to have a +36V or so supply voltage.  Finally, there is the subject of the controller stability and performance.  Is it stable?  What is the transient behavior like, overshoot and settling time?  What is the input noise immunity (e.g. from switching noise)?  I will return to these subjects in a later post.

This post is a poor man’s bookmark.

# Precision Bench Power Supply Project

I’m going to try to design an open source programmable precision bench power supply.  There are plenty of power supply designs floating around (see my recent link roundup), however, I’m not aware of any designs that compare with even low-end professional grade power supplies.  I’m going to loosely base my target specs on the \$409 Rigol 832 (without the precision upgrade):

2. 10mV and 1mA resolution.
3. The usual over current, over voltage and thermal protections.
4. Quantified regulation accuracy, transient and programming response, and thermal and temporal drift, again, initially aiming for something like the Rigol 832.

I would like the design to be modular in the sense that the above specs could be improved by choosing higher precision components, larger heat sinks, etc.  I’m going to aim for a single channel to start but, again, I’d like a modular design that makes it relatively easy to support other channel configurations.

I will aim to produce the following:

1. A discussion of the design (as a series of blog posts to start), including background theory and trade-offs.  This should make it easy for others to modify the design for different goals.
2. A complete set of design files, firmware and instructions so anyone can build a power supply for themselves.  There may be a few versions of this (TH vs SMT, multiple channels, higher precision, etc.)

Depending on how successful the design is, interest, etc., I might try to sell bare PCBs, kits, or maybe even a finished product.  That’s still a long way off.

I plan to break the design process into several stages.  To begin, in order to avoid the complexity of working with mains power, I plan to start with unregulated DC input.  This can either be provided by a wall wort, step-down transformer, rectifier and filter, or, in my case, a switching ATX power supply I have lying around.  To avoid a huge transformer and minimize the need for heat management in the final design, I plan to use a design which cascades a switching pre-regulator with a linear regulator.  This is the design I have been prototyping.  Pictured is prototypes of a microcontroller controlled non-inverting buck-boost converter, linear regulator and programmable dummy load.  I realize it might be prohibitive to filter the switching noise to achieve high accuracy regulation, in which case I will modify the design when I get more experience.  I will describe the circuits in more detail in coming posts as I continue to flesh out the design.

Thoughts?  Let me know!

# Impedance 1: Fourier Analysis

You won’t get very far in electronics without understanding the concept of impedance.  Loosely speaking, impedance is generalized frequency-dependent resistance.  To understand what that means, we need to review the basic ideas of Fourier analysis.

Let $g(t)$ be a complex-valued function of time, measured in seconds.  In Fourier analysis, we say $g$ is a time-domain function because, well, the domain of $g$ is time.  The basic idea of Fourier analysis is that $g$ can be expressed as a sum of complex exponentials $e^{2\pi ift}$ oscillating at frequency $f$ in Hertz.  Namely,

$\displaystyle g(t) = \int G(f)e^{2\pi i f t} df$.

The function $G(f)$, which denotes the contribution to $g$ of the exponential oscillating at frequency $f$, is called the Fourier transform of $g$.  We will also write $\mathcal{F}\{g(t)\}(f)$ for the Fourier transform $G(f)$.  It is given explicitly by the formula

$\displaystyle G(f) = \int g(t)e^{-2\pi i f t}\,dt$.

When $g(t)$ is periodic with minimal period $T$, that is, $g(t) = g(t + T)$ for all $t$, then the situation is simpler.  The Fourier transform is non-zero only for integer multiples of the fundamental frequency $f_0 = 1/T$.  The coefficients $G_k = G(k f_0)$ are called the Fourier series of $g$, and we can write

$\displaystyle g(t) = \sum_k G_k e^{2\pi i f_0 k t}$.

Finally, the Fourier transform enjoys some nice properties.  First, by linearity of the integral, the Fourier transform is also linear:

$\displaystyle\mathcal{F}\{ag(t) + bh(t)\}(f) = a\mathcal{F}\{g(t)\}(f) + b\mathcal{F}\{h(t)\}(f)$,

where $g, h$ are complex-valued functions and $a, b$ are complex numbers.  Second, it behaves nicely with respect to the derivative:

$\displaystyle\mathcal{F}\{f'(t)\}(f) = 2\pi i f \mathcal{F}\{f(t)\}(f)$.

What does this have to do with electronics?  More on that next time.

I’ve been thinking about bench power supplies and programmable dummy loads of late.  Here is a collection of links on the subject.

The simplest idea is to break out the outputs of a ATX computer power supply.  See, for example, Dangerous Prototype’s ATX Breakout Board.

Next level of sophistication is to use a computer power supply or wall wart to feed a linear regulator like a 78xx or LM317 adjustable with a pot.  These designs usually use voltage and current meter modules for the display.  This can give you a adjustable supply up to 30+ volts and a couple amps.  Here are two examples.

There are two ways to go from here.  The first is to drop the meter modules and control the supply with a microcontroller using some kind of DAC solution to generate a reference voltage supply.  The other way to go is to design the linear regulator explicitly using a power transistor as a pass element controlled by an op amp negative feedback loop.  With an explicit regulator, it is easy to do constant current/current limit.  Dave’s many-part power supply design series (part 1 of many) over on the EEVBlog is a must watch.  His design is based around the LT3080 but has a constant current control loop.  Here is an example with an explicit regulator (part 2, part 3).

There are many more designs floating around the internets.  Enough to drown in.

These designs are quite far from even a low-end precision bench power supply like the Rigol 832 or similar.  These isn’t a lot of discussion of their accuracy, precision or transient response to varying loads.

Switching power supplies for computers generally have the following architecture: (1) EMI filtering to protect the grid from regulator noise, and vice versa, (2) power factor correction (PFC) which makes the power supply look like a resistive load to the grid, (3) an isolated switching converter controlled by something like the TI TL494 PWM Controller, and finally (5) output filtering.  On Semi has a 255W ATX power supply reference design.  Dave did a teardown of a 40A bench power supply that has a very similar design.

To test a power supply, you need a programmable dummy load, which can draw constant (or programmable) current or power.  The Arachnid Labs Re:load 2 is a classic design using explicit linear regulation and is for sale on Tindie.  It can handle up to 3A or 40V and dissipate 20W.  However, the load is controlled by a pot and is not programmable.  Kerry Wong build a similar device and has a new design which is microcontroller controlled.  A dummy load necessarily has to dissipate the load as heat and the main challenge, besides precision regulation, is finding a big enough heat sink.

Finally, I’ve been reading The Fundamentals of Power Electronics and Power Electronics: Converters, Applications and Design to learn about switching converter design.  More on this in future posts.

# STM32F103 breakout board

When I prototype a simple design requiring a microcontroller on a boardboard, I often pop in an Atmel AVR in a DIP package.  When I also need easy connectivity over USB to a host computer, I use the SparkFun Pro Micro, a simple DIP breakout board for the ATmega32U4.  I like the form factor of the Pro Micro, but lately I’ve been moving away from the AVR in favor of the STM32.  So I decided to design a simple DIP breakout board for a small member of the STM32 family.  I chose to base the design on the STM32F103 in a 36-pin VFQFN package.  The board features microUSB (the power source), a 300mA 3.3V Microchip voltage regulator in a SOT-223 package, two LEDs, a 12MHz crystal for the high-speed external clock, a reset button and one user-defined button.  The LEDs and all passives are 0603.  The entire board is 0.7in by 1.4in.  I break out GND, VCC, NRST and all the IO pins, including those wired to the LEDs and push button.  I used Hackvana to fab the design.

I’ve tested all the functionality of the board and it works as designed with one errata: I missed a pull-up resistor in the USB interface which I patched by hand (not pictured).

Soldering the VFQFN was a challenge.  I made three boards and the first two had some bridging on the STM32 part after reflow which I was able to clean up with solder wick by hand.

I’m planning to respin the board with a few changes.  In addition to fixing the USB problem, I’d like to move to the 48-pin UFQFN, make the board slightly longer to break out the additional IO, add an external crystal for the 32KHz RTC oscillator, and break out VIN so the board can be powered without USB.  Any other suggestions?

If and when I’m happy with the updated board, I plan to release the design files and make some extra for sale.