Third Party Model Import Fatal error: Unknown device type: {

Hello everyone,
When I was trying to model a subcircuit for the modulator model PWM, I got this error:
Fatal error: Unknown device type: {
Here is my subcircuit:

  • Subcircuit for PWM Control
    .SUBCKT PWM 7 5 10 11 PARAMS:
  • fout = 60Hz p = 4
  • Model ref. carrier +g1 control +g3 control
  • Name signal signal voltage voltage
  • Where fout is the output frequency and p is the number of
  • pulses per half cycle
    Vref 7 0 PULSE (1 0 0 {1/(2*{2*{p}{fout}})}
    {1/(2
    {2*{p}{fout}})-1ns}1ns {1/{2{p}*
  • {fout}}}) ; Reference voltage at output frequency
    V_mod 5 0 0.6 ; Modulation index of less than 1.0
    Vx 8 0 PULSE (0 1 0 1ns 1ns {1/(2*{fout})-
    2ns} {1/{fout}}) ; pulse at the output frequency
    E_ABM21 6 0 VALUE {IF(V(5)-V(7) > 0, 1, 0)}
    E_ABM12 9 0 VALUE {1-V(8)} ; Inverter
    E_MULT1 10 0 VALUE {V(8)*V(6)} ; Multiplier 1
    E_MULT2 11 0 VALUE {V(9)*V(6)} ; Multiplier 2
    .ENDS PWM ; Ends subcircuit definition

So what’s wrong with my modulator model PWM? Can you guys help me fix it? I really need your help!

Thank you very much.

The problem is that the model has new line characters that are SPICE syntax errors. No SPICE will accept it.

For example, the line that starts out “{1/(2…” should be on the same line as the one before it.

Same for the line that starts out “2ns}”

–Mike

1 Like

OMG it actually works! Thanks very much for your help.
Because of being new to QSpice, I have struggled with this error for weeks and if you didn’t help me, I would have never fixed it! So again, I’m very appreciate your advice!

2 Likes

I think Mike already solved your problem, but anyone want to copy this PWM may not work even they fix the line break as characters are removed for auto format as your subcircuit not pasted to this forum with Preformatted text format.
For this sub-circuit, V_mod can be removed so that modulation index pin (5) can be used.

Files is upload to https://github.com/KSKelvin-Github/Qspice/tree/main/Forum/15706

This is the modified subcircuit

* Subcircuit for PWM Control
.SUBCKT PWM 7  5  10 11 PARAMS: fout = 60Hz p = 4
*           |  |  |  |
*           |  |  |  output 2
*           |  |  output 1
*           |  modulation index : 0-1V input voltage for pulse width modulation
*           sawtooth at output frequency (reference)
* input params : fout is the output frequency
*                p is the number of pulses per half cycle
Vref 7 0 PULSE (1 0 0 {1/(2*{2*{p}*{fout}})} {1/(2*{2*{p}*{fout}})-1ns} 1ns {1/{2*{p}*{fout}}}) ; sawtooth at output frequency
Vx 8 0 PULSE (0 1 0 1ns 1ns {1/(2*{fout})- 2ns} {1/{fout}}) ; pulse at the output frequency
E_ABM21 6 0 VALUE {IF(V(5)-V(7) > 0, 1, 0)}
E_ABM12 9 0 VALUE {1-V(8)} ; Inverter
E_MULT1 10 0 VALUE {V(8)*V(6)} ; Multiplier 1
E_MULT2 11 0 VALUE {V(9)*V(6)} ; Multiplier 2
.ENDS PWM ; Ends subcircuit definition

And this is an example.

2 Likes

Love you Kevin, I’m very appreciated your work!!!