• PDO

  过程数据对象用于在节点之间传送过程数据,如I/O模块I/O状态读取和设定,模拟量采集和模拟量输出等等,协议考虑从机硬件限制最多支持4组PDO,每组包含一个RPDO和一个TPDO。The Gold drive supports 4 TPDO and 4 RPDO. Each PDO contains up to 8 bytes of data.

  现在以I/O模块为例进行说明:设I/O模块有24路输入,24路输出。24输入通过TPDO传给监控终端或其他节点,24输出通过RPDO由控制节点对其进行设定,采用发送和接收PDO1组,即标识符TPDO:0x180+NODE_ID,RPDO:0x200+NODE_ID,用3个字节就可以表示24个I/O量,因此发送和接收PDO可以表示如下(假设NODE_ID=1):

  I/O节点→监控终端(TPDO)

  I/O节点←监控终端(RPDO)

PDO Mapping

  PDO只是个载体,它好比一辆货车,车厢里装什么货,是可以配置的,这些由PDO映射来完成。PDO映射用来指定把对象字典的那些对象装进PDO,或者从接收的PDO中将数据放到那些对象中。PDO mapping is a convention that maps an object from the object dictionary (data payload) to a PDO. Once mapped, the PDO can carry the assigned data items without explicit reference to the object dictionary, thereby saving on communication and CPU overhead. Some of the objects in the object dictionary can be mapped to a PDO, which can either receive or transmit. The mapping of an RPDO enables reception of commands and variables — for example, efficient transmission of high-speed online motion commands to the drive — whereas the mapping of a TPDO enables the drive to send a predefined message in response to an event such as end of motion.

  An RPDO is buffered upon reception; it is sent for interpretation immediately (when defined as asynchronous) or upon receipt of the next SYNC signal (when defined as synchronous). 即当RPDO设为异步时(transmission type=254/255),节点接收到后会立刻处理,不用等待同步信号。

  Objects 0x1A00 – 0x1A03 contain the objects mapped to TPDOs. Objects 0x1600 – 0x1603 contain the objects mapped to RPDOs. The data type of PDO mapping is described in object 0x21. 由下表可知,对子索引0对应要映射对象的数目,子索引1~8分别对应要映射的对象。

Transmission Type  

PDO通讯具有三种触发模式:内部事件驱动或内部定时器触发、同步触发、远程请求触发。

  1) 同步触发。同步触发PDO是指CANopen节点收到由管理节点发出的同步报文(同步对象SYNC)之后,根据触发报文条件向总线发出PDO报文。同步传输又分为周期性和非周期性,周期性是指CANopen节点接收到一定数量的同步报文之后才开始发送;非周期性PDO是指PDO触发条件成立之后,当收到下一个同步对象后马上发送PDO。同步传输在实际应用中的优势很多,它能提供一致的系统节拍,使得总线的数据尽量保证同步。同步传输的最重要应用是多轴同步控制,沒有这种同步机制,多轴传动功能是沒有办法实现的。
  SYNC就相当于一个网络节拍,数据根据节拍来进行固定周期的过程数据传输。比如网络中有一个压力传感器,一个温度传感器,一个物位传感器,网络中有一个监控终端来实时监控三个传感器采集的数据。压力传感器可能检测的是一个快速的压力变化,那可以每隔200ms更新一次数据,温度可能需要1s更新一次数据,物位可能5s更新一次数据。现在我可以设置一个200ms周期的SYNC消息,压力传感器每收到一个SYNC就传输一次数据,温度传感器可以每隔5个SYNC传输一次数据,同样物位传感器就是每收到25个SYNC发送一次数据。这种通讯方式显得比较规矩,好管理,系统运行效率高,适合周期性数据更新的应用。

