rpi-interface-board/rpi-scripts/interface_board_pins.py

113 lines
2.6 KiB
Python

# Pin mappings for GPIOs and other components specifically for the pi-interface-board_v1.0
# ======================
# === Digital Inputs ===
# ======================
# Pin mappings for digital inputs (labeled on housing as 1-8)
GPIO_DIGITAL_INPUTS = {
0: 25, # Dig-IN_1 is connected to GPIO_25
1: 16, # Dig-IN_2 is connected to GPIO_16
2: 26, # Dig-IN_3 is connected to GPIO_26
3: 13, # Dig-IN_4 is connected to GPIO_13
4: 6, # Dig-IN_5 is connected to GPIO_6
5: 5, # Dig-IN_6 is connected to GPIO_5
6: 22, # Dig-IN_7 is connected to GPIO_22
7: 24, # Dig-IN_8 is connected to GPIO_24
}
# ======================
# === Shift Register ===
# ======================
GPIO_SHIFT_REG_DATA = 27
GPIO_SHIFT_REG_LATCH = 17
GPIO_SHIFT_REG_CLOCK = 4
# FIXME: numbering in schematic is wrong (inverse) layout / terminal order matches the shift register though (left to right -> 0-7)
# Shift Register Channel Assignments
SHIFT_REG_CHANNEL_BUZZER = 0 # Buzzer connected to shift register channel 7
SHIFT_REG_CHANNEL_RELAY1 = 1 # Relay 1 connected to shift register channel 6
SHIFT_REG_CHANNEL_RELAY2 = 2 # Relay 2 connected to shift register channel 5
# ===============
# ===== ADC =====
# ===============
# ADC IC is connected to RPI SPI interface 0 (pins below)
ADC_SPI_BUS_NUM = 0
ADC_SPI_DEVICE_NUM = 0
ADC_SPI_CS_PIN = 8 # SPI Chip Select for MCP3208
# MISO_0: GPIO_9
# MOSI_0: GPIO_10
# SCLK_0: GPIO_11
# CE_0: GPIO# MCP3208 (ADC)
# Pin mappings for Terminal number to actual ADC channels (due to routing they do not match)
ADC_CHANNELS = {
0: 1, # Terminal 0 = ADC channel 1
1: 0, # Terminal 1 = ADC channel 0
2: 3, # ...
3: 2,
4: 5,
5: 4,
6: 7,
7: 6
}
# Alternative to ADC_CHANNELS list have separate constants for the channels (more intuitive)
ADC_CHANNEL_T0__0_TO_3V3 = 1
ADC_CHANNEL_T1__0_TO_3V3 = 0
ADC_CHANNEL_T2__0_TO_5V = 3
ADC_CHANNEL_T3__0_TO_5V = 2
ADC_CHANNEL_T4__0_TO_12V = 5
ADC_CHANNEL_T5__0_TO_12V = 4
ADC_CHANNEL_T6__0_TO_20MA = 7
ADC_CHANNEL_T7__0_TO_20MA = 6
# ====================
# === SPI Terminal ===
# ====================
SPI_BUS_NUM = 1
# MISO_1: GPIO_19
# MOSI_1: GPIO_20
# SCLK_1: GPIO_21
# CE_1: GPIO_7
# ====================
# === I2C Terminal ===
# ====================
GPIO_I2C_SDA = 2
GPIO_I2C_SCL = 3
# ===================
# === PWM outputs ===
# ===================
GPIO_PWM1 = 12 # RPI_PWM0
GPIO_PWM2 = 18 # RPI_PWM0 too
# ====================
# === UART / RS485 ===
# ====================
GPIO_UART_TX = 14 # RPI TXD
GPIO_UART_RX = 15 # RPI RXD
GPIO_UART_DIR = 23