MotionController Axis MultiAxis IO IOPoint NetworkNode RsiError
Sample Apps Changelog

RapidCode API

UserLimitGainChangeBasedOnPosition.cpp
#include "rsi.h" // Import our RapidCode Library.
#include "HelperFunctions.h" // Import our SampleApp helper functions.
using namespace RSI::RapidCode;
// which axis to use?
const int AXIS_NUMBER = 0;
// which user limit to use?
const int USER_LIMIT = 0;
// which condition to use (0 or 1)
const int CONDITION = 0;
// which gain table
const int GAIN_TABLE = 0;
void UserLimitGainChangeBasedOnPositionMain()
{
//RapidCode interface classes
MotionController *controller;
Axis *axis;
try
{
SampleAppsCPP::HelperFunctions::StartTheNetwork(controller); // [Helper Function] Initialize the network.
// initialize RsiController class
SampleAppsCPP::HelperFunctions::CheckErrors(controller);
// initialize RsiAxis class
Axis *axis = controller->AxisGet(AXIS_NUMBER);
SampleAppsCPP::HelperFunctions::CheckErrors(axis);
// this sample uses Interrupts
controller->InterruptEnableSet(true);
// set the command/actual position to zero
axis->PositionSet(0);
double Axis0TriggerPosition = 7500.0;
double ProportionalGain = axis->FilterCoeffGet(RSIFilterGainPIDCoeffGAIN_PROPORTIONAL, GAIN_TABLE) * 0.65;
// configure user limit to evaluate input bit
controller->UserLimitConditionSet(USER_LIMIT,
CONDITION,
Axis0TriggerPosition);
// configure user limit to set OUTPUT_BIT_MASK high when limit is true
// 64-bit output not supported
//controller->UserLimitOutputSet(USER_LIMIT,
// 0,
// (uint64)*((uint64*)&ProportionalGain),
// (long)axis->AddressGet(RSIAxisAddressType::RSIAxisAddressTypeFILTER_GAIN_KP)
// true);
// set the configuration
axis->MoveVelocity(500, 500);
printf("Waiting for axis0 to reach position specified....\n");
// wait for user limit to trigger
{
}
printf("Axis0 reached specified position. Proportional Gain for axis0 changed!\n");
// disable User Limit
controller->UserLimitDisable(USER_LIMIT);
// stop velocity move
axis->Stop();
}
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.
return;
}