Query about usage of IF statement and TIME command together

Hello everyone,

I am trying to simulate an interleaved buck converter. And I want to enable the second PWM after a certain time. So I have used the following syntax in my simulation:

V=if((V(v_time)>=12.5µ),((V(duty)>V(sawtooth2)),15,-5),0)

I am continuously getting the following error:

Fatal error: Apparently missplaced comma in source expression if((v(v_time)>=12.5µ),((v(duty)>v(sawtooth2)),15,-5),0)
The problem occured while parsing the line:
B´VPWM2 PWM2 0 V=IF((V(V_TIME)>=12.5µ),((V(DUTY)>V(SAWTOOTH2)),15,-5),0)

I have evaluated the expression repeatedly, however, I am unable to pinpoint where I could possibly be going wrong.

I would appreciate your help.

With regards,
Ankit

PS: As I am a new user I am not able to upload my simulation file at this moment.

Problem solved. It was due to an incorrect syntax and an IF statement was missing.

Incorrect syntax:

Correct syntax is:
V=if((V(v_time)>=12.5µ),(if((V(duty)>V(sawtooth2)),15,-5)),0)

If V(v_time) somehow represents the simulation time, you can simply use time

1 Like

Thank you for replying, Kelvin.

Yes, you are correct. TIME directly can be used instead of converting TIME into an equivalent voltage and then use it. This just makes the simulation heavy (computationally). I had verified this on my own after I had solved the issue and before you replied.

Again thanks for the help, Kelvin.

1 Like