Actions

KAmod RPI 485 CAN Hat: Difference between revisions

From Kamamilabs.com - Wiki

 
(7 intermediate revisions by the same user not shown)
Line 291: Line 291:
</center>
</center>


1 046 / 5 000
===== <b>Indicator lights </b>=====
===== <b>Indicator lights </b>=====
<br>
<br>
Line 320: Line 319:
[[File:KAmod_RPI_485%26CAN_Hat_ster_LED.png|none|600px|thumb|center]]
[[File:KAmod_RPI_485%26CAN_Hat_ster_LED.png|none|600px|thumb|center]]
</center>
</center>
Prześlij opinię
Dostępne są tłumaczenia


===== <b>Konfiguracja sygnałów SPI CE </b>=====
===== <b>Configuration of SPI CE signals </b>=====
<br>
<br>
<center>
<center>
{| class="wikitable" style="width: 1000px;"
{| class="wikitable" style="width: 1000px;"
|-
|-
! style="text-align: center;"|<b>Sygnał</b>
! style="text-align: center;"|<b>Signal</b>
! colspan="2"; style="text-align: center;"|<b>Funkcja</b>
! colspan="2"; style="text-align: center;"|<b>Function</b>
|-
|-
| rowspan="3"; style="text-align: center;"|<b>CAN CE</b>
| rowspan="3"; style="text-align: center;"|<b>CAN CE</b>
| colspan="2"; style="text-align: center;"|Wejście aktywujące interfejs SPI kontrolera MCP2515
| colspan="2"; style="text-align: center;"|Input activating the SPI interface of the MCP2515 controller
|-
|-
| style="text-align: center;"| Domyślnie połączone do GPIO08 (pin 24 złącza J3)
| style="text-align: center;"| By default connected to GPIO08 (pin 24 of J3 connector)
| style="text-align: center;"| Zwarta zwora JP1
| style="text-align: center;"| Shorted jumper JP1
|-
|-
| style="text-align: center;"| Opcjonalnie połączone do GPIO07 (pin 26 złącza J3)
| style="text-align: center;"| Optionally connected to GPIO07 (pin 26 of J3)
| style="text-align: center;"| Zwarta zwora JP2
| style="text-align: center;"| Shorted jumper JP2
|-
|-


| rowspan="3"; style="text-align: center;"|<b>RS CE</b>
| rowspan="3"; style="text-align: center;"|<b>RS CE</b>
| colspan="2"; style="text-align: center;"|Wejście aktywujące interfejs SPI kontrolera SC16IS762
| colspan="2"; style="text-align: center;"|Input activating the SPI interface of the SC16IS762 controller
|-
|-
| style="text-align: center;"| Domyślnie połączone do GPIO07 (pin 26 złącza J3)
| style="text-align: center;"| By default connected to GPIO07 (pin 26 of J3)
| style="text-align: center;"| Zwarta zwora JP3
| style="text-align: center;"| Shorted jumper JP3
|-
|-
| style="text-align: center;"| Opcjonalnie połączone do GPIO18 (pin 12 złącza J3)
| style="text-align: center;"| Optionally connected to GPIO18 (pin 12 of J3)
| style="text-align: center;"| Zwarta zwora JP4
| style="text-align: center;"| Closed jumper JP4
|-
|-
|}
|}
</center>
</center>
<br>
<br>
Moduł KAmod RPI 485&CAN Hat realizuje komunikację z płytką bazową np. Raspberry Pi poprzez dwa interfejsy SPI. Sygnały CE – Chip Enable, obu interfejsów mogą być połączone w dwóch konfiguracjach, w zależności od ustawienia zworek JP1...JP4, tak jak opisano w powyższej tabeli.
The KAmod RPI 485&CAN Hat module communicates with a base board, e.g. Raspberry Pi, via two SPI interfaces. The CE – Chip Enable signals of both interfaces can be connected in two configurations, depending on the setting of jumpers JP1...JP4, as described in the table above.
<br><br>
<br><br>
Zworki są umieszczone na dolnej stronie płytki modułu, co dokładnie obrazuje poniższy rysunek. Domyślnie połączone są zworki JP1 i JP3. W przypadku zmiany konfiguracji należy rozciąć połączone zworki i połączyć odpowiednie zworki za pomocą lutownicy i kropli spoiwa lutowniczego.
The jumpers are located on the bottom side of the module board, which is precisely illustrated in the figure below. By default, jumpers JP1 and JP3 are connected. In case of a configuration change, cut the connected jumpers and connect the appropriate jumpers using a soldering iron and a drop of solder.


