PLC论坛-全力打造可编程控制器专业技术论坛

 找回密码
 注册哦

QQ登录

只需一步,快速开始

微信扫码登录

查看: 14301|回复: 0

EtherCAT诊断进阶

[复制链接]
发表于 2024-1-26 14:47:47 | 显示全部楼层 |阅读模式
众所周知,在TwinCAT开发环境的EtherCAT | Online界面可以实现大部分EtherCAT问题的诊断,比如查看主站和每个从上的OP状态,CRC校验错误计数等。下面介绍TwinCAT中的几个“隐藏”得比较深的工具。

1     EtherCAT仿真工具2     从站的Register3     DC从站的Frame时序分析4     Frame的抖动5     完整的AL状态码解释
以上内容都包含在3个文档中,强烈推荐至倍福虚拟学院“https://tr.beckhoff.com.cn”下载,值得详细研读:
TE1111_TC3_EtherCAT_Simulation_en.pdf2_EtherCAT Diagnostics - cn V2.pptx3_EtherCAT Synchronization-cn V2.pptx

1      EtherCAT仿真工具

本来这是为了配合TwinCAT Matlab/Simulink硬件在环调试的一个工具,也可以用于专门的自动化仿真软件与TwinCAT的IO接口。我发现它的另一个用途:练习EtherCAT故障诊断——因为工程师并不是随时都在车间,当谈到一个EtherCAT故障的现象如何、应该如何处理的时候,手边没有硬件是没有办法实操练习的。倍福工程师有相对较好的实验条件,可以在Demo架上测试,但是如果系统复杂、IO站很多时,仍然很难重现故障。

最简单的EtherCAT仿真环境是这样的:



例如在编程笔记本上测试时,扩展一个USB转以太网的转换器,电脑就有了两个独立的有线网卡,用网线把它们短接,就搭成了上述测试的硬件平台:



EtherCAT Simulation的配置也很简单:
(1)    导出EtherCAT 配置文件



从项目文件或者手动配置好EtherCAT网络后,设置使用的Adapter,然后导出EtherCAT配置文件:



(2)    手动添加EtherCAT Simulation



然后设置使用的Adapter。 (3)    配置文件导入至Simulation



(4)    激活配置看结果

如果Adapter选择正确,EtherCAT驱动安装正确,双网卡互连,在EtherCAT Master的Topology窗体中可显示所有从站及状态。为了测试大型EtherCAT网络的仿真效果,本例中的配置了100个EK1100及若干XFC模块、紧凑驱动模块等:



(5)    模拟各种EtherCAT故障
EtherCAT Simulation可以模拟丢包、断线、WC等故障,既可以模拟短时故障,也可以模拟永久性故障:



(6)    特别说明
该功能需要TE1111授权,试用版授权只能运行30min。倍福工程师使用EtherCAT Simulation练习EtherCAT诊断时,可以借用含完整授权的USB Dongle,倍福用户则需要购买。

仿真效果与CPU性能有关,抖动越小,周期越短,则仿真效果越好

对于带DC时钟的从站的仿真,比如伺服驱动、XFC模块等,只能仿真其EtherCAT接口,并不能仿真模块本身的内部功能。受硬件影响,仿真出来的DC特性也不及真正的物理从站设备。

EtherCAT Simulation的典型的应与仿真软件配合,仿真现场设备以辅助EtherCAT主站应用的虚拟调试。故障模拟可以从TwinCAT XAE触发,也可以从仿真软件触发。本例中的从XAE触发,仅仅是为了演示方便。

完整功能请参考:
TE1111_TC3_EtherCAT_Simulation_en.pdf
2       EtherCAT 从站的Register

绝大多数时候,通过TwinCAT XAE中的EtherCAT Online界面、Slave Diagnose界面、TwinCAT 报警窗体就可以直观地诊断从站信息。那么这些信息是从哪里来的呢?它们一定是来自从站的Register,由主站进行采集并在TwinCAT XAE中以可视化的方式呈现。普通用户只要使用这些可视化界面就足够了,但是如果你想深入了解背后的机制,TwinCAT还提供了直接访问这些Register的通道。在从站的Advanced Setting页面选择最后一项“ESCAccess/Memory”:



输入Start Offset和Length,可以定义显示的起始地址和长度。那么哪些常用信息位于什么地址呢?
(1)   连接丢失计数器


Register 内存地址
长度含  义
0x03101 字节port 0 的连接丢失次数
0x03111 字节port 1 的连接丢失次数
0x03121 字节port 2 的连接丢失次数
0x03131 字节port 3的连接丢失次数
(2)   无效帧计数器

