oshw
Random thoughts and projects about Open Source Hardware
Categories:

Archives:
Meta:
October 2024
M T W T F S S
« Aug    
 123456
78910111213
14151617181920
21222324252627
28293031  
08/12/13
Raspberry Pi + wiringPi + 3Bpi
Filed under: OSHW, electronics.cat, Raspberry Pi, wiringPi
Posted by: @ 6:21 am

This post is a proof of concept using Raspberry PiwiringPi, 3Bpi and other OSHW boards

wiringPi is a GPIO Interface library for the Raspberry Pi written by Gordon Hedersonprojects.drogon.net).  It is designed to be familiar to people who have used the Arduino “wiring” system. And it is very friendly and convenient to use interfacing external boards to GPIO’s Raspberry Pi.

Video :

Code used in this video

To compile the code having installed wiringPi on Raspberry Pi :
gcc wPi00.c -o wPi00 -lwiringPi

Boards used in the video :
Raspberry Pi : Raspberry Pi
set05_08 : 3Bpi - Level translator board for Raspberry Pi
set05_02 : Relays Board
set01_04 : Inputs and Outputs (microswitch + LEDs)

In this specific sample, 3Bpi is used as a connector translator among boards. Translation between 3.3V and 5V is not required to drive outputs .

wiringPi can use different pin numbering. To translate by default pin numbering to 3Bpi ports I have used this global variables :

uint8_t byP2wPiMaster[] = {19,20,15,16}, byP2wPiSlave[] = {20,19,16,15};
uint8_t byP3wPi[] = {18,17,1,11,10,12,13,14};     /* [0]:LSB, [7]:MSB*/
uint8_t byP4wPi[] = {9,8,5,6,4,2,3,7};         /* [0]:LSB, [7]:MSB*/

And to define which pins are output or input I have used this notation (In this sample all the pins modes are outputs) :

#define P3_SETUP 0×00 /* 0 : Output, 1 : Input*/
#define P4_SETUP 0×00 /* 0 : Output, 1 : Input*/

Using these constants to call pinMode() :

    v3BpiP3pinMode(P3_SETUP);
    v3BpiP4pinMode(P4_SETUP);

Some electronics.cat’s boards are using nibbles to read inputs and to write outputs (for instance set05_02 Relays Board or set05_04 Input Board). For this reason these functions have been created :

void v3BpiP3digitalWrite(uint8_t by){
    v3BpiHighNibbleP3digitalWrite(by);
    v3BpiLowNibbleP3digitalWrite(by);
}

void v3BpiP4digitalWrite(uint8_t by){
    v3BpiHighNibbleP4digitalWrite(by);
    v3BpiLowNibbleP4digitalWrite(by);
}

These functions call to digitalWrite().

Code of this proof of concept can be downloaded clicking on this link.

Leave a Reply