예제 #1
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();
        }
예제 #2
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();
        }
        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();
        }
예제 #4
0
        static void Main(string[] args)
        {
            // Constants
            const int    HOLDING_AXIS_INDEX = 1;       // Specify which axis/motor to control.
            const int    MOVING_AXIS_INDEX  = 0;       // Specify which axis/motor to control.
            const double TRIGGER_POS        = 5;       // Specify the position that will be evaluted on triggering/releasing motion
            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) (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.
            controller.AxisCountSet(2);                                                                     // Specify two Axis in controller

            // Initiazlize Axes: holdingAxis and movingAxis
            Axis holdingAxis = controller.AxisGet(HOLDING_AXIS_INDEX);                                      // Initialize Axis Class. (Use RapidSetup Tool to see what is your axis number)

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

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

            SampleAppsCS.HelperFunctions.CheckErrors(movingAxis);                                           // [Helper Function] Check that the 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.

                // GET HOLD AXIS READY
                holdingAxis.UserUnitsSet(USER_UNITS);                                                       // Specify the counts per Unit.
                holdingAxis.PositionSet(0);                                                                 // Make sure motor starts at position 0 everytime.
                holdingAxis.ErrorLimitTriggerValueSet(1000);                                                // Specify the position error limit trigger. (Learn more about this on our support page)
                holdingAxis.Abort();                                                                        // If there is any motion happening, abort it.
                holdingAxis.ClearFaults();                                                                  // Clear faults.>
                holdingAxis.AmpEnableSet(true);                                                             // Enable the motor.

                // GET MOVE AXIS READY
                movingAxis.ErrorLimitActionSet(RSIAction.RSIActionNONE);                                    // If NOT using a Phantom Axis, switch to RSIActionABORT
                movingAxis.UserUnitsSet(USER_UNITS);                                                        // Specify the counts per Unit.
                movingAxis.PositionSet(0);                                                                  // Make sure motor starts at position 0 everytime.
                movingAxis.ErrorLimitTriggerValueSet(1000);                                                 // Specify the position error limit trigger. (Learn more about this on our support page)
                movingAxis.Abort();                                                                         // If there is any motion happening, abort it.
                movingAxis.ClearFaults();                                                                   // Clear faults.>
                movingAxis.AmpEnableSet(true);                                                              // Enable the motor.

                // SET UP MOTION HOLD                                                                       // Condition/Configuration to the Axis(movingAxis) that will hold Motion and its Position that will trigger/release motion
                holdingAxis.MotionHoldTypeSet(RSIMotionHoldType.RSIMotionHoldTypeAXIS_COMMAND_POSITION);    // Use RSIMotionHoldTypeAXIS_ACTUAL_POSITION if it is not Phantom Axis.
                holdingAxis.MotionHoldAxisNumberSet(movingAxis.NumberGet());                                // Specify motion hold to the Axis(movingAxis) whose position will hold the motion of holdingAxis.
                holdingAxis.MotionHoldAxisPositionSet(USER_UNITS * TRIGGER_POS);                            // Specify motion hold position which is the movingAxis's position(need to multiply with USER_UNITS to get correct position value) to trigger/release the motion of holdingAxis.
                holdingAxis.MotionHoldAxisLogicSet(RSIUserLimitLogic.RSIUserLimitLogicGE);                  // Specify the logic condition that will be evaluated to trigger/release motion based on the SET POSITION(USER_UNITS * TRIGGER_POS).In this case, GT(Greater than or Equal to) motion hold position limit to release

                // SET MOTION HOLD ON
                holdingAxis.MotionAttributeMaskOnSet(RSIMotionAttrMask.RSIMotionAttrMaskHOLD);              // Set the HOLD motion attribute mask ON. (This initializes the HOLD on a particular motion)
                holdingAxis.MoveRelative(10);                                                               // Command simple relative motion(This motion will be hold by condition above until movingAxis's Position passes motion hold position limit)

                // Release MOTION HOLD
                movingAxis.MoveRelative(10);                                                                // Move movingAxis.MovingAxis's position reaches its MotionHold Position limit(in this case, limit is 5). It will trigger/release motion on holdingAxis (holidingAxis will move relatively 10).
                movingAxis.MotionDoneWait();
                holdingAxis.MotionDoneWait();

                // Abort and Clear Faults
                holdingAxis.Abort();
                holdingAxis.ClearFaults();
                movingAxis.Abort();
                movingAxis.ClearFaults();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.WriteLine("\nPress Any Key To Exit");                                         // Allow time to read Console.
            Console.ReadKey();
        }
