Potentiometer Math

Introduction

I have an application where a potentiometer may be useful. In fact, it would be useful if the potentiometer had a logarithmic resistance characteristic, which is also called an audio taper for reasons that I will cover later. I have never used a potentiometer with a logarithmic characteristic before and I thought it would be worth documenting what I learned during this effort.

Background

Logarithmic Misnomer

What is normally referred to as a logarithmic taper is really an exponential characteristic. A typical logarithmic taper potentiometer characteristic is shown in Figure 1 (Source).

Figure 1: Example of A Logarithmic/Audio Taper Potentiometer Resistance Characteristic

Figure 1: Example of A Logarithmic/Audio Taper Potentiometer Resistance Characteristic

Each vendor will have a different "series" label for the logarithmic potentiometers, which often have names like "series A" or "series W." The series designation indicates a different set of resistance curves.

Potentiometer Specifications

Not all vendors include a graph of the resistance characteristics of their logarithmic potentiometers. Many of the vendors include a specification that says something similar to the following quote (source):

The “W” taper attains 20% resistance value at 50% of clockwise rotation (left-hand).

This specification means that the potentiometer has

  • 0% of it full scale resistance value with the wiper at 0% of its full scale position
  • 20% of it full scale resistance value with the wiper at 50% of its full scale position
  • 100% of the total resistance value at 100% of its full scale position.

This type of specification gives you sufficient information to create an exponential curve fit, which I illustrate in Figure 2.

Figure 2: Illustration of the Fitting of an Exponential Function to the Specified Points.

Figure 2: Illustration of the Fitting of an Exponential Function to the Specified Points.

The math associated with this curve fitting is shown in Figure 3.

Figure 3: Curve Fitting Math.

Figure 3: Curve Fitting Math.

Equation 1 illustrates the basic form of the logarithmic potentiometer's resistance characteristic R(x), where x is the wiper position as a percentage of full scale.

Eq. 1 R(x)={{R}_{0}}\cdot \left( {{e}^{{{R}_{1}}\cdot x}}-1 \right)

where

  • R0 is a curve fitting parameter
  • R1 is a curve fitting parameter
  • x is the wiper position as a percentage of full scale range

Human Hearing

The logarithmic taper is commonly called an audio taper because it is often used audio applications for loudness control. Understanding why involves knowing a little bit about human hearing. Figure 4 (Source) illustrates a human's perception of loudness relative to the Sound Pressure Level (SPL). Sound pressure level is proportional to an audio amplifier's output power. However, the ear is sensitive to the log of the sound pressure level. This is why the "logarithmic" taper is useful.

Figure 4: Loudness Level Versus Sound Pressure Level (dB).

Figure 4: Loudness Level Versus Sound Pressure Level (dB).

When people are adjusting the loudness of their audio gear, they prefer that the loudness increase by an amount proportional to amount of dial or slide movement. If a linear potentiometer is used to control output power (and therefore loudness), you will need to use larger and larger amounts of wiper movement to get the same loudness change. To get the same amount of loudness change for a the same amount of wiper movement, the potentiometer resistance needs to increase exponentially.

Compensating for Hearing

Figure 5 shows what how the loudness is perceived by a person as the potentiometer's wiper is moved. You can see that the perceived loudness increases approximately linearly for wiper positions above ~20%.

Figure 5: Potentiometer Resistance Model and Linearized Loudness Characteristic.

Figure 5: Potentiometer Resistance Model and Linearized Loudness Characteristic.

Conclusion

After all this research, I ended up not using the logarithmic potentiometer because it was not logarithmic. I ended up using another approach which I will discuss in a later post.

Posted in Electronics | Tagged , | 14 Comments

Meatball Math

Introduction

I used to watch the television show "MASH" years ago. They would refer to quick procedures for patient stabilization as "meatball surgery." I recently encountered some "meatball math" as part of my engineering job. I call it "meatball" because the "patient", a recalcitrant laser, had to be fixed quickly and rough approximations were totally acceptable. This application was a nice application of Mathcad and the implementation of the approximation in C will soon be going out in one our software loads.

Background

We use AVR processors from Atmel to perform simple controller functions. I like these processors so much that I have an AVR development system at home (you never know when you might want to cookup some controller code). In one of our products, we need to estimate the threshold current for a laser at a given temperature. It turns out that Equation 1 [Keiser] does a fair job of modeling the temperature variation of the threshold current.

Eq. 1 {{I}_{Threshold}}\left( T \right)={{I}_{z}}\cdot {{e}^{\frac{T}{{{T}_{0}}}}}

Equation 1 requires the computation of an exponential function. Unfortunately, a library version of the exponential function requires lots of memory space and my available AVR memory space is very small. However, it turns out that I do not need tremendous accuracy in this application – ±2% would be fine. I started to think in terms of a piecewise linear approximation. Let's take a look at what this approximation involves.

Analysis

Requirements

We begin with some simple algorithm requirements:

  • We need to compute the exponential function over an input range from 0 to 1.5
  • The exponential function must be accurate within 2%.
  • The routine must occupy much less memory than the accurate exponential library routine.

