• 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

转载于:https://www.cnblogs.com/21207-iHome/p/6050457.html

CANopen笔记2相关推荐

  1. CANopen笔记1

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

  2. CAN笔记(16) CANOpen简介

    CAN笔记(16) CANOpen简介 1. CAN 在 ISO 层级中的位置 2. 通信协议需求 3. CANopen 协议诞生 4. 设备子协议 5. CANOpen设备结构 1. CAN 在 I ...

  3. CanOpen协议栈学习笔记1-帧格式,SYNC和NMT报文介绍

    前面已经记录过can协议,后面开始CanOpen协议栈学习.其实协议栈代码已经看过了,而且已经在开发板上跑过了.这里回过头来,重新看下之前遇到的坑,记录下学习笔记.下面均以标准帧为例 文章目录 1.C ...

  4. 周立功阅读笔记-CANopen轻松入门基于DS301(一)

    周立功阅读笔记-CANopen轻松入门基于DS301(一) CANopen阅读笔记 4.CANopen的预定义报文和ID分类 5.对象字典OD(Object dictionary) 6.网络管理NMT ...

  5. linux系统学习笔记9——CANOpen状态转换

    CANopen CANopen状态转换 CANopen状态转换 从节点上电和内部初始化之后自动进入预损作状太(Pre-operational State),在进入预操作之前,发送标准的启动对象(Boo ...

  6. 《CANOpen》 学习笔记5

    <CANOpen> 学习笔记5 CANOpen 学习笔记5 驱动器 CANopen 调试笔记 驱动器 CANopen 调试笔记 驱动器 Copley 公司提供的 <CANopenPr ...

  7. CANopen学习笔记

    CANopen学习笔记 文章目录 CANopen学习笔记 1.NMT 1.1.NMT的Boot_up (节点上线报文) 1.2.NMT 节点状态与心跳报文 1.3.NMT节点守护 1.4 .NMT节点 ...

  8. linux canopen软件,CANopen学习笔记

    1. TPDO和RPDO都是针对从站来说的,协议上没有有讲任何一个关于主站的概念,协议就只是定义从站,没有定义主站任何东西. TPDO:从站->主站 RPDO:主站->从站 2. PDO的 ...

  9. CANopen协议 学习笔记

    大纲 前沿:以问题为导向学习是最高效的,本文主要讲述在学习Canopen协议中的一些疑惑点, 分享一些学习心得,不讲协议本身的内容. 1.主机和从机的概念? 2.PDO和SDO的区别是什么? 3.OD ...

最新文章

  1. 270个开源项目,总计24w星,帮你快速找代码
  2. 成功解决ValueError: `bins` must be positive, when an integer
  3. CTO说了,delete后不加limit,直接滚蛋!
  4. org.springframework.beans.factory.BeanDefinitionStoreExcept
  5. php.ini 老薛,出现Allowed memory size of 134217728 bytes exhausted怎么办?
  6. win7如何关闭密码保护共享
  7. 快速锁屏电脑快捷键_电脑小技巧
  8. 抢鲜体验:openGauss 安装编译过程要点及问题解决
  9. 贵大计算机在职,贵州大学在职研究生招生信息网
  10. win8游戏开发教程开篇
  11. 现实世界的Windows Azure:采访Definition 6首席技术官Paul Hernacki
  12. Atitit 提升开发效率使用内嵌Tomcat 内嵌webserver 于单元测试
  13. 机房走线槽安装现场需要检查的内容
  14. 杜立特尔分解法 MATLAB,chase追赶法算法
  15. Win10设置内存压缩
  16. 算式最大值 (思维题)
  17. win10不能上传文件到服务器,Win10系统下蓝牙无法传输文件怎么解决
  18. 利用excel批量操作MySql数据库
  19. 显卡知识扫盲 为你讲述流水线的发展与未来
  20. Java语言的动态性-invokedynamic

热门文章

  1. linux Apache启动提示 httpd: apr_sockaddr_info_get() failed f
  2. CSS工具之CSS重置(CSS Reset)
  3. fail to build phoneME Feature-转
  4. SpringBoot之Listener注册到Spring容器中的多种方法
  5. Python 按行读取文本文件 缓存 和 非缓存实现
  6. Python出现quot; SyntaxError: Non-ASCII character '\xe6' 或'\xd6' in filequot;错误解决方法
  7. Quartz使用-入门使用(java定时任务实现)
  8. 研发解决方案介绍#Tracing(鹰眼)
  9. Mysql 两种情况下更新字段中部分数据的方法
  10. Go 语言接口详解(一)