Author Topic: How do I get parameters to show up for a spice model in KiCad 8?  (Read 257 times)

0 Members and 1 Guest are viewing this topic.

Offline isitayushTopic starter

  • Newbie
  • Posts: 6
  • Country: in
Hi Everyone! I built a very simple transformer in KiCad 8 using two coupled inductors. It works when I simulate it with ngspice from it's auto-generated spice netlist. I extracted the relevant part's from the auto-generated spice netlist into a separate file so I could reuse the spice model in my other projects whenever I need to simulate a transformer. This new spice model file is called "transformer.lib" and it contains the following data,
Code: [Select]
****************************************************
* Transformer 1P 1S
****************************************************
*
*                         Primary In (PA)
*                         | Primary Out (PB)
*                         | | Secondary In (SA)
*                         | | | Secondary Out (SB)
*                         | | | |
.SUBCKT Transformer_1P_1S 1 2 3 4
.PARAM Lp=1m Ls=1m k=1
L1 1 2 Lp
L2 3 4 Ls
K L1 L2 k
.ENDS Transformer_1P_1S

You'll notice three parameter's Ls, Lp and k above. The problem is when I load the "tranformer.lib" file to be used as the spice model for a transformer symbol in KiCad 8, I don't see Ls, Lp and k parameter's in the "Parameters" section of "Simulation Model Editor" dialog box (the dialog box appears when you double click a symbol and click "Edit Simulation Model" button on the bottom). I'm very new to spice, ngspice and KiCad 8 and this is my first reusable model. I'd like to be able to adjust these three parameter's in the "Paramters" section based on the project/circuit needs whenever I want to simulate a transformer with ngspice in KiCad 8 very similar to how you can set values for resistor's and capacitors. I'm not sure what I'm doing wrong here or If I'm missing spice syntax. I've attached a screenshot below for the "Simulation Model Editor" dialog box and you can see the "Parameter's" section is empty when I select the model. How do I fix this?
« Last Edit: July 04, 2024, 01:47:52 pm by isitayush »
 

Offline isitayushTopic starter

  • Newbie
  • Posts: 6
  • Country: in
Re: How do I get parameters to show up for a spice model in KiCad 8?
« Reply #1 on: July 04, 2024, 03:04:30 pm »
Solved it! Here's new code for the "transformer.lib",
Code: [Select]
***************************************************************************
* Transformer 1P 1S
***************************************************************************
*
*                         Primary In (PA)
*                         | Primary Out (PB)
*                         | | Secondary In (SA)
*                         | | | Secondary Out (SB)
*                         | | | |         Primary Inductance
*                         | | | |         |     Secondary Inductance
*                         | | | |         |     |     Coupling Coefficient
*                         | | | |         |     |     |
.SUBCKT Transformer_1P_1S 1 2 3 4 params: Lp=1m Ls=1m k=1
L1 1 2 {Lp}
L2 3 4 {Ls}
K L1 L2 {k}
.ENDS Transformer_1P_1S
I still don't know how I can add helpful things like "Unit" & "Type" for Lp and Ls.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf