This product is designed to used with Raspberry Pi, which gives Raspberry Pi 5v GPIO, I2C and SPI handling capability. Further more, the onboard headers are placed in a way the same as Arduino UNO Rev3, which allow shields designed for Arduino could be directly plug onto this product without addtional wiring. As the Raspberry Pi has no ADCs onboard, an ADC chip is added to this product, now you can read analog voltage with your Pi. This product also has a 3.3V 0.5A LDO onboard, which convert the 5V coming from Raspberry Pi to 3.3V, this voltage is used by the onboard ICs, which will save the LDO on Raspberry Pi from over temperature.
- 3.3V/5V GPIO Capability
- 3.3V/5V I2C Capability
- 3.3V/5V SPI Capability
- Onboard ADC
- Stand alone 3.3V LDO
- Stand alone 5V SMSP
- All features are software programmable via I2C interface
RasPiDeck and Raspbery Pi Pin Map
Figure 1 Pin Map Sorted by Raspberry Pi IO
Figure 2: Pin Map Sorted by RasPiDeck IO
Figure 3: Pin Map Sorted by Alternative Function
Figure 4: Pin Map Sorted by Raspberry Pi P1 Connector
Hardware Techical Details
a. Power Supply
There are two power rails for this product. One is 3.3V and the other one is 5V. The 5V comes either from Raspberry Pi’s P1 connector or from the output of the onboard DC-DC SMPS which converts the voltage from the barrel connector to 5V. The 3.3V comes from the output of a 500mA LDO. As show in the pictures below:
Figure 5: DC-DC SMPS converts the voltage from barrel connector to 5V
The recommended voltage of the VIN(barrel connector) is 9VDC-12VDC.
Figure 6: 5V comes from Raspberry Pi’s P1 (Pin 2 and Pin 4)
The Q1 in Figure 6 limits the currect direction. It only allows currect drawn from Raspberry Pi but not allows current supply to Raspberry Pi.
The 5V is fed into the input of MIC5209, whose output is 3.3V. MIC5209 has an enable input and if Raspberry Pi’s 3.3V is below 2.5V, the LDO will be shutdown, as shown in the picture below.
Figure 7: 3.3V comes from MIC5209 with an enable input
b. Digital IO (D0-D13)
RasPiDeck has 14 GPIO in total, named D0-D13 and they are arranged in a way the same as Arduino UNO, which is shown in figure 8 below:
Figure 8: Position of the D0-D13 on RasPiDeck
Each IO has two operating mode, which could be selected via software:
- 3.3V input/output with 5V input tolerant capability
The mode selection is done by a voltage controlled SPDT analog switch SGM3157. An I2C IO expander chip, PCA9555, generates the signal used to control the analog switch. To select the working mode of the GPIO, user could set the output of PCA9555 via I2C by software. The structure of RasPiDeck’s GPIO is shown as below
Figure 9: Structure of a RasPiDeck digital D0-D10*
*NOTE: Please refer to the SPI section to see the structure of D11-D13
After POR, the switch will be on position 1. This is the 3.3V input/output mode with 5V tolerant capability.
In this mode, RaspDeck IO is connected to Raspberry Pi’s GPIO pin in series with a 100ohm resistor and a protection diode across the Raspberry Pi’s GPIO pin and its power rail, which is 3.3V. This will clamp the voltage on Raspberry Pi’s GPIO to 3.3V+0.7V , when a 5V is fed into RasPiDeck IO, and a 4V voltage is safe for Raspberry Pi’s vulnerable CPU. Though adding a 100ohm resistor will somehow slow down the rise/fall time, it will not be a problem in most cases.
If user set the output of PCA9555 to logic low, the swith in figure 9 will be in posion 2. This is the 5V output mode.
In this mode, once the output of Raspberry Pi’s GPIO is set high(3.3V), it will be translated to 5V by the buffer and then fed into RasPiDeck’s GPIO pin via the SPDT switch. The buffer is implemented with 74HCT244PW, which accepts 3.3V logic and outputs 5V logic.
c. Analog Input (A0-A5)
Analog read feature is implemented with ADS7828, which is a 12-Bit 50 kSPS ADC with I2C interface. Just like in Arduino, A0-A5 could also be used as digital IO. This feature is implemented with another I2C IO expander PCA9554. The structure of each IO pin is shown below.
Figure 10: Structure of RasPiDeck’s A0-A3 (x=0-3)
Figure 11: Structure of RasPiDeck’s A4
Figure 12: Structure of RasPiDeck’s A5
As shown in Figure 11 and Figure 12, the structure of A4 and A5 is a little bit different compared to A0-A3. User could config the A4 and A5 connect to I2C bus or to ADC and IO expander. On Arduino UNO, A4 and SDA are actually the same net with different alias. This is true for A5 and SCL, too. After POR, A4 and A5 are connected to SDA and SCL respectively, as is should be on Arduino UNO. Because some early designed shield for Arduino which use I2C as the communication interface use A4 as SDA and A5 as SCL. However, as the coming of the Arduino UNO rev3, there are dedicated breakout pins for SDA and SCL on the left-top header, most latest designs use the dedicated pins on the left-top of Arduino. If this is the case in application, user could set the IO6 of PCA9554 to LOW, which will disconnect the A4 and A5 from the I2C bus. This will set A4/A5 free to use as analog input or digital IO.
d. I2C Interface
Two TCA9406 I2C transceivers are used on RasPiDeck, one for onboard I2C chips (PCA9554, PCA9555, ADS7828), named transceiver A, and the other one for external shields or modules, named transceiver B. Transceiver A translate the level of the I2C bus from 3.3V to 5V, because all the onboard I2C interfaced chips(PCA9554, PCA9555, ADS7828) work on 5V rail. The output voltage of transceiver B could be configured to 3.3V or 5V to accommodate different offboard peripherals. Transceiver B could even be disabled, which will isolate onboard I2C bus from the offboard I2C bus. This feature is useful when the offboard peripheral does not support 400KHz clock. When operating the onboard chips at 400Khz, without the isolation, the offboard peripherals may be messed up by the unsupported high speed clock. The structure of RasPiDeck’s I2C interface is as shown below:
Figure 13: Structure of RasPiDeck’s I2C Interface
After POR, IO6 of PCA9555 will be HIGH so the SGM3001 will be on position NO, transceiver B will output a 3.3V as HIGH. If 5V I2C peripherals is connected to the offboard I2C bus, user should set IO6 of PCA9555 to LOW, which will set the switch to position NC.
To isolate the offboard I2C bus from the onboard one, user should set the CE1 pin of Raspberry Pi to LOW state, this will disable the transceiver B and set the offboard SCL and SDA to float.
Below are the 7-bit addresses of the onboard chips:
PCA9555 ——– 0x20
PCA9554 ——– 0x25
ADS7828 ——– 0x48
e. SPI Interface
On Arduino UNO The SPI pins are mutiplexed with D11-D13 of the digital IO pins. As you can see from figure 1, this is true on RasPiDeck too. MOSI, MISO, SCK are buffered by MAX3390E. The structure of the MOSI, MISO, SCK pins are shown in picture below:
Figure 13: Structure of RasPiDeck’s MOSI
Figure 14: Structure of RasPiDeck’s SCK
Figure 15: Structure of RasPiDeck’s MISO
On Arduino, D11-MOSI, D12-MISO, D13-SCK are actually the same net with different alias, however, on RasPiDeck they are in different net. On RasPiDeck, MOSI, MISO, SCK are broke out to ICSP headers and D11-D13 are broke out as shown on figure 8.
Just like the I2C interface transceiver B, the power supply of MAX3390E is selectable too. This could be done by setting the state of IO7 of PCA9555.
If the external shield uses the ICSP as the SPI pins, then it should be work right way after you correctly configured the SPI interface of Raspberry Pi.
If ther external shield uses the D11-D13 as the SPI pin and the shield is a 5V SPI device, then besides the proper configuraion of SPI, you may also need to configure the PCA9555 to let the MOSI and SCK to work in 5V output mode.
After POR, IO7 of PCA9555 is HIGH, this will set the power suply of MAX3390E to 3.3V. To communicate with an external 5V SPI device, user should set the IO7 of PCA9555 to LOW.
You can download the library HERE.
a. File Structure
The root directory of the libaray is named “RasPiDeck”, you should put all your sketches under this directory.
“\RasPiDeck\arduino\libraries\cores” contains library file adapted from arduPi.
“\RasPiDeck\arduino\Wire” contains libary file for I2C interface, which is adapted from arduPi too.
“\RasPiDeck\arduino\Peripherals” contains six files, and they are
i2cio.cpp and i2cio.h —- drivers for onboard PCA9554 chips
i2cio16.cpp and i2cio16.h —- drivers for onboard PCA9554 chips
Peripherals.cpp and Peripherals.h —– GPIO Logic level, I2C, SPI Transceiver API.
arduPi libaray enables users to write Arduino style code, it includes many function such as:
analogRead(), pinMode(), digitalWrite(), digitalRead(), delay()…etc. you can see all the details by click the hyperlink.
b. Peripherals.cpp and Peripherals .h
As arduPi gives users the possibility to write code like they are writing code on Arduino, RasPiDeck library provides addtional functions to change the output voltage level of GPIO, I2C, SPI, to enable/disable the onboard I2C, SPI transceiver.
Reset the onboard chips to their POR status.
Set the SPI transceiver logic level to 3.3v or 5v.
Enable Disable SPI transceiver.
Set the I2C transceiver logic level to 3.3v or 5v.
Enable/Disable I2C transceiver.
void RasPiDeckGPIO5v(int pin);
void RasPiDeckGPIO3v3(int pin);
Set the operating mode of GPIO to 5V output or 3v3 IO with 5v tolerant capability.
There is an example sketch in the root directory, named demo.pde, the sketch will blink a LED which is connected to RasPiDeck IO 3.
1. nano blink.pde — make modification to the sketch
2. ./arduino/build blink.pde — build the sketch
3. sudo ./blink — execute the sketch, which will blink the LED connected to RasPiDeck IO3 .