0503-09 MCP3208 ADC
Example Projects > 0503 Generic SPI Communication > 0503-09 MCP3208 ADC
Reading MCP3208 ADC via SPI bus
This folder contains the source files for reading ADC data from the MCP3208 12-bit ADC via SPI bus, which is available e.g. on the Raspberry Pi minicomputer. The example is based on the REXLANG user-programmable function block.
The 12-bit data obtained from the ADC chip can be further converted to physical units using e.g. the LIN function block.
Timing of the project
The algorithm runs each 100 milliseconds (0.1 s). See the EXEC function block,
tick x ntick0 = 0.01 x 10 = 0.1
- RexCore must be installed and running on the target device (Raspberry Pi).
- SPI bus must be enabled and available (e.g. /dev/spidev0.0 on the Raspberry Pi)
- The wiring must comply with the attached datasheet.
Running the example
- The *exec.mdl file is the project main file.
- Open it with RexDraw.
- Specify the SPI bus by the "p0" parameter of the REXLANG function block.
- Compile and download the project to the target device.
- Switch to Watch mode and observe the algorithm in real-time.
- Apply external voltage to the ADC input pins and observe the received data.
- Press F1 for help on the selected function block in the REXYGEN Studio.
- Getting started with REXYGEN on the Raspberry Pi minicomputer
- Function blocks of REXYGEN
- MCP3208 datasheet (attached)
- REXYGEN Studio User Guide
- Complete documentation of REXYGEN