http://analogtalk.com/?p=534

http://analogtalk.com/?p=551

Posted by AnalogAdvocate on April 09, 2010 
DesignGeneral

In today’s highly competitive electronics environment, designers are constantly looking for ways to reduce overall system costs.  One of the most commonly asked questions that analog specialists at digital microcontroller (MCU) companies hear from customers is, is the almost cost-free Pulse-Width-Modulation (PWM) Digital-to-Analog Converter (DAC) good enough for my application, or do I need a higher-performance, standalone DAC instead?”

The generation of an analog voltage using a digital Pulse-Width-Modulated signal is known as a PWM DAC.  As most designers’ PCB boards have a microcontroller with a built-in PWM-output feature onboard, a simple digital-to-analog data conversion can be easily realized by adding a few passive components at the MCU’s PWM-output pin.  This is an alternative to using a standalone DAC.  In the MCU application environment, system designers can have DAC functionality nearly free of charge.  PWM DACs are widely used in very low-cost applications, where accuracy is not a primary concern.   Standalone DACs, however, are used for applications requiring higher accuracy.

Although the PWM DAC can be realized with the simple addition of a few passive components, implementing a PWM DAC for system applications is not a simple task.  There are many limitations associated with this. Understanding the complexities of using the PWM DAC and its effects can save significant development time and effort.   This article presents a technique for converting a PWM pulse to an analog voltage using a simple, RC low-pass filter. This entry also reviews the PWM DAC’s limitations and its key design constraints on resolution, frequency, ripple, settling time and current consumption are discussed, which are very important design parameters that are largely affected by the R and C values, as well as the PWM duty cycle and frequency.

Standalone DACs

Figure 1 shows an example of a standalone DAC.  Its analog output voltage is given by:

Where Dn is the digital code.  For example, with a 12-bit DAC, the user can get Vout = 2.5V with Vref = 5V and Dn = 1000-0000-0000.  Typical standalone DAC devices provide good linearity and a short settling time, which is the time required to update each output voltage.

Figure 1 Configuration of Standalone DAC

How PWM DACs Work

Figure 2 shows a basic configuration of the PWM DAC. The MCU outputs a PWM signal to an RC low pass-filter. The PWM pulse train’s digital value becomes an analog voltage, when it passes through the RC filter.  At a given period of time, the analog output is proportional to the PWM pulse’s high durations.

Figure 2 Block Diagram of a PWM DAC

A PWM signal is defined as a digital signal with a fixed frequency, but a varying duty cycle.  Figure 3 illustrates a PWM signal.  The PWM period (T) is the time interval required to complete one full PWM cycle.  The duty cycle is the ratio of the high duration (t) to the total period (T).

Figure 3 PWM Signal

The PWM signal and RC-filter circuit parameters affect the analog output’s resolution, amplitude, settling time and ripple.  The PWM DAC’s limitations are clearly demonstrated by analyzing the interaction of the PWM parameters and the RC filter.  A better understanding of the relationship between these parameters enables designers to optimize the PWM to best suit their application’s requirements, while minimizing design time.

PWM DAC Bit Resolution

The PWM counter length (L) and the smallest duty-cycle change in the PWM counter (C) determine the PWM DAC’s bit resolution.  The following equation expresses the maximum bit resolution of the PWM DAC:

For example, if the system generates an analog output voltage from a PWM DAC with a counter of 4096 (L) and a minimum count step of one (C), the PWM DAC’s bit resolution is 12-bits.

When the PWM resolution is determined, it is possible to calculate the Least Significant Bit (LSB) size.  The LSB size is dependant upon the PWM resolution and the PWM’s output-high level voltage (VOH), and can be calculated using the following equation.

For example, a 12-bit PWM DAC with a VOH of 5V has an LSB size of 1.2mV.

RC Filter Design Considerations for PWM DAC

One key design consideration when determining the PWM’s resolution is output-voltage ripple. Ripple occurs due to overshoot and undershoot as the PWM charges and discharges the RC circuit. One way to approximate the charge characteristics is to modify the equations to charge and discharge an RC-filter circuit. As the effects of this are cumulative, the following equations can be used as approximations.

(4)(5)(6)

VLH is the voltage increase for a specific PWM period, and VHL is the voltage decrease for a specific PWM period. The values of VLH and VHL are dependant upon not only the RC filter values, but also upon the PWM frequency and duty cycle. The PWM frequency and duty cycle determine the time available for the PWM to charge (tcharge) and discharge (tdischarge) the capacitor. Vripple is the difference between VLH and VHL for the same PWM period.

