关键词不能为空

当前您在: 主页 > 英语 >

EtherCAT入门教程

作者:高考题库网
来源:https://www.bjmy2z.cn/gaokao
2021-02-06 07:04
tags:

-

2021年2月6日发(作者:宝剑锋)


EtherCAT


入门教程








本文翻译了


kithara


官方文档,


也加入了一些理解,


暂时

< p>
做得还不够完美,后续补充修正。


2014.06.06


EtherCAT


This tutorial describes the following topics using the EtherCAT


API


本向导描述了使用


EtherCAT API


的功能说明


Creating a


EtherCAT master assigned to a network adapterCreating slaves


assigned to the masterReal-time process data exchange with


datasets and assigned PDOsReal-time up/download of service


data objects (SDO)Real-time mailbox communicationState


control for master and slavesGetting information for master,


slaves, data objects, variable objects


中文说明创建

< br>EtherCAT



站使用的网卡创建连接主站的从站使 用


dataset



PDO

< p>
进行


实时过程数据交互


Master related functions----


主站相关功能



Opening a network adapter----


打开网卡



Before we can create a master, it is necessary to open a network


adapter first. This is done by using the function


KS_openAdapter. As parameters an adapter name, a receive and


a send pool size is needed. The adapter name is usually the name


of a network device. The function KS_enumDevices enumerates


all devices. To only get network devices the parameter


deviceType is set to “NET”.



在创建主站之前,


必须打开网卡。


使用


KS_openAdapter


函数


打 开网卡,需要的参数包括网卡名称,收发数据池大小等。


可以使用


KS_enumDevices


枚举设备获取网卡名称,使用该


函数时参数


deviceType


应该设置为“


NET




Mind that the function KS_openAdapter must be called with the


flag KSF_REALTIME_EXEC.


使用


KS_openAdapter


时需要将标志位


flag


设置为


KSF_REALTI ME_EXEC



表明网卡运行在实时模式。

< br>ksError


= KS_enumDevices(



//


枚举设备





















// Searches for network devices














deviceIndex,













// Count, starting with


zero














pDeviceName,













// Buffer for device


name














0);






















// Flags


if (ksError)



// ...ksError = KS_openAdapter(



//


打开网卡















&hAdapter,















// Adapter


handle pointer














pDeviceName,













// Hardware ID of


the Controller














256,





















// Receive Pool


Length














256,





















// Send Pool Length














KSF_REALTIME_EXEC);






// Flags


if (ksError)



// ...For further details see How to look up for devices.


Creating a master----


创建主站



To create a master the function KS_createEcatMaster can be


used. As parameters a network adapter handle and a path to


device description XML files are needed. A name of a topology


file (*.ktp) is optional. The device description XML files can be


found with a developer installation in the XML directory or can


be downloaded from the slave manufacturer website. A topology


file can be created with the Kithara ?Master Monitor?.


使用


KS_creat eEcatMaster


创建主站,


需要传入网卡句柄参数


和从站


XML


设备描述文件路径,也可以加 入一个拓扑文件


ktp


参数。设备描述文件可以从设备制造商的 网站上获取。


拓扑文件可以用


Master Monitor


生成。



The Kithara ?Master Monitor? is a tool for e.g. configuration,


diagnostics and saving XML configuration files for graphically


viewing slaves, objects and variables or comparing a given


topology with a target topology.


Master Monitor

< br>是一个用于配置、调试和保存


xml


配置文件

< p>
的图形化工具,


可以查看从站、


对象、

< p>
变量和对比拓扑文件。



Closing a master----


关闭主站



To close a master and free all its resources the function


KS_closeEcatMaster must be used.


使用


KS_closeEcatMaster


关闭从站



State change for a master----


主站的状态切换



To query and change the master's state the functions


KS_queryEcatMasterState and KS_changeEcatStatecan be used.



KS_queryEcatMasterState


查询主站状态。< /p>




KS_changeEcatSta te


改变主站状态。



The function KS_queryEcatMasterState needs a master handle,


a pointer to the structureKSEcatMasterState and flags. Be sure


to initialize the structure member structSize to the actual size of


the structure KSEcatMasterState before calling the function.




The function KS_changeEcatState needs a master handle, the


requested state and flags as parameters. The state of all assigned


slaves which are online is changed. Slaves are assigned using


the functionKS_createEcatSlave or KS_createEcatSlaveIndirect.




Nearly every EtherCAT API function has special requirements


regarding the state (see the APIdocumentation of the specific


function). For further information about the state machine see


The EtherCAT state machine.


几乎每一个


EtherCAT



API


函数都需 要主站在特定的状态


才能使用。



Slave related functions----


从站相关函数



Enumerating all online slaves----


枚举所有在线从站



After a master was created, all online slaves can be enumerated


using the function KS_enumEcatSlaves. As parameters a master


handle, a enumeration index and a pointer to the structure


KSEcatSlaveState are needed. Be sure to initialize the structure


member structSize to the actual size of the


structureKSEcatSlaveState before calling the function.


主站创建之后,则可以使用

< p>
KS_enumEcatSlaves


枚举所有从



.


需要的参数包括主站句柄、枚举顺序、一个


KSEcatSlaveState


结构体的指针。在使用前应当初始化结构< /p>


体的成员变量


structSize


大小 。



If the enumeration index is greater than the number of online


slaves, the error codeKSERROR_DEVICE_NOT_FOUND is


returned. Otherwise, a pointer to the structure KSEcatSlaveState


