Filter Design Details

Quote of the Day

Torture the date, and it will confess to anything.

— Ronald Coase, data scientist


Introduction

Figure 1: Examples of Filter Rolloffs.

Figure 1: Examples of Filter Roll Offs. (Source)

During a recent circuit design review, I saw the need for a simple two-pole filter in one region of the circuit. As I thought about, this filter might be a good example to work through here in the blog. While the application is rather routine, it does illustrate the general process involved in designing one of the most common forms of a low-pass filter.

This is also good application for a computer algebra system. I chose Mathcad, which did a very nice job.

Requirements

I am constantly amazed at how many people try to "short-change" the amount of effort they spend on determining requirements. I make sure that I have the requirements fully determined before I start designing. As far as I am concerned, every minute spent working on the wrong problem is a minute wasted.

This does not mean that determining requirements is easy. I refer to this process as "The Treasure Hunt." Requirements are my treasure and, like any real treasure, you may have to look hard to find it. In this case, the requirements were pretty obvious:

  • The output of the filter is a quasi-DC voltage level (i.e. it changes slowly and infrequently)
    We are using the PWM generator followed by this filter to build a "poor man's" a digital-to-analog converter (DAC). We are working with a very low-cost device that has a PWM generator but not a DAC. Our cost goals are so tough that we cannot afford to add a DAC.
  • The input to the filter is a pulse train that is pulse-width modulated.
    As mentioned above, we have a PWM generator available for free and we want to re-task it for use as a DAC.
  • The input level is from 0 to 1 V with a modulation rate of 100 kHz.
    The PWM generator uses 100 kHz switching frequency and we need to filter this component out to achieve a smooth enough DC level.
  • The output level is from 0 to 5 V and is to be a DC level with less than 0.5 mV of ripple.
    We need a relative steady voltage level. With an input amplitude of 1 V and an output amplitude of 5 V, it also means we need a circuit with some gain.
  • The circuit is not sensitive to offset voltage or any of the other op-amp imperfections.
    Some applications are very sensitive to common-mode errors, offset voltage, or bias currents. This application in not one of those.

Design

Approach

Given the operational requirements listed above, we can derive some design requirements as shown below.

  • I need to attenuate the PWM-induced voltage ripple by at least 4 orders of magnitude (5 V/10,000 = 0.5 mV).
  • Attenuation by a factor of 10,000 means 80 dB of attenuation \left( 20\cdot \log \left( \text{10,000} \right)=80\text{ dB} \right).
  • As a working assumption, set fBW = 100 Hz.
    This means we will have 3 decades of frequency rolloff to reduce the filter gain down by 80 dB or more. A wider transition region reduces the order of the filter required.
  • A 2-pole filter should provide more than enough attenuation.
    A 2-pole filter provides 40 dB of attenuation per decade of frequency rolloff. A 2-pole filter should be able to meet 80 dB of attenuation over 2 decades of frequency rolloff. Since we have 3 decades of frequency rolloff to work with (100 Hz to the 100 KHz PWM frequency), I should actually see 120 dB of attenuation (more is good). So I will set the filter bandwidth at f_{BW} = \text{100 Hz}.
  • The circuit needs a gain of 5 at DC (0 Hz)
    Basically, the circuit will need to amplify a pulse train with a 1 V peak amplitude to a DC level with a 5 V peak amplitude.
  • The circuit needs to have a low output impedance.
    This means that I really would like to have the voltage come directly off of the output of an opamp.

The circuit does not have stringent transient response requirements. I just need a nice, stable, filter circuit (i.e. no high Q poles). In this situation, many engineers will choose a Sallen-Key circuit configured to implement a Butterworth filter. That is exactly what I will do here.

Butterworth Polynomial

Implementing a Butterworth filter means coming up with a physical realization of a Butterworth polynomial. Normally, I just read the polynomial from a table. For illustrative reasons, I will forgo the table look-up and will derive the second-order Butterworth polynomial using the key defining characteristic of a Butterworth polynomial – maximal flatness at 0 Hz.This same approach can be used to determine the Butterworth polynomial of any order. I will also show any other Butterworth polynomial can be found.

Maximal flatness means that the first n-1 derivatives of the magnitude-squared function {{\left| G(j\cdot \omega ) \right|}^{2}} equal 0 at 0 Hz. Most filter design work (analog and digital) is done using the magnitude-squared function {{\left| G\left( j\cdot \omega \right) \right|}^{2}}. This is because {{\left| G\left( j\cdot \omega \right) \right|}^{2}} can always be expressed as a real-function of ω2\left( {{\left| G\left( j\cdot \omega \right) \right|}^{2}}=f\left( {{\omega }^{2}} \right) \right). As you will see below, this makes taking derivatives fairly simple.

We can set the first n-1 derivatives to zero because (1) we have n coefficients (i.e. n degrees of freedom), and (2) we use one degree of freedom when we set {{\left| G(j\cdot {{\omega }_{BW}}) \right|}^{2}}=\frac{1}{2}. With a second-order filter, this means that the first derivative of {{\left. \frac{d}{d{{\omega }^{2}}}{{\left| G\left( j\cdot \omega \right) \right|}^{2}} \right|}_{\omega =0}}=0.

Equation 1 shows the general 2-pole, low-pass, magnitude-squared function.

Eq. 1 {{\left| G\left( j\cdot {{\omega }_{n}} \right) \right|}^{2}}=\frac{{{K}^{2}}}{1+A\cdot {{\omega }_{n}}^{2}+B\cdot {{\left( {{\omega }_{n}}^{2} \right)}^{2}}}

where

  • K is the gain at 0 Hz (5 in this case).
  • A, and B are polynomial coefficients.
  • {{\omega }_{n}}\triangleq \frac{\omega }{{{\omega }_{3\text{dB}}}}

In Figure 2, I use Mathcad's symbolic solver to show that A = 0 and B = 1.

Figure 1: Derivation of the Magnitude Squared Function.

Figure 2: Derivation of the Magnitude Squared Function.

In Figure 1, we derived the magnitude squared function {{\left| G\left( j\cdot \omega \right) \right|}^{2}}=\frac{25}{1+{{\left( {{\omega }^{2}} \right)}^{2}}}=\frac{25}{1+{{\omega }^{4}}}. We can use the magnitude squared function to derive the Butterworth filter function (Figure 3).

