Wednesday, February 29, 2012

Boost for LEDs

I need to light the inside of a trailer used to haul camping equipment for my son's Boy Scout troop. I've discussed this with the adult quartermaster at some length. We have agreed small white LEDs placed about every 30cm around the top inside perimeter should provided sufficient illumination without being so bright as to completely ruin night vision. 
My original idea was to to use an LM317 regulator configured as a current source to drive two groups of two LEDs (four LEDs per regulator). My previous blog entry discussed one way to achieve this.  That design had several problems.
  • Needs 11.1V to operate at worst case corner.
  • Lots of wiring needed to connect LEDs to regulator.
  • Several regulators needed around the trailer.
I decided a better design would include a DC-DC boost regulator to boost the battery voltage to 40V. Two LM317 configured as current regulators would then each drive a string of eight LEDs with 20mA current as shown in the schematic. I chose 20mA because the LEDs are sufficiently bright at that current and it is significantly below the maximum specification of 35mA. Eight LEDs at the maximum forward voltage of 4.4V still allow 4.8V of dropout in the current regulator.

The 40V supply could be provided from a capacitor charge pump or a switch mode chip. Since I want to actually design and implement the circuit myself, I chose to ignore these simpler, cheaper, and more rational alternatives. Basically, I want to solve this problem using a switched-mode boost converter because I've never designed or worked with a switched-mode boost converter. I expect to learn some things along the way. So let's dive into a switch mode DC-DC boost voltage regulator from components.

First, the most important stage of any design, the specification. You can't design something if you don't know what you're designing.

Parameter Minimum Typical Maximum
Input Voltage 10 V 13.8 V 20 V
Output Voltage 40 V 44 V 48 V
Output current 36 mA 40 mA 44 mA

That's all that really matters. The input voltage minimum and maximum are somewhat arbitrary. The output voltage needs to be at least 40V to allow for the worst case corner, +/-10% seemed reasonable, so I set the maximum 20% higher. The frequency should be higher than 200Hz so any brightness variation isn't visible.

The schematic you find plastered all around the internet is shown here. It is wonderful if what you want to do is discuss operation principles or interview someone. It is woefully incomplete if you want to design a regulator.

Oversimplified boost schematic

The next schematic is what I've put together to actually design from. It is largely gathered from a special topics course Dr. Abhiman Hande taught at UTD during the fall of 2008, I am especially leaning on Ian Lopez's excellent final report. I know using a MOSFET instead of the schoktty diode would improve the efficiency, but I am sticking with that simplification for now. 
Simulation schematic


Let's do some calculating.

The duty cycle is D ≈ (Vout−Vin)/Vout = 50-79%, 69% typical.

The minimum inductor size needed stay in continuous conduction mode
L ≥ (Vout D (1−D)2)/(2 Iout f) = 4.8mH I choose 6.8mH.

The minimum capacitor to keep the output ripple to less than, say, 1V
C ≥ (Iout D)/(ΔV f) = 0.035μF choose 1μF because I have several of that size laying around.

fc = 1/(2 π √(LC)) = 1.9kHz

Let's zoom in on the compensator. The textbooks refer to this as a "Type III" compensator. I'm used to it being a "PID" controller. Whatever you like to call it, I certainly need the feedback circuit.
Compensator schematic

Compensator values
Parameter Formula Numbers Result Std Value
R1+R2 Vout/Iref 44V/1mA 44kΩ
R1 Vfb/Iref 1.2V/1mA 1.2kΩ 1.2kΩ
R2 R1+R2 - R1 44kΩ-1.2kΩ 42.8kΩ 43kΩ
fp1 fc*7.5 1.93kHz*7.5 14.5MHz
C2 1/(2 π R22 0.04) 1/(2*3.1416*43kΩ2*0.04) 2.17nF 2nF
fp2 1/(2 π CL CESR) 1/(2*3.1416*1μF*0.5Ω) 318kHz
fz1 fc 1.93kHz 1.93kHz
R3 (fz1*R2)/(fp2-fz1) (1.93kHz*43kΩ)/(318kHz-1.93kHz) 261Ω 270Ω
C1 1/(2 π fp2 R3) 1/(2*3.1416*318kHz*270Ω) 1.92nF 1.8nF
fz2 fc 1.93kHz 1.93kHz
R4 1/(2 π fc C2) 1/(2*3.1416*1.93kHz*2nF) 41.2kΩ 43kΩ
fp3 0.75 fsw 0.75*100kHz 75kHz
C3 1/(2 π fp3 R4) 1/(2*3.1416*75kHz*43kΩ) 49pF 51pF

