Motion profile
To create a motion profile for an axis, use SetAxisMotionProfile.
The unit of acceleration and jerk
Before you move an axis, you can decide the unit of acceleration and jerk, which is described in the McProfileType type. The unit determines how an axis accelerates and decelerates.
- profileUnitPerSecond: acceleration in unit per second2 and jerk in unit per second3. The unit is count or the user-defined unit when EnableAxisUnitConversion is called.
- profileDelayInSecond: acceleration delay in seconds. It determines how much time the interpolation takes when it increases its velocity and accelerates from zero to the max velocity.
Code
To create a motion profile, create an instance of the McProfileSettings structure and use SetAxisMotionProfile. In AxisConfiguration.cpp
, add the following code:
Copy
VOID MotionProfile(int Index)
{
RtPrintf("Create a motion profile.\n");
McProfileSettings Motion =
{
MINIMUM_ERROR, //MinimumFollowingError
MAXIMUM_ERROR, //MaximumFollwingError
MAXIMUM_VELOCITY, //MaximumVelocity
MAXIMUM_ACCELERATION, //Acceleration
MAXIMUM_DECELERATION, //Deceleration
MAXIMUM_JERK, //Jerk
MAXIMUM_JOLT //Jolt
};
//MotionProfileType: profileUnitPerSecond.
KsError nRet = SetAxisMotionProfile(Index, MOTION_PROFILE_TYPE, Motion);
if (nRet != errNoError)
RtPrintf("SetAxisMotionProfile failed: %x\n", nRet);
RtPrintf("\n");
}