<center>
<center>
Line 363: Line 358:
</center>
</center>


===== <b>Konfiguracja trybu pracy RS485 </b>=====
===== <b>RS485 operating mode configuration </b>=====
<br>
<br>
<center>
<center>
{| class="wikitable" style="width: 1000px;"
{| class="wikitable" style="width: 1000px;"
|-
|-
! style="text-align: center;"|<b>Sygnał</b>
! style="text-align: center;"|<b>Signal</b>
! colspan="2"; style="text-align: center;"|<b>Funkcja</b>
! colspan="2"; style="text-align: center;"|<b>Function</b>
|-
|-
| rowspan="3"; style="text-align: center;"|<b>RS1 DE</b>
| rowspan="3"; style="text-align: center;"|<b>RS1 DE</b>
| colspan="2"; style="text-align: center;"|Sygnał sterujący transceiverem interfejsu RS485-1
| colspan="2"; style="text-align: center;"|RS485-1 interface transceiver control signal
|-
|-
| style="text-align: center;"| Domyślnie aktywne jest automatyczne sterowanie sygnałem TXD
| style="text-align: center;"| By default, automatic TXD signal control is active
| style="text-align: center;"| Zwarta zwora JP8
| style="text-align: center;"| JP8 jumper closed
|-
|-
| style="text-align: center;"| Opcjonalnie możliwe jest sterowanie sygnałem RTS
| style="text-align: center;"| Optionally, it is possible to control the RTS signal
| style="text-align: center;"| Zwarta zwora JP7
| style="text-align: center;"| Closed jumper JP7
|-
|-


| rowspan="3"; style="text-align: center;"|<b>RS2 DE</b>
| rowspan="3"; style="text-align: center;"|<b>RS2 DE</b>
| colspan="2"; style="text-align: center;"|Sygnał sterujący transceiverem interfejsu RS485-2
| colspan="2"; style="text-align: center;"|RS485-2 interface transceiver control signal
|-
|-
| style="text-align: center;"| Domyślnie aktywne jest automatyczne sterowanie sygnałem TXD
| style="text-align: center;"| By default, automatic TXD signal control is active
| style="text-align: center;"| Zwarta zwora JP10
| style="text-align: center;"| Closed jumper JP10
|-
|-
| style="text-align: center;"| Opcjonalnie możliwe jest sterowanie sygnałem RTS
| style="text-align: center;"| Optionally, it is possible to control the RTS signal
| style="text-align: center;"| Zwarta zwora JP9
| style="text-align: center;"| Closed jumper JP9
|-
|-
|}
|}
</center>
</center>
<br>
<br>
Transceivery interfejsów RS485 wymagają sygnału sterującego nadajnikiem magistrali -aktywującego tryb nadawania. Sygnał sterujący może być uzyskiwany z sygnału danych wysyłanych na magistralę - TXD, lub może być doprowadzany niezależnie – poprzez stan linii RTS. Moduł KAmod RPI 485&CAN Hat pozwala na wybranie jednej z tych opcji dla każdego z interfejsów RS485-1 i RS485-2, poprzez ustawienie zworek JP7...JP10, tak jak opisano w powyższej tabeli.
RS485 interface transceivers require a signal controlling the bus transmitter - activating the transmission mode. The control signal can be obtained from the data signal sent to the bus - TXD, or can be supplied independently - via the RTS line status. The KAmod RPI 485&CAN Hat module allows you to select one of these options for each of the RS485-1 and RS485-2 interfaces, by setting jumpers JP7...JP10, as described in the table above.
<br><br>
<br><br>
Zworki są umieszczone na dolnej stronie płytki modułu, co dokładnie obrazuje poniższy rysunek. Domyślnie połączone są zworki JP8 i JP10 – tryb automatyczny dla obu interfejsów. W przypadku zmiany konfiguracji należy rozciąć połączone zworki i połączyć odpowiednie zworki za pomocą lutownicy i kropli spoiwa lutowniczego.
The jumpers are located on the bottom side of the module board, which is precisely illustrated in the figure below. By default, jumpers JP8 and JP10 are connected - automatic mode for both interfaces. In case of a configuration change, cut the connected jumpers and connect the appropriate jumpers using a soldering iron and a drop of solder.
<center>
<center>
[[File:KAmod_RPI_485%26CAN_Hat_ster_konfig_RS.png|none|600px|thumb|center]]
[[File:KAmod_RPI_485%26CAN_Hat_ster_konfig_RS.png|none|600px|thumb|center]]
</center>
</center>


