APIs, concepts, guides, and more
Velocity Motion

Types of velocity motions

🔹 What is Velocity Motion?

Velocity motion commanding an axis to reach a given velocity instead of a given position. Once the axis reachs the target velocity, it will continue moving at that velocity until it is stopped, aborted, or given another command.

📜 Sample Code

Basic Velocity Motion

  • C#

    // Command a velocity move
    axis.MoveVelocity(Constants.VELOCITY, Constants.ACCELERATION);

  • C++

    // Motion Parameters
    const double POSITION_0 = 0;
    const double POSITION_1 = 0.5;
    const double VELOCITY = 1;
    const double ACCELERATION = 10;
    const double DECELERATION = 10;
    const double JERK_PERCENT = 50;
    const double FINAL_VELOCITY = 0.5;
    std::cout << "Velocity Move:" << std::endl;
    std::cout << "Accelerating to velocity: " << VELOCITY << std::endl;
    axis->MoveVelocity(VELOCITY, ACCELERATION);
    HelperAtVelocityWait(controller, axis, TIMEOUT);
    std::cout << "Motion Complete" << std::endl;
    std::cout << "Decelerating to velocity: " << 0 << std::endl;
    axis->MoveVelocity(0, DECELERATION);
    HelperAtVelocityWait(controller, axis, TIMEOUT);
    std::cout << "Motion Complete" << std::endl;

Velocity Set by Analog Input Value

This Sample App was created using the EL3002 Analog Input module. Please note that some variable values might changed based on your analog input module.
The functionality used with many other Analog Input modules, not only Beckhoff's.
Learn more about the EL3XXX analog input modules from Beckhoff.

  • C#

    // GLOBAL VARIABLES
    double analogMaxValue = 65536; // The analog inputs used are 16 bit wide.
    double currentVelocity = 0; // Used to update velocity based on analog input value.
    double analogCurrentValue = 0; // Used to store current analog input value.
    double analogValuePrecentage = 0; // analogCurrentValue/anlogMaxValue.
    double velocityAbsoluteSum = 0; // Absolute sum of min and max velocities.
    // CONSTANTS
    const int AXIS_NUMBER = 0; // Specify which axis/motor to control.
    const int NODE_NUMBER = 0; // Specify which IO Terminal/Node to control. 0 for RSI AKD DemoBench
    const int ANALOG_INPUT_0 = 0; // Specify which Analog Input to read.
    const int MIN_VEL = -10; // Specify Min Velocity.
    const int MAX_VEL = 10; // Specify Max Velocity.
    const int ACC = 100; // Specify Acceleration/Deceleration value.
    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)
    HelperFunctions.CheckErrors(controller); // [Helper Function] Check that the controller has been initialized correctly.
    HelperFunctions.StartTheNetwork(controller); // [Helper Function] Initialize the network.
    Axis axis = controller.AxisGet(AXIS_NUMBER); // Initialize the axis.
    HelperFunctions.CheckErrors(axis); // [Helper Function] Check that the axis has been initialized correctly.
    IO ioNode = controller.IOGet(NODE_NUMBER); // Initialize the axis.
    HelperFunctions.CheckErrors(ioNode); // [Helper Function] Check that the axis has been initialized correctly.
    try
    {
    // CONSOLE OUT
    Console.WriteLine("Velocity Move Initialized.");
    Console.WriteLine("Max Speed = " + MAX_VEL);
    Console.WriteLine("Min Speed = " + MIN_VEL);
    Console.WriteLine("\nPress SPACEBAR to exit.");
    // READY AXIS
    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.DefaultAccelerationSet(ACC); // Set Acceleration.
    axis.DefaultDecelerationSet(ACC); // Set Deceleration.
    axis.Abort(); // If there is any motion happening, abort it.
    axis.ClearFaults(); // Clear faults.
    axis.AmpEnableSet(true); // Enable the motor.
    do
    {
    while (!Console.KeyAvailable)
    {
    velocityAbsoluteSum = Math.Abs(MIN_VEL) + Math.Abs(MAX_VEL);
    analogCurrentValue = (double)ioNode.AnalogInGet(ANALOG_INPUT_0); // Get analog in value.
    analogValuePrecentage = analogCurrentValue / analogMaxValue; // Get percentage of analog voltage.
    /*
    * REPRESENTATION OF ANALOG INPUT VALUE BASED ON DIGITAL OUTPUT VOLTAGE
    *
    * AI Value --> 0 ............ 32,769 ............ 65,536
    * DO Voltage --> 0 ........8 9 10 -10 -9 -8...... 0
    */
    if (analogValuePrecentage * 100 > 99 || analogValuePrecentage * 100 < 1) // If the Analog Input value is close to 0 or 65,536 then velocity is ZERO.
    currentVelocity = 0;
    else if (analogValuePrecentage * 100 < 50) // If the Analog Input value is less than 50% of 65,536 then velocity varies from 0 to 10.
    currentVelocity = velocityAbsoluteSum * analogValuePrecentage;
    else // If the Analog Input value is greater than 50% of 65,536 then velocity varies from 0 to -10.
    currentVelocity = -velocityAbsoluteSum + (velocityAbsoluteSum * analogValuePrecentage);
    axis.MoveVelocity(currentVelocity); // Update Velocity.
    }
    } while (Console.ReadKey(true).Key != ConsoleKey.Spacebar); // If the Spacebar key is pressed, exit.
    axis.Abort(); // Abort Motion.
    }
    catch (Exception e)
    {
    Console.WriteLine(e.Message); // If there are any exceptions/issues this will be printed out.
    }

🔹 Subsections

  • Final Velocity Motion : Perform an absolute or relative move with a specified final velocity.
  • Multi-Axis Velocity : Perform velocity moves on multiple axes that can be updated synchronously and on the fly.