Spice Netlist to Simscape Conversion Issue - LIB directive

11 次查看(过去 30 天)
Hi everyone,
I'm using LTspice to design power electronics topology or circuits for a while, and to control it I'm tring to use Simulink. So far I've done some simple simulations with using these two subcircuit2ssc('ABC.cir','+ABC') and ssc_build commands. However, I've been facing an issue with usage of .LIB directive.
The circuit below is what I'm trying to map into simulink. The FETs models are inside a separate .lib file.
Netlist for this diagram is as below:
.SUBCKT HALFBRIDGE VPP VPN G_H S_H G_L S_L
L1 VPP N004 {L} Rser=100m
E1 N006 N008 G_L S_L 1
R1 N007 N006 10
*V1 VPP VPN 430
E2 N001 N003 G_H S_H 1
R2 N002 N001 10
*Vgs1 G_H S_H PULSE(0 5 0 10n 10n {(1-D)/fs + DT} {1/fs})
*Vgs2 G_L S_L PULSE(0 5 0 10n 10n {D/fs - DT} {1/fs})
XU1 N002 VPP N004 N003 GS-065-008-1-L_L1V4P1
XU2 N007 N004 0 N008 GS-065-008-1-L_L1V4P1
R3 G_H S_H 1k
R4 G_L S_L 1k
C1 VPP N005 {C}
R5 N005 VPN 10m
.param fs = 100k
.param D = 0.2
.param DT = 100n
*.tran 100u
.param L = 10u
.param C = 10u
.lib GanSystem_Fets.lib
.ENDS
The library file(GanSystem_Fets.lib) is also in the same directory with the netlist file.
When I run subcircuit2ssc('GanFet_Test_Matlab.cir','+HalfBridge') spice to simscape converter function, I'm getting below error output:
Error using spiceSubckt.cleanNetlistStringArray
Line continuation is not in expected format.
Error in spiceSubckt/handleLibIncFiles
Error in spiceSubckt/loadSubckt
Error in spiceSubckt
Error in subcircuit2ssc
Error in subcircuit2ssc (line 31)
subcircuit2ssc(netlist,target);
From this document what my understanding is subcircuit2ssc() function should be able to handle .LIB directives. Without copying and then pasting the .LIB content in to the netlist file, are there any way to make .LIB files visible to subcircuit2ssc function/module?
Thanks in advance,
Nazım
  4 个评论
