CANopen对象字典生成办法
canopen builder逻辑控制编程

canopen builder逻辑控制编程CanOpen Builder 是一种常见的逻辑控制编程软件,专门用于CanOpen 协议设备的编程。
它的主要作用是以图形化编程方式,对CanOpen 设备进行程序设计和调试。
下面,将从以下几个方面详细阐述 CanOpen Builder 的逻辑控制编程过程。
1.安装 CanOpen Builder 软件首先,需要安装 CanOpen Builder 软件,然后打开软件,在菜单中选中“New Project”,并输入项目名称、选中设备类型、通信端口等信息,创建一个新的控制项目。
在软件左边的项目树中,可以看到主页面、配置、对象字典、软件版本等选项。
2.编辑对象字典在 CanOpen 协议中,对象字典是由许多不同类型和参数的对象组成。
首先,需要在 CanOpen Builder 软件中创建对象字典。
在“对象字典”选项中,选中“新建”按钮,然后设置对象的属性,包括它的ID、子 ID、类型和数据等。
在编辑对象字典时,需要确保对象的ID和子 ID 唯一,并正确设置其数据类型和参数。
3.创建模块CanOpen 设备通常包含多个模块,例如 I/O 模块、数据采集模块、控制模块等。
在 CanOpen Builder 中,需要创建一个新的模块来包含这些对象。
选择“新建模块”按钮,设置模块的名称、参数、数据类型等信息。
然后,在模块的属性中,可以添加/删除对象,修改变量值、参数等。
4.编写控制逻辑使用 CanOpen Builder 来编写控制逻辑是非常简单的。
在软件中单击“逻辑控制”选项,并选择“新建程序”按钮。
在编写程序过程中,需要设置输入/输出变量、控制语句、循环等。
控制语句可使用常见的命令,如 if/else, while, for 等等。
然后,将完成的程序上传至 CanOpen 设备中,以实现控制。
5. 调试程序编写完成后,需要对程序进行调试。
CanOpen Builder 软件可以实现快速的程序调试,比如检查程序的变量值、观察实际设备状态以及检查通信错误等。
CANopen对象字典的分析与具体实现

金超 。 夏继 强 。 庆 丰 满
( 京 航 空 航 天 大学 机 械 工 程及 自动 化 学 院 , 京 1 0 9 ) 北 北 0 1 1
摘 要 :C ANo e p n是 基 于 CAN 总线 的 开 放 的 、 准 化 的 应 用 层 协 议 , 象字 典 是 其 核 心 概 念 。本 文 在 对 C 标 对 ANo e p n对 象
atiu e f betso a esrtge r ic se ,a d so a ea dr a / i ce smeh d f betdcin r r ie . tr tso jc tr g ta e isa edsu s d n t rg n e d wrt ac s t o so jc it a yaegv n b o e o o
的接 口。
典 结 构 都 是 相 同的 , 为 通 信 参 数 、 造 商 定 义 对 象 和 设 这 制
备 对 象 提 供 了一 套 标 准 化 的 地 址 空 间 。
1 2 对 象 字 典 中对 象 的 结构 .
对 象 字 典 中 的元 素 , 各 种 通 信 对 象 和 应 用 对 象 , 即 使
Ke r s y wod :CANo e o jc it n r ;S ai a ry p n;be tdci a y ttc ra s o
略 , 出 了对 象 字典 的具 体 实 现方 法 。 给
引 言
CANo e p n协 议 是 在 C AN 总 线 的基 础 上 定 义 的 应 用 层 协 议 , 具有 高 度灵 活 配 置 能 力 的标 准化 嵌 入式 网 络 协 是 议 。 因其 协 议 精 练 、 明 、 于理 解 , 具 有 实 时性 和 可 靠 透 便 又 性 高 、 据 传 输 速 率 高 、 网 成 本 低 等优 点 , 多个 领 域 中 数 组 在
canopen 字典 使用方法

