Actions

KAmod RPI RS485 X2

From Kamamilabs.com - Wiki

Description

KAmod RPI RS485 X2 - Dual RS485 Interface Module for Raspberry Pi

KAmod RPI RS485 X2 allows for easy expansion of Raspberry Pi 5 minicomputers with two RS485 interfaces. The interfaces include extensive protection circuits and are galvanically isolated from the control circuits, which guarantees operational stability and resistance to interference and failures. The module is designed to be compatible with the Raspberry Pi series boards, not just version 5. It is controlled via the SPI interface available on the 40-pin RPi GPIO connector, as well as on many other boards, e.g., Arduino, STM32, etc.



Basic Parameters

  • 2 RS485 interfaces controlled by the SC16IS762 controller (SPI→2xUART)
  • RS485 interfaces equipped with ST485 type transceivers
  • RS485 interfaces are galvanically isolated from control circuits
  • Possibility to connect 120 Ω termination resistors to each interface line
  • Maximum communication speed of RS485 interfaces: 500 kbps
  • Controlled via SPI interface operating at 3.3 V
  • Automatic transmission direction control for RS485 transceivers
  • 5 V / 0.2 A power supply taken from the Raspberry Pi board or an additional source
  • Easy mounting on Raspberry Pi 5, also in the version with the RPi Active Cooler heatsink
  • Module dimensions: 65x56 mm, height approx. 15 mm (plus connector under the board with a height of approx. 13 mm)



Standard Equipment

Code Description
KAmod RPI RS485 X2

Assembled and tested module

Mounting Kit

Set of screws and spacers for attaching the HAT to the Raspberry Pi board



Block Diagram



Electrical Schematic



RS485 Interfaces


Interface Element Function
RS485-1

R1J3
Phoenix MC 3.81 mm connector

Main RS485-1 bus connector,

pin 1 – GND
pin 2 – B(-)
pin 3 – A(+)

R1J4
3x1 goldpin header, 2.54 mm
Additional RS485-1 bus connector,

pin 1 – GND
pin 2 – B(-)
pin 3 – A(+)

R1J2

3x1 goldpin pins, 2.54 mm

Connects a 120 Ω termination resistor to the RS485-1 bus lines
when the jumper is placed on pins 2-3
RS485-2 R2J3
Phoenix MC 3.81 mm connector
Main RS485-2 bus connector,

pin 1 – GND
pin 2 – B(-)
pin 3 – A(+)

R2J4

3x1 goldpin header, 2.54 mm

Additional RS485-2 bus connector,

pin 1 – GND
pin 2 – B(-)
pin 3 – A(+)

R2J2

3x1 goldpin pins, 2.54 mm

Connects a 120 Ω termination resistor to the RS485-2 bus lines
when the jumper is placed on pins 2-3




The RS485 interfaces are controlled by ST485 type transceivers with galvanically isolated control signals. The bus lines are marked as: A(+), B(-), and GND ground, and are available on the Phoenix MC type connector (R1J3, R2J3) and on standard 2.54 mm goldpin pins (R1J4, R2J4). Their layout is shown in the figure and described on the bottom side of the module board. The RS485 bus lines are equipped with overvoltage protection circuits.
Additionally, placing a jumper on pins 2-3 of RxJ2 connects a 120 Ω termination resistor between lines A and B of the respective interface.


RS485 Interface Control

The RS485 interfaces are implemented via the SC16IS762 controller, a detailed description of which is available in the manufacturer's documentation. The controller is driven via the SPI interface (MISO, MOSI, SCLK, CE) and additionally generates an IRQ interrupt signal. The operating mode of the RS485 transceivers can be controlled by the EN CH1 and EN CH2 signals.

Control Signal Function Default Connection Optional Connection (*)
MOSI SPI data input for SC16IS762 controller GPIO10 - MOSI0
pin 19, JP2
GPIO20 - MOSI1
pin 38, JP5
MISO SPI data output for SC16IS762 controller GPIO09 - MISO
pin 21, JP1
GPIO19 - MISO1
pin 35, JP4
SCLK SPI clock signal input for SC16IS762 controller GPIO11 - SCLK0
pin 23, JP3
GPIO21 - SCLK1
pin 40, JP6
CE SPI chip enable input for SC16IS762 controller GPIO08 - CE0
pin 24, JP7
GPIO18
pin 12, JP9
IRQ IRQ interrupt output from SC16IS762 controller GPIO25
pin 22, JP8
GPIO24
pin 18, JP10
EN CH1 Signal switching RS485-1 transceiver from receive mode (L) to transmit mode (H) GPIO04
pin 7, JP12
GPIO27
pin 13, JP11
EN CH2 Signal switching RS485-2 transceiver from receive mode (L) to transmit mode (H) GPIO17
pin 11, JP16
GPIO22
pin 15, JP15



