当前位置:网站首页>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
边栏推荐
- OpenShift常用管理命令杂记
- Wu Enda team 2022 machine learning course, coming
- 「运维有小邓」用于云应用程序的单点登录解决方案
- 2022新版PMP考试有哪些变化?
- Star Ring Technology launched transwarp Navier, a data element circulation platform, to help enterprises achieve secure data circulation and collaboration under privacy protection
- Why is February 28 in the Gregorian calendar
- 小林coding的内存管理章节
- VC编程入门浅谈「建议收藏」
- tkinter窗口预加载
- Mask wearing detection based on yolov3
猜你喜欢
最大人工岛[如何让一个连通分量的所有节点都记录总节点数?+给连通分量编号]
Redis Foundation
图片数据不够?我做了一个免费的图像增强软件
使用Jmeter虚拟化table失败
Mask wearing detection based on yolov3
PMP认证需具备哪些条件啊?费用多少啊?
含重复元素取不重复子集[如何取子集?如何去重?]
leetcode每日一题:字符串中的第一个唯一字符
Huaxia Fund: sharing of practical achievements of digital transformation in the fund industry
Matlab reference
随机推荐
flask接口响应中的中文乱码(unicode)处理
Redis基础
Sophon CE Community Edition is online, and free get is a lightweight, easy-to-use, efficient and intelligent data analysis tool
leetcode每日一练:旋转数组
PMP认证需具备哪些条件啊?费用多少啊?
Matlab built-in function how different colors, matlab subsection function different colors drawing
「运维有小邓」用于云应用程序的单点登录解决方案
图像分类,看我就够啦!
Le cours d'apprentissage de la machine 2022 de l'équipe Wunda arrive.
Sophon kg upgrade 3.1: break down barriers between data and liberate enterprise productivity
Cmake tutorial step5 (add system self-test)
Leetcode notes: Weekly contest 300
寻找第k小元素 前k小元素 select_k
在一台服务器上部署多个EasyCVR出现报错“Press any to exit”,如何解决?
Zabbix
Nanjing University: Discussion on the training program of digital talents in the new era
Which platform of outer disk gold is regular and safe, and how to distinguish it?
Interpretation: how to deal with the current security problems faced by the Internet of things?
EPM related
Redis Foundation