Category:EtherCAT:EC SETUP/zh-hans

From SoftMC-Wiki
< Category:EtherCAT:EC SETUP
Revision as of 03:03, 5 May 2017 by Chi (talk | contribs) (Created page with "{{Languages}} {{Category |description=如何设置EtherCAT. |frontpage=EtherCAT ==介绍== 在开始使用softMC之前,您必须设置EtherCAT主站才能使用从站...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
语言: English  • 中文(简体)‎

Category:EtherCAT:EC SETUP/zh-hans 如何设置EtherCAT.

The front page is EtherCAT

介绍

在开始使用softMC之前,您必须设置EtherCAT主站才能使用从站。
您必须以一定的方式配置系统中的轴,然后以有序的方式调用某些功能和子程序,并确保没有发生错误。

存储库中存在CONFIG.PRG和程序文件EC_SETUP.PRG,并演示以下过程。

CONFIG.PRG通过名称Axes []分配通用轴数组,并将系统中的所有现有轴设置为此数组。

NOTE-Info.svgNOTE
由于verison 0.4.15.3rc6引入了全局轴数组systemAxis[],并且数组Axes []是多余的,因此从CONFIG.PRG中删除。

EC_SETUP.PRG和AX_SETUP.PRG使用此数组自动设置系统。

IMPORTANT.svgIMPORTANT
保持EtherCAT设置的顺序至关重要。
给定示例中的任何更改都可能导致未定义的行为!

EC_SETUP.PRG

EC_SETUP.PRG是一个通用脚本。其目的是在启动EtherCAT主站和从站之前对其进行配置,启动主站,并最终运行其他操作来完成EtherCAT启动过程。

EC_SETUP.PRG以易于嵌入代码配置特定运动驱动器和IO模块的方式编写。

本文详细介绍了EtherCAT启动时由EC_SETUP.PRG执行的主要步骤。

驱动器地址

每个EtherCAT从站都有一个地址。 目前该地址严格按照系统physical topology中的从站位置确定; 也就是说,附加到MC的第一个从站被分配到驱动器地址1,链中的第二个从站被分为从站地址2,依此类推。

EtherCAT从站可以是运动驱动器,IO模块或网关。

PRE-OP模式

在主站启动之前,所有从站都处于PRE-OP模式。 在这个阶段,主站被创建,并且系统从从站收集信息,以便创建由主站以设置EtherCAT通信的数据结构。

首先,区分运动驱动器IO模块。 对于每个从站查询从站的供应商ID和产品代码。 以后可以使用此数据来识别特定产品并为其创建特定配置,如CDHD Configuration example

	numOfSlaves = EC_ETHERCAT_INIT

寻找未知的通用DS402运动驱动器。 如果发现,将其PDO重新映射到所需的最小值。
您可以通过将定义GENERIC_DS402_DRIVE_VENDOR替换为设备的供应商ID来更新以下代码,通过这样来做将其PDO重新映射到所需的最小值以创建同步位置运动:

	for drive_addr = 1 to numOfSlaves
		if ETSLAVES[drive_addr]->et_slavetype = ECAT_MOTIONSLAVE then
			if EC_SLAVES_INFO[drive_addr]->vendor_id = GENERIC_DS402_DRIVE_VENDOR then  '  替换您的产品的供应商ID
				call EC_REMAP_MINIMUM_PDOS(drive_addr)
			end if
		end if
	next

检查EtherCAT拓扑接线错误

EtherCAT拓扑结构对接线方向敏感。 每个EtherCAT从站都有一个INPUT连接器和一个OUTPUT连接器。
从EtherCAT主站的OUTPUT"启动"的电缆必须连接到第一个EtherCAT从站的INPUT。 第二根电缆将从第一个从站的OUTPUT"引出"并连接到第二个从站的INPUT,以此类推。
大多数情况下,'接线错误'意味着在拓扑结构中,EtherCAT电缆连接在INPUT和OUTPUT连接器之间混淆。
这种情况导致未定义的行为,甚至导致错误的电机动作,这是一个安全问题。

IMPORTANT.svgIMPORTANT
如果检测到接线错误,将抛出错误,EC_SETUP.PRG将停止运行
	retVal = CHECK_TOPOLOGY

创建EtherCAT主站.

	call EC_CREATE_MASTER

设置运动周期时间: 4000, 2000, 1000, 500 or 250 [us]

	call EC_SET_BUS_CYCLETIME(4000)  '  循环时间为500/250 [us],添加到FWCONFIG:hpetfreq = 2000


From here on EC_SETUP.PRG uses the gathered information to configure the slaves. A 'For Loop' goes over the slaves and tries to match them to already known products (such as the CDHD). When found, product specific functions are invoked to create data structures in the master that elaborate the PDO mapping of the slaves, be it a motion drive or an IO module. This is where you can add your own code to configure your own EtherCAT slave. Just add another case to match your Vendor ID.
You may use the already prepared GENERIC_DS402_DRIVE_VENDOR case.
Replace the define GENERIC_DS402_DRIVE_VENDOR with your device's vendor ID, and GENERIC_DS402_DRIVE_PRODUCT_ID with the device's product code:

      Case GENERIC_DS402_DRIVE_VENDOR  '  replace with your vendor id

        if EC_SLAVES_INFO[drive_addr]->product_code = GENERIC_DS402_DRIVE_PRODUCT_ID then  '  replace with your product id

          call EC_INSTALL_GENERIC_DRIVE(drive_addr, Counts_Per_Revolution)  '  Counts Per motor Revolution
          num_Of_Motion_Drives = num_Of_Motion_Drives + 1

        end if

If a Servotronix (STX) CDHD servo motion drive is found, the function EC_INSTALL_STX_CDHD is invoked. This function sets certain parameters in the drive, creates the PDO map of the CDHD, and queries the drive's PNUM and PDEN to allow calculation of the Position Factor.

For a generic drive, a minimum PDO mapping and default values are used.

The user can add his own code to EC_USER_PREOP_CONFIG to perform any specific configuration that must take place while the slaves are in PREOP mode.

After the slave configuration is done the master is started:

	' Create PDOs mapping, set bus cycle time, sync clocks between the master and the slaves,
	' raise slaves to OP-Mode and sets master's opmode to operational
	call EC_STARTMASTER  ' Syncs clocks between the master and the slaves, and sets master's opmode to operational

The master attempts to raise all the slaves to OP Mode. If it fails, the procedure is stopped and an error is issued. If it is successful, EtherCAT communication is now online and EC_SETUP.PRG starts the second stage of configuration.

OP Mode

Again, a For Loop goes over all the slaves. When a motion drive is encountered, EC_SETUP.PRG attaches its drive address to an axis and attempts to clear its faults. Again, the user can add his own code to EC_USER_SAFEOP_CONFIG and EC_USER_OP_CONFIG to perform any specific configuration that must take place while the slaves are in "SAFEOP" or "OP" mode.

	' SAFEOP state configuration - Add code to EC_USER_SAFEOP_CONFIG(byval drive_addr as long)
	retVal = EC_USER_SAFEOP_CONFIG(drive_addr)

	' OP state configuration - Add code to EC_USER_OP_CONFIG(byval drive_addr as long)
	retVal = EC_USER_OP_CONFIG(drive_addr)

	' Assign ECAT bus ID and slave address to an axis
	systemAxis(Axis_Attached_To_Drive).busnumber = ECAT_BUSID
	systemAxis(Axis_Attached_To_Drive).dadd = drive_addr

	' Attempt to clear faults in the drives
	Try

		call EC_CLEAR_FAULTS(drive_addr)

	Catch Else

		' if clear faults failed due to PLL Sync Error, wait a little longer and retry
		if EC_SDO_READ(drive_addr, 0x603f, 0) = 0x7386 then
			printu "PLL Error in drive #. Sleeping 5 seconds and retrying to clear fault";drive_addr
			sleep 5000
			call EC_CLEAR_FAULTS(drive_addr)
		end if

	End Try


All the motion drives are set to Synchronous Position Mode:

	' Set drives to sync position mode
	if EC_IS_PDO(Axes[Axis_Attached_To_Drive].dadd, 0x6060, 0) then
		call EC_PDO_WRITE(Axes[Axis_Attached_To_Drive].dadd, Modes_Of_Operation_6060h, 0, 8)
	else
		call EC_SDO_WRITE(Axes[Axis_Attached_To_Drive].dadd, Modes_Of_Operation_6060h, 0, 8, 8)
	end if


See Also


This category currently contains no pages or media.