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?

308 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

A Pulse Width Modulation (PWM) signal has 2 properties: Frequency of the pulses and the Duty Cycle. The duty cycle is the ratio between *on*-time and *off*-time of the signal.

A duty cycle of 100% means always on, 0% means always off, 50% means half of the time on/off, 25% means 25% on, etc…

Although this is technically not an anlog signal, the average voltage will correspond more or less with the duty cycle. (Where 100% is often 5V or 3,3V, depending on the hardware.)

A sinewave can be represented by changing the duty cycle over time; from 0% to 100% and back to 0%. in each period.
And additional circuit is used (with an opamp) to offset the voltage so 50% duty cycle corresponds with 0 for the sinewave. This means 100% will be the top of the wave and 0% is the bottom of the wave.

In order to create an accurate sine wave, the frequency of the PWM signal must be high enough, you must be able to change the duty cycle fast enough, and the pulsed output should be converted into a true analog signal. (By using a filter.)

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