Post Go back to editing

Mass importing compnents "Spice line" parameters

Thread Summary

The user seeks a method to mass import simulation parameters for multiple instances of a custom 'R L' matrix component in LTspice. The final solution involves using a .param statement to define parameters and including an external file (e.g., Excel-generated .prn file) to set these parameters for each component instance. This approach allows for easy parameter modification and comparison between different sets without manually editing each component in the schematic.
AI Generated Content
Category: Software
Software Version: 24.1.10

I try to find a way to importing simulation parameter for my own components.

Basically that my own components is "quite simple R L" matrix witch represent cable single wire and it's simulation values  can be given in LTSpice own editor  as example Format:     

"Enter new SpiceLine for ‘xxxx’  =  “Rw=10 Rg=24 Lw=21m”"

Component and it’s simulation works fine if I manually enter each separate components parameter in LTspice editor.
Now I try to find way to mass import  those SpiceLine values for  even over a hundred of same component in model  (In simulation each wire length, earth capacitance etc. are different) but “wire component” are still same.

My idea will be something lik that: 
- In first phase I have to manually create circuit diagram where all those “wires” are connected as needed and each of those have unique name, but I don’t concentrate simulation parameters.
- Then I like to export that spice model some format where all components values are as default values.  
- Next I would like to replace those "wire component" default values from excel, where that  simulation parameters source has been generated

-And then import that same spice model back to LT-spice… Only those Spice line “spell” has been  replaced by excel calculated data.  Ewryting else in spice model leavs as it is.

 Ideas how to do that "inpoering" ?

  • Hi  ,

    A little hard to follow your description. Let's start with the export. You could simply use Tools > Export Netlist to produce a human-parsable text file showing components and values. You would have to do a little text processing. Though, I don't think you need to do that. See attached files. I laid out a simple model using parameters.

    The parameter statement shown is commented out. The .include statement reproduces it via myparameters.prn.

    I've included the excel file, which is saved as a space-delimited text file ".prn". I include the ".prn". That is essentially the import. Note that the column of "+" (plus signs) allows you to use line breaks. Excel interprets a plus sign as the precursor to a function, so you must format all cells as "text" (Format > Cells).

    If you want calculated cells, simply add a column of  semicolons ";" and place the calculations after that column. 

    mike

    Using Excel.zip

  • Hi  

    That Idea looks usefull.. I need study  bit more that "   Include MyParameters.prn" usage.
    But I do that tomorrow or coming monday.
    I'll hope  at I can set one grid parameters from one row in excel/.prn file.  Then it's be more clear to keep calculation in hand.

    In under screen copy one sigle "wire element" configuration and it's simulation parameters and also how it's be presented in exported
    net list...    That Spice line format is bit tricy, with "X§" symbols but hopefully it's can handle as any Spice row.

    And I have those wire elemets about hunded in enitre project GrLine1, GrLine2...... GrLine105 and basically each of those have own Re, Rg and Lw values 


  • I try for thay but I can't find  solution/format to give that whole  Spiceline commad as parameter.   But Ican find sytax to set varible Wg1 = "Rw=10 Rg=2 Lw=20m"  which are needed parameters for components spice simulation


      

  • Hi  ,

    I'm confused. You want to create a string parameter where the contents of the string are the parameters?

    mike

  • Sorry my poor english... It be bit hard to me try to open that....

    Basically I have that my own subsiccuit used many dozens  in same sircuit  (GrLine1 and GrLine2 ..... GrLine77 ). And it's work nice if I manually set those simulation "Spiceline" parameter for each of those supsircuit separately  (In picture in under have just two of those subsircuit.... There in comprehensive model tose are dozens of those same subcircuit components).   Each of subcircuit components are same and only difference between them is that what  values is written of "Spiceline" row parameter (Red ringed)   As exsample that 1. sample component it's be "Rw=10 Rg=2 Lw=20m" and sample 2 "Rw=7.5 Rg=4.4 Lw=23m"" 

    Now I only try to find a way brirg each of those subsircuit  "SpiceLine" row contents from external file (maybe Excel).
    Reason for that needs is some how try to optimize system  and jump betweet those different  "parameter sets".  And you can gusess at it's bee bit hard to jump between diffrent parameter sets If I need to manually set each of those dozen components parameters in editor.   I Mean at I have at least two different parameter set for SpiseLine in separate file, and I run simulation both parameterset and then compare results and maybe made then thid parameter set.... and so one. 
      

  • Hi  ,

    I think I see what you want to do. I believe you would need to create a library of subcircuits, not just one. Each subcircuit in the library has the parameters you wish. You can name the subcircuits by the parameters of interest. Library would look like this:

    .sub AmpnerEarthWire_V3 A B G

    defs {Rw} {Rg} {Lw}

    .ends

    .sub Rw_10-Rg_2-Lw_20m A B G

    X1 A B G AmpnerEarthWire_V3 {params}

    .ends

    ETC.

    Then, when you place a symbol, you would have to call that "model". In the attributes for a specific symbol:

    ModelFile "nameoflibrary"

    SpiceModel Rw_10-Rg_2-Lw20m

    You could build out a netlist using this method and some clever parsing in Word or other editor, say with a python script.

    mike

  • I believe if you do it this way, the parameter sets will appear as a drop down list in the symbol attributes, once symbol is placed on a schematic. Nice simple UI for selecting your parameter set.

    You could build out the parameter sets and the eventual library file with clever parsing in excel or word from your exported netlist.

    I think I've circled back to your original question. :-)

    mike

  • LTspice does do some string manipulation, but I'm not sure you could do what you want using LTspice's limited sting manipulation feature, though, maybe....

    .param name = Rw + "_" + etc.

    X1 {name}

    might work. Have to try that one.

    mike

  • Thanks a lot MStokowski 
    I need to thik about that method for a while...

    Bigest info for me is that at at I know now at I can't give that "SpiceLine" content like variable as I try to.

    I'll be bit worry now do I have to step pair third back...  And and think do am I change  whole idea to simulate that..
    Example split my subcircuit so at I build circuits more as sematics of separate passive components which locate in main sematics.
    Just now I feel at It's goes too complicated to keep project in hand if part of matematic been on excel... Then some transfer /generatig algorithm handle that in phython and then inport that to LT-spice...   Is there too many ways to mixing things   

    May be I close that computer noe ad think again to morrow morning
    Anyhow... Thanks a lot for your instructions

  • Attached is a basic string parameter as subcircuit name built from parameters. Interesting thing is that the 1k and 10k are evaluated to full expansion.

    Using Strings for Subcircuit Name.asc

Before You Switch


Switching languages will make ADI Explorer unavailable. Resume your session by switching back to English and reopening ADI Explorer.