当前位置:网站首页>Can communication of nano
Can communication of nano
2022-07-05 18:03:00 【Luo Xiaohei has a good war record】
I bought raspberry pie with light snow SPI turn CAN. Now it's used in jetson nano On . I saw that the chips of the two modules are the same , The pins are all right , So I'm going to give this module to nano do can signal communication .
Have CAN function , Use SPI Interface CAN controller MCP2515, With transceiver SN65HVD230. Microchip Of MCP2515 Is a CAN Protocol controller , Fully support CAN V2.0B The technical specification . The device can send and receive standard and extended data frames as well as remote frames . MCP2515 The built-in two acceptance mask registers and six acceptance filter registers can filter out unwanted messages . CAN The output pin of the controller Tx Receive SN65HVD230 The data of
Input end D, This can be CAN The data sent by the node is transferred to CAN In the network ; and CAN The receiving pin of the controller Rx and SN65HVD230 The data output of R Connected to a , For receiving data .
I bought it for raspberry pie can Expansion board
In short, start the installation
Specifically for nano It's done can Communication adapter board 
minicom External hardware devices can be controlled through serial port . Suitable in linux Manage embedded devices through HyperTerminal . It can also be used minicom On the outside Modem Control .
linux hyper terminal minicom How to use
minicom Is a serial terminal debugging tool

Use /etc/modules-load.d/ To configure which modules are loaded when the system starts
Linux Module loading process and how to make the system automatically load modules after startup

Follow the web tutorial steps , You can see our nano Of spi1 Pin and mine can On module spi Pins correspond to
【 acutely Restart failed after setting , Now the screen has been black , You can only re burn the image . After re burning and re operating, the tutorial is no problem , But the module pin and baud rate on my side don't match 】
There are several problems after installation
- I bought raspberry pie with light snow SPI turn can, That module sets the interrupt output pin to nano Of 20 Position of pin No , I should change the module pin setting to 26 Pin No . But look nano Of SPI turn can The module of is also to set the position of the interrupt pin randomly . Maybe it doesn't matter if you change this .
- The baud rate is not right
- The extracted code file is only readable
# Written by the merchant nano Of cantest.py The test routine will send 1-8
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import MCP2515
import time
print("--------------------------------------------------------")
# try:
# This setup is referred to CAN SPI click mounted on flip n click device slot A
can = MCP2515.MCP2515()
print("init...")
can.Init()
print("send data...")
data = [1, 2, 3, 4, 5, 6, 7, 8]
can.Send(data, len(data))
readbuf = []
# while(1):
while(1):
readbuf = can.Receive()
print(readbuf)
time.sleep(0.5)
print("--------------------------------------------------------")
# except Exception as e:
# print(e)
About file permissions , I learned from brother bird
sudo chmod 777 -R Folder name /
This sentence opens all permissions
0(0+0+0)- No authority .
1(0+0+1)- Only execute permissions .
2(0+2+0)- Write permission only .
3(0+2+1)- Write and execute permissions .
4(4+0+0)- Read only permission .
5(4+0+1)- Read and execute permissions .
6(4+2+0)- read-write permission .
7(4+2+1)- Read 、 Write and execute permissions .
Usually we use Vim edit Shell After batch processing of documents , File permissions are usually rw-rw-r–(644), that , If you want to make the file executable , And don't let anyone else modify this file , Only the permission of this file should be rwxr-xr-x(755) that will do .
chmod 755 Set the user's permission to :
1. The file owner can read, write, and execute
2. Other users belonging to the same user group as the file owner can read and execute
3. Other user groups can read and execute
can Baud rate
MCP2515 Baud rate configuration
Because my module is 12M Crystal oscillator , The default in the program 8M Crystal oscillator , Therefore, it is necessary to recalculate the proportion of each communication stage according to the manual , Just refer to the blog above .
The calculation process is complicated , It still needs a little experience . Tell the truth , If you have that time to understand my above calculation process , It's better to read the blog and deduce by yourself .
What we need to know is 500Kbps Is the corresponding 2us Of Tbit. from 1/2us obtain . In the same way 250Kbps Is the need to 4us,125Kbps by 8us

【 Yes, of course , I didn't test one by one 】
If you change these two places, you can communicate 【 Connect the hardware first 】
So it really doesn't matter about the pin , I'm using 29 No. pin is output as an interrupt
Think about sending information

The merchant is set like this Only one was made send function . If you want to send extended frames, you can only write them yourself .
The appended drawings
nano Corresponding pin interface of
This is the default pin function when nothing is set 
nano Another more detailed table of , It is the corresponding pin that can be set to open .
This is nano Setting interface of 
Snowy nano A dedicated SPI turn CAN modular

Special for raspberry pie with light snow SPI turn CAN modular


Extended reading
Ying Wei Da Jeston nano<3> Use Python Realize three ways of serial communication
Jetson Nano To configure 40 Pin extension connector
linux Prompt when editing the file swp The file already exists
边栏推荐
- 南京大学:新时代数字化人才培养方案探讨
- Disabling and enabling inspections pycharm
- Leetcode exercise - 206 Reverse linked list
- Leetcode notes: Weekly contest 300
- ISPRS2022/云检测:Cloud detection with boundary nets基于边界网的云检测
- Xiaobai getting started with NAS - quick building private cloud tutorial series (I) [easy to understand]
- U-Net: Convolutional Networks for Biomedical Images Segmentation
- nano的CAN通信
- GFS分布式文件系统
- 星环科技重磅推出数据要素流通平台Transwarp Navier,助力企业实现隐私保护下的数据安全流通与协作
猜你喜欢
![最大人工岛[如何让一个连通分量的所有节点都记录总节点数?+给连通分量编号]](/img/8b/a60fc36115580f018445e4c2a28a9d.png)
最大人工岛[如何让一个连通分量的所有节点都记录总节点数?+给连通分量编号]

mybash

Binder开辟线程数过多导致主线程ANR异常

Star Ring Technology launched transwarp Navier, a data element circulation platform, to help enterprises achieve secure data circulation and collaboration under privacy protection

Sophon base 3.1 launched mlops function to provide wings for the operation of enterprise AI capabilities

nacos -分布式事务-Seata** linux安装jdk ,mysql5.7启动nacos配置ideal 调用接口配合 (保姆级细节教程)

吴恩达团队2022机器学习课程,来啦

Leetcode daily question: the first unique character in the string

Ten capabilities that cyber threat analysts should have

Cmake tutorial step1 (basic starting point)
随机推荐
Sentinel flow guard
Size_t 是无符号的
Sophon kg upgrade 3.1: break down barriers between data and liberate enterprise productivity
使用QT遍历Json文档及搜索子对象
消除`if()else{ }`写法
nacos -分布式事务-Seata** linux安装jdk ,mysql5.7启动nacos配置ideal 调用接口配合 (保姆级细节教程)
Teamcenter 消息注册前操作或後操作
Redis Foundation
Which platform of outer disk gold is regular and safe, and how to distinguish it?
PMP认证需具备哪些条件啊?费用多少啊?
MATLAB查阅
leetcode每日一练:旋转数组
深拷贝与浅拷贝【面试题3】
Read libco save and restore the on-site assembly code
ISPRS2022/雲檢測:Cloud detection with boundary nets基於邊界網的雲檢測
Leetcode exercise - 206 Reverse linked list
Sophon autocv: help AI industrial production and realize visual intelligent perception
Disabling and enabling inspections pycharm
Numerical calculation method chapter8 Numerical solutions of ordinary differential equations
EasyCVR平台通过接口编辑通道出现报错“ID不能为空”,是什么原因?