All control signals are routed to the J2 connector (40-pin, compatible with Raspberry Pi boards). The default connection redirects control signals to the SPI-0 interface pins of the Raspberry Pi. In addition to the default connection, each signal can be redirected to an optional connection (SPI-1 interface signals of Raspberry Pi boards) by changing the connections on the SMD jumpers JP1…JP18. To change the connection configuration, cut the connection between the pads of one jumper and use a drop of solder to connect the pads of the other jumper for a given signal. The default and optional connection configurations are described in the table and on the bottom side of the board.

Additionally, control signals are routed to the J1 connector. Their arrangement is shown in the figure and described on the bottom side of the KAmod RPI RS485 X2 board.



Power Supply

Element Function
J1 Connector 5 V power can be supplied to the J1 connector while maintaining correct polarity.

The power lines are common for both J1 and J2 connectors, so care must be taken not to interfere with the base board operation.

J2 Connector Power for the KAmod RPI RS485 X2 module is taken from the base board via the J2 connector. It is compatible with the Raspberry Pi 40-pin GPIO standard and features 5 V power lines.
D1 Diode Glowing D1 LED indicates the presence of power


The arrangement of connectors and the signaling diode is shown in the figure.



Signaling Indicators

Indicator Function
PWR
(D1)
Glowing D1 LED indicates the presence of power
RX
(D3, D6)
Flashing LED indicates receiving data from the RS485 bus
EN
(D4, D7)
Glowing or flashing LED indicates the RS485 transceiver is set to transmit mode; if the LED is off, the transceiver is in receive mode
TX
(D2, D5)
Flashing LED indicates transmitting data to the RS485 bus


The power signaling LED is common for both interfaces, while the communication signaling LEDs are assigned to each RS485 interface separately.


RS485 Operating Mode Configuration

The RS485 transceivers require a control signal to activate transmit mode. This control signal can be derived from the data signal sent to the bus (TXD), or it can be supplied independently – via the RTS line or a signal from the GPIO connector. The KAmod RPI RS485 X2 module allows selecting one of these options for each RS485-1 and RS485-2 interface. The available modes and jumper settings are described in the table.

Operating Mode Description
Automatic Control (default)

R1J1 - jumper in ON position,
J14 - shorted
R2J1 - jumper in ON position,
J18 - shorted

The control signal activating transmit mode is derived from the data signal sent to the bus - TXD
Automatic Control

R1J1 - jumper in ON position,
J13 - shorted
R2J1 - jumper in ON position,
J17 - shorted (J14 and J18 cut)

The control signal activating transmit mode is connected to the RTS output of the SC16IS762 chip. The controlling application is responsible for the RTS output state.
GPIO Control

R1J1 - jumper in OFF position,
JP12 - shorted
R2J1 - jumper in OFF position,
JP16 - shorted

Glowing or flashing LED indicates the RS485 transceiver is set to transmit mode; if the LED is off, the transceiver is in receive mode
GPIO Control

R1J1 - jumper in OFF position,
JP11 - shorted
R2J1 - jumper in OFF position,
JP15 - shorted (J12 and J16 cut)

The control signal activating transmit mode is connected to GPIO27 (pin 13, CH1) and GPIO22 (pin 15, CH2).

The controlling application is responsible for the GPIO output states.


In the case of GPIO control, the selected control lines (GPIO04, GPIO17, GPIO22, GPIO27) should have a current capacity of up to 5 mA, as they will drive optocouplers.

The active state on the transceiver control inputs is signaled by the glowing of LEDs D7 and D4.



Dimensions

The dimensions of the KAmod RPI RS485 X2 board are 65x56 mm, and it is compatible with Raspberry Pi type base boards. The board height is approx. 15 mm; additionally, the connector on the bottom side of the board fitting the base board has a height of approx. 13 mm.



Startup

Start the Raspberry Pi 5 with the operating system installed on a memory card or other medium. Once the desktop appears, open a console window (Terminal), e.g., using the Ctrl+Alt+T key combination, and type:
sudo nano /boot/firmware/config.txt
(in earlier versions of the OS, the config.txt file was located directly in the /boot directory)

In the file that opens, uncomment (remove the # sign) the line:
dtparam=spi=on
If such a line does not exist, it should be added.


Next, at the end of the file (scroll down with arrow keys), add the line:
dtoverlay=sc16is752-spi0,int_pin=25


Save changes using Ctrl+O, close the editor with Ctrl+X, and restart the system, e.g., by typing:
sudo reboot

After the desktop reappears, open the Terminal and type:
sudo dmesg | grep -i spi

If the previous steps were performed correctly, the following summary should appear:


This indicates that the SC16IS762 controller has been correctly installed in the system.

RS485 interfaces can be tested using the minicom program. For RS485-1, type:
minicom -D /dev/ttySC0

For RS485-2, type:
minicom -D /dev/ttySC1

The minicom program allows sending characters typed from the keyboard and displays characters received by the selected RS485 interface. During interface activity, LEDs D2…D7 will flash, but at high transmission speeds (e.g., 115200), the LED flashing will be barely noticeable.


Module Installation on the Raspberry Pi Connector


Links