Difference between revisions of "Template:RS485 CAN HAT B Manual"

From Waveshare Wiki
Jump to: navigation, search
Line 56: Line 56:
  
 
==Interface==
 
==Interface==
[[File:RS485 CAN HAT B Manual001.jpg|550px]]
+
[[File:RS485-CAN-HAT-B-details-inter.jpg|550px]]
 
*CAN bus(CAN_0, control via SPI0)
 
*CAN bus(CAN_0, control via SPI0)
 
{| class="wikitable"
 
{| class="wikitable"

Revision as of 07:00, 25 October 2022

Overview

RS485 CAN HAT (B) is a HAT with RS485 and CAN communication functions developed by Waveshare for Raspberry Pi, with RS485 and CAN communication functions.

Features

  • Standard Raspberry Pi 40PIN GPIO extension header, supports Raspberry Pi series boards
  • With 1-ch CAN, the controller MCP2515 and CAN transceiver, convert SPI to CAN
  • Adopts SC16IS752 + SP3485 dual-chip combination, converts SPI to RS485, data rate up to 921600bps
  • Onboard power conversion circuit, supports 8~28V wide voltage power supply, can supply power to Raspberry Pi at the same time
  • Onboard integrated power isolation, provides stable isolation voltage, and no additional power supply is required at the isolation end
  • Onboard integrated digital isolation for signal isolation with high reliability, strong anti-interference, and low power consumption
  • Onboard TVS (Transient Voltage Suppressor), effectively suppresses surge voltage and transient spike voltage in the circuit, lightning-proof & anti-electrostatic
  • Onboard auto-recovery fuse and protection diodes, ensures the current/voltage stable outputs, provides over-current/over-voltage proof, improve shock resistance
  • On-board 120Ω terminal resistor, enabled by jumper cap settings
  • It can be wired via onboard terminals or pin headers, making wiring more convenient
  • Breakout SPI control pins, for connecting with host control boards

Specification

Parameters
Expanded interface 2-Ch RS485 + 1-Ch CAN
Communication Bus SPI
CAN Controller MCP2515
CAN Receiver SIT65HVD230DR/SN65HVD23D
CAN Baud Rate ≦1Mbps
UART Expansion Chip SC16IS752
RS485 Receiver SP3485
RS485 Baud Rate 300~921600 bps
Power Supply External screw terminal or Raspberry Pi
External Voltage Range DC 8~28V
Operating Voltage 3.3V
Dimensions 65 × 56.5 mm

Interface

RS485-CAN-HAT-B-details-inter.jpg

  • CAN bus(CAN_0, control via SPI0)
Func BCM Description
5V 5V 5V power input
GND GND Ground
SCLK_0 11 (SCK) SPI clock input
MOSI_0 10 (MOSI) SPI data input
MISO_0 9 (MISO) SPI data output
CE_0 8 (CE0)[1] data/command selection
INT_0 D25[2] interrupt output
  • RS485 bus(control RS485_0 & RS485_1 via SPI1)
Func BCM Description
5V 5V 5V power input
GND GND Ground
SCLK_1 D21 SPI clock input
MOSI_1 D20 SPI data input
MISO_1 D19 SPI data output
CE_1 D18 data/command selection
INT_1 D24[3] interrupt output

Default Solder Joint Switching Description

When the default pin of the board conflicts with other external device pins, you can try to modify the back pin pad, that is, change the 0R resistance of the corresponding collision pin to other non-conflicting pins.
  1. CE_0 soldered to 8 (CE0) by default, you can change it to CE1 by modifying the 0R resistance on the back.
  2. Soldered to D25 by default, you can change it to D13 by modifying the 0R resistance on the back.
  3. Soldered to D24 by default, you can change it to D25/D16/D12 by modifying the 0R resistance on the back.
  • The detailed soldering joint on the back is shown below:

RS485 CAN HAT B solder.jpg

Hardware Description

CAN Bus

The CAN module is to process all the reception and transmission of the CAN bus. When sending the report, the report will be loaded in the correct report buffer and control register first. With the SPI interface, you can set the corresponding bit or the enabled pin to send the report. Also, you can check the communication and errors by reading the corresponding register. It will check all the reports in the CAN bus, and then match them with the user-defined filters to make sure the report can be transmitted to one of the receiving buffers.
As the Raspberry Pi cannot support CAN bus, you must use the CAN controller with SPI interface to match with a receiver to finish the CAN function.
Microchip Technology's MCP2515, a CAN protocol controller, totally supports CAN V2.0B specification and can send and receive standard and extended data frames as well as remote frames.
The MCP2515 comes with two acceptance mask registers and six acceptance filter registers that filter out unwanted packets, thus reducing the overhead of the main microcontroller (MCU). The MCU is connected to the device through the SPI interface, that is, the Raspberry Pi connects the chip through the SPI interface, and for the Raspberry Pi to use the chip, it does not need to write a driver, just open the core driver in the device tree to use.
MCP2515-PIN.png
For more details, please refer to the datasheet.
SN65HVD230 is a Texas Instruments 3.3V CAN transceiver suitable for serial communication with high communication rates, good interference immunity, and high-reliability CAN buses.
SN65HVD230 has three different operating modes: high speed, slope, and wait. Its operating mode control is possible via the Rs control pin. The output pin Tx of the CAN controller is connected to the data input D of the SN65HVD230, which can transfer the data sent by this CAN node to the CAN network; The receive pin Rx of the CAN controller is connected to R on the data output of the SN65HVD230 for receiving data.
RS485 CAN HAT (B)06.png

RS485 Bus

This product uses SC16IS752 as the control chip, and SC16IS752 is a dual-channel high-performance UART expansion chip supporting SPI and I2C communication. This module uses an SPI interface, onboard power isolation, ADI magnetical isolation, TVS (transient voltage suppression transistor), reset-up fuse and protection diode, and automatic transceiver conversion circuitry. It can effectively suppress the surge voltage and transient peak voltage in the circuit, lightning protection and anti-static, anti-overcurrent overvoltage, improve the ability to resist shock, and can carry out signal isolation, which has the advantages of high reliability, strong anti-interference, and low power consumption. The communication protocol is shown as below:
RS485 HAT.png
CS: Slave device chip selection. The chip is enabled when CS is in a low level.
SCLK: SPI communication clock.
MOSI/SI: SPI communication host sends and the slave device receives.
MIS0/SO: SPI communication host receives and the slave device sends.
Time order: CPHL = 0, CPOL = 0 (SPI0)
【Note】For more SPI communication information, you can search online.
The SP3485 is a low-power half-duplex transceiver that meets the specifications of RS485 serial protocols. It operates from a single +3.3V supply and uses half-duplex communication. The RO and DI terminals are the output of the receiver and the input of the driver, respectively; (RE) ̅ and DE are the receive and transmit enable sides, respectively, when (RE) ̅ is logic 0, the device is in the receiving state; When DE is logic 1, the device is in the transmit state; The A side and the B side are the receiving and transmitting differential signal terminals, respectively, when the A-B > +0.2V, the RO output logic 1; When A-B <-0.2V, the RO outputs logic 0. A matching resistor is added between the A and B terminals, and a 100Ω resistor is generally optional.
RS485 CAN HAT (B)0006.png
Among them: the RE and DE pins of the SP3485 chip are set to receive and send;
This module uses the automatic control of hardware to receive and send.
RS485 CAN HAT (B)077.png
Data receiving: TXD is high at this time, and is in an idle state. At this time, the MOS is turned on, the RE pin of the SP3485 chip is low, the data reception is enabled, and the RO begins to receive data, and the data received by the 485AB port is transmitted to the MCU.
Data transmission: There will be a pull-down level in TXD indicating that data is being sent at the beginning, at which point the MOS cuts off, the DE pin is high, and data transmission is enabled. At this time, if the transmitted data is '1', the MOS will be on, although the reception will become a valid state, but because the chip is in a high-impedance state during the transmission phase, it still maintains the transmit state and transmits '1' normally.