Figure 2: Derivation of the Second-Order Butterworth Polynomial.

Figure 3: Derivation of the Second-Order Butterworth Polynomial.

Thus, the second order Butterworth polynomial is s_{n}^{2}+\sqrt{2}\cdot {{s}_{n}}+1, where sn is the normalized Laplace frequency variable. This polynomial agrees with that listed for the second-order in this table of Butterworth polynomials.

We can prove that the general form of the magnitude-squared form of a Butterworth Polynomial of order n is 1-{{\left( \omega _{n}^{2} \right)}^{2}}. Figure 4 shows how Mathcad can be used to generate a table of Butterworth polynomials.

Figure 3: Mathcad Program for Generating a Table of Butterworth Polynomials.

Figure 4: Mathcad Program for Generating a Table of Butterworth Polynomials.

Sallen-Key Circuit

Figure 5 shows the Sallen-Key circuit, which is a very commonly used circuit for this type of application.

Figure 4: Sallen-Key Low-Pass Filter Circuit.

Figure 5: Sallen-Key Low-Pass Filter Circuit.

I have used this circuit many times with much success.

Analysis of Sallen-Key Circuit

Figure 6 shows a standard Kirchoff's Voltage Law (KVL) analysis of the Sallen-Key circuit.

Standard Solution

Figure 5: Equations for the Sallen-Key Circuit.

Figure 6: Equations for the Sallen-Key Circuit.

I usually do not work with filter equations in the form shown in Figure 5. I like to normalize the frequency variable, s, relative to the filter bandwidth ({{s}_{n}}\triangleq \frac{s}{2\cdot \pi \cdot {{f}_{BW}}}).

Normalized Form

Figure 7 shows the Butterworth equation normalized to the filter bandwidth. This is the equation form normally shown in the filter design tables.

Figure 6: Development of the Normalized Form of the Butterworth Filter.

Figure 7: Development of the Normalized Form of the Butterworth Filter.

Component Determination

Figure 8 shows how we can determine the component values required for this implementation using the equation solving abilities of Mathcad.

Figure 7: Determination of the Passive Components Value.

Figure 8: Determination of the Passive Components Value.

We can now generate a plot of the filter magnitude characteristic using these component values.

Gain Characteristic

Figure 9 shows the gain characteristic of this design. As expected, we are seeing 120 dB of ripple attenuation. The gain at 0 Hz is 5, so that requirement is also met.

Figure 8: 2-Pole Butterworth Gain Characteristic.

Figure 9: 2-Pole Butterworth Gain Characteristic.

Conclusion

This was a good example of a common filter design problem. I have used both circuit simulators and computer algebra software to design these filters. I have come to like computer algebra software for this kind of work because it gives me equations. These equations allow me to see how the output varies as a function of individual component values. This means that I can see useful approximations.

Save

Posted in Electronics | 3 Comments

Solar Photons

Quote of the Day

Forgiveness is the final form of love.

— Reinhold Niebuhr


Introduction

Figure 1: Our Sun. (Source)

Figure 1: Our Sun. (Source)

I was watching "How the Universe Works" on the Science Channel and they had a really interesting discussion on stars and photons. During the show, they mentioned that photons generated in the center of the Sun take 4000 years to get to the surface. From the surface, the photons only take 8 minutes to get to the Earth. As part of my campaign to promote active television watching, let's take a look at where these numbers come from. As part of this effort, I will use Mathcad for the calculations and as a programming tool for a simple simulation.

 

8 Minutes to Earth

This is an easy one and Figure 2 illustrates the calculation. In this calculation, dAU is the distance from the Sun to the Earth, and c is the speed of light.

Figure 1: Confirmation of 8 Minute Transit Time.

Figure 2: Confirmation of 8 Minute Transit Time.

4000 years to the Surface

I had to think about this one a bit. I want to treat this like a Fermi problem (i.e. an exercise in rough approximation). Basically, a photon in the center of the Sun has to play a game of pinball with all the atoms in there on its way to the Surface. The classic way to model this situation is as a random walk. Let's look at how we can model a random walk process.

Random Walk Modeling

For simplicity, let's assume that we can model the photon as traveling an average distance l between each interaction with an atom. When a photon interacts with an atom, it is re-emitted in a random direction. I will ignore any time associated with the re-emission. Since it is a photon, it travels at a velocity c between the interactions. The mean distance, \overline{d}, that a random walker travels from its point of origin is given by Equation 1.

Eq. 1 \overline{d}=l\cdot \sqrt{N}

where

  • l is the length between interactions.
  • N is the number of interactions.
  • \overline{d} is the mean distance traveled.

We can derive this expression for the one-dimensional case as shown in Equation 2. For this case, the random iterates all have equal magnitudes, but random signs.

Eq. 2 d={{l}_{1}}+{{l}_{2}}+\cdots +{{l}_{N}}
\left\langle {{\overline{d}}^{2}} \right\rangle =\left\langle {{\left( {{l}_{1}}+{{l}_{2}}+\cdots +{{l}_{N}} \right)}^{2}} \right\rangle
{{\overline{d}}^{2}}=\left\langle {{l}_{1}}\cdot {{l}_{1}}+{{l}_{2}}\cdot {{l}_{2}}+\cdots +{{l}_{N}}\cdot {{l}_{N}}+{{l}_{1}}\cdot {{l}_{2}}+{{l}_{1}}\cdot {{l}_{3}}+\cdots +{{l}_{N-1}}\cdot {{l}_{N}} \right\rangle
{{\overline{d}}^{2}}=\sum\limits_{i=1}^{N}{\underbrace{\left\langle {{l}_{i}}\cdot {{l}_{i}} \right\rangle }_{={{l}^{2}}}}+2\cdot \underbrace{\sum\limits_{i\ne j}{\left\langle {{l}_{i}}\cdot {{l}_{j}} \right\rangle }}_{=0}=N\cdot {{l}^{2}}
{{\overline{d}}^{2}}=N\cdot {{l}^{2}}
\therefore \overline{d}=l\cdot \sqrt{N}

