Author Topic: RaspBMC media center incorporating ATXRaspi  (Read 21657 times)

Dazza

  • Newbie
  • *
  • Posts: 5
RaspBMC media center incorporating ATXRaspi
« on: June 04, 2013, 04:43:19 AM »
NOTE: January 2016, some changes have happened since RaspBMC became OSMC.  I am updating these notes mainly for my benefit as I go along, changes or additions are in RED

I'm posting this to give an example of an implementation using Felix's ATXRaspi power controller.

The Brief:

An XBMC media player for my caravan, including on board storage and wireless access, plus access to the onboard library via iPad app.  Must run on 12V power and be able to support a variety of media formats and outputs.  It must also be housed in a neat and reasonable sized case.

Background:

Tests had been carried out using a WDTV Live Hub, but that runs part of my home theatre setup and I did not want to buy a new one.  I have previously built a Raspberry Pi based media centre for my outdoor entertainment area, but that was network based only (no onboard storage), was hard wired ethernet and was housed in a large Tupperware container.

I had also used a second Raspberry Pi as a VOIP PBX using Asterisk, so I am quite familiar with them plus I also had one spare left over from my experiment pile.

Parts List:

My nominal budget for this was the price of a WDTV Live Hub, about $220.  Using bits I already had and settling for a smaller hard drive I came in a bit below.  All prices are Australian dollars and include delivery.

PartPrice
Non Vented Instrument Case         $20
Raspberry Pin/a
300GB USB Driven/a
RJ45 Bulkhead Cable$4
USB Bulkhead Cable$3
HDMI Bulkhead Cable$7
Powered USB Hub$29
Adjustable switch power supply$6
ATXRaspi$24
Nano USB WiFi Adapter$7
SPST Rocker Switch$2
SPST Momentary Push Switch$5
PCB Crimp Sockets$1
Various 2, 3 and 4 pin Header Connectors$5
Small Red LEDn/a
IR Receiver$5
2.5mm Bulkhead Power Socket$3
12V Power Lead - Fused$3
Media centre IR Remote Controln/a
Various Cablesn/a
Heat Shrinkn/a

Total so far is $119.

If we then add in the cost of the Pi ($35), the drive (say $50? had it forever and replaced twice over) and the remote ($10) it comes to $214.  I did say it came in a "bit" under...

Schematic:


The following schematic concentrates on the power feed and control as we are mainly interested here in how the ATXRaspi is implemented.



An adjustable DC-DC power supply accepts a switched and fused 12V feed and is adjusted using the onboard trimpot for 5V output.  This PSU is rated up to 3A output which is more than sufficient to power the ATXRaspi and the powered USB hub.  Search eBay for LM2596S to find a range of boards with similar functionality.

The powered USB hub (not shown above) powers up on application of 12V power, this allows the USB disk to power up before turning on the Raspberry Pi.  It also powers the nano wifi adapter, I have had problems previously powering these directly from the Raspberry Pi USB ports.

The ATXRaspi is connected as shown in Felix's instruction page, the only other thing to note is the addition of an IR receiver powered by the Raspberry Pi 3.3V supply and connected to the ATXRaspi common ground.

Build Log:

All connections were made using crimped and soldered 0.1" pitch header connectors, or with single crimped and soldered header connectors.  A good quality temperature controlled soldering iron makes this easier, too high a heat from cheaper soldering irons can sometimes bend the connecters making them hard to insert into the connector housing.

A cheap $19 crimp tool is another worthwhile investment if you are going to be doing this sort of project work.

All connections were made to the ATXRaspi as per Felix's instructions. 

Software was already installed on the Raspberry Pi following again the instruction page.  Note that I had to install "make" and "gcc" before executing the "./build" command as shown below, modified from Felix's instructions.  This is because RaspBMC is a slim distribution of the Debian OS and did not already have these installed.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install git-core
sudo apt-get install make
sudo apt-get install gcc
sudo apt-get install build-essential
git clone git://git.drogon.net/wiringPi
cd wiringPi
./build


