The RMP Motion Controller APIs
UserLimitStateAction.cpp
1
2//@example UserLimitStateAction.cpp
3//
4//* @page user-limit-state-action-cpp UserLimitStateAction.cpp
5//
6//* @brief User Limit State Action sample application.
7//
8//* @details
9//This sample code shows how to configure the XMP controller's User Limits to compare an input bit to a specific pattern.
10//If the pattern matches, then the specified output bit is activated and a User Event is generated to the host.
11//
12//* @pre This sample code presumes that the user has set the tuning paramters(PID, PIV, etc.) prior to running this program so that the motor can rotate in a stable manner.
13//
14//* @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.
15//
16//* @copyright
17//Copyright © 1998-2021 by Robotic Systems Integration, Inc. All rights reserved.
18//This software contains proprietary and confidential information of Robotic
19//Systems Integration, Inc. (RSI) and its suppliers. Except as may be set forth
20//in the license agreement under which this software is supplied, disclosure,
21//reproduction, or use with controls other than those provided by RSI or suppliers
22//for RSI is strictly prohibited without the prior express written consent of
23//Robotic Systems Integration.
24//*
25//* @include UserLimitStateAction.cpp
26//
27//
28//*/
29//
30//#include "rsi.h" // Import our RapidCode Library.
31//#include "HelperFunctionsCpp.h" // Import our SampleApp helper functions.
32//using namespace RSI::RapidCode;
33//
35//const int AXIS_NUMBER = 0;
36//
38//const int TRIGGER_AXIS_NUMBER = 1;
40//const int USER_LIMIT = 0;
41//
43//const int CONDITION = 0;
44//
45//const RSIAction ACTION = RSIAction::RSIActionE_STOP_ABORT;
46//
47//void UserLimitStateActionMain()
48//{
49// // RapidCode interface classes
50// MotionController *controller;
51// Axis *axis;
52// Axis *triggerAxis;
53//
54// uint64_t axisStatusAddress;
55// int32_t axisStatusMask;
56//
57// try
58// {
59// HelperFunctionsCpp::StartTheNetwork(controller); // [Helper Function] Initialize the network.
60//
61// // Initialize MotionController class.
62// MotionController *controller = MotionController::CreateFromSoftware();
63// HelperFunctionsCpp::CheckErrors(controller);
64//
65// // initialize Rsi Axis class
66// Axis *axis = controller->AxisGet(AXIS_NUMBER);
67// HelperFunctionsCpp::CheckErrors(axis);
68//
69//
70// // initialize Rsi Axis class (we will be waiting for this axis' state to become an error)
71// triggerAxis = controller->AxisGet(TRIGGER_AXIS_NUMBER);
72// HelperFunctionsCpp::CheckErrors(triggerAxis);
73//
74//
75// // get the trigger axis' status address
76// axisStatusAddress = triggerAxis->AddressGet(RSIAxisAddressType::RSIAxisAddressTypeSTATUS);
77//
78// // ESTOP bit mask
79// axisStatusMask = (int32_t)RSIFirmwareStatus::RSIFirmwareStatusESTOP;
80//
81//
82// // configure user limit to evaluate another axis' status
83// controller->UserLimitConditionSet(USER_LIMIT,
84// CONDITION,
85// RSIUserLimitLogic::RSIUserLimitLogicEQ,
86// (long)axisStatusAddress,
87// axisStatusMask,
88// axisStatusMask
89// );
90//
91// // enable the user limit, generate ESTOP_ABORT action when ESTOP occurs on triggerAxis
92// controller->UserLimitConfigSet(USER_LIMIT, RSIUserLimitTriggerType::RSIUserLimitTriggerTypeSINGLE_CONDITION,
93// ACTION, AXIS_NUMBER, 0.0);
94//
95// printf("Waiting for the triggerAxis to have an ESTOP...\n");
96// printf("\nPress Any Key To Exit.\n");
97//
98// // wait for user limit to trigger
99// while (controller->OS->KeyGet((int32_t)RSIWait::RSIWaitPOLL) < 0)
100// {
101// printf("User Limit state is %d\r", controller->UserLimitStateGet(USER_LIMIT));
102// controller->OS->Sleep(10);
103// }
104//
105//
106// // disable User Limit
107// controller->UserLimitDisable(USER_LIMIT);
108//
109// }
110// catch (RsiError const& rsiError)
111// {
112// printf("Text: %s\n", rsiError.text);
113// }
114// controller->Delete(); // Delete the controller as the program exits to ensure memory is deallocated in the correct order.
115// system("pause"); // Allow time to read Console.
116//}
117//