This year I got a very original Valentines day present – a PiFace for my Raspberry Pi. This is an interface board made by element 14, that sits on top of the Pi.
Fortunately I had fairly recently updated the Pi operating system to the latest version of Raspbian wheezy, so knew I did not have that to do before installing the PiFace
On opening the little box it came in there was the circuit board, and a leaflet that had health and safety info on it. Nothing else. Using a bit of initiative the board was fitted easily, making sure the Pi was turned off before fitting, though unfortunately it does not fit within the current plastic case, so will have to leave the top off.
Then I suppose with not having any instructions I tuned the Pi on and vaguely hoped that it would see the board. Sadly this was not the case, spoilt by too many plug n play add ons. So had do some searching as to how to install the PiFace.
(For ease of use I connect to my Pi via vncserver that I have preconfigured and set up. This allows me to connect to the Pi via a vnc viewer. I have ultravnc viewer http://www.uvnc.com/ on the laptop I am using for this.)
I found some instructions here http://piface.openlx.org.uk/174770794 for the PiFace, but they have minor errors. Though minor they do stop things working, so with further investigation this is what I did to get it working
sudo nano /etc/modprobe.d/raspi-blacklist.conf.
(The install instructions miss off the leading slash (/), so if the file that appears is empty, you need to add the slash before editing it).
Do a restart and then it is a good idea to make sure everything is up to date so run
sudo apt-get update.
Once everything is updated run
Then I ran (This is slightly different form the official instructions, but that did not work for me)
This takes a long time to run, certainly more time than it took to go and boil the kettle and drink a cuppa. Fortunately it shows you that it is working as it writes to the screen all that it is doing and there are pages and pages of it.
Once it had finished I did a restart for good measure. Then I ran the command
The emulator started and works fantastically well.
To Control an output via the emulator
Click Override Enable.
Click Output Pin 1 to enable it.
The PiFace interface will click as the relay turns on and the corresponding LED will illuminate. The screen updates to show the LED being on, the contacts have changed over on the relay and the first output pin is on.
All the LEDs are in parallel with the outputs terminal connectors and indicate when the output is enabled.
I then tried some simple Python commands – (Note I could only get this to work with Python 2 not Python 3)
To use Piface with Python import the piface.pfio module:
Then before use, the board must be initialised with a call to init()
There are three main functions to control the interface
digital_read(pin_number) - which returns 1 or 0 depending on the state of the input numbered pin_number
digital_write(pin_number, state) - which 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) - which sets a 10k pullup on input numbered pin_number to be state 0 or 1. State 1 is pullup enabled
Having got this far I was feeling quite pleased with myself, so thought I would try and get it working with Scratch – Mmmhhhmm!!
Lots more searching on the web for some instructions which work, and sadly I have to say I did not find any. From opening the box to giving up with scratch it had taken around 5 hours. I did notice a comment from a dad on one site I looked at who had said he had spent most of the previous weekend trying to get the PiFace working with scratch with his son. He did say that he had eventually succeeded but it had taken more than 12 hours. It was a shame he did not say what he did. Still this is my challenge for this next weekend.
Dyslexic doodles on photography, food (growing, cooking & of course eating), faith and other fascinating things. This is a personal blog expressing my views.