January 02, 2016

Digital-Analog Conversion, or Voltage Control by PWM

For volume (amplitude) control of the unit's output channels, I will need a way of converting a digital volume value (say, a percentage) to an analog voltage level.

Essentially, a digital-analog converter (ADC) is required. I will, however, not use the ADC channels of the Due: it's only got two of them, and using them would be overkill, too. The common way to digitally control a voltage is by pulse-width modulation and a low-pass filter. Basically, a high-frequency PWM waveform gets smoothened by the capacitor in the low-pass filter. Then, the duty cycle of the PWM waveform is varied to control the voltage. The output voltage equals the integral of the PWM voltage (3.3V for the Due) over one PWM period. Hence, varying the duty cycle between 0% and 100% will yield an output voltage varying linearly between 0V and 3.3V. The website [1] nicely explains the concept in easy words.

A small rippling may remain in the output voltage depending on the design of the low-pass filter. For this, the capacitor is first chosen according to the current load that the voltage line needs to drive. Then, the resistor value determines the low-pass filter's properties, such as cutoff frequency, ripple voltage, and settling time. The applet [2] allows to compute output voltage, ripple voltage, and settling time for a duty cycle step change if given a PWM frequency and the resistor and capacitor values of the low-pass filter.

References

[1] http://provideyourown.com/2011/analogwrite-convert-pwm-to-voltage/
[2] http://sim.okawa-denshi.jp/en/PWMtool.php

No comments:

Post a Comment