As always, I began my work by seeing if anyone else has already solved my problem. My first search turned up an article on a bifurcated linear approximation to the exponential function over the input range 0 to 1.

Bifurcated Approach

Figure 1 shows a plot of the bifurcated approximation. This equation meets my accuracy requirement, but it is not designed for my input range from 0 to 1.5. Let's use Mathcad to fix this.

Figure 1: Bifurcated Linear Approximation to the Exponential Function.

Figure 1: Bifurcated Linear Approximation to the Exponential Function.

Trifurcated Approach

I needed to get this approximation out quickly, so I decided to augment the range setup of Equation 1 (0 to 0.5, and 0.5 to 1) with a third range (1.0 to 1.5).

Figure 2 shows the form of my linear function and my error function, which I will minimize. I am using the "minimax" optimality criterion for my approximation.

Figure 2: Linear Approximation Prototype and My Error Function.

Figure 2: Linear Approximation Prototype and My Error Function.

We can use solver to find the optimal solution. Figure 3 shows my solution setup. Note that I randomly chose the starting values. I ended up trying various random starting values to come to my final choice of coefficients.

Figure 3: Trifurcated Mathcad Solver Setup.

Figure 3: Trifurcated Mathcad Solver Setup.

Note how I am also enforcing a continuity requirement at the end points of my ranges. The bifurcated solution did not enforce this criterion and their error function was not smooth. Figure 4 shows the results of my Mathcad work.

Figure 4: Plot of My Trifurcated Linear Approximation to the Exponential Function.

Figure 4: Plot of My Trifurcated Linear Approximation to the Exponential Function.


This solution was simple and took very little memory. Note that we ended up implementing it in fixed point math, which is probably worth another blog post.

Conclusion

The equation shown in Figure 4 solved my problem. This was a good example of a "quick and dirty" solution to a common engineering dilemma -- an accurate solution is too big or expensive and you need to find an approach that is good enough. That is exactly what was done here.

Posted in Astronomy | Tagged , | 1 Comment

Some Laser Basics

Introduction

I am doing some interesting work with lasers this week. I thought it would be useful to provide some background on how we build and control lasers. We deploy a lot of lasers in outdoor applications, which means that special attention must be paid to the temperature characteristics of lasers. If you are a small business that is considering getting a laser cutter then you should probably do your research to understand better how laser cutters work, you could take a look at something like this best laser cutter for small business to show you what could be offered to you. Keep on reading though to find out more about lasers, the automotive supply chain and how they work. Like batteries, lasers have characteristics that vary with temperature, with some industrial lasers needing products like North Slope needed to mitigate the heat and stabilize equipment for optimal laser performance. These temperature variations would cause the laser's output power to drop if actions were not taken to compensate for the temperature variations. These variations also make a laser subject to thermal runaway, also just like a battery. This week's work will focus on temperature compensation. But first, let's discuss how our lasers operate and are assembled. Once we have established that base, we can move on to related topics.

Laser Basics

Lasers emit light when they are driven by current above a level called the threshold current (symbolically IThreshold). The more current you drive into the laser above the threshold level, the more optical power that the laser emits. Figure 1 illustrates this characteristic.

Figure 1: Idealized Laser Output Power Versus Input Current Characteristic.

Figure 1: Idealized Laser Output Power Versus Input Current Characteristic.

Let's summarize the key points of Figure 1:

  • No optical power is emitted until the drive current exceeds a given value called IThreshold.
  • For drive currents above threshold, the laser emits an optical power proportional to the amount that the drive current exceeds the threshold level
  • The constant of proportionality is called Slope Efficiency (SE)

We can model this characteristic using Equation 1.

Eq. 1 {{P}_{Output}}=SE\cdot \left( {{I}_{Drive}}-{{I}_{Threshold}} \right)\text{ for }{{I}_{Drive}}>{{I}_{Threshold}}\text{, 0 otherwise}

This power versus drive current characteristic by itself does not cause any problems. However, IThreshold and SE both vary with temperature and this is the source of my woes. Figure 2 shows how the laser characteristics vary with temperature for a real device. Notice how the slope efficiency reduces with increasing temperature. That is the key problem, as I will discuss below.

Figure 2: Slope Efficiency Graph for an Actual Laser.

Figure 2: Slope Efficiency Graph for an Actual Laser.

Controlling Laser Power

Communication Using Lasers

Digital communications using fiber optics is similar to many other forms of digital communications in that we encode binary information by sending light down the fiber at two different power levels. The high-level is called a "1" and the low-level is called a "0". Figure 3 illustrates what an idealized optical bit stream looks like.

Figure 3: Example of a Digital Bit Stream Using Optical Power Modulation.

Figure 3: Example of a Digital Bit Stream Using Optical Power Modulation.

Because SE decreases with temperature, maintaining constant "1" and "0" levels means increasing the drive current with increasing temperature. It turns out that this is a more difficult problem to solve than you might think. Figure 4 shows how we convert drive current into optical power. We try to control two parameters:

  • IBias, which controls the average power level
  • IModulation, which controls the difference between P0 and P1.