Two useful pages that list standard resistor and capacitor values.
fp2 is set the cancel the ESR zero. At least that's what the textbooks say. The capacitor ESR isn't a specified parameter, so it could be much higher or lower than this. But the pole needs to be set somewhere, so here it is.
fz1 and fz2 are set to cancel to cancel the poles at fc (1.6MHz).
Set fp3 to about 3/4 the switching frequency.
C2 should be much larger than C3

Some AC simulations are needed to verify this. But I'm impatient so I throw together a quick transient simulation just to do a quick check. And all you out there who know boost regulators already know the results. Vpwr=Vbatt-Vdiode. The problem is that if no switching is going on, it doesn't matter how the comparator is hooked up, the power transistor is either on or off and the feedback never crosses the reference. If switching isn't happening, it never starts. 

I didn't find any good references discussing this start up issue, so I'll have to figure a good solution myself. One quick solution is to simply ramp the reference voltage slowly. The current compensator and transient simulation is shown below.

compensator with ramped Vref

slow start-up, but at least it goes
There is much more switching noise than I expected, so I really need to verify those AC parameters. 

Looking at this start-up scheme, I also need to have a way to re-awaken the oscillations if they stop for some reason. Oh, well, more design work yet to be done! 

My son's Boy Scout Eagle project is this weekend and I have a short contract starting Monday so the next few entries here will be a bit brief. 

Until next week,
Bruce McLaren

Tuesday, February 21, 2012

LEDs Inside a Trailer

White LEDs are a good choice to light the inside of a boy scout trailer. They are low power. They do not produce too much light. They are inexpensive. They can be operated from a 12V battery. They are physically resilient.

The schematic shows four units of four LEDs and the associated circuitry. The unit can be repeated as many times as needed (four in this schematic). The LEDs are arranged in two parallel stacks of two series LEDs (2S2P). A stack of two LEDs will always operate with a battery voltage as low as 11.1V (4.4V for each LED, 1.3V across the resistor, 1V dropout). Two stacks will match close enough for this application while keeping the total current through the regulator below half it's rated capability. The LM317 is a nice adjustable regulator that I am using as a linear current regulator. Using a 33Ω resistor across the 1.2V reference results in 36mA of current. 

Schematic of four four LED units.


To implement this design, I obtained the following from Mouser. I bought 1000 resistors, so they are essentially free per piece. Each four LED unit costs $1.41, 16 LEDs costs $5.64.

Manufacturer Description Part Number Price
Cree White LED CP41B-WGS-CK0P0154 $0.30
Fairchild Adj. Regulator LM317LZ $0.17
Xicon 33Ohm 1/4W, 5% 291-33-RC $0.009

Construction

I breadboarded this circuit to get an idea of the brightness and so I would have a reference to drop LEDs into during construction to verify which direction they are pointing. I find these square LEDs difficult to orient.

One four LED unit on a breadboard.


The troop's adult quartermaster and I decided one light placed approximately every 30cm would be enough illumination for unloading the trailer at night. When I started to wire up the 16 or so LEDs that would be needed, I discovered this approach is a headache. Lots of branching and back and forth wiring is needed. Not a bad solution, but I can do better.

Next week I do better. Anyone for a boost switch mode DC-DC converter?

I've been listening to the Digikey/DesignNews "180 days of Education" For the last several weeks. The microcontroller lectures (the first two weeks) were worth the time. They are basic to intermediate level lectures well presented. The sensors lectures of the third week just didn't seem as useful to me. Probably worth listening to, but not necessarily. I will find the time to hear the next lectures.

Bruce McLaren

Tuesday, February 14, 2012

Dice Statistics

