Difference between revisions of "Program Examples:Homing"

From SoftMC-Wiki
Jump to: navigation, search
Line 5: Line 5:
 
{{Note|
 
{{Note|
 
The homing parameters must be set in "Drive Units", therefore the user values are converted to drives units
 
The homing parameters must be set in "Drive Units", therefore the user values are converted to drives units
by multiplying them in the relevant motion factor and by a factor of 1000 to scale from sec to msec.}}
+
by multiplying them in the relevant motion factor and by a factor of 1000 to scale from seconds to milliseconds.}}
  
  

Revision as of 08:28, 10 November 2014

The following example demonstrates how to issue a homing procedure on all the axes.

A "For Loop" iterates over the axes that are attached to motion drives, sets the desired homing parameters and invokes EC_SLAVE_HOME to start the homing procedure.

NOTE-Info.svgNOTE

The homing parameters must be set in "Drive Units", therefore the user values are converted to drives units

by multiplying them in the relevant motion factor and by a factor of 1000 to scale from seconds to milliseconds.


'**************************************************************************************************
' 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


The example corresponds to commit SHA-1: 4fe3c7018de141d855eb556d3e637e0283807314 in GIT.


See Also