X400 V3 DAC + clean shutdown?

Hello community!

I recently made my first system using Volumio. I use a raspberry 3B+ and a X400 v3.0 DAC. For power management I connected a latched switch to the X400 shield. Everything works perfectly but something bothers me: when I turn off the system with the switch, there is no soft shutdown! The raspberry is just cut off, which is not really a good thing on the long run as far as I know. I have to go to volumio to turn the system off before pressing the switch if I want to do things properly… not ideal. I am a bit disappointed that the X400 does not manage better the power to the Raspberry pi.

I have been trying to make a workaround using a relay to latch the switch input while I use a GPIO to trigger a soft shutdown and remove power when the raspberry is shut, but I am finding a lot of unexpected issues, and the X400 board turns out to be poorly documented when going a bit into details. My main struggle is that there seems to be a lot of different grounds, and I am afraid that without a good documentation I will interconnect 2 of them and burn something. (I mention that in case someone would have some info on that , that would help :smiley:)

So long story short, I would be interested in knowing how are other people shutting down their system. Are you guys always shutting down using the volumio’s software shutdown? or maybe a hard shutdown is not real an issue afterall?

Thanks!

Hi,

On my side, I’m using the Pi-Switch from nanomesher
(see my post here : My high-end streamer)

It has for effect to send an interrupt to the RPi, asking him to make a software shutdown, before cutting down the power supply through the help of a relay.
It works like a charm.

But I don’t know the X400, so I’m not sure of what has to be taken care of.

Florian

thanks for the tip. I didn’t know the Pi-switch, it would have save me some trouble :slight_smile:
Nice project, very inspiring!
I finally found a working solution with the relay. there was an error in the documentation of the DAC, a pin indicated as ground and that wasn’t. That solved it and now the thing works perfectly :slight_smile:

Hi,

I also own a x400 v3 and poweroff the pi is indeed an issue.
Could you share your solution?

Harry

sudo shutdown
on putty wil shutdown the pi

Hey i will detail what I did in the next days

Before I explain, I’ll just name Vin =the voltage provided by the power supply. In my case I have a 12Vdc power supply, so Vin = 12Vdc.

The switch has to be a latched switch.

Details about the connector of the X400 are here: https://raspberrypiwiki.com/X400_V3.0

The issue in X400 documentation I mentioned above is on the power switch connector. The pin number 3, instead of being a ground, is actually Vin. Probably the switch simply cuts the line between the jack and the power converter of the board.

So here is how the documentation tells you to wire your switch :

image

What we want to do is to connect pins 3 and 4 of the connector until the raspberry has shut down.

To do that, i use a relay powered by the Rpi and controlled by a GPIO that I will name «GPIO B». The GPIO will stay at 3,3V until the raspberry is down, and then go to ground. When that happens, the relay opens, and removes power from the X400 board.

Example of a relay board that can be used: https://www.amazon.com/HiLetgo-Channel-optocoupler-Support-Trigger/dp/B00LW15A4W/

If you only do that, the switch is shorted as soon as the Rpi has started. Any action on the switch has therefore no effect. To use the switch as a trigger for shutting down the Rpi, you need another connection. For that purpose it is much better to use a switch with 2 poles (DPDT). In case you don’t have a DPDT switch, like me, check below for the alternative solution. The second pole connects a GPIO to 3,3V when the switch is in OFF position. That GPIO, that I will name GPIO A, will be configured as an interrupt that triggers the shut down of the Pi.

GPIOA and GPIOB can be any GPIO available on the connector, except for GPIO18 which is already used by the X400 board. I recommend the use of GPIOs 17, 22, 23, 24 or 27 for GPIO A because they have a default pull down, which is what we need here.

The wiring looks like that :

Configuration of the RPi

via SSH, edit /boot/userconfig.txt and add the following lines :

gpio=7=ip,pd
gpio=8=op,dh
dtoverlay=gpio-poweroff,gpiopin=8,active_low=y

the first line is for GPIO A (in that case GPIO A is GPIO 7). It sets the gpio as an input with a pull down. This line is not necessary for GPIOs 9-27.
the second line is for GPIO B (in that case GPIO B is GPIO 8). it sets the gpio as an output in a high state.
The third line sets the GPIO B so that it will go to ground once the Rpi is off.

Reboot.

Install the plugin GPIO-buttons, and set the shutdown gpio to one you chose for GPIO A.

Alternative Solution using a single pole switch (NOT RECOMMENDED)

In case you don’t have a DPDT switch, which can be hard to find if you look for one round with LED and pictogram, there is an alternative. However be extra careful when using it. The GPIOs only support input voltage between approximately 1,8V to 3,3V . Double check your calculations, your wiring, your assembly, because if anything above 3,3V is applied to the GPIO, it will destroy it.

Here we use the “Normally Close” pin of the switch that is set to Vin when the switch is turned off.

The wiring looks like that:

The GPIOs read a high state between 1,8V and 3,3V. The lower threshold is not guarantee so it is better to be as close possible to 3,3V, without exceeding it.

To lower the voltage Vin to an acceptable voltage for the GPIO, I use a voltage divider. The voltage on the GPIO is equal to R1/(R1+R2) * Vin. So R1 / (R1+R2) should be between 1,8V /Vin and 3,3V /Vin.

In my case, Vin is 12V. I used 4 resistors of same value, 1 is R1 and the 3 other in serie are R2. R1/(R1+R2) = 1/4, so the Voltage on the gpio is 12/4 = 3V. That is sufficient to be detected by the Rpi.

Don’t use to low values resistors: R1+R2 should not fall under 1000ohms, else you might burn the board. Don’t use too high value resistors either or the GPIO will not detect the voltage (i’d say max 10kohms for R1+R2). I used 560ohms resistors for example, so in my case R1+R2 is 2000ohms.

The configuration is the same as explained above.

Good luck :slight_smile:

Paul,

Nice solution and great explanation!
Unfortunately I have the original case and all the extra parts wont fit nicely…

X400s

So I think I will connect a small switch to shutdown Volumio by software with the GPIO-plugin

Kind regards

Harry

Paul, I just ordered an x400 V3 DAC & am going to try your clean shutdown method but I am very very new to all this. I just need to order a round led dpdt power switch to follow your diagram but am not sure about voltage. Can you recommend a dtdp power switch that will work for this? I don’t want to buy the wrong one & blow up my Pi. Looking for a round 22mm metal led switch.

Would this 3v dtdp switch work?

C$ 4.15 | 22/25mm Waterproof Metal Push Button Switch sus304 stainless steel LED Light Reset Self Locking Power Switch6V12V24V220V NONC

Hi Nibs!
Sorry for my late reply, I was not checking my emails lately,
The voltage mentioned for your switch is for the LED, it will be supplied by 5V from the X400, so i’d say the 6V one is the best option here.
for comparison, on my project I used one rated 12Vdc and the thing is still working great after nearly 2 years now. But the closer it is to the supply voltage, the better, so 6V is a better option actually.

1 Like

Paul did you ever come across an issue with the X400 v3.0 DAC where if you hookup headphones to the 3.5mm jack the speakers also play at the same time instead of just the headphones?