A change of pace: dice statistics. I am in the midst of rolling up a Dungeons and Dragons character. The DM said she would allow a method I was not previously familiar with:
Method VIII: The player assigns 24d6 among a character's six ability scores. Each ability score must have at least 3d6, but no more 6d6, devoted to it. If the player desires a character with a high Strength, he could devote 4d6, 5d6, or even 6d6 to that ability. Next, the appropriate number of dice are rolled for each ability, and the total of the three highest results become the score. Any and all other dice rolled for that ability are discarded.
The obvious action is for me to find the statistical distribution for 3d6, 4d6, 5d6, and 6d6. My brute force answer is to write a Perl script that generates all combinations of dice results, sums the three highest rolls, and records the distributions. I stuck the code at the end of this post. 

The two figures summarize the results in graphical form. In both graphs, the y-axis is percent (%). This is a nice demonstration of the difference between "most likely" and median. When rolling 6d6 and summing the best three, 15 is the most likely result but 14 is the median. 







The code is straight-forward. I couldn't think of a way to make the number of for loops variable, which kept the code easy to follow but not as general as it could be. This the first time I have found a use for a format statement. 



#!/usr/bin/perl

# high3.pl
#
# A D&D character creation method is quoted below
# Method VIII: The player assigns 24d6 among a character's six ability scores.
# Each ability score must have at least 3d6, but no more 6d6, devoted to it.
# If the player desires a character with a high Strength, he could devote 4d6,
# 5d6, or even 6d6 to that ability. Next, the appropriate number of dice are
# rolled for each ability, and the total of the three highest results become
# the score. Any and all other dice rolled forthat ability are discarded.
#
# This program find the distribution and cumulative distribution function for 
# rolling 3d6, 4d6, 5d6, and 6d6. 
#
# All possible combinations 1-6 are generated six times. For 3d6 only the 
# first three rolls are considered, for 4d6 only the first four rolls are 
# considered, etc. 
# The rolls are sorted and the highest three dice summed and recorded. 
#
# Bruce McLaren
# 11 Feb 12

use   warnings;
use   strict;

my $debug = 1;

my @roll     = ();  # [0-5] array containing the die rolls
# array of results. results[5]=number of times 5 came up
# [0-2] will remain 0
my @results3 = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
my @results4 = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
my @results5 = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
my @results6 = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
my $total    =  0;    # total possibilities = 6**6

for ($roll[0] = 1; $roll[0]<=6; $roll[0]++)
{
   for ($roll[1] = 1; $roll[1]<=6; $roll[1]++)
   {
      for ($roll[2] = 1; $roll[2]<=6; $roll[2]++)
      {
         for ($roll[3] = 1; $roll[3]<=6; $roll[3]++)
         {
            for ($roll[4] = 1; $roll[4]<=6; $roll[4]++)
            {
               for ($roll[5] = 1; $roll[5]<=6; $roll[5]++)
               {
                  $total++;

                  my @sorted3 = reverse (sort (@roll[(0..2)]));
                  my $result3 = $sorted3[0] + $sorted3[1] + $sorted3[2];
                  $results3[$result3]++;

                  my @sorted4 = reverse (sort (@roll[(0..3)]));
                  my $result4 = $sorted4[0] + $sorted4[1] + $sorted4[2];
                  $results4[$result4]++;

                  my @sorted5 = reverse (sort (@roll[(0..4)]));
                  my $result5 = $sorted5[0] + $sorted5[1] + $sorted5[2];
                  $results5[$result5]++;

                  my @sorted6 = reverse (sort (@roll[(0..5)]));
                  my $result6 = $sorted6[0] + $sorted6[1] + $sorted6[2];
                  $results6[$result6]++;
              }
            }
         }
      }
   }
}

if($debug >3)
{
   print "@results3[(3..18)]\n";
   print "@results4[(3..18)]\n";
   print "@results5[(3..18)]\n";
   print "@results6[(3..18)]\n";
   print "$total\t",6**6,"\n";
}

my $outindex = 0;
my $result3  = 0;
my $result4  = 0;
my $result5  = 0;
my $result6  = 0;
my $cdf3     = 0;
my $cdf4     = 0;
my $cdf5     = 0;
my $cdf6     = 0;

# All results are percentages taken to one decimal point
format STDOUT =
@>  @#.# @##.#  @#.# @##.#  @#.# @##.#  @#.# @##.#
$outindex, $result3, $cdf3, $result4, $cdf4, $result5, $cdf5, $result6, $cdf6
.

