当前位置:网站首页>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
边栏推荐
- VBA drives SAP GUI to realize office automation (II): judge whether elements exist
- Cmake tutorial Step3 (requirements for adding libraries)
- Sophon base 3.1 launched mlops function to provide wings for the operation of enterprise AI capabilities
- Matlab built-in function how different colors, matlab subsection function different colors drawing
- How can cluster deployment solve the needs of massive video access and large concurrency?
- Operation before or after Teamcenter message registration
- Image classification, just look at me!
- Redis基础
- [performance test] full link voltage test
- PMP认证需具备哪些条件啊?费用多少啊?
猜你喜欢

Leetcode daily question: the first unique character in the string

Star ring technology data security management platform defender heavy release

Privacy computing helps secure data circulation and sharing

图扑软件数字孪生 | 基于 BIM 技术的可视化管理系统

How awesome is the architecture of "12306"?

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

神经网络自我认知模型

Neural network self cognition model

LeetCode每日一题:合并两个有序数组

flask接口响应中的中文乱码(unicode)处理
随机推荐
吳恩達團隊2022機器學習課程,來啦
How to improve the thermal management in PCB design with the effective placement of thermal through holes?
Binder开辟线程数过多导致主线程ANR异常
Compared with the loss of Wenxin, the performance is improved a lot
隐私计算助力数据的安全流通与共享
神经网络自我认知模型
较文心损失一点点性能提升很多
Cmake tutorial Step4 (installation and testing)
最大人工岛[如何让一个连通分量的所有节点都记录总节点数?+给连通分量编号]
Zabbix
leetcode每日一题:字符串中的第一个唯一字符
MATLAB中print函数使用
How can cluster deployment solve the needs of massive video access and large concurrency?
星环科技重磅推出数据要素流通平台Transwarp Navier,助力企业实现隐私保护下的数据安全流通与协作
论文阅读_中文NLP_LTP
Redis Foundation
Is it safe to open an account online? What is the general interest rate of securities financing?
PMP认证需具备哪些条件啊?费用多少啊?
rsync
ISPRS2020/云检测:Transferring deep learning models for cloud detection between Landsat-8 and Proba-V