We can illustrate how this equation works with a simple simulation.

Equation Verification Through Simulation

Figure 3 shows a Mathcad program for simulating a two-dimensional random walk of 5000 steps (variable N) 100 times (variable n). I will not go into detail here, but the results for 1, 2, and 3 dimensional random walks are the same.

Figure 2: Mathcad Simulation of a Two-Dimensional Random Walk.

Figure 3: Mathcad Simulation of a Two-Dimensional Random Walk.

The simulation uses complex numbers to make the path vector easily rotatable. I have set the interaction distance l to 1 for the demonstration. Figure 4 shows the result of one of trials from the program in Figure 3.

Figure 3: Simulation Results from a Single Trial.

Figure 4: Simulation Results from a Single Trial.

For 500 trials of 5000 interactions, the simulation computed a mean random walk distance of 69.4, while theory predicts 70.7 (Equation 1). The agreement is pretty good.

Solar Transit Time Calculation

We can compute an estimate for a photon's solar transit time as shown in Figure 5, which shows a simple pair of equations being solved simultaneously. In this system, I first solve for the number of interactions N. The transit time \tau can then be computed by assuming the photon traveled a distance of N \cdot l at a speed of c. For our rough analysis, we will assume that the average free path, l, for a photon is ~1 cm. Determining this number is complicated and I will refer you to this reference.

Figure 4: Calculation of the Transit Time for A Photon Through the Sun.

Figure 5: Calculation of the Transit Time for A Photon Through the Sun.

My result is ~5000 years, which is close to the 4000 years stated in the program.

Conclusion

I was able to derive the results stated in the program and got a feel for some of the dynamics going on inside of the Sun. All of the numbers associated with the Sun are so large that they always leave me in awe.

Save

Posted in Astronomy, General Science | 2 Comments

Chili Math and a Good Use for Decibels

Quote of the Day

It takes as much energy to wish as to plan.

— Eleanor Roosevelt


Introduction

You never know what you will see when you walk into a guy's cube. I went to an engineer's cube with a simple question on some electronic parts and I left with an education on chili peppers. My education began when I looked at his bookshelf and noticed that it was filled with various hot sauces, a dead giveaway that I was in the presence of a man who likes his heat. I also noticed the following chart on one of his walls (Figure 1).

Figure 1: Scoville Chile Heat Mask.

Figure 1: Scoville Chile Heat Mask.

Some of you may be familiar with the Scoville scale, but I was not. As far as culinary heat is concerned, I break into a sweat just walking near a Jalapeno pepper.

The Wikipedia has good discussion of the Scoville scale and its history, so I will not go into that here. My interest is in the dynamic range of the Scoville scale. Pure capsaicin, the heat-producing component in chile, has a Scoville rating of 15,000,000. A Belle pepper has a Scoville rating of near 0.

It is rare to see this kind of dynamic range in everyday life. It is here that I see a good use for decibels ...

Convenient Numbers

For those of you who are not familiar with the decibel (abbreviated dB), it is computed as shown in Equation 1.

Eq. 1 dB(x)=10\cdot \log \left( x \right)

I use decibels everyday, but I have never really liked them. Much of my dislike has to do with how they are used. I see people treat decibels as a unit, but they really are not a unit – decibels are a scaling. I see two main reasons to use decibels.

  • To compress physical measurements into a more friendly-number range.
    Human beings can only visualize a limited range of numbers. Because of our decimal orientation, engineers frequently try to use scalings that put frequently used numbers in the range of 0 to 100. The decibel does compress an amazing number of physical quantities into the range of 0 to 100.
  • The decibel converts multiplication into addition.
    This is the most important feature of the decibel and why engineer's specify so many system parameters in decibels. Because many systems have transfer functions that involve products of numbers, the use of decibels allows one to compute complex values using simple addition.

So while I see uses for the decibel, some guys take it to a ridiculous level. I know of at least one engineer who can figure out interest rates, car payments, and all sorts of compound interest calculations in his head by using dBs. It may be hard to believe, but even I think that is obsessive.

Anyway, I think that the Scoville range of 0 to 15,000,000 is way too big for a human to visualize. I think that dB could help here. Figure 2 shows Figure 1 expressed in dB. I think these numbers are easier to work with.

Figure 2: Scoville Scale in dB. I like these numbers better

Figure 2: Scoville Scale in dB. I like these numbers better

Posted in Baking, General Mathematics | 3 Comments

The Power of a Simple Magnifying Glass

Introduction

My favorite radio program is Science Friday. Last week, their web page included an excellent video where Science Friday's resourceful intern, Flora Lichtman, gave a wonderful explanation behind the use of a lens to concentrate the Sun's power. Her assistant in this effort was Thomas Baer, Executive Director of the Stanford Photonics Research Center (i.e. big shot). Here is a link to the video.

http://www.sciencefriday.com/embed/video/10380.swf

During the demonstration, they did bit of math that showed how a person could compute the level of solar power concentration provided by a simple magnifying glass. In a manner totally appropriate for this kind of video, they magically pulled out an equation and a value for the angular diameter of the Sun (Flora did say to look up the angular diameter of the Sun in any physics textbook). I thought it would be worthwhile to derive both the equation and the angular diameter of the Sun. Let's dig in ...

Analysis

During the video, Thomas Baer wanted to give a simple, approximate formula for the concentration factor of solar power provided by a common magnifying glass. He gave the formula shown in Equation 1.

Eq. 1 \text{Concentration Factor}={{\left( \frac{100}{F} \right)}^{2}}

where F is the F-number of the lens. The F-number of the lens is defined as F=\frac{f}{D_{Lens}}, where f is the focal length and DLens is the diameter of the lens. For the lens in their example, they computed an F-number of about 3.16, which means the concentration factor is 1000. This means that the power at the spot is the same as what entered the lens, but it is concentrated on an area 1000 times smaller.

I want to derive Equation 1 from first principles. We can start with Figure 1, which illustrates the geometry of the situation.

Figure 1: Illustration of the Magnifying Glass Scenario.

Figure 1: Illustration of the Magnifying Glass Scenario.

Determination of the Angular Diameter of the Sun