NAZIM YILDIZ
NAZIM YILDIZ 2022-11-21
Hello @Sangeeta, unfortunately I could not resolve the issue yet, after couple of tries I had stopped trying.
@David John, please see the code below:
*Level 1. Optimized for simulation speed
*$
*$
.subckt GS61008P gatein drainin sourcein source_S
*
*
.param rTC=-0.004 gan_res={3.38e-03} metal_res={2.0e-3} gtc=3.275 sh_s=0.239 sh_d=0.761
.param cur=0.089 x0_0=1.1 x0_1=1.1 x0_2=1.0 thr=1.8 itc=0.83 atc=180.15
*
*
rd drainin drain { sh_d* (metal_res/2.0*(1-1*rTc*(Temp-25)) + gan_res*PWR((Temp+273)/298,gtc)) }
rs sourcein source { sh_s * (metal_res/2.0*(1-1*rTc*(Temp-25)) + gan_res*PWR((Temp+273)/298,gtc)) }
RSS source_S source {0.001}
rg gatein gate {1.5}
*
*
Rcsdconv drain source {4000Meg}
Rcgsconv gate source {4000Meg}
Rcgdconv gate drain {4000Meg}
*
*
bswitch drain2 source2 I = (if(v(drain2,source2)>0,
+ (cur*(-(Temp-25)*itc+atc)*log(1.0+exp(26*(v(gate,source2)-thr)))*
+ v(drain2,source2)/(1 + dnlim(x0_0+x0_1*(v(gate,source2)+x0_2),0.2,5m)*v(drain2,source2))),
+ (-cur*(-(Temp-25)*itc+atc)*log(1.0+exp(26*(v(gate,drain2)-thr)))*
+ v(source2, drain2)/(1 + dnlim(x0_0+x0_1*(v(gate,drain2)+x0_2),0.2,5m)*v(source2,drain2)))))
*
*
R_drain2 drain2 drain {(1e-7)}
R_source2 source2 source {(1e-7)}
*
*
C_GS gate source {6.04e-10}
C_GS1 gate source Q = ( - 14.08e-11*(1-1./(1+exp(0.32*(-v(drain, source)+8.0))))
+ - 1.653e-11*(1-1./(1+exp(0.029*(-v(drain, source)+80.0))))
+ - 1.5e-10*(-1+1./(1+exp(0.16*(-v(drain, source)-2.1)))) )*x
*
*
C_GS2 gate source Q = ( 1.0e-010*log(1+exp(6.1*(x-2.2))))
*
*
C_GD gate drain {0.6e-012}
C_GD1 gate drain Q = ( 44e-11*log(1+exp(0.32*(x+8)))+
+ 57e-11*log(1+exp(0.029*(x+80))) )
*
*
C_SD source drain {2.18e-010}
C_SD1 source drain Q = ( 44e-11*log(1+exp(0.32*(x+8)))+
+ 57e-11*log(1+exp(0.029*(x+80)))+
+ 1.95e-10*log(1+exp(1.19*(x+16)))+
+ 1.69e-9*log(1+exp(0.07*(x+31))) )
*
*
.ends
*$
* Created in LTspice Version XVII *
* *
* GaN Systems Inc. Power Transistors *
* LTSpice Library for GaN Transistors *
* Version 3.1 *
* *
*****************************************************************
*****************************************************************
* *
* Models provided by GaN Systems Inc. are not warranted by *
* GaN Systems Inc. as fully representing all of the *
* specifications and operating characteristics of the *
* semiconductor product to which the model relates. The model *
* describes the characteristics of a typical device. *
* In all cases, the current data sheet information for a given *
* device is the final design guideline and the only actual *
* performance specification. *
* Although models can be a useful tool in evaluating the devices*
* performance, they cannot model exact device performance under *
* all conditions, nor are they intended to replace bread- *
* boarding for final verification. GaN Systems Inc. therefore *
* does not assume any liability arising from their use. *
* GaN Systems Inc. reserves the right to change models without *
* prior notice. *
* *
* This library contains models of the following GaN Systems *
* Inc. transistors: *
* *
* GS-065-008-1-L *
*****************************************************************
*Level. Focus on the simulation speed.
*
*
.subckt GS-065-008-1-L_L1V4P1 gatein drainin sourcein source_S
*
*
.param rTC=-0.004 gan_res={199e-3} metal_res={15.75e-3} gtc=2.715 sh_s = 0.05263 sh_d = 0.94376
.param cur=0.0443 x0_0=1.1 x0_1=0.3 x0_2=1.0 thr = 1.7 itc=0.103 atc=20.6629
*
*
rd drainin drain {sh_d*(metal_res*(1-1*rTc*(Temp-25)) + gan_res*PWR((Temp+273)/298,gtc))}
rs sourcein source {sh_s * (metal_res*(1-1*rTc*(Temp-25)) + gan_res*PWR((Temp+273)/298,gtc))}
RSS source_S source {0.035}
rg gatein gate {1.4+0.065}
*
*
Rcsdconv drain source {4000Meg}
Rcgsconv gate source {4000Meg}
Rcgdconv gate drain {4000Meg}
*
*
bswitch drain2 source2 I = (if(v(drain2,source2)>0,
+ (cur*(-(Temp-25)*itc+atc)*log(1.0+exp(26*(v(gate,source2)-thr)))*
+ v(drain2,source2)/(1 + max(x0_0+x0_1*(v(gate,source2)+x0_2),0.2)*v(drain2,source2))),
+ (-cur*(-(Temp-25)*itc+atc)*log(1.0+exp(26*(v(gate,drain2)-thr)))*
+ v(source2, drain2)/(1 + max(x0_0+x0_1*(v(gate,drain2)+x0_2),0.2)*v(source2,drain2)))))
*
*
R_drain2 drain2 drain {(1e-4)}
R_source2 source2 source {(1e-4)}
*
*
C_GS gate source {7.05e-11 * 0.7119}
C_GS1 gate source Q =(-1.9e-11*(1-1./(1+exp(0.07*(-v(drain, source)+20))))
+ -3.69e-11*(-0.682+0.66/(1+exp(0.11*(-v(drain, source)+.01)))))*x*0.7119
*
*
C_GS2 gate source Q = 1e-12*log(1+exp(8*(x-0.9))) * 0.7119
*
*
C_GD gate drain {0.46e-012 * 0.7119}
C_GD1 gate drain Q = 275e-12*log(1+exp(0.07*(x+20))) * 0.7119
*
*
C_SD source drain {2e-011 * 0.7119}
C_SD1 source drain Q = 0.85e-9*log(1+exp(0.085*(x+63))) * 0.7119
+ +1.45e-9*log(1+exp(0.025*(x+180))) * 0.7119
+ -2.65e-11*(1-1./(1+exp(0.07*(x+20))) * 0.7119)
*
*
.ends
*$
.SUBCKT GanSystem_Fets GATE DRAIN SOURCE SOURCE_K
R1 DRAIN SOURCE 1MEG
R2 GATE 0 1MEG
.ENDS GanSystem_Fets
Uruj
Uruj 2023-5-2
Hello,
How come dnlim is throwing up an error as an unrecognised function for me? Should I include some perticular addons?

