Author Topic: PWM to DC control voltage?  (Read 4350 times)

0 Members and 1 Guest are viewing this topic.

Offline dentakuTopic starter

  • Frequent Contributor
  • **
  • Posts: 881
  • Country: ca
PWM to DC control voltage?
« on: June 15, 2013, 02:00:58 am »
I'm wondering if there's a simple basic way to take a PWM signal and convert the pulse length (I'm assuming that's what you call it) to DC voltages?
In other words, as I modulate the pulse width, the output of the circuit would be a DC voltage to goes up and down depending on the pulse length of the input.

This would be useful for creating crude Control Voltage messages from an audio signal coming from a soft-synth.
« Last Edit: June 15, 2013, 02:10:32 am by dentaku »
 

Online Psi

  • Super Contributor
  • ***
  • Posts: 10220
  • Country: nz
Re: PWM to DC control voltage?
« Reply #1 on: June 15, 2013, 02:18:28 am »
Yes, this is very common and sometimes called a PWM DAC.

The simpliest way is to put the i/o pin PWM signal through a lowpass filter (resistor and cap to ground)

eg


A good starting point might be using a 100Hz low pass filter and a pwm frequency at maybe 4khz.

The higher your low pass filter frequency is the faster your dc signal will respond to pwm changes.
However
The closer your low pass filter frequency gets to your PWM frequency to more ripple you will get on the DC output.


« Last Edit: June 15, 2013, 02:22:37 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline Jebnor

  • Regular Contributor
  • *
  • Posts: 170
  • Country: ca
  • Absolutely! Yes, kind of, sort of, not really, no.
Re: PWM to DC control voltage?
« Reply #2 on: June 15, 2013, 04:57:51 am »
A simple RC lowpass circuit as Psi suggests will work. A 2 or 3 stage could work too. That just means that you put 2 or 3 or more low pass RC filters back to back.

Although quite a read, there a couple people have a great discussion about this topic in this post about a precision power supply https://www.eevblog.com/forum/projects/general-purpose-power-supply-design-7488/. The PWM & filter discussion starts about page 5 or 6. (Yes there are 23 pages)
« Last Edit: June 15, 2013, 05:00:55 am by Jebnor »
Before this, there was a typo.
 

Offline dentakuTopic starter

  • Frequent Contributor
  • **
  • Posts: 881
  • Country: ca
Re: PWM to DC control voltage?
« Reply #3 on: June 26, 2013, 02:48:58 am »
I finally took the time to experiment with this tonight and I got some interesting results. I can filter out most of the highs with a simple low pass filter and get a smooth change in voltage while modulating the Pulsewidth of a software synth with an LFO but if I change the values of the resistor by using a pot instead I can get some fun harsh sounding stuff happening too. I'm using this to modulate the frequency of a 555 multivibrator through pin 5.
It's like a modular synth built from salvaged parts :)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf