Where is LTSpice getting this Vrms from ?? - Page 1
Forum section: electronics / beginners

author: MathWizard
author_rank: Super Contributor
timestamp: March 21, 2025, 01:37:36 pm
content: Shouldn't the Vrms of a 20% Duty-on square-wave be Vrms=SQRT( (T*Vp^2) / 5*T) =Vp/SQRT5 = SQRT5 *Vp/5All last night, LTSpice was saying this pulse, PULSE(0 21.5597 0 1n 1n 2.3u 9.2u), had over 10.62Vrms, when it should be 9.6418Vrms.And I even had to check an online calculator. Now again this morning, it's giving me varying numbers. Zoomed way way out to ~250ms, it says the Vrms is 10.782V, I had 10.9xx on another zoom.Now zooming way in, if it just looks at the signal displayed on screen, at some zoom you be just looking at a line and the Vp=Vrms.But when zoomed way way out, how is the Vrms so much higher ? I've seen Vsoucre voltages get larger than a true perfect Vsource can get, no doubt from approximations that go on, and poor models or circuits.But w/ nothing connected connected to the Vsource, zoomed out to 1 sec, it still says PULSE(0 21.5597 0 1n 1n 2.3u 9.2u) has an rms of 10.781VOk so is it the default time-step is too-small to properly use the 1n rise/fall times ? Because when I go to 1ps r/f, which is way less than the default step size, it can't even really make a squarewave, and the Vrms was ~2VWith 1us Tr/f , or 10ns , I get the expected answer, but not for 1ns Tr/f. So I'm realizing more, I can't always trust what the sim says.Well again tho, not with PULSE(0 21.5597 0 10n 10n 2.3u 9.2u), that's still off, above I used 0.2 ON and 1sec period.Adding in the equal Tr/f to the Vrms, I getVrms = Vp * SQRT ((3*ton + 2tr)/(3*T))And w/ tr/f about 1/1000 of T, it barely affects anything

author: Zero999
author_rank: Super Contributor
timestamp: March 21, 2025, 05:45:29 pm
content: What .tran command did you use? Did you plot the all of the high and low cycles?LTSpice calculates the RMS voltage from the data plotted in the waveform window.The reason for the inaccurate result is probably due to the calculation looking at an odd number of cycles, given it's lower than expected, you're looking at more negative than positive cycles.edit:I've just done this myself. If I do .tran 92u and plot the entire waveform, I get 10.781V. When I zoomed in on the high part, I just get 21.5597V and when I zoom in on the zero, I get 0V.

author: MathWizard
author_rank: Super Contributor
timestamp: March 21, 2025, 07:05:45 pm
content: Oh nevermind, no wonder I can't recreate it now, I was mixing up the total period, with the off time in the Vsource. I had 25% duty cycle, not 20%, no wonder...

author: Zero999
author_rank: Super Contributor
timestamp: March 22, 2025, 06:55:21 pm
content: Quote from: MathWizard on March 21, 2025, 07:05:45 pmTry pasting this into a SPICE directive.V1 sq 0 PULSE(0 1 0 .1u .1u {5m-.1u} 10m).tran 100mNow plot V(sq) and calculate the RMS voltage. It should be 1/√2. Now, zoom into the high and low parts and calculate the RMS, which should be 0V or 1V, depending on whether the signal in the plot window is low or high.

author: bson
author_rank: Unknown
timestamp: March 22, 2025, 07:44:52 pm
content: RMS is only defined for a waveform with a mean of zero. What you're discussing is standard deviation.Average power for example is easily calculated from RMS voltage, but not from a DC voltage or from its standard deviation; consider the simple case of a flat DC voltage and current, it will have a std dev of zero, yet there is power delivered to the load.

author: MarkT
author_rank: Frequent Contributor
timestamp: March 23, 2025, 11:08:16 am
content: Quote from: bson on March 22, 2025, 07:44:52 pmOnly if you know the load impedance and it is constant. Otherwise you need the full voltage and current waveforms to calculate average power.For single frequency sinusoids you only need to know the rms voltage, rms current and the power factor (or, equivalently, phase difference between voltage and current).The RMS voltage of a DC voltage is its absolute value, nothing special there.

author: Zero999
author_rank: Super Contributor
timestamp: March 23, 2025, 01:29:11 pm
content: Quote from: bson on March 22, 2025, 07:44:52 pmNo, the RMS just means Root Mean Square. It can be calculated from any waveform, irrespective of whether it has any DC content.