I am trying to implement an ideal PWM controller in for an analog circuit I have in ORcad PSpice. Ideally I would use the SLPS tool for simulink, but unfortunatelly we do not have the licence for it so I have to look for a workarround.

The circuit is a Half-Bridge amplifier which gets four PWM signals to control the two transistors (two signas turn on the mosfets, and the two other turn them off and keep them that way). So what I would like is for the PID to give a control signal from 0 to 1 V or something like that and for that voltage level to control the duty cycles of the four square wave generators I have or to somehow make the PWMs I need. Something like if the PID signal is 0.4V the duty cycle is 40% (0.4). I tried something like in the image, but I get the following error:

.PARAM  vin=2.5 t_tot=1.5us freq=32k t={1/freq} d={v(v_duty)}
ERROR(ORPSIM-16131): Expression - use previously defined parameters only

Can anyone help me with this? It is for my master thesis.

Cheers, Camilo

duty cycle from voltage level

edit: it was suggested to use a comparator. Unfortunatelly that does not solve the issue in my case as that way I would have only one PWM, I need to generate something like this:


the comparator idea (as I understand it) would only work for both "off" signals. The full period of all signals is 32 kHz, the duty clycle of both off signals is the same and could be generated by the comparator. The on signals have one 1.5 us pulse (the top is always 0V with a 5V pulse, the bottom is the contrary) and the pulse kicks in after the deadtime (1.5 us) has passed (deadtime starts on a flank of the off signal)

  • \$\begingroup\$ It is for my master thesis. How is that relevant ? \$\endgroup\$ Commented Jul 4, 2016 at 14:50
  • \$\begingroup\$ Can it be in a netlist form or do you need the schematic representation? \$\endgroup\$ Commented Jul 8, 2016 at 15:09
  • \$\begingroup\$ schematic would be better \$\endgroup\$
    – gapsna
    Commented Jul 9, 2016 at 13:24

1 Answer 1


It is possible to make a PWm signal using a pulse source but it is cumbersome.

The "classical" way to make a nice PWM signal is to make a sawtooth or triangle wave of the preferred frequency. You can make this wave in the simulator using a pulse source, note that you will need relatively long rise and fall times.

Then compare that wave to a DC level using a comparator or opamp. Note that in the simualtor you will need an opamp with a selectable maximum and minimum output voltage.

Varying the DC level sets the PWM duty cycle. The output of the opamp or comparator is the PWM signal.

enter image description here

  • \$\begingroup\$ this does not help unfortunately, I will update my post \$\endgroup\$
    – gapsna
    Commented Jul 7, 2016 at 12:23
  • \$\begingroup\$ This does work but it might not be what you want. But what you want is quite unclear to me. You also have to think a bit more for yourself. It seems you need an "inverse PWM" also yet you are not able how to figure out how to get that. While I would just swap the inputs of the comparator. \$\endgroup\$ Commented Jul 8, 2016 at 11:46
  • \$\begingroup\$ still have not found a way to do this in PSpice. I am trying to get a students license for OrCad SLPS so I can generate the PWMs in Simulink and feed them to my circuit. That way I can also build a controll block. \$\endgroup\$
    – gapsna
    Commented Jul 12, 2016 at 7:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.