2) 内部事件驱动或内部定时器触发。通讯由某一事件触发。例如数字I/O口状态改变,超过预先设定的值、定时器中断等都会触发节点发送一个PDO。这种模式可使总线负载达到最小,在相对低的波特率下获得比较高的通讯特性。内部定时发送有别于SYNC同步触发,它是在本节点上实现周期发送,通过设置PDO参数,确定一个周期,每隔固定的时间向网络上发送一次PDO,它与SYNC无关。在网络设计中主要按照传感器的数据采集速度和数据更新要求来设定定时周期.

3) 远程请求触发。PDO消费者可以给PDO生产者发送远程PDO请求,相应PDO生产者将对远程帧做出响应,向总线上发送相应的PDO数据。

PDO传输类型定义表:

  If the RPDO transmission type is 1, the received message is buffered but actually transmitted for execution at the next SYNC message. With TPDOs, the message is transmitted according to transmission type value, which can range from 1 to 240, where 1 indicates on each single SYNC, 2 means every second SYNC message,and so on.

Communication Parameter

  每个PDO在对象字典中由两个对象描述:通信参数和映射参数。PDO通信参数指明使用哪个COB-ID、传输类型、禁用时间和定时时间;PDO 映射参数用于设定PDO报文中的数据的映射关系,确定要传输的数据在 CAN 报文数据域中的定位。

  一个PDO可以指定一个禁止时间,即定义两个连续PDO传输的最小间隔时间,避免由于高优先级信息的数据量太大,始终占据总线,而使其它优先级较低的数据无力竞争总线的问题。禁止时间由16 位无符号整数定义,单位为100us。If sub index 3 is set to 0, then the minimum time interval to transmit TPDO is disabled.

  一个 PDO可以指定一个事件定时周期,当超过定时时间后,一个PDO传输可以被触发。事件定时周期由16位无符号整数定义,单位为1ms。When a TPDO transmission type is 254 or 255, an event timer defined by sub index 5 can be used. The timer defines the maximum interval for TPDO transmission. The event occurs when the time is elapsed. The event timer resolution is 1ms. The event causes the transmission of this TPDO in addition to other asynchronous events. The occurrence of an event sets the timer again. A value of 0 disables this function.

 在开始PDO传输前要先配置好PDO通信参数,在0x20处描述了其格式。Transmit PDO communication parameter:Objects 0x1800 - 0x1803;Receive PDO communication parameter:Objects 0x1400 - 0x1403

=====================================================================================

  PDO 映射事例:将下表中3个对象映射到PDO1-Transmit, 为异步周期性类型,周期时间 10ms,禁止时间 2ms

  1)① Clear mapping TPDO1(To change the PDO mapping, sub-index 0 must be set to 0 (mapping is deactivated). Only then can the objects be remapped)

  number_of_mapped_objects(1A00 h: 00 h) = 0
       ② Disable TPDO1
       为了设置通信参数,必须要先将通信参数对象子地址1h的第31位置1,即要先使TPDO1失效才能配置其通信参数,否则会产生错误。It is not allowed to change bit 0 to 30 while the PDO exists and is valid (bit 31 = 0b). In this case, when attempting to change the values from bit 0 to bit 30, the devise responds with the SDO abort transfer service. 发送如下指令使TPDO1失效:

  2)设置映射对象参数(Modify mapping by changing the values of the corresponding sub-indices.)
  Index = 6041h  Subindex = 00h  Length = 10h ⇒ 1st_mapped_object(1A00 h: 01 h) = 60410010 h
  Index = 6061h  Subindex = 00h  Length = 08h ⇒ 2st_mapped_object(1A00 h: 02 h) = 60610008 h
  Index = 6064h  Subindex = 00h  Length = 20h ⇒ 3st_mapped_object(1A00 h: 03 h) = 60640020 h

  注意:The sub-indexes from 1 to number of entries contain the information about the mapped application variables. These entries describe the PDO contents by their index, sub-index and length. 即设置映射对象参数时要按照如下所示的格式(映射对象地址+对象子地址+映射数据的长度,按小端模式发送)

  假设设备节点ID为1,则发送一帧完整的SDO报文配置PDO,需要发送的格式如下:

  3)设置 number_of_mapped_objects(Enable mapping by setting sub-index 0 to the number of mapped objects.)
  number_of_mapped_objects(1A00 h: 00 h) = 3

  注意:When sub-index 0 is set to a value greater than 0, the device may validate the new PDO mapping before transmitting the response of the SDO service. If an error is detected, the Elmo drive transmits the Abort SDO Transfer Service with abort codes.

  4)设置 PDO 通讯参数
  PDO1-Transmit为异步周期性类型 ⇒ transmission_type (1800 h: 02 h)= FF h (TPDO1传输类型默认值为0xFF,即默认异步传输)
  禁止时间 2ms(20×100us) ⇒ inhibit_time (1800 h: 03 h) = 14 h
  周期时间 10ms(10×1ms) ⇒ event_time (1800 h: 05 h) = 0A h
  设置COB-ID(PDO1-Transmit) ⇒ COB-ID (1800 h: 01 h) = 0181 h

  通信参数对象子地址1h处包含了COB-ID,但其数据类型为32位(参照0x20描述),其它几位定义如下:

  The bit valid (bit 31) enables TPDOs. There may be TPDOs configured but not used, and therefore set to not valid.

  则发送如下指令来Enable TPDO1:

  5)PDO 映射完成(Finally, the PDO is created by writing to its communication parameter COB-ID.)