请先登录,再进行评论。

采纳的回答

David John
David John 2022-11-21
On lines 25 and 111 of the lib file, you have stray newlines in the middle of a continued line. Please try removing those two blank lines.
  1 个评论
NAZIM YILDIZ
NAZIM YILDIZ 2022-11-21
It worked, thank you.
However I'm getting a new error, could you please take a look this one as well?
I've issued below command:
subcircuit2ssc('HALFBRIDGE.cir','+HalfBridge')
The output that I got is:
Warning: Directory +HalfBridge does not exist. Creating new directory by that
name.
Error using spiceBase/getConnectionString
All external nodes must be connected in XU1.
Error in spiceSubckt/getSimscapeText
Error in spiceSubckt/preparSimscapeFile
Error in subcircuit2ssc
Error in subcircuit2ssc (line 31)
subcircuit2ssc(netlist,target);
HALFBRIDGE.cir netlist content is as follow:
.SUBCKT HALFBRIDGE VPP VPN G_H S_H G_L S_L
L1 VPP N004 {L} Rser=100m
E1 N006 N008 G_L S_L 1
R1 N007 N006 10
*V1 VPP VPN 430
E2 N001 N003 G_H S_H 1
R2 N002 N001 10
*Vgs1 G_H S_H PULSE(0 5 0 10n 10n {(1-D)/fs + DT} {1/fs})
*Vgs2 G_L S_L PULSE(0 5 0 10n 10n {D/fs - DT} {1/fs})
XU1 N002 VPP N004 N003 GS0650081L_L1V4P1
XU2 N007 N004 0 N008 GS0650081L_L1V4P1
R3 G_H S_H 1k
R4 G_L S_L 1k
C1 VPP N005 {C}
R5 N005 VPN 10m
.param fs = 100k
.param D = 0.2
.param DT = 100n
*.tran 100u
.param L = 10u
.param C = 10u
.lib GanSystem_Fets.lib
.ENDS
Thank you in advance.

请先登录,再进行评论。

更多回答(1 个)

David John
David John 2022-11-21
编辑:David John 2022-11-21
The .subckt definition is not quite right for XU1 and XU2. There are some dashes missing from the subcircuit names in order to look like in your lib file. It looks like we should improve the error message for this to make it more clear.
Note that this answer is referring to your followup question.
  1 个评论
NAZIM YILDIZ
NAZIM YILDIZ 2022-11-21
编辑:NAZIM YILDIZ 2022-11-21
Thank you very much for your time sir, now everything is fine. I've compiled the file without any issue.
subcircuit2ssc('HALFBRIDGE.cir','+HalfBridge')
Netlist converted. Review Simscape component files and make
manual edits for any unsupported items before building the
Simscape library located at:
+HalfBridge.
To provide extra information for the community, the statement line 89 has been fixed(GanSystem_Fets.lib):
% .subckt GS-065-008-1-L_L1V4P1 gatein drainin sourcein source_S
.subckt GS0650081L_L1V4P1 gatein drainin sourcein source_S
Because in the HALFBRIDGE.cir file XU1 and XU2 (which are GanFets) called as below:
XU1 N002 VPP N004 N003 GS0650081L_L1V4P1
XU2 N007 N004 0 N008 GS0650081L_L1V4P1
@Sangeeta, issue has been solved for me.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Choose and Parameterize Blocks 的更多信息

产品


版本

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by