Figure 4: Conversion of Drive Current Into Optical Output Power.

Figure 4: Conversion of Drive Current Into Optical Output Power.

Over the years, we have used various temperature compensation techniques. It turns out that controlling a laser's output power near room temperature is simple. However, particularly at high temperature, problems develop because the drive current becomes so high that the laser self-heats. This self-heating results in lower SE, which means more drive current. The laser is now in thermal runaway, which means our control circuitry will need to shut down the laser to prevent damage.

We have used feedback to control the laser's average output power \left( {{P}_{Average}}={}^{\left( {{P}_{High}}+{{P}_{Low}} \right)}\!\!\diagup\!\!{}_{2}\; \right). However, controlling the average power is not sufficient. Receivers actually detect the difference in power between a "1" and a "0". Reduced SE also reduces the difference between a "1" and "0". So we need an approach that will both increase the difference between the "1" and "0" drive levels and maintain an average power setting.

We have used a mathematical model for the variation of SE with temperature and have used this model to predict the required increase in the difference between the "1" and "0" drive levels with temperature. This has proven to be a mediocre solution. The temperature characteristics of a laser vary by vendor and lot. We need something better -- we need a two feedback loops. One feedback loop to control average power and another to control the difference in levels between a "1" and "0". It turns out that a new "dual-loop" laser drivers are now becoming available. Future posts will discuss how these devices work.

Basic Laser Construction

Before I go too far into controlling a laser, let's talk about how commercial laser systems are constructed. Figure 5 illustrates how lasers are typically configured for use in communications applications. The laser is mounted so that the vast majority of the optical power generated goes into the fiber, with a tiny fixed percentage tapped off for measurement by a photodiode (called the monitor photodiode). In Figure 2, the light going to the left is focused into fiber by some type of lens, which is commonly a ball lens but can be other types.

Figure 5: Standard Laser Configuration for Communications Applications.

Figure 5: Standard Laser Configuration for Communications Applications.

Figure 6 shows how lasers are packaged into transistor-outline (TO) cans, which is how we often see them.

Figure 6: Illustration of Laser TO-Can Packaging.

Figure 6: Illustration of Laser TO-Can Packaging.

Conclusion

This post was intended to provide some background for the posts to follow. These posts will look at applying lasers in communications applications.

Posted in Electronics, Fiber Optics | Tagged , , | 4 Comments

Baby Math

I was listening to a news program this weekend when I heard a journalist say that "4 million babies are born in the US every year." When I heard that statistic, I thought that I should be able to estimate that number using generally available information. Another Fermi problem!

But before we begin, I was inspired to write this post after speaking to two of my best friends. They have just had a baby and I got to meet her for the very first time a few days ago. She might only be a few months old, but already her parents have started playing educational songs and YouTube videos to keep her entertained! They are big believers in the notion that babies learn through music and I have to admit, some of the songs were pretty catchy so I can definitely see the appeal.

Now, baby news to one side, let's see if we can come up with a rough estimate of the number of babies born in the US every year. Here is my line of reasoning.

  • There are about 310 million people living in the US. For rough figuring, let's say 320 million because it has more even divisors.
  • Half the US population are women, which means there are 160 million women in the US.
  • Assume that US women have a life expectancy of 80 years, with 20 years being the primary childbearing years. So at any time, 25% (40 million) of US women are in their childbearing years .
  • Most of these women will experience a healthy birth and will bring an equally as healthy newborn into the world. There will be others, however, who won't have the same joy in that their child could be born with a birth defect - visit somewhere like LawTX to learn more about what they are and how you can proceed with your compensation claim.
  • The average US family has around 2 children. So US women spend roughly 2 years of their 20 childbearing years pregnant (10% of their childbearing years).
  • So at any one time about 4 million women are pregnant in the US.
  • Since most of these women have one baby at a time and pregnancy takes roughly a year, I would expect that 4 million babies are born in the US each year.

I was able to estimate that 4 million babies are born in the US each year using generally available information. This agrees nicely with the actual value of 4,055,000 (2010). Whenever I hear a statistic, I always like to think about it and see if it makes sense. Hearing that 4 million babies are born in the US each year now makes sense to me.

Posted in General Mathematics | 1 Comment

Book Review: Solving Mathematical Problems By Terence Tao

Figure 1: Terrence Tao with Paul Erdos.

Figure 1: Terrence Tao with Paul Erdos.

While on my vacation to Ireland, I brought along a book called "Solving Mathematical Problems: A Personal Perspective" by Terence Tao. The book was written when Tao was a 15 year old mathematics prodigy competing in international mathematics competitions. Today at 36, he is one of the world's top mathematicians.

I have really enjoyed reading this book. I work with a lot of folks on developing their problem solving abilities. In the past, I have used the books by Polya (here is one and another) on problem solving heuristics. While these books are good, I really like the tone of "Solving Mathematical Problems." Tao does a very good job of describing the experimental aspects of problem solving.