=====================================================================================

  PDO 映射事例:将Controlword对象0x6040和Interpolated data record对象0x60C1:1h映射到RPDO1,传输类型为同步类型

  1) Disable RPDO1(COB-ID 0x201),client sends:

    0x601  0x22 0x00 0x14 0x01 0x01 0x02 0x00 0x80

    Clear mapping RPDO1,client sends:

    0x601  0x22 0x00 0x16 0x00 0x00 0x00 0x00 0x00

  2) Set CW, object 0x6040, 16 bit length in sub index 1 of RPDO1

    0x601  0x22 0x00 0x16 0x01 0x10 0x00 0x40 0x60

    Set Interpolated data record, object 0x60C1, Sub index 1, 32 bit length in sub index 2 of RPDO1

    0x601  0x22 0x00 0x16 0x02 0x20 0x01 0xC1 0x60

  3) Set transmission type synchronous, every SYNC (RPDO默认传输类型值为255,即默认异步传输)

    0x601  0x22 0x00 0x14 0x02 0x01 0x00 0x00 0x00

  4)Set 2 objects are mapped

    0x601  0x22 0x00 0x16 0x00 0x02 0x00 0x00 0x00

    Enalbe RPDO1

    0x601  0x22 0x00 0x14 0x01 0x01 0x02 0x00 0x00

  • SYNC

  SYNC主节点定时发送 SYNC 对象,SYNC从节点收到后同步执行任务。SYNC报文的COB-ID固定为080h,SYNC报文可以不传送数据以使报文尽可能短(注意:数据帧的数据段可以发送0~8个字节的数据,控制段表示数据段的字节数。而SDO报文数据段长度始终为8字节,不够的要补0)

 

参考:

http://blog.csdn.net/iamplane/article/details/49931319

