I've seen a few threads on the topic of getting a MCP3008 to work with the RPI, but I've not found them helpful in resolving my issue. I'm using an RPI3 and have directly wired from the GPIO header to a breadboard with the MCP3008 on it. I'm testing the Adafruit demo code that reads out all 8 values, but everything appears as 0 for me. I have two inputs wired in on inputs 0 and 1. SPI is enabled on the RPI and have tried both software and hardware types of interfaces to the chip. I'm following the original demo setup with:
# Software SPI configuration:
CLK = 18
MISO = 23
MOSI = 24
CS = 25
mcp = Adafruit_MCP3008.MCP3008(clk=CLK, cs=CS, miso=MISO, mosi=MOSI)
To see what's going on, I wired into my MSO scope and attached the screenshot with labels added to the traces. I see communication being sent to the chip, but no response being sent. The product documentation for that chip describes certain CS values being toggled to get the chip talking, but I'm not seeing that. Does anyone have insights here?
thanks
Re: MCP3008 with output all 0?
What are these numbers? What program do you use? What is the actual wiring?
That's the Pi-3's pinout: https://pinout.xyz
SCLK: 11 (23)
MISO: 9 (21)
MOSI: 10 (19)
CE0: 8 (24)
In your screenshot, there is only a clock-pulse. No data is transmitted (neither sent nor received).
- DougieLawson
- Posts: 40533
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
- Contact: Website Twitter
Re: MCP3008 with output all 0?
It looks like the OP has used half of the SPI0 pins mixed with half of SPI1 ones.
https://pinout.xyz/pinout/spi
https://pinout.xyz/pinout/spi
Any language using left-hand whitespace for syntax is ridiculous
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Re: MCP3008 with output all 0? [RESOLVED]
The questions and suggestions helped resolve the issue which was incorrect wiring. The original instructions I was using were from the link below. I did not try to make software SPI work, but rather focused on hardware SPI along with the correct pins! Maybe it's just me, but I found the wiring instructions provided by Adafruit to be misleading and confusing.
https://learn.adafruit.com/raspberry-pi ... ftware-spi
thank you!
https://learn.adafruit.com/raspberry-pi ... ftware-spi
thank you!
- DougieLawson
- Posts: 40533
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
- Contact: Website Twitter
Re: MCP3008 with output all 0? [RESOLVED]
There's three naming conventions for one set of GPIO pins.CowboyWay wrote: ↑Tue Oct 17, 2017 11:32 pmMaybe it's just me, but I found the wiring instructions provided by Adafruit to be misleading and confusing.
https://learn.adafruit.com/raspberry-pi ... ftware-spi
There's "board numbering (BOARD)" that's pin#1 in the top left, pin#40 bottom right (next to the USB sockets) going odd numbers on the left, even numbers on the right.
There's "Broadcom numbering (BCM)" that's using the internal chip numbers which are exposed on the GPIO header in a higgledy piggledy order.
There's "Wiring Pi numbering" that's something invented by Gordon Henderson when he wrote his library that looks a bit like coding for an Arduino. Again the numbering is higgledy piggledy.
Code: Select all
pi@Challenger:~ $ gpio readall
+-----+-----+---------+------+---+---Pi 3---+---+------+---------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| | | 3.3v | | | 1 || 2 | | | 5v | | |
| 2 | 8 | SDA.1 | ALT0 | 1 | 3 || 4 | | | 5v | | |
| 3 | 9 | SCL.1 | ALT0 | 1 | 5 || 6 | | | 0v | | |
| 4 | 7 | GPIO. 7 | IN | 1 | 7 || 8 | 0 | IN | TxD | 15 | 14 |
| | | 0v | | | 9 || 10 | 1 | IN | RxD | 16 | 15 |
| 17 | 0 | GPIO. 0 | IN | 0 | 11 || 12 | 0 | IN | GPIO. 1 | 1 | 18 |
| 27 | 2 | GPIO. 2 | IN | 0 | 13 || 14 | | | 0v | | |
| 22 | 3 | GPIO. 3 | IN | 0 | 15 || 16 | 0 | IN | GPIO. 4 | 4 | 23 |
| | | 3.3v | | | 17 || 18 | 0 | IN | GPIO. 5 | 5 | 24 |
| 10 | 12 | MOSI | ALT0 | 0 | 19 || 20 | | | 0v | | |
| 9 | 13 | MISO | ALT0 | 0 | 21 || 22 | 0 | IN | GPIO. 6 | 6 | 25 |
| 11 | 14 | SCLK | ALT0 | 0 | 23 || 24 | 1 | OUT | CE0 | 10 | 8 |
| | | 0v | | | 25 || 26 | 1 | OUT | CE1 | 11 | 7 |
| 0 | 30 | SDA.0 | IN | 1 | 27 || 28 | 1 | IN | SCL.0 | 31 | 1 |
| 5 | 21 | GPIO.21 | IN | 1 | 29 || 30 | | | 0v | | |
| 6 | 22 | GPIO.22 | IN | 1 | 31 || 32 | 0 | IN | GPIO.26 | 26 | 12 |
| 13 | 23 | GPIO.23 | IN | 0 | 33 || 34 | | | 0v | | |
| 19 | 24 | GPIO.24 | IN | 0 | 35 || 36 | 0 | IN | GPIO.27 | 27 | 16 |
| 26 | 25 | GPIO.25 | IN | 0 | 37 || 38 | 0 | IN | GPIO.28 | 28 | 20 |
| | | 0v | | | 39 || 40 | 0 | IN | GPIO.29 | 29 | 21 |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+---------+------+---+---Pi 3---+---+------+---------+-----+-----+
pi@Challenger:~ $
Any language using left-hand whitespace for syntax is ridiculous
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.