# pspice subckt help

Discussion in 'Programmer's Corner' started by Babber, Feb 13, 2013.

1. ### Babber Thread Starter New Member

Apr 19, 2011
9
0
Hello. First time post.

I have a subckt model that I'm trying to investigate why it has convergence issues. What I am trying to do is view the internals as waveforms in a transient analysis.

I have been simulating circuits using Orcad pspice and have used the software when it was microsim pspice. I am mostly familiar with the visual editor and have done some work looking at models through the model editor. I have been doing a lot of reading about the pspice syntax and how different elements are implemented (E's, G's, C's, D's, Tables, Values) and it's just spinning my head marrying the two worlds of visual schematics and the text based pieces.

Here's the subcircuit that I'm working with and trying to dig into:
.subckt vco_sqr in out Params: Fcenter=1k Frange=50 Vmin=1 Vmax=5
+phase=0
Rin in 0 1G
Rtable table 0 1G
Etable table 0 Value {Table(V(in),Vmin,-1,Vmax,1)}
Esin sine 0 value {sin(6.28318*(Fcenter*time+Frange*SDT(V(table)))+phase*(3.14159/180))}
Esqr out 0 table {V(sine)} (0,0) (1n,1)
.ends

The reason I'm looking at this subcircuit is that it looks like a good starting point for a simple PWM controller model. I know that there are PWM models out there, but I'm interested in getting into the nuts and bolts for personal intrigue. Here's a simple boost circuit that I'm trying to place this VCO into.

I placed a second VCVS after the VCO just to boost the gain. I tried modifying the subckt to produce a 10V output, but I keep running into convergence problems which seem to point to the Esqr line. After playing around now for two days I decided to try to break apart the subckt and place it into a visual schematic so that I can observe the waveforms when they fail to converge. Plus, I think it would be an interesting exercise.

Here's the basic layout as I think it looks visually.

What I'm wondering is as follows:
1) Is there a "visual" model that I can put on the schematic that is a dependent voltage source? One that I can write in the equation for the output like is being done inside the Esin or Esqr or Etable lines? I have the generic E model, but that's a four terminal block with only a gain entry.
2) Is there a way to observe the internals of the subckt during simulation? In other words, can I put a 'voltage probe' on Rtable or the sine node inside the vco_sqr subckt?

I am used to doing all of my simulations in the transient domain.

Thanks

2. ### Babber Thread Starter New Member

Apr 19, 2011
9
0
Well, I think that I may be able to answer some of my own questions now. There is a library of models that I was not paying attention to that has the models that I need. Evalue, Etable, Gvalue, Gtable, summing nodes, integrating nodes...all sorts of goodies. the library is called ABM.olb. I must have overlooked it. I'll try to write another entry once I am a llittle further in my investigation.

I think this will enable me to see what is going on 'inside' the model now. I am figuring that the Esqr is causing the 'out' node to change between two values in one time step. That is what I think is the convergence problem.

3. ### Babber Thread Starter New Member

Apr 19, 2011
9
0
But, I guess a new question now arises. Why is the Etable in the vco_sqr subckt using a VALUE of a TABLE? whereas the Esqr is just using a table directly? What's the point?

4. ### Babber Thread Starter New Member

Apr 19, 2011
9
0
Okay, problem solved! Well, mostly. I noticed once I started playing around with the "two" terminal Etable and Evalue models the highlighted template. I realized that in Orcad there is a TABLE property in the Etable model that was not evident to me. The "value that you first enter is the controlling node signal, and you have to find the table property and enter in the table nodes that you want. So, I was able at least to get one of the Etables in my reconstructed model to work. I also changed the first Etable TO a table, rather than a Evalue with a table inside. I couldn't get the template to accept the table inside a value, but that might just be a matter of syntax that I need to learn.

I also chose to look at some of the functions such as SDT(x) and the time variable to see how they worked. I was able to probe these points explicitly because I just created more Etables and Evalues.

The conclusion that I came to was that I needed to modify the range of the last Esqr table to widen it a little. Originally it was looking for a value between 0 and 1n, which is really tiny and did seem to be trying to transition in one time step. It's conceivable that (and I'm just guessing) that when it crosses through the 0-1n point the spice calculation just couldn't decide whether to choose above or below...something like that. Anyhow, I changed the model to transition from -1m to 1m which hopefully at the speeds that I'm running should allow at least a few points between those values so that the transition takes more than one minimum time step. It seemed to work with the simple boost circuit that I was modeling with. Look, transient output!

5. ### tshuck Well-Known Member

Oct 18, 2012
3,527
679
I just wanted to stop by and say thanks for posting your solutions though you haven't gotten any others posting.

You'll notice that most people here use LTSpice. I usually use PSPICE, but I have never really needed to go this in-depth, so my 'help' would be of no use to you at this point...

Last edited: Feb 14, 2013
6. ### Babber Thread Starter New Member

Apr 19, 2011
9
0
Thanks for the response. A few of my co-workers use LTSPICE and I have started to use it a bit myself. I think it is a really neat tool, but I think the interface and editor is so much nicer in Orcad's Pspice. LTSPICE simulates really quickly and never seems to have 'convergence' issues. I love the, what do they call them, test setups, no fixtures. But I really enjoy the nitty gritty that you can get down to with PSPICE. I did see a few other related posts on Orcad, but they were dated back to 2007! I'll likely keep an eye on this site as I'm trying to learn as much as I can on spice in general and LTSPICE because we do a lot of work with LT parts.