Power was applied and the big red button pressed, the Raspberry Pi dutifully powered on.

Testing proved however that pressing the button for 4 seconds did not turn the Pi off.  The status led for the ATXRaspi pulsed slowly for a while, then came back on solid.  Obviously something was not quite right.

I powered down the Pi manually, then powered up again using the ATXRaspi.  I then SSHed into the machine to do a bit of troubleshooting.  First to make sure the shutdowncheck script was running I ran the "top" command.  shutdowncheck was running but consuming 2.6% of CPU rather than the 0.7% Felix expects.  Starting the shutdown sequence using the ATXRaspi caused the shutdowncheck script to crash.

To cut a long story short, the issue was with the cut down Debian distro that RaspBMC uses.  The sleep and halt commands were not in the path specified by the script.  The lack of the sleep command caused the high CPU usage, as the script was continually looping rather than pausing for .5 seconds each loop.  The script was crashing on shutdown because the halt command was not found.

Making some modifications as shown below to the PATH variable brought success.  The Pi powered up and down as advertised.

Unfortunately the story doesn't end there.  I stupidly decided to enable USB audio in the RaspBMC software which resulted in me finding about a known fault and having to install my software from scratch, using the latest RaspBMC download.

After setting up the script using the modified path statement, the Pi would now shutdown but not power off.  My configuration was identical to one that worked earlier that day so I was initially stumped.  A quick test with a multimeter showed that even though the Pi had shutdown down under control of shutdowncheck, pin 8 was still high.  Huh??

Google came to the rescue and suggested that using halt can leave some processes running even though the system appears shutdown.  They suggested using the command "shutdown -h now" instead for a clean shutdown.  Knowing the minimum I need about Debian I gave it a try and lo all was working again...  Maybe Felix can shed some light.

The final shutdowncheck script is below.  As the link for the Rev 1 ATXRaspi download appears to be broken, create the file by typing the following:

cd ~
nano shutdowncheck


Then paste the following into the file:


#!/bin/bash

PATH=/bin:/sbin:/usr/bin:/home/osmc/wiringPi/gpio

echo "ATXRaspi shutdown script starting..."
echo "Asserting pins (7=in,low; 8=out,high)"

gpio -g mode 7 in
gpio -g write 7 0
gpio -g mode 8 out
gpio -g write 8 1

COUNTER=0

#while [ $COUNTER -lt 10 ]; do
while [ 1 ]; do
    #echo Looping - counter is $COUNTER
    #let COUNTER=COUNTER+1
    #sleep 1
    if [ "$(/home/osmc/wiringPi/gpio/gpio -g read 7)" = "1" ]; then
        echo "PIN7 requested a SYSTEM HALT !"
        shutdown -h now
        break
    fi
    sleep 0.5
done


exit 0

Note that this is for RaspBMC based Pis only, stick with Felix's original script unless you have similar problems.

Layout:

Note that there is a fair amount of excess cable for the Hong Kong brand bulkhead connectors, these coil neatly up in the compartment housing the Raspberry Pi, they have been moved for the photos.  Also moved out of the way is the hard drive which is attached to the top cover and resides in the space above the power supplies.



"Rear" Panel:



"Front" Panel:



Finished and assembled:



Conclusion:

The ATXRaspi turns what was an awkward to use media centre into something my wife is happy using in the caravan.  My previous media centre build is permanently connected to a 5V USB power pack locked away in a cupboard.  Turning on the 240V supply turns on the Pi, and shutting it off required the use of an Android shutdown app or SSH connecting to the Pi and initiating a shutdown.  What normally happened was that I turned it off at the wall, twice so far resulting in a corrupt SD image.

Highly recommended product.
« Last Edit: January 19, 2016, 05:42:11 AM by Dazza »

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 5261
  • Country: us
    • LowPowerLab
Re: RaspBMC media center incorporating ATXRaspi
« Reply #1 on: June 04, 2013, 09:31:40 AM »
Dazza - nicely done!
How is the ATXRaspi working for you?