===== <b>Wymiary </b>=====
===== <b>Dimensions </b>=====
<br>
<br>
Wymiary płytki  KAmod RPI 485&CAN Hat to 65x56 mm. Wysokość płytki to ok. 15 mm, dodatkowo złącze na dolnej stronie płytki, pasujące do płytki bazowej, ma wysokość ok 13 mm.
The dimensions of the KAmod RPI 485&CAN Hat board are 65x56 mm. The board height is about 15 mm, and the connector on the bottom side of the board, which fits the base board, is about 13 mm high.
<center>
<center>
[[File:KAmod_RPI_485%26CAN_Hat_wym.png|none|600px|thumb|center]]
[[File:KAmod_RPI_485%26CAN_Hat_wym.png|none|600px|thumb|center]]
</center>
</center>


===== <b>Uruchomienie </b>=====
===== <b>Startup </b>=====
<br>
<br>
Uruchamiamy Raspberry Pi 5 z systemem operacyjnym zainstalowanym na karcie pamięci lub innym, nośniku. Po wyświetleniu pulpitu systemu otwieramy okno konsoli (Terminal) np. za pomocą kombinacji klawiszy Ctrl+Alt+T i wpisujemy:<br>
Start Raspberry Pi 5 with the operating system installed on the memory card or other media. After the system desktop is displayed, open the console window (Terminal), e.g. using the Ctrl+Alt+T key combination and enter:<br>
'''<pre style="color: blue">sudo nano /boot/firmware/config.txt</pre>'''
'''<pre style="color: blue">sudo nano /boot/firmware/config.txt</pre>'''
(we wcześniejszych wersjach systemu operacyjnego plik config.txt był umieszczony bezpośrednio w katalogu /boot)<br><br>
(in earlier versions of the operating system, the config.txt file was placed directly in the /boot directory)<br><br>


