PWM vs DAC Output: Creating Analog Voltages With Microcontrollers

Microcontrollers usually produce digital outputs: a pin is either LOW or HIGH. But many projects need something that behaves like an analog voltage. Two common ways to do this are PWM and DAC output.

PWM is a fast digital switching signal that can be filtered or interpreted as a variable power level. A DAC produces a real analog voltage directly. Both methods are useful, but they are not the same. This article compares PWM and DAC output from a practical Arduino-compatible project point of view.

The Basic Difference

PWM and DAC output are often used for similar-looking tasks, but the signal type is different.

  • PWM: digital output that switches between LOW and HIGH with a variable duty cycle
  • DAC: analog output that produces a voltage level between minimum and maximum

PWM is excellent for controlling power. DAC output is better when another circuit needs a real analog voltage signal.

PWM: Fast Digital Switching

PWM stands for pulse-width modulation. The microcontroller switches the output pin on and off quickly. The duty cycle determines how much of the time the signal is HIGH.

  • 0% duty cycle means always LOW
  • 50% duty cycle means HIGH half the time
  • 100% duty cycle means always HIGH

Many loads respond to the average effect of PWM. LEDs appear dimmer or brighter. Motors receive more or less effective power. A filtered PWM signal can also approximate an analog voltage.

DAC: Real Analog Voltage Output

A DAC, or digital-to-analog converter, converts a digital number into an analog voltage. Instead of switching rapidly between LOW and HIGH, the output sits at a voltage level.

  • Useful for analog setpoints
  • Useful for reference voltages
  • Useful for sensor simulation
  • Useful for control voltages
  • Useful when ripple from PWM would be a problem

DAC output can come from a microcontroller with a built-in DAC or from an external DAC module such as MCP4725 or MCP4728.

Main Comparison Table

Feature PWM Output DAC Output
Signal type Digital pulses Analog voltage level
Typical microcontroller support Very common Only on some microcontrollers, or external DAC module required
Best for LED dimming, motor speed control, heaters, power control Analog references, setpoints, control voltages and sensor simulation
Needs filtering for smooth voltage? Yes, if a true analog voltage is required Usually no simple PWM filter required
Ripple Can have ripple after filtering Usually smoother for slow analog control
Efficiency for power loads Very good with suitable driver Not normally used directly for power loads
Hardware cost Usually no extra chip needed May require external DAC module
Main limitation Not a true analog voltage unless filtered Signal output only; limited current and voltage range

Duty Cycle vs Voltage Level

PWM does not directly change the output voltage. A 5V PWM pin still switches between 0V and 5V. What changes is the percentage of time the signal is HIGH.

  • 25% PWM on a 5V pin switches between 0V and 5V, HIGH for 25% of the time
  • 50% PWM switches between 0V and 5V, HIGH for 50% of the time
  • 75% PWM switches between 0V and 5V, HIGH for 75% of the time

A DAC is different. If set to 2.5V, the output actually sits near 2.5V instead of rapidly switching between 0V and 5V.

PWM for LED Brightness

PWM is excellent for LED dimming. The LED is switched on and off quickly enough that the eye sees an average brightness.

  • Efficient
  • Simple to implement
  • Works well with LED drivers and MOSFETs
  • Does not require a DAC
  • Brightness can be controlled in software

For normal LED dimming, PWM is usually better than a DAC. The DAC would still need a driver circuit for higher LED current.

PWM for Motor Speed Control

PWM is also widely used for DC motor speed control. The motor receives pulses of power, and its mechanical inertia smooths the effect.

  • Efficient with a MOSFET or motor driver
  • Good for speed control
  • Works with many motor driver modules
  • Can also be used for fans, pumps and heaters

A DAC output alone should not be used to power a motor. It can provide a control voltage to a motor controller, but not drive the motor directly.

Filtering PWM Into an Analog Voltage

PWM can be converted into a smoother analog-like voltage by using a low-pass filter, often a resistor and capacitor.

  • The filter averages the PWM pulses
  • Higher PWM frequency makes filtering easier
  • More filtering reduces ripple but slows response
  • The filtered signal may need a buffer op-amp
  • Load current can disturb the filtered voltage

This can work well for simple analog control, but it is not as clean or predictable as a real DAC in many measurement or setpoint applications.

Filter Tradeoff: Ripple vs Response Speed

A PWM filter has a tradeoff. Strong filtering reduces ripple, but it also makes the output respond more slowly when the duty cycle changes.

Filter Choice Advantage Limitation
Light filtering Fast response More ripple remains
Heavy filtering Smoother voltage Slower response to changes
Filtered and buffered output Better drive capability and more stable voltage Requires extra components

This is one reason why a DAC is often preferred when a clean analog control voltage is required.

DAC for Analog Setpoints

