Hey all,
my name is Sven (21), I’am a german student and I started a DIY All-in-One amplifier project back in the early days of the RPi before volumio existed. I paused the project for a few years and as I have vacations of my studies now I’am looking forward to make progress again. Now I run into trouble connection my old setup with an RPi running with volumio and Hifiberry DAC+. I really hope that someone here could help me with this specific audio/volumio problem or give me some kind of hint how I could try to fix it because I like volumio so much and want combine it with my “older setup”.
My DIY amplifier (Symasym stereo setup) is working and I made a custom source selection board driven by the portexpander MCP23S17 connected to the first Rev Raspberry PI B via an SPI bus (GPIO 18,23,24,25). This setups works really well with a python script with GUI I got from the german bookauthor “Erik Bartmann” and his homepage. Down below I added an easier python script of him that runs well on my source selection board. Back then I used a simple USB audio card.
Now I want to migrate this setup to my new Raspberry PI B 3, running Volumio with the HifiBerry DAC+ (using GPIO 18,19,20,21 and GPIO 2,3 for configuration).
[b]
There I encountered several questions and problems:
- Is it possible to use the Portexpander MCP23S17 parallel with the HifiBerry DAC+ on one Raspberry Pi 3? Can I change the PCM_SLK GPIO Port 18 for the connection between the portexpander and the RPI to another yet unused pin so I can drive the Hifiberry and my Portexpander simultanously ?[/b]
Overview of the GPIO Header layout (compare RPi B Version 1 with Version 3):
http://www.raspberrypi-spy.co.uk/2012/06/simple-guide-to-the-rpi-gpio-header-and-pins/
2) How can I get the Python script down below running on my RPi 3 with the Volumio distro ?
- I already established the ssh connection to the volumio PI using putty on windows
- Then run sudo apt-get update and sudo apt-get upgrade (and later read that is isnt recommenede to do that ?!?),
- After that I tried to install python-dev (because in the book its said that I need it for the script below) which didn’t worked because of unmet dependencies,
- Additonaly to that I need to install RPi.GPIO library which I did not tried yet because of the errors with installing python-dev.
- How could I try to fix this ?
volumio@volumio:~$ sudo apt-get install python-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
libpam-systemd : Depends: systemd (= 215-17+deb8u7) but 215-17+deb8u6 is to be installed
python-dev : Depends: libpython-dev (= 2.7.9-1) but it is not going to be installed
Depends: python2.7-dev (>= 2.7.9-1~) but it is not going to be installed
systemd : Depends: libsystemd0 (= 215-17+deb8u6) but 215-17+deb8u7 is to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
Python Code for an LED Pattern on the MCP23S17 connected to Raspberry Pi B Rev 1:
[code]#-------------------------------------------------------------------------------
Name: control_mcp23S17
Purpose: Portexpander mit dem Raspberry Pi + MCP23S17
GPIO-Library: RPi.GPIO 0.4.1a
Author: Erik Bartmann,
Website: www.erik-bartmann.de
Created: 12.10.2012
#-------------------------------------------------------------------------------
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
MCP23S17 Werte
SPI_SLAVE_ADDR = 0x40
SPI_IOCTRL = 0x0A
SPI_IODIRA = 0x00
SPI_IODIRB = 0x01
SPI_GPIOA = 0x12
SPI_GPIOB = 0x13
MCP23S17-Pins
SCLK = 18 # Serial-Clock
MOSI = 24 # Master-Out-Slave-In
MISO = 23 # Master-In-Slave-Out
CS = 25 # Chip-Select
ledPattern = (0b01010101, 0b10101010, 0b01010101, 0b10101010,
0b00000001, 0b00000010, 0b00000100, 0b00001000,
0b00010000, 0b00100000, 0b01000000, 0b10000000)
def sendValue(value):
# Value senden
for i in range(8):
if (value & 0x80):
GPIO.output(MOSI, GPIO.HIGH)
else:
GPIO.output(MOSI, GPIO.LOW)
# Negative Flanke des Clocksignals generieren
GPIO.output(SCLK, GPIO.HIGH)
GPIO.output(SCLK, GPIO.LOW)
value <<= 1 # Bitfolge eine Position nach links schieben
def sendSPI(opcode, addr, data):
# CS aktive (LOW-Aktiv)
GPIO.output(CS, GPIO.LOW)
sendValue(opcode) # OP-Code senden
sendValue(addr) # Adresse senden
sendValue(data) # Daten senden
# CS nicht aktiv
GPIO.output(CS, GPIO.HIGH)
def main():
# Pin-Programmierung
GPIO.setup(SCLK, GPIO.OUT)
GPIO.setup(MOSI, GPIO.OUT)
GPIO.setup(MISO, GPIO.IN)
GPIO.setup(CS, GPIO.OUT)
# Pegel vorbereiten
GPIO.output(CS, GPIO.HIGH)
GPIO.output(SCLK, GPIO.LOW)
# Initialisierung de MCP23S17
sendSPI(SPI_SLAVE_ADDR, SPI_IODIRB, 0x00) # GPPIOB als Ausgaenge programmieren
sendSPI(SPI_SLAVE_ADDR, SPI_GPIOB, 0x00) # Reset des GPIOB
while True:
for i in range(len(ledPattern)):
sendSPI(SPI_SLAVE_ADDR, SPI_GPIOB, ledPattern[i])
time.sleep(0.5)
if name == ‘main’:
main()
[/code]
Additional Links:
Overview of the GPIO usage of the Hifiberry DAC+: https://www.hifiberry.com/build/documentation/gpio-usage-of-hifiberry-boards/
Thank you so much for having a look at my struggles. Hope I explained it well enough. I am looking forward to your comments on it