Camming

This AeroScript program shows camming motion in which the position of a follower axis is based on the position of a leader axis.

// Camming Example:
// Demonstrates Camming Motion in which the position of a follower axis depends on the position of a leader axis.

#define CAMMING_POINTS 7

program

	// Configure two arrays to map leader values to follower values. When the leader axis is at the position specified in the leader array,
	// the follower axis moves to the related follower position.
	var $leaderValues[CAMMING_POINTS] as real = [0, 60, 120, 180, 240, 320, 360]
	var $followerValues[CAMMING_POINTS] as real = [0, 10, 30, 45, 90, 180, 360]

	// Each camming configuration is stored in a table. The controller can store a maximum of 100 camming tables.
	var $tableNumber as integer = 0

	// Specify the $leaderValues and $followerValues arrays in primary controller units.
	var $unitsMode as CammingUnits = CammingUnits.Primary

	// Specify how the controller will interpolate follower motion.
	// Cubic interpolation supplies third order splining which is more accurate than linear interpolations.
	// Linear interpolation supplies linear curve fitting and might be necessary if cubic overshoot is too large.
	var $interpolationMode as CammingInterpolation = CammingInterpolation.Cubic

	// Camming wrap lets the configured values be cyclic.
	var $wrapMode as CammingWrapping = CammingWrapping.Wrap

	// Load the camming configuration into the controller. The table number identifies this configuration.
	CammingLoadTableFromArray($tableNumber, $leaderValues, $followerValues, CAMMING_POINTS, $unitsMode, $interpolationMode, $wrapMode, 0.0)

	// Enable and home the axes.
	Enable([X, Y])
	Home([X, Y])

	// Configure camming $leaderValues to be interpreted as position commands of the leader axis.
	var $cammingSource as CammingSource = CammingSource.PositionCommand

	// Configure camming $followerValues to be interpreted as absolute positions of the follower axis.
	var $cammingOutput as CammingOutput = CammingOutput.AbsolutePosition

	// Enable camming with follower Y and leader X.
	CammingOn(Y, X, $tableNumber, $cammingSource, $cammingOutput)

	// With camming enabled, the linear motion on X will cause axis Y to also move.
	MoveLinear(X, 540)

	// Disable camming and free the previous configuration.
	CammingOff(Y)
	CammingFreeTable($tableNumber)

	// Disable the axes.
	Disable([X, Y])

end