Register 内存地址长度含  义
0x03001 字节port 0 的CRC校验错误计数器
0x03011 字节port 0的RX (接收)错误计数器
0x03021 字节port 1 的CRC校验错误计数器
0x03031 字节port 1的RX (接收)错误计数器
0x03041 字节port 2 的CRC校验错误计数器
0x03051 字节port 2的RX (接收)错误计数器
0x03061 字节port 3 的CRC校验错误计数器
0x03071 字节port 4的RX (接收)错误计数器

(3)   EtherCATOnline界面显示CRC


TwinCAT 中, EtherCAT主站的Online 页面总是以 word-oriented的方式显示计数值。但是默认的Online界面并不显示以上计数,需要在主站的Advanced Setting页面的Online View中进行设置:



勾选中0300等Register之后,就中以在Online中显示了:



(4)   Frame到达从站端口的时间



(5)   历史诊断信息Register 0x10F3

有的模块支持Diag History功能,在其界面上就有相应的Tab页:



如果这里有显示,从注册字0x10F3中也可以看到相应的内容 (6)   AL状态码Register 0x0134

配置错误:
0x0003 : Invalid  Device Setup (BK1xxx上配置的KL模块顺序不正确)0x001D : Invalid  Output Configuration (配置的输出过程数据无效)0x001E : Invalid  Input Configuration (配置的输入过程数据无效)0x0035 : Invalid  Sync Cycle Time (在DC 模式中设置的Cycle Time不支持)
运行时错误:
0x001A :  Synchronization error (网络的抖动导致从站的同步丢失)0x001B : Sync  manager watchdog (从站未接收到周期性数据的时间,持续超过了watchdog时间)0x002C : Fatal  SYNC error (ESC 再未收到 SYNC 硬件中断) 完整的故障代码列表,见文末第5节。
3       Frame时序分析

对于普通IO模块或者EtherCAT从站来说,EtherCAT Frame早到或者晚到甚至偶尔不到都影响不大,但是对于带DC时钟并启用了DC功能的EL模块或者EtherCAT从站来说,Frame晚到或者丢失就会引起报警。

那么Frame到底是什么时间到达特定的EtherCAT从站的呢?TwinCAT XAE中提供了可视化界面。以一个包含两个DC从站EL7201和EL7211的EtherCAT网络为例,控制器在Runing模式下,从EtherCAT Master的Advanced Setting界面打开Slave Diagnose窗体:



图中,先点击Start开始记录,表格中的Eof to SYNC、SYNC to PDI列就会连续刷新。再Display FrameTiming显示时序,就会出现彩色显示的各个DC从站的特定时间标记。点击Settings,可以选择显示内容:显示哪些DC从站的DC同步信号或PDI时序。
这里有几个术语要解释:
•SoF (Start of Frame) : Frame 的第1个Bit 到达 ESC•EoF (End of Frame) : Frame 的最后1个Bit 离开 ESC•SYNC : DC单元根据本地时钟触发的同步信号•PDI : 本地主控制器访问 ESC的双口内存(DPRAM)
这几个术语所代表的时间点,在从站侧的相互关系为:



尝试修改主站和从站的Shift Time,然后在这个可视化界面显示时序图,可以更加深刻地理解EtherCAT分布时钟。当从站报Sync Lost时,就可以到这个界面进一步观察故障信息。详细的说明请参考:3_EtherCAT Synchronization -cn V2.pptx (Page48-60)

4      EtherCATframe的抖动

最理想的情况是每个任务周期EtherCAT Frame在相同的时间出发,但实际上受TwinCAT实时核抖动以及任务运算量波动的影响,Frame的实际出发时间总是和理论值有所偏差,包括正差(pos)和负差(neg)。TwinCAT XAE中在EtherCAT主站的Advanced Setting里提供DistributedClocks的Diagnosis功能,可以监视实际的波动情况:



上图显示最大偏差界于20-50us之间,按50us计算。如果这个偏差超过了任务周期的20-30%,就很容易发生同步错误。所以任务周期越短——比如低于1ms——发生同步错误的概率越大。如果最大偏差超过500us,那就不是同步任务的问题,而要检测EtherCAT网卡、驱动、TwinCAT实时核的问题了。比如在第三方PC上测试运行TwinCAT通常会发生抖动偏大的问题,对于有分布时钟要求的微秒级任务就可能会有影响。

5      完整的AL状态码解释

0x0000
No eror   No error

0x0001

Unspecified error   General Error which is not defined in the  following list

0x0002

No Memory    Local Application runs out of memory

