CANopen 协议简介

本文介绍了CANopen协议,包括设备体系结构、对象字典、网络管理(NMT)、心跳包、PDO、SDO、紧急消息生产和消费、LSS节点ID和比特率设置、CANopen网关以及一致性测试工具。详细阐述了CANopen协议栈的各个组成部分及其在CAN网络中的作用,同时提到了CANopen开源实现项目CANopenNode。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、CANopen 开源代码

https://github.com/CANopenNode/CANopenNode/blob/master/README.md

1、CANopen internal device architecture

1.1、CANopen 设备体系结构

General device architecture
As illustrated, a CANopen device consists of three logical parts. The CANopen protocol stack handles the communication via the CAN network. The application software provides internal control functionality as well as an interface to the process hardware. The CANopen object dictionary interfaces the protocol and the application software. It contains references for all used data types and stores all communication and application parameters.
consists of three logical parts
在这里插入图片描述

1.2、CANopen object dictionary 对象字典

In this object dictionary, all data that needs to be exchanged between the communication part (CANopen protocol stack) and the application part (application software) of the device owns unique 24-bit addresses.
CANopen 的协议层与 application 之间通过 object dictionary 进行 数据交换,24位的地址数据 ,
This address is divided into a 16-bit index and an 8-bit sub-index. Any entry in the CANopen object dictionary is readable via CANopen communication services.
Sub-index是用于标识一个对象字典(Object Dictionary)中对象的子属性或子元素的索引
在这里插入图片描述
System designers can adjust the desired communication behavior (e.g. participating in a synchronous network behavior; establishing communication coherences between two or several network participants, etc.) in the index range 1000h to 1FFFh. 这个地址范围定义网络同步,建立网络参与者之间的通信连贯的行为。
In the object ranges 2000h to 5FFFh and 6000h to 9FFFh application specific parameters can be set either in a manufacturer specific or standardized way, according to CiA device and application profiles. 这个几个地址范围是 应用的特定或者标准的 参数,依照 CiA 设备或者 应用的profiles 文件。

2、Network management (NMT)

2.1、概述

The CANopen NMT state machine consists of an Initialization state, a Pre-operational state, an Operational state, and a Stopped state. After power-on or reset, the device enters the Initialization state. 网络管理 包含的几个状态
在这里插入图片描述

  • initialization :initialization is finished, the device automatically transits to Pre-operational state and indicates this transition by sending the boot-up message.
  • Pre-operational: A device that stays in Pre-operational state can start to transmit SYNC-, Time Stamp- or Heartbeat messages if these services are supported and configured in the right way. PDO communication that has to be disabled in this state, the device can communicate via SDO
  • Operational:PDO communication is only possible in the Operational state.During Operational state, the device can use all supported communication objects.
  • Stopped:A device that was switched to the Stopped state only reacts to received NMT commands.In addition, the device indicates the current NMT state by supporting the error control protocol during Stopped state.

2.2、Initilization state

初始化状态分为三个子状态:The Initialization state covers the three substates Initialising, Reset Application, and Reset Communication.

  • Initialising:During Initialising, the device starts up and initializes its internal parameters.
  • Reset Application:introduced to enable partial reset commands, During Reset Application all parameters in the object dictionary range from 2000h to 9FFFh are set to the power-on or default values.
  • Reset Communication:introduced to enable partial reset commands,After setting the power-on values, the NMT substate Reset Communication is entered autonomously. During the Reset Communication substate, the parameters of the communication profile (Index range 1xxxh) are set to their power-on/default values. communication profile 被设置为 power-on/default values.

2.3、NMT protocol

The reception of the NMT protocol forces the CANopen device to transit to the commanded NMT state.
The NMT protocol comes in a single CAN frame with a data length of 2 byte.

  • The first byte contains the command specifier 包含命令说明符
  • the second contains the Node-ID of the device that has to perform the command (if this value is equal to 0, all nodes have to perform the commanded state transition). 执行命令状态转换
    在这里插入图片描述

3、Heartbeat 心跳包

NMT FSA代表网络管理(Network Management)状态机(Finite State Automaton)。NMT FSA是CANopen网络中的一个关键部分,用于管理网络中的节点并控制其状态转换。

3.1、Error control protocols

Error control protocols enable the monitoring of a CANopen network.

  • All error control protocols (Heartbeat and Boot-up message) use the same the CAN-ID (700h + Node-ID).

3.2、Heartbeat protocol

The Heartbeat protocol is a cyclically transmitted message that informs all heartbeat consumers of the availability of the heartbeat producer.

  • In addition to the availability of the heartbeat producer, the heartbeat protocol provides the current NMT FSA state of the heartbeat producer.
  • The cycle time for transmitting the Heartbeat message is configurable in the object dictionary index 1017h.

3.3、Boot-up protocol

The boot-up protocol represents a special type of an error control protocol.

3.4、Node-/Life guarding protocol

4、PDO

broadcasting process data with high priority and no protocol overhead.Variables from Object Dictionary can be dynamically mapped to the TPDO, which is then transmitted according to communication rules and received as RPDO by another device.
SDO server enables expedited, segmented and block transfer access to all Object Dictiona

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值