예제 #1
0
        static void Main(string[] args)
        {
            // Constants
            const int AXIS_NUMBER = 0;                  // Specify which axis/motor to control.

            // 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 initialized correctly.

            SampleAppsCS.HelperFunctions.StartTheNetwork(controller);                                // [Helper Function] Initialize the network.

            Axis axis = controller.AxisGet(AXIS_NUMBER);                                             // Initialize the axis.

            SampleAppsCS.HelperFunctions.CheckErrors(axis);                                          // [Helper Function] Check that the axis has been initialized correctly.

            try
            {
                // CHECK AXIS STATE
                RSIState state = axis.StateGet();                                                   // StateGet will return RSIState enum name of the current state of the Axis or MultiAxis. (Ex: RSIStateERROR)

                RSISource source;                                                                   // Declare a RSISource variable.

                switch (state)
                {
                case RSIState.RSIStateIDLE:
                case RSIState.RSIStateMOVING:
                    PrintState(state);
                    break;

                case RSIState.RSIStateERROR:
                case RSIState.RSIStateSTOPPING_ERROR:
                case RSIState.RSIStateSTOPPED:
                case RSIState.RSIStateSTOPPING:
                    source = axis.SourceGet();                                                      // SourceGet will return the RSISource enum name of the first status bit that is active. (Ex: RSISourceAMP_FAULT)
                    PrintState(state);
                    PrintSource(axis, source);
                    break;

                default:
                    Console.WriteLine("");
                    break;
                }

                // or USE STATUS BIT GET

                bool isAmpFault_Active          = axis.StatusBitGet(RSIEventType.RSIEventTypeAMP_FAULT);   // StatusBitGet returns the state of a status bit, true or false.
                bool isPositionErrorLimitActive = axis.StatusBitGet(RSIEventType.RSIEventTypeLIMIT_ERROR);
                bool isHWNegativeLimitActive    = axis.StatusBitGet(RSIEventType.RSIEventTypeLIMIT_HW_NEG);
                bool isHWPostiveLimitActive     = axis.StatusBitGet(RSIEventType.RSIEventTypeLIMIT_HW_POS); // This can be done for all RSIEventTypes

                Console.WriteLine("\nPress Any Key To Exit");                                               // Allow time to read Console.
                Console.ReadKey();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);                                                                       // If there are any exceptions/issues this will be printed out.
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            // RapidCode objects
            MotionController controller;                                                                                        // Declare what 'controller' is.
            Axis             axis;                                                                                              // Declare what 'axis' is.


            // Constants
            const int AXIS_INDEX                = 0;                                                                                // This is the index of the axis you will use to command motion.
            const int USER_LIMIT                = 0;                                                                                // Specify which user limit to use.
            const int USER_LIMIT_COUNT          = 1;
            const int CONDITION                 = 0;                                                                                // Specify which condition to use. (0 or 1) ("0" to compare 1 input || "1" to compare 2 inputs)
            const RSIUserLimitLogic       LOGIC = RSIUserLimitLogic.RSIUserLimitLogicGT;                                            // Logic for input value comparison.
            const double                  POSITION_TRIGGER_VALUE = 250;                                                             // The value to be compared which needs to be set here.
            const RSIUserLimitTriggerType TRIGGER_TYPE           = RSIUserLimitTriggerType.RSIUserLimitTriggerTypeSINGLE_CONDITION; // Choose the how the condition (s) should be evaluated.
            const RSIAction               ACTION = RSIAction.RSIActionNONE;                                                         // Choose the action you want to cause when the User Limit triggers.
            const int    DURATION          = 0;                                                                                     // Enter the time delay before the action is executed after the User Limit has triggered.
            const double DEFAULT_FEED_RATE = 1.0;
            const double DESIRED_FEED_RATE = 2.0;


            // Other Global Variables
            ulong feedRateAddress;


            // Initialize RapidCode Objects
            controller = MotionController.CreateFromSoftware();                                                                 // 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.


            // Some Necessary Pre User Limit Configuration
            controller.UserLimitCountSet(USER_LIMIT_COUNT);                                                                     // Set the amount of UserLimits that you want to use.

            SampleAppsCS.HelperFunctions.StartTheNetwork(controller);                                                           // [Helper Function] Initialize the network.

            axis = controller.AxisGet(AXIS_INDEX);                                                                              // Initialize your axis object.
            SampleAppsCS.HelperFunctions.CheckErrors(axis);


            try
            {
                axis.FeedRateSet(DEFAULT_FEED_RATE);                                                                            // Restore FeedRate to default value.

                // USER LIMIT CONDITION
                controller.UserLimitConditionSet(USER_LIMIT, CONDITION, LOGIC, axis.AddressGet(RSIAxisAddressType.RSIAxisAddressTypeACTUAL_POSITION), POSITION_TRIGGER_VALUE);              // Set your User Limit Condition (1st step to setting up your user limit)

                // USER LIMIT CONFIGURATION
                controller.UserLimitConfigSet(USER_LIMIT, TRIGGER_TYPE, ACTION, axis.NumberGet(), DURATION);                    // Set your User Limit Configuration. (2nd step to setting up your user limit)

                // USER LIMIT OUTPUT
                feedRateAddress = axis.AddressGet(RSIAxisAddressType.RSIAxisAddressTypeTARGET_FEEDRATE);
                controller.UserLimitOutputSet(USER_LIMIT, DESIRED_FEED_RATE, feedRateAddress, true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
예제 #3
0
        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.

                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();
        }
예제 #4
0
        static void Main(string[] args)
        {
            // Constants
            const int    AXIS_NUMBER          = 0;      // Specify which axis/motor we will be controlling.
            const bool   ACTIVE_HIGH          = true;   // Constant for active high.
            const bool   ACTIVE_LOW           = false;  // Constant for active low.
            const double HW_POS_DURATION_TIME = 0.01;   // Positive limit duration. (in seconds)
            const double HW_NEG_DURATION_TIME = 0.01;   // Negative limit duration. (in seconds)

            // 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.
            //controller.AxisCountSet(1);                                                           // Uncomment if using Phantom Axes.
            Axis axis = controller.AxisGet(AXIS_NUMBER);                                             // Initialize Axis Class. (Use RapidSetup Tool to see what is your axis number)

            SampleAppsCS.HelperFunctions.CheckErrors(axis);                                          // [Helper Function] Check that the axis has been initialize correctly.

            try
            {
                Console.WriteLine("Hardware Limits Example\n");

                // Change Hardware POSITIVE (+) Limit characteristics.
                axis.HardwarePosLimitActionSet(RSIAction.RSIActionE_STOP);                              // Set the positive limit action to E_STOP.
                Console.WriteLine("\nHardware Positive Limit Action set to " + axis.HardwarePosLimitActionGet());

                axis.HardwarePosLimitTriggerStateSet(ACTIVE_HIGH);                                      // Set the positive limit trigger state to ACTIVE_HIGH.
                Console.WriteLine("\nHardware Positive Limit TriggerState set to " + axis.HardwarePosLimitTriggerStateGet());

                axis.HardwarePosLimitDurationSet(HW_POS_DURATION_TIME);                                 // Set the positive limit duration to 0.01 seconds.
                Console.WriteLine("\nHardware Positive Limit Duration set to " + axis.HardwarePosLimitDurationGet() + " seconds");

                // Change Hardware NEGATIVE (-) Limit charateristics.
                axis.HardwareNegLimitActionSet(RSIAction.RSIActionE_STOP);                              // Set the negative limit action to E_STOP.
                Console.WriteLine("\nHardware Negative Limit Action set to " + axis.HardwareNegLimitActionGet());

                axis.HardwareNegLimitTriggerStateSet(ACTIVE_LOW);                                       // Set the negative limit trigger state to ACTIVE_LOW.
                Console.WriteLine("\nHardware Negative Limit TriggerState set to " + axis.HardwareNegLimitTriggerStateGet());

                axis.HardwareNegLimitDurationSet(HW_NEG_DURATION_TIME);                                 // Set the negative limit duration to 0.01 seconds.
                Console.WriteLine("\nHardware Negative Limit Duration set to " + axis.HardwareNegLimitDurationGet() + " seconds\n");

                Console.WriteLine("\nAll Hardware Limit characteristics set\n");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.WriteLine("\nPress Any Key To Exit");                                               // Allow time to read Console.
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            // constants
            const int AXIS_NUMBER  = 0;         // Specify which axis/motor to control.
            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)
            const int VELOCITY     = 1;         // Specify your velocity.       -   units: Units/Sec    (it will do 1048576 counts/1 revolution every 1 second.)
            const int ACCELERATION = 10;        // Specify your acceleration.   -   units: Units/Sec^2
            const int DECELERATION = 10;        // Specify your deceleration.   -   units: Units/Sec^2

            // 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.
            //controller.AxisCountSet(1);                                                           // Uncomment if using Phantom Axes.
            Axis axis = controller.AxisGet(AXIS_NUMBER);                                             // Initialize Axis Class. (Use RapidSetup Tool to see what is your axis number)

            SampleAppsCS.HelperFunctions.CheckErrors(axis);                                          // [Helper Function] Check that the axis has been initialize correctly.

            try
            {
                axis.UserUnitsSet(USER_UNITS);                                                      // Specify the counts per Unit.

                axis.Abort();                                                                       // If there is any motion happening, abort it.
                axis.ClearFaults();                                                                 // Clear faults.
                axis.AmpEnableSet(true);                                                            // Enable the motor.
                axis.HardwareNegLimitActionSet(RSIAction.RSIActionSTOP);                            // Neg Limit action set to STOP.
                axis.HomeMethodSet(RSIHomeMethod.RSIHomeMethodNEGATIVE_LIMIT);                      // Set the method to be used for homing.
                axis.HomeVelocitySet(VELOCITY);                                                     // Set the home velocity.
                axis.HomeSlowVelocitySet(VELOCITY / 10);                                            // Set the slow home velocity. (used for final move, if necessary)
                axis.HomeAccelerationSet(ACCELERATION);                                             // Set the acceleration used for homing.
                axis.HomeDecelerationSet(DECELERATION);                                             // Set the deceleration used for homing.
                axis.HomeOffsetSet(0.5);                                                            // HomeOffsetSet sets the position offset from the home (zero) position.

                axis.Home();                                                                        // Execute the homing routine.

                if (axis.HomeStateGet() == true)                                                    // HomeStateGet returns true if the Axis is homed.
                {
                    Console.WriteLine("Homing successful\n");
                }

                axis.ClearFaults();                                                                 // Clear faults created by homing.
                axis.AmpEnableSet(false);                                                           // Disable the motor.
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.WriteLine("\nPress Any Key To Exit");                                         // Allow time to read Console.
            Console.ReadKey();
        }
예제 #6
0
        static void Main(string[] args)
        {
            // Constants
            const int AXIS_NUMBER  = 0;        // Specify which axis/motor to control.
            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)
            const int POSITION     = 10;       // Specify the position to travel to.
            const int VELOCITY     = 1;        // Specify your velocity.       -   units: Units/Sec    (it will do 1048576 counts/1 revolution every 1 second.)
            const int ACCELERATION = 10;       // Specify your acceleration.   -   units: Units/Sec^2
            const int DECELERATION = 10;       // Specify your deceleration.   -   units: Units/Sec^2

            // 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.
            //controller.AxisCountSet(1);                                                           // Uncomment if using Phantom Axes.
            Axis axis = controller.AxisGet(AXIS_NUMBER);                                             // Initialize Axis Class. (Use RapidSetup Tool to see what is your axis number)

            SampleAppsCS.HelperFunctions.CheckErrors(axis);                                          // [Helper Function] Check that the axis has been initialize correctly.

            try
            {
                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.ErrorLimitTriggerValueSet(1);                                                  // Set the position error trigger value
                axis.Abort();                                                                       // If there is any motion happening, abort it.
                axis.ClearFaults();                                                                 // Clear faults.
                axis.AmpEnableSet(true);                                                            // Enable the motor.

                Console.WriteLine("Absolute Move\n\n");
                Console.WriteLine("Trapezoidal Profile: In Motion...\n");

                //axis.ErrorLimitActionSet(RSIAction.RSIActionNONE);                                // Uncomment when using Phantom Axes.

                axis.MoveTrapezoidal(POSITION, VELOCITY, ACCELERATION, DECELERATION);               // Command simple trapezoidal motion.
                axis.MotionDoneWait();                                                              // Wait for motion to be done.

                Console.WriteLine("Trapezoidal Profile: Completed\n\n");                            // If motion is completed this will be printed out.

                axis.AmpEnableSet(false);                                                           // Disable the motor.

                Console.WriteLine("\nTest Complete\n");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);                                                     // If there are any exceptions/issues this will be printed out.
            }
            Console.WriteLine("\nPress Any Key To Exit");                                         // Allow time to read Console.
            Console.ReadKey();
        }
예제 #7
0
        // Main
        static void Main(string[] args)
        {
            // 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 initialized correctly.

            SampleAppsCS.HelperFunctions.StartTheNetwork(controller);                                // [Helper Function] Initialize the network.
            Axis axis = controller.AxisGet(0);

            CaptureEachIndexPulseDuringMotion(controller);

            CapturePositionOnFallingEdgeOfSI6(controller, axis);
        }
예제 #8
0
        static void Main(string[] args)
        {
            // Constants
            const int AXIS_NUMBER = 0;                                                  // Specify the axis that will be used.

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

            Axis axis = controller.AxisGet(AXIS_NUMBER);                                             // Initialize axis. (Use RapidSetup Tool to see what is your axis number)

            SampleAppsCS.HelperFunctions.CheckErrors(axis);                                          // [Helper Function] Check that the axis has been initialize correctly.

            Console.WriteLine("Axis {0}:\n", AXIS_NUMBER);
            Console.WriteLine("Dedicated Inputs:");

            try
            {
                // Retrieve dedicated inputs with generic and specific function.
                Console.WriteLine("RSIMotorDedicatedInLIMIT_HW_NEG: {0} and {1}",
                                  axis.DedicatedInGet(RSIMotorDedicatedIn.RSIMotorDedicatedInLIMIT_HW_NEG),
                                  axis.NegativeLimitGet());

                Console.WriteLine("RSIMotorDedicatedInLIMIT_HW_POS: {0} and {1}",
                                  axis.DedicatedInGet(RSIMotorDedicatedIn.RSIMotorDedicatedInLIMIT_HW_POS),
                                  axis.PositiveLimitGet());

                Console.WriteLine("RSIMotorDedicatedInHOME: {0} and {1}",
                                  axis.DedicatedInGet(RSIMotorDedicatedIn.RSIMotorDedicatedInHOME),
                                  axis.HomeSwitchGet());

                Console.WriteLine("RSIMotorDedicatedInAMP_FAULT: {0} and {1}",
                                  axis.DedicatedInGet(RSIMotorDedicatedIn.RSIMotorDedicatedInAMP_FAULT),
                                  axis.AmpFaultGet());

                Console.WriteLine("RSIMotorDedicatedInAMP_ACTIVE: {0} and {1}",
                                  axis.DedicatedInGet(RSIMotorDedicatedIn.RSIMotorDedicatedInAMP_ACTIVE),
                                  axis.AmpEnableGet());
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);                                                     // If there are any exceptions/issues this will be printed out.
            }
            Console.WriteLine("\nPress Any Key To Exit");                                         // Allow time to read Console.
            Console.ReadKey();
        }
예제 #9
0
        static void Main(string[] args)
        {
            // Constants
            const int AXIS_NUMBER       = 0;        // Specify which axis/motor to control
            const int RELATIVE_POSITION = 100;      // Specify the position to travel to.
            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)
            const int VELOCITY          = 10;       // Specify your velocity.       -   units: Units/Sec    (it will do "1048576 counts / 1 motor revolution" per second)
            const int ACCELERATION      = 10;       // Specify your acceleration.   -   units: Units/Sec^2
            const int DECELERATION      = 10;       // Specify your deceleration.   -   units: Units/Sec^2
            const int JERK_PCT          = 50;       // Specify your jerk percent (0.0 to 100.0)

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

            Axis axis = controller.AxisGet(AXIS_NUMBER);                                             // Initialize axis. (Use RapidSetup Tool to see what is your axis number)

            SampleAppsCS.HelperFunctions.CheckErrors(axis);                                          // [Helper Function] Check that the axis has been initialize correctly.

            try
            {
                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.Abort();                                                                       // If there is any motion happening, abort it.
                axis.ClearFaults();                                                                 // Clear faults.
                axis.AmpEnableSet(true);                                                            // Enable the motor.

                Console.WriteLine("SCurve Motion Example\n");
                Console.WriteLine("SCurve Profile: In Motion...\n");

                axis.MoveSCurve(RELATIVE_POSITION, VELOCITY, ACCELERATION, DECELERATION, JERK_PCT); // Command SCurve Motion
                axis.MotionDoneWait();                                                              // Wait for motion to finish

                Console.WriteLine("SCurve Profile: Completed\n");

                axis.AmpEnableSet(false);                                                           // Disable the motor
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);                                                       // If there are any exceptions/issues this will be printed out.
            }
            Console.WriteLine("\nPress Any Key To Exit");                                           // Allow time to read Console.
            Console.ReadKey();
        }
예제 #10
0
        static void Main(string[] args)
        {
            // Constants
            const int AXIS_NUMBER = 0;                                                               // Specify which axis/motor to control.

            int points     = 3;                                                                      // Specify the total number of streamed points. (Very Important!)
            int emptyCount = -1;                                                                     // E-stop generated if there aren't at least this many points loaded. ("-1" if you don't wish to trigger an E-Stop)

            double[] positions     = { 4.0, 8.0, 16.0 };                                             // Specify the positions that you want to reach. (it can be n number)
            double[] velocities    = { 1.0, 2.0, 4.0 };                                              // Specify the velocities that you want to use to reach your position.
            double[] accelerations = { 1, 1, 1 };                                                    // Specify the accelerations that you want to use to reach your position.
            double[] jerks         = { 50, 50, 50 };                                                 // Specify the jerk that you want to use in each move.
            double[] times         = { 4.0, 2, 1 };                                                  // Specify the times in which you want to reach each position. (velocity and acceleration is calculated by the RMP)
// 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 initialized correctly.

            SampleAppsCS.HelperFunctions.StartTheNetwork(controller);                                // [Helper Function] Initialize the network.

            Axis axis = controller.AxisGet(AXIS_NUMBER);                                             // Initialize the axis.

            SampleAppsCS.HelperFunctions.CheckErrors(axis);                                          // [Helper Function] Check that the axis has been initialized correctly.

            try
            {
                axis.Abort();
                axis.ClearFaults();
                axis.AmpEnableSet(true);
                axis.PositionSet(0);
                axis.UserUnitsSet(1048576);

                axis.MovePVAJT(positions,                                                       // Specify the type of PT Motion that you want to perform. (RSIMotionType.RSIMotionTypePT, RSIMotionType.RSIMotionTypeBSPLINE, RSIMotionType.RSIMotionTypeBSPLINE2)
                               velocities,                                                      // Specify the positions that you want to reach. (it can be n number)
                               accelerations,                                                   // Specify the accelerations that you want to use during every move.
                               jerks,                                                           // Specify the jerk that you want to use during every move.
                               times,                                                           // Specify the times in which you want to reach each position. (velocity and acceleration is calculated by the RMP)
                               points,                                                          // Specify the total number of streamed points.
                               emptyCount,                                                      // E-stop generated if there are this number or fewer frames loaded. Use the value “0” to trigger an E-stop when the buffer is empty, or “-1” to not trigger an E-stop. (Typically for PT motion there are two frames per PT point)
                               false,                                                           // Specify whether points are kept, or are not kept.
                               true);                                                           // Specify if this is the last MovePT. (If True, this is the final point. If False, more points expected.)

                axis.MotionDoneWait();                                                          // Wait for motion to be completed.
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);                                                   // If there are any exceptions/issues this will be printed out.
            }
        }
예제 #11
0
        static void Main(string[] args)
        {
            // Constants
            const int AXIS_NUMBER = 0;            // Specify which axis/motor to control.
            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) ("user unit = 1" means it will do one count out of the 1048576)

            // Other Variables
            double currentUserUnits;

            // 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);                                    // Check that the controller has been initialized correctly.

            SampleAppsCS.HelperFunctions.StartTheNetwork(controller);                                // [Helper Function] Initialize the network.

            Axis axis = controller.AxisGet(AXIS_NUMBER);                                             // Initialize Axis Class.

            SampleAppsCS.HelperFunctions.CheckErrors(axis);                                          // [Helper Function] Check that the axis has been initialize correctly.

            try
            {
                axis.UserUnitsSet(1);                                                  // SET YOUR USER UNITS!
                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.

                currentUserUnits = axis.UserUnitsGet();                                // Verify that your user units were changed!

                Console.WriteLine("The axis current user unit is: {0}", currentUserUnits);


                axis.UserUnitsSet(USER_UNITS);                                                  // SET YOUR USER UNITS!
                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.

                currentUserUnits = axis.UserUnitsGet();                                         // Verify that your user units were changed!

                Console.WriteLine("The axis current user unit is: {0}", currentUserUnits);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);                                                   // If there are any exceptions/issues this will be printed out.
            }
            Console.WriteLine("\nPress Any Key To Exit");                                       // Allow time to read Console.
            Console.ReadKey();
        }
예제 #12
0
        static void Main(string[] args)
        {
            // RapidCode Objects
            MotionController controller;                                                    // Declare what controller is.

            // Initialize RapidCode Objects
            controller = MotionController.CreateFromSoftware(/*@"C:\RSI\X.X.X\"*/);         // If your project is not on the RapidSetup folder, 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. (Function logic at the bottom of source code)


            try
            {
                // Get Input Values

                int inputCount = controller.NetworkInputCountGet();                         // Get number of Network Inputs (PDOs)

                for (int i = 0; i < inputCount; i++)
                {
                    int    size   = controller.NetworkInputBitSizeGet(i);                   // Read Input BitSize
                    int    offset = controller.NetworkInputBitOffsetGet(i);                 // Read Input BitOffset
                    string name   = controller.NetworkInputNameGet(i);                      // Read Input Name
                    UInt64 value  = controller.NetworkInputValueGet(i);                     // Read Input Value
                }


                // Get Output Values

                int outputCount = controller.NetworkOutputCountGet();                       // Get number of Network Outputs (SDOs)

                for (int i = 0; i < outputCount; i++)
                {
                    int    size   = controller.NetworkOutputBitSizeGet(i);                  // Read Output BitSize
                    int    offset = controller.NetworkOutputBitOffsetGet(i);                // Read Output BitOffset
                    string name   = controller.NetworkOutputNameGet(i);                     // Read Output Name
                    UInt64 value  = controller.NetworkOutputSentValueGet(i);                // Read Output Value
                    controller.NetworkOutputOverrideValueSet(i, value);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);                                                                       // If there are any exceptions/issues this will be printed out.
            }
        }
예제 #13
0
        static void Main(string[] args)
        {
            // Constants
            const int AXIS_NUMBER               = 0;     // Specify which axis/motor to control.
            const int POSITION_TOLERANCE_FINE   = 200;   // Specify the fine position tolerance.
            const int POSITION_TOLERANCE_COARSE = 300;   // Specify the coarse position tolerance.
            const int VELOCITY_TOLERANCE        = 12000; // Specify the velocity tolerance.
            const int SETTLING_TIME             = 5;     // Specify the settling time.

            // 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 initialized correctly.

            SampleAppsCS.HelperFunctions.StartTheNetwork(controller);                                // [Helper Function] Initialize the network.

            Axis axis = controller.AxisGet(AXIS_NUMBER);                                             // Initialize the axis.

            SampleAppsCS.HelperFunctions.CheckErrors(axis);                                          // [Helper Function] Check that the axis has been initialized correctly.

            try
            {
                Console.WriteLine("Settling Criteria Example\n");
                Console.WriteLine("\nOld Criteria\n");

                PrintParameters(axis);                                                              // Print current axis settling parameters.

                axis.PositionToleranceFineSet(POSITION_TOLERANCE_FINE);                             // Set fine position tolerance.
                axis.PositionToleranceCoarseSet(POSITION_TOLERANCE_COARSE);                         // Set coarse position tolerance.
                axis.VelocityToleranceSet(VELOCITY_TOLERANCE);                                      // Set velocity tolerance.
                axis.SettlingTimeSet(SETTLING_TIME);                                                // Set settling time.

                Console.WriteLine("\nNew Criteria\n");

                PrintParameters(axis);                                                              // Print current axis settling parameters.

                Console.WriteLine("\nPress Any Key To Exit");                                       // Allow time to read Console.
                Console.ReadKey();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);                                                       // If there are any exceptions/issues this will be printed out.
            }
        }
예제 #14
0
        static void Main(string[] args)
        {
            // Constants
            const int AXIS_NUMBER = 0;                   // Specify which axis/motor to control.
            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)

            int points     = 3;                          // Specify the total number of streamed points.
            int emptyCount = -1;                         // E-stop generated if there are this number or fewer frames loaded. Use the value “0” to trigger an E-stop when the buffer is empty, or “-1” to not trigger an E-stop. (Typically for PT motion there are two frames per PT point)

            double[] positions = { 2.0, 5.0, 0.0 };      // Specify the positions that you want to reach. (it can be n number)
            double[] times     = { 2.0, 3.0, 1.0 };      // Specify the times in which you want to reach each position. (velocity and acceleration is calculated by the RMP)

            // 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 initialized correctly.

            SampleAppsCS.HelperFunctions.StartTheNetwork(controller);                                 // [Helper Function] Initialize the network.

            Axis axis = controller.AxisGet(AXIS_NUMBER);                                              // Initialize the axis.

            SampleAppsCS.HelperFunctions.CheckErrors(axis);                                           // [Helper Function] Check that the axis has been initialized correctly.

            axis.Abort();
            axis.ClearFaults();
            axis.AmpEnableSet(true);
            axis.PositionSet(0);
            axis.UserUnitsSet(USER_UNITS);

            axis.MovePT(RSIMotionType.RSIMotionTypePT,                                      // Specify the type of PT Motion that you want to perform. (RSIMotionType.RSIMotionTypePT, RSIMotionType.RSIMotionTypeBSPLINE, RSIMotionType.RSIMotionTypeBSPLINE2)
                        positions,                                                          // Specify the positions that you want to reach. (it can be n number)
                        times,                                                              // Specify the times in which you want to reach each position. (velocity and acceleration is calculated by the RMP)
                        points,                                                             // Specify the total number of streamed points.
                        emptyCount,                                                         // E-stop generated if there are this number or fewer frames loaded. Use the value “0” to trigger an E-stop when the buffer is empty, or “-1” to not trigger an E-stop. (Typically for PT motion there are two frames per PT point)
                        false,                                                              // Specify whether points are kept, or are not kept.
                        true);                                                              // Specify if this is the last MovePT. (If True, this is the final point. If False, more points expected.)

            axis.MotionDoneWait();                                                          // Wait for motion to be completed.
        }
예제 #15
0
        static void Main(string[] args)
        {
            // Constants
            const int    AXIS_NUMBER             = 0;       // Specify which axis/motor to control.
            const double STOP_RATE_DEFAULT       = 1.0;     // Specify the default STOP rate in seconds.
            const double ESTOP_RATE_DEFAULT      = 0.05;    // Specify the default ESTOP rate in seconds.
            const double ESTOP_DECELERATION_RATE = 1000;    // Specify the default ESTOP deceleration rate in seconds.


            // 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] Verify the controller has started correctly.

            SampleAppsCS.HelperFunctions.StartTheNetwork(controller);                                // [Helper Function] Initialize the network.            //controller.AxisCountSet(1);                                                           // Uncomment if using Phantom Axes.
            Axis axis = controller.AxisGet(AXIS_NUMBER);                                             // Initialize Axis Class. (Use RapidSetup Tool to see what is your axis number)

            SampleAppsCS.HelperFunctions.CheckErrors(axis);                                          // [Helper Function] Check that the axis has been initialize correctly.

            try
            {
                Console.WriteLine("OLD: StopRate = " + Math.Round(axis.StopTimeGet(), 4) + "\t\teStopRate = " + Math.Round(axis.EStopTimeGet(), 4) + "\n" + "\t\tDecelRate = " + Math.Round(axis.EStopDecelerationGet(), 4) + "\n");

                axis.StopTimeSet(STOP_RATE_DEFAULT);                                                // Set the default STOP time to STOP_RATE_DEFAULT secs.
                axis.EStopTimeSet(ESTOP_RATE_DEFAULT);                                              // Set the default ESTOP time to ESTOP_RATE_DEFAULT secs.
                axis.EStopDecelerationSet(ESTOP_DECELERATION_RATE);                                 // Set the default ESTOP time to ESTOP_DECELERATION_RATE secs.

                Console.WriteLine("NEW: StopRate = " + Math.Round(axis.StopTimeGet(), 4) + "\t\teStopRate = " + Math.Round(axis.EStopTimeGet(), 4) + "\n" + "\t\tDecelRate = " + Math.Round(axis.EStopDecelerationGet(), 4) + "\n");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.WriteLine("\nPress Any Key To Exit");                                         // Allow time to read Console.
            Console.ReadKey();
        }
예제 #16
0
        static void Main(string[] args)
        {
            try
            {
                // Constants
                const int AXIS_NUMBER = 2;                  // Specify which axis/motor to control.

                // 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.
                Axis axis = controller.AxisGet(AXIS_NUMBER);

                PrintErrors(controller);

                SampleAppsCS.HelperFunctions.StartTheNetwork(controller);                               // [Helper Function] Initialize the network. (Function logic at the bottom of source code)Axis axis = controller.AxisGet(AXIS_NUMBER);                                                 // Initialize Axis Class. (Use RapidSetup Tool to see what is your axis number)
                SampleAppsCS.HelperFunctions.CheckErrors(axis);                                         // [Helper Function] Check that the axis has been initialize correctly.
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);                                                       // If there are any exceptions/issues this will be printed out.
            }
            Console.WriteLine("\n\nPress Any Key To Exit");                                         // Allow time to read Console.
            Console.ReadKey();
        }
예제 #17
0
        static void Main(string[] args)
        {
            // RapidCode objects
            MotionController controller;                                                                                            // Declare what 'controller' is.
            Axis             axis;                                                                                                  // Declare what 'axis' is.

            // Constants
            const int INPUT_INDEX         = 10;                                                                                     // This is the index of the digital input you will use to trigger the user limit.
            const int AXIS_INDEX          = 0;                                                                                      // This is the index of the axis you will use to command motion.
            const int AXIS_COUNT          = 1;                                                                                      // Axes on the network.
            const int USER_UNITS          = 1048576;                                                                                // Specify your motor's count per units.
            const int USER_LIMIT          = 1;                                                                                      // Specify which user limit to use.
            const int CONDITION           = 0;                                                                                      // Specify which condition to use. (0 or 1) ("0" to compare 1 input || "1" to compare 2 inputs)
            const RSIUserLimitLogic LOGIC = RSIUserLimitLogic.RSIUserLimitLogicEQ;                                                  // Logic for input value comparison.
            const int INPUT_MASK          = 1;                                                                                      // Decide the bits in an address which need to be used when comparing. Use 0xFFFFFFFF when a long or float comparison is desired.
            const int LIMIT_VALUE         = 1;                                                                                      // The value to be compared which needs to be set here.
            const RSIUserLimitTriggerType TRIGGER_TYPE = RSIUserLimitTriggerType.RSIUserLimitTriggerTypeSINGLE_CONDITION;           // Choose the how the condition (s) should be evaluated.
            const RSIAction ACTION          = RSIAction.RSIActionE_STOP_ABORT;                                                      // Choose the action you want to cause when the User Limit triggers.
            const int       DURATION        = 0;                                                                                    // Enter the time delay before the action is executed after the User Limit has triggered.
            const int       USER_DATA_INDEX = 0;

            // Other Global Variables
            ulong inputAddress;

            // Initialize RapidCode Objects
            controller = MotionController.CreateFromSoftware();                                                                     // 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.

            // Some Necessary Pre User Limit Configuration
            controller.UserLimitCountSet(1);                                                                                        // Set the amount of UserLimits that you want to use.
            controller.InterruptEnableSet(true);                                                                                    // Enable User Limit Interrupts. (When a user limit input comparison is met, and interrupt is triggered)

            SampleAppsCS.HelperFunctions.StartTheNetwork(controller);                                                               // [Helper Function] Initialize the network.

            axis = controller.AxisGet(AXIS_INDEX);                                                                                  // Initialize your axis object.
            SampleAppsCS.HelperFunctions.CheckErrors(axis);                                                                         // [Helper Function] Check that the axis has been initialize correctly.

            try
            {
                // GET AXIS READY & MOVING
                axis.UserUnitsSet(USER_UNITS);                                                                                      // Specify the counts per unit. (every 1048576 counts my motor does one full turn) (varies per motor)
                axis.ErrorLimitTriggerValueSet(1);                                                                                  // Specify the position error limit trigger value. (learn more about this on our support page)
                axis.PositionSet(0);                                                                                                // Ensure the motor starts at position 0 every time.
                axis.Abort();                                                                                                       // If there is any motion happening, abort it.
                axis.ClearFaults();                                                                                                 // Clear any faults.
                axis.AmpEnableSet(true);                                                                                            // Enable the axis.
                axis.MoveVelocity(1.0, 10.0);                                                                                       // Command a velocity move (Velocity=1.0, Acceleration=10.0).


                // USER LIMIT CONDITION
                inputAddress = controller.NetworkInputAddressGet(INPUT_INDEX);                                                      // 10 was the index of my 1st input. (To check your IO indexes go to RapidSetup -.


                controller.UserLimitConditionSet(USER_LIMIT, CONDITION, LOGIC, inputAddress, INPUT_MASK, LIMIT_VALUE);              // Set your User Limit Condition (1st step to setting up your user limit)


                // USER LIMIT CONFIGURATION
                controller.UserLimitConfigSet(USER_LIMIT, TRIGGER_TYPE, ACTION, AXIS_INDEX, DURATION);                              // Set your User Limit Configuration. (2nd step to setting up your user limit)


                // USER LIMIT USER DATA SET
                controller.UserLimitInterruptUserDataAddressSet(USER_LIMIT,                                                                         // Specify the user limit you want to add User Data for.
                                                                USER_DATA_INDEX,                                                                    // Specify what user data index you would like to use. (must be a value from 0 to 4)
                                                                axis.AddressGet(RSIAxisAddressType.RSIAxisAddressTypeCOMMAND_POSITION));            // Specify the address of the data value you want to store in your User Data so that you can retrieve it later after the UserLimit limit triggers.


                // WAIT FOR DIGITAL INPUT TO TRIGGER USER LIMIT EVENT.
                Console.WriteLine("Waiting for the input bit to go high...\n");
                while (controller.InterruptWait((int)RSIWait.RSIWaitFOREVER) != RSIEventType.RSIEventTypeUSER_LIMIT)                                // Wait until your user limit triggers.
                {
                }

                int    triggeredUserLimit = controller.InterruptSourceNumberGet() - AXIS_COUNT;                                                     // Check that the correct user limit has triggered. (an extra user limit is allocated for each axis)
                UInt64 data = controller.InterruptUserDataGet(USER_DATA_INDEX);                                                                     // Get the data stored in the user data you configured.
                double interruptPosition = BitConverter.ToDouble(BitConverter.GetBytes(data), 0);                                                   // Convert from raw 64-bit memory bytes into 64-bit double.

                Console.WriteLine("Input bit went HIGH and User Limit {0} triggered!", triggeredUserLimit);                                         // Get the index of the user limit that triggered.
                Console.WriteLine("User Limit Interrupt Position = " + interruptPosition / USER_UNITS);                                             // Get the position of the axis when it user limit event triggered.
                Console.WriteLine("\nDoes InterruptSourceNumberGet() - AxisCountGet() == userLimit: " + triggeredUserLimit.Equals(USER_LIMIT));

                controller.UserLimitDisable(USER_LIMIT);                                                                                             // Disable User Limit.
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
예제 #18
0
        static void Main(string[] args)
        {
            // Constants
            const int AXIS_NUMBER = 0;                 // Specify which axis/motor to control.

            const int modeOfOpIndex          = 0x6060; // Mode of Operation (DS402 Standard)
            const int modeOfOpSubindex       = 0x0;    // Subindex
            const int modeOfOpByteSize       = 1;      // INTEGER8 (1 byte)
            const int modeOfOpValueToHOME    = 6;      // Hex value to determine Mode (6 = Homing mode)
            const int modeOfOpValueToDEFAULT = 8;      // Hex value to determine Mode (8 = Cyclic synchronous position mode)

            // 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.
            //controller.AxisCountSet(1);                                                           // Uncomment if using Phantom Axes.
            Axis axis = controller.AxisGet(AXIS_NUMBER);                                             // Initialize Axis Class. (Use RapidSetup Tool to see what is your axis number)

            SampleAppsCS.HelperFunctions.CheckErrors(axis);                                          // [Helper Function] Check that the axis has been initialize correctly.

            try
            {
                axis.ErrorLimitActionSet(RSIAction.RSIActionNONE);                                // Position Error must be disabled for drive based homing.

                // 1. READY DRIVE
                axis.NetworkNode.ServiceChannelWrite(modeOfOpIndex, modeOfOpSubindex, modeOfOpByteSize, modeOfOpValueToHOME);               // Mode of Operation (Homing Mode = 6)
                axis.NetworkNode.AKDASCIICommand("DRV.OPMODE 2");                                                                           // Sets the drive operation mode (0 - current | 1 = velocity | 2 = position).
                axis.NetworkNode.AKDASCIICommand("HOME.AUTOMOVE 0");                                                                        // 0 = Disabled | 1 = Homing starts when drive is enabled.

                // Make sure you know your motor's position, velocity, and acceleration units before you send any values.

                // 2. SET YOUR LIMIT SWITCHES
                axis.NetworkNode.AKDASCIICommand("DIN5.MODE 18");                               // Sets the digital input modes.                        - DI5 is now our Positive Limit Switch.
                axis.NetworkNode.AKDASCIICommand("DIN5.INV 1");                                 // Sets the indicated polarity of a digital input mode. - DI5 is now active when Low.
                axis.NetworkNode.AKDASCIICommand("DIN6.MODE 19");                               // Sets the digital input modes.                        - DI6 is now our Negative Limit Switch.
                axis.NetworkNode.AKDASCIICommand("DIN6.INV 1");                                 // Sets the indicated polarity of a digital input mode. - DI6 is now active when Low.

                // 3. CONFIGURE DRIVE HOMING PARAMETERS
                axis.NetworkNode.AKDASCIICommand("HOME.MODE 1");                                // Selects the homing method; active in opmode 2 (position) only. MODE1 = Find limit input
                axis.NetworkNode.AKDASCIICommand("HOME.V 20");                                  // Sets homing velocity; active in opmode 2 (position) only.
                axis.NetworkNode.AKDASCIICommand("HOME.ACC 200");                               // Sets homing acceleration; active in opmode 2 (position) only.
                axis.NetworkNode.AKDASCIICommand("HOME.DEC 200");                               // Sets homing deceleration; active in opmode 2 (position) only.
                axis.NetworkNode.AKDASCIICommand("HOME.DIR 0");                                 // Sets homing direction; active in opmode 2 (position) only. (0 = negative | 1 = positive)
                axis.NetworkNode.AKDASCIICommand("HOME.P 0");                                   // Sets home position; active in opmode 2 (position) only.
                axis.NetworkNode.AKDASCIICommand("HOME.DIST 0");                                // Sets homing distance; active in opmode 2 (position) only.
                axis.NetworkNode.AKDASCIICommand("HOME.MAXDIST 0");                             // Sets the maximum distance the motor is allowed to move during the homing routine. (Disabled when value = 0)
                axis.NetworkNode.AKDASCIICommand("HOME.IPEAK");                                 // Sets the current limit during homing procedure to a mechanical stop; active in opmode 2 (position) only.

                // 4. READY AXIS
                axis.Abort();                                                                   // Disable axis.
                axis.ClearFaults();                                                             // Clear any faults.
                axis.AmpEnableSet(true);                                                        // Enable the axis.
                System.Threading.Thread.Sleep(1000);                                            // Allow time for amp enable

                // 5. START HOMING
                axis.NetworkNode.AKDASCIICommand("HOME.MOVE");                                  // Starts a homing procedure; active in opmode 2 (position) only.
                Console.WriteLine("HOME.MOVE");

                // 6. CHECK IF HOMING IS DONE
                UInt16 statusWordValue;
                int    isHomedvalue = 0;

                while (isHomedvalue != 1)                                                       // When isHomedValue = 1, homing has finished.
                {
                    statusWordValue = axis.NetworkNode.StatusWordGet(0);                        // Get the status word value (index 0x6060).
                    isHomedvalue    = statusWordValue >> 12;                                    // Get the 12th bit only. This bit tells us homing is done when it goes HIGH.
                }

                Console.WriteLine("Axis homed.");

                // 7. CLEAN UP
                axis.Abort();                                                                                                               // Disable the axis.
                axis.NetworkNode.ServiceChannelWrite(modeOfOpIndex, modeOfOpSubindex, modeOfOpByteSize, modeOfOpValueToDEFAULT);            // Mode of Operation (Homing Mode = 6)
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.WriteLine("\nPress Any Key To Exit");                                         // Allow time to read Console.
            Console.ReadKey();
        }
예제 #19
0
        static void Main(string[] args)
        {
            // Constants
            const int AXIS_NUMBER    = 0;        // Specify which axis/motor to control.
            const int POSITION       = 5;        // Specify the position to travel to.
            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)
            const int VELOCITY       = 1;        // Specify your velocity.       -   units: Units/Sec    (it will do 1048576 counts/1 revolution every 1 second.)
            const int ACCELERATION   = 10;       // Specify your acceleration.   -   units: Units/Sec^2
            const int DECELERATION   = 10;       // Specify your deceleration.   -   units: Units/Sec^2const int POSITION_INDEX = 0;                                               // This is the index of the input you will use to trigger the user limit.
            const int POSITION_INDEX = 0;        // This is the index of the axis actual position that will go active when the user limit triggers.
            const int OUTPUT_INDEX   = 0;        // This is the index of the digital output that will go active when the user limit triggers.
            const int NODE_INDEX     = 0;        // The EtherCAT Node we will be communicating with

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

            Axis axis = controller.AxisGet(AXIS_NUMBER);                                               // Initialize Axis Class. (Use RapidSetup Tool to see what is your axis number)

            SampleAppsCS.HelperFunctions.CheckErrors(axis);                                            // [Helper Function] Check that the axis has been initialize correctly.
            IOPoint output0 = IOPoint.CreateDigitalOutput(controller.IOGet(NODE_INDEX), OUTPUT_INDEX); // Create IOPoint object. Can be used to automatically get the address of a specified node and input index

            try
            {
                controller.UserLimitCountSet(2);                                                                    // Set the amount of UserLimits that you want to use. (every connected axis will automatically get 1 user limit)
                controller.InterruptEnableSet(true);                                                                // Enable User Limit Interrupts. (When a user limit input comparison is met, and interrupt is triggered)

                //-------- PARAMETERS FOR UserLimitConditionSet --------
                int userLimit                  = 1;                                                       // Specify which user limit to use.
                int condition                  = 0;                                                       // Specify which condition to use (0 or 1) ("0" to compare 1 input || "1" to compare 2 inputs)
                RSIUserLimitLogic logic        = RSIUserLimitLogic.RSIUserLimitLogicGE;                   // Logic for input value comparison. (Greater or equal)
                ulong             inputAddress = controller.NetworkInputAddressGet(POSITION_INDEX);       // 0 was the index of tha axis' Position Actual Value. (To check your IO indexes go to RapidSetup -.


                uint inputMask  = 0XFFFFFFFF;
                uint limitValue = (uint)controller.NetworkInputValueGet(POSITION_INDEX) + (1048576 * POSITION);     // Get the current encoder value, then add to it your axis encoder unit count times the number of revolutions you want your motor to do before stopping.

                // [1] Configure the input's trigger condition.
                controller.UserLimitConditionSet(userLimit,                                                      // (User Limit Index)   - Specify which user limit to use
                                                 condition,                                                      // (Condition Number)   - Specify how many inputs you want to compare.
                                                 logic,                                                          // (Comparison Logic)   - Specify the how the input value(s) will be compared
                                                 inputAddress,                                                   // (Input Address)      - Specify the address of the input that will be compared.
                                                 inputMask,                                                      // (Input Mask)         - Specify the bits in an address which need to be used when comparing inputs.
                                                 limitValue);                                                    // (Limit Value)        - Specify the value to be compared with.

                //-------- PARAMETERS FOR UserLimitConfigSet --------
                RSIUserLimitTriggerType triggerType = RSIUserLimitTriggerType.RSIUserLimitTriggerTypeSINGLE_CONDITION;
                RSIAction action   = RSIAction.RSIActionABORT;                                   // Abort move when user limit triggers.
                int       duration = 0;

                // [2] Configure and Enable the user limit.
                controller.UserLimitConfigSet(userLimit,                                                          // (User Limit Index)   - Specify which user limit to use.
                                              triggerType,                                                        // (Trigger Type)       - Specify how your condition should be evalutated.
                                              action,                                                             // (User Limit Action)  - Specify the action you want to cause on the axis when the user limit triggers.
                                              AXIS_NUMBER,                                                        // (Current Axis)       - Specify the axis that the action (defined above) will occur on.
                                              duration);                                                          // (Output Timer)       - Specify the time delay before the action is executed after the User Limit has triggered.

                //-------- PARAMETERS FOR UserLimitOutputSet --------
                uint  andMask       = (uint)output0.MaskGet();                       // Get the appropriate mask from your IOpoint. OR use 0x00010000 for AKD General IO, 1 for Beckhoff IO Terminals
                uint  orMask        = (uint)output0.MaskGet();;                      // Get the appropriate mask from your IOpoint. OR use 0x00010000 for AKD General IO, 1 for Beckhoff IO Terminals
                ulong outputAddress = output0.AddressGet();                          //Alternatively set manually using: controller.NetworkOutputAddressGet(OUTPUT_INDEX);
                bool  enableOutput  = true;

                // [3] Configure what the output will be.                                                          (Call this method after UserLimitConfigSet if you want an output to be triggered) (The output will only be triggered if the input conditions are TRUE.)
                controller.UserLimitOutputSet(userLimit,                                                            // (User Limit Index)   - Specify which user limit to use.
                                              andMask,                                                              // (Logic AND Mask)     - Specify the value that the digital output will be AND-ed with.
                                              orMask,                                                               // (Logic OR Mask)      - Specify the value that the digital output will be OR-ed with.
                                              outputAddress,                                                        // (Output Address)     - Specify the digital output address.
                                              enableOutput);                                                        // (Enable Output Set)  - If TRUE, the output AND-ing and OR-ing will be executed when the User Limit triggers.

                Console.WriteLine("Waiting for axis to reach specified position\n");

                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.Abort();                                                                                       // If there is any motion happening, abort it.
                axis.ClearFaults();                                                                                 // Clear faults.
                axis.AmpEnableSet(true);                                                                            // Enable the motor.

                axis.MoveTrapezoidal(POSITION, VELOCITY, ACCELERATION, DECELERATION);                               // Command simple trapezoidal motion.

                // Wait for user limit to trigger.
                while (controller.InterruptWait((int)RSIWait.RSIWaitFOREVER) != RSIEventType.RSIEventTypeUSER_LIMIT)
                {
                }

                Console.WriteLine("User Limit {0} triggered!", controller.InterruptSourceNumberGet());              // Get the index of the user limit that triggered.

                axis.AmpEnableSet(false);                                                                           // Disable the motor.
                controller.UserLimitDisable(userLimit);                                                             // Disable User Limit.
                Console.WriteLine("\nPress Any Key To Continue");                                                   // Allow time to read Console.
                Console.ReadKey();
                output0.Set(false);                                                                                 // Set output low so program can run again
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.WriteLine("\nPress Any Key To Exit");                                         // Allow time to read Console.
            Console.ReadKey();
        }
예제 #20
0
        static void Main(string[] args)
        {
            // Constants
            const int NODE_INDEX   = 0;
            const int INPUT_INDEX0 = 0;           // This is the index of the digital input you will use to trigger the user limit.
            const int INPUT_INDEX1 = 1;           // This is the index of the digital input you will use to trigger the user limit.
            const int OUTPUT_INDEX = 0;           // This is the index of the digital output that will go active when the user limit triggers.

            // 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.UserLimitCountSet(2);                                                                    // Set the amount of UserLimits that you want to use. (every connected axis will automatically get 1 user limit)
                controller.InterruptEnableSet(true);                                                                // Enable User Limit Interrupts. (When a user limit input comparison is met, and interrupt is triggered)

                //-------- PARAMETERS FOR 1st and 2nd UserLimitConditionSet --------
                int userLimit           = 1;                                                               // Specify which user limit to use.
                RSIUserLimitLogic logic = RSIUserLimitLogic.RSIUserLimitLogicEQ;                           // Logic for input value comparison.

                IOPoint input0  = IOPoint.CreateDigitalInput(controller.IOGet(NODE_INDEX), INPUT_INDEX0);  // Create IOPoint object. Can be used to automatically get the address of a specified node and input index
                IOPoint input1  = IOPoint.CreateDigitalInput(controller.IOGet(NODE_INDEX), INPUT_INDEX1);  // Create IOPoint object. Can be used to automatically get the address of a specified node and input index
                IOPoint output0 = IOPoint.CreateDigitalOutput(controller.IOGet(NODE_INDEX), OUTPUT_INDEX); // Create IOPoint object. Can be used to automatically get the address of a specified node and input index

                SampleAppsCS.HelperFunctions.CheckErrors(input0);
                SampleAppsCS.HelperFunctions.CheckErrors(input1);
                SampleAppsCS.HelperFunctions.CheckErrors(output0);

                int   condition0    = 0;                                                                   // Specify which condition to use (0 or 1) ("0" to compare 1 input || "1" to compare 2 inputs)
                ulong input0Address = input0.AddressGet();                                                 // 10 was the index of my 1st input. (To check your IO indexes go to RapidSetup -.

                uint input0Mask  = (uint)input0.MaskGet();
                uint limitValue0 = (uint)input0.MaskGet();

                int   condition1    = 1;                                           // Specify which condition to use (0 or 1) ("0" to compare 1 input || "1" to compare 2 inputs)
                ulong input1Address = input1.AddressGet();                         // 11 was the index of my 2nd input. (To check your IO indexes go to RapidSetup -.

                uint input1Mask  = (uint)input1.MaskGet();
                uint limitValue1 = (uint)input1.MaskGet();

                // [1] Configure the 1st input's trigger condition. (condition 1)
                controller.UserLimitConditionSet(userLimit,                                                      // (User Limit Index)   - Specify which user limit to use
                                                 condition0,                                                     // (Condition Number)   - Specify how many inputs you want to compare.
                                                 logic,                                                          // (Comparison Logic)   - Specify the how the input value(s) will be compared
                                                 input0Address,                                                  // (Input Address)      - Specify the address of the input that will be compared.
                                                 input0Mask,                                                     // (Input Mask)         - Specify the bits in an address which need to be used when comparing inputs.
                                                 limitValue0);                                                   // (Limit Value)        - Specify the value to be compared with.

                // [2] Configure the 2nd input's trigger condition. (condition 2)
                controller.UserLimitConditionSet(userLimit,                                                      // (User Limit Index)   - Specify which user limit to use
                                                 condition1,                                                     // (Condition Number)   - Specify how many inputs you want to compare.
                                                 logic,                                                          // (Comparison Logic)   - Specify the how the input value(s) will be compared
                                                 input1Address,                                                  // (Input Address)      - Specify the address of the input that will be compared.
                                                 input1Mask,                                                     // (Input Mask)         - Specify the bits in an address which need to be used when comparing inputs.
                                                 limitValue1);                                                   // (Limit Value)        - Specify the value to be compared with.

                //-------- PARAMETERS FOR UserLimitConfigSet --------
                RSIUserLimitTriggerType triggerType = RSIUserLimitTriggerType.RSIUserLimitTriggerTypeCONDITION_AND;
                RSIAction action   = RSIAction.RSIActionNONE;
                int       axis     = 0;
                int       duration = 0;

                // [3] Configure and Enable the user limit.
                controller.UserLimitConfigSet(userLimit,                                                          // (User Limit Index)   - Specify which user limit to use.
                                              triggerType,                                                        // (Trigger Type)       - Specify how your condition should be evalutated.
                                              action,                                                             // (User Limit Action)  - Specify the action you want to cause on the axis when the user limit triggers.
                                              axis,                                                               // (Current Axis)       - Specify the axis that the action (defined above) will occur on.
                                              duration);                                                          // (Output Timer)       - Specify the time delay before the action is executed after the User Limit has triggered.


                //-------- PARAMETERS FOR UserLimitOutputSet --------
                uint  andMask       = (uint)output0.MaskGet();
                uint  orMask        = (uint)output0.MaskGet();
                ulong outputAddress = output0.AddressGet();
                bool  enableOutput  = true;

                // [4] Configure what the output will be.                                                              (Call this method after UserLimitConfigSet if you want an output to be triggered) (The output will only be triggered if the input conditions are TRUE.)
                controller.UserLimitOutputSet(userLimit,                                                          // (User Limit Index)   - Specify which user limit to use.
                                              andMask,                                                            // (Logic AND Mask)     - Specify the value that the digital output will be AND-ed with.
                                              orMask,                                                             // (Logic OR Mask)      - Specify the value that the digital output will be OR-ed with.
                                              outputAddress,                                                      // (Output Address)     - Specify the digital output address.
                                              enableOutput);                                                      // (Enable Output Set)  - If TRUE, the output AND-ing and OR-ing will be executed when the User Limit triggers.

                Console.WriteLine("Waiting for the input bit to go high...\n");

                // Wait for user limit to trigger.
                while (controller.InterruptWait((int)RSIWait.RSIWaitFOREVER) != RSIEventType.RSIEventTypeUSER_LIMIT)
                {
                }

                Console.WriteLine("User Limit {0} triggered!", controller.InterruptSourceNumberGet());      // Get the index of the user limit that triggered.

                controller.UserLimitDisable(userLimit);                                                     // Disable User Limit.
                Console.WriteLine("\nPress Any Key To Continue");                                           // Allow time to read Console.
                Console.ReadKey();
                output0.Set(false);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
        static void Main(string[] args)
        {
            // Constants
            const int AXIS_INDEX       = 0;                     // Specify which axis/motor to control.
            const int USER_UNITS       = 1048576;               // Specify USER UNITS
            uint      SOFTWARE_ADDRESS = 0x026000B4;            // Specify Avaiable firmware address (starting from 0x026000B4 to 0x027FFFFF) can be checked in VM3.In VM3, look for Address without label which are available/free.

            // Initialize RapidCode Objects
            MotionController controller = MotionController.CreateFromSoftware(/*@"C:\RSI\X.X.X\"*/); // Insert the path location of the RMP.rta (usually the RapidSetup folder) (This sample app used RMP 8.0.1).

            SampleAppsCS.HelperFunctions.CheckErrors(controller);                                    // [Helper Function] Check that the controller has been initialize correctly.

            SampleAppsCS.HelperFunctions.StartTheNetwork(controller);                                // [Helper Function] Initialize the network.

            Axis axis = controller.AxisGet(AXIS_INDEX);                                              // Initialize Axis Class. (Use RapidSetup Tool to see what is your axis number)

            SampleAppsCS.HelperFunctions.CheckErrors(axis);                                          // [Helper Function] Check that the axis has been initialize correctly.

            try
            {
                // GET AXIS READY
                axis.UserUnitsSet(USER_UNITS);                                                      // Specify the counts per Unit.
                axis.PositionSet(0);                                                                // Make sure motor starts at position 0 everytime.
                axis.Abort();                                                                       // If there is any motion happening, abort it.
                axis.ClearFaults();                                                                 // Clear faults.
                axis.AmpEnableSet(true);                                                            // Enable the motor.

                // SET MOTION HOLD ON AVAILABLE SOFTWARE ADDRESS
                ulong hostAddress = controller.HostAddressGet(SOFTWARE_ADDRESS);                    // Get host address from software address
                axis.MotionHoldTypeSet(RSIMotionHoldType.RSIMotionHoldTypeCUSTOM);                  // Use TypeCUSTOM to hold execution based on a particular bit turning ON or OFF.
                axis.MotionHoldUserAddressSet(hostAddress);                                         // Specify the available hostAddress . This address' value will be used to evaluate the motion hold condition.
                axis.MotionHoldUserMaskSet(0x1);                                                    // Specify the bit you want to mask/watch from the MotionHoldUserAddressSet' address value (this evaluates using a logic AND)
                axis.MotionHoldUserPatternSet(0x1);                                                 // Specify the bit value that will release the motion hold. (When this value is met, motion hold will be released)

                // Check the condition to be false at first
                if (controller.MemoryGet(hostAddress) != 0x0)                                       // Check Available host address value is mask to be false (in this case 0x0)
                {
                    controller.MemorySet(hostAddress, 0x0);                                         // if not, mask it to false value/condition (in this case 0x0)
                }

                // SET MOTION HOLD
                axis.MotionAttributeMaskOnSet(RSIMotionAttrMask.RSIMotionAttrMaskHOLD);             // Set the HOLD motion attribute mask ON. (This initializes the HOLD on a particular motion)

                axis.MoveRelative(10);                                                              // Command simple relative motion. (This motion will be HOLD by the condition above)
                System.Threading.Thread.Sleep(3000);                                                // Sleep for 3 second before releasing motion hold.

                // RELEASE MOTION HOLD
                controller.MemorySet(hostAddress, 0x1);                                             // Release Motion Hold by specifying the host address value to SET Condition (in this case 0x10000)
                axis.MotionDoneWait();                                                              // Wait for motion to be done
                controller.MemorySet(hostAddress, 0x0);                                             // Specify host address value back to false value/condition (in this case 0x0)

                // COMMAND MOTION AGAIN
                axis.MoveRelative(10);                                                              // Command simple relative motion again. (This motion will be HOLD by the condition above)
                System.Threading.Thread.Sleep(3000);                                                // Sleep for 3 second before releasing motion hold.

                // RELEASE MOTION HOLD
                controller.MemorySet(hostAddress, 0x1);                                             // Release Motion Hold by specifying the host address value to SET Condition (in this case 0x1)
                axis.MotionDoneWait();                                                              // Wait for motion to be done
                controller.MemorySet(hostAddress, 0x0);                                             // Specify host address value back to false value/condition (in this case 0x0)

                // CLEAR MOTION HOLD
                axis.MotionAttributeMaskOffSet(RSIMotionAttrMask.RSIMotionAttrMaskHOLD);            // Set the HOLD motion attribute mask OFF. (This will clear any motion HOLDS that were set on this Axis)

                axis.MoveRelative(10);                                                              // This motion will have no HOLD since the previous line has set the motion attribute mask OFF.
                axis.MotionDoneWait();                                                              // Wait for Motion to be completed.

                // Abort and Clear Faults
                axis.Abort();
                axis.ClearFaults();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.WriteLine("\nPress Any Key To Exit");                                         // Allow time to read Console.
            Console.ReadKey();
        }
예제 #22
0
        static void Main(string[] args)
        {
            // RapidCode Objects
            MotionController controller;                // Declare what controller is.
            Axis             axis0;                     // Declare what axis1 is.
            Axis             axis1;                     // Declare what axis2 is.
            Axis             axis2;                     // Declare what axis3 is.
            Axis             axis3;                     // Declare what axis4 is.
            Axis             axis4;                     // Declare what axis5 is.
            Axis             axis5;                     // Declare what axis6 is.
            MultiAxis        multi;                     // Declare what multi is.

            // Constants
            const int cycles = 5;                       // Specify how many times you want to update the velocity.

            int i;

            double[] accelerations = new double[6] {
                1000, 1000, 1000, 1000, 1000, 1000
            };                                                                                      // Specify the acceleration for all 6 axes.
            double[] velocities = new double[6];                                                    // Initialize the array that will contain the velocities of all 6 axes.
            Random   rnd        = new Random();                                                     // Initialize the Random object that we will use to generate random velocities.

            // Initialize RapidCode Objects
            controller = MotionController.CreateFromSoftware(/*@"C:\RSI\X.X.X\"*/);                 // If your project is not on the RapidSetup folder, 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.

            axis0 = controller.AxisGet(0);                                                          // Initialize axis1. (You can use RapidSetup to see what axes you are using.)
            axis1 = controller.AxisGet(1);                                                          // Initialize axis2.
            axis2 = controller.AxisGet(2);                                                          // Initialize axis3.
            axis3 = controller.AxisGet(3);                                                          // Initialize axis4.
            axis4 = controller.AxisGet(4);                                                          // Initialize axis5.
            axis5 = controller.AxisGet(5);                                                          // Initialize axis6.

            SampleAppsCS.HelperFunctions.CheckErrors(axis0);                                        // Check that the axis1 has been initialize correctly.
            SampleAppsCS.HelperFunctions.CheckErrors(axis1);                                        // Check that the axis2 has been initialize correctly.
            SampleAppsCS.HelperFunctions.CheckErrors(axis2);                                        // Check that the axis3 has been initialize correctly.
            SampleAppsCS.HelperFunctions.CheckErrors(axis3);                                        // Check that the axis4 has been initialize correctly.
            SampleAppsCS.HelperFunctions.CheckErrors(axis4);                                        // Check that the axis5 has been initialize correctly.
            SampleAppsCS.HelperFunctions.CheckErrors(axis5);                                        // Check that the axis6 has been initialize correctly.

            multi = controller.MultiAxisGet(6);                                                     // Configure your MultiAxis on RapidSetup (Make sure MotionCount is 1 higher than AxisCount)
            SampleAppsCS.HelperFunctions.CheckErrors(multi);                                        // Check that multi has been initialized correctly.

            multi.AxisRemoveAll();                                                                  // If there are any current axes on multi, remove them.

            multi.AxisAdd(axis0);                                                                   // Add axis1 to your Multi-Axis controller.
            multi.AxisAdd(axis1);                                                                   // Add axis2 to your Multi-Axis controller.
            multi.AxisAdd(axis2);                                                                   // Add axis3 to your Multi-Axis controller.
            multi.AxisAdd(axis3);                                                                   // Add axis4 to your Multi-Axis controller.
            multi.AxisAdd(axis4);                                                                   // Add axis5 to your Multi-Axis controller.
            multi.AxisAdd(axis5);                                                                   // Add axis6 to your Multi-Axis controller.

            try
            {
                multi.Abort();                                                                      // If there is any motion happening, abort it.
                multi.ClearFaults();                                                                // Clear faults and enable all axes.
                multi.AmpEnableSet(true);                                                           // Enable the motor.

                Console.WriteLine("Start Multi-Axis Move\n");

                for (i = 0; i < cycles; i++)                                                        // This loop will iterate 5 times based on the value of "cycles"
                {
                    int random_vel1 = rnd.Next(1, 100);                                             // random_vel1 is a number [ >= 1 and < 100 ]
                    int random_vel2 = rnd.Next(1, 100);
                    int random_vel3 = rnd.Next(1, 100);
                    int random_vel4 = rnd.Next(1, 100);
                    int random_vel5 = rnd.Next(1, 100);
                    int random_vel6 = rnd.Next(1, 100);

                    velocities = new double[6] {
                        random_vel1,                                                                // Update axis1's velocity.
                        random_vel2,                                                                // Update axis2's velocity.
                        random_vel3,                                                                // Update axis3's velocity.
                        random_vel4,                                                                // Update axis4's velocity.
                        random_vel5,                                                                // Update axis5's velocity.
                        random_vel6
                    };                                                                              // Update axis6's velocity.

                    multi.MoveVelocity(velocities, accelerations);                                  // Move your Multi-Axis. (this will also update the move on the fly)

                    System.Threading.Thread.Sleep(100);                                             // Sleep for 100ms before iterating again.
                }

                multi.Abort();                                                                      // Stop motion on all axes.

                Console.WriteLine("\nTest Complete\n");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);                                                     // If there are any exceptions/issues this will be printed out.
            }
            Console.WriteLine("\nPress Any Key To Exit");                                         // Allow time to read Console.
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            // Constants
            const int AXIS_NUMBER = 0;                 // Specify which axis/motor to control.

            const int offsetIndex    = 0x607C;         // Homing Offset.
            const int offsetSubindex = 0x0;            //
            const int offsetByteSize = 4;              //
            const int offsetValue    = 0;              //

            const int methodIndex    = 0x6098;         // Home Method
            const int methodSubindex = 0x0;            //
            const int methodByteSize = 1;              //
            const int methodValue    = 24;             //

            const int targetSpeedIndex    = 0x6099;    // Speed To Switch
            const int targetSpeedSubindex = 0x1;       //
            const int targetSpeedByteSize = 4;         //
            const int targetSpeedValue    = 2;         //

            const int originSpeedIndex    = 0x6099;    // Speed to Zero
            const int originSpeedSubindex = 0x2;       //
            const int orignSpeedByteSize  = 4;         //
            const int originSpeedValue    = 10;        //

            const int accelerationIndex    = 0x609A;   // Homing Acceleration
            const int accelerationSubindex = 0x0;      //
            const int accelerationByteSize = 4;        //
            const int accelerationValue    = 100;      //

            const int modeOfOpIndex          = 0x6060; // Mode of Operation - For Switching To/From Homing Mode.
            const int modeOfOpSubindex       = 0x0;    //
            const int modeOfOpByteSize       = 1;      //
            const int modeOfOpValueToHOME    = 6;      //
            const int modeOfOpValueToDEFAULT = 8;      //

            const int axisControlWordIndex = 0;        // This value is just an example.  It will likely be different for your topology.

            //Desired DS402 Enabled Output.
            const int CONTROL_WORD_TO_PREP_HOMING     = 15;
            const int CONTROL_WORD_TO_START_HOMING    = 31;
            const int ACCEPTABLE_DELAY_IN_MS          = 20;
            const int STATUS_WORD_TARGET_REACHED_BIT  = 0x400;  // Status Bit 10 (0x400) indicates Target Reached (Homing is Complete).
            const int STATUS_WORD_HOMING_ATTAINED_BIT = 0x1000; // Status Bit 12 (0x1000) indicates Homing Attained (Homing is Successful).
            const int STATUS_WORD_HOMING_ERROR_BIT    = 0x2000; // Status Bit 13 (0x2000) indicates Homing Error (Homing ran into a problem).

            // 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.
            //controller.AxisCountSet(1);                                                           // Uncomment if using Phantom Axes.
            Axis axis = controller.AxisGet(AXIS_NUMBER);                                             // Initialize Axis Class. (Use RapidSetup Tool to see what is your axis number)

            SampleAppsCS.HelperFunctions.CheckErrors(axis);                                          // [Helper Function] Check that the axis has been initialize correctly.

            try
            {
                //1. CONFIGURE (Writing to SDOs)
                axis.NetworkNode.ServiceChannelWrite(offsetIndex, offsetSubindex, offsetByteSize, offsetValue);                             // Home Offset
                axis.NetworkNode.ServiceChannelWrite(methodIndex, methodSubindex, methodByteSize, methodValue);                             // Home Method (Home type)
                axis.NetworkNode.ServiceChannelWrite(targetSpeedIndex, targetSpeedSubindex, targetSpeedByteSize, targetSpeedValue);         // Home Speed during search for switch
                axis.NetworkNode.ServiceChannelWrite(originSpeedIndex, originSpeedSubindex, orignSpeedByteSize, originSpeedValue);          // Home Speed during search for zero
                axis.NetworkNode.ServiceChannelWrite(accelerationIndex, accelerationSubindex, accelerationByteSize, accelerationValue);     // Home acceleration

                //2. READY AXIS
                axis.Abort();                                                                                                               // Disable axis.
                axis.ClearFaults();                                                                                                         // Clear any faults.
                axis.AmpEnableSet(true);                                                                                                    // Enable the axis to trigger the home start.

                axis.rsiControl.NetworkOutputOverrideValueSet(axisControlWordIndex, CONTROL_WORD_TO_PREP_HOMING);                           // Control Word should be 15 before Switching to Homing Mode.
                axis.rsiControl.NetworkOutputOverrideSet(axisControlWordIndex, true);                                                       // Override Control Word.
                Thread.Sleep(ACCEPTABLE_DELAY_IN_MS);                                                                                       // Delay to give transitions time -or- setup something more complex to ensure drive is in the appropriate state.

                axis.NetworkNode.ServiceChannelWrite(modeOfOpIndex, modeOfOpSubindex, modeOfOpByteSize, modeOfOpValueToHOME);               // Mode of Operation (Homing Mode = 6)
                Thread.Sleep(ACCEPTABLE_DELAY_IN_MS);                                                                                       // Delay to give transitions time -or- setup something more complex to ensure drive is in the appropriate state.

                //3. HOME
                axis.rsiControl.NetworkOutputOverrideValueSet(axisControlWordIndex, CONTROL_WORD_TO_START_HOMING);                          // Start Homing.
                Thread.Sleep(ACCEPTABLE_DELAY_IN_MS);                                                                                       // Delay to give transitions time -or- setup something more complex to ensure drive is in the appropriate state.

                UInt16 statusWordValue;                                                                                                     // Takes the axis index. This will return the status word value.
                bool   cancelHome = false;

                statusWordValue = axis.NetworkNode.StatusWordGet(AXIS_NUMBER);
                while ((!cancelHome) && ((statusWordValue & STATUS_WORD_TARGET_REACHED_BIT) == 0))                                          // When Status Word Indicates Target Reached (Success or Fail) or external evaluator (cancelHome)
                {
                    statusWordValue = axis.NetworkNode.StatusWordGet(AXIS_NUMBER);                                                          // Get the status word value (index 0x6060).
                    //A timeout that sets cancelHome would be a good idea.
                }

                // 4. EVALUATE HOMING SUCCESS
                if ((statusWordValue & STATUS_WORD_HOMING_ATTAINED_BIT) == 1)
                {
                    Console.WriteLine("Axis homed.");
                }
                else if ((statusWordValue & STATUS_WORD_HOMING_ERROR_BIT) == 1)
                {
                    Console.WriteLine("Error Occured during homing.");
                }

                //5. CLEAN UP
                axis.AmpEnableSet(false);                                                                                                   // Disable the axis.
                axis.ClearFaults();
                axis.rsiControl.NetworkOutputOverrideSet(axisControlWordIndex, false);
                axis.NetworkNode.ServiceChannelWrite(modeOfOpIndex, modeOfOpSubindex, modeOfOpByteSize, modeOfOpValueToDEFAULT);            // Restore the mode of operation to the control mode you want to run in. Mode of Operation (Default Mode = 8?)
                Thread.Sleep(ACCEPTABLE_DELAY_IN_MS);                                                                                       // Delay to give transitions time -or- setup something more complex to ensure drive is in the appropriate state.
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
예제 #24
0
        static void Main(string[] args)
        {
            // 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)

            SampleAppsCS.HelperFunctions.CheckErrors(controller);                                    // [Helper Function] Check that the controller has been initialized correctly.
            SampleAppsCS.HelperFunctions.StartTheNetwork(controller);                                // [Helper Function] Initialize the network.

            Axis axis = controller.AxisGet(AXIS_NUMBER);                                             // Initialize the axis.

            SampleAppsCS.HelperFunctions.CheckErrors(axis);                                          // [Helper Function] Check that the axis has been initialized correctly.

            IO ioNode = controller.IOGet(NODE_NUMBER);                                               // Initialize the axis.

            SampleAppsCS.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.
            }
        }
        static void Main(string[] args)
        {
            // Constants
            const int X_AXIS      = 0;                   // Specify which axis will be the x axis
            const int Y_AXIS      = 1;                   // Specify which axis will be the y axis
            const int NUM_OF_AXES = 2;                   // Specify the number of axes (Make sure your axis count in RapidSetup is 2!)
            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)

            // Parameters
            double[] positions1 = new double[2] {
                100, 200
            };                                                  // The first set of positions to be moved to
            double[] positions2 = new double[2] {
                300, 300
            };                                                  // The second set of positions to be moved to
            double[] velocities1 = new double[2] {
                5, 10
            };                                                  // The velocity for the two axes for the first move- Units: units/sec (driver will execute 10 rotations per second)
            double[] velocities2 = new double[2] {
                10, 5
            };                                                  // The velocity for the two axes for the second move
            double[] accelerations = new double[2] {
                10, 10
            };                                                  // The acceleration for the two axes
            double[] decelerations = new double[2] {
                10, 10
            };                                                  // The deceleration for the two axes
            double[] jerkPercent = new double[2] {
                50, 50
            };                                                  // The jerk percent for the two axes

            // 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 initialized correctly.

            SampleAppsCS.HelperFunctions.StartTheNetwork(controller);                                 // [Helper Function] Initialize the network.

            //controller.AxisCountSet(NUM_OF_AXES);                                                   // Uncomment when using Phantom Axes.

            Axis axis0 = controller.AxisGet(X_AXIS);                                                  // Initialize axis0
            Axis axis1 = controller.AxisGet(Y_AXIS);                                                  // Initialize axis1

            SampleAppsCS.HelperFunctions.CheckErrors(axis0);                                          // [Helper Function] Check that 'axis0' has been initialized correctly
            SampleAppsCS.HelperFunctions.CheckErrors(axis1);                                          // [Helper Function] Check that 'axis1' has been initialized correctly

            controller.MotionCountSet(3);                                                             // We will need a motion supervisor for every Axis object and MultiAxis object
                                                                                                      // In this application, we have two Axis objects and one MultiAxis object, so three motion supervisors are required
            MultiAxis multi = controller.MultiAxisGet(NUM_OF_AXES);                                   // Initialize a new MultiAxis object. MultiAxisGet takes a motion supervisor number as its argument.

            // This number is equal to the number of axes since motion supervisors are zero indexed (i.e., motion supervisors
            // 0 and 1 are used for axis0 and axis1, so motion supervisor 2 is available for our MultiAxis object).

            SampleAppsCS.HelperFunctions.CheckErrors(multi);                                          // [Helper Function] Check that 'multi' has been initialized correctly
            controller.AxisCountSet(NUM_OF_AXES);                                                     // Set the number of axis being used. A phantom axis will be created if for any axis not on the network. You may need to refresh rapid setup to see the phantom axis.

            multi.AxisRemoveAll();                                                                    // Remove all current axis if any. So we can add new ones

            multi.AxisAdd(axis0);                                                                     // Add axis0 to the MultiAxis object
            multi.AxisAdd(axis1);                                                                     // Add axis1 to the MultiAxis object

            try
            {
                axis0.UserUnitsSet(USER_UNITS);                                                       // Specify the counts per unit.
                axis0.ErrorLimitTriggerValueSet(1);                                                   // Specify the position error limit trigger. (Learn more about this on our support page)
                axis1.UserUnitsSet(USER_UNITS);
                axis1.ErrorLimitTriggerValueSet(1);

                multi.Abort();                                                                        // If there is any motion happening, abort it

                axis0.PositionSet(0);                                                                 // Zero the position (in case the program is run multiple times)
                axis1.PositionSet(0);                                                                 // This negates homing, so only do it in test/sample code

                multi.ClearFaults();                                                                  // Clear any faults

                multi.AmpEnableSet(true);                                                             // Enable the motor

                Console.WriteLine("MultiAxis Point-to-Point Motion Example\n");

                Console.WriteLine("\nBegin SCurve Motion\n");

                //axis0.ErrorLimitActionSet(RSIAction.RSIActionNONE);                                 // Uncomment when using Phantom Axes.
                axis1.ErrorLimitActionSet(RSIAction.RSIActionNONE);                                   // Uncomment when using Phantom Axes.

                multi.MoveSCurve(positions1, velocities1, accelerations, decelerations, jerkPercent); // Move to the positions specified in positions1 using a trapezoidal motion profile
                multi.MotionDoneWait();                                                               // Wait for motion to finish

                Console.WriteLine("\nSCurve Motion Complete\n");
                Console.WriteLine("\nBegin Trapezoidal Motion\n");

                multi.MoveTrapezoidal(positions2, velocities2, accelerations, decelerations);         // Move to the positions specified in positions2 using a SCurve motion profile
                multi.MotionDoneWait();                                                               // Wait for the motion to finish

                multi.AmpEnableSet(false);                                                            // Disable the axes

                Console.WriteLine("\nTrapezoidal Motion Complete\n");
                Console.WriteLine("\nTest Complete\n");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.WriteLine("\nPress Any Key To Exit");                                         // Allow time to read Console.
            Console.ReadKey();
        }
예제 #26
0
        static void Main(string[] args)
        {
            // Constants
            const int AXIS_NUMBER        = 0;       // Specify which axis/motor to control
            const int RELATIVE_POSITION1 = 25;      // Specify the first relative position to move to
            const int RELATIVE_POSITION2 = -50;     // Specify the second relative position to move to
            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)
            const int VELOCITY           = 10;      // Specify your velocity - units: Units/Sec     (it will do "1048576 counts / 1 motor revolution" per second)
            const int ACCELERATION       = 100;     // Specify your acceleration - units: Units/Sec^2
            const int DECELERATION       = 100;     // Specify your deceleration - units: Units/Sec^2
            const int JERK_PCT           = 50;      // Specify your jerk percent - units: Units/Sec^2

            // 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 initialized correctly.

            SampleAppsCS.HelperFunctions.StartTheNetwork(controller);                                // [Helper Function] Initialize the network.

            Axis axis = controller.AxisGet(AXIS_NUMBER);                                             // Initialize the axis.

            SampleAppsCS.HelperFunctions.CheckErrors(axis);                                          // [Helper Function] Check that the axis has been initialized correctly.

            try
            {
                axis.UserUnitsSet(USER_UNITS);                                                          // Specify the counts per Unit. (every 1048576 counts my motor does one full turn) (varies per motor)
                axis.ErrorLimitTriggerValueSet(1);                                                      // Specify the position error limit trigger. (Learn more about this on our support page)
                axis.PositionSet(0);                                                                    // Ensure motor starts at position 0 every time

                axis.Abort();                                                                           // If there is any motion happening, abort it
                axis.ClearFaults();                                                                     // Clear any fualts
                axis.AmpEnableSet(true);                                                                // Enable the axis

                Console.WriteLine("Relative Motion Example\n");

                axis.MoveSCurve(25, VELOCITY, ACCELERATION, DECELERATION, JERK_PCT);                    // To demonstrate relative motion, we will start the axis at position 25.
                axis.MotionDoneWait(3000);                                                              // Then, when we make a relative move to RELATIVE_POSITION1, we will end up at position 50, and
                                                                                                        // and when we move to RELATIVE_POSITION2, we will be back at position 0.
                                                                                                        // NOTE that this move is an ABSOLUTE MOVE, so it moves the axis to position 25 rather than 25
                                                                                                        // units ahead of the current position.

                // Wait for Motion to finish. (the motion should take 2.5 seconds)
                // (if the motion is not done in 3000 milliseconds, MotionDoneWait() will throw an error)

                Console.WriteLine("\nRelative move of " + RELATIVE_POSITION1 + " from " + axis.ActualPositionGet() + "...\n");

                axis.MoveRelative(RELATIVE_POSITION1, VELOCITY, ACCELERATION, DECELERATION, JERK_PCT);  // Command a relative move
                axis.MotionDoneWait(3000);                                                              // Wait for motion to finish. (the motion should take 2.5 seconds)
                                                                                                        // (if the motion is not done in 3000 milliseconds, MotionDoneWait() will throw an error)

                Console.WriteLine("\nFinal Position: " + axis.ActualPositionGet() + "\n");
                Console.WriteLine("\nRelative move of " + RELATIVE_POSITION2 + " from " + axis.ActualPositionGet() + "...\n");

                axis.MoveRelative(RELATIVE_POSITION2, VELOCITY, ACCELERATION, DECELERATION, JERK_PCT);  // Command a relative move. (the motion should take 5 seconds)
                axis.MotionDoneWait(6000);                                                              // Wait for the motion to finish. (the motion should take 5 seconds)
                                                                                                        // (if the motion is not done in 6000 milliseconds, MotionDoneWait() will throw an error)
                Console.WriteLine("\nFinal Position: " + axis.ActualPositionGet() + "\n");
                Console.WriteLine("\nDone\n");

                axis.AmpEnableSet(false);                                                               // Disable the axis
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.WriteLine("\nPress Any Key To Exit");                                           // Allow time to read Console.
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            // Initialize RapidCode Objects
            controller = MotionController.CreateFromSoftware();                                                                 // 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.

            // Some Necessary Pre User Limit Configuration
            controller.UserLimitCountSet(USER_LIMIT_COUNT);                                                                     // Set the amount of UserLimits that you want to use.

            SampleAppsCS.HelperFunctions.StartTheNetwork(controller);                                                           // [Helper Function] Initialize the network.

            axis = controller.AxisGet(AXIS_INDEX);                                                                              // Initialize your axis object.
            SampleAppsCS.HelperFunctions.CheckErrors(axis);


            try
            {
                // set the triggered modify values to stop very quickly
                axis.TriggeredModifyDecelerationSet(DECEL);
                axis.TriggeredModifyJerkPercentSet(JERK_PCT);

                //////////// FIRST USER LIMIT ////////////
                // USER LIMIT CONDITION 0 (trigger on digital input)
                controller.UserLimitConditionSet(USER_LIMIT_FIRST, 0, LOGIC, axis.AddressGet(RSIAxisAddressType.RSIAxisAddressTypeDIGITAL_INPUTS), 0x400000, 0x400000);              // Set your User Limit Condition (1st step to setting up your user limit)

                //// USER LIMIT OUTPUT  (copy TC.ActualPosition to UserBuffer)
                // controller.UserLimitOutputSet(USER_LIMIT_FIRST, RSIDataType.RSIDataTypeDOUBLE,  axis.AddressGet(RSIAxisAddressType.RSIAxisAddressTypeTC_ACTUAL_POSITION), controller.AddressGet(RSIControllerAddressType.RSIControllerAddressTypeUSER_BUFFER), true);

                //// USER LIMIT CONFIGURATION  (cause a TRIGGERED_MODIFY action on the Axis)
                controller.UserLimitConfigSet(USER_LIMIT_FIRST, TRIGGER_TYPE, ACTION, axis.NumberGet(), DURATION, ONE_SHOT);                    // Set your User Limit Configuration. (2nd step to setting up your user limit)


                //////////// SECOND USER LIMIT ////////////
                // CONDITION 0  (wait for first user limit to trigger)
                controller.UserLimitConditionSet(USER_LIMIT_SECOND, 0, RSIUserLimitLogic.RSIUserLimitLogicEQ, controller.AddressGet(RSIControllerAddressType.RSIControllerAddressTypeUSERLIMIT_STATUS, USER_LIMIT_FIRST), 1, 1);

                // CONDITION 1 (AND wait for Axis command velcity = 0.0)
                controller.UserLimitConditionSet(USER_LIMIT_SECOND, 1, RSIUserLimitLogic.RSIUserLimitLogicEQ, axis.AddressGet(RSIAxisAddressType.RSIAxisAddressTypeCOMMAND_VELOCITY), 0.0);

                // OUTPUT (copy value from UserBuffer to TC.CommandPosition when trigered)
                //controller.UserLimitOutputSet(USER_LIMIT_SECOND, RSIDataType.RSIDataTypeDOUBLE, controller.AddressGet(RSIControllerAddressType.RSIControllerAddressTypeUSER_BUFFER), axis.AddressGet(RSIAxisAddressType.RSIAxisAddressTypeTC_COMMAND_POSITION), true);
                controller.UserLimitConfigSet(USER_LIMIT_SECOND, RSIUserLimitTriggerType.RSIUserLimitTriggerTypeCONDITION_AND, RSIAction.RSIActionNONE, 0, 0, ONE_SHOT);


                // get the Axis moving
                axis.ClearFaults();
                axis.AmpEnableSet(true);
                axis.MoveVelocity(VELOCITY, ACCEL);

                // configure and enable interrupts
                ConfigureUserLimitInterrupts(USER_LIMIT_FIRST);
                ConfigureUserLimitInterrupts(USER_LIMIT_SECOND);
                controller.InterruptEnableSet(true);

                // wait for (and print) interrupts
                WaitForInterrupts();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
예제 #28
0
        static void Main(string[] args)
        {
            // Constants
            const int AXIS_NUMBER = 0;         // Specify which axis/motor to control.
            const int POINTS      = 1;         // Specify how many points per streaming motion method call.
            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)

            double[] first  = { 10.0 };        // specify the array with position(s) that will go in the first MovePT call.
            double[] second = { 20.0 };        // specify the array with position(s) that will go in the second MovePT call
            double[] third  = { 7.0 };         // specify the array with position(s) that will go in the third MovePT call

            double[] time1 = { 5.0 };          // specify the array with time(s) that will go in the first MovePT call.
            double[] time2 = { 2.0 };          // specify the array with time(s) that will go in the second MovePT call.
            double[] time3 = { 5.0 };          // specify the array with time(s) that will go in the third MovePT call.

            // 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 initialized correctly.

            SampleAppsCS.HelperFunctions.StartTheNetwork(controller);                                // [Helper Function] Initialize the network.

            Axis axis = controller.AxisGet(AXIS_NUMBER);                                             // Initialize the axis.

            SampleAppsCS.HelperFunctions.CheckErrors(axis);                                          // [Helper Function] Check that the axis has been initialized correctly.

            try
            {
                axis.UserUnitsSet(USER_UNITS);
                axis.ErrorLimitTriggerValueSet(1);                                                  // Specify the position error limit trigger. (Learn more about this on our support page)
                axis.PositionSet(0);


                axis.Abort();                                                                               // If there is any motion happening, abort it.
                axis.ClearFaults();                                                                         // Clear faults.
                axis.AmpEnableSet(true);                                                                    // Enable the motor.

                axis.MovePT(RSIMotionType.RSIMotionTypePT, first, time1, POINTS, -1, false, false);         // Start motion and stream a point.
                axis.MovePT(RSIMotionType.RSIMotionTypePT, second, time2, POINTS, -1, false, false);        // Append a point.

                // After you stop a streaming motion, you can do 2 things.
                // 1. You can either RESUME motion and continue to append.
                // 2. Or you can DISCARD the points before the stop and start new motion.

                axis.Stop();                                                                                // Calling Stop() after streaming motion will put you in an STOPPED state.

                //axis.EStop();                                                                             // Calling EStop() after streaming motion will put you in an ERROR state.
                // Therefore, you must ClearFaults() before taking any action.

                //axis.Abort();                                                                             // Calling Abort() after streaming motion will put you in an ERROR state and trigger an AmpEnable(false).
                // Therefore, you must call AmpEnable(true) before taking action.

                axis.MotionDoneWait();                                                                      // Wait for axis to come to a stop.
                axis.Resume();                                                                              // Resume() is the key here.
                                                                                                            // If you include Resume() you will append all next streaming points to the old ones.
                                                                                                            // If you do not include Resume() you will discard all previous points and start with new motion with the new points.

                axis.MovePT(RSIMotionType.RSIMotionTypePT, third, time3, POINTS, -1, false, true);          // Depending on whether you include Resume() or not this point will be appended or will be starting motion.
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);                                                     // If there are any exceptions/issues this will be printed out.
            }
            Console.WriteLine("\nPress Any Key To Exit");                                         // Allow time to read Console.
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            // Constants
            const int DIGITAL_INPUTS_PDO_INDEX = 3; // Specify the pdo inputs index that represent digital inputs.
            const int AXIS_INDEX = 0;               // Specify which axis/motor to control.
            const int USER_UNITS = 1048576;         // Specify USER UNITS

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

            Axis axis = controller.AxisGet(AXIS_INDEX);                                              // Initialize Axis Class. (Use RapidSetup Tool to see what is your axis number)

            SampleAppsCS.HelperFunctions.CheckErrors(axis);                                          // [Helper Function] Check that the axis has been initialize correctly.


            try
            {
                // GET AXIS READY
                axis.UserUnitsSet(USER_UNITS);                                                      // Specify the counts per Unit.
                axis.PositionSet(0);                                                                // Make sure motor starts at position 0 everytime.
                axis.ErrorLimitActionSet(RSIAction.RSIActionNONE);                                  // Uncomment when using Phantom Axes.
                axis.Abort();                                                                       // If there is any motion happening, abort it.
                axis.ClearFaults();                                                                 // Clear faults.
                axis.AmpEnableSet(true);                                                            // Enable the motor.


                // SET MOTION HOLD
                ulong inputAddress = controller.NetworkInputAddressGet(DIGITAL_INPUTS_PDO_INDEX);   // Get host address using the PDO Input Index of Digital Inputs.

                axis.MotionHoldTypeSet(RSIMotionHoldType.RSIMotionHoldTypeCUSTOM);                  // Use TypeCUSTOM to hold execution based on a particular bit turning ON or OFF.
                axis.MotionHoldUserAddressSet(inputAddress);                                        // Specify the digital inputs host address. This address' value will be used to evaluate the motion hold condition.
                axis.MotionHoldUserMaskSet(0x20000);                                                // Specify the bit you want to mask/watch from the MotionHoldUserAddressSet' address value (this evaluates using a logic AND)
                axis.MotionHoldUserPatternSet(0x20000);                                             // Specify the bit value that will release the motion hold. (When this value is met, motion hold will be released)

                axis.MotionAttributeMaskOnSet(RSIMotionAttrMask.RSIMotionAttrMaskHOLD);             // Set the HOLD motion attribute mask ON. (This initializes the HOLD on a particular motion)

                axis.MoveRelative(10);                                                              // Command simple relative motion. (This motion will be HOLD by the condition above)
                axis.MotionDoneWait();                                                              // Wait for Motion to be completed.

                axis.MoveRelative(10);                                                              // If motion attribute mask off has not been set, this motion will have same HOLD condition as previous move.
                axis.MotionDoneWait();                                                              // Wait for Motion to be completed.

                axis.MotionAttributeMaskOffSet(RSIMotionAttrMask.RSIMotionAttrMaskHOLD);            // Set the HOLD motion attribute mask OFF. (This will clear any motion HOLDS that were set on this Axis)

                axis.MoveRelative(10);                                                              // This motion will have no HOLD since the previous line has set the motion attribute mask OFF.
                axis.MotionDoneWait();                                                              // Wait for Motion to be completed.

                // Abort and Clear Faults
                axis.Abort();
                axis.ClearFaults();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);                                                     // If there are any exceptions/issues this will be printed out.
            }
            Console.WriteLine("\nPress Any Key To Exit");                                         // Allow time to read Console.
            Console.ReadKey();
        }
예제 #30
0
        static void Main(string[] args)
        {
            // Constants
            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) ("user unit = 1" means it will do one count out of the 1048576)
            const int    MASTER_AXIS_NUMBER  = 0;       // Specify which is your master axis/motor.
            const int    SLAVE_AXIS_NUMBER   = 1;       // Specify which is your slave axis/motor.
            const double MASTER_VELOCITY     = 2;       // Specify your master's axis velocity.   -   units: Units/Sec      (it will do 1 counts / (1/104857) of a revolution every 1 second.)
            const double MASTER_ACCELERATION = 10;      // Specify your master's acceleration.    -   units: Units/Sec^2

            // Commanded Positions
            double[] masterDistances = { 5 * USER_UNITS, 20 * USER_UNITS, 15 * USER_UNITS };        // This is the RELATIVE master distance, every n revolutions it changes its slave position. (This is the x-axis)
            double[] slavePositions  = { 10 * USER_UNITS, 20 * USER_UNITS, 10 * USER_UNITS };       // This is the final ABSOLUTE slave position, for every 5 revolutions one of this positions gets applied. (This is the y-axis)

            // Initialize RapidCode Objects
            MotionController controller = MotionController.CreateFromSoftware(/*@"C:\RSI\X.X.X\"*/); // Insert the path location of the RMP.rta (usually the RapidSetup folder) (This sample app used RMP 8.1.3).

            SampleAppsCS.HelperFunctions.CheckErrors(controller);                                    // [Helper Function] Check that the controller has been initialized correctly.

            SampleAppsCS.HelperFunctions.StartTheNetwork(controller);                                // [Helper Function] Initialize the network.

            Axis master = controller.AxisGet(MASTER_AXIS_NUMBER);                                    // Initialize master Class. (Use RapidSetup Tool to see what is your axis number)
            Axis slave  = controller.AxisGet(SLAVE_AXIS_NUMBER);                                     // Initialize slave Class.

            SampleAppsCS.HelperFunctions.CheckErrors(master);                                        // [Helper Function] Check that the master axis has been initialize correctly.
            SampleAppsCS.HelperFunctions.CheckErrors(slave);                                         // [Helper Function] Check that the slave axis has been initialize correctly.

            try
            {
                controller.AxisCountSet(2);                                                         // Set the number of axis being used. A phantom axis will be created if for any axis not on the network. You may need to refresh rapid setup to see the phantom axis.

                master.UserUnitsSet(USER_UNITS);                                                    // (MUST BE SET TO 1 FOR CAMMING MOTION)
                master.ErrorLimitTriggerValueSet(1000);                                             // Specify the position error limit trigger. (Learn more about this on our support page)
                slave.UserUnitsSet(USER_UNITS);                                                     // (MUST BE SET TO 1 FOR CAMMING MOTION)
                slave.ErrorLimitTriggerValueSet(1000);

                master.Abort();                                                                     // If there is any motion happening, abort it.
                slave.Abort();

                master.ClearFaults();                                                               // Clear faults.
                slave.ClearFaults();

                master.AmpEnableSet(true);                                                          // Enable the motor.
                slave.AmpEnableSet(true);

                master.PositionSet(0);                                                              // this negates homing, so only do it in test/sample code.
                slave.PositionSet(0);

                // Command motion on the slave before the master starts
                slave.MoveCamLinear(master.NumberGet(),
                                    RSIAxisMasterType.RSIAxisMasterTypeAXIS_COMMAND_POSITION,       // This specified to use the actual position of the master axis.
                                    masterDistances,
                                    slavePositions,
                                    masterDistances.Length);

                master.MoveVelocity(MASTER_VELOCITY, MASTER_ACCELERATION);                          // Command a constant velocity on the master axis, slave will follow.

                slave.MotionDoneWait();                                                             // Wait for the cam motion to complete

                master.Stop();                                                                      // Stop the master

                master.AmpEnableSet(false);                                                         // Disable the motor.
                slave.AmpEnableSet(false);

                Console.WriteLine("\nTest Complete\n");
            }
            catch (RsiError e)
            {
                Console.WriteLine(e.Message);                                                     // If there are any exceptions/issues this will be printed out.
            }
            Console.WriteLine("\nPress Any Key To Exit");                                         // Allow time to read Console.
            Console.ReadKey();
        }