constint AXIS_NUMBER = 0; // Specify which axis/motor to control.
constint USER_UNITS = 1048576; // Specify USER UNITS
unsignedint SOFTWARE_ADDRESS = 0x026000B4; // Specify Avaiable firmware address (starting from 0x026000B4 to 0x027FFFFF) can be checked in VM3.In VM3, look for Address without label which are available/free.
char rmpPath[] = "C:\\RSI\\X.X.X\\"; // Insert the path location of the RMP.rta (usually the RapidSetup folder)
axis->MotionHoldUserAddressSet(hostAddress); // 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(hostAddress) != 0x0) // Check Available host address value is mask to be false (in this case 0x0)
{
controller->MemorySet(hostAddress, 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(10); // Command simple relative motion. (This motion will be HOLD by the condition above)
std::this_thread::sleep_for(std::chrono::seconds(3)); // Sleep for 3 second before releasing motion hold.
// RELEASE MOTION HOLD
controller->MemorySet(hostAddress, 0x1); // Release Motion Hold by specifying the host address value to SET Condition (in this case 0x10000)
controller->MemorySet(hostAddress, 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(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.