Program Examples:Homing/zh-hans

From SoftMC-Wiki
Jump to: navigation, search
语言: English  • 中文(简体)‎

以下示例演示如何在所有轴上发出回零过程。

"For Loop"循环遍历连接到运动驱动器的轴,设置所需的归位参数,并调用EC_SLAVE_HOME启动回零过程。

NOTE-Info.svgNOTE
必须在“驱动单元”中设置回零参数,因此通过将用户值乘以相关的运动因子和1000倍的乘积,将用户值转换为驱动单位,从秒到毫秒。


'**************************************************************************************************
' File:			HOME.PRG
' Purpose:		Home all the drives
' Version:		1.00
' Author:		Nir Geller
' Global Variables Used: num_Of_Motion_Drives as long  - Number of ECat MOTION DRIVES found by EC_SETUP.PRG
'			Axes[64] - An array that holds all the axes in the system. Defined in CONFIG.PRG
' History:		9.11.14 - Created
' Description:	This program example iterates over the axes and calls homing procedure.
'		The homing parameters setting and the homing procedure is CDHD specific
'**************************************************************************************************



'**************				Explanation				**************

'		Before starting the homing procedure the user must set homing parameters in the drive.
'		These parameters must be in "drive units", therefore, the desired homing velocity is translated to
'		drive units by multiplying it by the velocity factor and by a factor of 1000 in order to scale from
'		seconds to milliseconds. The same is done for homing acceleration.

'**********************************************************************************************

Program

	dim dHomingFactorFast	as double = 0.5
	dim dHomingFactorslow	as double = 0.25
	dim dHomingFactorAcc	as double = 0.1
	dim dSec2msec		as double = 1000 ' this is used to convert from typical user time-units [msec] to typical drive time-units [sec]
	dim dHomingVelocity	as double = 0
	dim dHomingAcceleration	as double = 0
	dim i as long = 0

	' **** Home all the drives ****
	for i = 1 to num_Of_Motion_Drives

		attach Axes[i]

			' **** Set homing parameters ****
			' set homing method = 34 (pulse index, positive direction)
			call EC_SLAVE_SET_HOMING_PARAMETERS(Axes[i], HOMING_METHOD, 34)

			' set homing offset
			call EC_SLAVE_SET_HOMING_PARAMETERS(Axes[i], HOMING_OFFSET, 0)

			' set FAST homing speed = 10
			dHomingVelocity = (Axes[i].VCruise * Axes[i].VFac * dSec2msec) * dHomingFactorFast
			call EC_SLAVE_SET_HOMING_PARAMETERS(Axes[i], FAST_HOMING_SPEED, dHomingVelocity)

			' set SLOW homing speed = 2
			dHomingVelocity = (Axes[i].VCruise * Axes[i].VFac * dSec2msec) * dHomingFactorSlow
			call EC_SLAVE_SET_HOMING_PARAMETERS(Axes[i], SLOW_HOMING_SPEED, dHomingVelocity)

			' set homing acceleration/deceleration
			dHomingAcceleration = (Axes[i].amax * Axes[i].afac * dSec2msec^2) * dHomingFactorAcc
			call EC_SLAVE_SET_HOMING_PARAMETERS(Axes[i], HOMING_ACCELERATION, dHomingAcceleration)

			call EC_SLAVE_HOME(Axes[i], 120000)  '  Homing timeout: 120,000 msec

			Axes[i].en = 0

		detach Axes[i]

	next

End Program


该示例对应于在GIT中的提交的SHA-1: 4fe3c7018de141d855eb556d3e637e0283807314 in GIT.


参见