MotionController Axis MultiAxis IO IOPoint NetworkNode RsiError
Sample Apps Changelog

RapidCode API

PhantomAxis.cs

Phantom Axis sample application.

This sample application demonstrates how to set up a phantom axis. Phantom axes can be used to test your applications when the network is unavailable or you need more axes than are currently connected to your network.

Precondition
This sample code presumes that the user has set the tuning paramters(PID, PIV, etc.) prior to running this program so that the motor can rotate in a stable manner.
Warning
This is a sample program to assist in the integration of your motion controller with your application. It may not contain all of the logic and safety features that your application requires.
using RSI.RapidCode.dotNET; // Import our RapidCode Library
using RSI.RapidCode.dotNET.Enums;
using System;
namespace SampleAppsCS
{
class PhantomAxis
{
static void Main(string[] args)
{
// RapidCode objects
Axis phantomAxis; // Declare what 'axis' is
// 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 initialize correctly.
SampleAppsCS.HelperFunctions.StartTheNetwork(controller); // [Helper Function] Initialize the network.
try
{
controller.AxisCountSet(controller.AxisCountGet() + 1); // Configure one additional axis to be used for the phantom axis
int axisNumber = controller.AxisCountGet() - 1; // Set the axis number to the last axis on the network (subtract one because the axes are zero indexed)
Console.WriteLine("\nPhantom Axis Example");
Console.WriteLine("\nCreate Phantom Axis\n");
phantomAxis = controller.AxisGet(axisNumber); // Initialize Axis class
SampleAppsCS.HelperFunctions.CheckErrors(phantomAxis); // [Helper Function] Check that the axis has been initialized correctly
// These limits are not meaningful for a Phantom Axis (e.g., a phantom axis has no actual position so a position error trigger is not necessary)
// Therefore, you must set all of their actions to "NONE".
Console.WriteLine("\nSetting all limit actions to NONE...\n");
phantomAxis.ErrorLimitActionSet(RSIAction.RSIActionNONE); // Set Error Limit Action.
phantomAxis.HardwareNegLimitActionSet(RSIAction.RSIActionNONE); // Set Hardware Negative Limit Action.
phantomAxis.HardwarePosLimitActionSet(RSIAction.RSIActionNONE); // Set Hardware Positive Limit Action.
phantomAxis.HomeActionSet(RSIAction.RSIActionNONE); // Set Home Action.
phantomAxis.SoftwareNegLimitActionSet(RSIAction.RSIActionNONE); // Set Software Negative Limit Action.
phantomAxis.SoftwarePosLimitActionSet(RSIAction.RSIActionNONE); // Set Software Positive Limit Action.
const double positionToleranceMax = Double.MaxValue / 10.0; // reduce from max slightly, so XML to string serialization and deserialization works without throwing System.OverflowException
phantomAxis.PositionToleranceCoarseSet(positionToleranceMax); // Set Settling Coarse Position Tolerance to max value
phantomAxis.PositionToleranceFineSet(positionToleranceMax); // Set Settling Fine Position Tolerance to max value (so Phantom axis will get immediate MotionDone when target is reached)
Console.WriteLine("\nComplete\n");
Console.WriteLine("\nSetting MotorType...\n");
phantomAxis.MotorTypeSet(RSIMotorType.RSIMotorTypePHANTOM); // Set the MotorType to phantom
Console.WriteLine("\nComplete\n");
Console.WriteLine("\nPhantom Axis created\n");
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
Console.WriteLine("\nPress Any Key To Exit"); // Allow time to read Console.
Console.ReadKey();
}
}
}