Many folks new to problem solving will see a fully formed solution and do not understand that there may have been quite a bit of trial and error involved in coming up with that solution. Thus, the most common question I get from these newbies is "how do I know where to start"? Tao addresses this question by including with his solutions a discussion of alternative approaches and why he chose not to use them. I really appreciate this style of presentation -- all in the voice of a 15-year old. It is conversational and pleasant to read.

The book is focused on the kind of problems encountered in mathematics competitions:

  • Analytic geometry
  • Euclidean geometry
  • Number theory
  • Polynomials
  • Diophantine Equations
  • Sequences and Series

It is a small book, but filled with mathematical gems. If you decide to check it out, I think you will find it worthwhile.

Posted in General Mathematics | Comments Off on Book Review: Solving Mathematical Problems By Terence Tao

Potato Math

Quote of the Day

Being president is like running a cemetery -- you've got a lot of people under you and nobody's listening.

- Bill Clinton


Introduction

I have taken a break from blogging to do some traveling. You may have already noticed from my Instagram account. I've decided to start using it again. To be honest, I probably would've stayed off it for a bit longer hadn't it been for my friend who is starting to get a lot of followers to their account. I think they said they have enlisted the help of an instagram manager to assist with their growth, and I have to say it's definitely seemed to work. So, you could say that it was part of my decision to start using it again. It'll also allow me to remember those places and bring back memories. I only have one issue... I have zero followers?! I know there are ways to get free followers on sites similar to socialfollow so I may give that as a shot! But above all, the highlight of my travels has been a bus trip around Ireland. It was great! We spent 8 days on a bus driving all over Ireland (see Figure 1). We also spent 4 days on driving around Ireland on our own. I must admit that driving on the left-hand side initially worried me, but after a day of careful, thoughtful driving it started to feel normal.

Figure 1: Our Bus Ride Around Ireland.

Figure 1: Our Bus Ride Around Ireland.

The Irish could not have been nicer, but things are not easy over there. Their economy is in a shambles and the cost of living there is high -- I read a news article that stated that Ireland has the fifth highest cost of living in the EU. They have many of the same economic complaints as the folks in the US:

  • clueless politicians
  • corrupt bankers
  • no one to hold accountable

In the case of the Irish, their sadness is particularly profound because many feel that their chief export today is their young people – just as during the Irish Famine. Thank goodness that Australia has work for some of them. However, losing your young people because of economic conditions is a terrible thing to say about an economy.

During our trip, the impact of the potato on Irish history could not be ignored. While I have no Irish ancestry (my wife has all the Irish blood), I do feel a kinship with the Irish in regards to the potato. I was raised in a small town that was surrounded by potato fields, my brother was a potato farmer, and I worked on a potato farm to earn money for college. When I was a boy, the potato farmers would proudly boast that no crop produced calories per acre like the potato. While apple growers may take exception, the potato does beat the grain crops handily. Consider the data in Table 1 for irrigated crops today. Yields at the time of the Irish Famine were substantially less.

Millions of Kilocalories Per Acre By Crop
Crop Millions of Kilocalories Per Acre
Soybeans 2.1
Wheat 6.4
Corn 12.3
Potatoes 17.8

Potatoes were the calorie per acre leader back in 1846 as well.

Our bus stopped by the Irish National Famine Museum. It was very impressive place that provided us some insight to the living conditions at that time. During our tour, our guide discussed a number of Irish Famine facts:

  • The landlords made their money by exporting all the corn, wheat, barley, and oats the Irish farmers grew. The Irish grew potatoes to feed themselves.
    This meant that the Irish subsisted on the potatoes and dairy products that they could grow on their land. Remarkably, potatoes and a bit of dairy will provide a nutritious diet (Reference)
  • At the time of the Famine, an average Irish farmer consumed ~14 pounds of potatoes a day (Reference).
    While this seems like a lot of potatoes, the calories work out about right for a person doing hard manual labor.
  • During the depths of the Famine, potato yields dropped to 1/7th of their pre-Famine levels (Reference).
  • The Famine Museum is on an old farm site at which there were 5000 tenant farmers on 30,000 acres, with an average of 6 acres for each farmer.
    This is a very small amount of land on which to support a family. I failed to find a good reference for the average family size prior to the Famine. I found one economic reference that used an average family size of five (Reference), but that was lower than some reports. For example, I have seen forum discussions that estimated average family at eight or more (Reference).
  • When the potato blight hit, the landlord ordered his tenant farmer to switch from growing potatoes to oats.
    Oats turned out to be completely inadequate as a food source and starvation set in. The landlord began to fear for his life as the starving masses began to rise up. It turned out he did have something to fear as one of his tenants eventually did kill him.

Let's examine that calories per acre question a bit closer. How big an impact did the switch from potatoes to oats have on calorie production?.

Analysis