is returned which contains information about the slave's state.




Using the function KS_enumEcatSlaves the slaves are


enumerated by their absolute position.


Creating a slave----


创建从站



To create a slave, one of the functions


KS_createEcatSlaveIndirect or KS_createEcatSlave can be used.


The function KS_createEcatSlaveIndirect makes use of the


structure KSEcatSlaveState which can be obtained using the


function KS_enumEcatSlaves.


The function KS_createEcatSlave needs additional parameters


like slave id, position, vendor id and revision number. With the


parameter slave id a relative position can be provided, too.


The parameters are unique to a slave type. This information can


be found in the slave's manual, using the method above with the


structure KSEcatSlaveState or can be displayed with the


Kithara ?Master Monitor?.


If a slave is already assigned and the function


KS_createEcatSlave is called with the same vendor ID, product


ID, revision number and position, an error


KSERROR_DEVICE_ALREADY_USED is returned together


with a slave handle to the already assigned slave.


Deleting a slave----


删除从站



A slave can be deleted using the function KS_deleteEcatSlave.


Getting information from slaves----


获取从站信息



To query information from a slave the function


KS_queryEcatSlaveInfo can be used. It delivers a pointer to the


structure KSEcatSlaveInfo. If information about process data


objects (PDO), service data objects (SDO) or both are needed,


the flags KSF_SDO and KSF_PDO can be passed to the


function. The function is time consuming (up to 30 seconds) and


the state PREOP or higher is needed for online slaves.


Within the structure KSEcatSlaveInfo there is an array of


KSEcatDataObjInfo and within this structure there is an array of


KSEcatDataVarInfo.


If using languages like C# these structured cannot be accessed.


Alternatively, the functionsKS_queryEcatDataObjInfo,


KS_queryEcatDataVarInfo, KS_enumEcatDataObjInfo


andKS_enumEcatDataVarInfo can be used instead.


State changes for slaves----


从站状态机改变,与主站类似



To query and change the slave's state the functions


KS_queryEcatSlaveState and KS_changeEcatState can be used.


查询和 改变从站状态可以用以上两个函数,改变状态的函数


与改变主站的相同

< br>


The function KS_queryEcatSlaveState needs a slave handle, a


pointer to the structure KSEcatSlaveStateand flags. Be sure to


initialize the structure member structSize to the actual size of the


structureKSEcatSlaveState before calling the function.


查询从站状态函数,需要一个从站句柄 、指向


KSEcatSlaveState


结构体的指针和标志 位。使用前请初始化


结构体内部的


structSize


变量。



For further information concerning the state machine see The


EtherCAT state machine.


更多的信息可以查看此章节



Other operations on slaves----


从站的其他操作



Using the function KS_writeEcatSlaveId it is possible to write a


unique ID to any slave. The ID is written to non-volatile


memory and will be persistent. Within a connected real topology


the IDs must be unique. Mind that the slave must be in INIT


state.


使用


KS_write EcatSlaveId


函数可以给从站写入唯一的


ID



ID


必须是唯一的,注意此时从站的状态必 须是


INIT


Dataset related functions----Dataset


相关函数



A dataset is a collection of sync managers, a sync manager can


contain several PDOs (process data objects) and a PDO can be


mapped to multiple SDO (service data object) variables. A sync


manager is a slave internal mechanism to keep data consistent.

-


-


-


-


-


-


-


-



本文更新与2021-02-06 07:04,由作者提供,不代表本网站立场,转载请注明出处:https://www.bjmy2z.cn/gaokao/606256.html

EtherCAT入门教程的相关文章

  • 余华爱情经典语录,余华爱情句子

    余华的经典语录——余华《第七天》40、我不怕死,一点都不怕,只怕再也不能看见你——余华《第七天》4可是我再也没遇到一个像福贵这样令我难忘的人了,对自己的经历如此清楚,

    语文
  • 心情低落的图片压抑,心情低落的图片发朋友圈

    心情压抑的图片(心太累没人理解的说说带图片)1、有时候很想找个人倾诉一下,却又不知从何说起,最终是什么也不说,只想快点睡过去,告诉自己,明天就好了。有时候,突然会觉得

    语文
  • 经典古训100句图片大全,古训名言警句

    古代经典励志名言100句译:好的药物味苦但对治病有利;忠言劝诫的话听起来不顺耳却对人的行为有利。3良言一句三冬暖,恶语伤人六月寒。喷泉的高度不会超过它的源头;一个人的事

    语文
  • 关于青春奋斗的名人名言鲁迅,关于青年奋斗的名言鲁迅

    鲁迅名言名句大全励志1、世上本没有路,走的人多了自然便成了路。下面是我整理的鲁迅先生的名言名句大全,希望对你有所帮助!当生存时,还是将遭践踏,将遭删刈,直至于死亡而

    语文
  • 三国群英单机版手游礼包码,三国群英手机单机版攻略

    三国群英传7五神兽洞有什么用那是多一个武将技能。青龙飞升召唤出东方的守护兽,神兽之一的青龙。玄武怒流召唤出北方的守护兽,神兽之一的玄武。白虎傲啸召唤出西方的守护兽,

    语文
  • 不收费的情感挽回专家电话,情感挽回免费咨询

    免费的情感挽回机构(揭秘情感挽回机构骗局)1、牛牛(化名)向上海市公安局金山分局报案,称自己为了挽回与女友的感情,被一家名为“实花教育咨询”的情感咨询机构诈骗4万余元。

    语文