Ligne 42 : |
Ligne 42 : |
| Voici le détail du montage | | Voici le détail du montage |
| | | |
− | [[Fichier:Pi-MCP3008-Analog.jpg]] | + | In order to read analog data we need to use the following pins: |
| + | * VDD (power), DGND (digital ground) to power the MCP3008 chip. |
| + | |
| + | We also need four 'SPI' data pins: |
| + | * DOUT (Data Out from MCP3008), |
| + | * CLK (Clock pin), |
| + | * DIN (Data In from Raspberry Pi), |
| + | * and /CS (Chip Select). |
| + | |
| + | Finally of course, a source of analog data, we'll be using the basic 10k trim pot. |
| + | |
| + | The MCP3008 has a few more pins we need to connect: AGND (analog ground, used sometimes in precision circuitry, which this is not) connects to GND, and VREF (analog voltage reference, used for changing the 'scale' - we want the full scale so tie it to 3.3V) |
| + | |
| + | Below is a wiring diagram. Connect the 3.3V cobbler pin to the left + rail and the GND pin to the right - rail. Connect the following pins for the MCP chip |
| + | |
| + | * MCP3008 VDD -> 3.3V (red) |
| + | * MCP3008 VREF -> 3.3V (red) |
| + | * MCP3008 AGND -> GND (black) |
| + | * MCP3008 CLK -> #18 (orange) |
| + | * MCP3008 DOUT -> #23 (yellow) |
| + | * MCP3008 DIN -> #24 (blue) |
| + | * MCP3008 CS -> #25 (violet) |
| + | * MCP3008 DGND -> GND (black) |
| + | |
| + | Next connect up the potentiometer: |
| + | * Pin #1 (left) goes to GND (black), |
| + | * Pin #2 (middle) connects to MCP3008 CH0 (analog input #0) with a gray wire, |
| + | * and #3 (right) connects to 3.3V (red) |
| + | |
| + | Advanced users may note that the Raspberry Pi does have a hardware SPI interface (the cobbler pins are labeled MISO/MOSI/SCLK/CE0/CE1). The hardware SPI interface is super fast but not included in all distributions. |
| + | |
| + | For that reason we are using a bit banged SPI implementation so the SPI pins can be any of the raspberry pi's GPIOs (assuming you update the script). |
| + | |
| + | [[Fichier:Pi-MCP3008-Wiring.jpg]] |
| | | |
| Source: AdaFruit.com | | Source: AdaFruit.com |