Our Famine Museum tour guide mentioned that potatoes produce 2.5 times more calories per acre than oats. Let's try to understand where this number comes from because it is critical to understanding the Famine.

  • I will assume an average of 9 tons of potatoes per acre.
    Prior to the start of the Irish Famine, Irish potato yields varied from 6 to 12 tons per acre (6 ton Reference, 12 ton Reference).Agricultural yields are highly variable because of soil conditions, weather, crop enemies (insects, rodents, fungi, etc), and agricultural practices (e.g. availability of manure for fertilizer and water for irrigation).
  • Potatos provide 77 kilocalories per 100 grams (Reference).
    Potatoes are between 75% and 80% water, which makes their calories density appear to be low. However, potatoes still produce the greatest number of calories per acre for a standard field crops (apple growers like to claim the title of most calories per acre for any crop)
  • I will assume an average of 39 imperial bushels of oats per acre (Reference) and 40 pounds of oats per imperial bushel (Reference).
  • Oats provide 389 kilocalories per 100 grams (Reference)

Given this information, the calorie comparison between potatoes and oats can be performed as shown in Figure 2.

Figure 2: Comparison of the Calories Per Acre Between Potatoes and Oats.

Figure 2: Comparison of the Calories Per Acre Between Potatoes and Oats.

So I now understand the calorie difference between potatoes and oats. If we assume that the Irish tenant farmers were growing their personal food on the same acreage as before, the switch from potatoes to oats meant that the land could now only support 40% of the existing population. One solution to the problem would have been to stop exporting crops and use those crops to feed the Irish. The landlords did not do this. They simply chose to let the Irish starve.

Conclusion

Sadly, the Irish Famine was completely unnecessary. It turns out that there was plenty of food in Ireland to feed the people, but the landlords needed to export the food in order to keep their incomes up. The attitude of the government is summed up by the following quote (Reference).

The economists then concluded that since all the demand side measures had failed, nothing could be done. The only way to prevent future famines was to reduce demand, by "letting nature take its course". "‘I have always felt a certain horror of political economists,' said Benjamin Jowett, the celebrated Master of Balliol, ‘since I heard one of them say that he feared the famine of 1848 in Ireland would not kill more than a million people, and that would scarcely be enough to do much good.' The political economist in question was Nassau Senior, one of the Government's advisers on economic affairs." (Woodham-Smith 1991 pp 375-6). He need not have worried: 2.5 million people died out of a population of 8 million.

You might wonder how the British were able to export food with starving people all around. Here is another quote that describes that situation (Reference).

Ireland starved because its food, from 40 to 70 shiploads per day, was removed at gunpoint by 12,000 British constables reinforced by the British militia, battleships, excise vessels, Coast Guard and by 200,000 British soldiers (100,000 at any given moment)

Posted in History of Science and Technology | 2 Comments

How Much Does A Cloud Weigh?

Introduction

We have had a lot of rain in Minnesota this summer. As I sit here staring at the rain falling hard outside, I occurs to me that a cloud must be a very heavy thing in order to drop this much rain. It seems to me that figuring out the weight of a rain cloud would be a good Fermi problem. This cloud also dropped quite a bit of rain – how much of the cloud mass was lost as rain? Let's dig in …

Background

I need to round up some facts about clouds.

  • Clouds float for the same reason a balloon floats – cloud material weighs less than air.
  • The density of air at a typical altitude and temperature is about 1.007 kg/m3.
    This is an interesting number. Air is heavier than I thought. Think about it – a cubic meter of air weighs 1.0 kg, which is 2.2 lbs. For some reason that seems like a lot to me.
  • The density of cloud droplets is about 1.003 kg/m3.

Given these typical characteristics, lets try a specific example.

A Cloud Example

The cloud that hangs over my home can be modeled as a cuboid.

  • The cloud height (top to bottom) is 2 km (hCloud= 2 km)
  • The cloud length is 10 km (lCloud= 10 km)
  • The cloud width is 5 km (wCloud= 5 km)
  • This cloud dropped 2 inches of rain (lRain= 2 inches)

Analysis

A quick bit of Mathcad work gives me my estimate for cloud weight and the percentage of weight that rain represents.

Figure 1: Estimate of Cloud Weight and the Percentage Rain Represents of a Cloud.

Figure 1: Estimate of Cloud Weight and the Percentage Rain Represents of a Cloud.

Conclusion

I would have never guessed that a cloud weighed that much. I also am surprised that a major rainfall represents such a small portion of the weight.

Posted in General Science | 6 Comments

More Interview Criteria and A Funny Story

I read a management forum on LinkedIn that I like. The following exchange was on the forum yesterday that made me smile. Two people were discussing how to evaluate an interviewee.

Justin Hoffman • I use four simple guidelines (KSQB) Do they have the necessary industry "knowledge" to be successful. Do they have "skills" required for their role. Do they have the fundamental "qualities".

I can develop knowledge and skills over time but, I will never compromise on qualities. Qualities are many of the things noted above (integrity, leadership, drive, passion, honesty, etc.) I rank all candidates on a scale of 1-10. To this day I can go back and see a direct connection in candidates I have pushed or been pushed to hire that rank below an 8 on qualities. The net result is always the same...not good for either of us.

