Let’s expand RaspberryPi functionalities with a shield that is compatible with the Arduino pinout and with an onboard analog to digital converter with 16-bit resolution. Further expansions that we will present in the future will allow you to add a DAC, a number of additional digital I/Os and the ability to connect also with non GPIO enabled boards.
Today we present an ADC shield that allows you to add to the possibility for a RaspberryPi to read from analog sensors. As we will see later in the article, this shield can be powered both 12V and 5V: it converts the voltage levels from 3.3V to 5V for the GPIO digital pins and the for the communication bus of i2 and SPI. In addition, this shield has both a GPIO compliant connector for RaspberryPi and the strips matching the typical Arduino microcontrollers and related shields.
Essentially, with this shield you can use RaspberryPi along with many of the already available Arduino shields or just share some pins to put a RaspberryPi and an Arduino microcontroller in communication.
Extend the functionality of the GPIO with a four-channel differential or single ADC converter, directly on the board and, with an additional shield, with an boost to 16 additional digital I/O plus a 4096 steps DAC.,
using 5V RaspberryPi power supply or external 5V to 12V power supplies for compatibility with the Arduino shield;
Converting 3.3V with 5V, and vice versa, from the I2C and SPI digital I/O buses to meet the electrical requirements of both RaspberryPi and the external sensors and devices
having the possibility to use the ADC converter with inputs both in differential and linear mode
having a 26-pin connector to connect GPIO to RaspberryPi
having connectors for directly connecting an Arduino board and the future shield we are going to release;
having connectors for additional external USB/i2C and USB / SPI converters .
Let’s analyze the wiring diagram to see how the requirements have been put to work in practice. We can start from the power supply, consisting a classical configuration based on the 7805 regulator. The capacitors filter and stabilize the output voltage. The EXT and INT jumpers allow you to choose whether to receive the 5V supply from pin 2 of the GPIO connector or from an external controller through the 7805 regulator. In this way it is possible to avoid an external power supply, when it not necessary. Pin 2 of the RaspberryPi is capable of delivering 500 mA in the A version and and 300 mA in version B. For shields and sensors with greater absorption or with shields requiring higher voltages as, for example, the relay shield, you must use an external power supply.
Now let’s check the level conversion circuits, which are manufactured using two different approaches.
Th conversion of the levels of the digital I/O pins is done using the TBX0108 integrated, an 8-bit level shifter with two power lines.
On the A side, you’find the lines coming from the GPIO RaspberryPi connector dubbed RPI in the diagram, on the B side you see the lines connected IOL and IOH connectores, mapping Arduino I/Os. GND is connected to ground, VCCA and VCCB are the voltage references for the conversion of levels and are connected to 3V and 5V lines; OE (Enable) enables the operation of the integrated when placed at high level then is connected to VCCA (Voltage 3,3V)..
The tableshows the correspondence between the RaspberryPi’s GPIO pins and Arduino pin connectors, the two sections of the table give the correspondences for both the configuration of the rev. 1 both and of the rev. 2.
RPI rev. 1
RPI rev. 2
In the TBX0108, voltage level conversion works in both directions automatically as the TBX0108 is able to determine the direction of data flows for each I / O pin (autosensing).
For what regards the I2C bus, SPI bus and serial port lines we choose a solution based on the BSS138 MOS- FET, N-channel field effect transistor in enhancement mode with a VGS threshold of 1.3 V.
The level conversion circuit is identical for each signal line. As an example we refer to the SDA line of the I2C bus. The gate (g) of the BSS138 MOS-FET (T7) is connected to the to 3.3 V power supply line, the source (s) is connected to the lower level signal line (3,3 V) and the drain (d) is connected to the higher level line (5V).
Let’s check now the ADC conversion for which we have chosen the Microchip MCP3428 .
In the ADC conversion we had to accept a little compromise in mapping the pins on the Arduino shield connectors. Arduino has six ADC inputs but two of these, pins A4 and A5 are shared with I2C inputs. In the Arduino environment, the different locations of the pins are programmatically configurable, according to the application. This possibility is not reproducible with the RaspberryPi, which is not natively equipped with ADC converter. In our case, we have adopted the external integrated circuit that communicates with the microcontroller via I2C, engaging related pins and leaving only four pins free for the ADC inputs. On the other hand MCP3428 allows conversions up to 16 bits of precision of both linear and differential signals.
For more detail: Expansion Shield for RaspberryPi compatible with Arduino