PWM sweep from 0 - 100% duty cycle in LTSpice

  • #1
PhysicsTest
238
26
TL;DR Summary
How do i sweep pwm in ltspice from 0% to 100% duty
How do i simulate the PWM signal with duty from 0% to 100% in Ltspice.
1693846790874.png


I can generate a pwm signal with single duty.
 
Engineering news on Phys.org
  • #2
Do you want to plot some variable, as a function of duty cycle from 0 to 100% ?
How many cycles do you require across the plot ?
 
  • #3
I want to check the inductor current as the PWM voltage source duty varies from 0% to 100% duty.
1693848337036.png
 
  • #4
For any PWM duty, it will take a number of cycles to settle to a new average current, so it is probably best to stack several plots on the one graph. Each plot for a different DC%.

To do that, I would .PARAMeterise the duty, then use a .STEP to sweep through a number of values.

The average current, for the cycle at the end of each sweep, could be .MEASured and recorded in the log file.
 
  • Like
Likes DaveE
  • #5
Attached is an example.
 

Attachments

  • PWM_0-100.asc.txt
    803 bytes · Views: 59
  • Like
Likes PhysicsTest and jim mcnamara
  • #6
My idea is i want to generate a sine output current across inductor by varying the PWM duty. I want to simulate the same in LTspice. I am trying it.
 
  • #7
PhysicsTest said:
My idea is i want to generate a sine output current across inductor by varying the PWM duty.
That appears to be a different problem.
What frequency sine wave, 50/60 Hz ?
What frequency is the PWM, 100 kHz ?
Does "current across inductor" mean you want to produce a sinusoidal magnetic field, by the changing current flowing through an inductor?
 
  • #8
It is 50Hz and pwm frequency is 20khz. First step is only to change current in the inductor as a sinusoid by making the pwm duty changes.
 
  • #9
How will you deal with the DC offset? PWM between 0 - 5V will have a DC component which will make the inductor current grow without limit.

What sort of accuracy can you tolerate? There are some pretty easy schemes to follow a sinusoidal reference with a ramp and comparator function, but they are not precise. They will have harmonic distortion.

50Hz is 2.6 decades below 20KHz, so you might just put in a continuous time sinewave instead of pwm as a good approximation.

edit:
"a DC component which will make the inductor current grow without limit."
Oops! sorry, This is wrong, I forgot about the series resistor which determines the DC current.
 
Last edited:
  • #10
I am not sure why my results are not matching with circuit in post3
1694016343846.png

For t=2ms i used the below equation
1694016640354.png


1694016524262.png

But the answer does not match at t=2ms it is around 2.4A. I am really confused not able to solve basic circuits.
 
  • #11
First, ignore the ripple.
Average the voltage or current over one full cycle.
For 100% duty cycle; duty = 1.00 ; I(L1) = V1 / R1;
For any other duty, averaged over each full cycle;
Vd = duty * V1;
Id(L1) = duty * V1 / R1.
 
  • #12
But if i see the below website he gave an example for Capacitor
Capacitor should i not follow the same for inductor?
 
  • #13
PhysicsTest said:
But if i see the below website he gave an example for Capacitor should i not follow the same for inductor?
That depends on what you are trying to simulate.

The voltage on a capacitor will increase and decrease in a decaying exponential when supplied with a PWM voltage. The average capacitor voltage will depend on duty cycle and the PWM voltage.

The current through an inductor will increase and decrease in a decaying exponential when supplied with a PWM voltage. The average current will be the PWM voltage * duty / circuit resistance.

If you are interested in the ripple amplitude, then that is another question.

What exactly has this topic become?
 
  • Like
Likes berkeman
  • #14
I have lot of questions to understand and i do not want to start new threads, but related to the first question which i have to solve.
 
  • #15
  • #16
PhysicsTest said:
My idea is i want to generate a sine output current across inductor by varying the PWM duty. I want to simulate the same in LTspice. I am trying it.
Errors are always made with the wrong assumptions. So check mine. I assume this is a unipolar 0 to 5V square voltage signal. This makes a big difference from bipolar signals because of the DC component.

