The PI-SPI and PI-SPI-DIN series of modules enables the Raspberry Pi to be used in real world automation applications. Each series has 5 main components:
- Analog Input
- Analog Output
- Digital Input
- Relay (Digital) Output
Both series are very similar: The PI-SPI modules have the the same foot print as the RPi3, the PI-SPI-DIN series has DIN rail mounting capability and has a different powering scheme.
Various combinations of the PI-SPI-DIN modules can be combined together to create different types of automation measurement and control systems. Shown above is a system that has the main controller module with RS485, Real Time Clock, 16 Analog 4-20 mA Inputs, 8 Isolated digital inputs, 4 analog 4-20 mA outputs and 12 Relay Outputs. The main system power is provided by the 120VAC to 24 VDC DIN rail mounted power supply in the bottom right corner of the picture.
Sample Python Code
To get started, each PI-SPI-DIN I/O module has a simple test program written in Python. All programs were developed using a Raspberry Pi 3 module and Python 3 Idle that comes standard with the latest distro's.
Each module relies on the PI-SPI-DIN-LIB library file located here:
Each PI-SPI-DIN module (except for the 4AO Analog Output Module) has 5 Chip Select jumpers for the SPI communication. For the time being, the RPi kernal only supports 2 chip selects, CE0 and CE1 which are automatically controlled by the SPI driver.
To get around this limitation, in each of the Python programs listed below, CE0 is not used, even though SPI Port 0 is opened. By not using CE0 and manually controlling the GPIO pins assigned to the other Chip selects, more than 2 modules can be accessed from the SPI communications.
PI-SPI-DIN-8AI Analog Input Module
The PI-SPI-DIN-8AI has 4 different input configurations:
- 4-20 mA
- 0 to 5 VDC
- 0 to 10 VDC
- Temperature using 10K Thermistors (3380 Beta) and SteinHart-Hart Equation
Typically, the chip select is CE1 and the SPI port is 1 for the following sample Programs
Read 8 channels 4-20 mA
Read 8 channels 0 to 5 VDC
Read 8 channels 0 to 10 VDC
Read 8 channels Temperature in Dec C
PI-SPI-DIN-8DI Isolated Digital Input Module
The PI-SPI-DIN-DI module can accept either DC or AC Isolated inputs, typically 24 VDC/AC (Remove Jumpers J4 to Isolate the Inputs)
In cases where Isolated is not required and a field voltage is required for switch or contact inputs, leave the J4 jumpers installed. This will bring the applied field voltage to the field wiring terminal block positions COM and +V.
Each module has 4 addresses that are jumper selectable A0 and A1. With both jumpers installed the MCP23S08 address is "0", remove A0 jumper and the address is 1, etc. This allows up to 32 digital inputs (4 modules) from the same Chip Select.
Typically, the sample Python program uses CE2 and SPI port 0.
PI-SPI-DIN-4KO Relay Output Module
The PI-SPI-DIN-4KO has 4 relays with SPDT 2A contacts.
Each module has 4 addresses that are jumper selectable A0 and A1. With both jumpers installed the MCP23S08 address is "0", remove A0 jumper and the address is 1, etc. This allows up to 16 relay outputs (4 modules) from the same Chip Select.
Typically, the sample Python program uses CE3 and SPI port 0.
PI-SPI-DIN-4AO Analog Output Module
The Pi-SPI-DIN-4AO Analog Output Module has 4 channels of 4-20 mA (0 to 20 mA) and use the I2C bus. The Python sample code shows how to write all 4 channels or a single channel using the SMBUS.
The default address for the MCP4728 is 0x60. Up to 8 different addresses are available from 0x60 to 0x67 giving a total of 32 analog 4-20 mA outputs from one system.
The PI-SPI-DIN-RTC-RS485 is the main interface module for the PI-SPI-DIN series.
This module accepts 9 to 36 VDC and powers the RPi with a 5VDC 2.5A power supply via the GPIO interface cable. All modules connected to the PI-SPI-DIN GPIO port also get powered via the interconnect ribbon cable.
RS485 LCD Display Modules
All of the PI-SPI series of products have an RS485 option. Typically the RS485 is hard wired using the terminal blocks, these modules also have a RJ45 connector making connections to the VP-EC-RDU and VP-EC-RDU-MINI LCD displays a snap! by using standard Ethernet cables. Power to the LCD's are carried over the standard cable.
Sample code in Python is available for both displays:
These Python code examples work with both the PI-SPI-DIN series modules and the PI-SPI-RS485 module.
Sample code for RS485 applications in Python
Sample code for the Real Time Clock in Python.