Figure 2 illustrates how to calculate the Sun's angular diameter at the Earth (Ө). I used Google to get the Sun's diameter (DSun) and distance (RSun).

Figure 2: Mathcad Screen Capture of Solar Angular Diameter Calculation.

Figure 2: Mathcad Screen Capture of Solar Angular Diameter Calculation.

This analysis agrees with the value listed in the Wikipedia.

Concentration of Solar Power From First Principles

Figure 3 shows my calculation for the magnifying glass' concentration of solar power. I make the assumption that we can approximate the diameter of the spot by using {{D}_{Spot}}\approx f\cdot \theta , where Ө is the angular diameter of the Sun.

Figure 3: Mathcad Screen Capture of Magnifier's Solar Concentration.

Figure 3: Mathcad Screen Capture of Magnifier's Solar Concentration.

Concentration of Solar Power Using F-Number

Figure 4 shows my derivation of Equation 1. It is straightforward and gives the same numerical answer as above. The only difference from what Flora and Tom obtained occurs because my angular diameter is a bit different than theirs. Of course, they were using approximate numbers.

Figure 4: Derivation of F-Number Equation.

Figure 4: Derivation of F-Number Equation.

Conclusion

Flora and Tom did a nice job on the video. I wanted to walk through it and make sure that I understood mathematically what was going on. I believe that I do.

P.S.

If you want to see what you need to start a leaf on fire with a lens, see this post.

Posted in Astronomy, Fiber Optics | 2 Comments

A Simple Analog Multiplier

Introduction

I regularly get questions on using solar panels to power our Fiber-To-The-Home gear (FTTH). You might think that sounds kind of odd, but it makes a lot of sense for many businesses and municipalities. For example, every municipality has water towers, sewage lift stations, and energy delivery systems that have alarm sensors that need to be monitored. In the old days, phone lines could be used to provide both connectivity and power to these sensors (e.g. powered T1 lines). However, FTTH systems are connected with glass and there is no way to provide any electrical power down these lines. Businesses also have remote pipelines and electrical distribution systems with sensors that need to be monitored. I even had one ranch that wanted to provide voice, video, and data services to a remote bunkhouse for cowboys. Many businesses want to take advantage of solar energy because it contributes to the lessening of greenhouse emissions on Earth, helping to reduce global warming and climate change. Businesses could look at Reliant Energy reviews which could assist in finding the best price for solar energy production if they were interested in getting solar panels.

As with any power system, you want to get the maximum amount of power possible out of a solar panel. As with most electrical systems, solar panels put out the most power when they are presented with an optimal load. Figure 1 shows an example of the current versus voltage curves (aka "i-v curves") for a typical solar panel (Source). The i-v curves are represented by the solid lines and the available power is represented by the dashed lines.

Figure 1: Photovoltaic Current versus Voltage Curves.

Figure 1: Photovoltaic Current versus Voltage Curves.

To get optimum power from a solar panel, the load presented to the solar panel must be varied as the incident solar power varies through the day. Fortunately, switching power supplies allow us the vary the input load while maintaining they maintain a constant output voltage, which is important for doing things like charging batteries.

Ideally, we would have a circuit that would allow us to monitor the power output from the solar panel and would vary the switching power supply load as needed to achieve optimum results. It turns out there are a number of ways to accomplish this feat, which is called Maximum Power Point Tracking (MPPT). While investigating various MPPT designs, I encountered the following article by Stephen Woodward. I always admire Woodward's designs – they are elegance writ in silicon. I will not review his entire circuit, rather I will examine how he computes the power from the solar panel using very simple electronics.

Background

Approach

Most MPPT controllers use a perturbation-based approach to determine the optimum load they need to present. In general, they deliberately create a small load disturbance to the solar panel and they determine whether power increased or decreased. They will change their load to ensure that they are constantly adjusting their load to increase the power from the solar panel. Generally, these schemes compute power by multiplying the current value by the voltage value. This approach often requires analog multipliers (expensive) or software (demands software, memory, and a processor – also expensive). This approach assumes that we can compute the power from the solar panel. Woodward's design includes a beautifully simple means for generating a voltage that is related to power. Maximizing this voltage will also maximize the power we obtain from the solar panel.

Woodward's Solution

It is well known that the voltage across the base-emitter junction can be described by Equation 1.

Eq. 1 {{V}_{BE}}={{V}_{T}}\cdot \ln \left( \frac{{{I}_{BE}}}{{{I}_{S}}} \right)

where

  • VBE is the base-emitter voltage of the transistor.
  • IBE is the base-emitter current of the transistor.
  • IS is the saturation current of the transistor (it varies from device to device).
  • VT is the thermal voltage \left( {{V}_{T}}=\frac{k\cdot T}{q} \right) from the Shockley equation.

Figure 2 illustrates the accuracy of this relation with respect to an actual transistor (2N3904). This plot shows base-emitter voltage versus collector current. Collector current is closely related to the base-emitter current by the equation I_C = I_{BE} \cdot \frac{\beta }{\beta +1}, where ? is the current gain of the transistor. Equation 1 models this characteristic very well, particularly at low currents.

Figure 2: Semilog Plot of a 2N3904 Transistor (Typical NPN Device).

Figure 2: Semilog Plot of a 2N3904 Transistor (Typical NPN Device).


Woodward's approach is simple:

  • Note that \log \left( {{k}_{1}}\cdot i \right)+\log ({{k}_{2}}\cdot v)=\log ({{k}_{1}}\cdot {{k}_{.2}}\cdot i\cdot v)=\log (\text{power})+\log \left( {{k}_{1}}\cdot {{k}_{.2}} \right). Since maximizing the logarithm of the power is the same as maximizing the power, we can maximize this equation and obtain our objective.
  • Use two cheap, identical transistors in series.
  • Drive one of the transistor with a current proportional to the voltage from the solar panel.
  • Drive the second transistor with a current proportional to the current from the solar panel.
  • Since the transistors are in series, their voltages sum will be the related to the logarithm of the product of solar panel current and voltage, i.e. power.

Circuit

Woodward's original contained the multiplier sub-circuit shown in Figure 3. As mentioned earlier, the sum of the Q1 and Q2 Collector-Emitter (CE) voltages represent the power being drawn from the solar panel.

