/* userLimitStateAction.cpp Copyright(c) 1998-2009 by Robotic Systems Integration, Inc. All rights reserved. This software contains proprietary and confidential information of Robotic Systems Integration, Inc. (RSI) and its suppliers. Except as may be set forth in the license agreement under which this software is supplied, disclosure, reproduction, or use with controls other than those provided by RSI or suppliers for RSI is strictly prohibited without the prior express written consent of Robotic Systems Integration. This sample code shows how to configure the XMP controller's User Limits to compare an input bit to a specific pattern. If the pattern matches, then the specified output bit is activated and a User Event is generated to the host. For any questions regarding this sample code please visit our documentation at www.roboticsys.com Warning! This is a sample program to assist in the integration of your motion controller with your application. It may not contain all of the logic and safety features that your application requires. */ #include "rsi.h" using namespace RSI::RapidCode::SynqNet; // which controller to use? (0 is first PCI controller) #define CONTROLLER_NUMBER 0 // which axis to use? #define AXIS_NUMBER 0 // which axis will we monitor #define TRIGGER_AXIS_NUMBER 1 // which user limit to use? #define USER_LIMIT RSIEventTypeLIMIT_USER0 // which condition to use (0 or 1) #define CONDITION 0 void userLimitStateActionMain() { // RapidCode interface classes MotionController *controller ; Axis *axis ; Axis *triggerAxis ; long axisStatusAddress; long axisStatusMask; try { // initialize MotionController class controller = MotionController::CreateFromBoard(CONTROLLER_NUMBER); // initialize Rsi Axis class axis = controller->AxisGet(AXIS_NUMBER); // initialize Rsi Axis class (we will be waiting for this axis' state to become an error) triggerAxis = controller->AxisGet(TRIGGER_AXIS_NUMBER); // get the trigger axis' status address axisStatusAddress = triggerAxis->AddressGet(RSIAxisAddressTypeSTATUS); // ESTOP bit mask axisStatusMask = RSIXmpStatusESTOP; // configure user limit to evaluate another axis' status axis->UserLimitConditionSet(USER_LIMIT, CONDITION, RSIXmpLimitTypeBIT_CMP, (long)axisStatusAddress, axisStatusMask, axisStatusMask ); // enable the user limit, generate ESTOP_ABORT action when ESTOP occurs on triggerAxis axis->UserLimitConfigSet(USER_LIMIT, (RSIXmpStatus)(RSIXmpStatusLIMIT | RSIXmpStatusESTOP_ABORT), RSIXmpLogicSINGLE , 0.0); printf("Waiting for the triggerAxis to have an ESTOP...\n"); printf("Press any key to exit.\n"); // wait for user limit to trigger while(controller->OS->KeyGet(RSIWaitPOLL) < 0) { printf("User Limit state is %d\r", axis->UserLimitStateGet(USER_LIMIT)); controller->OS->Sleep(1); } // disable User Limit axis->UserLimitConfigSet(USER_LIMIT, RSIXmpStatusLIMIT, RSIXmpLogicNEVER , 0.0); } catch (RsiError *rsiError) { printf("Text: %s\n", rsiError->text); } }