(e.g. dynamic memory allocation  for emergency messages

0x0011

Invalid requested state change  Requested state change is invalid(e.g. IS, IO, PO, PB, SB, OB)


0x0012

Unknown requested state       Requested state change is unknown(e.g. if the requested state  code is not 1, 2, 3 4, 8)

0x0014

No valid firmware  The downloaded file is no valid firmware  file

0x0013

Bootstrap not supported  The device doesn't support Bootstrap state

0x0015


Invalid mailbox configurationThe maibox SyncManger configuration is not  valid in Bootstrap state

0x0016

Invalid mailbox configurationThe mailbox SyncManger configuration is not  valid in PREOP state

0x0017

Invalid sync manager  configuration Sync manager configuration is not valid

0x0018

No valid inputs available       Slave application cannot provide valid  inputs

0x0019

Slave applicaton cannot receive  valid outputs

0x001A

Synchronization eror      Multiple synchronization errors. Device  is not synchronized any more(shall be used d no specific Synchronization  error can be distinguished)

0x001B

Sync manager watchdogNo process data recerved yet (s->O)or not  received within a specifed timeout value

0x001C

Invalid Sync Manager Types

0x001D


Invalid output Configuration  SyncManger configuration for output process data is invalid

0x001E

Invalid Input configurator      SyndManger configuration for mput process data is invalid

0x001F

Invalid watchdog configuration     watchdog Settings are invalid (e.g.  SyndManger watchdog trigger is enabled but no watchdog timeout is defined)

0x0020

Slave needs cold start     evice requires a power off-power on reset

0x0021

Slave needs INIT    pplication  requests INIT state

0x0022     

Slave needs PREOP       Slave  application requests PREOP state

0x0023

Slave needs SAFEOP    Slave  application requests SAFEOP state

0x0024

Invalid Input Mapping    Input process data mapping do not match to expected mapping

0x0025

Invalid Output Mappingoutput process data mapping do not match to expected mapping

0x0026

Inconsistent Settings      General settings mismatch

0x0027

Freerun not supported

0x0028

Synchronization not supported

0x0029

Freerun needs 3 Buffer ModeFreeRun Mode, sync manager has to run in 3-Bufler Mode

0x002A

Background Watchdog

0x002B

No Valid Inputs and Outputs

0x002C

Fatal Sync Error     Fatal  Sync Error Synco or Sync1 are not received any more

0x002D

No Sync Eror  ync  not receed: In SAFEOP the slave waits for the firstSyncorSync1 events before  switching to OP if these events were not received during the SAFEOP to OP-  Timeout time the ecode      should  refuse the state transition to oP with this al status(SystemTimeottset too  big. no DC event received

0x0030

Invalid DC SYNC Configuration   Distributed Clocks configuraton is invalid  due to applicaton requirements

0x0031

Invalid DC Latch Configuration    DC Latch connguration is invalld due to  application requirements

0x0032

PLL ErTor      Master not synchronized at least one DC  event received

0x0033

DC Sync IO Error  Mutuple synchronization errors. IO is not  synchronized any more

0x0034

DC Sync Timeout ErrorMufuple synchronization errors. Too much SM  Events missed

0x0035

DC Invalid Sync Cycle Time

0x0036

DC Synco Cyde Time    DC Synco Cycle time does not fit to  applicaton requrements

0x0037

DC Sync1 Cycle Time   DC Sync1 cyde time does not nt to  application requirements

0x0041

MBX_ AOE

0x0042

MBX EOE

0x0043

MBX COE

0x0044

MBX FOE

0×0045

MBX SOE

0x004F

MBX VOE

0x0050

EEPROM No Access     EEPROM not assigned to PDI

0x0051

EEPROM Error     EEPROM access error

0x0060

Slave Restarted Locally

0x0061

Device ldentification value  updated The device identifcation value was updated and is now valid

0x00F0

Application Controler avalable  The local application releases the appcation controller which snow avadable  and services the ethercAt state machine and all other device features

This optional AL Status Code  shall onty be used for devices that have a different power suppl for the ESC  and the application controller and which cannot define a maximum timeout  value for transition|→P

NOTE: Use case can be if ESC is  powered before applicaton controller. Err Indication can be used by Master to  indicate that stave is ready for boot-up (instead of cchc polling)

END

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册哦

x
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册哦

本版积分规则

QQ|小黑屋|手机版|Archiver|PLC技术网-PLC论坛 ( 粤ICP备17165530号 )|网站地图

GMT+8, 2024-5-5 04:55 , Processed in 0.055285 second(s), 27 queries .

快速回复 返回顶部 返回列表