Sunday, February 19, 2017

Importing SPICE Models in MATLAB

Importance of importing Aim-SPICE models in MATLAB :

MATLAB operates only on Level 1 and Level 3 models for MOSFET. As number of Levels increases then the accuracy of design improves. Aim-SPICE defines 26 MOSFET Levels which can be imported into MATLAB by using a methodology given below.
The flowchart for importing SPICE Models in MATLAB is shown below.

Methodology

1.      Write Netlist in Aim-SPICE:
First step in any design is designing the circuit. In Aim-SPICE designed circuit is defined by writing netlist.
2.      Importing SPICE netlist in MATLAB:
For importing the SPICE netlist in MATLAB first step is to open MATLAB and link MATLAB and Aim-SPICE by setting path. Setting path means to let MATLAB know the directory of Aim-SPICE.
After this step, importing is performed by using function ‘netlist2sl’. This function imports netlist of circuit from Aim-SPICE to MATLAB Simulink.
1.      Generation of Model as a Black-box:
After using the function ‘netlist2sl (filename, library)’ MATLAB generates a black-box model of filename and stores it in a library which is defined in the given function.
For e.g. if it is written “netlist2sl (‘mydiode’, ‘genlib’)” then a black-box model of name ‘mydiode’ will be generated and it will be stored in library ‘genlib’.
1.      Check for Errors if Output is not as Expected:
If circuit is not giving output as required then corrections has to be done either in netlist by going to Aim-SPICE or in model designed in Simulink.

2.      Assign Input and Output to New Model:
In this step, the generated model is used to design a complete circuit in Simulink by connecting input and output blocks.
For e.g. ‘mydiode’ is used to make a circuit of diode as a switch as shown in below figure.
1.      Run the Model and See the Output:
When the design is error free then it can be run and output can be seen on the scope.

For seeing the netlist in MATLAB command window, function ‘type (filename)’ function is used.
For e.g. if netlist of ‘mydiode’ is to be seen then function ‘type (‘mydiode.cir’) is used.



No comments:

Post a Comment