Friday, 24 February 2012

Why do we have capacitors at IC supply pins

In analog/digital circuit, we always see capacitors being connected from supply pins to circuit ground, but why?

From my perspective, the two primary reasons for those caps are:

Reason #1:
Connection from supply to IC has impedance - those caps (placed near the IC) will supply most of fast current demand which gives less voltage fluctuation on supply pin when supply current flows

Reason #2:
The supplies  are not ideal, regardless of them being a battery or switch mode supply, there is always internal impedance/resistance, and those capacitors will make sure the IC "see" low impedance supplies across the frequency of its bandwidth (remember that capacitor impedance drops as frequency increase)

Saturday, 18 February 2012

Purpose/Introduction of this blog

To provide an introduction of analogue /mixed circuit design consideration in
1.       As little equation
2.       As much diagram as possible – A picture is worth a thousand words.
4.       Talk about each aspect in 1-2 page max
The bad news is that there is too much information on this subject for any decent mind to pick it ALL up. It takes time to know enough to be good in this.
But the good news is that, you don’t need to master all at once, starting with a desire to learn, you can consider the below to get started
1.       Read through basic stuffs (Kirchhoff’s Law, Thevenin's theorem …) – remind yourself on what’s the purposes of the stuffs you learn, and no memorization please
2.       Seek and read articles that talk about the real life circuit – things that people learnt it the ‘Hard Way’ - the book “The Arts of Electronics” is one of my favourite.
3.       Live by the motto “seek to understand, then to be understood” – when things don’t work, take it easy, isolate the problem, seek to understand the problem, the solution will come automatically once you know what’s going on.
4.       Always hands on – reading won’t get you far, try the following
a.       Know what needs to be build
b.      Takes a couple of days to do background study – you don’t have to fully know all the details though
c.       Build it – possibly through simulation software, then prototype it with most basic stuffs
d.      Test it up – with the understanding that things will not work as expected (for average person, getting the expectation right is utmost important, coz when things don’t work (and trust me, usually it won’t)). This will allow you to avoid the frustration
e.      Debug the circuit – understand the root cause, cross check with theory when things don’t work as expected.

Opamp: Gain Setting Resistor Type and Package Consideration

 What is the resistor type to use?

In a nutshell:

1.       You would need to know the requirement of your circuit
2.       You need to know what’s available and what’s not in terms of selecting resistor
3.       You need to know how real life resistor deviate from text book

Requirement of circuit:

Ok, to answer this seemingly simple question, we need to know a few aspect of the circuit function
1.       Power rating required?
2.       Accuracy required?
3.       Cost allowed?
4.       Availability?

Basic knowledge:

1.       Then you would need to know what’s available in the market, of course the best place to get to know this is through wiki: http://en.wikipedia.org/wiki/Resistor
2.       Some good info on Resistor 101 (www.vishay.com/docs/49873/49873.pdf)
3.       It is extremely rewarding if you understand pros and cons of basic resistor types, as they allow you to make your selection almost immediately in future. Resistor is basic ingredient in most circuit, so your time invested is going to have a pretty good ROI (return of investment J)
4.       Continue from point #2, below are some basic type and common expectation that I have on them (off my mind)
a.       Wirewound
i.      Expensive – as it takes effort to wind those wire, and just imagine how long the wire to use to get at 1MOhm (to state the obvious wire is always in mOhm range)
ii.      High inductance – hey, wound wire is almost like a inductor, so if the circuit is of high frequency nature, I would avoid it
iii.      Precision – not much drift
b.      Thin film
i.      Accurate
ii.      Low inductance – no winding of conductor
iii.      Low noise
iv.      Low Resistance – how much resistance can a piece of film has
c.       Thick film
i.      Wide range of value
ii.      Cannot be as accurate as thin film
d.      Carbon
i.      Easily available
ii.      Noisy – compare to other resistor types, the question is how relevant this noise is to application

Real life resistor

1.       Temperature coefficient:
a.       what is means is that the resistance value will change according to temperature, stated as ppm per unit temperate change,
b.      note that temperature of the resistor is in turn depend on the selfheat of the resistor and ambient temperature change. Which means the better the temperature coefficient is, the better the accuracy is (more expensive as well)
c.       The temp coef is readily available in the datasheet, so you are generally know what you are getting

2.       Breakdown voltage
a.       If you have a 0.1Watt 10MOhm resistor, you would expect that the voltage level can go up to P = V^2/R = sqrt (P*R) = sqrt (1M) = 1kV
b.      But the fact is that all resistor will eventually breakdown above certain voltage, and for a typical part, 1kV certainly is too much to bear with. Use of common sense tells you that all 0805, 0603, 0402 has too little clearance between terminals and should not be able to handle it kV – either resistor breakdown or arcing will occur.
c.       This value is generally available in the datasheet, ensure no violation on this spec.

3.       Voltage coefficient
a.       One of the most likely mistake in choosing resistor is that fresh engineer overlook the fact that resistance changes when voltage across them changes. If you are using a voltage divider, this will give you some serious error depend of the resistor type
b.      Resistor that meant for high voltage (above 100V I think) will generally have this spec in the datasheet. If you can’t find this spec, and you intend to use the resistor for 100V or more, good luck.

4.       Power dissipation
a.       Given enough power, you can raise temperature of resistor into > 100degC, as long as that does not go beyond resistor’s rating you are fine, but your resistance will change like crazy
b.      Given too much power, you can burn the resistor, literally.
c.       So always size up the resistor size for the expected power level.
d.      To give an example: a 0.1W 0603 resistor will have power derating curve as below: to get the sense of how much temperate rises for a given operating condition, let’s calculate the thermal impedance of this part.
i.      Rated power = 0.1Watt
ii.      Tmax = 155degC (refer to any resistor datasheet for this, in 0603, the curve is labelled as 3E in this particular example)
iii.      TderatingStart = 70degC
iv.      Rthermal = (TmaxTderatingStart)/Prated = (155-70)/0.1 = 85degC per Watt

Application of knowledge:

Now that you know about what you can choose from, non-ideal characteristic of resistor and the requirement from your circuit, let’s go through some of it
1.       Power rating required?
a.       Calculate worst case power dissipation
b.      Ensure factor in the ambient temperature of end product
i.      If your product is going to be used in outdoor of Africa, then be prepare for the maximum ambient temperate
2.       Accuracy required?
a.       If your circuit has calibration, then initial tolerance is less critical, only drift and calibration period matters.
b.      Remember temperature changes of the resistor due to power dissipation or environmental temperature will change the accuracy. For example, a 100ppm part with negligible power dissipation but having 10degC operating temperature changes will have 1000ppm of changes, which is 0.1% of error.
c.       Consider to mount the gain setting resistor close by, such as both will see the same temperature changes. By doing so, both resistor values will drift together, and since the gain is depend on the ratio of the two, total error will be much less. Remember certain part of the PCB will always be hotter than the rest, as high power devices always heat up the region around it.
3.       Cost allowed?
a.       Know how much you are supposed to spend
4.       Availability?
a.       It is useless if you cannot get the resistor in time , or you can’t buy them
b.      If your design cycle is short, always pick those parts that distributor has plenty of stock. Some part lead time can be as long as 16weeks – 4months!!
5.       Others
a.       If you are going to handle the assembly, pick resistor size that is manageable. Personally, it is extremely tough to handle 0402 part
b.      For prototyping or hand build board, 0603 part is extremely useful, as the standard prototyping breadboard will have holes just about 60mils, so you can solder them neatly and tightly.

References

www.vishay.com/docs/49873/49873.pdf

Tuesday, 14 February 2012

Opamp: Gain Setting Resistor Consideration

We know that the gain is R2/R1, and we already know what level of gain we want, for example if we want gain of -1, then R2/R1 = 1
But what about the absolute value of R1 and R2? No matter whether I choose R1 = R2 = 1Meg or R1 = R2 = 1Ohm, the gain is still -1. What are the considerations involves in choosing the absolute value?

It is the way nature works

Just like planets evolve around sun, in nature’s world, log or exponential relationship is a common place.
For example:
1.       Radioactive material has a half cycle of x amount of years
2.       House mortgage or anything with compounded interest. If you principle is x0 amount of \$\$, with annual interest rate of i%, then without any payment, the balance at the end of each year will be x0 * (1+ i/100)^n, with n = the amount of years

To be able to look at wide dynamic range

 x y 1 1.00 2 2.00 3 4.00 4 8.00 5 16.00 6 32.00 7 64.00 8 128.00 9 256.00 10 512.00
Table 1
By representing gain/freq/attenuation in dB we are able to have a clue on how information of interest behaves over a wide range.
Let’s look at the perspective when we keep the linear scale at x-axis and do a linear (Graph 1) and a log scale y-axis plot (Graph 2) on a set of logarithmic data (which is very common in engineering life) and have a feel of the details of visual info available.

To be able to perform simulation with minimum resource

Figure 1: log scale from 1 to 10Meg
Consider the case of a simple low pass filter, if we were to calculate the response from 1Hz to 1MHz in one 1Hz step, then we need 1 million data points, which takes time.  Instead of doing it the bull-dozer way, in log scale we only have to take 10 data points (it can be more) for each decade (x10), on in this case we have 6 decade * 10 points – just 60 points of calculation. Looking at Figure 1 gives you a sense of the look in logarithmic scale.

To be able to read specification

In engineering world, lots of specification being stated in dB, so by learning it, you are in tune with the industrial. If you want to be in engineering world, you must speak engineering terms, or your life will be miserable.  It is as simple as not speaking English in UK or Japanese in Japan.
For example, we state filter attenuation, RF amplifier gain in dB

To turn multiplication/division into algebra

Let’s acknowledge this, hand calculation of multiplication is too much a pain in the ass.

By learning how to “log” a number, and how to “antilog” a number, all multiplication and divide WILL becomes simple algebra (addition or substract).  If you have forgotten how to do it – refer to http://obsoleteskills.wikispot.org/Reading_a_log_table
Let’s say we want to know the following by hand calculation (use table attached)
23445 * 0.923 / 24543 = ?
To solve the problem using algebra, there’s only a few steps (simple steps)
1.       Find out (for this you need to learn to use the log table, see the reference).
a.       Log10 (23445) = 4.3701
b.      Log10 (0.923) =-0.0348
c.       Log10 (23543) =4.3900
2.       Perform algebra operation according to * or / : 4.3701 + (-0.0348) – 4.3900 = - 0.0547
3.       Then perform antilog operation: 10^(-0.0547) = 0.8817
Look at how AMAZING this is, this is so simple and do-able. In engineering works, do don’t need all the precision in the digit, for the following reason:
1.       Real measurement circuit is only accurate up to certain level, 5digit is pretty good – which correspond to 0.001% accuracy and this is already very very good.
2.       Practical environment does not allow precision data, even if your equipment is able to do it. for example, maybe you only have 1ms to perform your measurement, but to reach 0.01% accuracy you would typical needs 10’s of ms to get a stable result (actual time depend on your equipment).
3.       To get intuition, 90% accuracy level is more than enough, struggle to get too much precision is futile, let the PC do the job, we human is not computer, the moment you lost this perception you are deem for a frustration.