Labels

lego (12) Linux (39) pi (20) Thinkpads (4)

Wednesday 25 September 2013

My First Raspberry Pi Lego Case (ver 2 rev 1)


Intention: To be used for various purposes including as an XBMC media player,airplay server/client, a ASTC to wifi converter box, etc.  Need for both ethernet and wifi and access to a keyboard/trackball.


Equipment:
  • Raspberry Pi (model B -- memory: 512MB, 2 USB ports, ethernet)
  • IR receiver (hooked up to GPIO)
  • class 10 SD card
  • micro USB (for power, plugged into TV <-> raspberry pi)
  • HDMI cable
Assumptions:
  • possible need for VIDEO port
  • possible need for AUDIO jack
  • access to the i/o ports (camera port, GPIO pins, etc)
  • require a "window" for IR receiver

Front-side view



The front white block has the IR receiver behind it (it is a 2x2 curved block that matches the curved blocks on the right side.  The VIDEO port and AUDIO jack are accessible through a double-set door -- the entire door can be lowered or just the inner window.  The power and data onboard red/amber/green LEDs are viewable through the same IR receiver window.  The front of the unit curves up slightly making the base one lego block size bigger in depth.  The height is 4 +1/3rd lego blocks size. The bottom 1/3rd lego block size is a re-enforced grey layer that is more cosmetic then for structure.  Above it, there is a 1/3rd lego block size black layer.  The raspberry pi sits on that, with 3 + 1/3rd lego block size being the height from the base of the board to just above the GPIO ports, with a final 1/3rd lego block size layer on top.


Right-side view:


The micro-USB power port is accessible and the SD card slot is accessible, making it easy to plug in/out both components.



Notes:  

  • A standard SD card sticks out about half-way.  Advantage is easy switching of cards.  Disadvantage is that if you drop the unit on this side, you risk damaging the SD card slot..


Back-side view:


The HDMI located behind a top-swing door.  When not connected to a monitor/TV (for headless operation), the door is swung down to prevent dust buildup.

Left-side view:




There is a top-swing door over the ethernet port that allows the port to be tucked away when not in use.  It sits perfectly flush to the unit, but when the door is open, the door becomes flimsy (easily falls off) -- therefore, the door can be removed.  The 3 2x2 blocks provide visual access to the system onboard LEDs.  The higher 2x2 also provides access for the IR receiver to receive signals from this side of the unit..

The unit is depicted with a wifi dongle and a wireless lenovo multimedia keyboard/trackpad dongle.


(this keyboard, which I owned for 1-2 years prior to owning the pi, but had yet found not a single purpose for it.  Now I find the keyboard a pure necessity )



Top view:


A bit dusty -- I built this case about 6-8 months ago, but only now got around to documenting it.


The top is constructed of two top-swinging doors that provide for easy access to the wires and  camera port....



...and from a different angle, the GPIO,


My Revised Second Raspberry Pi Lego Case (pi model a ver1 rev2)


The previous version was demonstrated in the previous blogpost (http://ddurdle.blogspot.ca/2013/09/my-second-raspberry-pi-lego-case-pi.html)

Intention [unchanged]: To be used as a XBMC media player.  Some will include a wifi dongle (for streaming) while others will feature only videos stored locally)

Challenges addressed with the revision:

  • add a power switch (to provide for easy-means of shutting down, powering off and powering on the device)
  • widen the IR window to broaden distance and angle
  • build a safe-guard around the SD card (to protect the SD card slot)
  • re-orient the raspberry pi so the right-side becomes the predominant side (front-side)


Equipment:
Assumptions:
  • No need for the VIDEO port (going to use HDMI)
  • No need for AUDIO jack (going to use HDMI)
  • No need to access camera port, GPIO pins, etc
  • Require a "window" for IR receiver
  • No powered hub required; will be streaming, using SD card/USB key/powered-hard-drive for video watching
Front-side view



Gone is the IR window from the fronts-side.  The IR receiver has been relocated to the right side under a more generous window.  The unit now raises 2/3rds a lego brick size higher on the right side to accommodate the wiring extending from the power switch.


Right-side view:


closeup with switch powered on (blue light)



Added exactly one lego block size out on the right side of the unit, and 2/3rd a lego block size higher.

The IR window is 4 times as large as it was before (was 2x1, now 4x2) and there is 180 degree aperture  as there is an additional 1x2 of the window accessible from the front view of the unit.

The illuminated push button fits perfect with ample space around to prevent the button catching on the case.  The exact size allowed in my design was 4/3rds a lego brick size.  The micro-USB slot is slightly higher, being replaced by the one on the power switch.  The new micro-USB slot fits more flush with the case then the previous one.

The addition of the lego blocks has provided a better safety mechanism around the SD card, as it now sits completely flush with the unit.  The build up of the blocks gives the case more stability as now both the front-side and right-side are two lego blocks in depth in the core areas giving the case more structural integrity.

Notes:  
  • The SD card is nearly impossible to pull out with your fingers (unless your fingers consist of toothpicks) -- both an advantage and disadvantage.  To take the card out, placing a piece of tape on the top of the card would provide you the needed grip to pull the card out.  As a compromise, the lower section of blocks were strategically built in a manner that would allow you to easily pull the bottom section off without dismantling the case or removing unnecessary blocks.  Care just has to be taken when pulling the blocks off.
  • Consideration was given to making a finger gap to allow for my fat fingers to be able to grab the SD card and pull it out, but was decided against as it left a huge unsightly gap and pulling the card out in such a manner would put at risk damaging the SD card slot.

Back-side view:


I had to extend the HDMI opening by one lego block size on the right.  The original design allowed the board inside to shift left or right up to 3 mm, which would accommodate HDMI plugs that have a fat plastic casing (and indeed most of mine have this).  With the new additions to the case, the board inside fits more snug with just a 1mm shifting allowed for temperature contractions/expansion. You end up seeing more of the internals and subject more to dust.

Left-side view:



Only change here is the changing of the window colouring from blue to white to match the right-side.  I had no large windows for the right-side that were in blue tint (at least none that I could easily find).

The picture shows a wifi dongle attached to the USB port.

Notes:  

  • The onboard LEDs colour output is noticeable at this viewing angle (red glow indicates the system is powered on, a slight green flow overtop the red glow indicates data is being accessed).  This level of output was sufficient for the intended deployment...
  • The white window is thicker in material (the blue tinted window was hollow from the inside), so the LEDs are more obscured from view in this case design.  Since the re-positioning of the case now puts the LEDs in the rear, the function of these LEDs becomes less important.  The illuminated light switch replaces most of the need for these LEDs. 
Top view:


A slight incline on one side.  Some may think it makes the case look ugly, but I think it adds to its character.

Notes:  

  • The raspberry pi internals are still not easily accessible from the top.  Unlike some of my other lego cases that feature a door for access, there was no need for easy access in the intended deployment.  With the new incline, the GPIO is even more of a challenge to access,however, the wiring for the IR receiver and power switch are very accessible with just the removal of a single 4x4 pannel.
Action shots:



Adding a Power Switch to a Raspberry Pi


Challenge:  The Raspberry Pi always remains powered-on as long as there is power coming in on the micro-USB power line.  A shutdown/halt/poweroff command will shutdown the OS and leave the system in a powered on but idle state.  The power consumption would be unchanged between idle and active on the Raspberry Pi.  Further, to turn the system back on, the USB cable needs to be unplugged or the power supply needs to be unplugged (reset).

Ideally we need....

  • something that powers the raspberry pi off when it is shutdown (power consumption becomes negligible / < 0.5 W) [POWER OFF]
  • something that can trigger a clean software shutdown [CLEAN SHUTDOWN]


Mediation:  All my TVs supply a "service" USB port, and when tested, the port was supplying enough power to power either a model B (3.5 W) or model A (1.5 W).  Therefore, I've been plugging in the raspberry pi directly into the TV for the power source.  I just remember that whenever I turn off the TV and I need to "shutdown" the raspberry pi (ssh into it to run the shutdown command or from XBMC).  If the raspberry pi is idling, it's not as risky to just cut the power, although, like any computer,  it is always best to shutdown safely (you stand the risk of corrupting the filesystem).  Also, whenever the TV is on, the raspberry pi is on.  In XBMC, you can enlist an idle timeout to shutdown after X minutes of idle use.  Remember the raspberry pi will continue to consume power from the TV even if it is shutdown.

Solution 1: Panic Button

I purchased a Panic/Stress relief USB button from TheSource for clearance ($4.96 - http://www.thesource.ca/estore/product.aspx?product=8003038&language=en-CA).  I knew it would feature essentially a USB interface to 2 i/o streams that would be either high or low.  I could then write a simple shell script that polls the stream and performs a clean poweroff when the button is pressed.


Pros:

  • cheap and resourceful
  • kind of geeky (re-pursing a device)
  • the casing can be taken apart and just the logical board with usb cable can be deployed

Cons:

  • a USB device that occupies a USB port
  • doesn't provide a full power off state
  • doesn't address the POWER OFF requirement

Solution 2: Brew your own circuit


Use a breadboard and construct a logical switch to perform the same function as solution 1.



Pros:

  • extremely geeky

Cons:

  • more expensive (the components are fairly cheap, but you need to buy them in qtys of 5-10, and the price starts to add up)
  • very susceptible to movement
  • size of the breadboard alone becomes impracticable for scenarios where the footprint of the device is a factor
  • doesn't address the POWER OFF requirement


Solution 3: Buy a PCB


Since this is a common problem, some smart people have come up with solutions
http://www.pi-supply.com/product/pi-supply-raspberry-pi-power-switch/

Essentially, this circuit board is place inline with the micro-USB power line, with a single connection to the GPIO.  It cuts the power to the


Pros:

  • extremely geeky
  • very small
  • easy to integrate with any setup
  • doesn't affect your case design

Cons:

  • very expensive (15 pounds converts to just under $25 Canadian, the price of a raspberry pi)
  • you need to construct the circuit yourself (solder the components onto the PCB)
  • would still need to add a separate button circuit or usb device to allow for triggering a shutdown
  • doesn't address the CLEAN SHUTDOWN requirement




Solution 4: Direct Shutdown PCB



The best solution I found was a fully assembled direct shutdown PCB from a hobbiest http://www.mausberrycircuits.com

He offers a wide range of solutions with various style switches (including add-your-own).  He will even work with your design requirements and alter the switch.

Essentially, this circuit board is place inline with the micro-USB power line, with two connections to the GPIO (1 input, 1 output).  A press of the button or a toggle of the switch takes the unit from off (complete power off for the raspberry pi) to on mode.  A shell script starts on bootup that passes a high/1 to the switch to instruct indicate the raspberry pi is on.  A low/0 signal passes from the switch to the raspberry pi to indicate the switch is neutral.  A toggle of the rocket switch to off or holding a press button switch for two seconds changes the output to high/1 which the polling script triggers a safe poweroff.  When the raspberry pi has finally fully shutdown, the GPIO goes from high/1 to low/0, which tells the switch the raspberry pi power can be cut safely.  The rocket-style switches also come with a reset button that can trigger a raspberry pi reset if it becomes frozen, etc -- something that normally would require to pull the power line.

The switch also detects software shutdowns invoked by the user (as the GPIO will toggle from high/1 to low/0, which the switch polls for).


Pros:

  • very small
  • may need some modification to your raspberry pi case
  • addresses the CLEAN SHUTDOWN and POWER OFF requirements fully.
  • everything fully assembled

Cons:

  • expensive but cheaper then any alternatives


I purchased a number of the switches from Mausberry Circuits.  The illuminated push button switch easily integrates into my lego design cases -- the added width is 1 lego block.

Here's what my case looked like before adding the switch:



I had to rip down the right-side wall to set it up.  But it is lego after all.  Time to integrate the switch into the case!





Solution 5RemotePi Board by MSL Digital Solutions  (added December 2013)



At its core, the RemotePi Board by MSL Digital Solutions promises the same functionality has the that intercept the micro USB power connector on the Raspberry Pi, which is to control the power on/off state of the Pi through a switch and through software.  But instead of intercepting the power flow through the micro USB power connector, it controls the power through the GPIO.  Instead of connecting your power to the micro USB power connector on the Raspberry Pi, you connect it to this board.  You then either toggle the power state by pressing the black button on the top, or better, you can use a IR remote to toggle the power.



Pros:
  • very small
  • may need some modification to your raspberry pi case, but otherwise fits within the existing case (doesn't extend out from the board's footprint)
  • addresses the CLEAN SHUTDOWN and POWER OFF requirements fully
  • no issues with provided switch script (for other switches, I had problems and I had to make customizations to the scripts provided by other offerings)
  • fully integrated IR receiver that can be used to allow your IR remote to control XBMC
  • everything fully assembled

Cons:

In action:





Integrated into a lego case:



The power button is accessible from the top:


My full review of this product is available in this post.

My Second Raspberry Pi Lego Case (pi model a ver1 rev1)

Intention: To be used as a XBMC media player.  Some will include a wifi dongle (for streaming) while others will feature only videos stored locally)

Outcome: Built a couple of these and use one on each TV.

Equipment:

  • Raspberry Pi (model A -- memory: 256MB, 1 USB port, no ethernet)
  • IR receiver (hooked up to GPIO)
  • class 10 SD card
  • micro USB (for power, plugged into TV <-> raspberry pi)
  • HDMI cable
Assumptions:
  • No need for the VIDEO port (going to use HDMI)
  • No need for AUDIO jack (going to use HDMI)
  • No need to access camera port, GPIO pins, etc
  • Require a "window" for IR receiver
  • No powered hub required; will be streaming, using SD card/USB key/powered-hard-drive for video watching

Front-side view: One of the systems deployed under a TV.



The front blue window has the IR receiver behind it.  The VIDEO port and AUDIO jack are intentionally blocked over.  The power and data onboard red/amber/green LEDs are intentionally covered and visible on the left-side view.

Notes:  

  • The blue window the height of one lego block and the length of two lego blocks provides a limited span for IR.  Ok if you are using the unit in front of the TV within a respectable distance and angle within viewing distance.
Right-side view:


The micro-USB power port is accessible and the SD card slot is accessible, making it easy to plug in/out both components.



Notes:  

  • A standard SD card sticks out about half-way.  Advantage is easy switching of cards.  Disadvantage is that if you drop the unit on this side, you risk damaging the SD card slot..


Back-side view:


The HDMI port is exposed, making it easy to plug into the TV.

Left-side view:



There is no ethernet port on the model A, therefore the gap is blocked over.  There is only one USB port, and, therefore, only the single port is accessible.  Beside the USB port is a window for viewing onboard LEDs.



Notes:  

  • The onboard LEDs colour output is noticeable at this viewing angle (red glow indicates the system is powered on, a slight green flow overtop the red glow indicates data is being accessed).  This level of output was sufficient for the intended deployment...
Top view:


The tactical feel of the top of the unit make it suitable for storing a remote control on top.

Notes:  

  • The raspberry pi internals are not easily accessible from the top.  Unlike some of my other lego cases that feature a door for access, there was no need for easy access in the intended deployment..