using System.Threading;
Console.WriteLine("📜 Axis Motion: Velocity via Analog Input");
const double ACCELERATION = 100;
const double MAX_VEL = 10;
const double MAX_ANALOG = 65536;
const int RUN_TIME_SECONDS = 20;
try
{
if (controller.NetworkStateGet() !=
RSINetworkState.RSINetworkStateOPERATIONAL)
{
Console.WriteLine("Network not started. Please start it before running this app.");
return;
}
var node = controller.NetworkNodeGet(nodeNumber: 0);
Console.WriteLine($"Max Speed = {MAX_VEL}");
Console.WriteLine($"Running for {RUN_TIME_SECONDS} seconds...\n");
var startTime = DateTime.Now;
while ((DateTime.Now - startTime).TotalSeconds < RUN_TIME_SECONDS)
{
double analogValue = node.AnalogInGet(analogChannel: 0);
double normalizedValue = analogValue / MAX_ANALOG;
double velocity = normalizedValue * MAX_VEL;
Thread.Sleep(1);
}
}
finally
{
controller.Delete();
}
Constants used in the C# sample apps.
const int AXIS_1_INDEX
Default: 1.
static void AbortMotionObject(RapidCodeMotion motionObject)
Aborts motion on the given RapidCodeMotion object (Axis or MultiAxis), waits for motion to stop,...
static void CheckErrors(RapidCodeObject rsiObject)
Checks for errors in the given RapidCodeObject and throws an exception if any non-warning errors are ...
static void PhantomAxisReset(Axis phantomAxis)
Configures a phantom axis on the controller.
Helpers class provides static methods for common tasks in RMP applications.
void MoveVelocity(double velocity)
Represents a single axis of motion control. This class provides an interface for commanding motion,...
static MotionController * Get()
Get an already running RMP EtherCAT controller.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
int32_t AmpEnableSet(bool enable, int32_t ampActiveTimeoutMilliseconds=AmpEnableTimeoutMillisecondsDefault, bool overrideRestrictedState=false)
Enable all amplifiers.
RSINetworkState
State of network.