canopen 字典使用方法CanOpen 字典的使用方法引言:CanOpen 是一种用于工业自动化领域的通信协议,它基于 CAN 总线,并使用字典来组织和描述设备的功能和参数。
本文将介绍CanOpen 字典的使用方法,帮助读者更好地理解和应用 CanOpen 协议。
一、CanOpen 字典的概述CanOpen 字典是CanOpen 协议中的重要组成部分,它定义了设备的功能和参数,使得CanOpen 设备之间可以进行有效的通信。
字典由一系列的对象字典和子字典组成,每个对象字典包含一个或多个对象,每个对象有唯一的标识符和属性,用于描述设备的功能和参数。
二、CanOpen 字典的结构CanOpen 字典采用树状结构组织,由对象字典和子字典构成。
对象字典是字典的最基本单位,它包含了设备的功能和参数信息。
子字典是对象字典的集合,用于组织和分类对象字典。
通过对象字典的索引和子字典的标识符,可以方便地定位和访问设备的功能和参数。
三、CanOpen 字典的使用方法1. 查找对象字典要查找对象字典,首先需要知道设备的字典索引和子字典标识符。
然后,按照索引和标识符,可以在CanOpen 字典中找到相应的对象字典。
可以使用CanOpen 设备的配置工具或者CanOpen 字典编辑器来查找对象字典。
2. 读取对象字典读取对象字典的方法取决于CanOpen 设备的通信接口和协议。
通常,可以通过发送特定的CanOpen 消息来读取对象字典。
消息中包含了读取对象的索引和标识符,设备接收到消息后,会返回相应的对象值。
3. 写入对象字典写入对象字典和读取对象字典类似,也需要发送特定的CanOpen 消息。
消息中包含了写入对象的索引、标识符和数值。
设备接收到消息后,会将数值写入相应的对象字典中。
4. 配置对象字典CanOpen 字典中的对象可以通过配置来实现特定的功能和参数设置。
配置对象字典通常需要发送一系列的CanOpen 消息,包含了配置信息和指令。
canopen中的对象字典通俗讲解

canopen中的对象字典通俗讲解
CanOpen是一种用于工业控制领域中的通信协议,其中的对象字典是CanOpen的核心概念之一。
对象字典是CanOpen中用于描述设备的数据结构,通常包括设备的参数、状态、控制命令等信息。
在CanOpen通讯中,各个设备之间通过发送和接收报文来实现通信。
发送方将需要发送的数据打包成报文,然后通过总线发送给接收方。
接收方在接收到报文后,将其解析并提取出所需的信息。
对象字典就是用来帮助接收方解析报文的。
发送方在发送报文时,需要将报文中涉及到的对象字典的索引和子索引打包成报文中的数
据域。
接收方在接收到报文后,就可以通过报文中的索引和子索引在对象字典中查找所需的数据。
对象字典中的每个对象都由一个唯一的索引和一个子索引组成。
索引和子索引的作用就是用来定位对象。
当接收到报文时,接收方通过报文中的索引和子索引来查找对象字典中的对应对象。
对象字典中的每个对象都有其对应的数据类型和数据长度,接收方在查找到对应对象后,就可以根据对象的数据类型和数据长度来解析出其具体的值。
除了用来描述设备参数和状态等信息外,对象字典还可以用来描述控制命令。
发送方在发送控制命令时,将命令代码打包成报文中的数据域,接收方在接收到报文后,就可以根据命令代码来执行相应的控制操作。
总之,对象字典是CanOpen通信中的核心概念之一,是用来描述设备的数据结构,包括参数、状态、控制命令等信息。
它能够帮助发
送方将所需发送的数据打包成报文,并帮助接收方解析和提取出所需的信息,从而实现设备之间的通信。
对象字典