Dazza

  • Newbie
  • *
  • Posts: 5
Re: RaspBMC media center incorporating ATXRaspi
« Reply #2 on: June 05, 2013, 05:48:07 AM »
It's working exceptionally well, thanks Felix, especially after fixing some issues with the RaspBMC distro and making a couple of changes to the script.  I will detail them in the build log but tonight it's time to watch Rugby League State of Origin and have a few beers. 

I will try and finish the post tomorrow otherwise after the Queen's Birthday long weekend.  We Aussies do have some weird traditions....

Daryl


Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 5261
  • Country: us
    • LowPowerLab
Re: RaspBMC media center incorporating ATXRaspi
« Reply #3 on: June 05, 2013, 07:54:20 AM »
Excellent! Thanks Daryl!

Dazza

  • Newbie
  • *
  • Posts: 5
Re: RaspBMC media center incorporating ATXRaspi
« Reply #4 on: June 11, 2013, 07:20:33 AM »
Final build notes all finished so just giving the topic a bump  ;)

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 5261
  • Country: us
    • LowPowerLab
Re: RaspBMC media center incorporating ATXRaspi
« Reply #5 on: June 11, 2013, 07:37:58 AM »
Very nice indeed, I'll link this on the ATXRaspi page.

Mister Fab

  • Newbie
  • *
  • Posts: 2
Re: RaspBMC media center incorporating ATXRaspi
« Reply #6 on: August 06, 2013, 09:08:00 AM »
Hi Dazza,

Thank you very much for your work, it was really helpfull to setup my Raspbmc media center.

I just added to this the trick from Obundra ( in ATX Raspi R1 comments) wich was to add a transistor to control the electric switchoff from xbmc's menu. I also modified a switch I got from a PC tower with a plastic ring and leds to get a nice light effect, and to install everything in a small case.

A quick video to show it running:

http://youtu.be/WoWZctlIkuQ







« Last Edit: August 06, 2013, 09:40:36 AM by Mister Fab »

Dazza

  • Newbie
  • *
  • Posts: 5
Re: RaspBMC media center incorporating ATXRaspi
« Reply #7 on: August 07, 2013, 07:25:03 PM »
Hi Fab - that looks good. I am up to my elbows in Arduinos at the moment but I think I will have to drag my Pi back out and incorporate your transistor fix. 

I can't find the post you refer to from Obundra - I assume there is some code on the Pi to support this?

Thanks,

Daryl

Mister Fab

  • Newbie
  • *
  • Posts: 2
Re: RaspBMC media center incorporating ATXRaspi
« Reply #8 on: August 14, 2013, 05:41:29 AM »
Hi Dazza, sorry for my late answer.

There's some code to support this. I refered to the comments on the ATX raspi V1: http://lowpowerlab.com/atxraspi_r1/

Here's the original text:

obundra on June 14, 2013 at 1:26 pm said:
Hello!
As the ATXRaspi not cutting off power if shutdown command is given from shutdown menu in xbmc and power button not pressed, I added a little modification, so now my xbmc can shut down the power from shutdown menu without pressing power button.I added BC337 NPN transistor to the power button.E to the GND and C to +5 on button pins.B through 10k resistor to free gpio pin on RPi.
Next I modified file /opt/xbmc-bcm/xbmc-bin/share/xbmc/addons/skin.confluence/720p/DialogButtonMenu.xml. There is “Shutdown button” description and line “XBMC.Powerdown()”, I changed it to “System.Exec(“/home/pi/gpioshutd.sh”)”. I wrote a little shell script /home/pi/gpioshutd.sh with content:”#!/bin/bash
sudo gpio -g mode 10 out;sudo gpio -g write 10 1 ;sleep 4.6;sudo gpio -g write 10 0″
So when I choose shutdown from xbmc menu it will run a shell script which pulls gpio 10 up for 4.6 seconds and transistor connecting powerbutton pins and usual ATXRaspi shutdown sequence begins.