1. Inductor current integrates a step voltage, the resulting PWM current is not a sine but a triangle wave.
2. The link to the pulsed capacitor file reports ripple (V1-Vo)/2. However, by convention, they only rate capacitors for RMS current and we usually mean p-p when we say ripple going from 0 to 100% and not V(p-p)/2. The maximum ripple current will be when the duty factor is 50% while the maximum DC current is at 100%.
3. The exponential time constant of Tau = L/R = 1.13 ms to reach ~63% of target while the PWM half cycle is 50us/2 = 25 us. After this time you can measure steady state ripple.
4. The triangular current has a DC component current which you integrate over the PWM cycle.
5. Reducing the duty factor causes the average inductor voltage to approach 0 Vdc in 10 τ=10L/R time but this raises the instantaneous positive voltage and slew rate while reducing the negative slew rate by the same amount while always maintaining 5V p-p.
6. Thus, the ripple current [p-p] is a minimum at <1% and >99% and maximum at 50% while the DC current is proportional to the duty factor.
7. To choose an appropriate capacitor for such a problem is a different question not asked but worth learning. We usually de-rate the cap to achieve a certain life and not operate it at the limit which might only last 1kh or 1000 hours. The absolute maximum ripple current is reduced for thermal margin to extend hours of MTBF say from a standard rating of 85'C or an industrial rating 105'C rating and some as high as 125'C and then we convert current to RMS.

p.s.
Arrhenius Law dictates that for every approx 10 'C rise of internal temperature lifetime reduces 50%. Such that the rated RMS current squared * ESR of internal Effective Series Resistance with an elevated ambient causes the standard electrolytic capacitor to last only 1000 to 1500 hrs at 85'C at some Irms current value, which is only 60 'C above the "standard room temp" of 25'C. But don't worry about this until you have to do some real design.
 

What is PWM and how is it implemented in LTSpice?

PWM, or Pulse Width Modulation, is a technique used to control the amount of power delivered to an electronic device by breaking up the signal into discrete on and off periods. In LTSpice, PWM can be implemented using a voltage source configured to output a square wave where the duty cycle (the proportion of the time the signal is high versus low) can be adjusted according to the desired output.

How do you set up a PWM sweep from 0 to 100% duty cycle in LTSpice?

To set up a PWM sweep from 0 to 100% duty cycle in LTSpice, you can use a piecewise linear (PWL) voltage source to create a varying duty cycle. This involves setting the voltage source to output a waveform that changes its high and low durations over time, effectively sweeping the duty cycle across the desired range. You can also use a behavioral voltage source with a formula that adjusts the duty cycle over time.

What are the typical applications of a PWM sweep in circuit simulations?

PWM sweeps are commonly used in simulations that involve testing the response of circuits to changes in power delivery, such as in motor control systems, power supply units, and LED dimming circuits. By sweeping the duty cycle, you can analyze how different components react to various levels of power and optimize the circuit's performance and efficiency.

Can you simulate a PWM sweep in LTSpice for components like MOSFETs or BJTs?

Yes, you can simulate a PWM sweep in LTSpice for components like MOSFETs or BJTs. By applying a PWM signal to the gate of a MOSFET or the base of a BJT, you can observe how these components behave under different duty cycles. This is useful for designing and testing switching circuits, power regulators, and amplifiers.

What are some challenges you might encounter when setting up a PWM sweep in LTSpice?

Some challenges in setting up a PWM sweep in LTSpice include ensuring that the timing of the PWM signal is accurate, dealing with the convergence issues that high-frequency PWM signals can cause, and accurately modeling the thermal and transient responses of components affected by the PWM signal. Additionally, setting up complex PWM signals that involve non-linear components or feedback loops can require careful tuning of simulation parameters to achieve realistic results.

Similar threads

Replies
2
Views
820
  • Electrical Engineering
Replies
1
Views
637
Replies
18
Views
2K
Replies
7
Views
1K
  • Electrical Engineering
Replies
26
Views
3K
Replies
1
Views
962
  • Electrical Engineering
Replies
14
Views
811
  • Electrical Engineering
Replies
2
Views
2K
Replies
25
Views
4K
Replies
9
Views
4K
Back
Top