当前位置:网站首页>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
边栏推荐
- Delete some elements in the array
- Why is all (()) true and any (()) false?
- [TestLink] testlink1.9.18 solutions to common problems
- Cmake tutorial Step2 (add Library)
- Binder开辟线程数过多导致主线程ANR异常
- Redis Foundation
- Sentinel flow guard
- 含重复元素取不重复子集[如何取子集?如何去重?]
- Interpretation: how to deal with the current security problems faced by the Internet of things?
- QT console printout
猜你喜欢

Configure pytorch environment in Anaconda - win10 system (small white packet meeting)

记一次使用Windbg分析内存“泄漏”的案例

小林coding的内存管理章节

What are the requirements for PMP certification? How much is it?

Matlab reference
![[JMeter] advanced writing method of JMeter script: all variables, parameters (parameters can be configured by Jenkins), functions, etc. in the interface automation script realize the complete business](/img/a6/aa0b8d30913dc64f3c0cd891528c40.png)
[JMeter] advanced writing method of JMeter script: all variables, parameters (parameters can be configured by Jenkins), functions, etc. in the interface automation script realize the complete business

ISPRS2022/雲檢測:Cloud detection with boundary nets基於邊界網的雲檢測

“12306” 的架构到底有多牛逼?

Six bad safety habits in the development of enterprise digitalization, each of which is very dangerous!

ELK日志分析系统
随机推荐
Teamcenter 消息注册前操作或後操作
论文阅读_中文NLP_LTP
南京大学:新时代数字化人才培养方案探讨
IDC report: Tencent cloud database ranks top 2 in the relational database market!
How can cluster deployment solve the needs of massive video access and large concurrency?
Why is all (()) true and any (()) false?
Anaconda中配置PyTorch环境——win10系统(小白包会)
Star ring technology data security management platform defender heavy release
Zabbix
热通孔的有效放置如何改善PCB设计中的热管理?
Introduction to VC programming on "suggestions collection"
EasyCVR接入设备开启音频后,视频无法正常播放是什么原因?
LeetCode每日一题:合并两个有序数组
Sophon CE Community Edition is online, and free get is a lightweight, easy-to-use, efficient and intelligent data analysis tool
How to solve the error "press any to exit" when deploying multiple easycvr on one server?
Sentinel flow guard
吴恩达团队2022机器学习课程,来啦
Sophon base 3.1 launched mlops function to provide wings for the operation of enterprise AI capabilities
使用Jmeter虚拟化table失败
[JMeter] advanced writing method of JMeter script: all variables, parameters (parameters can be configured by Jenkins), functions, etc. in the interface automation script realize the complete business