# How to find mean value of square signal

I have a comparator circuit and I need to find the mean value of the output square wave. I have calculated it like this:

$$\Vmean=1/T*integral(U*dt)\$$ from 0 to T and I got $$\Vmean=-0.7896V\$$

Can someone please check if that is correct?

• This would be more of a calculus question. You'd probably set up the integral $\displaystyle \frac{1}{T}\int_0^T f(t) dt$ – user103380 Oct 2 '19 at 18:46

You can check it yourself in the LTspice simulation:
Zoom the waveform to the region of interest (make sure you are seeing a whole number of periods).
Then move the mouse to the label of the trace (V(n002) or V(004) in your case), hold down the control key and left mouse click.

The pop-up window will show the average and RMS value.

• Thank you didn't know that ltspice can do that makes my life much simpler. – user229923 Oct 3 '19 at 19:15
• @TihomirRaicevic You'll find LTspice to be one of the most important/powerful tools for an EE. – Huisman Oct 3 '19 at 19:22

Since it's a square wave you can just use the duty cycle times the Max value.

I've used Mathematica to construct a function:

Finding:

$$\overline{\text{V}}_{\space\text{square}}=\frac{1}{\text{T}}\int_0^\text{T}\text{V}_{\space\text{square}}\left(t\right)\space\text{d}t=-\frac{19}{3}\approx-6.33333\space\text{V}\tag1$$

And the RMS value:

$$\text{V}_{\space\text{square}\space\text{RMS}}=\sqrt{\frac{1}{\text{T}}\int_0^\text{T}\text{V}_{\space\text{square}}^2\left(t\right)\space\text{d}t}=\sqrt{\frac{313}{3}}\approx10.2144\space\text{V}\tag2$$

• Thanks for the help I hope it didn't take too much of your time really appreciate it. – user229923 Oct 3 '19 at 19:17
• @TihomirRaicevic You're welcome man! – Jan Oct 3 '19 at 19:47