Full documentation will be published in the next couple of days, but in the mean time, for those who have been lucky enough to receive the first interfaces, here’s a brief summary
Getting started with PiFace Digital
PiFace Digital is one of the quickest and easiest way to connect your Raspberry Pi to the real world. Follow this guide and you’re Raspberry Pi will be reacting to switches and controlling motors and lights in less than ten minutes!
- PiFace Digital features at a glance:
- 2 changeover relays
- 4 switches
- 8 digital inputs
- 8 open-collector outputs
- 8 LED indicators
- Easy to program in Python, Scratch and C
- Graphical emulator and simulator
Always disconnect the power before connecting anything to your Raspberry Pi or PiFace Digital.
Fitting the board
PiFace Digital sits neatly above the Raspberry Pi and connects using the expansion connector. Take care to ensure all expansion pins are lined up with the holes on the PiFace socket. Check the alignment for left and right and front and back and never force the boards together if they don’t slide smoothly.
The fastest way to get started is to download a prepared operating system image and copy it to an SD card. Images are available from http://pi.cs.man.ac.uk/download.
Alternatively, you can install the necessary libraries to your own Raspbian image with the instructions below.
Installing the software yourself in Raspbian
PiFace Digital communicates to the Raspberry Pi using the SPI interface. The SPI interface driver is included in the later Raspbian distributions but is not enabled by default. You can always enable the SPI driver, or you can load it by hand when required.
Always enabling SPI
To always enable the SPI driver:
- After logging in, edit /etc/modprobe.d/raspi-blacklist.conf
sudo nano etc/modprobe.d/raspi-blacklist.conf
- Insert a # at the start of the line containing blacklist spi-bcm2708
Alternatively, to load the SPI driver by hand (will not be loaded on reboot):
· Type in a terminal:
sudo modprobe spi-bcm2708
Next, you we need to install the PiFace Digital libraries and change the permissions of the SPI interface. The following script automates this into one command.
To install and setup the software, ensure your Pi can access the Internet and type:
sudo apt-get update
wget -O – http://pi.cs.man.ac.uk/download/install.txt | bash
The software will complete installing in a few minutes.
Reboot your Pi by typing:
After installing the software and restarting, login and startx.
Start the PiFace emulator by typing in a terminal:
1. To manually control the outputs, in the PiFace Emulator window, click Override Enable.
2. Toggle Output Pin 1 on by clicking on it. The PiFace interface will click as the relay turns on and the corresponding LED will illuminate. Notice the graphic onscreen updates to show the LED being on, the contacts have changed over on the relay and the first output pin is on.
The LEDs are in parallel with the outputs terminal connectors and indicate when the output is enabled.
1. We want to observe the inputs so click Keep inputs updated checkbox so the emulator reads the buttons and updates the screen. The interval sets how often the inputs are read, for most cases, it is fine to leave it on 500ms.
2. Press one of the buttons on the bottom left of PiFace. Notice how the onscreen representation changes to indicate the switch has been pressed.
First steps with Python
To use Piface with Python import the piface.pfio module:
Before use, the board must be initialised with a call to init() .
There are three main functions to control the interface
o returns 1 or 0 depending on the state of the input numbered pin_number
· digital_write(pin_number, state)
o sets the output numbered pin_number to state 0 or 1. State 1 turns the LED on and enables to open collector to sink current
· digital_write_pullup(pin_number, state)
o sets a 10k pullup on input numbered pin_number to be state 0 or 1. State 1 is pullup enabled