当前位置:网站首页>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
边栏推荐
- How to modify MySQL fields as self growing fields
- Sophon Base 3.1 推出MLOps功能,为企业AI能力运营插上翅膀
- VBA drives SAP GUI to realize office automation (II): judge whether elements exist
- 消除`if()else{ }`写法
- Ten top automation and orchestration tools
- leetcode每日一题:字符串中的第一个唯一字符
- 论文阅读_中文NLP_LTP
- MATLAB中print函数使用
- Leetcode daily question: the first unique character in the string
- Elk log analysis system
猜你喜欢
RSE2020/云检测:基于弱监督深度学习的高分辨率遥感图像精确云检测
Six bad safety habits in the development of enterprise digitalization, each of which is very dangerous!
GFS分布式文件系统
[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
EPM相关
2022新版PMP考试有哪些变化?
JVM third talk -- JVM performance tuning practice and high-frequency interview question record
MATLAB查阅
小林coding的内存管理章节
「运维有小邓」用于云应用程序的单点登录解决方案
随机推荐
How can cluster deployment solve the needs of massive video access and large concurrency?
VBA drives SAP GUI to realize office automation (II): judge whether elements exist
Redis Foundation
The comprehensive competitiveness of Huawei cloud native containers ranks first in China!
神经网络自我认知模型
leetcode每日一练:旋转数组
Check namespaces and classes
Easynmon Usage Summary
Interpretation: how to deal with the current security problems faced by the Internet of things?
Teamcenter 消息注册前操作或后操作
Clickhouse (03) how to install and deploy Clickhouse
nano的CAN通信
基于YOLOv3的口罩佩戴检测
Sophon CE Community Edition is online, and free get is a lightweight, easy-to-use, efficient and intelligent data analysis tool
Isprs2022 / Cloud Detection: Cloud Detection with Boundary nets Boundary Networks Based Cloud Detection
职场进阶指南:大厂人必看书籍推荐
ISPRS2022/雲檢測:Cloud detection with boundary nets基於邊界網的雲檢測
Sophon AutoCV:助力AI工业化生产,实现视觉智能感知
“12306” 的架构到底有多牛逼?
[paddleclas] common commands