Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

[SOLVED] How to compare Matlab/Theory <=> Cadence: Switched-cap. Integrator: Mag & Phase

Status
Not open for further replies.

bernd2700

Newbie
Joined
Jan 15, 2021
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
76
Dear guys,

I tried to compare the simple switched-capacitor integrator below between Cadence and Matlab (at the end acting as a simple loop-filter for a delta-sigma) and I am stuck now on the point of how to compare the 2 results CORRECTLY because of the additional sample & hold maybe (?) needed and instantiated in the Cadence schematics.

I have read Mr. Ken Kundert’s papers:
*) “Simulating Switched-Capacitor Filters with SpectreRF”, and
*) “Device Noise Simulation of Delta-Sigma Modulators”.

I’m an electronics engineer, but not a mathematician, and so, from the practical point of view I have not found a good answer for me from the internet, therefore I would be very happy, if you could give me a practical advice.

Block schematics and timing diagram:

Block schematics and timing diagram.png

Transfer function for this circuit

(confirmed by e.g. [Richard Schreier, “yellow” Delta-Sigma book, p.337]):

vo/vi =(-Cs)/(Cf)∙z^(-0.5)/(1-z^(-1) )

Transfer function equation.png

I also calculated the theoretical magnitude and phase at fs/2 (with ideal opamp and with Cs = Cf = 1). It yields “+j/2” which is 0.5 magnitude (-6 dB) and +90° phase.

Cadence circuit:

As Ken Kundert writes in his papers, I am interested upfront in the discrete-time (DT) behavior, thus I have attached his S&H circuit next to the output “Vo”. It is sampling just a few moments before the rising edge of phase p1, so should be equivalent the read-out at rising edge of p1 at time point “n*T” indicated in the block diagram (node “Vo_ext”) and match with the theoretical result.

Cadence circuit.png

Cadence results:

Cadence result PAC magnitude.png

Cadence result PAC phase.png

Matlab result:

I created a Bode diagram of the above theoretical, also discrete-time transfer function (thick green line).

Matlab result with code.png

Comparison and questions:

1. Q1:
Why does Cadence show 159 mHz as 0 dB magnitude line (as it would be a continuous-time (CT) integrator comparable to a Matlab “1/s” transfer function), although it is discrete-time (DT) behavior after the S&H?

Ken Kundert writes in his papers that Spectre basically reports the continuous-time behavior, and if I am interested in the discrete-time behavior then I need to attach a S&H, which I did, but for the magnitude result (as in contrast to the phase result) there is NO difference. The PAC result of BOTH nodes, “Vo” and “Vo_ext” show the 159 mHz. Matlab, instead, shows 167 mHz as 0 dB line.

2. Q2: Why the Cadence PAC goes on with the -20dB/dec straight line as again it would be a continuous-time integrator (and reaches -10 dB at fs/2), although it’s the PAC result AFTER the S&H (I have 2 sidebands shown above fs/2 that one can see well the continuing straight line). Matlab’s result, however, flattens out to -6dB at fs/2, also my theoretical calculation yields -6dB.

3. When I extend the Matlab plot to beyond fs/2, one could see (not shown here) the symmetrical behavior around fs/2, as it should be for a DT system.
Q3: Why does the node after the S&H (“Vo_ext”) in Cadence PAC not show the symmetry around fs/2, although it should be a DT behavior, as Ken writes in his papers?

4. For the phase, I would have found a solution for an conclusive explanation in my head, but it is not consistent with the procedure / method of the amplitude:
I could argue the following way: When I want to know the response of the integrator alone, I omit the S&H at the end in the Cadence circuit, and I get 90° of phase shift (from +180° to +90°) and make the trick with the Matlab that I can plot z^-0.5. Then, for the phase at least, Matlab fits to Cadence, at least to fs/2. When I want to know the “real” DT behavior (so e.g. every 1/fs = every integer second here (and not half a sec.)), I take node “Vo_ext” in Cadence AFTER the S&H and of course then in Matlab for every Ts=1/fs, it also has to be z^-1, and both results fit.
Q4: Is here my thinking somehow correct?

5. We see: If I apply the same procedure for the magnitude as for the phase, both Cadence results, before and as well after the S&H are still showing 159 mHz as 0 dB line and -10 dB at fs/2 and neither case does fit to Matlab / theory (167 mHz and -6 dB).
Q5: Why does the phase match with this thinking (at least to fs/2), but the magnitude doesn’t?