Figure 3: Schematic of Woodward's Analog Multiplier.

Figure 3: Schematic of Woodward's Analog Multiplier.
VSum represents the logarithm of the power and is used to optimize the power transfer. Note that the emitter of Q2 is at virtual ground.


To analyze this circuit, let's break it down into two parts: (1) the CE voltage for Q1 (VQ1), and (2) the CE voltage for Q2 (VQ1).

Transistor Q1 Voltage

Figure 4 shows the circuit used to generate a current proportional to the solar panel voltage, which then produces a voltage across Q1. Amplifier A2 is used to build a negative resistor. As shown in Figure 4, this negative resistor, when combined with the solar panel voltage (VPV) and R1, is used to build a current source that produces I_{Q1} = \frac{V_{PV}}{R_1}.

Figure 4: Schematic of Circuit Section that Generates A Q1 Current Proportional to the PV Voltage.

Figure 4: Schematic of Circuit Section that Generates A Q1 Current Proportional to the PV Voltage.


This current means that the CE voltage of Q1 can be written as {{V}_{Q1}}={{V}_{T}}\cdot \log \left( \frac{{{V}_{PV}}}{{{R}_{1}}\cdot {{I}_{S}}} \right).

Transistor Q2 Voltage

Figure 5 shows how Q2's voltage is generated. Amplifier A1 is used to build a current source that draws {{I}_{Q2}}={{I}_{PV}}\frac{{{R}_{S}}}{{{R}_{2}}}. To derive this equation, note that the minus input of A1 is a virtual ground. This means that the voltage across R2 is V_{R2} = I_{PV} \cdot R_S. From this voltage and the value of R2, we can compute IQ2.

Figure 5: Schematic of Circuit Section that Generates A Q2 Current Proportional to the PV Current.

Figure 5: Schematic of Circuit Section that Generates A Q2 Current Proportional to the PV Current.


This current means that the CE voltage of Q2 can be written as {{V}_{Q1}}={{V}_{T}}\cdot \log \left( \frac{{{I}_{PV}}\cdot {{R}_{S}}}{{{R}_{2}}\cdot {{I}_{S}}} \right).

Voltage Sum

Equation 2 gives us the voltage across Q1 and Q2.

Eq. 2 {{V}_{Sum}}={{V}_{Q1}}+{{V}_{Q2}}={{V}_{T}}\cdot \log \left( {{I}_{PV}}\cdot {{V}_{PV}} \right)+{{V}_{T}}\cdot \log \left( \frac{{{R}_{S}}}{{{R}_{1}}\cdot {{R}_{2}}\cdot {{I}_{S}}^{2}} \right)
{{V}_{Sum}}={{V}_{T}}\cdot \log \left( {{P}_{PV}} \right)+{{V}_{T}}\cdot \log \left( \frac{{{R}_{S}}}{{{R}_{1}}\cdot {{R}_{2}}\cdot {{I}_{S}}^{2}} \right)

where P_{PV}=V_{PV} \cdot I_{PV} is the power from the solar panel.

Thus, we can maximize the power obtained from the solar panel by maximizing the voltage given by Equation 2.

Conclusion

This circuit nicely illustrates how the clever use of the logarithmic characteristic for a transistor junction can be used to make a simple and inexpensive power calculation circuit. In a later post, I will show how this circuit can be combined with a switching power supply to make an MPPT controller for a solar panel.

Update
Another engineer beat me to it. See this blog post. It references this post and includes a complete design for an MPPT controller.

Posted in Electronics | 6 Comments

Learning How Electronic Parts Work (Part 2)

As you guys know, I've been on a mission to learn how electronic parts work. As an engineer, I have a decent knowledge of certain parts of electronics but I always want to know more. What makes the leviton switches work? How do circuit breaks happen? Why does the amount of voltage matter? I thought I did a pretty good job explaining in part 1 but wanted to clear a few things up.

I noticed that in my post "Learning How Electronic Parts Work" that I neglected to compare my model to reality. I thought I had better rectify this situation because a year from now I will forget what I did and have to reconstruct my arguments. There was more algebra involved than I anticipated. I used Mathcad to perform my analysis and modeling. The figures shown below are all screenshots from my Mathcad model.

Figure 1 shows my logarithm function model (I call it the prototype) and the Maxim representation of their part characteristics, which they specify as the slope and intercept of a line on a semilog plot.

Figure 1: Logarithm Prototype Function and Maxim Empirical Model.

Figure 1: Logarithm Prototype Function and Maxim Empirical Model.

Figure 2 shows how I have beaten Maxim's semilog data into the more conventional logarithmic function form.

Figure 2: Conversion of Maxim Semilog Model to Logarithm Function.

Figure 2: Conversion of Maxim Semilog Model to Logarithm Function.

Figure 3 shows the results of my model converted to a standard logarithm function form.

Figure 3: My Model Converted to Conventional Logarithmic Function.

Figure 3: My Model Converted to Conventional Logarithmic Function.

The Maxim specifications and my Mathcad model are in good agreement (thank goodness). You may notice that there is a lot of algebra associated with the use of decibels. Even though I am an electrical engineer and I have to use decibels all day, I really do not like decibels. I am forced to deal with them because that is how electrical systems are specified. I do all my calculations in Mathcad, which helps me keep all my units and logarithmic scalings straight.

Posted in Electronics | 2 Comments

What is a Hyperbola Doing in There?

Introduction

An engineer came by my cube and asked me a question about a part we use in one of our older designs. This clever little device is made by Maxim and is called the 3660. This chip is used to convert an optical version of a television signal into its electronic counterpart. Video service providers transport their video signals around optically, but must convert the optical signal to its electronic form for use by standard televisions. Because optical signal strength decreases with the distance it must travel, we need a way to compensate for the loss of signal level. TV watchers like to receive signals with a constant signal level to ensure that they do not have to watch poor quality images. The service providers also like this feature because it means that they can service customers over a wide range of distances with no degradation in signal quality, simplifying their system designs. Ideally, we would use a receiver that would convert our optical signal to an electrical signal that has a constant level regardless of the optical input level.