The last is a simple Y/N. Would I enjoy having a "beer" with this person after work. If I don't enjoy spending time with the people I work with then what's the point. I spend more time with my employees/co-workers than I do my own family. I better like them.

The response below is pretty funny. I have had the experience of finding a very qualified candidate that I would not necessarily want to spend a lot of hours with.

Dave Stevens • @ Justin, very good check list. I interviewed someone with an extensive and packed resume once, the font was below 6, but the sentence that stood out was her experience in the Alcohol Enforcement Patrol in law school, where she volunteered to snuff out all inappropriate drinking parties on their DRY campus. She was at the top of her class, a Jeopardy champion, and you could not touch her on accomplishments. But, the partners in this very large law firm thought she would conflict with our Friday scotch nights.

Posted in Management | 1 Comment

Capacitor Puzzle Redeux

My first blog post discussed the following interview question I received many years ago.

You are handed a 1 F capacitor charged to 10 V and two boxes containing uncharged capacitors: one box contains an uncharged 1 F capacitor and the other contains 1 million 1 µF capacitors. You can connect the capacitors from one box, one at a time, across the charged capacitor. Your job is to determine which box will allow you to discharge the voltage on the charged capacitor the most?

I received a comment recently from a reader who had looked at the problem and brought up an interesting aspect of the problem that I had not mentioned – energy does not appear to be conserved. My solution used charge conservation, so I skirted the energy conservation issue. Here is how the question came to me.

Meant to mention that these two problems together beg the question of how much energy is stored in the million charged 1uFs and, added to 6.7668 joules remaining on the 1F, how does the total compare to the original 50 joules. This is a tougher problem because each small cap is charged to a different – though calculable – value. I haven’t tackled that question yet; maybe you have.

Many problem solutions depend on some property remaining true throughout some transformation. A property that remain true throughout a transformation is called an invariant. There were clearly two candidate invariants in this problem: energy conservation and charge conservation. It turns out that the bookkeeping for the charge conservation is easier because this problem presents no opportunity to lose charge. Unfortunately, the bookkeeping for energy conservation is more difficult because energy can be lost in the interconnection between the capacitors. I will illustrate how using energy conservation for this problem presents an issue – how do I determine the losses that occur in the interconnection?

Let's begin my computing the energy on the 1 F capacitor before and after the million 1 microfarad capacitors have been attached. Since I am computationally lazy, I will write a Mathcad program to compute the result.

Figure 1: Energy on the 1 F capacitor before and after one million microfarad capacitors were attached.

Figure 1: Energy on the 1 F capacitor before and after one million microfarad capacitors were attached.


From this calculation we can see that the 1F capacitor loses about 43.2 Joules of energy. We now need to compute how much energy did the million one microfarad capacitors pick up, which is done below.
Figure 2: Energy on the One Million Microfarad Capacitors.

Figure 2: Energy on the One Million Microfarad Capacitors.


The million microfarad capacitors only ended up with 21.6 J of energy. Therefore, we are missing 42.3 J - 21.6 J = 21.7 J of energy.

Energy must be conserved, so where did the energy go? It was lost during the charge transfer through a combination of heat and electromagnetic radiation. This is why I used charge conservation for my invariant. I did not have a way to determine the energy loss that occurs during the connection.

Posted in Electronics | 4 Comments

Thermistor Mathematics

Quote of the Day

If Hitler invaded hell, I would have had a nice word or two for the devil in the House of Commons.

— Sir Winston Churchill, his response when asked why he was saying nice things about the Soviet Union after Hitler invaded the Soviet Union.


Introduction

Figure 1: Typical Thermistor Construction and Symbols (Source).

Figure 1: Typical Thermistor Construction and Symbols (Source).

A common electrical engineering task during the design of a circuit card is designing a way for the circuit to measure its own temperature. Knowing the temperature of a circuit board is important for compensating for component temperature variations and diagnosing heat problems. Normally, I use a thermistor as my temperature probe. A thermistor is a resistor whose resistance varies with temperature (Figure 1). The thermistors that I use have a negative temperature coefficient (NTC), which means their resistance reduces as their temperature increases. In many ways, thermistors are a great sensor: cheap, tough, small, and accurate.

Thermistors have one major drawback – their resistance variation with temperature is non-linear. Figure 2 shows how the resistance of a typical NTC thermistor varies with temperature.

Figure 1: Resistance Versus Temperature for a Murata NCP03XM102 05RL Thermistor.

Figure 2: Resistance Versus Temperature for a Murata NCP03XM102 05RL Thermistor.

Linearity is a sensor characteristic that is loved by analog engineers. For this kind of problem, it means that calibration is simple (i.e. two points determine a line) and I do not need a processor around to implement complex compensation equations. The resistance characteristic of an NTC thermistor is too non-linear for my application directly. But what if I combined the NTC thermistor with other components in a manner that would somehow tame this non-linear response? This post will look at a common approach to linearizing the circuit response from a thermistor.

Problem Description

