using RSI.RapidCode.dotNET;
using System;
#if DOXYGEN
#endif
class VelocitySetByAnalogInputValue
{
static void Main(string[] args)
{
double analogMaxValue = 65536;
double currentVelocity = 0;
double analogCurrentValue = 0;
double analogValuePrecentage = 0;
double velocityAbsoluteSum = 0;
const int AXIS_NUMBER = 0;
const int NODE_NUMBER = 0;
const int ANALOG_INPUT_0 = 0;
const int MIN_VEL = -10;
const int MAX_VEL = 10;
const int ACC = 100;
const int USER_UNITS = 1048576;
IO ioNode = controller.
IOGet(NODE_NUMBER);
try
{
Console.WriteLine("Velocity Move Initialized.");
Console.WriteLine("Max Speed = " + MAX_VEL);
Console.WriteLine("Min Speed = " + MIN_VEL);
Console.WriteLine("\nPress SPACEBAR to exit.");
do
{
while (!Console.KeyAvailable)
{
velocityAbsoluteSum = Math.Abs(MIN_VEL) + Math.Abs(MAX_VEL);
analogCurrentValue = (double)ioNode.AnalogInGet(ANALOG_INPUT_0);
analogValuePrecentage = analogCurrentValue / analogMaxValue;
if (analogValuePrecentage * 100 > 99 || analogValuePrecentage * 100 < 1)
currentVelocity = 0;
else if (analogValuePrecentage * 100 < 50)
currentVelocity = velocityAbsoluteSum * analogValuePrecentage;
else
currentVelocity = -velocityAbsoluteSum + (velocityAbsoluteSum * analogValuePrecentage);
}
} while (Console.ReadKey(true).Key != ConsoleKey.Spacebar);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
static void CheckErrors(RapidCodeObject rsiObject)
Check if the RapidCodeObject has any errors.
static void StartTheNetwork(MotionController controller)
Start the controller communication/network.
Helper Functions for checking logged creation errors, starting the network, etc.
void UserUnitsSet(double countsPerUserUnit)
Sets the number of counts per User Unit.
void ErrorLimitTriggerValueSet(double triggerValue)
Set the Position Error Limit trigger value.
void MoveVelocity(double velocity)
void PositionSet(double position)
Set the Command and Actual positions.
Represents a single axis of motion control. This class provides an interface for commanding motion,...
void DefaultAccelerationSet(double acceleration)
Set the default acceleration in UserUnits.
void DefaultDecelerationSet(double deceleration)
Set the default deceleration in UserUnits.
Axis * AxisGet(int32_t axisNumber)
AxisGet returns a pointer to an Axis object and initializes its internals.
static MotionController * CreateFromSoftware()
Initialize and start the RMP EtherCAT controller.
IO * IOGet(int32_t nodeNumber)
IOGet returns a pointer to an IO object using its node number and initializes its internals.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
void ClearFaults()
Clear all faults for an Axis or MultiAxis.
void AmpEnableSet(bool enable)
Enable all amplifiers.
void Abort()
Abort an axis.