print " n   3d  3dcdf    4d 4dcdf    5d 5dcdf    6d 6dcdf\n";
for ($outindex=3; $outindex<=18; $outindex++)
{
   # results are multiplied by 100 to make them percentages
   $result3 = $results3[$outindex]/$total*100;
   $cdf3 += $result3;
   $result4 = $results4[$outindex]/$total*100;
   $cdf4 += $result4;
   $result5 = $results5[$outindex]/$total*100;
   $cdf5 += $result5;
   $result6 = $results6[$outindex]/$total*100;
   $cdf6 += $result6;

   write;
}

Here are the raw results (after passing through a StarOffice spread sheet).


n 3d 3dcdf 4d 4dcdf 5d 5dcdf 6d 6dcdf
3 0.5 0.5 0.1 0.1 0.0 0.0 0.0 0.0
4 1.4 1.9 0.3 0.4 0.1 0.1 0.0 0.0
5 2.8 4.6 0.8 1.2 0.2 0.3 0.0 0.1
6 4.6 9.3 1.6 2.8 0.5 0.8 0.2 0.2
7 6.9 16.2 2.9 5.7 1.2 2.0 0.4 0.7
8 9.7 25.9 4.8 10.5 2.2 4.1 1.0 1.6
9 11.6 37.5 7.0 17.5 3.8 7.9 2.0 3.6
10 12.5 50.0 9.4 26.9 6.0 14.0 3.6 7.2
11 12.5 62.5 11.4 38.3 8.6 22.5 5.8 13.0
12 11.6 74.1 12.9 51.2 11.3 33.9 8.9 21.8
13 9.7 83.8 13.3 64.5 13.6 47.4 12.1 33.9
14 6.9 90.7 12.3 76.9 14.9 62.3 15.1 49.1
15 4.6 95.4 10.1 87.0 14.3 76.6 16.7 65.7
16 2.8 98.1 7.3 94.2 12.0 88.6 16.2 81.9
17 1.4 99.5 4.2 98.4 7.8 96.5 11.9 93.8
18 0.5 100.0 1.6 100.0 3.5 100.0 6.2 100.0


Next week I may yet post the trailer LED circuit and implementation. Although my interview notes on bandgap voltage references are more likely.

Bruce McLaren

Wednesday, February 08, 2012

IC Design Interview 2: Miller Op-Amp

I sprinkle Miller op-amps around my designs. They are useful to drive low capacitance internal signal lines. They make fine buffer amplifiers. Many IC designers seem to be dead set against them, but I think they do have their place. Even those engineers who would never use a Miller op-amp and spend a fair amount of time during the interview explaining why no one should ever use them will expect good knowledge of the structure, theory, and practice of design and use of the lowly Miller op-amp.

These are my interview notes so they only cover the things I tend to forget, i.e., the equations.



I am hoping to have interior trailer lights ready for next week.

Bruce McLaren

Saturday, February 04, 2012

IC Design Interview 1: Basic Device Equations

I've been on both sides of the hiring desk and can say that interviewing for an IC design position is an interesting process. There aren't really that many of us, so we either know each other or know someone who knows the other. Everyone involved (the hiring manager, job seeker, other designers) is busy with things other than the interview. 

The usual process is for an interviewer to meet with the job seeker for an hour or so. This repeats about six times with a break for a group lunch. The interview is usually extremely technical in nature. There will be equations derived and schematics drawn. This seems to surprise people in other professions. 

I memorize equations poorly. This is bad when I know I will be required to recite a multitude of equations. These equations are basic to our profession and are used regularly, I just can't spit them out during an interview. So I spend several days ahead of the interview cramming as if for a test. I have prepared seven pages of basic information to be memorized before an interview with a few pages that I add on depending on the specific position. The first page of notes are the basic device equations. I present these here without explanation; the explanation would encompass an undergraduate electronics course.



I am still learning how to use google docs and embed the result in this blog.

Until next week.

Bruce McLaren

Wednesday, February 01, 2012

Introduction and Intention

A Mixed Signal by which I mean analog and digital. Or hardware and software.

I want to cover many technical and engineering related topics of interest to me. This blog will force me to put those ideas in an organized form. It will also be a place for me to store notes. I expect to be the only reader of this blog. The intent is to post every week.

Topics I want to cover:
Interview Notes--Things you must know to interview for an IC design position
Simple LED circuits
Basic IC Building Blocks
Power Converters