Rich2222
Posts: 1
Joined: Sat Jan 07, 2017 6:09 am

PiFace Digital 2 & RPi 3

Sat Jan 07, 2017 6:14 am

I hope this is the right forum....

I have seen a number of posts on the Web from people who say that they are running PiFace 2 Digital with a Raspberry Pi 3.
I have seen posts which say that it SHOULD work because "it uses I2C interface which is compatible back to the Model B+/A+"
I am looking for a definitive answer from someone who has this combination working.

This is the sequence I have used (http://www.piface.org.uk/guides/Install ... _Raspbian/)

- Newly formatted Sd Card
- Fresh Installation of Raspian (2016-11-25-raspbian-jessie)
- Updated Raspian (sudo apt-get update && sudo apt-get upgrade)
- Updated raspi-config (sudo apt-get install raspi-config)
- Selected SPI (sudo raspi-config)
- Installed PiFace™ Digital 2 software (sudo apt-get install python3-pifacedigitalio)
- Installed PiFace™ Digital 2 Emulator software (sudo apt-get install python3-pifacedigital-emulator)
- Rebooted Raspberry Pi

However, the emulator does not work and the blink script does not work

The board is not detected:

Traceback (most recent call last):
File "/home/pi/Desktop/blink.py", line 9, in <module>
pifacedigital = pifacedigitalio.PiFaceDigital()
File "/usr/lib/python2.7/dist-packages/pifacedigitalio/core.py", line 82, in __init__
self.init_board()
File "/usr/lib/python2.7/dist-packages/pifacedigitalio/core.py", line 107, in init_board
h=self.hardware_addr, b=self.bus, c=self.chip_select))
NoPiFaceDigitalDetectedError: No PiFace Digital board detected (hardware_addr=0, bus=0, chip_select=0).

Can someone help me (a new starter)?

joppep
Posts: 1
Joined: Wed Nov 08, 2017 7:50 am

Re: PiFace Digital 2 & RPi 3

Wed Nov 08, 2017 8:04 am

I had the same issue. It turns out (thanks to gam3t3ch ) that the later kernels for RPI3 uses an incompatible frequence for the SPI serial channel (basically it is higher than what PiFace Digital 2 can handle - lowering this makes the display work again, see more on this at https://github.com/raspberrypi/linux/issues/2165 )

You need to override the default frequency by changing the spi.py file included in the pifacecommon package as follows:

Depending on how you installed the support libraries it is either in the system folder or in your local library. Since I have installed the support modules locally mine are located at:

/usr/local/lib/python3.5/dist-packages/pifacecommon/spi.py

(and the corresponding python2 libraries if you use them as well)

The you need to find the transfer struct in spi.py and override the default frequency by changing the transfer setting from

Code: Select all

      # create the spi transfer struct
        transfer = spi_ioc_transfer(
            tx_buf=ctypes.addressof(wbuffer),
            rx_buf=ctypes.addressof(rbuffer),
            len=ctypes.sizeof(wbuffer) 
        )
to

Code: Select all

      # create the spi transfer struct
        transfer = spi_ioc_transfer(
            tx_buf=ctypes.addressof(wbuffer),
            rx_buf=ctypes.addressof(rbuffer),
            len=ctypes.sizeof(wbuffer),
            speed_hz=ctypes.c_uint32(100000) 
        )
Note the added setting for the speed_hz field.
For me this solves all problems I had with the board on newer kernels.

Return to “Automation, sensing and robotics”