What the design engineer needs is an amplifier whose gain will increase when the input voltage decreases. This feature is usually referred to as Automatic Gain Control (AGC). The engineer who came to my cube had noticed something odd in how the AGC feature of this circuit works compared to other amplifiers with AGC – the 3660 has a hyperbolic AGC characteristic. This is where my story begins.

Background

AGC common in electronics. Normally, the gain of AGC amplifier varies linearly or logarithmically with the voltage placed on one of the chip's pins. Figure 1 shows an example of a typical linear variable gain amplifier characteristic. The voltage used for AGC is referred to as VAGC.

Figure 1: Typical Variable Gain Amplifier Characteristic.

Figure 1: Typical Variable Gain Amplifier Characteristic
The gain of the amplifier increases linearly with the voltage on the AGC pin.


The engineer at my cube had noticed that the Maxim 3660 does not have a linear or logarithmic gain characteristic – it has a hyperbolic characteristic (see Figure 2).
Figure 2: Maxim 3660 Hyperbolic Gain Characteristic.

Figure 2: Maxim 3660 Hyperbolic Gain Characteristic.


What is a hyperbolic curve doing in there? When I first saw the part, I had the same question. The 3660 was designed by Javier Sanchez, an analog guru whose designs are absolutely first-rate. He had a good reason to design it this way.

Analysis

Design Rationale

The output voltage of the 3660 is described by Equation 1. In Equation 1, I am ignoring the clipping that occurs at both high and low AGC voltages. We never operate our systems in those areas of the AGC curve, so we can ignore them.

Eq. 1 {{V}_{Out}}=\frac{K}{{{V}_{AGC}}}\cdot {{V}_{IN}}

where

  • VIN is the input voltage to the amplifier.
  • VOUT is the output voltage from the amplifier.
  • VAGC is the gain control voltage.
  • K is a constant term.

Equation 1 shows us that the gain of the amplifier indeed varies hyperbolically with VAGC. A close look at Equation 1 also shows us what we must do to maintain a constant output from this amplifier. What if we make V_{AGC}=K_0 \cdot V_{IN}, where K0 is a constant? The result is shown in Equation 2.

Eq. 2 {{V}_{Out}}=\frac{K}{{{K}_{0}}\cdot {{V}_{IN}}}\cdot {{V}_{IN}}
\therefore {{V}_{Out}}=\frac{K}{{{K}_{0}}}

Equation 2 shows that the 3660 will generate a constant output if we make VAGC proportional to the input voltage. It turns out that this is very easy to do. In our actual implementation, we set VAGC to a value that is proportional to the DC level of the input signal (the AC portion of the signal is the actual information). The proportionality (K0) is set so that the constant output level is the value you desire.

This approach was used in an early version of our products and we have shipped hundreds of thousands of these units to happy TV watchers.

How Did Javi Do It?

Electronic designs routinely work with circuit parameters that vary linearly or exponentially, which makes generating these curves a breeze. However, generating a hyperbola does not come easily. When an integrated circuit designer approaches a problem, he looks reuse existing designs as much as possible to minimize his design effort. In the case of the 3660, Javi used three copies of an existing linear variable gain amplifier design. Using standard techniques, he pieced their characteristics together as shown in Figure 3.

Figure 3: Piecewise Linear Approximation to a Hyperbola.

Figure 3: Piecewise Linear Approximation to a Hyperbola.


While the basic concept shown here is simple, there are numerous details that must be dealt with to ensure that the amplifiers turn on and off at the proper times. I will not cover these details in this post. Just understand that there is quite a bit of work involved in turning any good idea into a credible piece of silicon. The piecewise linear approximation to a hyperbolic curve worked just fine for a real world application and it was simple for the chip's end users to apply.

Conclusion

The 3660 variable gain amplifier design is a good example of a design engineer understanding the problem he was solving and working to solve the problem in the most direct way possible. This design ended up providing high performance at very low cost. I really can't ask any more than that.

Posted in Electronics | 2 Comments

Measuring Power with A Logarithmic Amplifier

One of our young engineers asked me why all of us old-timers like to use logarithmic amplifiers when we need to measure input signal power. The answer is simple -- power expressed in dB is a linear function of the logarithm of the voltage. I must admit that the way electrical engineers use dB for everything sometimes makes things seem a bit confusing. In the cable TV market, we assume 75 Ω impedances and use dBmV (decibel millivolt) and dBmW (decibel milliWatt) for units. Anyway, here is a quick derivation and example.

Figure 1: Derivation of dB Relationship between Power an Voltage.

Figure 1: Derivation of dB Relationship between Power and Voltage.

Posted in Electronics | Comments Off on Measuring Power with A Logarithmic Amplifier

Learning How Electronic Parts Work

Introduction

A few years ago, I gave a lunch time talk on Mathcad to my hardware engineers. During the talk, one of the engineers mentioned that he starts a Mathcad worksheet when he is reading a part datasheet. While he is reading the datasheet, he works on developing a mathematical model of the part he is reading about. I had to smile – I do exactly the same thing.

We have a new design in progress and this design is using a device known a demodulating logarithmic amplifier (I will use the term log amp here). I have never used this device before, so I wanted to work my way through the datasheet. Our radio-frequency (RF) application is ideal for this type of device. I thought it would be useful to give you a glimpse at how I go about learning how a part works by using a Mathcad mathematical model.

Background

There are two general types of logarithmic amplifiers:

  • True Logarithmic Amplifier
    When analog designers think of a log amp, they think of these devices. These devices usually use the exponential characteristic of a semiconductor junction in a feedback loop to generate the logarithmic characteristic. While these circuits work well, they do not operate well at the high frequencies at which our designs must operate. The Wikipedia has a nice discussion of these devices and I will not pursue them here further.
  • Demodulating logarithmic amplifiers
    When an RF engineer thinks of a log amp, they think of these devices. They are known by a number of aliases:

    These devices work by summing the outputs from a string of linear amplifiers hooked output to input. Just prior to summing , the amplifier outputs are passed through an envelope detector. This means that the demodulating log amps generate the logarithm of the envelope of the signal.

This post will focus entirely on the demodulating log amp approach. These are really the only option for a high-frequency application.

This Application

