PDA

View Full Version : PCP + Pi Zero W Analog Audio Out



S3cret
2018-08-16, 12:43
Hi, i am using PCP 4 Beta 7 and I used this tutorial (http://shallowsky.com/blog/hardware/pi-zero-audio.html) to build a small circuit to power an active speaker of mine.
Only problem: I do not hear a thing. In the squeezelite settings I set analog audio as output, I edited the /boot/config.txt and inserted the line

dtoverlay=pwm-2chan,pin=18,func=2,pin2=13,func2=4
The circuit is one channel only and connected to gpio 18. I verified several times that the circuit is correct and all the connections are correct. Is there something else that has to be considered using PCP?

Second question: Since I only power one speaker, how can I configure PCP to output mono sound?

Thanks in advance

kidstypike
2018-08-16, 13:15
Hi, i am using PCP 4 Beta 7 and I used this tutorial (http://shallowsky.com/blog/hardware/pi-zero-audio.html) to build a small circuit to power an active speaker of mine.
Only problem: I do not hear a thing. In the squeezelite settings I set analog audio as output, I edited the /boot/config.txt and inserted the line

dtoverlay=pwm-2chan,pin=18,func=2,pin2=13,func2=4
The circuit is one channel only and connected to gpio 18. I verified several times that the circuit is correct and all the connections are correct. Is there something else that has to be considered using PCP?

Second question: Since I only power one speaker, how can I configure PCP to output mono sound?

Thanks in advance

Mono sound. Select the "beta" tab at the bottom of the pCP web gui (heed the warning). On the main page, click the "Extras" button, then "Asound".

25469

S3cret
2018-08-16, 23:38
This was easier than thought, thanks.

So remaining is only the problem with no sound at all. I will attach my speaker directly to the GPIO later today to make sure that it is not my circuit that is fault.

However, is there something in PCP that needs to be changed additionally to the one line in the config.txt?

paul-
2018-08-17, 03:42
The best way to make sure pCP knows what is going on is to create a new card definition in

/usr/local/etc/pcp/cards

There is a README file there to explain, and look at some of the card configs too.

S3cret
2018-08-17, 22:52
Ok, for testing I now switched to PCP 3.5. I did some tests with Raspbian and audio immediately worked after adding the line in config.txt. So it is definitely the software.

I tried creating a new card definition but even though I set the correct rights my new file disappears at every reboot. Also when I do changes to one of the existing files, they will be lost at reboot.

And what was confusing: In the README it says "The location of the dtoverlay files is mnt/mmcblk0p1/overlays."
But the overlays folder does not exist.

Greg Erskine
2018-08-17, 23:58
hi S3cret,

I'll let you in on a secret, piCorePlayer is mainly loaded into RAM. On every reboot, the Linux system gets rebuilt. You need to do a backup to save your files (ie. $pcp bu, but you may need to know about filetool.lst). Also, the first partition gets unmounted after a reboot so you need to mount it (ie. $m1).

These How To's might give you some basic tips:

https://www.picoreplayer.org/main_howto.shtml

Tiny Core/piCore is not like normal Linux distributions.

regards
Greg

S3cret
2018-08-18, 02:09
Hi Greg,
thanks for your explanation.

As far as I know, the only real difference between the Zero and other PI's with audio out is the missing high/low pass filters and the audio jack. So my approach was to use the standard Analog.conf and modify it to use the pwm-2chan overlay:

[COMMON]
CARD="ALSA"
OUTPUT="hw:CARD=ALSA"
ALSA_PARAMS="80:::1"
SSET="PCM"
GENERIC_CARD="ONBOARD"
DTOVERLAY="pwm-2chan"
CONTROL_PAGE="soundcard_control.cgi"
LISTNAME="Analog audio Pi Zero"
PARAMS1="pwm-2chan,pin=18,func=2,pin2=13,func2=4"
SHAIRPORT_OUT="hw:CARD=ALSA"
SHAIRPORT_CONTROL=""
RPI_MODEL="HAT_ALL_NO_HAT"

I played a little with the params for dtoverlay but I had no success. Unfortunately, due to my restricted available time, I am not really in the mood for hours and hours of investigation and searching for what is wrong in the setup.
So unless someone knows whats wrong or has a good idea, I am thinking about buying an already supported DAC.

sbp
2018-08-18, 03:42
Hi Greg,
thanks for your explanation.

As far as I know, the only real difference between the Zero and other PI's with audio out is the missing high/low pass filters and the audio jack. So my approach was to use the standard Analog.conf and modify it to use the pwm-2chan overlay:

[COMMON]
CARD="ALSA"
OUTPUT="hw:CARD=ALSA"
ALSA_PARAMS="80:::1"
SSET="PCM"
GENERIC_CARD="ONBOARD"
DTOVERLAY="pwm-2chan"
CONTROL_PAGE="soundcard_control.cgi"
LISTNAME="Analog audio Pi Zero"
PARAMS1="pwm-2chan,pin=18,func=2,pin2=13,func2=4"
SHAIRPORT_OUT="hw:CARD=ALSA"
SHAIRPORT_CONTROL=""
RPI_MODEL="HAT_ALL_NO_HAT"

I played a little with the params for dtoverlay but I had no success. Unfortunately, due to my restricted available time, I am not really in the mood for hours and hours of investigation and searching for what is wrong in the setup.
So unless someone knows whats wrong or has a good idea, I am thinking about buying an already supported DAC.

I don't have your setup, but the PARAMS1 seems wrong. I would think that you should remove the Pwm-2chan from here, as this is already set in the DTOVERLAY variable.

S3cret
2018-08-18, 03:45
Oops, I used the wrong file to put here.

PARAMS1="pin=18,func=2,pin2=13,func2=4"

This is the line I tried mainly.

paul-
2018-08-18, 07:06
Just put the whole string on the overlay line.

DTOVERLAY="pwm-2chan,pin=18,func=2,pin2=13,func2=4" and yes after making any changes to your card.conf, you need to run "pcp bu" to save the changes.

After changing the card definition, you will need to change to a different card and back.

But if all you are trying to do is get audio on your Zero, there a bunch of low cost Dacs that will go on a zero that are going to sound way better than this.

S3cret
2018-08-18, 09:13
So this is what I did with a just installed PCP 3.5 (just wifi added through newconfig file) in SSH:


tc@piCorePlayer:~$ cd /usr/local/etc/pcp/cards
tc@piCorePlayer:/usr/local/etc/pcp/cards$ cp Analog.conf AnalogZero.conf
tc@piCorePlayer:/usr/local/etc/pcp/cards$ sudo chown root AnalogZero.conf
*now has group staff and root as owner just like other card configs
tc@piCorePlayer:/usr/local/etc/pcp/cards$ sudo chmod 664 AnalogZero.conf
tc@piCorePlayer:/usr/local/etc/pcp/cards$ sudo vi AnalogZero.conf
*now Added the line DTOVERLAY="pwm-2chan,pin=18,func=2,pin2=13,func2=4" and changed the listname to "Analog audio Pi Zero", see full file below
tc@piCorePlayer:/usr/local/etc/pcp/cards$ pcp bu
[ INFO ] Backing up files to /mnt/mmcblk0p2/tce/mydata.tgz\
Done.
[ OK ] Backup successful.
tc@piCorePlayer:/usr/local/etc/pcp/cards$ pcp rb

AnalogZero.conf:

[COMMON]
CARD="ALSA"
OUTPUT="hw:CARD=ALSA"
ALSA_PARAMS="80:::1"
SSET="PCM"
GENERIC_CARD="ONBOARD"
DTOVERLAY="pwm-2chan,pin=18,func=2,pin2=13,func2=4"
CONTROL_PAGE="soundcard_control.cgi"
LISTNAME="Analog audio Pi Zero"
SHAIRPORT_OUT="hw:CARD=ALSA"
SHAIRPORT_CONTROL=""
RPI_MODEL="HAT_ALL_NO_HAT"

After Reboot switched to the web interface and selected the new card and rebootet immediately.
Switching back to ssh:

tc@piCorePlayer:~$ speaker-test -t wav -c 2

speaker-test 1.1.1

Playback device is default
Stream parameters are 48000Hz, S16_LE, 2 channels
WAV file(s)
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 256 to 32768
Period size range from 256 to 32768
Using max buffer size 32768
Periods = 4
was set period_size = 8192
was set buffer_size = 32768
0 - Front Left
1 - Front Right
.
.
.
But no sound, then installed LMS, played a radio, but obviously no sound as well.

The reasons why I didn't go with a supported DAC so far:
- I always like to safe money :D
- I love to build and create
- I am not audiophile

Any other ideas for a solution?
Thanks for all your help so far!

bpa
2018-08-18, 10:47
Purely as an observer - no handson experience of thiss issue and maybe you have already tried below suggestion.
In another thread somebody else seems to havce the same problem - the following post (#17) seems to indicate a solution
https://forums.slimdevices.com/showthread.php?107901-questions-for-a-most-basic-portable-squeezebox-using-PiCorePlayer-and-Pi-Zero-W&p=893315&viewfull=1#post893315

S3cret
2018-08-18, 11:54
Purely as an observer - no handson experience of thiss issue and maybe you have already tried below suggestion.
In another thread somebody else seems to havce the same problem - the following post (#17) seems to indicate a solution
https://forums.slimdevices.com/showthread.php?107901-questions-for-a-most-basic-portable-squeezebox-using-PiCorePlayer-and-Pi-Zero-W&p=893315&viewfull=1#post893315

Oh wow, how did you find that. Or did you still have that in mind after the whole year?
What can I say, it works!

So the solution is the following:

None of the above that I mentioned is necessary, just stick to the Analog audio and add the following lines under Tweaks -> User commands
gpio -g mode 18 ALT5
gpio -g mode 13 ALT0

reboot, done.

In case you set it to GPIO pins 13 and 18. More info in the link posted by bpa.

Thanks alot for all help. The audio is alright for the beginning. Although, as you mentioned, I can hear a difference to when I connect the same boxes (Swissonic ASM 7) to my PC with a better audio card.

paul-
2018-08-18, 12:15
I wonder what happens if you follow the pin assignments described in the overlay

https://github.com/raspberrypi/linux/blob/rpi-4.14.y/arch/arm/boot/dts/overlays/README#L1465

Likely the issue is that i2s audito interface is on by default, and that uses bcm pin 18.

bpa
2018-08-18, 12:24
Oh wow, how did you find that. Or did you still have that in mind after the whole year?

I had a vague memory of a user with a zero using the pwm method for audio on PCP so I did a google search of the forum with keywords of your problem and it turned up the thread/post

site:forums.slimdevices.com dtoverlay audio zero

S3cret
2018-08-18, 12:54
I wonder what happens if you follow the pin assignments described in the overlay

https://github.com/raspberrypi/linux/blob/rpi-4.14.y/arch/arm/boot/dts/overlays/README#L1465

Likely the issue is that i2s audito interface is on by default, and that uses bcm pin 18.

I just tried it. I set i2c, i2s and spi to off in the config.txt and tried my approach from post 11 but no sound. If you would like me to test it with other gpio pins as mentioned in your link, then let me know. I would gladly help you.



I had a vague memory of a user with a zero using the pwm method for audio on PCP so I did a google search of the forum with keywords of your problem and it turned up the thread/post

site:forums.slimdevices.com dtoverlay audio zero
Good job. I tried searching by using the forums search, but either I am not capable of finding stuff or the search isn't as good as googles. I think its a mix of both :D

paul-
2018-08-18, 13:03
I just tried it. I set i2c, i2s and spi to off in the config.txt and tried my approach from post 11 but no sound. If you would like me to test it with other gpio pins as mentioned in your link, then let me know. I would gladly help you.



Good job. I tried searching by using the forums search, but either I am not capable of finding stuff or the search isn't as good as googles. I think its a mix of both :D

It's up to you if you want to play. Your option should work just fine. And by using a card config, it should mostly be held through updates.

bpa
2018-08-18, 13:26
I tried searching by using the forums search, but either I am not capable of finding stuff or the search isn't as good as googles. I think its a mix of both :D
Forums search is not good, I no longer use it - using google with "site" and then pick 3 maybe 4 keywords carefully - in your case "zero" rather than "pi" or "raspberry" and then also dtoverlay as I guessed that was the key problem/identification area. "Audio" eliminates the post about using GPIO for other uses such as power or swtiches.