Difference between revisions of "RS485-CAN-HAT"

From SB-Components Wiki

Line 91: Line 91:
  
 
===== Code Test =====
 
===== Code Test =====
 +
* Stack RS485 CAN HAT on GPIO header of both Raspberry Pi.
 +
* Now connect A and B Terminal of the first HAT to A and B terminal of the second HAT.
 +
* Clone or download Github repository by running below command.
 +
<pre> git clone https://github.com/sbcshop/RS485-CAN-HAT.git  </pre>
 +
* Now enter cloned repository by running below command one by one.
 +
<pre>
 +
cd RS485-CAN-HAT
 +
cd RS485
 +
</pre> 
 +
* Now run code on receiver first.
 +
<pre> sudo python3 485_receive.py </pre>
 +
* Now run code on Sender.
 +
<pre> sudo python3 485_send.py  </pre>
 +
 +
You can start getting data on receiver terminal after above steps.
  
 
== Resources ==
 
== Resources ==

Revision as of 10:11, 27 May 2021

RS485 CAN HAT

RS485 CAN HAT is a multi node communication module, to communicate with devices in a long-range, designed dedicatedly for Raspberry Pi with an operating voltage of 3.3 V, CAN controller MCP2515 via SPI interface, onboard transceiver SN65HVD230 that is controlled via UART. It is built to support automatic TX/RX control without programming. It performs half-duplex communication and it has an onboard transceiver SP3485.

Features

  • Onboard TVS (Transient Voltage Suppressor),lightning-proof & anti-electrostatic
  • Standard Raspberry Pi 40 Pins GPIO Extension Headers
  • Half-duplex Communication
  • Long-Distance Communication via RS485/CAN functions

Specifications

  • Operating voltage: 3.3V
  • CAN transceiver: SN65HVD230
  • RS485 transceiver: SP3485
  • CAN controller: MCP2515
  • Communication Protocol - RS485 and CAN
RS485 CAN HAT
Buy it From : Click Here

Pinout

Board PINRaspberry Pi GPIO (BCM)DESCRIPTION
3V33V33.3V Power
GNDGNDGround
SCKGPIO 11SPI clock input
MOSIGPIO 10SPI data input
MISOGPIO 9SPI data output
CSGPIO 8SPI chip selection
INTGPIO 25Interrupt
RXDGPIO 15RS485 UART receive
TXDGPIO 14RS485 UART transmit
RSEGPIO 4RS485 TX/RX control Line (Currently in auto mode)

Installation

Python

Library Installation

Before running this board you have install required libraries for RS485 CAN HAT.

  • For Python3, install these two libraries by running below command on the terminal.
 sudo apt-get install python-pip 
 sudo pip3 install python-can 


CAN TEST

Required Hardware
  • Raspberry Pi x 2
  • RS485 CAN HAT x 2
Setup
  • Stack RS485 CAN HAT on GPIO header of both Raspberry Pi, and modify the boot/config.txt file.
 sudo nano /boot/config.txt 
  • Add below line to the end of the file.
dtparam=spi=on
dtoverlay=mcp2515-can0,oscillator=12000000,interrupt=25,spimaxfrequency=2000000

485-CAN-HAT-config.PNG

  • Save this file on both boards and reboot both raspberry pi one by one.
 sudo reboot 
  • After restart, run the below command to verify the installation by running the below command (Make sure RS485 CAN HAT is connected while booting).
 dmesg | grep -i '\(can\|spi\)' 

485-CAN-HAT-install-check.PNG

Code Test
  • Now connect H and L Terminal of the first HAT to H and L terminal of the second HAT.
  • Clone or download Github repository by running below command.
 git clone https://github.com/sbcshop/RS485-CAN-HAT.git 
  • Now enter cloned repository by running below command one by one.
cd RS485-CAN-HAT
cd CAN   
  • Now run code on receiver first.
 sudo python3 can_receive.py 
  • Now run code on Sender.
 sudo python3 can_send.py 


You will get some value with timestamp and id on receiver terminal.

RS485 TEST

Required Hardware
  • Raspberry Pi x 2
  • RS485 CAN HAT x 2
Code Test
  • Stack RS485 CAN HAT on GPIO header of both Raspberry Pi.
  • Now connect A and B Terminal of the first HAT to A and B terminal of the second HAT.
  • Clone or download Github repository by running below command.
 git clone https://github.com/sbcshop/RS485-CAN-HAT.git  
  • Now enter cloned repository by running below command one by one.
cd RS485-CAN-HAT
cd RS485
  • Now run code on receiver first.
 sudo python3 485_receive.py 
  • Now run code on Sender.
 sudo python3 485_send.py  

You can start getting data on receiver terminal after above steps.

Resources