The RMP Motion Controller APIs
Motion: Hold

Motion Hold Move Released By Digital Input sample application. More...

Warning
This is a sample program to assist in the integration of the RMP motion controller with your application. It may not contain all of the logic and safety features that your application requires. The sample apps assume that the system (network, axes, I/O) are configured prior to running the code featured in the sample app. See the Configuration page for more information.


📜 Motion Hold by Digital Input
This sample code is done in AKD Drive with Digital IO Inputs switches. A digital input switch triggers to release the HOLD set on the specified Motion. This functionality is available for all Drives but some changes to the sample app may be required.

// Constants
const int DIGITAL_INPUTS_PDO_INDEX = 3; // Specify the pdo inputs index that represent digital inputs.
// SET MOTION HOLD
ulong inputAddress = controller.NetworkInputAddressGet(DIGITAL_INPUTS_PDO_INDEX); // Get host address using the PDO Input Index of Digital Inputs.
axis.MotionHoldTypeSet(RSIMotionHoldType.RSIMotionHoldTypeCUSTOM); // Use TypeCUSTOM to hold execution based on a particular bit turning ON or OFF.
axis.MotionHoldUserAddressSet(inputAddress); // Specify the digital inputs host address. This address' value will be used to evaluate the motion hold condition.
axis.MotionHoldUserMaskSet(0x20000); // Specify the bit you want to mask/watch from the MotionHoldUserAddressSet' address value (this evaluates using a logic AND)
axis.MotionHoldUserPatternSet(0x20000); // Specify the bit value that will release the motion hold. (When this value is met, motion hold will be released)
axis.MotionAttributeMaskOnSet(RSIMotionAttrMask.RSIMotionAttrMaskHOLD); // Set the HOLD motion attribute mask ON. (This initializes the HOLD on a particular motion)
axis.MoveRelative(10); // Command simple relative motion. (This motion will be HOLD by the condition above)
axis.MotionDoneWait(); // Wait for Motion to be completed.
axis.MoveRelative(10); // If motion attribute mask off has not been set, this motion will have same HOLD condition as previous move.
axis.MotionDoneWait(); // Wait for Motion to be completed.
axis.MotionAttributeMaskOffSet(RSIMotionAttrMask.RSIMotionAttrMaskHOLD);// Set the HOLD motion attribute mask OFF. (This will clear any motion HOLDS that were set on this Axis)
axis.MoveRelative(10); // This motion will have no HOLD since the previous line has set the motion attribute mask OFF.
axis.MotionDoneWait(); // Wait for Motion to be completed.
// Abort and Clear Faults
axis.Abort();
axis.ClearFaults();

Learn more in topic page.


📜 Motion Hold by Position
This sample code is done in AKD Drive with one Actual Axis and one Phantom Axis. It can be applied to two Phatom Axis or two Actual Axis with the slight changes of code which is guided in comment.

// Constants
const double TRIGGER_POS = 1; // Specify the position that will be evaluted on triggering/releasing motion
const int MOVING_AXIS_TARGET = 10;
const int HOLDINGAXIS_TARGET = 2;
// Initialize RapidCode Objects
// Initiazlize Axes: holdingAxis and movingAxis
Axis holdingAxis = controller.AxisGet(Constants.HOLDING_AXIS_INDEX); // Initialize Axis Class. (Use RapidSetup Tool to see what is your axis number)
HelperFunctions.CheckErrors(holdingAxis); // [Helper Function] Check that the axis has been initialize correctly.
Axis movingAxis = controller.AxisGet(Constants.MOVING_AXIS_INDEX); // Initialize HoldAxis Class. (Use RapidSetup Tool to see what is your axis number)
HelperFunctions.CheckErrors(movingAxis); // [Helper Function] Check that the axis has been initialize correctly.
// SET UP MOTION HOLD // Condition/Configuration to the Axis(movingAxis) that will hold Motion and its Position that will trigger/release motion
holdingAxis.MotionHoldTypeSet(RSIMotionHoldType.RSIMotionHoldTypeAXIS_COMMAND_POSITION); // Use RSIMotionHoldTypeAXIS_ACTUAL_POSITION if it is not Phantom Axis.
holdingAxis.MotionHoldAxisNumberSet(movingAxis.NumberGet()); // Specify motion hold to the Axis(movingAxis) whose position will hold the motion of holdingAxis.
holdingAxis.MotionHoldAxisPositionSet(TRIGGER_POS); // Specify motion hold position which is the movingAxis's position(need to multiply with USER_UNITS to get correct position value) to trigger/release the motion of holdingAxis.
holdingAxis.MotionHoldAxisLogicSet(RSIUserLimitLogic.RSIUserLimitLogicGE); // Specify the logic condition that will be evaluated to trigger/release motion based on the SET POSITION(USER_UNITS * TRIGGER_POS).In this case, GT(Greater than or Equal to) motion hold position limit to release
// SET MOTION HOLD ON
holdingAxis.MotionAttributeMaskOnSet(RSIMotionAttrMask.RSIMotionAttrMaskHOLD); // Set the HOLD motion attribute mask ON. (This initializes the HOLD on a particular motion)
holdingAxis.MoveRelative(HOLDINGAXIS_TARGET); // Command simple relative motion(This motion will be hold by condition above until movingAxis's Position passes motion hold position limit)
// Release MOTION HOLD
movingAxis.MoveRelative(MOVING_AXIS_TARGET); // Move movingAxis.MovingAxis's position reaches its MotionHold Position limit(in this case, limit is 5). It will trigger/release motion on holdingAxis (holidingAxis will move relatively 10).
movingAxis.MotionDoneWait();
holdingAxis.MotionDoneWait();