Powerlink 的对象字典一、 对象字典简介设备对象字典是CANopen 的核心概念。
CANopen 是CAN 网络的应用层协议,CANopen 建立在CAN 的数据链路层(CAN 只定义了物理层和数据链路层)之上。
一个典型的CANopen 设备(如下图1.1所示)可以分为三个部分:● 通信部分 ● 对象字典 ● 应用部分图 1.1 典型的CANopen 设备模块通行部分提供在总线上收发通信对象的服务,应用部分出了处理硬件接口外还提供设备内部控制功能,对象字典是通信部分和应用程序的接口,他描述了设备使用的数据类型、通信对象以及应用对象。
对象字典是设备描述中最重要的部分,其实质是一组对对象集合,可以以一种定义好的方式被网络中的设备访问。
主要的参考标准是CiA301。
二、 对象字典的规约2.1 对象字典的一般结构对象字典条目的格式如下图2.2所示。
图 2.1 对象字典的条目结构对象字典的记录条目如上所示,包括6个部分。
(1)Index对象字典的索引是用来表示此条对象在字典中的位置,类似于对象的地址。
(2)Object对象栏用特定的对象名表示,它用来表示对象字典里的特定索引处的对象类型。
所有的对象类型如下表2.1所示。
表 2.1 对象字典的对象类型定义(3)Name名称栏给出一个对特定对象的功能的文本描述。
(4)Type类型栏给出对象类型。
包含以下的预定义类型:布尔,浮点数,无符号整形,有符号整形,8 字节/可见字符串,time-of-day,时差和域。
它也包含预定义的复杂数据类型,例如PDO映射和其他一些如生产商或设备规定。
不能定义记录的记录,记录排列或者排列的记录也属于这种类型。
当对象是一个排列或一个记录,子索引就是对象里的一个数据域。
(5)Attrib.属性栏特定对象的访问权限。
对象可以是如下表2.2所列的属性。
表 2.2 对象的属性(6)M/OM/ O栏定义对象是强制性的还是可选的。
强制性对象必须在设备上实现,可选对象可以不必在设备上实现。
CANopen devds402_对象字典设计(德国)

