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.


Precision Bench Power Supply Project

2013-11-09 00.45.30I’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):

  1. 0-30V and 0-3A adjustable.
  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!

Link Roundup: Power Supplies and Dummy Loads

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

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

stm32f4 discovery hello word

I got a stm32f4 discovery development board recently.  It has a ST Micro stm32f4 ARM Cortex M4 SoC running at 168MHz and had a bunch of goodies including an st-link/v2 in-circuit programmer/debugger, break out of all the stm32f4 IO, a 3-axis accelerometer and more, all for less than $15!  Crazy!  Check it out if you’re getting bored with your Arduino.  However, the discovery isn’t quite as user friendly as the Arduino.  This post goes through getting the dev board “hello world” (blinking LEDs) up on the discovery from Mac OS X.

The target for the discovery is arm-none-eabi.  The first step is to get the toolchain up: binutils and gcc.  I used binutils-2.23 configured with –target=arm-none-eabi.  GCC depends on GMPMPFR, and MPC; install them if needed (in that order).  I used gcc-4.7.3 configured with –target=arm-none-eabi –enable-languages=’c’ –disable-libssp.  libssp is a stack protection library; it depends on libc, which we aren’t building.

The next step is build the IO_Toggle example from the discovery board firmware package. I used v1.1.0.  The firmware package has project files for various embedded development environments, but no Makefiles for gcc.  Here is the Makefile and linker script stm32f4xx_flash.ld.  These are based on the files posted at STM32F4 Notes, although his setup involved modifying the IO_Toggle source files and did not work out of the box for me.  Drop them both into the Project/Peripheral_Examples/IO_Toggle subdirectory of the firmware package and run “make”.  This should build IO_Toggle.elf.

Finally, we need a programmer to load the image onto the board.  I used openocd, which depends on libusb.  I used libusb-1.0.9 and openocd-0.7.0.  (libusb-1.0.16 was literally released while writing this.  I haven’t tried it yet.)  openocd was configured with –enable-stlink.

Finally, we can program the board!  In IO_Toggle, run “openocd -f board/stm32f4discovery.cfg -c ‘program IO_Toggle.elf verify reset'”.  The example should be up and running!

I don’t think any of this was specific to Mac OS X and the same story should work under, say, Linux.

This isn’t so exciting.  Baby steps.  Next up: Get gdb working with openocd.  How does IO_Toggle work?  What about the other peripherals?  More to come!


I’ve started playing with hardware recently: basic electronics, microcontrollers, Atmel AVR and Arduino, ARM, stm32f4, Beagleboard, PBC design, Eagle, FPGAs, Verilog, SATA, SMT, do-it-yourself reflow ovens, control theory, video, HDMI, …  The purpose of this blog is to document some adventures in hardware hackery.