Learn more in topic page.


📜 Motion Hold by Software Address
This sample code is done in AKD Drive with one Actual axis. There are a lots of available/free firmware address. Some are suggested in comment. Avaiable/free firmware addess can be found using vm3 as long as there is no label on address, it can be used.

// Constants
UInt64 SOFTWARE_ADDRESS = controller.AddressGet(RSIControllerAddressType.RSIControllerAddressTypeUSER_BUFFER, 1);
int WAIT_TIME = 10;
int MOVE_DIST = 2;
// SET MOTION HOLD ON AVAILABLE SOFTWARE ADDRESS
axis.MotionHoldTypeSet(RSIMotionHoldType.RSIMotionHoldTypeCUSTOM); // Use TypeCUSTOM to hold execution based on a particular bit turning ON or OFF.
axis.MotionHoldUserAddressSet(SOFTWARE_ADDRESS); // Specify the available hostAddress . This address' value will be used to evaluate the motion hold condition.
axis.MotionHoldUserMaskSet(0x1); // Specify the bit you want to mask/watch from the MotionHoldUserAddressSet' address value (this evaluates using a logic AND)
axis.MotionHoldUserPatternSet(0x1); // Specify the bit value that will release the motion hold. (When this value is met, motion hold will be released)
// Check the condition to be false at first
if (controller.MemoryGet(SOFTWARE_ADDRESS) != 0x0) // Check Available host address value is mask to be false (in this case 0x0)
{
controller.MemorySet(SOFTWARE_ADDRESS, 0x0); // if not, mask it to false value/condition (in this case 0x0)
}
// SET MOTION HOLD
axis.MotionAttributeMaskOnSet(RSIMotionAttrMask.RSIMotionAttrMaskHOLD); // Set the HOLD motion attribute mask ON. (This initializes the HOLD on a particular motion)
axis.MoveRelative(MOVE_DIST); // Command simple relative motion. (This motion will be HOLD by the condition above)
System.Threading.Thread.Sleep(WAIT_TIME); // Sleep for (x) miliseconds before releasing motion hold.
var expectedCmdPos1 = axis.CommandPositionGet(); // Sould be 0
// RELEASE MOTION HOLD
controller.MemorySet(SOFTWARE_ADDRESS, 0x1); // Release Motion Hold by specifying the host address value to SET Condition (in this case 0x10000)
axis.MotionDoneWait(); // Wait for motion to be done
controller.MemorySet(SOFTWARE_ADDRESS, 0x0); // Specify host address value back to false value/condition (in this case 0x0)
var expectedCmdPos2 = axis.CommandPositionGet(); // Should be MOVE_DIST
// COMMAND MOTION AGAIN
axis.MoveRelative(MOVE_DIST); // Command simple relative motion again. (This motion will be HOLD by the condition above)
System.Threading.Thread.Sleep(WAIT_TIME); // Sleep for (x) miliseconds before releasing motion hold.
// RELEASE MOTION HOLD
controller.MemorySet(SOFTWARE_ADDRESS, 0x1); // Release Motion Hold by specifying the host address value to SET Condition (in this case 0x1)
axis.MotionDoneWait(); // Wait for motion to be done
controller.MemorySet(SOFTWARE_ADDRESS, 0x0); // Specify host address value back to false value/condition (in this case 0x0)
// CLEAR MOTION HOLD
axis.MotionAttributeMaskOffSet(RSIMotionAttrMask.RSIMotionAttrMaskHOLD); // Set the HOLD motion attribute mask OFF. (This will clear any motion HOLDS that were set on this Axis)
axis.MoveRelative(MOVE_DIST); // This motion will have no HOLD since the previous line has set the motion attribute mask OFF.
axis.MotionDoneWait(); // Wait for Motion to be completed.

