Search This Blog

Showing posts with label control loop. Show all posts
Showing posts with label control loop. Show all posts

Friday, 5 October 2012

Getting to know simulation - Part11 - Monte Carlo


To best illustrate the usefulness of the monte-carlo simulation, let’s use a voltage divider as example.
Run Transient simulation and get:
So this is a perfect voltage divider. But we all knows that resistor has tolerance, let’s say each of R1, R2 has 1% tolerance. We should factor this in by running Monte Carlo simulation and see what are we dealing with.
Enter 1% as the resistor tolerance.
Tick “Enable multi-step” to enable Monte-Carlo analysis


Set number of runs to 100
Re-run the transient simulation to see gain statistic of  divider made of 2 pieces of 1% resistor.
With resistor tolerance of 1%, the voltage divider will give an error of ~-0.9% to ~+1%. Use of Monte-Carlo simulation will ease such analysis. If your application cannot tolerate such variance, then resistors with better tolerance are needed.

Friday, 28 September 2012

Getting to know simulation - Part10 - Multi-Step



So continue from previous session, inserting C2 1nF to kill oscillation gives you the stability but make your buffer damn slow. You can try out few value to see the optimum C2 value for highest speed and still gives you the best stability, instead of manually change the values and re-run Transient Simulation, there is something called “Multi-Step” analysis that let you sweep any parameter and plot the result.


1. Open up analysis and tick “Enable multi-step”
      2. Click “Define…” button and key in the  info as below:
3.  Run the simulation and you get the plot shown – looking at 1pF, 10pF, 100pF, 1nF you see that the best capacitance value for performance is at 10pF. And now you have a complete buffer design for the application stated in Part1 :) . 

Saturday, 22 September 2012

Getting to know simulation - Part9 - Fixing oscillation

  
1.       There are plenty of ways to resolve this, one way is to add a capacitor in parallel with feedback resistor R2. Let’s do this in the schematic and re-do the AC simulation. At this point of time, the value of C2 is arbitrary chosen to be 1nF, we will talk more about this in next session – any way the latest schematic becomes:  
2.       Re-do the simulation for AC with simulation frequency up to 10MHz to see the new closure- you can see now that the rate of closure becomes 20dB / decade – indicating stability has achieved, let’s modify the schematic to re-do the transient
3.       To look at the end result of the fix in time domain, insert 1nF for the transient simulation file:



4.       Re-run of transient simulation shows that so we have solved the problem of oscillation – but the problem is that the output of the buffer takes 4ms to settle to the right value – too slow for our liking – this we will try to solve in next session.

Friday, 14 September 2012

Getting to know simulation - Part8 - Arranging bode plot for AC analysis

1.       The best way to do AC stability analysis to plot Aforw vs 1/beta, plot of 1/beta essentially is the inversion of the beta gain – which is input/output instead of output/input – so let’s reverse the bode plot  and rename the block as shown
2.       So now you can see that the 40dB per decade closure of Aforw and 1/beta is the cause for oscillation


Friday, 7 September 2012

Getting to know simulation - Part7 - Bode Plot from a buffer circuit (that oscillate)





Continue from last post, to solve the problem, we need to acknowledge that the buffer circuit is in fact a feedback loop
To identify which components belong to with block – refer to the blog
Let’s modify the schematic to perform bode plot analysis
1.       Ground non-inverting input – since op-amp input is already high impedance – any voltage source with series resistance is pretty much behaving just like a pure voltage source – for DC voltage source, it is always a AC ground.
2.       Place large inductor, infinite AC coupling capacitor and AC source, configure the AC source as below:
3.       Choose AC analysis:
4.       Your schematic should becomes:
5.       After simulation, you get
6.       But, how to interpret the plot?

Sunday, 2 September 2012

Getting to know simulation - Part6 - Practical circuit consideration

Continue from last simulation done in Part5, the simulation result shows that the circuit is too ideal – in practical PCB, there will be about 10pF of capacitance from op amp input pin to GND, let’s insert this capacitance as below:

