PWM Audio Guide

Various user-contributed guides for hardware-related things
User avatar
Spruc3Moose
Posts: 34
Joined: Thu May 05, 2016 4:00 am
Location: Maryland
Has thanked: 2 times
Been thanked: 5 times

Re: PWM Audio Guide

Post by Spruc3Moose » Fri Jun 10, 2016 11:13 am

So I built my filter today, but not sure if it is hooked up right. I just thought I would post it here for some feedback. I have not hooked it up the pi zero yet because I am not sure which wires go where. I have the two wires from the amp (from the guide) ready to go, but not sure which ground to use going into the filter and out. Also not sure where the pot wheel goes in this setup. Any help would be great...or I will just wait until the next guide.

Image
Image
Screen Shot 2016-06-10 at 1.05.21 PM.png
Screen Shot 2016-06-10 at 1.05.21 PM.png (44.98 KiB) Viewed 4686 times

User avatar
Kharmeleon
Posts: 21
Joined: Thu May 05, 2016 12:05 pm
Location: Germany
Has thanked: 1 time
Been thanked: 1 time

Re: PWM Audio Guide

Post by Kharmeleon » Sat Jun 18, 2016 3:25 am

Sorry for the question but why is it necessary to use that low pass filter? Would it be necessary to use it at the audio jack output of a raspberry pi 3? Thanks for any statement about that in advance. Greets

User avatar
Kilren
Posts: 574
Joined: Wed May 11, 2016 4:40 pm
Location: Washington, USA
Has thanked: 35 times
Been thanked: 84 times

Re: PWM Audio Guide

Post by Kilren » Sat Jun 18, 2016 3:08 pm

Kharmeleon wrote:Sorry for the question but why is it necessary to use that low pass filter? Would it be necessary to use it at the audio jack output of a raspberry pi 3? Thanks for any statement about that in advance. Greets
This is for the raspberry pi zero because it does not have audio out naturally. You have two choices to get audio out on RPi0: by PWM low-filter, or by usb-dac.

You don't need this if you're using RPi2/3

User avatar
Kharmeleon
Posts: 21
Joined: Thu May 05, 2016 12:05 pm
Location: Germany
Has thanked: 1 time
Been thanked: 1 time

Re: PWM Audio Guide

Post by Kharmeleon » Sat Jun 18, 2016 3:17 pm

Kilren wrote:
Kharmeleon wrote:Sorry for the question but why is it necessary to use that low pass filter? Would it be necessary to use it at the audio jack output of a raspberry pi 3? Thanks for any statement about that in advance. Greets
This is for the raspberry pi zero because it does not have audio out naturally. You have two choices to get audio out on RPi0: by PWM low-filter, or by usb-dac.

You don't need this if you're using RPi2/3
Thank you for the answer mate!

User avatar
Ganreizu
Posts: 552
Joined: Thu May 05, 2016 8:20 am
Has thanked: 168 times
Been thanked: 97 times

Re: PWM Audio Guide

Post by Ganreizu » Fri Jun 24, 2016 7:44 am

So say i'm doing mono sound, is this the code i would use?

Code: Select all

dtoverlay=pwm-1chan,pin=18,func=2
(for left channel?)

vs

Code: Select all

dtoverlay=pwm-2chan,pin=18,func=2,pin2=13,func2=4

User avatar
tronicgr
Posts: 138
Joined: Tue Jun 07, 2016 4:26 pm
Has thanked: 94 times
Been thanked: 66 times
Contact:

Re: PWM Audio Guide

Post by tronicgr » Fri Jun 24, 2016 8:00 am

Kilren wrote:
Kharmeleon wrote:Sorry for the question but why is it necessary to use that low pass filter? Would it be necessary to use it at the audio jack output of a raspberry pi 3? Thanks for any statement about that in advance. Greets
This is for the raspberry pi zero because it does not have audio out naturally. You have two choices to get audio out on RPi0: by PWM low-filter, or by usb-dac.

You don't need this if you're using RPi2/3
Actually there is a third option for sound on raspberry pi zero, I2S sound!
https://forums.adafruit.com/viewtopic.php?f=50&t=97961

Thanks
Thanos

SP33
Posts: 25
Joined: Tue May 17, 2016 5:41 pm
Has thanked: 3 times
Been thanked: 23 times

Re: PWM Audio Guide

Post by SP33 » Fri Jun 24, 2016 6:26 pm

Ganreizu wrote:So say i'm doing mono sound, is this the code i would use?

Code: Select all

dtoverlay=pwm-1chan,pin=18,func=2
(for left channel?)

vs

Code: Select all

dtoverlay=pwm-2chan,pin=18,func=2,pin2=13,func2=4
I have not tried mono sound myself yet but from my own tests, pin 18 was outputting in the right channel so I believe pin2 and func2 would be for left channel (pin 13)
so either try

Code: Select all

dtoverlay=pwm-1chan,pin2=13,func2=4
or

Code: Select all

dtoverlay=pwm-2chan,pin2=13,func2=4
(I'm unsure if pwm-1chan is valid)
or you could just use the original code and not use pin 18, only hook up pin 13 (left channel) just to be sure.

User avatar
joe7dust
Posts: 218
Joined: Mon Jun 06, 2016 4:13 am
Has thanked: 23 times
Been thanked: 7 times

Re: PWM Audio Guide

Post by joe7dust » Sat Jun 25, 2016 4:25 am

SP33 wrote:
Ganreizu wrote:So say i'm doing mono sound, is this the code i would use?

Code: Select all

dtoverlay=pwm-1chan,pin=18,func=2
(for left channel?)

vs

Code: Select all

dtoverlay=pwm-2chan,pin=18,func=2,pin2=13,func2=4
I have not tried mono sound myself yet but from my own tests, pin 18 was outputting in the right channel so I believe pin2 and func2 would be for left channel (pin 13)
so either try

Code: Select all

dtoverlay=pwm-1chan,pin2=13,func2=4
or

Code: Select all

dtoverlay=pwm-2chan,pin2=13,func2=4
(I'm unsure if pwm-1chan is valid)
or you could just use the original code and not use pin 18, only hook up pin 13 (left channel) just to be sure.
Where do we put our speaker's ground? I'm not using to a channel only having 1 wire, it is usually 2.

SP33
Posts: 25
Joined: Tue May 17, 2016 5:41 pm
Has thanked: 3 times
Been thanked: 23 times

Re: PWM Audio Guide

Post by SP33 » Sat Jun 25, 2016 5:53 am

@joe7dust Just use the same ground you used for the audio filter you just made, you can solder a wire where you attached the ground and to your audio plug.

User avatar
joe7dust
Posts: 218
Joined: Mon Jun 06, 2016 4:13 am
Has thanked: 23 times
Been thanked: 7 times

Re: PWM Audio Guide

Post by joe7dust » Sat Jun 25, 2016 6:43 am

SP33 wrote:@joe7dust Just use the same ground you used for the audio filter you just made, you can solder a wire where you attached the ground and to your audio plug.

I did that but it's not working. -_- http://imgur.com/f2L1mkn

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest