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#

    axis.AmpEnableSet(true);
    axis.MoveVelocity(VELOCITY, ACCELERATION); // move at constant velocity

  • C++

    // *NOTICE* The following constants must be configured before attempting to run with hardware.
    const int NUM_AXES = 1; // the number of axes to configure
    const int AXIS_INDEX = 0; // the index of the axis to configure
    // motion Parameters
    const double POSITION_0 = 0; // specify the start position
    const double POSITION_1 = 0.5; // specify the position to move to
    const double VELOCITY = 1; // specify your velocity - units: UserUnits/Sec
    const double ACCELERATION = 10; // specify your acceleration - units: UserUnits/Sec^2
    const double DECELERATION = 10; // specify your deceleration - units: UserUnits/Sec^2
    const double JERK_PERCENT = 50; // specify your jerk percent (0.0 to 100.0)
    const double FINAL_VELOCITY = 0.5; // specify your final velocity - units: UserUnits/Sec
    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#

    /* This sample demonstrates how to control axis velocity dynamically using an analog input value.
    The analog input value (0 to 65536 for a 16-bit input) is mapped to a velocity range.
    This was created using the EL3002 Analog Input module but works with many other modules.
    */
    using RSI.RapidCode; // RSI.RapidCode.dotNET;
    using System.Threading;
    Console.WriteLine("📜 Axis Motion: Velocity via Analog Input");
    // set sample config params
    const double ACCELERATION = 100;
    const double MAX_VEL = 10;
    const double MAX_ANALOG = 65536; // 16-bit analog input
    const int RUN_TIME_SECONDS = 20; // how long to run the velocity control loop
    // get rmp objects
    try
    {
    Helpers.CheckErrors(controller);
    // check is network is started
    if (controller.NetworkStateGet() != RSINetworkState.RSINetworkStateOPERATIONAL)
    {
    Console.WriteLine("Network not started. Please start it before running this app.");
    return;
    }
    // get phantom axis
    Axis axis = controller.AxisGet(Constants.AXIS_1_INDEX);
    Helpers.CheckErrors(axis);
    // get node
    var node = controller.NetworkNodeGet(nodeNumber: 0);
    Helpers.CheckErrors(node);
    // configure axis
    Helpers.PhantomAxisReset(axis);
    axis.AmpEnableSet(true);
    // print sample info
    Console.WriteLine($"Max Speed = {MAX_VEL}");
    Console.WriteLine($"Running for {RUN_TIME_SECONDS} seconds...\n");
    // control velocity based on analog input
    var startTime = DateTime.Now;
    while ((DateTime.Now - startTime).TotalSeconds < RUN_TIME_SECONDS)
    {
    // get analog input value and normalize to 0.0 - 1.0
    double analogValue = node.AnalogInGet(analogChannel: 0);
    double normalizedValue = analogValue / MAX_ANALOG;
    /*
    ┌────────────────────────────────────────────────────┐
    │ Analog Input Value Maps Linearly to Velocity │
    │ │
    │ Analog: 0 ............................ 65,536 │
    │ Velocity: 0 ............................ MAX_VEL │
    └────────────────────────────────────────────────────┘
    */
    // map analog input linearly to velocity (0 to MAX_VEL)
    double velocity = normalizedValue * MAX_VEL;
    axis.MoveVelocity(velocity, ACCELERATION);
    Thread.Sleep(1); // prevent cpu spin
    }
    // cleanup
    Helpers.AbortMotionObject(axis);
    }
    // handle errors as needed
    finally
    {
    controller.Delete(); // dispose
    }
    Constants used in the C# sample apps.
    Definition _constants.cs:3
    const int AXIS_1_INDEX
    Default: 1.
    Definition _constants.cs:12
    void MoveVelocity(double velocity)
    Represents a single axis of motion control. This class provides an interface for commanding motion,...
    Definition rsi.h:5863
    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...
    Definition rsi.h:800
    int32_t AmpEnableSet(bool enable, int32_t ampActiveTimeoutMilliseconds=AmpEnableTimeoutMillisecondsDefault, bool overrideRestrictedState=false)
    Enable all amplifiers.
    RSINetworkState
    State of network.
    Definition rsienums.h:568
    Helpers namespace provides utility functions for common tasks in RMP applications.
    Definition helpers.h:21

🔹 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.