It’s easy to create a CANopen compliant DSP-402 drive,isn’t it?Torsten Gedenkport GmbH, Germany1. IntroductionModern drives systems can be adapted to the most different custom-designed require-ments and integrated into all sorts of communication networks. As a robust field bus sys-tem CANopen finds increasingly use in drive applications. Therefore many users are fac-ing the necessity to integrate the CANopen communication profile into their drives.Figure 1 - Structure of a CANopen deviceThe CANopen software must provide all components necessary for a CANopen drive as represented in the figure 1.To achieve this, the following considerations play a decisive role:1. How to achieve the fastest and most cost effective implementation in conformitywith the CANopen standard?2. How is the implementation carried out?3. Which software tools are available?4. Which of these are, in addition, useful?This article describes how a CANopen drive can be developed successfully in shortest time with the aid of software tools.2. Components of a CANopen driveThe CiA has published different standards for the communication in a CANopen net-work. The available CANopen services are defined in the communication profile DS-301. Special drive functions with their parameters are defined in the "Device profiles Drives and Motion Control" DSP-402.The DSP-402 defines the behavior of a drive at the start, the configuration and the execution of motion sequences by a state machine.A CANopen drive can be divided into following parts:•drive application•communication stack and special drive profile in conformity with the standards DS-301 and DSP-402.•object dictionary•CAN driver interfaceThe drive application is not CANopen specific and therefore shall not be examined in detail. The communication interface and protocol software provide services to transmit and to receive communication objects over the bus. The object dictionary describes these data types, communication objects and application objects used in this drive.Conse-quently the most important part of a CANopen drive is the object dictionary.All data and parameter of a drive,which should be visible from CAN, are stored in the object dictio-nary and can be reached via the object dictionary.It is the interface to the application software. The application program provides the internal control functionality as well as the interface to the process hardware interfaces. The CAN driver is the interface to send and receive CAN messages.Possible realization variants are:•drive application and CANopen communication on one micro controller or•further use of the available drive controller and CANopen communication on a separate communication processor with a RS485 connection, a dual port RAM or another solu-tion for data interchange.The advantage of the first variant are the lower manufacturing costs.In contrast to that the second variant ensures that the full power of the micro controller is available for the drive control. Additionally,the reuse of existings drive components may save dev e lop-ment time.3. Software requirementsIn order to implement the CANopen functionality an individualized CANopen stack could be developed or alternatively,an already available CANopen stack could be uti-lized.The efforts for the development of an individually designed CANopen stack appears to be substantial when the necessary standards and possible requirements of implementing the CANopen conformance tests, together with the CANopen drive,are taken into considera-tion. This means that it would be preferable to invest in an available stack.Further arguments against developing an individualized CANopen stack are the benefits available to the user of a ready-made stack.These include, for example, the guaranteed updating service or the special support for implementation offered by the provider of the CANopen stack.All relevant protocol stacks on the market are written in ANSI-C and therefore cover the main use case since more than 90% of the drive software is implemented in this program-ming language.This does not rule out that special parts of the drive control are written in assembler.Depending on the drive application to be realized the operation modes have to be imple-mented and their extent have to be defined. DSP-402defines operating modes with mandatory objects for each mode.Additional functionality can be implemented by optional objects and even manufacturer specific objects.The design of the CANopen interface to an existing drive application depends a lot on the requirements and on the structure of the application.The interface can contain:•the state machines defined in DS-301 and DSP-402,•the object dictionary and•a signalisation of all CANopen events.The simplest way of linking is the use of the application variables in the object dictionary. While the drive application is using the variable like before, it can be accessed via CANopen using SDOs.For further services (e.g. transmission of a PDO) the CANopen stack provides functions.pdoNr = 1;writePdoReq( pdoNr );Listing 1 - Transmission of a PDOThese functions encapsulate all related actions, like the following for the example above (listing 1):•Check of the NMT state•Check of the inhibit time, if necessary•Preparation of the PDO data by reading the corresponding values from the object dic-tionary (e.g. status word and actual position)•Transmission of the PDO, if it is asynchronous•or storage of the PDO in the SYNC buffer,if it is a synchronous PDOTo inform the application about CANopen requests, CallBack functions are used.On occurence of a CANopen event (Indication) the corresponding CallBack function is called. In this function the application can react to the event, if necessary.4. Design of the Object DictionaryThe most important part of the development of a CANopen drive is the design of the object dictionary.An object dictionary is difficult to create.In addition to the process data it contains value ranges, initialization values, access attributes and including the manufacturer’s parame-ters, which have to be set up in conformity with the standards and the application.Appli-cation data can be C variables that have to be assigned to the objects.It is sensible to maintain these data in a general data base and to use a software tool to generate the object dictionary in implementation code (mostly in C).The used database can also be used for the creation of Electronic Data Sheets (EDS).This automatically produces the advantage of an exact conformity with the implementation of the device and the EDS.If the input of the device specific interpretation of the parameters can be organized through a yet more detailed description, the developer can get a documentation of the device at the same time with little additional effort. This documentation serves not only as the basis of the user documentation, but is also helpful to maintenance and test tasks.Figure 2 - CANopen Design ToolThere are the the following advantages:•Such tools provide drive data bases, from which an object dictionary in C-code, an Electronic Data Sheet and a documentation are produced automatically.•The generated C-source code of the object dictionary is included by the application modules. This ensures the direct access to the variables (via variable names) and the access via index and sub-index.•These tools take over error-prone tasks and repetitious jobs and supports the implemen-tation part.5. Test of the CANopen driveThe next step is the integration of the drive into a network respectively the test of the drive.A CAN-analyser is indispensable for the implementation of CANopen networks and the integration of CANopen equipment.A CAN-analyser provides the online obser-vation of the bus traffic, sending unique or cyclic messages and whole message sequences as well as recording of the CAN messages and storing into logging files.It is advisable if supplementary software modules provide extended functions like a CANopen specific representation of the messages.Besides a CAN-Analyzer it is helpful to use a tool that allows the configuration of the CANopen drives in a CANopen network. Furthermore the access to the implemented CANopen services should be possible and it should be supported to write test or control applications. The test software must be able to import the EDS file or the device descrip-tion file (ISO-15745-compliant) of the device to get information about the representation of the object dictionary.For such an integration and test of CANopen devices resp. networks the CANopen Device Monitor (CDM, figure 3) can be used.Its scripting capability facilitates tests and can be used for network control.The following listing (listing 2) shows an example script for drives in the profile position mode.set targetPosition 5000go $targetPositionwaitForPDO 1 TargetReachedset actPosition [r 0x6063 0 i32]set deviation [expr $actPosition - $targetPosition]puts "Deviation: $deviation"if { $deviation > 10 } {puts "Error: Deviation too high"}Listing 2 - Position controlAt first the command to go to a defined position is sent (go).Then the script waits until the bit "TargetReached" is set in the first PDO.When the drive has reached its target position, the actual position is read and compared with the target position.If the devia-tion is too high, an error message is typed out.The above example can be extended that different control parameters can be adjusted and the respective paths can be recorded as a set of curves.Figure 3 - CDM with drive configuration componentsThe drives extension for the CDM extends it with dialogs to control the state machine and to test the profile position mode.Further the status and control words are displayed bit by bit.One tab contains the complex state machine of the DSP-402.There state changes can be triggered by mouse clicks instead of bit-wise modification in the object 0x6040.The sta-tus word can be polled cyclically with SDOs or received by PDO.The Profile Position Mode module allows the configuration of parameters like accelera-tion, velocity,deceleration and target position.The motions can be watched in a graphi-cal way and stopped by "Stop" or "Halt" to test the implementation.6. ConclusionThe development of a CANopen drive consists of the following tasks, implementation, test and integration. Besides an existing drive application or experience in drive dev e lop-ment the CANopen Source Code Stack is mandatory for the development of a CANopen drive.Normally there is nothing else what is needed.However, with the help of advanced software tools implementation, test and integration isstraightforward.Such tools provide functions like creation of object directory and EDS file, drive-specific test and configuration functions and configuration of complete CANopen networks. The last figure illustrates a complete tool-set for implementation, test and integration of a CANopen drive.Figure 4 - CANopen drives design flowReferences[1] CiA DS-301 CANopen Application Layer and Communication Profile[2] CiA DSP-402 Device Profile Drives and Motion Control[3] http://www.port.deport GmbHRegensburger Straße 7bD-06132 Halle/Saale+49 345 777 55 0service@port.de。
CANopen对象字典生成办法