Figure 4 illustrates the magnitude of the voltage ripple across the output capacitor vs. time. The vertical axis displays the magnitude of the ripple voltage, while the horizontal axis provides the corresponding time. The plot shows how the ripple voltage settles at approximately 125 mV in a time interval of approximately 40 ms for R = 10K ohms, and 250 mV at 20 ms for R = 1 K ohm. In the previous example, an LSB size of less than 1.2mV for a 12-bit system was needed. This ripple is greater than 100 LSB for 12-bit DAC with a 5V reference, meaning that the resulting PWM DAC solution has an effective resolution of less than 6 bits due to the ripples.

Figure 4: Voltage Ripple Comparison for VOH = 5V, C = 1μF, PWM frequency = 1 kHz, Duty Cycle = 50%

The ripple can be reduced by increasing the capacitor and the resistor values or increasing the PWM frequency. All of these will decrease the ripple’s magnitude.

As shown in Figure 4, the ripple decreases as the resistance value increases. However, nothing comes without a price-the settling time doubles as the ripple decreases by 50 %.

For applications that require faster settling time (increased bandwidth) and higher resolution, one could add a second RC filter. The obvious tradeoffs include the cost of additional components and the increased board space occupied. Figure 5 shows a model for a two-pole RC low-pass filter. Figure 6 shows the analog output voltage of this model.

Figure 5: PSPICE Model for Two-Pole RC Low-Pass Filter

Figure 6: Analog Voltage Output vs. Settling Time of the Two Pole RC Low-Pass Filtere

There are a couple of things to keep in mind when designing the filter. First, make sure that the pole of the RC is set at a much greater frequency than that of the signal being generated. Secondly, if you are designing a two-pole filter, make sure that R2 > R1.

The 3dB corner frequency of the RC filter is given by:

(7)

There are a couple of additional things to consider. Increasing the PWM frequency will also decrease the ripple, but the tradeoff is increased settling time. Figure 7 shows the cases for 10 kHz and 5 kHz

Figure 7: Voltage Ripple at the PWM DAC when PWM Frequency Changes. Where VOH = 5V, C = 1μF, R = 10 kΩ, Duty Cycle = 50 %, PWM Frequency = 10 kHz and 5 kHz

The worst-case ripple occurs at a 50% duty cycle. The ripple will decrease as the duty cycle moves closer to 0% or 100%. Figure 8 shows the peak-to-peak magnitude of ripples on the PWM DAC output. The ripple decreases almost two times as the duty cycle changes from 50 % to 85 %.

Figure 8: Voltage Ripple at the PWM DAC when PWM Duty Cycle Changes. VOH = 5V, C = 10 μF, R = 1 kΩ, PWM Frequency = 1 kHz, Duty Cycle = 50 % (Solid Curve) and 85 % (Dotted Curve)

PWM DACs and Power Consumption

Many electronic products today are portable or handheld devices. These devices are battery powered, and many have strict constraints with regard to power consumption. Therefore, it is a good idea to minimize the PWM DAC’s power consumption. The current consumed in the PWM solution is simple to approximate, using the following equation:

(8)

Figure 9: Current and Voltage Plots of PWM DAC with R =1000 Ω, C = 10μF, Duty Cycle = 50 %, VOH = 5V

Figure 9 shows the current and voltage plots. As sown in the plot, the PWM DAC with a lower resistor draws a significant amount of current (in the range of a few mA). This high level of current consumption is unacceptable for many battery-powered applications. Current can be decreased by increasing the resistor value.

In Figure 10, the resistor value has been increased by a factor of ten, which has likewise decreased the current consumption by a factor of ten.

Figure 10:  Current and Voltage Plots of PWM DAC with R =10,000 Ω, C = 10μF, Duty Cycle = 50 %, VOH = 5V

As the resistor limits the current available to charge/discharge the capacitor, decreasing the amount of current available (increasing resistance) to the circuit will increase the settling time.

Another factor to consider is the filter’s pole. As the resistor value increases, the 3 dB frequency decreases by the same magnitude. This can be compensated for by reducing the capacitor value by the same magnitude, which offsets the increased settling time and maintains the original pole of the filter. Figure 11 demonstrates this. Note that, as the capacitor value reduces, the circuit becomes more susceptible to loading. This is another important design consideration.

