Build a transformer in LTSpice as a symbol/model/subcricuit

Thread Starter

PsySc0rpi0n

Joined Mar 4, 2014
1,786
Hello everyone.

I will be working a bit with transformers in the next 3 months or so in school. And I was looking to build a symbol/model/subcircuit that I could use every time I need to use a transformer instead of building one every time I need one.

So, usually I use 2 inductors and a 'K' parameter and some simple math to find the relative inductances to produce the desired output voltage.

What I want is just add that Transformer symbol, insert L1, L2 parameter values, the coupling factor and nothing else to have my transformer ready to use.

But I don't know many aspects of how to build a symbol/model/subcircuit. So I was about to try the follwoing:

- Open an 'ind.asy' symbol file in LTSpice.
- Duplicate, mirror and position the first inductor to have a second inductor that will act as the secondary winding.
- Add L1 and L2 in curly brackets to be able to change their values according to the ratio between windings. Same with 'K' parameter.

But then, questions starts.
As I duplicate the 1st inductor, 'L' parameter is not duplicated. So, when I use this symbol, how am I going to set L2 value?
Also, when I use this symbol, as I don't have an L2 parameter, how am I going to associate K to L1 and L2?
 

Bordodynov

Joined May 20, 2015
3,431
You have described only the creation of a symbol from an inductance symbol. After copying, reflecting and assigning the inductance value, you must remember the symbol under a new name. The same name must be written in the symbol. Use the keyboard cntrl + A.
trans.png

Next, using a text editor, create a model file Trans.sub.
Note that the pins have names. To create a transformer description, you need to know the syntax of the spice.
.subckt Trans P1 P2 S1 S2 Lp={L1} Ls={L2} Rp={R1} Rs={R2}
.......
.ends

PS.
The names of the pins can be made invisible.
 
Last edited:

Thread Starter

PsySc0rpi0n

Joined Mar 4, 2014
1,786
Thank you a lot @Bordodynov ... In fact the first example is very complex to my needs.

I have also asked help in Yahoo LTSpice groups and they also helped me creating something like you did in your second example.

But somehow I think the waveforms are not as they were supposed to be!

The files are attached!
My request is that you help me figuring out what is wrong in my approach, if anything is wrong!

Thanks you
 

Attachments

Last edited:

Thread Starter

PsySc0rpi0n

Joined Mar 4, 2014
1,786
Ok, I found the problem. The reference ground of the right side of the circuit was in the wrong place!

@Bordodynov I was looking feeper to your 2nd example and what means the Prefix XTR??? I'm only used to see R, X, etc.
 
Last edited:

Bordodynov

Joined May 20, 2015
3,431
It is Enough First letter, but possible enlarge their their amount. Defining is a first letter. I so do to in the event of mistake, examine netlist. Adding additional letters, I relieve itself that for element in text file.
 
Top