CANopen对象字典生成办法CANopen协议是一种基于控制器局域网(CAN)的应用层协议,该协议具有实时高效、组网灵活和产品兼容性高等优势,CANopen协议在国内越来越受到青睐,其应用领域也越来越多广泛,不仅应用于过程与生产自动化等领域,还涉及到医疗、铁路、军事、太阳能等等领域。
目前CANopen协议由CiA(CAN in Automation)组织负责管理与推广。
对象字典是CANopen通信接口与应用程序之间接口,是CANopen协议的重要组成部分。
在CANopen网络中,每个标准的CANopen设备都有一个对象字典,用来描述CANopen设备的全部功能。
一般在CANopen配置或者开发工程中,对象字典的创建与管理是一个不可缺少的步骤,同时也是保证CANopen正常通讯的重要保障。
如果CANopen系统工程相对比较简单,人工编写对象字典是可行的。
但是如果面对系统较复杂、通讯量庞大的CANopen工程,单纯用人工编写对象字典是很低效的,同时也很容易出现编写错误,可能给CANopen工程带来潜在的危险。
为了提高对象字典的编辑效率,同时最大限度地避免对象字典的编辑错误,本文描述的一个快速可靠的对象字典生成器ODBuilder,为CANopen工程的对象字典生成与修改提供一个很好的解决方案。
一、对象字典结构与EDS文件描述1.1对象字典结构对象字典是一个有序的对象组,每个对象采用一个16 位的索引值来寻址,为了允许访问数据结构中的单个元素,同时定义了一个 8 位的子索引。
对象字典中索引值0000- 0x0FFF 是数据类型的定义,具体类型有固定的分区。
而一个CANopen节点的对象字典相关的常用范围在 0x1000 到 0x9FFF 之间。
其中,索引1000h-1FFFh描述的是通信对象(COB),如设备类型,错误寄存器,支持的 PDO 数量等等,该参数定义了CANopen 接口的通信功能。
索引2000h-5FFFh是预留给制造商定义的特定对象。
canopen 字典 使用方法