예제 #5
0
        static void Main(string[] args)
        {
            // Constants
            const int    MASTER_AXIS  = 0;       // Specify which axis will be the master axis
            const int    SLAVE_AXIS   = 1;       // Specify which axis will be the slave axis
            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    POSITION1    = 50;      // Specify the position to travel to.
            const int    POSITION2    = 0;       // Specify the position to travel to.
            const double VELOCITY     = 10;      // Specify your velocity - units: units/sec     (it will do (1048576*10)counts/10-revolutions every 1 second.)
            const double ACCELERATION = 100;     // Specify your acceleration - units: units/sec^2
            const double DECELERATION = 100;     // Specify your deceleration - units: units/sec^2
            const double JERK_PERCENT = 50;      // Specify your jerk percentage

            // 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 master = controller.AxisGet(MASTER_AXIS);                                           // Initialize master Class. (Use RapidSetup Tool to see what is your axis number)
            Axis slave  = controller.AxisGet(SLAVE_AXIS);                                            // 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);                                                // Specify the counts per Unit.
                master.ErrorLimitTriggerValueSet(1);                                            // Specify the position error limit trigger. (Learn more about this on our support page)
                slave.UserUnitsSet(USER_UNITS);
                slave.ErrorLimitTriggerValueSet(1);
                slave.ErrorLimitActionSet(RSIAction.RSIActionNONE);                             // If NOT using a Phantom Axis, switch to RSIActionABORT

                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);                                                          // Zero the position (in case the program is run multiple times)
                slave.PositionSet(0);                                                           // this negates homing, so only do it in test/sample code.

                Console.WriteLine("Gearing Example");

                int numerator   = 2;                                                            // Specify the numerator of the gearing ratio.
                int denominator = 1;                                                            // Specify the denominator of the gearing ratio.

                // Configure the 'slave' axis to be a slave to the 'master' axis at a ratio of 2:1, that is,
                // for every rotation of the master axis, the slave axis will rotate twice.
                slave.GearingEnable(master,
                                    RSIAxisMasterType.RSIAxisMasterTypeAXIS_COMMAND_POSITION,    // If NOT using a Phantom Axis, switch to RSIAxisMasterTypeAXIS_ACTUAL_POSITION
                                    numerator,
                                    denominator);

                Console.WriteLine("\nTesting for Gearing Ratio {0}/{1}\n", numerator, denominator);

                master.MoveSCurve(POSITION1,
                                  VELOCITY,
                                  ACCELERATION,
                                  DECELERATION,
                                  JERK_PERCENT);                                                // Perform a S-curve motion on the master axis.

                master.MotionDoneWait();                                                        // Wait for motion to finish.

                // Test changing the gearing ratio to -1:1, that is,
                // for every rotation of the master axis, the slave axis will rotate once in the opposite direction
                numerator   = -1;
                denominator = 1;

                slave.GearingRatioChange(numerator, denominator);                               // Change the electronic gearing ratio

                Console.WriteLine("\nTesting for Gearing Ratio {0}/{1}\n", numerator, denominator);

                master.MoveSCurve(POSITION2,                                                        // New Position.
                                  VELOCITY,
                                  ACCELERATION,
                                  DECELERATION,
                                  JERK_PERCENT);                                                // Perform a S-curve motion on the master axis again.

                master.MotionDoneWait();                                                        // Wait for motion to finish.

                Console.WriteLine("\nDisable Gearing\n");

                slave.GearingDisable();                                                         // Disable gearing on the slave.
                master.AmpEnableSet(true);                                                      // Disable the motor.
                slave.AmpEnableSet(true);

                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();
        }