Re-run the transient and get:

In this case, we caught the potential issue - oscillation – as to solve it, let’s do it in the next posts.

Saturday, 25 August 2012

Getting to know simulation - Part5 - Transient Simulation

So far so good for DC, but we still need to know the characteristic for fast changing sensor output – what’s the waveform going to be. Let us replace Vsensor from DC 1V to Step 1V by double click on the source and configure the output to be 1V Step voltage with 2ms delay:

To ease subsequent examples about simulation, change some of the op amp settings by double click on it, change as below:


  
To plot the waveform, insert a probe at the output of buffer (short cut “B”)



Then choose Transient analysis:
And you would get nice waveform as shown below:

So far so good - but is it too good to be true?

Getting to know simulation - Part4 - insert basic buffer amplifier


To continue from previous post, let’s modify the circuit above as below
1.       Insert a parameterised opamp from menu Place –> Analog Functions ->  Parameterised Opamp
2.       Insert a +/-15V DC supplies from menu Place –> Voltage Sources ->  Power Supply
3.       Insert off-page connectors from menu Place -> Connection -> Terminal
4.       Wire up the opamp as x2 buffer amp using 1Meg Ohm resistors (so that 1V full scale sensor output will translate to 2V full scale ADC input). Route the circuit accordingly, re-run DCOP simulation and you get:
Now with the buffer – we get pretty good DC result – 1V sensor translated into ~2V adc input. For now, don’t concern yourself with the ~20mV error (2V – 1.97997V), we will cover this some other time.

Saturday, 18 August 2012

Getting to know simulation - Part3 - using DCOP

Let’s look at the reason we need to design the buffer. If we direct connect the sensor to adc input –
We will have 1V * 1k/(100k + 1k) ~= 10mV only, clearly this is not acceptable. Note that in Mindi, instead of using R1, R2 ... you can right click on component and change its name, in this case Radc is the name chosen to represent the ADC.

To simulate – all spice required “Ground” symbol for reference, so let’s insert one as below, double click on V1 and rename it to Vsensor, and change name of R1 to Rout.
We want to know the voltage at ADC input, so place voltage marker on the interconnect node for Rout, Radc to see the voltage



Schematic after placing marker:
Then choose simulation mode to be DCOP
And click “Run”


Now you see the need for buffer circuit. DCOP is the first thing that I recommend for any simulation, since it let you see the DC biasing in the schematic itself  – especially when the circuit is much more complicated than this. You can place as many markers as required.

Getting to know simulation - Part2 - Modeling


Let’s get started by modeling the blocks in schematic – knowing how to model is critical – else it will be GIGO (Garbage-In-Garbage-Out).

1.       Modeling of the sensor to ease design process – if you look at sensors such as microphone, transducer, you would find that most of them if not all do not have “Low output impedance”, which means, you cannot use a voltage source to model it. So let’s model our sensor as below, the values of R1, R2 is not important, which will become clear at this end of the series: in this case, output of the sensor is 1V.
2.       As for the ADC,  to ease design process let’s use a 1kOhm resistor to represent it – it is the load of the buffer circuit, at the end of the series, you will know why this is good enough

Getting to know simulation - Part1 – Introduction

Getting to know simulation - Part1 – Introduction

In circuit design - simulation tools will ease your life a lot - if you know what you are doing. As such I am writing a series of posts that I hope will best help you to understand what you can do with simulation - by using a buffer amplifier design example. The goal is to introduce basic features such as
  1. DCOP
  2. TRAN
  3. AC
  4. Multi-Step
  5. Monte-Carlo
Let’s take an example as below:

