Released:
Sep 21, 2016 MCP3208 SPI ADC Interfacing with Raspberry Pi. September 21, 2016 November 14, 2017 Bikash Panda. The MCP3208 12-bit Analog-to-Digital Converter (ADC) combines high performance and low power consumption in a small package, making it ideal for embedded control applications. IC features a successive approximation register (SAR) architecture.
A python library for MCP3208
This is a python library designed to work with the MCP3208 ADC using SPI on a Raspberry Pi. The MCP3208 is capable of:
Maui meta 3g imei change download. The yellow color will appear in the circle if the device is successfully connected. Next switch off your phone and connect it with your computer using USB cable.
For more information, see the datasheet.
This chip uses SPI to interface with the Raspberry Pi. Basically, the chipreturns 12 bits contained in 3 bytes. You are able to read the MCP3208either LSB or MSB first.
Copyright (c) 2017 Kevin J. Walchko
Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the “Software”), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.
0.0.6
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size mcp3208-0.0.6-py2-none-any.whl (6.8 kB) | File type Wheel | Python version py2 | Upload date | Hashes |
Filename, size mcp3208-0.0.6-py3-none-any.whl (6.8 kB) | File type Wheel | Python version py3 | Upload date | Hashes |
Filename, size mcp3208-0.0.6.tar.gz (3.8 kB) | File type Source | Python version None | Upload date | Hashes |
Algorithm | Hash digest |
---|---|
SHA256 | bc5a116390669eb358d6004bf2cf72bf24d0c166c79caae813143fe940fe7c6b |
MD5 | 5640a99d44f7e626b41f807d61849b1b |
BLAKE2-256 | aa5d9e30d543d2b1ef521fd0bd45cb0009a5cfe0985a7306a37c32de68948452 |
Algorithm | Hash digest |
---|---|
SHA256 | 207068b4ba7779bd44b572b1ee69b0657dee49e1dd782e36dbcb8ed1b58ef1aa |
MD5 | 598bf377656bdeb13930a85713320abd |
BLAKE2-256 | 6340e86c28e68edb062e3c7c5e5e8047f1864c9694b91b31bb4163693c33956c |
Algorithm | Hash digest |
---|---|
SHA256 | 25249c16aefd460b1ffcbe281df3fddef21866970d1c5247b72c74b7dcb2f2be |
MD5 | 8968d12beb4fe37a672413b7860207b1 |
BLAKE2-256 | 58fbad4836951de44aea7c8865e84bdf68b255d7bf14f87ffaea3c5dd9360f18 |
The Raspberry Pi is equipped with one SPI bus that has 2 chip selects.
The SPI master driver is disabled by default on Raspbian. To enable it, use raspi-config, or ensure the line dtparam=spi=on
isn't commented out in /boot/config.txt
, and reboot. If the SPI driver was loaded, you should see the device /dev/spidev0.0
.
The SPI bus is available on the P1 Header:
WiringPi includes a library which can make it easier to use the Raspberry Pi's on-board SPI interface. Accesses the hardware registers directly.
This is a C library for Raspberry Pi (RPi). It provides access to GPIO and other IO functions on the Broadcom BCM 2835 chip. Accesses the hardware registers directly.
There's a loopback test program in the Linux documentation that can be used as a starting point. See the Troubleshooting section. Uses the Linux spidev
driver to access the bus.
The BCM2835 on the Raspberry Pi has 3 SPI Controllers. Only the SPI0 controller is available on the header.Chapter 10 in the BCM2835 ARM Peripherals datasheet describes this controller.
Signal name abbreviations
In Standard SPI master mode the peripheral implements the standard 3 wire serial protocol (SCLK, MOSI and MISO).
In bidirectional SPI master mode the same SPI standard is implemented, except that a single wire is used for data (MOMI) instead of the two used in standard mode (MISO and MOSI). In this mode, the MOSI pin serves as MOMI pin.
The LoSSI standard allows issuing of commands to peripherals (LCD) and to transfer data to and from them. LoSSI commands and parameters are 8 bits long, but an extra bit is used to indicate whether the byte is a command or parameter/data. This extra bit is set high for a data and low for a command. The resulting 9-bit value is serialized to the output. LoSSI is commonly used with MIPI DBI type C compatible LCD controllers.
Note:
Some commands trigger an automatic read by the SPI controller, so this mode can't be used as a multipurpose 9-bit SPI.
The CDIV (Clock Divider) field of the CLK register sets the SPI clock speed:
Errata: 'must be a power of 2' probably should be 'must be a multiple of 2'
See the Linux driver section for more info.
Setup and Hold times related to the automatic assertion and de-assertion of the CS lines when operating in DMA mode are as follows:
The default Linux driver is spi-bcm2708.
The following information was valid 2014-07-05. 20 crackling balls.
The driver supports the following speeds:
When asking for say 24 MHz, the actual speed will be 15.6 MHz.
Forum post: SPI has more speeds
Bidirectional or '3-wire' mode is supported by the spi-bcm2835 kernel module. Please note that in this mode, either the tx or rx field of the spi_transfer struct must be a NULL pointer, since only half-duplex communication is possible. Otherwise, the transfer will fail. The spidev_test.c source code does not consider this correctly, and therefore does not work at all in 3-wire mode.
Only interrupt mode is supported.
The following appears in the kernel log:
This thread discusses latency problems.
This is a fork of spi-bcm2708 which enables DMA support for SPI client drivers that support DMA.
https://github.com/notro/spi-bcm2708 (wiki)
This can be used to test SPI send and receive. Put a wire between MOSI and MISO. It does not test CE0 and CE1.