UserLimit directly sets a command position sample application.
More...
- 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. We recommend that you wire an external hardware emergency stop (e-stop) button for safety when using our code sample apps. Doing so will help ensure the safety of you and those around you and will prevent potential injury or damage.
The sample apps assume that the system (network, axes, I/O) are configured prior to running the code featured in the sample app. See the Configuration page for more information.
📜 User Limit Trigger: Digital Input
Conditions: 1
This sample code is done in AKD Drive with one Actual axis. There are a lots of available/free firmware address. Some are suggested in comment. Avaiable/free firmware addess can be found using vm3 as long as there is no label on address, it can be used.
const int INPUT_INDEX = 0;
const int OUTPUT_INDEX = 1;
IOPoint input0 = IOPoint.CreateDigitalInput(controller, userBufferAddress, INPUT_INDEX);
int userLimitNumber = 0;
int condition = 0;
UInt64 inputAddress = input0.AddressGet();
uint test = (uint)input0.MaskGet();
uint inputMask = (uint)input0.MaskGet();
uint limtValue = (uint)input0.MaskGet();
condition,
logic,
inputAddress,
inputMask,
limtValue);
int axisNumber = 0;
int duration = 0;
triggerType,
action,
axisNumber,
duration);
uint andMask = (uint)output0.MaskGet();
uint orMask = (uint)output0.MaskGet();
UInt64 outputAddress = output0.AddressGet();
bool enableOutput = true;
andMask,
orMask,
outputAddress,
enableOutput);
{
Assert.False(output0.Get(), "We expect the output to NOT be triggered");
controller.
MemorySet(input0.AddressGet(), 1);
}
Assert.True(output0.Get(), "We expect the output to be triggered");
output0.Set(false);
Learn more in topic page.
📜 User Limit Trigger: Digital Input
Conditions: 2
This sample code shows how to configure the RMP controller's User Limits to compare an two different input bits to a specific signal (high signal (1) OR low signal (0)). If the (2 conditions) patterns match, then the specified output bit is activated (turns high).
In this example we configure a user limit to trigger when both our INPUTS turns high(1). Once the INPUTS turn high(1) then our user limit will set the OUTPUT to high(1). The INPUTS are specified in two different UserLimitConditionSet() The OUTPUT is specified in UserLimitOutputSet()
In this example Beckhoff IO Terminals (Model EL1088 for Inputs and Model EL2008 for outputs) were used to control the Digital IO signals.
Make sure to check the correct digital IO signal indexes of your system in: RapidSetup -.Tools -.NetworkIO
const int INPUT_INDEX0 = 0;
const int INPUT_INDEX1 = 1;
const int OUTPUT_INDEX = 2;
int userLimitNumber = 0;
IOPoint input0 = IOPoint.CreateDigitalInput(controller, userBufferAddress, INPUT_INDEX0);
IOPoint input1 = IOPoint.CreateDigitalInput(controller, userBufferAddress, INPUT_INDEX1);
IOPoint output0 = IOPoint.CreateDigitalOutput(controller, userBufferAddress, OUTPUT_INDEX);
int condition0 = 0;
UInt64 input0Address = input0.AddressGet();
uint input0Mask = (uint)input0.MaskGet();
uint limitValue0 = (uint)input0.MaskGet();
int condition1 = 1;
UInt64 input1Address = input1.AddressGet();
uint input1Mask = (uint)input1.MaskGet();
uint limitValue1 = (uint)input1.MaskGet();
condition0,
logic,
input0Address,
input0Mask,
limitValue0);
condition1,
logic,
input1Address,
input1Mask,
limitValue1);
int axis = 0;
int duration = 0;
triggerType,
action,
axis,
duration);
uint andMask = (uint)output0.MaskGet();
uint orMask = (uint)output0.MaskGet();
UInt64 outputAddress = output0.AddressGet();
bool enableOutput = true;
andMask,
orMask,
outputAddress,
enableOutput);
{
Assert.False(output0.Get(), "We expect the output to NOT be triggered");
controller.
MemorySet(input0.AddressGet(), 1);
Assert.False(output0.Get(), "We expect the output to NOT be triggered");
controller.
MemorySet(input0.AddressGet(), 2);
Assert.False(output0.Get(), "We expect the output to NOT be triggered");
controller.
MemorySet(input0.AddressGet(), 3);
}
Learn more in topic page.
📜 User Limit Trigger: Digital Input
Conditions: 1
Event: EStop
This sample code shows how to configure a RMP controller's User Limit to compare an input bit to a specific signal (high signal (1) OR low signal (0)).
If the (1 condition) pattern matches, then the specified input bit has been activated (turned high) and a User limit Event will trigger. In this example we configure a user limit to trigger when our INPUT turns high(1). Once the INPUT turns high(1) then our user limit will command an E-Stop action on the Axis and store the Axis Command Position. The INPUT is specified in UserLimitConditionSet() The User Limit configuration is done on UserLimitConfigSet() The specified address to record on User Limit Event is specified in UserLimitInterruptUserDataAddressSet() The Data from the speficified addres is retrieved by calling InterruptUserDataGet() In this example Beckhoff IO Terminals (Model EL1088 for Inputs) were used to control the Digital IO signals. Make sure to check the correct digital IO signal indexes of your system in: RapidSetup -. Tools -. NetworkIO
const int AXIS_INDEX = 0;
const int INPUT_INDEX = 0;
const int AXIS_COUNT = 1;
const int USER_LIMIT = 0;
const int CONDITION = 0;
const int LIMIT_VALUE = 1;
const double DURATION = 0.125;
const int USER_DATA_INDEX = 0;
IOPoint input0 = IOPoint.CreateDigitalInput(controller, userBufferAddress, INPUT_INDEX);
axis = CreateAndReadyAxis(Constants.AXIS_NUMBER);
axis.MoveVelocity(10.0, 20.0);
controller.
UserLimitConditionSet(USER_LIMIT, CONDITION, LOGIC, input0.AddressGet(), (uint)input0.MaskGet(), LIMIT_VALUE);
USER_DATA_INDEX,
{
controller.
MemorySet(input0.AddressGet(), 1);
}
Console.WriteLine("TRIGGERED - User Limit Interrupt Position = " + interruptPosition / axis.UserUnitsGet());
Learn more in topic page.
📜 User Limit Trigger: Position
Conditions: 1
Event: FeedRate
Configure a UserLimit to change the FeedRate when the axis has reached a specified position.
const int USER_LIMIT = 0;
const int USER_LIMIT_COUNT = 1;
const int AXIS_COUNT = 1;
const int CONDITION = 0;
const double POSITION_TRIGGER_VALUE = 5;
const int DURATION = 0;
const double DEFAULT_FEED_RATE = 1.0;
const double DESIRED_FEED_RATE = 2.0;
UInt64 feedRateAddress;
axis = CreateAndReadyAxis(Constants.AXIS_NUMBER);
axis.FeedRateSet(DEFAULT_FEED_RATE);
controller.
UserLimitConfigSet(USER_LIMIT, TRIGGER_TYPE, ACTION, axis.NumberGet(), DURATION);
Learn more in topic page.
📜 User Limit Trigger: Position
Conditions: 1
Event: Abort
Configure a User Limit to call abort when a specified position is reached.
const int AXIS_COUNT = 1;
const int USER_LIMIT_COUNT = 1;
const int USER_LIMIT_NUMBER = 0;
const double TRIGGER_POSITION = 0.05;
const double MOVE_POSITION = 1.0;
const int OUTPUT_INDEX = 1;
const int WAIT_FOR_TRIGGER_MILLISECONDS = 100;
IOPoint output0 = IOPoint.CreateDigitalOutput(controller, userBufferAddress, OUTPUT_INDEX);
output0.Set(false);
axis = CreateAndReadyAxis(Constants.AXIS_NUMBER);
int condition = 0;
double limitValue = TRIGGER_POSITION;
condition,
limitValue);
int duration = 0;
triggerType,
action,
axis.NumberGet(),
duration);
uint andMask = (uint)output0.MaskGet();
uint orMask = (uint)output0.MaskGet(); ;
UInt64 outputAddress = output0.AddressGet();
bool enableOutput = true;
andMask,
orMask,
outputAddress,
enableOutput);
Assert.False(output0.Get(), "We expect the output to NOT be triggered");
axis.MoveSCurve(MOVE_POSITION);
{
Assert.That(controller.
InterruptSourceNumberGet(), Is.EqualTo(USER_LIMIT_NUMBER + AXIS_COUNT),
"We got a USER_LIMIT interrupt but it was the wrong one.");
Assert.True(output0.Get(), "We expect the output to be turned on when the user limit triggers.");
}
else
{
Assert.Fail("We expected a USER_LIMIT interrupt when the trigger position was exceeded but instead got " + interruptType.ToString());
}
axis.AmpEnableSet(false);
output0.Set(false);
Learn more in topic page.
📜 Two User Limits Custom
Configure two UserLimits. The first will trigger on a digital input and copy the Axis Actual Position to the UserBuffer and decelerate to zero velocity with TRIGGERED_MODIFY. The second UserLimit will trigger after the first UserLimit triggers and the Axis gets to IDLE stae and it will directly set the command position of an Axis from the position stored in the UserBuffer.
const int AXIS_COUNT = 1;
const int USER_LIMIT_FIRST = 0;
const int USER_LIMIT_SECOND = 1;
const int USER_LIMIT_COUNT = 2;
const int DURATION = 0;
const bool ONE_SHOT = true;
const int COMMAND_POSITION_INDEX = 0;
const int ACTUAL_POSITION_INDEX = 1;
const int TC_COMMAND_POSITION_INDEX = 2;
const int TC_ACTUAL_POSITION_INDEX = 3;
public void UserLimitCommandPositionDirectSet()
{
axis = CreateAndReadyAxis(Constants.AXIS_NUMBER);
axis.TriggeredModifyDecelerationSet(Constants.DECELERATION);
axis.TriggeredModifyJerkPercentSet(Constants.JERK_PERCENT);
controller.
UserLimitConfigSet(USER_LIMIT_FIRST, TRIGGER_TYPE, ACTION, axis.NumberGet(), DURATION, ONE_SHOT);
axis.ClearFaults();
axis.AmpEnableSet(true);
axis.MoveVelocity(Constants.VELOCITY, Constants.ACCELERATION);
ConfigureUserLimitInterrupts(USER_LIMIT_FIRST);
ConfigureUserLimitInterrupts(USER_LIMIT_SECOND);
WaitForInterrupts();
}
public void ConfigureUserLimitInterrupts(int userLimitIndex)
{
}
public void WaitForInterrupts()
{
bool done = false;
int timeout_millseconds = 10;
while (!done)
{
switch (eventType)
{
break;
done = true;
break;
default:
break;
}
}
}
Learn more in topic page.