0
\$\begingroup\$

A simple PWM circuit is simple to create using LTSPICE, such as:

VIN VSIN 0  SIN(0 1 10 0 0)
 VP VTRI 0 PULSE(-1.5 1.5 0 9.998m 1u 1u 10m)
 B1 VOUT 0 V=U(V(Vtri)-V(Vsin))*5

But voltage reflection simulations, i need the PWM rising edge to be more realistic, i.e. with a time delay on the rising edge like this:

enter image description here

I have tried using a PULSE, but its frequency and on-time is fixed.

What I need is something that activates a given pulse, or a behavioral voltage source that can create a pulse if a certain condition is true. The pulse has to be as long as the condition is true - as with conventional PWM.

An example of what I have tried, but which caused a syntax error:

enter image description here

The syntax error is that in the B2-element (to the right), cannot use "V1" as voltage output. It has to be 5 (volts) or something.

How to I solve this? I just started using SPICE two days ago, and I bet there is a few tricks I am not aware of yet

\$\endgroup\$
  • \$\begingroup\$ I haven't tried this yet, but you probably need to write V(V1) in that expression/source on the left . \$\endgroup\$ – Fizz Nov 15 '15 at 14:01
  • \$\begingroup\$ Thanks for your comment. It worked partially: It outputs the current value of the PULSE, but that PULSE still have a given on-time which does not adjust according to the desired pulse width. However, I did learn something new which can be useful later. \$\endgroup\$ – fluxmodel Nov 15 '15 at 14:20
  • \$\begingroup\$ Well, I don't see why you expect that latter to work. Your V1 needs to be a triggered ramp. \$\endgroup\$ – Fizz Nov 15 '15 at 14:32
  • \$\begingroup\$ Exactly, but i didn't realize that until seeing the results. Learning by failing \$\endgroup\$ – fluxmodel Nov 15 '15 at 15:07
0
\$\begingroup\$

This works for me.

enter image description here

I had to change the prefix to BV for [B]V4. And also use net names; it doesn't seem to take the voltage sources' names in those behavioral expressions.

enter image description here


What I need is something that activates a given pulse, or a behavioral voltage source that can create a pulse if a certain condition is true.

What you seem to actually want however is a PWL triggered ramp like so:

enter image description here

Also what you're describing is not actually called PWM. If you somehow need to modulate the width instead of triggering then see this solution.


Well assuming you only want non-zero rise (as in your graph) but zero fall time, and you want that combined with PWM, then you basically have to combine the above two solutions:

enter image description here

\$\endgroup\$
  • \$\begingroup\$ First of all, thank you for your answer and your effort. I see that I have been unclear in describing what I need. It is in fact a PWM, but I need to be able to adjust the rate of rise of the PWM pulse so that it resembles a realistic voltage output from an e.g. IGBT to a long cable + motor. The width has to be dynamic according to the input sine and triangular wave as normal. \$\endgroup\$ – fluxmodel Nov 15 '15 at 15:12
  • \$\begingroup\$ @fluxmodel: before I add 3rd solution/reply: adjust the rise based on what? \$\endgroup\$ – Fizz Nov 15 '15 at 15:15
  • \$\begingroup\$ I am testing how different rise time affects the voltage reflection and filter parameters. So I have to be able to adjust the rise time before each simulation. during the simulation the rise time will be kept constant. And, once again i am very grateful for your contribution! \$\endgroup\$ – fluxmodel Nov 15 '15 at 15:31
  • \$\begingroup\$ It seems as if your second solution is what i need. I will test it later tonight. \$\endgroup\$ – fluxmodel Nov 15 '15 at 15:33
  • \$\begingroup\$ Works perfectly. Thanks for teaching my these nifty tricks :) \$\endgroup\$ – fluxmodel Nov 15 '15 at 21:39
0
\$\begingroup\$

The proposed methods will work, but you're much better off using a dedicated element for this job: [Digital]/diffschmitt:

pwm

You can specify separate rise and fall times through trise and tfall. For more about it, see the help, LTspice > Circuit Elements > A. Special functions.

\$\endgroup\$
0
\$\begingroup\$

Try using a piece-wise linear voltage source (in the advanced dialog).

This uses a time-value pair sequence and can be defined in the source dialog or from a file.

LTSpice will interpolate from a given pair to the next in a linear fashion.

If I start with time=0 and v=0 and the next pair is at time=1m with v=3, then you will get a rising signal at 3v/millisecond.

Add more points to get the precise wavrform you want.

This is incredibly useful when you have measured a waveform and saved it from a scope to do what-if analysis with a circuit in the simulator, to name at least one other application.

\$\endgroup\$
  • \$\begingroup\$ Thank you for teaching me about PWL. I have tested it and it creates a shape that I want. How can I make the PWM-generator use this signal shape? \$\endgroup\$ – fluxmodel Nov 15 '15 at 13:58
  • 1
    \$\begingroup\$ Use the PWLsource as the PWM generator to test the rest of the circuit. \$\endgroup\$ – Peter Smith Nov 15 '15 at 14:28

protected by Community Sep 5 '18 at 11:49

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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