Learn more in topic page.

RSI::RapidCode::RapidCodeMotion::MotionHoldUserPatternSet
void MotionHoldUserPatternSet(int32_t pattern)
Sets the Motion Hold User pattern bit mask.
RSI::RapidCode::RapidCodeMotion::ClearFaults
void ClearFaults()
Clear all faults for an Axis or MultiAxis.
RSI::RapidCode::MotionController::MemoryGet
int32_t MemoryGet(uint64_t address)
Read controller memory.
RSI::RapidCode::Axis::MoveRelative
void MoveRelative(double relativePosition, double vel, double accel, double decel, double jerkPct)
Command a relative point-to-point S-Curve motion.
RSI::RapidCode::RSIMotionHoldType
RSIMotionHoldType
Types for MotionHold attribute.
Definition: rsienums.h:1000
RSI::RapidCode::RSIUserLimitLogic
RSIUserLimitLogic
Logic options for User Limits.
Definition: rsienums.h:626
RSI::RapidCode::MotionController::MemorySet
void MemorySet(uint64_t address, int32_t data)
Write a value to controller memory.
RSI::RapidCode::RapidCodeMotion::MotionAttributeMaskOffSet
void MotionAttributeMaskOffSet(RSIMotionAttrMask maskOff)
Turn off a particular motion attribute mask.
RSI::RapidCode::RSIMotionAttrMask
RSIMotionAttrMask
Attribute masks for motion. You cannot mix RSIMotionAttrMaskDELAY and RSIMotionAttrMaskAPPEND.
Definition: rsienums.h:964
RSI::RapidCode::MotionController::AxisGet
Axis * AxisGet(int32_t axisNumber)
AxisGet returns a pointer to an Axis object and initializes its internals.
RSI::RapidCode::MotionController::AddressGet
uint64_t AddressGet(RSIControllerAddressType type)
Get the an address for some location on the MotionController.
RSI::RapidCode::RapidCodeMotion::Abort
void Abort()
Abort an axis.
RSI::RapidCode::RapidCodeMotion::MotionHoldUserMaskSet
void MotionHoldUserMaskSet(int32_t holdMask)
Sets the Motion Hold User bit mask.
RSI::RapidCode::Axis::CommandPositionGet
double CommandPositionGet()
Get the current command position.
RSI::RapidCode::RSIControllerAddressType
RSIControllerAddressType
Used to get firmware address used in User Limits, Sequencers, etc.
Definition: rsienums.h:411
RSI::RapidCode::RapidCodeMotion::MotionHoldUserAddressSet
void MotionHoldUserAddressSet(uint64_t address)
Sets the Motion Hold User Address.
RSI::RapidCode::RapidCodeMotion::MotionHoldTypeSet
void MotionHoldTypeSet(RSIMotionHoldType type)
Set the motion hold type.
RSI::RapidCode::MotionController::NetworkInputAddressGet
uint64_t NetworkInputAddressGet(int32_t index)
HelperFunctions.CheckErrors
static void CheckErrors(RapidCodeObject rsiObject)
Check if the RapidCode Object has any errors.
Definition: HelperFunctions.cs:64
RSI::RapidCode::RapidCodeMotion::MotionDoneWait
int32_t MotionDoneWait()
Waits for a move to complete.
HelperFunctions
Helper Functions for checking logged creation errors, starting the network, etc.
Definition: HelperFunctions.cs:50
RSI::RapidCode::RapidCodeMotion::MotionAttributeMaskOnSet
void MotionAttributeMaskOnSet(RSIMotionAttrMask maskOn)
Turn on a particular motion attribute mask.