A DAC is useful when another circuit expects a voltage level as a command or setpoint.

  • Programmable reference voltage
  • Power supply voltage setpoint
  • Current limit setpoint
  • Analog sensor simulation
  • Control input for an analog circuit

In these applications, PWM ripple may cause instability or measurement errors. A DAC output is usually cleaner and easier to design around.

DAC for Sensor Simulation

Sometimes a project needs to simulate an analog sensor output. A DAC is well suited for this because it can generate a controlled voltage.

  • Testing ADC inputs
  • Simulating a temperature sensor voltage
  • Generating a calibration voltage
  • Testing analog thresholds
  • Creating repeatable input conditions

A filtered PWM signal may also work for rough testing, but a DAC is usually more predictable.

Output Current and Buffering

Neither PWM pins nor DAC outputs should be treated as power outputs. A microcontroller pin has limited current capability, and DAC outputs are usually signal outputs with even more limited drive capability.

  • Use a MOSFET or driver for LEDs, motors and heaters
  • Use an op-amp buffer for DAC outputs that must drive a load
  • Do not connect heavy loads directly to DAC outputs
  • Check the microcontroller pin current limits for PWM outputs

The output method controls the signal. A driver stage provides the power.

Resolution

PWM resolution describes how many duty-cycle steps are available. DAC resolution describes how many voltage steps are available.

  • 8-bit PWM gives 256 duty-cycle steps
  • 10-bit PWM gives 1024 duty-cycle steps
  • 12-bit DAC gives 4096 voltage steps

Higher resolution can create finer control, but noise, filtering, reference voltage and output stage design still matter.

PWM Frequency

PWM frequency matters. Low PWM frequency can cause visible LED flicker, audible noise in motors or poor filtered analog output.

  • LED dimming should avoid visible flicker
  • Motor PWM can create audible whine if frequency is in the audible range
  • Filtered PWM works better when the PWM frequency is high enough
  • Changing PWM frequency can affect timers and libraries on some microcontrollers

For simple Arduino projects, default PWM settings may be fine. For polished products, PWM frequency deserves more attention.

Analog Accuracy

A DAC output is usually better for analog accuracy than filtered PWM, but it is not automatically perfect.

  • DAC reference or supply voltage affects output accuracy
  • Noise on the supply can appear at the output
  • Output loading can shift the voltage
  • Op-amp buffers may introduce their own errors
  • PCB layout and grounding still matter

A DAC makes analog output easier, but good analog design is still required.

When PWM Is the Better Choice

  • LED dimming
  • Motor speed control
  • Fan control
  • Heater control
  • Simple brightness or power adjustment
  • Projects where a driver already accepts PWM input

PWM is usually the best choice when the load naturally responds to average power.

When a DAC Is the Better Choice

  • Analog reference voltage
  • Control voltage for another circuit
  • Sensor output simulation
  • Analog setpoint generation
  • Calibration voltage
  • Applications where PWM ripple would cause problems

A DAC is usually the best choice when the receiving circuit expects a real analog voltage.

Choosing by Project Type

Project Type Better Choice Reason
LED dimmer PWM Efficient and simple with a suitable driver
DC motor control PWM Motor drivers commonly use PWM for speed control
Programmable voltage reference DAC A real analog voltage is preferred
Sensor simulator DAC DAC output is cleaner and more predictable
Simple analog-like output with low precision Filtered PWM Can work with only a resistor and capacitor
Multi-channel analog setpoints External DAC such as MCP4728 Several real analog outputs from one module

Common Mistakes

  • Assuming PWM is a lower analog voltage
  • Using PWM without filtering when a circuit expects DC voltage
  • Using a DAC output to drive a high-current load directly
  • Ignoring PWM frequency and visible flicker
  • Expecting a simple RC filter to give perfect analog output
  • Expecting a DAC to output beyond its supply voltage
  • Forgetting that analog outputs may need buffering

When to Use Something Else

Sometimes neither basic PWM nor a simple DAC module is the right answer.

  • Use an audio DAC or I2S audio output for sound
  • Use a dedicated motor driver for motors
  • Use a constant-current LED driver for precision LED control
  • Use an op-amp circuit when the output needs scaling, buffering or offset
  • Use isolation or protected outputs for industrial control signals

Conclusion

PWM and DAC outputs are both useful ways to control analog-like behavior, but they solve different problems.

  • Use PWM for efficient power control, LED dimming, motors, fans and heaters.
  • Use a DAC when the project needs a real analog voltage, such as a reference, setpoint or sensor simulation signal.
  • Use filtered PWM only when the required analog voltage does not need to be very clean or fast.

The practical question is simple: does the load respond to average power, or does the circuit need a clean voltage level? If it responds to power, PWM is usually best. If it needs a voltage signal, a DAC is usually the better choice.

Shopping Cart
Scroll to Top