We have a classic application for a demodulating log amp:

  • large dynamic range (45 dB)
  • burst detection, which means that we need to detect the presence and measure the strength (level) of the RF signal.
  • circuit needs to be able to switch within 1 sec of the signal hitting our threshold level

For the work in this post, I will be using the Maxim 9933 RF-Detecting Control and RF Detector (yet another alias) as an example to motivate this discussion. This part represents the best of this technology available today. Here is a block diagram of this part.

Figure 1: Maxim 9933 Demodulating Log Amp Block Diagram.

Figure 1: Maxim 9933 Demodulating Log Amp Block Diagram.


My focus here is to explain how a chain of linear amplifiers can be used to generate a logarithmic transfer function.

Theory of Operation

Over the years, I have seen sets of amplifiers used to approximate many different functional relationships. For example, I have done a lot of work with a part designed by Javier Sanchez of Maxim (an analog guru) that uses three identical amplifiers to create a piecewise-linear approximation to a hyperbola (I will cover that little gem in a later post). The 9933 uses four amplifiers in series to create a piecewise-linear approximation to a logarithmic characteristic.

Functional Characteristic

Let's begin by defining what I mean by a logarithmic transfer function. Equation 1 shows the basic mathematical definition.

Eq. 1 {{V}_{Out}}={{V}_{0}}\cdot \log \left( \frac{{{V}_{In}}}{{{V}_{1}}} \right)

where

  • VOut is the output voltage from the log amp.
  • VIn is the input voltage to the log amp.
  • V0 is a gain constant which can be set during device calibration.
  • V1 is an input voltage scaling term, which is also set during calibration.

Demodulating Log Amp Block Diagram

I have googled the web and found at least four different approaches to using a series of amplifiers to approximate a logarithmic characteristic. Figure 2 illustrates the basic structure of the demodulating log amplifiers I have examined. All the implementation approaches have variations that make them different in the details, but they all generally function the same way.


Because these amplifiers are intended to detect power and signal envelopes, they include envelope detectors, summers, and low-pass filter. I will not discuss those circuit components because their implementation is straightforward and are covered in many places on the web (envelope detector, analog summer, low-pass filter). Most engineers will have knowledge of electronic circuits anyway as it is one of the main aspects of their job. Circuits are essential to powering most electrical devices, so it's vital that engineers do understand each different type of circuit. Most circuits are usually assembled by professional companies. Perhaps anyone looking for a custom-built electronic circuit could consider visiting the international sensors website to learn more about their services. Hopefully, this will lessen the need for an engineer to fix the circuit as the parts will have been professionally made.

Figure 2: Generic Demodulating Log Amp Block Diagram.

Figure 2: Generic Demodulating Log Amp Block Diagram.

Normally, amplifiers can be modeled as functions that multiply the input signal (current or voltage) by a fixed number. For my modeling here, I am assuming that the amplifiers within the log amp also multiply their input signals by a fixed number (called gain) but that also have output levels that will not exceed a specific voltage, which I call VLimit. Figure 3 illustrates the voltage output versus input transfer function. For this discussion, I will refer to the amplifiers within the log amp as limit amps.

Figure 3: Idealized Limit Amplifier Characteristics

Figure 3: Idealized Limit Amplifier Characteristics

Let's first try to understand qualitatively how the amplifier works. Assume we are going to apply a steadily increasing voltage from 0 to the point where all the amplifiers are limiting. At very low input voltages, no amplifiers are limiting and the gain of the system is the product of all the amplifier gains. As the input voltage increases, the last amplifier in the chain limits and the total gain of the system now reduces by the gain of that amplifier. As the input voltage continues to increase, the amplifiers limit one by one and the overall system gain reduces. When all the amplifiers have limited the gain of the system is 0. Figure 4 shows how limit amps can be connected in series to create a piecewise-linear approximation to the logarithm function (Equation 1).

Figure 4: Logarithmic Amplifier As Piecewise-Linear Approximation.

Figure 4: Logarithmic Amplifier As Piecewise-Linear Approximation.


In Figure 4, I assume that the first amplifier has a gain of m?1. Generally, engineers would make all the amplifiers identical and simply attenuate the output of the first amplifier. This is an approach used by some logarithmic amplifiers and it makes for a simple derivation of logarithmic performance (shown below). There are other approaches, but I will only cover the system shown in Figure 4.

Modeling in Mathcad

Figure 5 shows the two models that I generated, one recursive and the other iterative. They are very similar and show how easily Mathcad models this type of circuit.

Figure 5: Iterative and Recursive Log Amp Models in Mathcad.

Figure 5: Iterative and Recursive Log Amp Models in Mathcad.


Both models produce the same answer. I did two models just to demonstrate equivalent, but different, approaches. Figure 6 shows the output from the model. It is very similar to the same graph published for the 9933.

While I model the amplifiers as having a "hard" clipping characteristic, real amplifiers have a "softer" clipping characteristic. It turns out that this "softer" clipping actually improves the circuit's conformance to a logarithm function (I will not go into detail here). It is not often in engineering where the non-ideal characteristics of a component actually make an engineer's job easier, but this is one case.

Derivation

As shown in Figure 4, assume each of the amplifiers are labeled from left to right with numbers from 1 to N. Note how all but the first amplifier have gains of m. The first amplifier has a gain of m-1. Figure 4 shows the piecewise-linear approximation. The slope of the characteristic changes each time an amplifier saturates. We can compute the input voltage at which the kth amplifier saturates as shown in Equation 1.

Eq. 2 {{V}_{T,k}}\cdot \left( m-1 \right)\cdot {{m}^{k-1}}=1\quad \Rightarrow \quad {{V}_{T,k}}=\frac{1}{\left( m-1 \right)\cdot {{m}^{k-1}}}

where VT,k is the input threshold voltage at which the kth amplifier saturates.

We can compute the output voltage of the amplifier chain when the kth amplifier is saturated. If m>1, every amplifier after the kth will also be saturated. Equation 3 shows the details of the derivation. During the derivation, I normalize all the voltages to the value of the limit voltage, VLimit. Equation 3 shows the output voltage at the points where the amplifiers just reach VLimit ( VIn = VT,k).

