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.
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.
📜 G-Code
Setup and run a simple G-Code program.
string gcodprgm = "G91; Sets the programming mode to RELATIVE\n" +
"G64; Turns off exact stop mode(Default)\n" +
"G1 X1.0 Y0.0 Z0.0 F60.0; Move on USERUNIT in positive x direction at 60in/min\n" +
"G3 X1 Y1 I0 J1; Counter clockwise arc with a center point of 0,1,0 and end point of 1,1,0 relative to the current position\n";
const string xLabel = "X-Axis";
const string yLabel = "Y-Axis";
const string zLabel = "Z-Axis";
const string aLabel = "A-Axis";
const string bLabel = "B-Axis";
const string cLabel = "C-Axis";
x_axis.UserLabelSet(xLabel);
y_axis.UserLabelSet(yLabel);
z_axis.UserLabelSet(zLabel);
a_axis.UserLabelSet(aLabel);
b_axis.UserLabelSet(bLabel);
c_axis.UserLabelSet(cLabel);
Axis[] axes = new Axis[] { x_axis, y_axis, z_axis, a_axis, b_axis, c_axis };
jointsMultiAxis.AxesAdd(axes, axes.Length);
jointsMultiAxis.ClearFaults();
const string modelName = "RSI_XYZABC";
const double scaling = 1.0, offset = 0.0;
LinearModelBuilder builder = new LinearModelBuilder(modelName);
builder.JointAdd(
new LinearJointMapping(0,
CartesianAxis.X) { ExpectedLabel = xLabel, Scaling = scaling, Offset = offset });
builder.JointAdd(
new LinearJointMapping(1,
CartesianAxis.Y) { ExpectedLabel = yLabel, Scaling = scaling, Offset = offset });
builder.JointAdd(
new LinearJointMapping(2,
CartesianAxis.Z) { ExpectedLabel = zLabel, Scaling = scaling, Offset = offset });
builder.JointAdd(
new LinearJointMapping(3,
CartesianAxis.Roll) { ExpectedLabel = aLabel, Scaling = scaling, Offset = offset });
builder.JointAdd(
new LinearJointMapping(4,
CartesianAxis.Pitch) { ExpectedLabel = bLabel, Scaling = scaling, Offset = offset });
builder.JointAdd(
new LinearJointMapping(5,
CartesianAxis.Yaw) { ExpectedLabel = cLabel, Scaling = scaling, Offset = offset });
const int motionFrameBufferSize = 50;
robot = Robot.RobotCreate(controller, jointsMultiAxis, builder, motionFrameBufferSize);
robot.GcodeAccelerationRateSet(1000);
try
{
robot.GcodeStringLoad(gcodprgm);
}
catch (Exception e)
{
if (robot.GcodeErrorLineNumberGet() != -1)
{
Console.WriteLine("Error on line: " + robot.GcodeErrorLineNumberGet() + "Details: " + e.Message);
}
else
{
Console.WriteLine("Error: " + e.Message);
}
}
jointsMultiAxis.ClearFaults();
jointsMultiAxis.AmpEnableSet(true);
robot.Run();
Int64 activeLineNumber = 0;
do
{
Thread.Sleep(200);
if (activeLineNumber != robot.GcodeExecutingLineNumberGet())
{
activeLineNumber = robot.GcodeExecutingLineNumberGet();
Console.WriteLine("G-Code Line Number: " + activeLineNumber);
}
} while (robot.IsRunning());
Learn more in topic page.
📜 Changing Linear Units G-Code
How changing linear units affects vel and accel setters.
const string xLabel = "X-Axis";
const string yLabel = "Y-Axis";
const string zLabel = "Z-Axis";
const string aLabel = "A-Axis";
const string bLabel = "B-Axis";
const string cLabel = "C-Axis";
x_axis.UserLabelSet(xLabel);
y_axis.UserLabelSet(yLabel);
z_axis.UserLabelSet(zLabel);
a_axis.UserLabelSet(aLabel);
b_axis.UserLabelSet(bLabel);
c_axis.UserLabelSet(cLabel);
Axis[] axes = new Axis[] { x_axis, y_axis, z_axis, a_axis, b_axis, c_axis };
jointsMultiAxis.AxesAdd(axes, axes.Length);
jointsMultiAxis.ClearFaults();
const string modelName = "RSI_XYZABC_Centimeters";
const double scaling = 1.0, offset = 0.0;
LinearModelBuilder builder = new LinearModelBuilder(modelName);
builder.UnitsSet(units);
builder.JointAdd(
new LinearJointMapping(0,
CartesianAxis.X) { ExpectedLabel = xLabel, Scaling = scaling, Offset = offset });
builder.JointAdd(
new LinearJointMapping(1,
CartesianAxis.Y) { ExpectedLabel = yLabel, Scaling = scaling, Offset = offset });
builder.JointAdd(
new LinearJointMapping(2,
CartesianAxis.Z) { ExpectedLabel = zLabel, Scaling = scaling, Offset = offset });
builder.JointAdd(
new LinearJointMapping(3,
CartesianAxis.Roll) { ExpectedLabel = aLabel, Scaling = scaling, Offset = offset });
builder.JointAdd(
new LinearJointMapping(4,
CartesianAxis.Pitch) { ExpectedLabel = bLabel, Scaling = scaling, Offset = offset });
builder.JointAdd(
new LinearJointMapping(5,
CartesianAxis.Yaw) { ExpectedLabel = cLabel, Scaling = scaling, Offset = offset });
const int motionFrameBufferSize = 50;
robot = Robot.RobotCreate(controller, jointsMultiAxis, builder, motionFrameBufferSize);
Console.WriteLine(robot.GcodeUnitsGet());
robot.GcodeAccelerationRateSet(10);
robot.GcodeFeedRateSet(10);
Console.WriteLine(robot.GcodeUnitsGet());
robot.GcodeAccelerationRateSet(10);
robot.GcodeFeedRateSet(10);
Learn more in topic page.