Author Topic: Low pass a PWM?  (Read 3139 times)

0 Members and 1 Guest are viewing this topic.

nexekho

Low pass a PWM?
« on: September 01, 2011, 05:54:53 PM »
I've been looking into getting an Arduino Nano to experiment with some DSP ideas without the latency problems I have with using PortAudio on my desktop.  They have great analogue input features, but outputs are sorely lacking.  It's possible to hook up a DAC/resistor ladder, but each bit costs another digital IO pin and you only have 14 bits even if you leave nothing for control/etc.  I notice that some of the digital pins can pulse width modulate a square wave to approximate analogue outputs, often used with LEDs, etc. so if I included a low-pass filter, could this be used for an analogue output?

(I have several years' programming experience including a decent amount of work homebrewing for GBA + NDS)

Thanks.

EDIT: Could I use two pins, both low passed, one with a low volume, to get 16-bit out?
« Last Edit: September 01, 2011, 06:13:17 PM by nexekho »
I made the transistor angry.

potul

Re: Low pass a PWM?
« Reply #1 on: September 01, 2011, 06:32:25 PM »
You can use PWM for audio with some filtering, and yes, you can use 2 8 bit outputs to get 16 bits. Take a look at this project, it explains quite well how to get 16 bits resolution out of 2 8 bits pwm outputs:

(damn... the site seems to be down.... hunt for a project called TRAXMOD, it had a nice explanation on how to get those 16 bits combining 2 8 bits pwm outputs. Maybe you can use waybackmachine to get the page back)

potul

Re: Low pass a PWM?
« Reply #2 on: September 01, 2011, 06:34:09 PM »

.Mike

Re: Low pass a PWM?
« Reply #3 on: September 01, 2011, 06:44:53 PM »
See the datasheet for the VCLFO9D or the TAPLFO2. They both output PWM, and they both include example filters for smoothing the PWM, and swinging it +/-.

They do not, however, use the PWM for audio, just for LFOs.

Likewise, there is some filtering shown in my working draft of a tap tempo phaser that was working pretty good.

Mike
If you're not doing it for yourself, it's not DIY. ;)

My effects site: Just one more build... | My website: America's Debate.

nexekho

Re: Low pass a PWM?
« Reply #4 on: September 01, 2011, 06:46:01 PM »
Ah, thanks, I suspected as much.  I note that he uses straight-up resistors instead of resistor dividers; is there an advantage to this?
I made the transistor angry.

nexekho

Re: Low pass a PWM?
« Reply #5 on: September 01, 2011, 07:00:50 PM »
Found someone else had done the research and built something pretty decent:
http://www.instructables.com/id/Lo-fi-Arduino-Guitar-Pedal/step4/Normalize-the-Input-and-Output/
I made the transistor angry.

nexekho

Re: Low pass a PWM?
« Reply #6 on: September 15, 2011, 09:20:55 PM »
I have built the Arduino Nano DSP and though it's not very powerful in mono you can get some seriously decent effects.  My chorus:
http://soundcloud.com/nexekho/much-much-smoother
http://pastebin.com/2ed16VD0
(note: designed for above circuit)
I made the transistor angry.