All engineering problems begin with determining requirements. Here is how I see my requirements for this problem:

  • Limited range of temperatures to be measured
    I only need to measure temperature over a limited temperature range (0 °C to 40 °C). This is considered the standard temperature range for indoor applications.
  • Minimal calibration
    Sensors usually require calibration, which is an expensive operation in production.
  • Generates a voltage that varies linearly (approximately) with temperature.
    I want a linear sensor to simplify my calibration. A linear sensor requires a couple of measurements to complete calibration.
  • Temperature accurate within 5 °C.
    This level of accuracy means that I can get by with an approximately linear sensor.
  • Minimal impact on software
    My processor is a very limited microprocessor (i.e. AVR) with minimal memory. I will use an analog-to-digital converter in the processor to read the voltage. I want the conversion from voltage to temperature to very simple. I have neither the memory nor time to require any fancy curve interpolation to get a simple temperature reading.
  • Minimal Printed Circuit Board (PCB) space because I only have space for a couple 0603-sized (i.e. 0.6 mm x 0.3 mm) components. Instead, you could consider contacting a PCB software specialist company for advice or help with this electrical engineering task (such as Altium for example).
  • Minimal cost
    I need something that costs pennies.
  • No integrated circuits.
    I am not wild about using an IC in this application. There are quite a few ICs that put out a voltage that is Proportional to Absolute Temperature (PTAT), but they generally require a power supply voltage that I do not have available or they cost too much.

Thermistor Characteristics

The resistance characteristic of Figure 1 can be modeled in a number of ways, but only two are really seen often: the Steinhart-Hart equation, and the ß-Parameter Equation.

The classic approach is the Steinhart-Hart equation (Equation 1). It is a very accurate model. In fact, it is far more accurate than I need.

Eq. 1 \frac{1}{T}=a+b\cdot \ln (R)+c\cdot {{\ln }^{3}}(R)

where

  • a, b, c are parameters that are chosen to fit the equation to the resistance characteristic.
  • R is the thermistor resistance (Ω).
  • T is the thermistor temperature (K)

While the Steinhart-Hart equation may be accurate, I have found it useless for use by an analog designer in a hardware application. It is simply too difficult to work mathematically without substantial software resources.

The ß-Parameter Equation is much more interesting to an analog engineer. Equation 2 shows the ß-Parameter Model as it is usually seen.

Eq. 2 R={{R}_{0}}\cdot {{e}^{\beta \cdot \left( \frac{1}{T}-\frac{1}{{{T}_{0}}} \right)}}

where

  • R0 is the themistor resistance at temperature T0
  • ß is a curve fitting parameter.

The ß-Parameter Model is sufficiently accurate for my purposes and is much simpler to work with mathematically than the Steinhart-Hart equation. We will use this model for the remainder of this post.

Thermistor Linearization

Approach

Most thermistor linearization approaches involves adding parallel or series resistors. I will use a thermistor with a series resistor configured as a voltage divider (see Figure 3). This is the simplest linearization circuit that I can think of.

Figure 2: Simple Series Resistor Circuit for Thermistor Linearization.

Figure 3: Simple Series Resistor Circuit for Thermistor Linearization.

We will be measuring the output voltage (VOut) from the voltage divider, which is given by Equation 3.

Eq. 3 \frac{{{V}_{OUT}}}{{{V}_{IN}}}=\frac{{{R}_{S}}}{{{R}_{S}}+{{R}_{T}}\left( T \right)}

where

  • VIN is the voltage divider drive voltage.
  • VOUT is the voltage divider output voltage.
  • RS is the resistance of the series resistance.
  • RT(T) is the resistance of the thermistor.

To get an intuitive feel for the how the linearization occurs, you need to consider the asymptotic cases. For low temperatures, RT(T) is large relative to RS and the output is approximately {}^{{{V}_{IN}}\cdot {{R}_{S}}}\!\!\diagup\!\!{}_{{{R}_{T}}\left( T \right)}\;, which approaches 0 as the temperature drops. For high temperatures, RT(T) is small relative to RS and the output voltage approaches VIN. Figure 4 shows the thermistor resistance and the normalized output voltage versus temperature.

Figure 3: Example of a Thermistor's Resistance and the Linearized Voltage Divider Ratio.

Figure 4: Example of a Thermistor's Resistance and the Linearized Voltage Divider Ratio.

Look closely at Figure 4 and you will see an inflection point in the curve (452 Ω and 50 °C in Figure 4). At the inflection point, \frac{{{d}^{2}}}{d{{T}^{2}}}\left( \frac{{{V}_{OUT}}}{{{V}_{IN}}} \right)=0. After a long, tedious derivation (shown in the Appendix below), one can show that the inflection point can be moved where you want it by changing RS. Equation 4 shows the relationship between the temperature of the inflection point and the value of RS.

Eq. 4 {{R}_{S}}={{R}_{0}}\cdot {{e}^{\frac{\beta }{{{T}_{I}}}-\frac{\beta }{{{T}_{0}}}}}\cdot \frac{\beta -2\cdot {{T}_{I}}}{\beta +2\cdot {{T}_{I}}}

