# How to Calculate the average of a Square Wave?

I could not figure how to calculate the average of a square wave.

Consider a square wave of +5V from time 0 to 6 sec and -3V from 6 to 10 sec.

On integrating from time 0 to 6 the average: 3.0V

On integrating from time 6 to 10 the average: -1.2V

Thus the total average is : $$3-1.2=1.8V$$

But according to my teacher it results in 4.2V (3 +1.2).

Can anyone explain me the calculation?

• What kind of "average"? – Phil Frost Jan 7 '14 at 16:58
• Maybe they mean average magnitude? That would make the maths correct, but it's a funny thing to compute. – pjc50 Jan 7 '14 at 19:51
• It's a potentially useful thing to compute for certain purposes. Like, say, demonstrating the difference between average voltage and RMS voltage for power dissipation in a resistor. – Stephen Collings Jan 7 '14 at 20:10
• It could be that the teacher made a legit error, but I suspect there's some unspoken assumption in the question being asked. Like when someone specifies an AC voltage, and you just assume it's RMS and not average or peak because... that's what you do. – Stephen Collings Jan 8 '14 at 13:24
• Yeah, it looks like the words "RMS" got lost somewhere between teacher, pupil and here. – pjc50 Jan 8 '14 at 16:30

The first half is 6 x 5. The second half is 4 x -3. Add the areas together and you get 18. Now divide by the total length of time (10) to get 1.8. Same as you. Your teacher is wrong or you asked them a different question. If we assume that the negative part of this signal is also contribute to the power delivered on the load, then the RMS value of up1 will be which is 15

and the RMS value of up2 which is equal to 3.6

and the total RMS value of the bipolar pulse waveform will be equal to square root of the sum of the squares of up1 and up2 or 4,31V

Mean (average) value calculated as follow: D is duty cycle so Umean equals 4,2V

• could you please explain me why the concept i used is wrong here? integrating the signal over the total time and then dividing it by the total time: – user35219 Jan 8 '14 at 9:08
• Just some minor pedantry on textual sequence: Duty cycle D is unitless, as it is time divided by time. So duty cycle doesn't equal 4.2 Volts, mean voltage u_mean from the previous equation does. – Anindo Ghosh Jan 8 '14 at 12:05
• Sorry for my english that missdrivig you ...Anindo already clarify. Let me edit to correct – GR Tech Jan 8 '14 at 12:54
• Keep in mind that the maximum value is called the positive peak (V+p), and the minimum value is called the negative peak (V-p); and the difference between them is called the peak to peak value. In this case Vpp=+5-(-3)=+8V. Are you wanted to calculate or to measure AC or DC component of this signal? – GR Tech Jan 8 '14 at 13:36
• In what circumstances is the average value of the voltage useful? The average voltage ( taking into account sign ) is useful for e.g. inductor balance in a dc-dc converter, the RMS voltage is useful for power into a resistive load, but what would the average value be useful for? – Pete Kirkham Jan 8 '14 at 15:59

You still lose energy in the resistor when the voltage is at -3. So you are losing power at +5V and when you are at -3V so you need the absolute value of -3V. So you have 5V for 6 seconds along with 3V at 4 seconds

By definition, average value is:

$$V_{av} = \frac{\text{intgeral of Voltage over time}}{\text{total time}}$$

$$V_{av} = \frac{((5V * 6sec) + (- 3V * 4sec))}{10sec}$$ $$V_{av} = \frac{(30V/sec -12V/sec)}{10sec}$$ $$V_{av} = \frac{18V/sec}{10sec}$$ $$V_{av} = 1.8V$$

You are correct!

PS: RMS is NOT same as average or mean.

• no his answer is 4.2V while what i got is 1.8V. – user35219 Jan 8 '14 at 9:09

Your teacher provided the correct answer 4.2V. Average value of a pulse waveform V(avg)=baseline + duty cycle x amplitude. 5v from 0 to 6 sec. ( 0v + 60% X 5 v = 3v. and -3 frm. 6 - 10s ( 0v + 40%x3)= 1.2v. Then you add 3v+1.2v=4.2v. Amplitude always positive number...

• Presumably, the OP has already completed the course and graduated, since this question was from 2014. There’s no harm in posting answers to old questions, though. Just letting you know. Sometimes old posts find their way back to the top, and they’re easy to mistake as new. – Blair Fonville Jun 29 '18 at 4:50

Instead of integrating, you can think about it as finding the weighted average. They will both give the same answer but the weighted average is a lot less labour! 6 seconds out of the 10 seconds,the voltage was -3V and 4s out of the total 10 seconds, the voltage was 5V. So, V_av = 0.6×(-3) + 0.4×(5) = 1.8

It seems one question has two answers. If you put minus 3 (-3) in the math calculation the answer is 1.8V = [5v X 6s + (-3)v x 4s] / 10s, however if you read this wave on the oscilloscope the Vp-p is 8v. Therefore, in positive area Vp1avg = Vp1XD=5v x 0.6 = 3V and Vp2avg=Vp2XD=3v x 0.4 = 1.2v if you count Vp1avg + Vp2avg= 3v + 1.2v = 4.2v that confirms your teacher gave the correct answer.

Where D stands for Duty Cycle for squareware duty cycle is percent i.e. 100%. In 5v D is 60% (0.6) while the -3v is 40 % (0.4).

I am amazed by so many wrong answers, and bad concept knowledge about why is the use os RMS. Elevating ANY number to its square is exactly as rectifiering a bipolar waveform. Any polarity of the waveform is useful and should be threated as absolute numbers. Do you really believe that a negative voltage produces negative power??? SquareRoot of 6 periods of 5V squared, plus 4 periods of 3V squared, divided by total periods. Sqrt((25×6 + 9×4 )/10) = SQRT((150+36)/10) = SQRT(18.6) = 4.31. What a heck? What is the problem with you guys? This is straight obvious.

• The question doesn't mention power or RMS. What is the problem with you? This is straight obvious. ;^) – Transistor Jan 8 at 7:25
• There are simply a whole bunch of mathematically possible averages. What's obvious is that the OP means the arithmethic average. Besides that there also quadratic average (RMS), cubic averages etc. You can even think of maximum or minimum of a function as some kind of 'weird' averages (derived from a mathematical norm). For introductory reading see en.wikipedia.org/wiki/Mean – oliver Jan 8 at 18:30