Raspberry Pi - pins


First let's get familiar with the numbering/ labeling system of the pins on the board. There are two numbering conventions, one is as per the Broadcom SOC (called bcm here and everywhere else) and one as per the numbering printed on the board (simply called board).

The numbers in big bold towards the extremes of the diagram refer to the bcm naming convention , which is usually preferred since it remains the same throughout the various models. The numbering next to the colorful circles(i.e. the pins) are the number printed on the board.

You might argue why two different conventions, it is because the bcm refers to the internal(logical?) of the SoC while the board represents it's physical location .

Let us first understand the various data/bit transferring protocol before we talk about the individual pins.
  •  I2C
This protocol was found by Philips electronics and is popular for the reason that only two pins are required to connect to a device. It is the cousin of the SPI protocol. The addresses of the module is sent in a 7 bit hex format to the  module and once it matches communication takes place.t is also well supported by user-made libraries. There are many components designed to be used with I2C on Raspberry Pi. While it is slower than SPI, it still works fast enough for most day to day uses.


Much like SPI, the protocol has a master device, such as the Pi, and a slave device, such as a screen, shift register, or motor driver.

The first connection between the devices is the SCL (Serial Clock) which is set by the master to synchronize the transfer of data. The second line is the SDA (Serial Data) which transfers the data back and forth between all devices on the I2C bus.

The master device begins communication with a start bit, and a seven-bit hex address. This must match the slave device in order for them to communicate. This is how so many devices can be used with only two wires.

The master device then specifies whether it wants to read or write (R/W) the slave, before receiving an acknowledgment or ACK back.

  • SPI
SPI (or Serial Peripheral Interface) allows a microcontroller such as the Pi to communicate with over 100 peripheral components at once. The microcontroller acts as a “master” to all of the “slave” components, and can communicate with them at a high speed. This diagram outlines a simple SPI connection:
SCLK is the clock speed set by the master which determines the speed that information is shared between the devices.At each cycle (or “tick”) of the clock, both master and slave send and receive one bit of information. This is what the MOSI (Master Out Slave In) and MISO (Master In Slave Out) pins are for.

The SS or Slave Select pin (marked CE0 or CE1 on the Pi) is used to tell a slave device to communicate with the master—or not—at any given time. In most cases, each slave device requires its own SS pin, but can share the SCLK, MOSI and MISO pins.

Some devices can be “daisy chained” to share an SS pin, keeping the total pins used down to four, plus two for power and ground. SPI is known for being incredibly fast and is commonly used in shift registers or ADCs (Analogue to Digital converters) to pass data between devices.

https://www.makeuseof.com/tag/enable-spi-i2c-raspberry-pi/

  • UART

UART stands for Universal Asynchronous Receiver/Transmitter. It’s not a communication protocol like SPI and I2C, but a physical circuit in a microcontroller, or a stand-alone IC. A UART’s main purpose is to transmit and receive serial data.

In UART communication, two UARTs communicate directly with each other. The transmitting UART converts parallel data from a controlling device like a CPU into serial form, transmits it in serial to the receiving UART, which then converts the serial data back into parallel data for the receiving device. Only two wires are needed to transmit data between two UARTs. Data flows from the Tx pin of the transmitting UART to the Rx pin of the receiving UART:
UART is used to connect the bluetooth module or in scenarios where the board is supposed to be used in a header-less way(i.e. without the display)  .
UARTs transmit data asynchronously, which means there is no clock signal to synchronize the output of bits from the transmitting UART to the sampling of bits by the receiving UART. Instead of a clock signal, the transmitting UART adds start and stop bits to the data packet being transferred. These bits define the beginning and end of the data packet so the receiving UART knows when to start reading the bits. UART is used to connect the bluetooth module or in scenarios where the board is supposed to be used in a header-less way(i.e. without the display)  . The kernel of the board can be directly accessed via this port.

https://web.stanford.edu/class/cs140e/notes/lec4/uart-basics.pdf


  • PCM
PCM (Pulse-code Modulation) is a digital representation of sampled analog. On the Raspberry Pi it's a form of digital audio output which can be understood by a DAC for high quality sound.

It consists of FS which groups the bits into frames, CLK for synchronization and DIN/DOUT for input and output.

  • PWM
 PWM stands for ‘Pulse Width Modulation’. PWM is a method used for getting variable voltage out of constant power supply. used for connection motors and blinking leds.

It is not compulsory that the pins function as per the diagram above, they can be set to the alternative usage as shown below

 


There is one more resource i would like to share if you would like to know more about the pins (from Broadcom's perspective)

https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripherals.pdf

Comments

Post a Comment

Popular posts from this blog

PHP programming for DBMS

Raspberry Pi - introduction