6. I somehow have in mind, that of course I will see the unwanted (“sin(x)/x” coloring) but maybe also wanted (DT, as Ken writes) behavior of the S&H. As by theory, a sim. has shown -3.9 dB of magnitude drop and the phase is at -180 degrees if the S&H is simulated alone. If I simulate 2 of them in series, I obtain the very same data. Thus I conclude, this S&H is NOT an LTI system. Therefore, it’s not allowed to simply divide by its transfer function (so to deduct the sample and hold from the overall circuit, so to exclude the behavior of the additional magnitude and phase influence of the S&H (but which I possibly even want, because, as Ken writes, I am interested in the discrete-time behavior). So maybe I need the discrete-time behavior without the influence of the S&H??? You see, it’s not clear to me.
Q6: So, my main question: How to CORRECTLY compare, evaluate, interpret and argue the results obtained in order that the answers are consistent and I have a correct procedure / methodology which is valid for also all the circuits to be analyzed in the future? (e.g. the STF of complete Delta-Sigma modulators, etc.)? So in a way that someone of you says: “Take this node and do that with it and then you get the correct result”, and not that the methodology for some cases it maybe will fit (e.g. here phase until fs/2) in others it doesn’t (magnitude).

Thank you so much in advance and my best regards,
bernd2700
 

BradtheRad

Super Moderator
Staff member
Joined
Apr 1, 2011
Messages
13,890
Helped
2,757
Reputation
5,512
Reaction score
2,665
Trophy points
1,393
Location
Minneapolis, Minnesota, USA
Activity points
103,639
1.

Cs appears to have no resistance through which it charges & discharges. Cs charges/discharges instantly but only theoretically since in reality there is always some resistance.

As for the simulator it is unable to calculate a sensible RC time constant. That is unless SW1 SW2 contain some invisible resistance. Can you determine whether this has a definite ohm value?

Or else you should install a resistor with a fixed ohm value.

2.

0.159 Hz is the calculated rolloff frequency for an RC combination of 1 Farad 1 ohm. Formula:
f = 1 / (2 π R C)

Alternately 0.167 Hz happens to be 1/6. If you take an RC time constant of 1 (1 Farad times 1 ohm), and consider 6 time constants as the time to fully charge or discharge, then that could be where .167 comes from.
I'm not sure if this is focus of your question.

Note: By convention we usually regard 5 time constants as the time to fully charge/ discharge. 6 isn't too far off, and anyway it's just about 2π which appears in the formula above.
 

bernd2700

Newbie
Joined
Jan 15, 2021
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
76
Dear „BradtheRad“,

Thanks for your answer!

To your comments:

Ad 1.
Cs HAS a resistance, it is “hidden” inside the switches (but therefore I have displayed for one of the switches the exact chosen data, the other has the same data). So, it IS DEFINED, namely with 10 uOhms in closed and 10 Meg in open state. I have chosen them in a way that I am out of band, but for safety before posting, I also have modified the the resistance and the capacitances as well by a factor of 10, but no influence in the results, so my choice was good.

Ad 2.
Yes, exactly, 159 mHz is the 0 dB line of a CT (Continuous-Time) integrator. However, for a DT (Discrete-Time) it is 167 mHz. Moreover, for a CT integrator, the magnitude line goes on with -20 dB/dec forever (ideally) reaching -10 dB at 0.5 Hz, whereas for the DT case, as I write, it flattens out at -6 dB at fs/2 (0.5 Hz here). So far, so good. But now, extra for this, I DID instantiate a S&H circuit (as Mr. Ken Kundert has written in his papers I am then interested in the DT behavior), so why then the Bode diagram magnitude result of Cadence does NOT match the Matlab (neither from taking the result from before or after the S&H, whereas the phase does match at least to fs/2 from before the S&H)??

Your convention with 5 time constants of (dis-)charging of the caps is not applicable here, because I specifically took care that the (dis-)charging process of the caps, also with the opamp, happens a LOT of times faster than 1/fs (which is 1 sec.) and thus is BY FAR out of band. (E.g. I even made the opamp with unity gain frequency fT = 100 Hz, so a 100 times faster. For the switches, the tau is 10us. Remember I have ages (1/2 a period for each phase active, that’s 0.5 sec. per phase!) available! So, that all of it does NOT have a significant (degradation) result in the AC analysis.

So, now? Please, anyone, any idea?

BR,
bernd2700
 
Last edited:

bernd2700

Newbie
Joined
Jan 15, 2021
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
76
Dear guys,

Mr. Ken Kundert in person gave the crucial hint for the solution of this topic and I want to thank him 1.000.000 times for his answer and share the essential result here also with you:

-------------------------------------------
So the key point summarized for all:
============================
The key point (for this case at least, the rest I have to check, then) is obviously to apply in Cadence the “PAC SAMPLED” ANALYSIS and moreover, CORRECTLY apply it (i.e. select a concrete time, and not “time averaged”, see below)! The S&H in the output can stay and so in this example “Vo_ext” can be taken for the result. With these actions, Cadence then matches Matlab perfectly, see the screenshot!
-------------------------------------------


In a bit more detail: In my case, there was a choice of 2 sub-options in the PAC (Periodic AC analysis for the others) result: That is to say, if one choses the PAC result “time averaged” then one gets wrong results (or at least me in this case), so guys, also maybe you need to take option B: The concrete time “e.g. 799ms”, then you’ll get the correct results which PERFECTLY match to Matlab (or to “theory” if you want)! I have to find out what is behind this selection in more detail, but this I can do on my own, I think.

So I wanted to state this also here as a closing summary that maybe others who will fall into the same issue will have an easier job! ;-)

Many greetings,
bernd2700
 

Attachments


Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top