How to make pwl source

I want to make pwl source with below parameter.
But, it does not work.
Warning: IBUS: The first and last values of PWL REPEAT FOR…ENDREPEAT source must match: 0 vs 30.

Please tell me how to make this pwl source.
Thank you.

.param I1 120
.param I2 50
.param T1 150m
.param T2 150m
.param tr 1µ
.param tf 1µ

pwl repeat for 20 I1 0 I1 T1 I2 T1+tr I2 T1+tr+T2 I1 T1+tr+T2+tf endrepeat

Hello Tanbom

I don’t get that error but, I do get a flat line at the output and, for good reasons: the format for PWL is TIME1 VALUE1 TIME2 VALUE 2 ..., whereas you have reversed them: VALUE1 TIME1 .... If you’ll change them to match this: pwl repeat for 20 0 I1 T1 I1 T1+tr I2 T1+tr+T2 I2 T1+tr+T2+tf I1 endrepeat, it should work.

Still, there may be two points to be made:

  • the way you specify the time points is cumulative so it’s more convenient to use the increment operator, +: pwl repeat for 20 0 I1 T1 I1 +tr I2 +T2 I2 +tf I1 endrepeat (at every new timepoint you’re simply adding the required quantity);
  • if all you want is a train of pulses for a specific number of periods, you’re better off using the more friendly PULSE with a specified number of periods (as you type you get hints about the values, see NCYCLES).

Vlad

1 Like

Hello archbugaboo
Thank you for your information and useful tips.

It worked without any problems.

1 Like