1.      Supposed that we need to design something that interface a sensor to ADC, so we have
a.      sensor
b.      The ADC
c.       And something in between – a voltage buffer – and this is what we need to design
2.      To supplement the design example, let’s put some more details
a.      Sensor bandwidth is at least 10kHz
b.      Sensor can swing from 0V to 1V
c.       ADC full range voltage is 0V to 2V.
Since I am a user of Mindi from Microchip, I will use Mindi as examples, but essentially all simulation tools have the basic set of features. If you want, you can install Mindi mentioned from my earlier blog (In this case, you can quickly test out the example)http://electroniccircuitdesignsharing.blogspot.com/2012/03/tools-for-circuit-design.html.

Alternately, you can down load SIMetrix from http://www.simetrix.co.uk/site/demo.html, which is essentially the same thing as Mindi (just the name different as far as I am concerned, same GUI, same file type....)

My advice is to play around with your simulation tools, knowing the capability of what it can do will make your life a lot more fun :). So wait for Part 2 to get started.

Wednesday, 23 May 2012

Feedback loop element identification: Which is which? Non-Inverting Op amp circuit


General Control Loop block diagram:


Given schematic below, how to know which is which? Knowing which is which is critical, as it allows the use of theory to achieve the best result.






Equations that allowed us to identify corresponding blocks:
From simple voltage divider rule
vn = Ri/(Ri + Rf) * vout
eq 1
let α = Ri/(Ri+Rf)
vn = α * vout
eq 2
We see that vout is just opamp gain (Aamp) multiply by its input voltage
vout = (vp - vn) * Aamp
vout = (vin - α * vout) * Aamp
vout * ( 1 + α * Aamp) = vin * Aamp
vout / vin = Aamp / ( 1+ α * Aamp)
eq 3
From close loop equation of control theory:
vout/vin = TF = Aforward/(1 + Aforward*β)
eq 4
Comparing eq 3 with eq 4 , we see that
Aforward = Aamp
Aforward*β = α * Aamp
β = α = Ri/(Ri+Rf)
When loop gain (Aforward*β) is large enough, we see that
1 + Aforward*β ~= Aforward*β
TF = Aforward/ Aforward*β
TF = 1/β = (Ri + Rf)/Ri = 1 + (Rf/Ri)

Feedback loop element identification: Which is which for Inverting Opamp circuit?


General Control Loop block diagram:



Given schematic below, how to know which is which? Knowing which is which is critical, as it allows the use of theory to achieve the best result.




Equations that allowed us to identify corresponding blocks:

voltage at inverting pin of amp is just vin summed up with voltage drop across Ri

vn = vin + Ri * i
eq 1


since amp input is of high input impedance, current through Ri, Rf is just

i = (vout - vin) / (Ri + Rf)
eq 2


we see that vout is just opamp gain (Aamp) multiply by its input voltage

vout = (0 - vn) * Aamp

vout = - vn* Aamp
eq 3


eq 2 -> eq 1

vn = vin + Ri * (vout - vin) / (Ri + Rf)

let α = Ri/(Ri + Rf)

vn = vin + α * (vout - vin)

vn = (1-α)*vin + α * vout
eq 4


eq 4 -> eq 3

vout = - {(1-α)*vin + α * vout} * Aamp

vout = - {(1-α)*vin* Aamp + α * vout* Aamp}

vout * (1 + α*Aamp) = - {(1-α)*vin* Aamp}

vout/vin = - {(1-α)* Aamp} /(1 + α*Aamp)
eq 5


from close loop equation of control theory:

Vout/Vin = TF = Aforward/(1 + Aforward*β)
eq 6


comparing eq 6 with eq 5 , we see that

Aforward = - {Rf/(Ri+Rf)} *Aamp
eq 7

Aforward*β = α*Aamp
eq 8

and

β = α * Aamp/Aforward
re-arrange eq 8

β = { Ri/(Ri+Rf) } {- (Ri+Rf)/Rf }
substitue Aforward from eq 8

β = - Ri/Rf


when loop gain (Aforward*β) is large enough, we see that

1 + Aforward*β ~= Aforward*β

TF = Aforward/ Aforward*β

TF = 1/β = -Rf/Ri