Forum
[SOLVED] Pi Zero, PWM (analogue) output - Printable Version

+- Forum (http://forum.xbian.org)
+-- Forum: Hardware (/forum-7.html)
+--- Forum: Video and Audio (/forum-28.html)
+--- Thread: [SOLVED] Pi Zero, PWM (analogue) output (/thread-3895.html)



Pi Zero, PWM (analogue) output - TheDutypaid - 10th Apr, 2017 06:38 AM

Hello, I have just joined this forum, sorry for posting in here first but I can not start a new topic?

I have a question about using PWN audio with a Pi Zero.

Hoping I will be able to put this in the right part of the forum soon.


RE: I am a noob, please help me! - Nachteule - 10th Apr, 2017 07:03 AM

(10th Apr, 2017 06:38 AM)TheDutypaid Wrote:  Hello, I have just joined this forum, sorry for posting in here first but I can not start a new topic?

I have a question about using PWN audio with a Pi Zero.

What is PWN audio ???

And what is your question ???


RE: I am a noob, please help me! - TheDutypaid - 10th Apr, 2017 09:16 AM

Sorry 'PWM'

I am making a project where I am putting a Pi Zero into an old portable TV. Using XBian as I have found getting a composite signal from the other KODI's was tricky and this on has a nice big interface. the screen is very small.

The big problem I am having is the audio, I made the RC filter for the Zero and added "dtoverlay=pwm,pin=18,func=2" to the config file. But still no audio.

I have tested the sound is working on the TV, which is fine. Not sure if I screwed up the filter or it is a software problem.

I noted in the read me file,

"Name: audioinjector-wm8731-audio
Info: Configures the audioinjector.net audio add on soundcard
Load: dtoverlay=audioinjector-wm8731-audio
Params: <None>


Name: audremap
Info: Switches PWM sound output to pins 12 (Right) & 13 (Left)"

I think I understand you need to put some text into the config file, but I'm unsure what?


RE: I am a noob, please help me! - Nachteule - 10th Apr, 2017 11:09 PM

I do not have Pi Zero, so I do not have any practical experience with such device

(10th Apr, 2017 09:16 AM)TheDutypaid Wrote:  Sorry 'PWM'

I am making a project where I am putting a Pi Zero into an old portable TV. Using XBian as I have found getting a composite signal from the other KODI's was tricky and this on has a nice big interface. the screen is very small.

The big problem I am having is the audio, I made the RC filter for the Zero and added "dtoverlay=pwm,pin=18,func=2" to the config file. But still no audio.

I'm sure you know this article
But you forgot to assign second channel. However, I don't believe that this is the problem

Quote:I have tested the sound is working on the TV, which is fine. Not sure if I screwed up the filter or it is a software problem.

Test without filter

Quote:I noted in the read me file,

"Name: audioinjector-wm8731-audio
Info: Configures the audioinjector.net audio add on soundcard
Load: dtoverlay=audioinjector-wm8731-audio
Params: <None>


Name: audremap
Info: Switches PWM sound output to pins 12 (Right) & 13 (Left)"

I think I understand you need to put some text into the config file, but I'm unsure what?

I suppose audremap overlay did not exist when above linked article was written.

So, did you already added

Code:
dtoverlay=audremap

to config.txt without adding dtoverlay=pwm,pin=18,func=2 to that file and use pin 12 and 13 for audio output?

Btw, which sound device are you using in Kodi? You have to use Analogue output


RE: Pi Zero, PWM (analogue) output - TheDutypaid - 11th Apr, 2017 02:22 AM

Thank you so much for the help so far it it most kind.

Nachteule Wrote:I'm sure you know this article
But you forgot to assign second channel. However, I don't believe that this is the problem

Yes I have read through that and this guide builds upon it and is a lot simpler.

Quote:Test without filter

yes, first port of call. I don't even get static so this leads me to believe, there is no output of any kind.

Quote:I suppose audremap overlay did not exist when above linked article was written.

So, did you already added

Code:
dtoverlay=audremap

to config.txt without adding dtoverlay=pwm,pin=18,func=2 to that file and use pin 12 and 13 for audio output?

Btw, which sound device are you using in Kodi? You have to use Analogue output

I have it set to both analogue and HDMI which I changed in the main settings.
Tried quite a few variants of code, including what you have said.
This is my current text I added to the config file.
Code:
# uncomment for composite PAL
sdtv_mode=2

dtoverlay=audremap

dtoverlay=audioinjector-wm8731-audio


I need to try building a new filter, I am only testing with a mono quick board that was made up out of salvaged components that I desoldered from old PCB's all parts was tested before making the board up

Finding reference to Kodi, Pi Zero and audio is hard. HDMI and job is done. Not many people want to watch TV on a 2.3" LCD

The model of portable I am using is a small handheld one 'Casio TV-880' It has AV input which is lucky as the old analogue TV signal was switched off in the UK a good few years ago now.

I'll be away next week for Easter but hope to test the new filter before then.
Will report back when I have new findings. Will still check on here if there is anymore ideas.


RE: Pi Zero, PWM (analogue) output - Nachteule - 11th Apr, 2017 04:22 AM

Hmmm, the Raspberry Pi Zero Audio Circuit howto you're using sounds quite simple Smile

Why are you adding

Code:
dtoverlay=audremap

dtoverlay=audioinjector-wm8731-audio

to your config.txt? IMO audioinjector-wm8731-audio overlay is needed for different audio sound card, so you should not add it.

I think adding

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

is quite enough for audio part (and oc dtparam=audio=on, but this is enabled per default)


RE: Pi Zero, PWM (analogue) output - TheDutypaid - 13th Apr, 2017 03:24 AM

Hmm,

Got all my new components today and breadboarded it all up for testing. Only running the one line of audio code
Code:
dtoverlay=pwm-2chan,pin=18,func=2,pin2=13,func2=4

Turned it all on and... nothing.

Even tested bare output from the Zero.

I feel the problem is a programming one,
Looking back through the README.overlays file I found this, which I have not tested as running out of time, do you think this is what is needed?

Code:
Name:   audremap
Info:   Switches PWM sound output to pins 12 (Right) & 13 (Left)
Load:   dtoverlay=audremap,<param>=<val>
Params: swap_lr                 Reverse the channel allocation, which will also
                                swap the audio jack outputs (default off)
        enable_jack             Don't switch off the audio jack output
                                (default off)

So do I need to add this below to the config file?
Code:
dtoverlay=audremap,<enable_jack>=<val>

I'm unsure about the val.


RE: Pi Zero, PWM (analogue) output - Nachteule - 13th Apr, 2017 03:31 AM

You could try it, but don't put both dtoverlay= lines to config.txt. Only one of them

IMO audremap does not need any parameters, bc you do not need to swap l<->r channel and you do not have audio jack output on Pi Zero


RE: Pi Zero, PWM (analogue) output - TheDutypaid - 13th Apr, 2017 06:35 AM

I have been a bit silly, been following this 'pin out' for the Pi


There is a big difference between 'pin' 13 and GPIO 13

The simple code, works fine.
Code:
dtoverlay=pwm-2chan,pin=18,func=2,pin2=13,func2=4


Thank you again for your help you have given and setting up my question in the right place.

It was with your support, I keep trying new things and double checking my work. Funny when your mind thinks you have something right, that is completely wrong.


RE: Pi Zero, PWM (analogue) output - Nachteule - 13th Apr, 2017 07:15 AM

(13th Apr, 2017 06:35 AM)TheDutypaid Wrote:  There is a big difference between 'pin' 13 and GPIO 13

Indeed, it is Tongue

I was thinking about that, but was sure you were usiing right pins Smile

Quote:The simple code, works fine.
Code:
dtoverlay=pwm-2chan,pin=18,func=2,pin2=13,func2=4


Thank you again for your help you have given and setting up my question in the right place.

It was with your support, I keep trying new things and double checking my work. Funny when your mind thinks you have something right, that is completely wrong.

You're welcome. Good, you got it now Smile

Enjoy your new project, so this thread can be set to solved


RE: Pi Zero, PWM (analogue) output - LauriBuell - 2nd Nov, 2018 03:57 AM

Hi...The possibility to remap the PWM output to accessible GPIO pins was completely new to me and opens up a lot of simple audio applications for the Pi Zero (talking clock etc.).

smt pcba