W pliku, którego treść zobaczymy, należy usunąć komentarz (usunąć znak #) z linii:
In the file whose content we will see, remove the comment (remove the # sign) from the line:
'''<pre style="color: blue">dtparam=spi=on</pre>'''
'''<pre style="color: blue">dtparam=spi=on</pre>'''
Natomiast, jeżeli takiej linii nie ma to należy ją dopisać.
However, if there is no such line, you should add it. <center>
<center>
[[File:KAmod-MultiBus-Hat config 1.jpg|none|800px|thumb|center]]
[[File:KAmod-MultiBus-Hat config 1.jpg|none|800px|thumb|center]]
</center>
</center>
Następnie na końcu pliku (przewijamy strzałkami do samego dołu) należy dopisać linie:<br>
Then at the end of the file (scroll to the bottom with the arrows) add the following lines:<br>
'''<pre style="color: blue">dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25,spimaxfrequency=10000000</pre>'''
'''<pre style="color: blue">dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25,spimaxfrequency=10000000</pre>'''
<br>
<br>
oraz
and
'''<pre style="color: blue">dtoverlay=sc16is752-spi1,int_pin=24</pre>'''
'''<pre style="color: blue">dtoverlay=sc16is752-spi1,int_pin=24</pre>'''
<br>
<br>
Line 430: Line 422:
[[File:KAmod-MultiBus-Hat_config_2.jpg|none|800px|thumb|center]]
[[File:KAmod-MultiBus-Hat_config_2.jpg|none|800px|thumb|center]]
</center>
</center>
Następnie należy zapisać zmiany za pomocą klawiszy Ctrl+O, zamknąć edytor za pomocą klawiszy Ctrl+X i uruchomić system ponownie, np. wpisując polecenie:<br>
Then save the changes using the Ctrl+O keys, close the editor using the Ctrl+X keys and restart the system, e.g. by entering the command:<br>
'''<pre style="color: blue">sudo reboot</pre>'''<br>
'''<pre style="color: blue">sudo reboot</pre>'''<br>
Po wyświetleniu pulpitu systemu otwieramy okno konsoli (Terminal) np. za pomocą kombinacji klawiszy Ctrl+Alt+T i wpisujemy:
After the system desktop is displayed, open the console window (Terminal), e.g. using the Ctrl+Alt+T key combination and enter:
'''<pre style="color: blue">sudo dmesg | grep -i spi</pre>'''<br>
'''<pre style="color: blue">sudo dmesg | grep -i spi</pre>'''<br>
Jeśli wcześniejsze etapy zostały wykonane prawidłowo powinno pokazać się takie podsumowanie:
If the previous steps were performed correctly, the following summary should be displayed:
<center>
<center>
[[File:KAmod-MultiBus-Hat_config_3.jpg|none|800px|thumb|center]]
[[File:KAmod-MultiBus-Hat_config_3.jpg|none|800px|thumb|center]]
</center>
</center>
Oznacza to, że zarówno kontroler SC16IS762, jak i MCP2515 zostały prawidłowo zainstalowane w systemie.<br><br>
This means that both the SC16IS762 and MCP2515 controllers have been correctly installed in the system.<br><br>
Przetestowanie interfejsu CAN wymaga wpisania 3 komend:
Testing the CAN interface requires entering 3 commands:
'''<pre style="color: blue">sudo ip link set can0 up type can bitrate 1000000
'''<pre style="color: blue">sudo ip link set can0 up type can bitrate 1000000
sudo ifconfig can0 up
sudo ifconfig can0 up
cansend can0 000#11.22.33.44</pre>'''<br>
cansend can0 000#11.22.33.44</pre>'''<br>
Powinna migać dioda LED D10 sygnalizująca aktywność na magistrali CAN.<br>
The D10 LED should flash, indicating activity on the CAN bus.<br>
Interfejsy RS485 można przetestować z użyciem programu minicom, dla RS485-1 należy wpisać:
RS485 interfaces can be tested using the minicom, for RS485-1 enter:
'''<pre style="color: blue">minicom -D /dev/ttySC0</pre>'''<br>
'''<pre style="color: blue">minicom -D /dev/ttySC0</pre>'''<br>
natomiast dla RS485-2 należy wpisać:
while for RS485-2 enter:
'''<pre style="color: blue">minicom -D /dev/ttySC1</pre>'''<br>
'''<pre style="color: blue">minicom -D /dev/ttySC1</pre>'''<br>
Program minicom pozwala wysyłać znaki wpisywane z klawiatury oraz wyświetla znaki odebrane przez wybrany interfejs RS485. W czasie aktywności interfejsów będą migały diody D5/D7, ale przy znacznych prędkościach transmisji, np. 115200, miganie diod LED będzie ledwo zauważalne.
The minicom program allows you to send characters entered from the keyboard and displays characters received via the selected RS485 interface. During the interface activity, the D5/D7 diodes will flash, but at high transmission speeds, e.g. 115200, the flashing of the LEDs will be barely noticeable.
<br><br>
<br><br>


===== <b>Linki </b>=====
===== <b>Links </b>=====
*[https://wiki.kamamilabs.com/images/8/83/MCP2515.pdf Karta katalogowa MCP2515]
*[https://wiki.kamamilabs.com/images/8/83/MCP2515.pdf Datasheet MCP2515 ]
*[https://wiki.kamamilabs.com/images/c/cb/SC16IS752_SC16IS762.pdf Karta katalogowa SC16IS762IPW]
*[https://wiki.kamamilabs.com/images/c/cb/SC16IS752_SC16IS762.pdf Datasheet SC16IS762IPW]
*[https://wiki.kamamilabs.com/images/0/0a/ADM2483.pdf Karta katalogowaADM2483]
*[https://wiki.kamamilabs.com/images/0/0a/ADM2483.pdf Datasheet ADM2483]
*[https://wiki.kamamilabs.com/images/f/fd/TJA1052IT.pdf Karta katalogowa TJA1052]
*[https://wiki.kamamilabs.com/images/f/fd/TJA1052IT.pdf Datasheet TJA1052]
*[https://wiki.kamamilabs.com/images/3/35/Tps5401.pdf Karta katalogowa TPS5401]
*[https://wiki.kamamilabs.com/images/3/35/Tps5401.pdf Datasheet TPS5401]
*[https://wiki.kamamilabs.com/images/2/25/KAmod-MultiBus-Hat_3d.zip Model CAD (STEP)]
*[https://wiki.kamamilabs.com/images/2/25/KAmod-MultiBus-Hat_3d.zip CAD Model (STEP)]

Latest revision as of 06:41, 3 June 2025

Description

KAmod RPI 485&CAN Hat - Module with two RS485 interfaces and a CAN interface for Raspberry Pi

KAmod RPI 485&CAN Hat allows you to easily expand Raspberry Pi 5 computers with two RS485 interfaces and one CAN 2.0B interface. The interfaces contain extensive protection circuits and are galvanically isolated from the control circuits, which guarantees stable operation and resistance to interference and failures. The module has been designed to be compatible with Raspberry Pi series boards not only in version 5. It is controlled via 2 SPI interfaces, available on the 40-pin RPi connector, and in many other boards, e.g. Arduino, STM32, etc.

Basic features and parameters
  • 2 RS485 interfaces – controlled by SC16IS752 controller (SPI→2xUART)
  • 1 CAN 2.0B interface – controlled by MCP2515 controller (SPI→CAN)
  • RS485 interfaces equipped with 2 isolated ADM2483 transceivers
  • CAN interface equipped with isolated TJA1052 transceiver
  • RS485 and CAN interfaces galvanically separated from control circuits
  • Possibility to connect 120 Ω terminating resistors to each interface line
  • ​​Maximum RS485 interest communication speed: 500 kbps
  • Maximum CAN interest communication speed: 1 Mbps
  • Control via two SPI interfaces operating with 3.3 V voltage
  • Automatic control of RS485 transceiver transmission direction
  • Power supply 5 V/0.3 A taken from the Raspberry Pi board or from an additional source
  • Optional power input adapted to a voltage in the range of 8...32 V
  • Stabilized power output 5 V, max 0.5 A
  • Easy installation on Raspberry Pi 5, also in the version with the RPi Active Cooler radiator
  • Can work with many boards from the Raspberry Pi family and others equipped with SPI interfaces operating at a voltage of 3.3 V
  • Module dimensions 65x56 mm, height approx. 15 mm (and a connector under the board with a height of approx. 13 mm)



Standard Equipment
Code Description
KAmod RPI 485&CAN Hat
  • Assembled and started module
Mounting Kit
  • Set of screws and spacers to attach the overlay to the Raspberry board
Block diagram


Circuit diagram


The circuit diagram of the KAmod RPI 485&CAN Hat module can be downloaded here: KAmod RPI 485&CAN Hat diagram

RS485 Interfaces


Interface Element Function
RS485-1

Connector
3x1,2,54 mm pins
R1J1

Connecting a 120 Ω terminating resistor to the RS485-1 bus line,
when the jumper is placed on pins 2-3

Connector
Phoenix MC 3.81 mm
R1J2

Main RS485-1 bus connector, pin 1 – GND; pin 2 – B(-); pin 3 – A(+)

Connector
3x1, 2.54 mm pins
R1J3

Additional RS485-1 bus connector, pin 1 – GND; pin 2 – B(-); pin 3 – A(+)

LED
D7

The diode lights up to indicate data transmission/reception on the RS485-1 interface signal lines
RS485-2

Connector
3x1,2,54 mm pins
R2J1

Connecting a 120 Ω terminating resistor to the RS485-2 bus line,
when the jumper is placed on pins 2-3

Connector
Phoenix MC 3.81 mm
R2J2

Main RS485-2 bus connector, pin 1 – GND; pin 2 – B(-); pin 3 – A(+)

Connector
3x1 pins, 2.54 mm
R1J3

Secondary RS485-2 bus connector, pin 1 – GND; pin 2 – B(-); pin 3 – A(+)

LED
D7

The diode lights up to indicate data transmission/reception on the RS485-2 interface signal lines


The RS485 interfaces are controlled by ADM2483 transceivers, which also provide galvanic separation between the control signals and the RS485 bus lines.

The bus lines are marked as: A(+), B(-) and GND ground and are available on the Phoenix MC connector (R1J2, R2J2) and on goldpin pins with a standard 2.54 mm pitch (R1J3, R2J3). Their arrangement is shown in the drawing and is described on the bottom side of the module board.

The RS485 bus lines are equipped with circuits protecting against overvoltages. Putting a jumper on pins 2-3 of RxJ1 allows you to connect a 120 Ω terminating resistor between lines A and B of the interface.

CAN Interface


Interface Element Function
CAN

Connector
Pins 3x1.2.54 mm
CJ1

Connecting a 120 Ω terminating resistor to the CAN bus line,
when the jumper is placed on pins 2-3

Connector
Phoenix MC 3.81 mm
CJ2

Main CAN bus connector, pin 1 – GND; pin 2 – CAN L; pin 3 – CAN H

Connector
3x1, 2.54 mm pins
CJ3

Additional CAN interface connector,

pin 1 – GND; pin 2 – CAN L; pin 3 – CAN H

LED
D10

The diode lights up to indicate data transmission/reception on the CAN interface lines


The CAN interface is controlled by a TJA1052 transceiver, which also provides galvanic separation between control signals and the CAN bus lines.

The bus lines are marked as: CAN H, CAN L and ground GND and are available on the Phoenix MC (CJ2) type connector and on goldpins (CJ3) with a standard 2.54 mm pitch. Their layout is shown in the drawing and is described on the bottom side of the module board.

The CAN bus lines are equipped with circuits that protect against overvoltages. Putting a jumper on pins 2-3 of CJ1 allows you to connect a 120 Ω terminating resistor between the CAN H and CAN L lines.



RS485 Control


RS485 Interfaces
Control Signal Function
MOSI1 (SPI 1) SPI data input of SC16IS762 controller, connected to GPIO20 RPi (pin 38 of J3)
MISO1 (SPI 1) SPI data output of SC16IS762 controller, connected to GPIO19 RPi (pin 35 of J3)
SCLK1 (SPI 1) SPI clock input of SC16IS762 controller, connected to GPIO21 RPi (pin 40 of J3)
RS CE SPI interface activation input of SC16IS762 controller
By default connected to GPIO07 (pin 26 of J3 connector) - Shorted jumper JP3
Optionally connected to GPIO18 (pin 12 of J3 connector) - Shorted jumper JP4
RS INT SC16IS762 controller IRQ interrupt output connected to GPIO24 (pin 18 of J3 connector)


All control signals are led out on connector J1 (40-pin, compatible with Raspberry Pi boards) and on pin header J2. The signal layout is shown in the figure below, additionally the signals on connector J2 are described on the bottom side of the KAmod RPI 485&CAN Hat board.

RS485 interfaces are implemented via the SC16IS762 controller, the description of this system is available in the manufacturer's documentation.

CAN Control


CAN Interface
Control Signal Function
MOSI0 (SPI 0) MCP2515 Controller SPI Data Input Connected to GPIO10 RPi (J3 Pin 19)
MISO0 (SPI 0) MCP2515 controller SPI data output connected to RPi GPIO09 (J3 pin 21)
SCLK0 (SPI 0) MCP2515 controller SPI clock input connected to RPi GPIO11 (J3 pin 23)
CAN CE MCP2515 controller SPI interface enable input
By default connected to GPIO08 (J3 pin 24) - JP1 jumper closed
Optionally connected to GPIO07 (pin 26 of J3 connector) - Shorted jumper JP2
CAN INT MCP2515 controller IRQ interrupt output connected to GPIO25 (pin 22 of J3 connector)


All control signals are output on connector J1 (40-pin, compatible with Raspberry Pi boards) and on pin connector J2. The signal layout is shown in the figure below, additionally the signals on connector J2 are described on the bottom side of the KAmod RPI 485&CAN Hat board.

The CAN interface is implemented via the MCP2515 controller, a description of the operation of this system is available in the manufacturer's documentation.

Power Supply


Element Function
Connector
J1 PWR
Optional power supply input adapted to a voltage in the range of 8...32 V. Powers the integrated switching regulator, which provides a voltage of 5 V with a capacity of up to 0.5 A, to power the components of the KAmod RPI 485&CAN Hat module.
Connector
J2
Connector J2 provides 5V from the integrated regulator. It can be used as a power source for additional circuits or modules. The current consumption should not exceed 0.5A.
Connector
J1
Connector J1 provides 5V from a base board, e.g. Raspberry Pi. This voltage is connected via a rectifier diode to the 5V power supply of the KAmod RPI 485&CAN Hat module, so the module is powered from the base board, but the module cannot supply power to the base board.
LED D12 LED D12 lighting indicates power supply


The KAmod RPI 485&CAN Hat module offers various power supply options:

  • can be powered by 5V from a base board connected to connector J1, e.g. Raspberry Pi. No external power supply is required;
  • can be powered by a voltage in the range of 8...32 V connected to connector J1 PWR. Then a stabilized voltage of 5 V is available on connector J2, but it does not power the base board connected to connector J1;
  • can be powered by a stabilized voltage of 5 V connected to connector J2, but it does not power the base board connected to connector J1;

The layout of the connectors and contacts and their polarity are shown in the figure.

Indicator lights


Indicator light Function
D7 The diode lights up to indicate data transmission/reception on the RS485-1 interface signal lines
D5 The diode lights up to indicate data transmission/reception on the RS485-2 interface signal lines
D10 The diode lights up to indicate data transmission/reception on the CAN interface signal lines
D12 The diode lights up to indicate power supply


The layout of the signaling lights on the KAmod RPI 485&CAN Hat board is shown in the figure.

Configuration of SPI CE signals


Signal Function
CAN CE Input activating the SPI interface of the MCP2515 controller
By default connected to GPIO08 (pin 24 of J3 connector) Shorted jumper JP1
Optionally connected to GPIO07 (pin 26 of J3) Shorted jumper JP2
RS CE Input activating the SPI interface of the SC16IS762 controller
By default connected to GPIO07 (pin 26 of J3) Shorted jumper JP3
Optionally connected to GPIO18 (pin 12 of J3) Closed jumper JP4


The KAmod RPI 485&CAN Hat module communicates with a base board, e.g. Raspberry Pi, via two SPI interfaces. The CE – Chip Enable signals of both interfaces can be connected in two configurations, depending on the setting of jumpers JP1...JP4, as described in the table above.

The jumpers are located on the bottom side of the module board, which is precisely illustrated in the figure below. By default, jumpers JP1 and JP3 are connected. In case of a configuration change, cut the connected jumpers and connect the appropriate jumpers using a soldering iron and a drop of solder.

RS485 operating mode configuration


Signal Function
RS1 DE RS485-1 interface transceiver control signal
By default, automatic TXD signal control is active JP8 jumper closed
Optionally, it is possible to control the RTS signal Closed jumper JP7
RS2 DE RS485-2 interface transceiver control signal
By default, automatic TXD signal control is active Closed jumper JP10
Optionally, it is possible to control the RTS signal Closed jumper JP9


RS485 interface transceivers require a signal controlling the bus transmitter - activating the transmission mode. The control signal can be obtained from the data signal sent to the bus - TXD, or can be supplied independently - via the RTS line status. The KAmod RPI 485&CAN Hat module allows you to select one of these options for each of the RS485-1 and RS485-2 interfaces, by setting jumpers JP7...JP10, as described in the table above.

The jumpers are located on the bottom side of the module board, which is precisely illustrated in the figure below. By default, jumpers JP8 and JP10 are connected - automatic mode for both interfaces. In case of a configuration change, cut the connected jumpers and connect the appropriate jumpers using a soldering iron and a drop of solder.

Dimensions


The dimensions of the KAmod RPI 485&CAN Hat board are 65x56 mm. The board height is about 15 mm, and the connector on the bottom side of the board, which fits the base board, is about 13 mm high.

Startup


Start Raspberry Pi 5 with the operating system installed on the memory card or other media. After the system desktop is displayed, open the console window (Terminal), e.g. using the Ctrl+Alt+T key combination and enter:

sudo nano /boot/firmware/config.txt

(in earlier versions of the operating system, the config.txt file was placed directly in the /boot directory)

In the file whose content we will see, remove the comment (remove the # sign) from the line:

dtparam=spi=on

However, if there is no such line, you should add it.

Then at the end of the file (scroll to the bottom with the arrows) add the following lines:

dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25,spimaxfrequency=10000000


and

dtoverlay=sc16is752-spi1,int_pin=24


Then save the changes using the Ctrl+O keys, close the editor using the Ctrl+X keys and restart the system, e.g. by entering the command:

sudo reboot


After the system desktop is displayed, open the console window (Terminal), e.g. using the Ctrl+Alt+T key combination and enter:

sudo dmesg | grep -i spi


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

This means that both the SC16IS762 and MCP2515 controllers have been correctly installed in the system.

Testing the CAN interface requires entering 3 commands:

sudo ip link set can0 up type can bitrate 1000000
sudo ifconfig can0 up
cansend can0 000#11.22.33.44


The D10 LED should flash, indicating activity on the CAN bus.
RS485 interfaces can be tested using the minicom, for RS485-1 enter:

minicom -D /dev/ttySC0


while for RS485-2 enter:

minicom -D /dev/ttySC1


The minicom program allows you to send characters entered from the keyboard and displays characters received via the selected RS485 interface. During the interface activity, the D5/D7 diodes will flash, but at high transmission speeds, e.g. 115200, the flashing of the LEDs will be barely noticeable.

Links