RS485 CAN for Jetson Nano

From Waveshare Wiki
Jump to: navigation, search
RS485 CAN for Jetson Nano
RS485 CAN for Jetson Nano.png

Environmental Sensor
{{{name2}}}

{{{name3}}}

{{{name4}}}

{{{name5}}}

{{{name6}}}

Overview

RS485 CAN Expansion Board for Jetson Nano.

Features

  • Standard 40PIN GPIO extension header, supports direct attaching to Jetson Nano.
  • Onboard CAN controller MCP2515 via SPI interface, matching with SIT65HVD230DR transceiver.
  • Features RS485 function, controlled via UART, half-duplex communication, supports automatic TX/RX control without programming, onboard transceiver SP3485.
  • Onboard TVS (Transient Voltage Suppressor), effectively suppresses surge voltage and transient spike voltage in the circuit for RS485 transceiving, lightning proof & anti-electrostatic.
  • Onboard digital isolation chip, safer signal isolation communication, and better stability and anti-interference
  • Reserved control pins, allowing working with other control boards.
  • Comes with online development resources and manuals (examples in Python).

Specification

RS485 CAN for Jetson Nano spec.png

How to Connect

RS485 CAN for Jetson Nano spec2.png

What's On Board

RS485 CAN for Jetson Nano spec3.png

Pin Definition

RS485 CAN for Jetson Nano spec4.png

Dimensions

RS485 CAN for Jetson Nano spec5.png

How to Use

Install Libraries

sudo apt-get install minicom 
sudo apt-get install python-pip nano
sudo pip install pyserial
sudo pip install spidev==3.1

Enable SPI

Please refer to #Official B01 Kit Enable SPI for the Official B01 kit.
Jetson Nano B01 with emmc module does not support configuring 40PIN through jetson-io.py. Here we provide a direct way to modify the device tree file to enable SPI1. I have only verified JetPack 4.6.2, this operation requires a reinstallation of the system, please operate it with caution.

Hardware Preparation

  1. Ubuntu computer or virtual machine.
  2. Jetson Nano.
  3. Micro USB cable.

Software Setting (Host PC)

The device tree file needs to be modified on the system. If you have installed the system image on the system by SDK Manager, you can directly modify it. If not, you can refer to the following resource package. The resource package is Jetpack4.6.2 version, and if you need other resource packages, you can click here to download.

Resource Download

  1. Create a new folder on the Ubuntu computer:
    sudo mkdir sources_nano
    cd sources_nano
  2. Download the following two resource packs:
    https://developer.nvidia.com/embedded/l4t/r32_release_v7.2/t210/jetson-210_linux_r32.7.2_aarch64.tbz2
    https://developer.nvidia.com/embedded/l4t/r32_release_v7.2/t210/tegra_linux_sample-root-filesystem_r32.7.2_aarch64.tbz2
  3. Move the resource pack to a folder and decompress it (in actual operation, please try to use the tag button to automatically complete the command).
    sudo mv ~/Downloads/Jetson-210_Linux_R32.7.2_aarch64.tbz2 ~/sources_nano/
    sudo mv ~/Downloads/Tegra_Linux_Sample-Root-Filesystem-R32.7.2_aarch64.tbz2 ~/sources_nano/
  4. Decompress resources:
    tar -xjf Jetson-210_Linux_R32.7.2_aarch64.tbz2
    cd Linux_for_Tegra/rootfs/
    tar -xjf ../../Tegra_Linux_Sample-Root-Filesystem-R32.7.2_aarch64.tbz2
    cd ../
    sudo ./apply_binaries.sh (If an error occurs, follow the system prompts, and then enter the command line again)

