How to handle "table" syntax when .sub use a "table" function

D2D Buck Closed loop small signal.qsch (18.8 KB)
The following is .subckt CPM-CCM,I try to create a symbol in Qspice but the result was wrong. I am wondering if there is problem for “table” syntax? Or there are other problems in my circuits.Could any experts help me out? thanks!
.subckt CPM-CCM vc vs vm1 vm2 d
+params: L=100e-6 fs=1e5 Va=0.5 Rf=1
Em1 m1 0 value={Rfv(vm1)/L/fs}
Em2 m2 0 value={Rf
v(vm2)/L/fs}
Eduty d 0 table

  • {
  • 2*(v(vc)-v(vs))
  • /((v(m1)+v(m2))(1-v(d)) + 2Va)
  • } (0.01,0.01) (0.99,0.99)
    .ends

Would you like to simulate loop gain with the PWM Switch Model? Is your simulation based on something that already works in another simulator like LTspice or PSpice?

table is not a function that can output a result in AC analysis. Here is an example showing that a table will always output 0V in .ac analysis.

.tran

.ac

@KSKelvin Yes, I can successuflly simulate loop gain with this model in LTspice.


average.lib (12.0 KB)
In Qspice, I try to add a limiter for the output of opamp, but I am not sure if the result is correct!!
![image|690x364]
D2D Buck Closed loop small signal.qsch (21.0 KB)
(upload://mRPtB6odtwyPQEXPt6xJJaHut55.png)

1 Like

In general, the first step should be replicating the original simulation. I modified the drawing of your CCM1 to better fit a buck converter configuration, so the LTspice simulation result can basically be replicated.
AP2962 GM study - 01 - Replicate LTspice.qsch (22.6 KB)

I then placed an ideal op-amp into the circuit. In the original circuit, the G-source has one of its terminals connected to V(in), but I don’t know how that translates into the op-amp version. There is a few dB difference in the results, so I used an E-source with gain=3.144 to match the G-source with this ideal op-amp version. I cannot figure out what causing that few dB different. I guess it is not Qspice issue, but how that G-source feedback should translate into Opamp compensator.
AP2962 GM study - 02 - Replace with Opamp.qsch (23.8 KB)

Thank you for your kind guidance. I should step by step to diagnose the issues. I learnt a lot now. Thanks again.