1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

RPi + Other Software Use SPI Chip Select

Discussion in 'Hardware Support' started by ScarletStar, 2 August 2016.

  1. Andrey Popov

    Andrey Popov New Member

    Messages:
    22
    Hardware:
    RPi2, +Arduino
    I have RPi2 with connected nrf24 - I use it as smart home server, which receives signals from different sensors and devices.

    Can u post here very detailed instruction for noobies, how to connect nrf24 with hyperion.
     
  2. penfold42

    penfold42 Active Member

    Messages:
    746
    Hardware:
    RPi1/Zero, RPi2, RPi3, 32/64bit, +Arduino, +nodeMCU/ESP8266
    What led strip do you have ?
     
  3. Andrey Popov

    Andrey Popov New Member

    Messages:
    22
    Hardware:
    RPi2, +Arduino
    WS2801 too !

    Current wiring for nrf24 is:
    1 GND -> 25 (GND)
    2 VCC -> 17 (3.3V)
    3 CE -> 22 (GPIO 25)
    4 CSN -> 24 (GPIO 8 SPI_CE0)
    5 SCK -> 23 (GPIO 11)
    6 MOSI -> 19 (GPIO 10)
    7 MISO -> 21 (GPIO 9)
    8 IRQ

    For hyperion I should use:
    GPIO 11 SCK
    GPIO 10 MOSI

    Please, help me to use both devices!

    2016-08-29_13-45-34.png 2016-08-29_13-46-28.png
     
    Last edited: 29 August 2016
  4. penfold42

    penfold42 Active Member

    Messages:
    746
    Hardware:
    RPi1/Zero, RPi2, RPi3, 32/64bit, +Arduino, +nodeMCU/ESP8266
    What 74hct series chips do you have at hand ?
     
  5. Andrey Popov

    Andrey Popov New Member

    Messages:
    22
    Hardware:
    RPi2, +Arduino
    Actually I dont have. I can order this: link to aliexpress

    I found many different chips at my local store. I can buy anyone.

    Which one was tested?
    2016-08-29_14-55-11.png
     
    Last edited: 29 August 2016
  6. penfold42

    penfold42 Active Member

    Messages:
    746
    Hardware:
    RPi1/Zero, RPi2, RPi3, 32/64bit, +Arduino, +nodeMCU/ESP8266
    74hct125 is cleanest
    74hct138 can also work

    Do you know they're a collection of surface mount parts ? What we your soldering skills like ?
     
  7. penfold42

    penfold42 Active Member

    Messages:
    746
    Hardware:
    RPi1/Zero, RPi2, RPi3, 32/64bit, +Arduino, +nodeMCU/ESP8266
    Actually I'm not sure that the 138 will work - I need to think some more.

    The 125 definitely will
     
  8. ScarletStar

    ScarletStar New Member

    Messages:
    13
    Hardware:
    RPi1/Zero, +Arduino, +PhilipsHue
    I used the 74AHCT125D
    It's SMD, my local shop only had those in SMD.
    As penfold said though its important to use the T variant, so it will have TTO compatible threshold voltages.
    The other conditions the chip needs to fulfill are 5V VCC so it can act as a level shifter, taking the 3.3V logic signals from the RaspberryPi and outputting 5V for the LED strip.
    And an active low output enable pin because the Chip select pins are active low.

    1 GND -> 25 (GND)
    2 VCC -> 17 (3.3V)
    3 CE -> 22 (GPIO 25)
    4 CSN -> 24 (GPIO 8 SPI_CE0)
    5 SCK -> 23 (GPIO 11)
    6 MOSI -> 19 (GPIO 10)
    7 MISO -> 21 (GPIO 9)
    8 IRQ

    Wiring for the WS2801:
    1 GND -> GND
    2 DI -> Raspberry PI GPIO 10 (SPI_MOSI)
    3 CI -> 74AHCT 1Y (output1)
    2 VCC -> 5V

    Wiring for the 74AHCT:
    1 1/OE (output enable not 1) -> GPIO7 SPI_CE1
    2 1A (input 1) -> Raspberry PI GPIO 11 SPI_SCLK
    3 1Y (output 1) -> WS2801 CI (Clock In)
    7 GND -> GND
    14 VCC -> 5V


    In the Hyperion Config be sure to set spidev0.1 since the WS2801 will be connected to CE1.
     
  9. Andrey Popov

    Andrey Popov New Member

    Messages:
    22
    Hardware:
    RPi2, +Arduino
    1. Do I need to use resistors in this circit?

    2. So both NRF24 and LED connect to one pin?
    2 DI -> Raspberry PI GPIO 10 (SPI_MOSI)
     
  10. ScarletStar

    ScarletStar New Member

    Messages:
    13
    Hardware:
    RPi1/Zero, +Arduino, +PhilipsHue
    No resistors.
    Yes:
    GPIO10 MOSI will be connected to both WS2801 and NRF24
    GPIO11 SCLK will be connected to both 74AHCT and NRF24

    The raspberrypi will use the CE0 and CE1 pin to tell which one of the devices will listen.
     
  11. Andrey Popov

    Andrey Popov New Member

    Messages:
    22
    Hardware:
    RPi2, +Arduino
    No such kind of chip in my country, so I ordered it from aliexpress. 1 month to wait )
    Thank u guys!
     
  12. Andrey Popov

    Andrey Popov New Member

    Messages:
    22
    Hardware:
    RPi2, +Arduino
    I leave it here:

    2016-08-29_15-56-12.png
     
  13. Andrey Popov

    Andrey Popov New Member

    Messages:
    22
    Hardware:
    RPi2, +Arduino
    Finally I received this chip. Guys, is that right position? Bottom-Left -> GND ? I don't understand
    chip.png

    Left side is more bevelled

    I made my first prototype, looks like crap)
    2016-09-26_19-02-07.png
     
    Last edited: 26 September 2016
  14. Andrey Popov

    Andrey Popov New Member

    Messages:
    22
    Hardware:
    RPi2, +Arduino
    I made this wiring scheme, tomorrow I will try to connect all these things:)
    [​IMG]
     
  15. ScarletStar

    ScarletStar New Member

    Messages:
    13
    Hardware:
    RPi1/Zero, +Arduino, +PhilipsHue
    Looks good. I think the top is the side with the long strip printed on it. So yeah should be right.

    Which library are you using for the NRF btw? I can't seem to get mine working, always crashes with TMRh20 RF24 library.
     
  16. Andrey Popov

    Andrey Popov New Member

    Messages:
    22
    Hardware:
    RPi2, +Arduino
    TMRh20 RF24 + NRF24 Network
    It crashes sometimes as well. But these crashes are predictable, and I use linux "forever" to restart my init.d script
     
  17. Andrey Popov

    Andrey Popov New Member

    Messages:
    22
    Hardware:
    RPi2, +Arduino
    Guys! Finally my hyperion works with OSMC and spidev0.0

    Now the next step - adding nrf24
    I connected 74ACT - nrf24 works correctly as before. But hyperion through spidev0.1 gives me kernel panic every time when I setColor
    It looks like it has conflict.

    What can you advice me?

    [​IMG]
     
  18. penfold42

    penfold42 Active Member

    Messages:
    746
    Hardware:
    RPi1/Zero, RPi2, RPi3, 32/64bit, +Arduino, +nodeMCU/ESP8266
    Oops...

    The kernel shouldn't do that ever - it's a kernel bug.

    Hyperion doesn't do anything weird or low level. We only use the normal user space spi interface. We do however write large chunks of data (num_leds * 3 * 4) every update.

    I wonder if the kernel is failing to check that a previous transfer has finished before the other consumer tries to access what is really a shared hardware resource.

    What if you drop the Hyperion led count to 1?
     
  19. Andrey Popov

    Andrey Popov New Member

    Messages:
    22
    Hardware:
    RPi2, +Arduino
    Do u mean software limit to 1 ?

    I checked kernel logs. Found these strings:

    Oct 17 09:42:58 raspberrypi kernel: [ 298.757680] spidev spi0.1: SPI transfer timed out
    Oct 17 09:42:58 raspberrypi kernel: [ 298.762156] bcm2835-dma 3f007000.dma: DMA transfer could not be terminated
     
    Last edited: 17 October 2016
  20. penfold42

    penfold42 Active Member

    Messages:
    746
    Hardware:
    RPi1/Zero, RPi2, RPi3, 32/64bit, +Arduino, +nodeMCU/ESP8266
    Reconfigure Hyperion to only have 1 led.

    This will shorten the transmission time and maybe the issue will go away.
    It doesn't help you in the end but may help in isolating cases that do/don't work.

    Logs look interesting - and point in the direction of my theory