CANopen笔记2的更多相关文章

  1. CANopen笔记1

    CAN现场总线只定义了OSI网络模型的第一层(物理层) 和第二层(数据链路层) ,而这两层一般已被CAN硬件完全实现了.由于没有规定应用层,本身并不完整,需要一个高层协议来定义CAN报文中的11/29 ...

  2. CANopen——笔记

    1. c语言的typedef高级用法 typedef void (*post_sync_t)(CO_Data*); http://zhidao.baidu.com/link?url=_lDBGq_uk ...

  3. 【转】(笔记)CANopen协议【CANFestival】移植方法

    一.背景 CAN组网就必须得要应用层协议,原因就在于 * 便于网络管理与控制 * 确认数据的收发 * 发送大于8个字节的数据块(CAN每帧数据传输大小为8字节) * 为不同节点分配不同的报文标识符 * ...

  4. (笔记)CanOpen协议【CanFestival】移植方法 支持VC、QT、STM32

    转自http://bbs.21ic.com/icview-878522-1-1.html   前段时间学习了CanOpen协议,到网上下载的CanFestival3-10源码,移植到VC.QT.STM ...

  5. (笔记)CANOpen移植(CanFestival移植)

    在网上下载CanFestival源码最新版本CanFestival-3-884a60cbb83e建立以下文件夹:inc文件夹:放LM3S8962硬件相关以及驱动部分的头文件,adc.h.hw_adc. ...

  6. 基于CANopen DSP402的运动控制笔记

    常用的mode of operation 有以下几种: 控制字 control word: 6--------------7---------------15--------------------7 ...

  7. Apollo学习笔记(一):canbus模块与车辆底盘之间的CAN数据传输过程

    Apollo学习笔记(一):canbus模块与车辆底盘之间的CAN数据传输过程 博主现在从车载自组网信道分配和多跳路由转向了自动驾驶,没啥经验,想快些做出来个Demo还是得站在巨人的肩膀上才行,我选择 ...

  8. git-简单流程(学习笔记)

    这是阅读廖雪峰的官方网站的笔记,用于自己以后回看 1.进入项目文件夹 初始化一个Git仓库,使用git init命令. 添加文件到Git仓库,分两步: 第一步,使用命令git add <file ...

  9. js学习笔记:webpack基础入门(一)

    之前听说过webpack,今天想正式的接触一下,先跟着webpack的官方用户指南走: 在这里有: 如何安装webpack 如何使用webpack 如何使用loader 如何使用webpack的开发者 ...

随机推荐

  1. zw版【转发·台湾nvp系列Delphi例程】HALCON SetLineStyle2

    zw版[转发·台湾nvp系列Delphi例程]HALCON SetLineStyle2 procedure TForm1.Button1Click(Sender: TObject);var img : ...

  2. 【crunch bang】调整窗口大小

    在终端下,   <super> + 上箭头  == 向上调整大小 <super> + 下箭头(左.右)

  3. OpenStack 界面开发中的排序问题

    Contents [hide] 1 需求 2 调研 3 排序的办法 4 解决代码 需求 获取主机列表的时候,希望能够对主机列表能分组显示,比如网络,一组网络段希望在一起显示 调研 openstack的 ...

  4. 项目中的一个JQuery ajax实现案例

    /**  * brief 这些代码用于在线制图中 attention author <list of authors> <date> begin modify by  * nu ...

  5. mysql单表查询&&多表查询(职员表14+9)

    dept(deptno,dname,loc) emp(empno,ename,job,mgr,hiredate,sal,COMM,deptno) salgrade(grade,losal,hisal) ...

  6. 前端开发自动化工作流工具,JavaScript自动化构建工具grunt、gulp、webpack介绍

    前端开发自动化工作流工具,JavaScript自动化构建工具grunt.gulp.webpack介绍 前端自动化,这样的一个名词听起来非常的有吸引力,向往力.当今时代,前端工程师需要维护的代码变得及为 ...

  7. Dynamics AX 2012 R2 Service Middle Tier WCF WCF转发

    参考了蒋金楠老师08年的文章.好吧,那时候我才大二.大三,大神果然是大神. http://www.cnblogs.com/artech/archive/2008/09/01/1280939.html ...

  8. Server.MapPath()获取本机绝对路径

    1.    Server.MapPath("/")  应用程序根目录所在的位置 如 C:\Inetpub\wwwroot\ 2.Server.MapPath("./&qu ...

  9. Web前端工作2个月小结

    开始语: 2013年6月30日,Microsoft Learning support 项目结束,转而进入Forerunner Development 项目,这对于这块领域空白的我,空前的困难,可是我坚 ...

  10. 搭建HTTP Live Streaming直播系统

    最近,需要将苹果的HTTP Live Streaming系统搭建起来.完全没有头绪,故第一步就是学习. 一.学习资料 官网资料 1. http://developer.apple.com/resour ...