Wednesday 9 October 2013

RPi GPIO & Armdroid Interface

GPIO stands for General Purpose Input/Output, and a GPIO pin can be set to logic high, or low, with a value of 1 or 0 respectively.  The Raspberry Pi can set pins to take either value and treat them as output, or it can detect a value as input.

The GPIO header on the Raspberry Pi consists of twenty-six pins, which include power (3.3v/5v/ground) and seventeen GPIO pins.  Some of these pins have special functions as well, we won't concern ourselves with these for now.

The GPIO pins operate at 3.3volts, which means we need to do some logic-level translation in order to interface our Armdroid.

To make the make the task of breaking out the GPIO pins easier on a breadboard, I'm going to use an Adafruit Pi Cobbler breakout kit.  I soldered up mine in about 10 minutes, but looks like you can now buy these ready assembled.


The layout of my Armdroid / Raspberry Pi interface circuit.

Armdroid / RPi interface - breadboard layout

IC1 & IC2 are 74HC4050  High Speed Hex non-Inverting Buffers
The header pins (see right-hand side) represent the Armdroid connector D1 - D8
Power is taken directly from the GPIO, we could use the power source from the Armdroid interface

The circuit works using two 74HC4050 as logic level translators, converting logic high 3.3v to 5v before continuing to the Armdroid's 8-bit Parallel Interface.   This design is not bi-directional, which means we cannot read the micro-switch sensors, but we'll revisit that later in time...

GPIO ASSIGNMENTS
PIN   GPIO       ARMDROID
11    0 (brown)     D1
12    1 (red)       D2
13    2 (orange)    D3
15    3 (yellow)    D4
16    4 (green)     D5
18    5 (blue)      D6
22    6 (purple)    D7
 7    7 (grey)      D8

This table gives the physical pin numbers of each GPIO channel and mapping to Armdroid notation.



The completed circuit on the breadboard:

Armdroid / RPi interface - prototype board

Armdroid / RPi interface - connection to Raspberry Pi


Testing
As mentioned in recent updates, the gpio command-line utility can be used to test the circuit.  The following example sets pin 0 to output mode, and then sets to logic High.

gpio mode 0 out
gpio write 0 1
By substituting pin numbers, we can test all 8 output lines on our circuit with a Digital Logic Probe





All that I need to do now is solder up my ribbon cable and connectors.... and work can commence on writing software....

No comments:

Post a Comment