Modify Device Tree

  1. Install the dtc tool:
    sudo apt-get install -y device-tree-compiler
    sudo apt-get install nano
    
  2. Decompile the dts file:
    cd kernel/dtb
    sudo dtc -I dtb -O dts -o tegra210-p3448-0002-p3449-0000-b00.dts tegra210-p3448-0002-p3449-0000-b00.dtb
  3. Modify the dts file:
    sudo cp tegra210-p3448-0002-p3449-0000-b00.dts tegra210-p3448-0002-p3449-0000-b00-bak.dts
    sudo nano tegra210-p3448-0002-p3449-0000-b00.dts

    Press ctrl^w, input spi@7000d400 (followed by a space), press Enter and find the spi@7000d400{} part.
    Config1-1re.png
    Add the statement status = "okay" in the spi@0 structure and spi@1 structure respectively;
    Config1-2re.png
    Find the pin setting of spi1, modify nvidia, function to spi1, nvidia,tristate to 0x0. Modify nvidia,enable-input to 0x1. Five pins should be configured. THe effect as shown below:

    Config1-3re.png

  4. Ctrl+Y to save the file and recompile it to dtb. Note, if you need to modify the SD card and other operations, please do it together. The main thing is not to modify the wrong position, otherwise, it will easily cause the system to fail to start normally.
    sudo dtc -I dts -O dtb -o tegra210-p3448-0002-p3449-0000-b00.dtb tegra210-p3448-0002-p3449-0000-b00.dts

Re-program System

Set nano to recovery burning mode, and connect to the Ubuntu computer. Note that only updating the dtb partition is not supported here, so the entire system needs to be re-burned, and the boot configuration needs to be re-done after burning the system. Therefore, please connect the HDMI screen and keyboard to the Nano in advance.

cd ../../
sudo ./flash.sh jetson-nano-emmc mmcblk0p1

Test SPI

  1. After the system is burned successfully, the boot configuration is completed, and the nano will restart automatically.
    Load spidev:
    sudo modprobe spidev
    git clone https://github.com/rm-hull/spidev-test
    cd spidev-test/
    gcc spidev_test.c -o spidev_test
  2. Use a cable to short pins 19 and 21 of nano 40PIN, and run the program test:
    ./spidev_test -v -D /dev/spidev0.0 -p "Test"

    If the printing information is interrupted, RX and TX can send and receive information normally.
    Config1-4.jpg


Official B01 Kit Enable SPI

After executing the above, add in the following file:

sudo nano /etc/modules-load.d/modules.conf

add a line:

spidev

Press ctrl+x and then press Y, press Enter to save and exit, and then open the hardware SPI:

sudo /opt/nvidia/jetson-io/jetson-io.py

as shown.
Choose to configure 40PIN pin.
Enable SPI1.png
Use the keyboard to select, and configure the pins.
Enable SPI2.png
Use the keyboard to select, move to SPI1 and press Enter to confirm.
Enable SPI3.png
Save and select restart (keep Enter to restart).
Enable SPI4.png
After restarting, ls /dev/spidev* can see the device number.
Enable SPI-5.png

Download the Sample Demo

In the user main directory, execute the following command:

wget https://files.waveshare.com/upload/7/77/RS485_CAN_for_JetsonNano_Code.zip
sudo unzip ./RS485_CAN_for_JetsonNano_Code.zip -d ./RS485_CAN_for_JetsonNano_Code/

CAN

Please connect the hardware first, and then run the program. As SPI to CAN and the default crystal oscillator is 8M, the temporary baud rate is 500Kbps.
The Python driver provided by this product currently supports a baud rate of 500Kbps (the default is 500Kbps), pay attention to select the baud rate of the other end of the communication:

cd RS485_CAN_for_JetsonNano_Code
sudo python cantest.py

The test demo will send 1-8 when a message is received;

485

Please connect the hardware first, and then run the program. RS485 is transferred from UART, so please do not occupy UART.

sudo python rs485test.py

Resource

Document

Code

Related Resource

FAQ

 Answer:

The maximum baud rate currently supported is 500Kbps.

{{{5}}}



Support



Technical Support

If you need technical support or have any feedback/review, please click the Submit Now button to submit a ticket, Our support team will check and reply to you within 1 to 2 working days. Please be patient as we make every effort to help you to resolve the issue.
Working Time: 9 AM - 6 PM GMT+8 (Monday to Friday)