canopen 字典使用方法(原创实用版5篇)《canopen 字典使用方法》篇1CanOpen 字典是一种用于描述CanOpen 设备及其属性的数据结构。
以下是一个CanOpen 字典的使用示例:```pythonimport can# 创建一个CanOpen 字典canopen_dict = {"device_id": "0x1234","mode": "OPMODE1","master_clock": 10000,"driver_reset": 1,"enable": 1,"select": "slot 0","secondary_reset": 0,"power_supply": "6V","output_status": 0,"load_status": 0,"command": "TEST_PATTERN","command_value": 0x5A,"master_clear": 0,"position": 0,"limit": [0, 0, 0],"home": [0, 0, 0],"target": [0, 0, 0],"run_state": 0,"tacho_count": 0,"temperature": -45,"velocity": 0,"actual_velocity": 0,"distance": 0,"actual_distance": 0,}# 发送CanOpen 数据帧data = can.Message(canopen_dict)data.arbitration_id = 0x55data.dlc = len(canopen_dict) - 1data.data = canopen_dict.values()send_can(data)```在上面的示例中,我们首先创建了一个名为`canopen_dict` 的CanOpen 字典,其中包含了设备的属性信息。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
CANopen对象字典生成办法发布时间:2013-09-25 来源:中国自动化网类型:解决方案1081人浏览关键字:CANopen对象字典生成器导读:本文在阐述CANopen对象字典的概念与结构的基础之上,结合生成对象字典常用方法的不足,引出一种可快速可靠创建与修改对象字典的对象字典生成器ODBuilder,不仅有效减少编辑对象字典的时间,而且最大限度地避免工程师手工编辑对象字典的错误出现,为CANopen设备参数设置提供有力可靠的解决方案。
摘要:本文在阐述CANopen对象字典的概念与结构的基础之上,结合生成对象字典常用方法的不足,引出一种可快速可靠创建与修改对象字典的对象字典生成器ODBuilder,不仅有效减少编辑对象字典的时间,而且最大限度地避免工程师手工编辑对象字典的错误出现,为CANopen设备参数设置提供有力可靠的解决方案。
关键词:CANopen,对象字典,生成器,ODBuilder,EDS文件Abstract:In this paper, on the introduction of the concept and structure of the CANo pen object dictionary,c ombined with the shortage of common methods of generat ing object dictionary, l ead to a object dictionary generator-ODBuilde r,which is quick ly and reliabl y create and modify the CANopen object diction ary. T his tool not only effectively reduce the time of editing object dict ionary, but significantly minimize the occurrence of error of manual ly edit ing the object dictionary, and provid e a robust and reliable solutions for th e parameter Settings of CANopen equipment.Key words:CANopen,Object dictionary,generator,ODBuilder,EDS File引言CANopen协议是一种基于控制器局域网(CAN)的应用层协议,该协议具有实时高效、组网灵活和产品兼容性高等优势,CANopen协议在国内越来越受到青睐,其应用领域也越来越多广泛,不仅应用于过程与生产自动化等领域,还涉及到医疗、铁路、军事、太阳能等等领域。
目前CANopen协议由CiA(CAN in Automation)组织负责管理与推广。
对象字典是CANopen通信接口与应用程序之间接口,是CANopen协议的重要组成部分。
在CANopen网络中,每个标准的CANopen设备都有一个对象字典,用来描述CANopen设备的全部功能。
一般在CANopen配置或者开发工程中,对象字典的创建与管理是一个不可缺少的步骤,同时也是保证CANopen正常通讯的重要保障。
如果CANopen系统工程相对比较简单,人工编写对象字典是可行的。
但是如果面对系统较复杂、通讯量庞大的CANopen工程,单纯用人工编写对象字典是很低效的,同时也很容易出现编写错误,可能给CANopen工程带来潜在的危险。
为了提高对象字典的编辑效率,同时最大限度地避免对象字典的编辑错误,本文描述的一个快速可靠的对象字典生成器ODBuilder,为CANopen工程的对象字典生成与修改提供一个很好的解决方案。
一、对象字典结构与EDS文件描述1.1对象字典结构对象字典是一个有序的对象组,每个对象采用一个16 位的索引值来寻址,为了允许访问数据结构中的单个元素,同时定义了一个8 位的子索引。
对象字典中索引值0000- 0x0FFF 是数据类型的定义,具体类型有固定的分区。
而一个CANopen节点的对象字典相关的常用范围在0x1000 到0x9FFF 之间。
其中,索引1000h-1FFFh描述的是通信对象(COB),如设备类型,错误寄存器,支持的PDO 数量等等,该参数定义了CANopen 接口的通信功能。
索引2000h-5FFFh是预留给制造商定义的特定对象。
索引000h-9FFFh是用于标准化设备子协议的对象描述,例如I/O模块子协议、驱动与运动控制设备子协议、传感器与测量设备子协议、医疗器材子协议、电梯子协议等等。
CANopen 对象字典通用结构如表1所示。
表1 CANopen 对象字典通用结构1.2 EDS文件描述CANopen 网络中每个节点都有一个对象字典,对象字典包含了描述这个设备和它的网络行为的所有参数。
而在描述CANopen设备时,使用了一种标准化的ASCII格式的描述文件,即:电子数据表(EDS)。
电子数据表不仅记录了对象字典的所有参数,同时也对设备及其配置进行标准化的描述,所以EDS电子数据表是对象字典的载体与保存方式。
二、对象字典的实现通常来说,在CANopen工程中将所有的CANopen通信描述条目放在一个表格中,然后用索引来访问所有的对象。
这不失是一个解决方法,不过这种方法只适用于系统简单、通信参数少、非CANopen通信标准化的产品中,而且对象字典的修改与管理工作都较为繁琐。
由此本文介绍一种动态输入掩码显示各个参考的对象类型,编辑过程不断检查其正确性并修正的对象字典生成器ODBuilder。
ODBuilder工具生成的对象字典,通信描述完全符合CANopen 标准规范CiA DS301以及设备描述符合EDS标准文件CiA DSP306规范,具有CANopen标准化设备的通用性。
三、对象字典生成器ODBuilder3.1对象字典生成原理对象字典生成器ODBuilder生成对象字典的原理是根据CANopen通信协议的访问对象字典的机制,通过固定的索引、子索引来创建每一个CANopen对象字典条目。
访问对象字典示意图如图3.1所示。
图3.1 CANopen访问对象字典对象字典条目表格提供一个指向存储器中某个变量的指针,而应用程序可直接通过变量名称访问所需的条目。
因此对象字典条目列表就构成了索引/子索引与对应变量名称之间的接口。
对象字典列表分为几个不同的块,目的为了方便对象的查找。
通常分为用户可通过索引查找相应的列表(如通信Communication Profile Area),再通过偏移量访问该列表中所需的单元。
因此在生成对象字典时为了描述索引里的单元,就先创建该单元的访问类型、数据类型和指针变量等的结构体。
然后利用创建好的结构体与应用变量建立相关联的索引条目。
此外,还会编辑一个包含指向子索引字段的指针列表,方便查找相关条目。
3.2对象字典生成过程对象字典生成器ODBuilder创建一个简明树形结构的对象字典工程,方便修改与访问对象字典条目;在编辑对象字典条目过程中,无需手工输入不同条目的数据类型,直接通过下拉选项选择对应类型;在编辑过程中,ODBuilder不断检查对象字典的输入条目的正确性并提供修正参考,最后完成后可生成标准EDS文件。
ODBuilder对象字典生成过程原理框图如图3.2所示。
图3.2 对象字典生成过程原理框图3.3 创建简明树型条目根据对象字典条目的分布特性,ODBuilder将创建的对象字典以简明的树型结构,索引值由小到大排列。
用户需要访问或者修改某一条索引,可直接点击该条目就可以进行访问或修改。
如图3.3所示。
图3.3 树型结构索引结构3.4 编辑对象字典索引属性1.根据CANopen协议CiA DSP306规范,输入不同的索引值,可灵活设定其“可选”、“强制”属性。
以编辑0x1000h索引为例,如图3.3.1所示,通常用于Device Type,“制造商”、如果作为从站的产品,该索引通常为“强制”属性,ODBuilder将其自动设置为“强制”属性。
图3.4.1编辑对象字典索引属性2.根据不同的CANopen设备的存储需要,可选择索引是否存储在非易失存储器以及ROM 或者RAM中。
3.索引的对象参数、数据类型、访问类型等直接通过下拉条选择,如图3.3.2所示,另外可选该索引条目是否有PDO映射功能。
图3.4.2 下拉条选项输入4.根据对象参数属性,如果选择为变量,默认值、最小值和最大值为可输入状态。
5.子索引自动继承索引属性,无需要重新设定其存储属性、PDO映射参数。
3.5检查输入正确性在CANopen系统工程较复杂的情况下,ODBuilder随时提示对象字典的输入,确保对象字典条目的每一个属性参数不遗漏,检查对象字典条目的输入正确性。
例如,如果编辑对象字典时遗漏索引标示符(Designator)的输入,则会提示用户输入对应值。
同样,遗漏索引值、对象类型、数据类型、访问类型任何一项都有相应的输入提示。
如图3.5所示。
图3.4 检查输入提示3.6导出EDS文件当完成对象字典所有条目的编辑,ODBuilder的检查功能已经很大程度的减少对象字典的输入错误,同时导出符合CiA DSP306规范的EDS文件,该文件不仅包含了CANopen设备的对象字典所有的内容,同时也要求添加文件描述信息,设备信息等信息。
如图3.6所示。
图3.6生成EDS结语本文在CANopen对象字典的概念基础上,进一步阐述了一种可快速可靠灵活创建对象字典的工具ODBuilder,并生成标准化EDS文件,不仅为CANopen设备的生产也为CANopen工程设备的参数配置,提供快速创建与修改对象字典的解决方案,目前该软件已经应用于多家大型医疗器材、运动控制、轨道运输等行业设备的对象字典生成。
参考文献[1] Olaf pfeiffer, Andrew Ayre, Christan Keydel,embedded networking with CAN andCANopen [M], 2008,42-56[2](德)Holger Zeltwanger 著,周立功,黄晓清,严寒亮译,现场总线CANopen 设计与应用[M],2011,62-75[3]CiA Draft Standard 306,Version 1.3,01 January 2005[4] CANopen Object Dictionary Software ODBuilder Manual, Edition August 2008作者简介龚龙峰,(1988- ),男,助理工程师,研究方向:自动化及通信技术。