MotionController Axis MultiAxis IO IOPoint NetworkNode RsiError
Sample Apps Changelog

RapidCode API

FeedRate.cs
using RSI.RapidCode.dotNET; // Import our RapidCode Library.
using System;
namespace SampleAppsCS
{
class FeedRate
{
static void Main(string[] args)
{
// Constants
const int AXIS_NUMBER = 0; // Specify which axis/motor to control.
const int USER_UNITS = 1048576; // Specify your counts per unit / user units. (the motor used in this sample app has 1048576 encoder pulses per revolution)
// Initialize RapidCode Objects
MotionController controller = MotionController.CreateFromSoftware(/*@"C:\RSI\X.X.X\"*/); // Insert the path location of the RMP.rta (usually the RapidSetup folder)
SampleAppsCS.HelperFunctions.CheckErrors(controller); // [Helper Function] Check that the controller has been initialized correctly.
SampleAppsCS.HelperFunctions.StartTheNetwork(controller); // [Helper Function] Initialize the network.
Axis axis = controller.AxisGet(AXIS_NUMBER); // Initialize the axis.
SampleAppsCS.HelperFunctions.CheckErrors(axis); // [Helper Function] Check that the axis has been initialized correctly.
try
{
// Get Axis Ready for Motion
axis.UserUnitsSet(USER_UNITS); // Specify the counts per Unit.
axis.ErrorLimitTriggerValueSet(1); // Specify the position error limit trigger. (Learn more about this on our support page)
axis.PositionSet(0); // Make sure motor starts at position 0 everytime.
axis.DefaultVelocitySet(1); // Specify velocity.
axis.DefaultAccelerationSet(10); // Specify acceleration.
axis.DefaultDecelerationSet(10); // Specify deceleration.
axis.FeedRateSet(1); // Make sure the FeedRate has its default value.
axis.Abort(); // If there is any motion happening, abort it.
axis.ClearFaults(); // Clear faults.
axis.AmpEnableSet(true); // Enable the motor.
// Start Motion
Console.WriteLine("Motion Start");
axis.MoveSCurve(15); // Call MoveScurve to move to a position.
while (axis.ActualPositionGet() < 10) { } // Wait here until we reach position "15".
axis.Stop(); // Stop the axis/motor.
axis.MotionDoneWait(); // Wait for move to complete.
axis.FeedRateSet(-1); // Change FeedRate to reverse motion.
axis.Resume(); // Start Reverse Motion.
Console.WriteLine("New Feed Rate Start");
while (axis.ActualPositionGet() > 5) { } // Wait here until we reach position "5".
axis.Stop(); // Stop the axis/motor.
axis.MotionDoneWait(); // Wait for move to complete.
axis.FeedRateSet(1); // Change FeedRate to default value.
axis.Resume(); // Resume the MoveScurve Motion.
Console.WriteLine("New Feed Rate Start");
axis.MotionDoneWait(); // Wait for move to complete.
axis.AmpEnableSet(true); // Disable axis/motor.
}
catch (Exception e)
{
Console.WriteLine(e.Message); // If there are any exceptions/issues this will be printed out.
}
Console.WriteLine("\nPress Any Key To Exit"); // Allow time to read Console.
Console.ReadKey();
}
}
}