Look for more at: http://www.bartbania.com/
Just recently I got a PiFace Digital from Farnell. PiFace Digital is an interesting Raspberry Pi add-on board.
It features 8 digital inputs, and 8 open collector outputs, as well as 2 relays (NOTE: though the relays are rated at 250v at 10Amps, the PiFace board will support up to 20V, the relays are designed to only run at 5V). According to the official description, allows you to sense and control the real world. To be honest, this pretty much sums up the documentation for the product, or rather - lack of it. For now, I suppose, as it's a rather fresh project.
If you are a real beginner and find yourself buying this add-on, beware - you are almost on your own. You don't get anything with the PiFace apart from a safety note and some stickers in the box. The official documentation is not that easy to obtain. I had to google a lot through misleading webpages to finally get to it. What I have found, terrified me: PiFace Digital Quick Start Guide. It literally says you nothing about the board and you are still in the dark. I say that for a £26 product, it's description, accessibility, usage examples, tutorials and documentation in general, are REALLY limited. Of course, one may argue it's nothing technical, you just connect a wire, power source, robot chicken or any other low-voltage stuff and that's it! Easy-peasy-lemon-squeezy!
Fortunately, there is the Get Started guide, that tells you a bit more about the gadget and gives some limited usage examples. All in all, it is a useful and interesting add-on and you might want give it a try after familiarizing yourself with Python a bit (or any other coding language for that matter; I've found C and Java libraries). There is an official github repository, as well as nice documentation for Python. Also, Gordon@Drogon created a wiringPiFace library to work with his wiringPi.
My Feelings
After one day of shovelling the Google junk in search for useful information about the board (I've found about 20 so-so pages saying the same thing over and over again - how to install the libraries), I've decided to abandon my search and try something on my own. I've installed the PiFace libraries:
sudo apt-get update
wget http://pi.cs.man.ac.uk/download/install.txt
chmod +x install.txt
./install.txt
Sipped coffee while waiting for the installation to finish (quite a lot of things to be installed), halted my Pi, carefully attached the PiFace to the GPIO pins (it's always better to switch off the Pi when attaching anything) and ran the PiFace "emulator", which also controls the PiFace from desktop application:
piface/scripts/piface-emulator
It's a small interface letting you control the outputs on the board. Click... click... It works.
Coding
The Python documentation became very useful tool for learning (as most documentations do). I've tried it a bit in the Python console, and, becoming a bit bored with the PiFace (it was the first time I got bored with RasPi!!!), I've wrote two simple scripts to toggle LEDs on/off (which could have been done with the use of Raspberry's GPIO itself...). The first one:
#!/usr/bin/python
from time import sleep
import piface.pfio as p
p.init()
while True:
p.digital_write(0,1)
sleep(0.25)
p.digital_write(1,1)
sleep(0.25)
p.digital_write(2,1)
sleep(0.25)
p.digital_write(2,0)
sleep(0.25)
p.digital_write(1,0)
sleep(0.25)
p.digital_write(0,0)
sleep(0.25)
And a demo:
And a second one, doing the same exact thing with more LEDs (clumsy, dirty, lazy, loooooooooong code):
#!/usr/bin/python
from time import sleep
import piface.pfio as p
p.init()
while True:
p.digital_write(0,1)
sleep(0.25)
p.digital_write(1,1)
sleep(0.25)
p.digital_write(2,1)
sleep(0.25)
p.digital_write(3,1)
sleep(0.25)
p.digital_write(4,1)
sleep(0.25)
p.digital_write(5,1)
sleep(0.25)
p.digital_write(6,1)
sleep(0.25)
p.digital_write(7,1)
sleep(0.5)
p.digital_write(2,0)
sleep(0.25)
p.digital_write(6,0)
sleep(0.25)
p.digital_write(7,0)
sleep(0.25)
p.digital_write(1,0)
sleep(0.25)
p.digital_write(4,0)
sleep(0.25)
p.digital_write(0,0)
sleep(0.25)
p.digital_write(5,0)
sleep(0.25)
p.digital_write(3,0)
sleep(1)
Nothing fancy, as I said, I got a bit disinterested with the project. I did, still, test combining input/output interrupts (pressing a switch lights up an LED), but it was only a brief python console test:
>>> import pifacedigitalio as p
>>> p.init()
>>> pfd = p.PiFaceDigital()
>>> def led0_on(event):
... pfd.leds[0].toggle()
...
>>> listener = p.InputEventListener()
>>> listener.register(0, p.IODIR_ON, led0_on)
>>> listener.activate()
I still intend to do something practical with the use of PiFace (definitely not a shaking talking chicken) and enable the relays to control, say, night-stand light, LED morning wake-up bed lights to illuminate walls on the dull winter mornings... For now, I'm testing, getting to know the equipment and learning how to use it.
PiRack - the PiFace companion
The PiFace PiRack is a relatively new product. Not yet fully tested and developed I guess, PiRack is an expansion board allowing the connection of up to 4 I/O boards to the Raspberry Pi. It can be daisy-chained, allowing multiple PiRack to be connected together. It's just a simple expansion board, yet it's brilliant in it's simplicity. It can also be powered separately to the Raspberry Pi with 5V power supply which means that it will not effect Pi's performance. However, be prepared to get a power supply with 2.1mm x 5.5mm barrel plug, as the connector is big. I think it'd be better to get rid of this big connector and replace it with microUSB port for power supply.
The only documentation that comes with the PiRack is a PiFace PiRack Regulatory Compliance and Safety Information - a small leaflet with unclear instructions.
I had some problems with getting it work with the PiFace Digital itself, though it works great with other components I already have, including PiBorg LedBorg and breadboard with sensors, and my LCD Monitor without any changes to the PiRack, yet getting it work out of the box with the PiFace is a bit more complicated. The guys from element14 also told me they also , but in their case it's getting 4 PiFaces work on the PiRack. I've ofund a simple solution. The PiRack, apart from RPi/external power jumpers, has jumpers to swap SPI CS lines. In my case, they simply had to be swapped from the default position:
And the PiFace sitting on the PiRack started responding to Python commands!
The product is still under development and testing. In fact, there is a PiRack Connect Four Challenge where you create a project using the PiRack and any combination of up to four compatible devices, create a blog entry on element14 community pages and could win Arduino Robot Development Kit! You have time till October 18, 2013, so why not give it a try?
Useful PiFaced links
If you want to get more out of PiFace, though in limited amount, check those websites:
- PiFace Digital Get Started Guide
- PiFace documentation for Python
- Github repository
- WiringPiFace
- Small about page
- element14 PiFace microsite
- PiFace WordPress something
PiFaced PROJECTS
- ARM - Setting up PiFace on Raspberry Pi
- PiFace - The basics
- A Facefull of Pi: Working with Pi Face
- Getting Started with a PiFace Interface Card
- Building a remote control vehicle using a Raspberry Pi
- Controlling Piface with Python Script
- Door Answering System Project (PDF)
- Hall's House of Pi PiFace Software
- The Gadget Show: RPi + PiFace Ice Cream Maker