The RMP Motion Controller APIs
UserLimitDigitalInputAction.cpp
#include "rsi.h" // Import our RapidCode Library.
#include "HelperFunctions.h" // Import our SampleApp helper functions.
using namespace RSI::RapidCode;
void UserLimitDigitalInputActionMain()
{
const int IO_NODE_NUMBER = 1; // which SqNode to use for I/O?
const int AXIS_NUMBER = 3; // which Axis number to abort?
const int USER_LIMIT = 0; // which user limit to use?
const int CONDITION = 0; // which condition to use (0 or 1)
const int INPUT_BIT_NUMBER = 7; // which input bit?
// RapidCode interface classes
IO *io;
IOPoint *digitalInput;
// Initialize MotionController class.
try
{
HelperFunctions::StartTheNetwork(controller); // [Helper Function] Initialize the network.
// initialize the I/O class
io = controller->IOGet(IO_NODE_NUMBER);
digitalInput = IOPoint::CreateDigitalInput(io, INPUT_BIT_NUMBER);
// configure user limit to evaluate input bit
controller->UserLimitConditionSet(USER_LIMIT,
CONDITION,
RSIUserLimitLogic::RSIUserLimitLogicEQ,
digitalInput->AddressGet(),
digitalInput->MaskGet(),
digitalInput->MaskGet());
// enable the user limit, generate ESTOP_ABORT action when input is turned on
controller->UserLimitConfigSet(USER_LIMIT, RSIUserLimitTriggerType::RSIUserLimitTriggerTypeSINGLE_CONDITION, RSIAction::RSIActionE_STOP_ABORT, AXIS_NUMBER, 0.0);
printf("Waiting for the input bit to go high...\n");
printf("\nPress Any Key To Exit.\n");
// wait for user limit to trigger
while (controller->OS->KeyGet((int32_t)RSIWait::RSIWaitPOLL) < 0)
{
printf("User Limit state is %d\r", controller->UserLimitStateGet(USER_LIMIT));
controller->OS->Sleep(1);
}
// disable User Limit
controller->UserLimitDisable(USER_LIMIT);
}
catch (RsiError const& rsiError)
{
printf("Text: %s\n", rsiError.text);
}
controller->Delete(); // Delete the controller as the program exits to ensure memory is deallocated in the correct order.
system("pause"); // Allow time to read Console.
}
RSI::RapidCode::MotionController::OS
RapidCodeOS * OS
Provides access to operating system (Windows) features.
Definition: rsi.h:3781
RSI::RapidCode::RapidCodeOS::Sleep
void Sleep(int32_t milliseconds)
Put the current thread to sleep.
RSI::RapidCode::IOPoint::MaskGet
int32_t MaskGet()
Get the bit mask for the I/O point.
RSI::RapidCode::RsiError
The RsiError object contains information about any RapidCode API object's error/exception.
Definition: rsi.h:105
RSI::RapidCode::IO
The IO object provides an interface to the inputs and outputs of a network node.
Definition: rsi.h:4221
RSI::RapidCode::MotionController::Delete
void Delete(void)
Delete the MotionController and all its objects.
RSI::RapidCode::RapidCodeOS::KeyGet
int32_t KeyGet(int32_t milliseconds)
Wait for a key to be pressed and return its value.
RSI::RapidCode::MotionController::UserLimitDisable
void UserLimitDisable(int32_t number)
Disable the processing of a User Limit.
RSI::RapidCode::MotionController::CreateFromSoftware
static MotionController * CreateFromSoftware()
Initialize and start the RMP EtherCAT controller.
RSI::RapidCode::IOPoint::AddressGet
uint64_t AddressGet()
Get the Host Address for the I/O point.
RSI::RapidCode
RSI::RapidCode::MotionController::IOGet
IO * IOGet(int32_t nodeNumber)
IOGet returns a pointer to an IO object using its node number and initializes its internals.
RSI::RapidCode::MotionController::UserLimitConfigSet
void UserLimitConfigSet(int32_t number, RSIUserLimitTriggerType triggerType, RSIAction action, int32_t actionAxis, double duration, bool singleShot)
Configure a User Limit.
RSI::RapidCode::MotionController::UserLimitConditionSet
void UserLimitConditionSet(int32_t number, int32_t conditionNumber, RSIUserLimitLogic logic, uint64_t addressOfUInt32, uint32_t userLimitMask, uint32_t limitValueUInt32)
Set the conditions for a User Limit with a 32-bit integer trigger value.
RSI::RapidCode::MotionController
The MotionController object represents the RMP INtime soft motion controller.
Definition: rsi.h:770
RSI::RapidCode::MotionController::UserLimitStateGet
bool UserLimitStateGet(int32_t number)
Get the state of a User Limit.
RSI::RapidCode::IOPoint
The IOPoint object represents one specific point class such as: Digital Output, Digital Input,...
Definition: rsi.h:12083
RSI::RapidCode::IOPoint::CreateDigitalInput
static IOPoint * CreateDigitalInput(Axis *axis, RSIMotorDedicatedIn motorDedicatedInNumber)
Create a Digital Input from an Axis' Dedicated Input bits.
HelperFunctions.CheckErrors
static void CheckErrors(RapidCodeObject rsiObject)
Check if the RapidCode Object has any errors.
Definition: HelperFunctions.cs:64
HelperFunctions.StartTheNetwork
static void StartTheNetwork(MotionController controller)
Start the controller communication/network.
Definition: HelperFunctions.cs:109