Eli5: So apparently Arduino Uno cannot output analog signals and so it uses pulse width modulation to mimic an analog signal output. So then, how can a square wave with varrying width mimic an analog signal’s sine wave?

292 views

Eli5: So apparently Arduino Uno cannot output analog signals and so it uses pulse width modulation to mimic an analog signal output. So then, how can a square wave with varrying width mimic an analog signal’s sine wave?

In: 34

18 Answers

Anonymous 0 Comments

The important factor is that the percentage of the cycle for which the output is high can be varied. This is the pulse width in the name, and is more commonly referred to as the duty cycle, with 100% being high all the time, 50% being high 50% of the time and low 50% of the time.

For PWM to work perfectly you need a load that will smooth the output slightly. This is true if the load has some capacitance or inductance, which most do. If you just set your output to a fast 50% duty cycle square wave then the load would experience that as a smooth output at half the supply voltage.

This is the key point; the cycles are fast enough that the load experiences them as merely the average voltage from a couple of cycles. This average voltage depends on the duty cycle – 100% duty cycle means the average voltage over the cycle is 100% of supply voltage, and so on.

So start with a 100% duty cycle, and slowly reduce to 0%. The load will experience this as a slowly reducing voltage, just like you would get out of an analogue supply. Now ramp the duty cycle up and down and hey presto you have a sine wave!

You are viewing 1 out of 18 answers, click here to view all answers.