Eq. 3 {{V}_{Out}}={{V}_{In}}\cdot \left( 1+\left( m-1 \right)+\cdots +\left( m-1 \right)\cdot {{m}^{k-2}} \right)+{{V}_{Limit}}\cdot \left( N-k+1 \right)
Define {{V}_{On}}\triangleq \frac{{{V}_{Out}}}{{{V}_{Limit}}} and V_{In} \triangleq \frac{V_{In}}{V_{Limit}}.
{{V}_{On}}={{V}_{In}}\cdot \left( 1+m+\cdots +{{m}^{k-1}}-\left( 1+m+\cdots +{{m}^{k-2}} \right) \right)+N-k+1
{{\left. {{V}_{On}} \right|}_{{{V}_{In}}={{V}_{T,k}}}}=\frac{{{m}^{k-1}}}{\left( m-1 \right)\cdot {{m}^{k-1}}}+N-k+1
\therefore {{\left. {{V}_{On}} \right|}_{{{V}_{In}}={{V}_{T,k}}}}=\frac{1}{m-1}+N-k+1

To show that Equation 3 describes a logarithmic characteristic, we can solve Equation 2 for k and substitute that expression into Equation 3. Equation 4 shows how Equation 2 can be solved for k.

Eq. 4 {{m}^{k-1}}=\frac{1}{\left( m-1 \right)\cdot {{V}_{T,k}}}\quad \Rightarrow \quad k=-\frac{\log \left( \left( m-1 \right)\cdot {{V}_{T,k}} \right)}{\log \left( m \right)}+1

We can substitute Equation 4 into Equation 3 to obtain Equation 5.

Eq. 5 {{V}_{On}}=\frac{1}{\left( m-1 \right)}+N+\frac{\log \left( \left( m-1 \right)\cdot {{V}_{T,k}} \right)}{\quad \log \left( m \right)\quad }
{{V}_{On}}=\underbrace{\frac{1}{\left( m-1 \right)}+N+\frac{\log \left( m-1 \right)}{\quad \log \left( m \right)\quad }}_{\text{Constant}}+\underbrace{\frac{1}{\log \left( m \right)}}_{\text{Slope}}\cdot \log \left( {{V}_{T,k}} \right)

Equation 5 shows the input voltages at which each limit amplifier begins to limit. These are the input voltages at which the output voltage will exactly match the logarithm function. Note that the actual characteristic will deviate from that of a logarithm at input voltages that are not at the limit points.

Figure 6 shows a plot of my Mathcad model for the actual characteristic and the logarithmic curve that the limit points pass through.

Figure 6: Idealized Logarithm Function and Mathematical Model Output.

Figure 6: Idealized Logarithm Function and Mathematical Model Output.
A straight line on a semi-log plot means the function is logarithmic.

Conclusion

I thought this was a good example to illustrate how a computer algebra system can be used by an engineer to develop insight into how the parts he is using work. I use this approach all the time. I will try to publish a few more of these analyses if people find them interesting.


(see part 2 for some further details)

Posted in Electronics | 2 Comments

Bad Business Decisions

During a hallway discussion, the topic of bad business decisions came up. Everyone knows that a business can make a bad decision if they don't consider the facts and look at the statistics for every decision. It's no surprise that things like statmodeling is getting advanced when it comes to helping businesses with decision making, as this is an important part of a business's success. Not every business bothers with this though, so when I was asked to relate the dumbest business decision that I had ever seen, it was very easy for me to tell my story. Because I do not wish to receive hate mail, I will not mention the name of the company who made this decision. Let's call them Brand X.

The story starts five years ago when the fiber-to-the-home business was still in its infancy. Today, millions of units per year of fiber-to-the-home products are being shipped, but back then maybe 100K per year were being shipped worldwide. There is a part that is used on most of these units. Brand X is a company a few blocks from where I work and they made an excellent version of this part. Unfortunately, they are focused on shipping to the military and aerospace market and my firm is commercial. I went over to their facility and had a discussion with them about their part and I ended up using their part in our design. The part was a little clunky in a commercial application because military RF systems typically operate at 50 and fiber-to-the-home systems run at 75. I told the management of Brand X that I will use their part for now, but that I need them to eventually make a 75 version of the part. Their engineers told me that the change was minor and could be done by one person over a couple of months. We agreed on a unit price of $5.

I ended up buying large numbers of Brand X parts, but eventually, I really needed to get a 75 version of this part. I made another trip over to Brand X and asked them again to make a 75 version of this part. Their response was interesting. They wanted me to pay $50K to cover their R&D costs. I was buying about $50K worth of product every few months at that point. I told them that I would not cover their R&D costs. Besides my volume, they could sell millions of units to other people in the fiber-to-the-home space besides me. I could easily go to other companies who would make the part for me with no up-front costs. The local company told me that their system was focused on the military and aerospace markets where R&D costs are paid for by the customers. Their system could not deal with investing money in order to make more money. I was floored.

After thinking about it for a long time, I still couldn't wrap my head around it. Isn't taking risks a big part of running a business? You may not achieve as much growth as you'd like to see if you abide by the rules all the time. My friend is all about investing money, and he tries absolutely anything and everything he can to make as much income as possible. So much so, he's even decided to look at how these best investment apps uk may be able to help him to earn more going forward, as he wants to be able to see some growth with his own personal finance. Good for him! That's why I struggle to come to terms with the fact that businesses, particularly this one, don't take a similar sort of route. I just want to be able to put some money into my Self Managed Super Funds account! I'm not the best when it comes to savings but I thought this business venture would help me due to the extra income involved. I guess it's a bit more slow-moving than I originally thought!

To make a long story short, I discussed this with the Brand X management numerous times and they insisted that they could not make the change without up-front money. I ended up talking to several brands, including WG Henschen and an Australian company who developed a 75 Ω version of the part for nothing and I ended up using their part. I dropped Brand X and will never use them again. This particular part has now become standard in the industry and millions of these units are now used every year in the fiber-to-the-home market. My company alone purchases over 100K units per year. The local firm continues to make small quantities for the military market. The best thing for their company and the local community would have been to make this simple change, but they could not see further than their current market. I hope that I never develop that level of nearsightedness.

Posted in Management | Comments Off on Bad Business Decisions