14 Replies Latest reply on Apr 14, 2019 9:51 PM by cclegends

    PiFace connection

    cclegends

      Hi E14 community, I just received my PiFace Control and Display. After I connect them to the GPIO pins and nothing appears / pops up. I've done install the library as well as module. Upon running sys info.py, the errors are :

       

      Traceback (most recent call last):

        File "sysinfo.py", line 61, in <module>

          cad = pifacecad.PiFaceCAD()

        File "/usr/lib/python3/dist-packages/pifacecad/core.py", line 50, in __init__

          self.init_board()

        File "/usr/lib/python3/dist-packages/pifacecad/core.py", line 80, in init_board

          h=self.hardware_addr, b=self.bus, c=self.chip_select))

      pifacecad.core.NoPiFaceCADDetectedError: No PiFace Control and Display board detected (hardware_addr=0, bus=0, chip_select=1).

       

       

      Tried to search more information about this, other forums shows that the kernel update makes this display are not able to work. Is there any workaround to make this display working? Thanks.

        • Re: PiFace connection
          ralphjy

          The PiFace uses the SPI interface, so make sure that is enabled in the Raspi-config.  Also, make sure your chip_select jumpers. (JP1,JP2) are set correctly.  It seems odd that it is looking for chip_select=1 if you are only using a single PiFace board (usually defaults to 0).

           

          Have you tried the emulator to verify the software is installed correctly?

          4 of 4 people found this helpful
            • Re: PiFace connection
              cclegends

              Hi thanks for reply Ralph, I've checked and enabled the SPI interface in Raspi-Config. Is there any way to edit the value back to zero? 

                • Re: PiFace connection
                  ralphjy

                  I'm not sure why the default in core.py is for chip_select=1, but you can either edit this line in the file or you can change your jumpers.  If you change the jumpers then you will have to explicitly set the address when doing reads and writes.  I would edit the file unless you have multiple PiFaces.

                   

                   

                   

                  At the top of core.py:

                   

                       import pifacecommon.mcp23s17

                       import pifacecommon.interrupts

                       import pifacecad.lcd

                   

                       DEFAULT_SPI_BUS = 0

                      DEFAULT_SPI_CHIP_SELECT = 1

                       NUM_SWITCHES = 8

                   

                   

                  From your traceback, the file is /usr/lib/python3/dist-packages/pifacecad/core.py

              • Re: PiFace connection
                jomoenginer

                Try running through what is listed at the following.  This should verify the config.

                http://piface.github.io/pifacecad/installation.html#sysinfo-service

                 

                Have a look-see at the troubleshooting suggestion posted at the following

                https://github.com/piface/pifacecad/issues/24

                 

                I vaguely remember having to do this.

                • Re: PiFace connection
                  jomoenginer

                  This is what I have in the spi.py file

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

                   

                      
                  # 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)
                      
                  )
                  
                  
                  1 of 1 people found this helpful
                    • Re: PiFace connection
                      cclegends

                      Updates, Thanks Jon for the code modification. Now the display power ups and working but there is a little hiccup. Where it can't display free memory on the display. The tracebacks are :

                       

                      Traceback (most recent call last):

                        File "sysinfo.py", line 75, in <module>

                          show_sysinfo()

                        File "sysinfo.py", line 56, in show_sysinfo

                          cad.lcd.write(":{}".format(get_my_free_mem()))

                        File "sysinfo.py", line 35, in get_my_free_mem

                          used_mem = float(run_cmd(USED_MEM_CMD))

                      ValueError: could not convert string to float:

                        • Re: PiFace connection
                          jomoenginer

                          cclegends  wrote:

                           

                          Updates, Thanks Jon for the code modification. Now the display power ups and working but there is a little hiccup. Where it can't display free memory on the display. The tracebacks are :

                           

                          Traceback (most recent call last):

                            File "sysinfo.py", line 75, in <module>

                              show_sysinfo()

                            File "sysinfo.py", line 56, in show_sysinfo

                              cad.lcd.write(":{}".format(get_my_free_mem()))

                            File "sysinfo.py", line 35, in get_my_free_mem

                              used_mem = float(run_cmd(USED_MEM_CMD))

                          ValueError: could not convert string to float:

                          Is this working now?

                           

                          I inadvertently updated my config and ran into this issue as well.  I found the solution at the following:

                          https://github.com/piface/pifacecad/issues/27 
                          

                           

                          This is what I have in my sysinfo.py file

                          #USED_MEM_CMD = "free | grep '\-\/+' | awk '{print $3}'"
                          USED_MEM_CMD = "free | grep 'Mem' | awk '{print $3}'"
                          

                           

                          This is actually running on an older Pi B+ but I am still having an issue on a Pi 3 B+ with the sp.py entry.

                            • Re: PiFace connection
                              jomoenginer

                              On my Pi 3 B+ I ended up having to download the pifaceacad code from their github repo and run the setup install from that to get it to work.  Just running from apt-get loaded some older code that did not like the spi.py entry.

                               

                              This is what I had seen prior to loaded the code from the github repo.

                              python3 /usr/share/doc/python3-pifacecad/examples/sysinfo.py
                              Traceback (most recent call last):
                                File "/usr/share/doc/python3-pifacecad/examples/sysinfo.py", line 61, in <module>
                                  cad = pifacecad.PiFaceCAD()
                                File "/usr/lib/python3/dist-packages/pifacecad/core.py", line 50, in __init__
                                  self.init_board()
                                File "/usr/lib/python3/dist-packages/pifacecad/core.py", line 75, in init_board
                                  self.iocon.value = ioconfig
                                File "/usr/lib/python3/dist-packages/pifacecommon/mcp23s17.py", line 238, in value
                                  self.chip.write(v, self.address)
                                File "/usr/lib/python3/dist-packages/pifacecommon/mcp23s17.py", line 163, in write
                                  self._pyver_write(data, address)
                                File "/usr/lib/python3/dist-packages/pifacecommon/mcp23s17.py", line 167, in _py3write
                                  self.spisend(bytes((ctrl_byte, address, data)))
                                File "/usr/lib/python3/dist-packages/pifacecommon/spi.py", line 69, in spisend
                                  speed_hz=ctypes.c_uint32(self.speed_hz)
                              AttributeError: 'PiFaceCAD' object has no attribute 'speed_hz'
                              

                               

                               

                              It is working now on both a RasPi B+ and a RasPi 3 B+.

                              1 of 1 people found this helpful
                              • Re: PiFace connection
                                cclegends

                                Hi Jon, sorry for late updates. Thanks for the code, the screen is able to display and show the available memory.

                                jomoenginer  wrote:

                                 

                                cclegends   wrote:

                                 

                                Updates, Thanks Jon for the code modification. Now the display power ups and working but there is a little hiccup. Where it can't display free memory on the display. The tracebacks are :

                                 

                                Traceback (most recent call last):

                                  File "sysinfo.py", line 75, in <module>

                                    show_sysinfo()

                                  File "sysinfo.py", line 56, in show_sysinfo

                                    cad.lcd.write(":{}".format(get_my_free_mem()))

                                  File "sysinfo.py", line 35, in get_my_free_mem

                                    used_mem = float(run_cmd(USED_MEM_CMD))

                                ValueError: could not convert string to float:

                                Is this working now?

                                 

                                I inadvertently updated my config and ran into this issue as well.  I found the solution at the following:

                                https://github.com/piface/pifacecad/issues/27 
                                

                                 

                                This is what I have in my sysinfo.py file

                                #USED_MEM_CMD = "free | grep '\-\/+' | awk '{print $3}'"
                                USED_MEM_CMD = "free | grep 'Mem' | awk '{print $3}'"
                                

                                 

                                This is actually running on an older Pi B+ but I am still having an issue on a Pi 3 B+ with the sp.py entry.

                            • Re: PiFace connection
                              cclegends

                              jomoenginer  wrote:

                               

                              This is what I have in the spi.py file

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

                               

                                  
                              # 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)
                                  
                              )
                              
                              

                              Correct and Working