RS485 CAN for Jetson Nano
| ||
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
How to Connect
What's On Board
Pin Definition
Dimensions
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
- Ubuntu computer or virtual machine.
- Jetson Nano.
- 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
-
Create a new folder on the Ubuntu computer:
sudo mkdir sources_nano cd sources_nano
- 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
- 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/
- 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
- Install the dtc tool:
sudo apt-get install -y device-tree-compiler sudo apt-get install nano
- 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
- 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.
Add the statement status = "okay" in the spi@0 structure and spi@1 structure respectively;
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: - 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
-
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
- 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.
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.
Use the keyboard to select, and configure the pins.
Use the keyboard to select, move to SPI1 and press Enter to confirm.
Save and select restart (keep Enter to restart).
After restarting, ls /dev/spidev* can see the device number.
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
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)