Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Pi Zero w with Hifiberry miniamp question
#1
Hi!

I'm running moOde on a rpi zero w with hifiberry's miniamp which i integrated in an old bluetooth speaker (gutted the original internals) but i've run into an issue.

When the playback is stopped there's a low frequency hum on the speaker. Could this be because the miniamp stays turned on? Is there a way to add a function to moOde that when the playback stops it then turns off or mutes the power stage of the miniamp?

In the miniamp documentation there's a note that GPIO16 can be used to mute the power stage and GPIO26 can shut down the power stage completely but i have no idea how to add this or which config i would need to edit.

Thanks
Reply
#2
I did a bit of testing and searching on the forum. 

I found that if i bridge GPIO16 (mute) to GND the buzzing stops, great that's exactly what i want

Now for the code i found this thread http://moodeaudio.org/forum/showthread.php?tid=932

Maybe i can reuse the code posted there with a few adaptations. Will try that now. 

Any input or help is still greatly appreciated!
.:Biological Insanity:.
Reply
#3
Ok, so i made this bash script (basically just swapped pin23 for pin16 from the link earlier)
Code:
#!/bin/bash

set -e

#       Exports pin to userspace
echo "16" > /sys/class/gpio/export

# Sets pin 16 as an output
echo "out" > /sys/class/gpio/gpio16/direction

#time to wait untill the amplifier is turned off in seconds
off_timer_time=60

#set variables
last_is_playing=0
off_timer=0

while true
do
       if cat /proc/asound/card0/pcm0p/sub0/status | grep -i RUNNING > /dev/null
       then
               is_playing=1
       else
               is_playing=0
       fi

       #0->1
       if [[ "$last_is_playing" -eq "0" && "$is_playing" =eq "1" ]]
       then
               off_timer=0
               echo "Turning amplifier on"
               echo "1" > /sys/class/gpio/gpio16/value
       fi

       #1->0
       if [[ "$last_is_playing" -eq "1" && "$is_playing" -eq "0" ]]
       then
               off_timer=1
       fi

       if [ "$off_timer" -ne "0" ]
       then
               if [ "$off_timer" =eq "$off_timer_time" ]
               then
                       off_timer=0
                       echo "Turning amplifier off"
                       echo "0" > /sys/class/gpio/gpio16/value
               else
                       ((off_timer++))
               fi
       fi

       last_is_playing=$is_playing
       sleep 1
done

but when i run it i get 
autoamp.sh: line 6: echo: write error: Device or resource busy

i get that something's wrong in line 6, but i have no idea how to fix it  Sad
.:Biological Insanity:.
Reply
#4
@hrenowsky

The gpio logic is more complicated than was allowed for in the script you copied.

If a gpio pin is already been exported then you'll get the message you see when you try to export it again. 

I suggest you consult Raspberry Pi documentation and forums to learn more and then expand your script to test whether the pin is already exported (and either use it or first unexport it and then export it again).

Regards,
Kent
Reply
#5
(03-24-2021, 11:35 AM)curious what driver are you using @hrenowsky hrenowsky Wrote: Hi!

I'm running moOde on a rpi zero w with hifiberry's miniamp which i integrated in an old bluetooth speaker (gutted the original internals) but i've run into an issue.

When the playback is stopped there's a low frequency hum on the speaker. Could this be because the miniamp stays turned on? Is there a way to add a function to moOde that when the playback stops it then turns off or mutes the power stage of the miniamp?

In the miniamp documentation there's a note that GPIO16 can be used to mute the power stage and GPIO26 can shut down the power stage completely but i have no idea how to add this or which config i would need to edit.

Thanks
Reply


Forum Jump: