# Set parameter from voltage output (LTspice)

I have PULSE(0 123 0 0.0000001 0.0000001 0.0000333 0.0000666) and I want to change the sixth parameter according to a voltage source output. I need to alter the parameter to make sine wave.

How could I do that?

I would imagine something like PULSE(0 123 0 0.0000001 0.0000001 V1+0.0000333 0.0000666)

TV1 is SINE(0 0.0000333 50 0)

• Just add two voltage sources, one a PULSE the other a SINE. Neither of those accepts time dependent variables as parameters, but they can accept .param. Aug 20, 2021 at 14:37
• but can .param be time dependant? i simply need to change pulse value to simulate sine wave with pwm Aug 21, 2021 at 13:21

## 1 Answer

All .param statements are evaluated prior to simulation start, therefore time, which starts at zero with the simulation, cannot be a parameter. A .func can be time dependent, but then its evaluation will only be done during the simulation. Implicitly, if the PULSE and the SINE sources can accept .param but not time-dependent .func definitions then they can't have variable parameters.

However, put like that it's an XY problem. What you describe is a PWM, since you need to vary the 6th term (Ton) in a PULSE, according to a SINE. For that, there already are solutions.

• I tried that example in link. How is it supposed to change that pulse parameter? How could I apply it to mine? Aug 22, 2021 at 7:16
• @RiDi You'll have to think for yourself a bit, otherwise how do you expect to get on in life with problems: by asking at every step? What is depicted in the linked answer is the basic configuration for generating a PWM. If it's that difficult, here is a practical example. Aug 22, 2021 at 8:12
• your example give this result - shouldnt PWM be like this? Aug 22, 2021 at 10:59
• @RiDi It looks like you used a fixed voltage for the reference, not a sine. Either that or you didn't run it for a long enough time span. There is a third possibility: that you don't know what PWM means or does, but surely this is not the case, no? Aug 22, 2021 at 11:23
• sorry, I mean it is not pwm on switches, but their control signals. I do not understand why they (switches) should be controlled like this Aug 22, 2021 at 11:36