Arduino

HTPC

I finally got around to taking some photos of my HTPC.

Here it is fully assembled in its Mini-ITX chassis

Here it is fully assembled in its Mini-ITX chassis

 

And here is the front bezel of the chassis (Power button w/LED, HDD LED, reset button - the big red one)

And here is the front bezel of the chassis (Power button w/LED, HDD LED, reset button – the big red one)

With the top off. Top tray holds the HDD.

With the top off. Top tray holds the HDD.

 

And here's all the guts. The middle board is the PMU I designed. It is controlled by the blue Arduino Micro on board.

And here’s all the guts. The middle board is the PMU I designed. It is controlled by the blue Arduino Micro on board.

 

Close-up of the PMU. The green terminal block on the right is power input. The block up top is the switched power (to RPi and HDD).

Close-up of the PMU. The green terminal block on the right is power input. The block up top is the switched power (to RPi and HDD).

 

Sunday, May 5th, 2013 Arduino, Hardware, Raspberry Pi No Comments

Raspberry Pi ATX power management using an Arduino (Pt. 2)

Well, I finally posted all my source code and schematics on github at https://github.com/cyrusbuilt/CyrusBuiltHTPC.  Now some details on the Arduino code: To enable debug mode (if necessary…. it’s been thoroughly tested and I’m currently using it on my own box everyday), uncomment line 45 in Raspi_ATX_PMU.ino.  If you do, the firmware will not complete initialization until it connects to the host that will be monitoring the serial output.  It will attempt a serial connection at 9600 BAUD and will not do anything else until connected.  This is intentional so that you can see the boot screen which displays the pin definitions and their current state. Otherwise, you’d miss the boot screen by the time the connection is actually made.  Once connected, all actions and pin states are output to the serial port as the events are handled.  The 2 libraries in the “lib” folder will need to be copied to the “libraries” folder of your Arduino installation in order to compile.

And now some notes on the HTPC platform installation stuff:  Use the following procedure to set up the platform correctly: 1) Make sure SSH is enabled on the Raspberry Pi.  2) Navigate to the CyrusBuiltHTPC folder from a terminal and type “chmod +rx remote_install.sh”. This will make the remote installation script executable. 3) Type “./remote_install.sh”.  This will just push all the platform installation stuff to the Pi using SCP.  If you’ve already copied the platform installation stuff to the Pi by other means, then just skip steps 2 and 3. 4) Type “chmod +rx setup.sh” in the terminal on the Pi (or via SSH), and then type “./setup.sh”.  This will perform the initial setup by setting the appropriate permissions on the other scripts and installing the utility scripts (systemreboot, systemshutdown, systemupdate) in /usr/bin. 5) Navigate to /home/pi/xbmc_install in the terminal and type “./build-and-install-xbmc.sh”.  This will pull XBMC from its github repository and proceed to compile and install XBMC.  This may take up to 13 hours to complete. 6) After rebooting, navigate to “~/” and type “./configure-htpc-platform.sh”.  This will configure the platform appropriately and set up the Pi to boot into XBMC automatically (you can still exit XBMC to get to a command prompt).

The whole system performs well.  I’ve been streaming TV shows in HD from my TVersity server for months without any problem.  I think I can reduce boot time by relocating rootfs to the USB HDD, as described here.  I will post some pictures of the HTPC and some additional schematics laying out how the whole thing is supposed to be connected together.

Cheers!

Wednesday, April 3rd, 2013 Arduino, C/C++, Programming, Raspberry Pi No Comments

Arduinos!!

Ok, so I’ve been playing with a couple of Arduinos for a while now.  I love these things…. soooo many possibilities.  I used to use the Parallax BASIC Stamp 2P24 for similar purposes, but quite frankly, they are just too expensive to compete with the Arduino (or Raspberry PI for that matter).  Plus, I don’t really care for the PBasic programming language either. The Arduino essentially uses C/C++ and the libraries are extensive.

Anyway, I bought 2 of these guys.  I started with an Arduino Uno and did some experiments and prototyping with it.  After playing around I had a cool idea….. remember when I said I got a Raspberry PI a while back?  Well, I had decided to build an HTPC using the PI, a Mini-ITX chassis w/power supply, an RTC (real-time clock), and some other goodies.  I found that Raspberry Pi + Raspbian + XBMC (Xbox Media Center) = One badass HTPC.  I mostly stream video from my TVersity server, but I also added a 250GB 2.5″ SATA HDD using a USB-to-SATA adapter.  The power supply that came with Mini-ITX chassis is more than ample considering the Pi only uses 5V @ 0.5A DC.  The bulk of the power consumption is spent on the HDD.  I also got a SWEET mini wireless keyboard/mouse combo so I can work the whole thing while sittin across the room in bed.  I can even surf the web!

Caveats:
1) There is a lot of work to getting XBMC compiled and installed on Raspbian.  There are pre-built images that have a stripped-down OS based on Raspbian with XBMC already integrated as a self-contained HTPC OS.  They were great, but did not support I2C or the DS1307 (both needed for the RTC module), nor did it have adequate support for my USB-to-SATA controller.  I found it best to just build XMBC on top of Raspbian and then customize the whole thing as needed.

2) Power.  The Mini-ITX chassis uses an ATX-style power supply.  It also has power and reset buttons, as well as power indicator LED in the front bezel just as you’d expect from any other PC.  The problem is this:  The Pi does not behave like an ATX-class PC.  You can soft-off through the OS, but it does not power off the board.  You have to disconnect and then reconnect the power in order to get it to boot up again.  However, there are 2 solder pads on the Pi used for reset.  So then I got the idea:  I could build a PMU (power management unit) using an Arduino!!

As it turns out, the ATX specification has a 5V standby pin (purple wire) that is always on as long as it has power.  This is what keeps certain functions of your motherboard alive so it can monitor power button presses, which then tells the power supply to turn on by driving the trigger pin (green wire) low, or in other words, ties it to ground.  So my thought was to use the Arduino to sense power and reset buttons and then drive relays to to control them.

But that is where I ran into problems.  I started off trying to use an ATtiny85 and just program it using my Arduino Uno as an ISP, but that didn’t work out because I couldn’t get the damn thing programmed.  I eventually gave up and bought an Arduino Micro from AdaFruit.  Not as cheap as the ATtiny85, but far more versatile and a breeze to program.  Plus it supported a greater instruction set, which I ended up needing anyway.

Then I ran into another problem:  Power draw.  The Arduino Micro, plus LED and a couple of relays is just too much power draw from the 5V standby pin.  I did not have sufficient power to run the whole circuit.  So, plan B: tie the trigger pin low leaving the ATX supply on full-time (or while it to a switch for hard-disconnect).  Then I can use the full 12V and 5V rails from the ATX supply.  The only thing is, I had to add a third relay.  The relay assignments are as follows:

Relay 1 = Reset switch.
Relay 2 = 5V power switch for Raspberry Pi and HDD.
Relay 3 = 12V power switch for HDD.

So the basic operation is simple:

Power button press (momentary):
Power currently on? no-> turn on LED and Relays 2 and 3. Otherwise, turn them all off.

Reset button press (momentary):
Power currently on? yes->turn off LED and turn on Relay 1. Do not switch states back until button release. During this time, ignore power button presses; Otherwise, do nothing.

This was actually quite effective.  The prototyping phase is done.  I just need to start soldering this stuff to the PCB!!  I’ll be posting schematics, source code, etc to github as soon as I get everything put together and tested.

Tuesday, February 12th, 2013 Arduino, C/C++, Hardware, Programming, Raspberry Pi No Comments