Pi3 B+ with Stretch - MCP3008 SPI Not working

Runtime
Anerdgy
2018-10-30
2018-11-02
  • Anerdgy

    Anerdgy - 2018-10-30

    Hi

    am trying to get the MCP3008 to work with the Pi3 B+ using teh MCP3008 sample project.

    Unfortunately not receiving any readings. The hardware is defintely OK as with a python script I can read the values normally.

    I am using Hardware SPI.

    SPI master and devices running.

    Thanks in advance

    Peter

    IMG: Capture1.PNG

     
  • eschwellinger

    eschwellinger - 2018-10-30

    Hi,
    since Stretch fullspeed SPI does not work - so you need to reduce it here.
    BR
    Edwin

    IMG: SPIMaxSpeed.jpg

     
  • Anerdgy

    Anerdgy - 2018-10-30

    Many thanks. That solved it. I'm curious as to why the hardware code using the Adafruit python code worked as I had not changed the SPI speed.

    Secondly, how do I change it to use the second SPI hardware pins? ie using a differnet GPIO as chip select, BCM19 pin 35 MISO, BCM20 pin 38 MOSI and BCM21 pin 40 SCLK as I will now purchase a canberry dual board to mount and it is already using the original SPI pins as well as CE0 and CE1. Maybe I could just use a different GPIO for chip select , but if it affects the timing, maybe easier to move all the MCP3008 work onto the second SPI pins.

    https://www.industrialberry.com/canberrydual-iso-v2-1/

    Many thanks

    Peter

     
  • Anerdgy

    Anerdgy - 2018-11-01

    Through trial and error it seems that the max SPI clock speed is 7.8Mhz. If I go higher eg 15.6Mhz, I get a reduced scale and it no longer reads the values correctly.

     
  • Anerdgy

    Anerdgy - 2018-11-01

    Enable SPI1 on the raspberry pi in the config.txt

    Then add another device under the SPI and change the SPI port and MaxSpeed (due to stretch issue), move the MCP3008 into it.

    And all works. You can change the CS pin as well on the pi.

    I found this link useful . https://terminal28.blogspot.com/2016/05/enabling-spi1-on-raspberry-pi-bzero23.html

    IMG: Capture2.PNG

     
  • eschwellinger

    eschwellinger - 2018-11-02

    Hi,
    thanks for this helpful information for the community, well appreciated.

    BR
    Edwin

     

Log in to post a comment.