where

  • TI is the temperature of inflection.
  • T0, R0 ,and ß are thermistor parameters given by the thermistor vendor.

The "rule of thumb" is to select RS to place the inflection point in the middle of your temperature range of operation. As you can see in Figure 4, this placement helps to minimize the maximum deviation from a line through the inflection point. However, it is not guaranteed to be the point of minimum error. When I need that level of accuracy, I use numerical methods to find the RS that minimizes the maximum error.

Example

Figure 5 shows a worked example of my thermistor calculations in Mathcad.

Figure 4: Example of Thermistor Calculations for Series Linearization.

Figure 5: Example of Thermistor Calculations for Series Linearization.

Conclusion

The design of the linearization circuit for a thermistor is a nice use of basic calculus in an engineering application. Hopefully, some of you will find all the details presented useful.

Appendix

I wanted to record my derivation of Equation 4 so I would not have to go through the derivation pain again later, but since it is long and tedious I did not want to put readers through it – an Appendix seemed the appropriate place.

My approach is straightforward:

  • Develop an expression for VOUT using the ß-Parameter model.
  • Take the first and second derivatives of this expression.
  • Set the second derivative equal to zero.
  • Solve this expression for RS.

The derivation is shown in Equation 5. I will let the details stand for themselves.

Eq. 5 \text{Let }G\triangleq \frac{{{V}_{OUT}}}{{{V}_{IN}}}=\frac{{{R}_{S}}}{{{R}_{S}}+{{R}_{T}}\left( T \right)}
G=\frac{1}{1+\frac{{{R}_{{{T}_{R}}}}}{{{R}_{S}}}\cdot {{e}^{\frac{\beta }{T}}}}=\frac{1}{1+k\cdot f(T)}
\text{where }k\triangleq \frac{{{R}_{{{T}_{R}}}}}{{{R}_{S}}}\text{ and }f(T)\triangleq {{e}^{\frac{\beta }{T}}}
\frac{dG}{dT}=-\frac{k\cdot {f}'\left( T \right)}{{{\left( 1+k\cdot f\left( T \right) \right)}^{2}}}
\frac{{{d}^{2}}G}{d{{T}^{2}}}=-\frac{k\cdot {{f}'}'\left( T \right)\cdot {{\left( 1+k\cdot f\left( T \right) \right)}^{2}}-2\cdot \left( 1+k\cdot f\left( T \right) \right)\cdot {{k}^{2}}\cdot {f}'{{\left( T \right)}^{2}}}{{{\left( 1+f\left( T \right) \right)}^{4}}}
{{f}'}'\left( {{T}_{I}} \right)\cdot \left( 1+k\cdot f\left( {{T}_{I}} \right) \right)-2\cdot k\cdot {f}'\left( {{T}_{I}} \right)=0
\text{where }{{T}_{I}}\text{= inflection temperature}
{{f}'}'\left( {{T}_{I}} \right)+k\cdot {{f}'}'\left( {{T}_{I}} \right)\cdot f({{T}_{I}})=2\cdot k\cdot {f}'{{\left( {{T}_{I}} \right)}^{2}}
k=\frac{{{f}'}'\left( {{T}_{I}} \right)}{2\cdot {f}'{{\left( {{T}_{I}} \right)}^{2}}-{{f}'}'\left( {{T}_{I}} \right)\cdot f({{T}_{I}})}
k=\frac{\left( \frac{{{\beta }^{2}}}{T_{I}^{4}}+2\cdot \frac{\beta }{T_{I}^{3}} \right)\cdot f\left( {{T}_{I}} \right)}{2\cdot \frac{{{\beta }^{2}}}{T_{I}^{4}}f{{\left( {{T}_{I}} \right)}^{2}}-\left( \frac{{{\beta }^{2}}}{T_{I}^{4}}+2\cdot \frac{\beta }{T_{I}^{3}} \right)\cdot f{{\left( {{T}_{I}} \right)}^{2}}}=\frac{1}{f\left( {{T}_{I}} \right)}\cdot \frac{\beta +2\cdot {{T}_{I}}}{\beta -2\cdot {{T}_{I}}}
k\triangleq \frac{{{R}_{{{T}_{R}}}}}{{{R}_{S}}}=\frac{1}{f\left( {{T}_{I}} \right)}\cdot \frac{\beta +2\cdot {{T}_{I}}}{\beta -2\cdot {{T}_{I}}}\Rightarrow {{R}_{S}}={{R}_{0}}\cdot {{e}^{\frac{\beta }{{{T}_{I}}}-\frac{\beta }{{{T}_{0}}}}}\cdot \frac{\beta -2\cdot {{T}_{I}}}{\beta +2\cdot {{T}_{I}}}

You can also derive Equation 4 using Mathcad, which I demonstrate in Figure 6. The main issue with my Mathcad derivation is that many of the details are hidden. However, it took me less than a minute to complete it.

Figure 5: Mathcad Derivation of Equation X.

Figure 6: Mathcad Derivation of Equation 4.

Save

Save

Save

Posted in Electronics | 35 Comments