User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

Specification for Pi PWM audio??

Thu Oct 24, 2013 8:42 pm

I'm thinking of building a switching circuit that would turn on my audio amplifier when audio is present at the headphone socket even if the audio is silent but still playing.
This would prove useful in a battery operating environment since an audio amplifier would still be using power even when silence (quiescent current).
Since the Pi's on-board audio uses pulse width modulation with a low pass filter I am hoping that there still sufficient levels of high frequency to recover (or I may have to rip out the filtering capacitors).

Can anyone please tell me what is the centre frequency of the modulation and how much actually leaks out one of the audio channels unfortunately I'm not blessed with an oscilloscope or spectrum analyser.

Richard S.

karlkiste
Posts: 189
Joined: Tue Jan 22, 2013 8:50 am
Location: berlin, germany

Re: Specification for Pi PWM audio??

Fri Oct 25, 2013 5:42 am

What a pity... A year ago, PWM was switched off completely when no sound was played. This lead to a loud click when PWM was switched on. You could have easily detected that... But, to get rid of the click, PWM now stays on, once activated.

Then, when I had a look with my cheap scope, I saw something irregular which felt like 40MHz serial data. There's not much left of that after the output filter.

I think it would be best to use a GPIO pin to switch on and off the amplifier.

User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

Re: Specification for Pi PWM audio??

Fri Oct 25, 2013 11:51 am

40MHz is quite high for most general purpose transistors or operational amplifiers to rectify and convert into measurable DC levels.
Also the fact the Pi runs off the mains with no ground connection is causing humming issues (EMF) with my ultra high gain amplifier circuit.
In the end I found different solution which is to build a basic radio receiver circuit and then tune into one of the 40MHz harmonics.
I've found 135.2MHz quite strong and in fact even with the volume set to the lowest level (not muted) there is still sufficient modulation to pass into a detector circuit.
Ideally I should really toggle the GPIO output pin to control my amplifier power but that would require additional code and possibly a customised media player which I want to avoid.

Just out if curiosity if the audio is completely silent but still active is the PWM engine turned off during this period??

Richard S.

karlkiste
Posts: 189
Joined: Tue Jan 22, 2013 8:50 am
Location: berlin, germany

Re: Specification for Pi PWM audio??

Fri Oct 25, 2013 1:44 pm

Just checked again: It's more like 50MHz. My cheap scope says 49.1.

PWM is off when raspbian is booted. When the first sound is played, PWM is switched on, and not switched off afterwards. This is no bug, but a feature: Otherwise there's a really annoying loud click at the start of every sound.

Replace your audio player by a wrapper script, which switches the amplifier on, starts the original player, and switches the amp off after the player is closed. The most reliable way, I think.

User avatar
redhawk
Posts: 3465
Joined: Sun Mar 04, 2012 2:13 pm
Location: ::1

Re: Specification for Pi PWM audio??

Fri Oct 25, 2013 10:05 pm

I often wondered how dom fixed the blip problems, well it looks to me more like a dirty hack than a fix keeping the pwm engine running indefinitely. :(

Does anyone know how to force the pwm off once it's activated??

At least I know my plan with the radio receiver won't work, I guess I'll go back to my original idea of checking the signals at the L and R channels.

cheers,

Richard S.

User avatar
Burngate
Posts: 6091
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Specification for Pi PWM audio??

Sat Oct 26, 2013 10:01 am

redhawk wrote:Does anyone know how to force the pwm off once it's activated??
I've no idea if it'd work ... Since the R & L pwm are ALT0 on GPIOs 40 & 45, could you force them to be standard inputs (or outputs)?
On power-up, are they already allocated to ALT0, or does the audio system allocate them when it starts up?

Return to “HATs and other add-ons”