Figure 11: Current and Voltage Plots of PWM DAC with R =10,000 Ω, C = 1μF, Duty Cycle = 50 %, VOH = 5Vircuit

PWM DAC vs. Standalone的更多相关文章

  1. 【STM32】PWM DAC基本原理(实验:PWM实现DAC)

    虽然STM32F103ZET6具有内部DAC,但是也仅仅只有两条DAC通道,并且STM32还有其他的很多型号是没有DAC的.通常情况下,采用专用的D/A芯片来实现,但是这样就会带来成本的增加. 不过S ...

  2. PWM DAC Low Pass Filtering

    [TI博客大赛][原创]LM3S811之基于PWM的DAC http://bbs.ednchina.com/BLOG_ARTICLE_3005301.HTM http://www.fpga4fun.c ...

  3. How determine the RC time constant in PWM DAC low-pass filter?

    how determine the RC time constant in PWM digital to analog low-pass filter? I 'm looking for the be ...

  4. MCU PWM DAC OP Voltage Output

  5. Make a DAC with a microcontroller's PWM timer

    http://www.edn.com/design/analog/4337128/Make-a-DAC-with-a-microcontroller-s-PWM-timer Many embedded ...

  6. how to generate an analog output from a in-built pwm of Atmega 32AVR microcontrloller?

    how to generate an analog output from a in-built pwm of Atmega 32AVR microcontrloller? you need a re ...

  7. PEM DAC note

    开发指南V1.0库函数版本,PWM DAC实验 350页 STM32 的定时器最快的计数频率是72Mhz,8 为分辨率的时候,PWM 频率为72M/256=281.25Khz.如果是1阶RC滤波,则要 ...

  8. 说说M451例程之PWM

    /**************************************************************************//** * @file main.c * @ve ...

  9. DIY FSK RFID Reader

    This page describes the construction of an RFID reader using only an Arduino (Nano 3.0 was tested, b ...

随机推荐

  1. 【鬼脸原创】JQuery获取元素的方法总结

    目录 一.说明 二.获取本身 三.获取同级元素 四.获取父级元素 五.获取子级元素 一.说明   获取元素的方法分为两种:jQuery选择器.jQuery遍历函数. 做个总结,巩固下知识. 二.获取本 ...

  2. No.14 selenium for python table表单

    table表单,HTML中的特征 标识性标签:table.tr.th.td 定位使用Xpath定位 点击表格中的元素即可

  3. 用命令对sql进行备份

    利用T-SQL语句,实现数据库的备份与还原的功能 体现了SQL Server中的四个知识点: 1. 获取SQL Server服务器上的默认目录 2. 备份SQL语句的使用 3. 恢复SQL语句的使用, ...

  4. SQL之PROCEDURE(存储过程)

    先来看一小段代码 create procedure pr_bank(@bank_id int) as BEGIN select *from bank where bank_ID = @bank_id ...

  5. 一步一步学习IdentityServer3 (15) 授权模式那些事

    总结一句话,其实很简单 在什么Clients 拿的认证权限Scope 就去 去开什么Scope限制的服务接口门 在写Clients的时候,会有Scope,看下面的代码 new Client { Cli ...

  6. Azkaban(一)Azkaban的基础介绍

    一.为什么需要工作流调度器 1.一个完整的数据分析系统通常都是由大量任务单元组成: shell 脚本程序,java 程序,mapreduce 程序.hive 脚本等 2.各任务单元之间存在时间先后及前 ...

  7. 【转】 LINUX中IPTABLES和TC对端口的带宽限制 端口限速

    不管是iptables还是tc(traffic control)功能都很强大,都是与网络相关的工具,那么我们就利用这两个工具来对端口进行带宽的限制. 1.使用命令ifconfig查看服务器上的网卡信息 ...

  8. PHP 数组的添加和读取

    在实际的开发中,会经常使用数组的添加和读取.这里把经常使用的操作记下来,以备以后查阅. <?php //一维数值数组 $list = array('wang','god'); $list[] = ...

  9. Spring 单例 httprequest 线程安全

    @Autowired HttpServletRequest之所以线程安全是因为, httpsevletRequest 储存在 RequestContextHolder中. 每次http请求的doXXX ...

  10. MySQL 关于索引那点事

    索引 其实数据库中的数据是按页存放的其实索引也是按页存放的所以本质上索引也占硬盘空间(以最小的消耗,换取最大的利益) 索引是一种有效组合数据的方式!为快速查找到指定记录做铺垫 目的就是快速或者某个记录 ...