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();
        }
Esempio n. 2
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();
        }
Esempio n. 3
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();
        }
Esempio n. 4
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.
            }
        }
Esempio n. 5
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.
        }
        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();
        }
Esempio n. 7
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();
        }
Esempio n. 8
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();
        }
Esempio n. 9
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)

            // 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
            {
                // Get Axis Ready for Motion

                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.DefaultVelocitySet(1);                                                         // Specify velocity.
                axis.DefaultAccelerationSet(10);                                                    // Specify acceleration.
                axis.DefaultDecelerationSet(10);                                                    // Specify deceleration.
                axis.FeedRateSet(1);                                                                // Make sure the FeedRate has its default value.

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


                // Start Motion
                Console.WriteLine("Motion Start");
                axis.MoveSCurve(15);                                                                // Call MoveScurve to move to a position.

                while (axis.ActualPositionGet() < 10)
                {
                }                                                                                   // Wait here until we reach position "15".

                axis.Stop();                                                                        // Stop the axis/motor.
                axis.MotionDoneWait();                                                              // Wait for move to complete.
                axis.FeedRateSet(-1);                                                               // Change FeedRate to reverse motion.
                axis.Resume();                                                                      // Start Reverse Motion.

                Console.WriteLine("New Feed Rate Start");

                while (axis.ActualPositionGet() > 5)
                {
                }                                                                                   // Wait here until we reach position "5".

                axis.Stop();                                                                        // Stop the axis/motor.
                axis.MotionDoneWait();                                                              // Wait for move to complete.
                axis.FeedRateSet(1);                                                                // Change FeedRate to default value.
                axis.Resume();                                                                      // Resume the MoveScurve Motion.

                Console.WriteLine("New Feed Rate Start");

                axis.MotionDoneWait();                                                              // Wait for move to complete.
                axis.AmpEnableSet(true);                                                            // Disable axis/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();
        }
Esempio n. 10
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();
        }
Esempio n. 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)
            const int RELATIVE_POSITION = 50;      // Specify which position to travel to.
            const int VELOCITY          = 10;      // Specify your velocity - units: Units/Sec     (it will do "10485760 counts/10 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^3
            const int FINAL_VELOCITY    = 5;       // Specify your final velocity - units: Units/Sec

            // 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. (Function logic at the bottom of source code)

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

                Console.WriteLine("\nFinal Velocity Example");
                Console.WriteLine("\nSCurve Motion in progress...\n");

                axis.MoveSCurve(RELATIVE_POSITION,                                              // Command an SCurve move with a final velocity of FINAL_VELOCITY.
                                VELOCITY,
                                ACCELERATION,                                                   // Once the commanded position has been reached, the motor will begin
                                DECELERATION,                                                   // spinning with a speed of FINAL_VELOCITY, and continue to spin at that
                                JERK_PCT,                                                       // velocity until stopped.
                                FINAL_VELOCITY);

                controller.OS.Sleep(8000);                                                      // Motion should take 8 seconds to complete.


                Console.WriteLine("\nSCurve Motion Done\n");
                Console.WriteLine("\nMotor now spinning at a speed of " + axis.ActualVelocityGet() + " revs/sec\n");

                controller.OS.Sleep(2500);                                                      // Let the axis spin for 2.5 seconds before stopping.

                Console.WriteLine("\nMotor Stopped\n");
                axis.Abort();                                                                   // Stop the motion.
                axis.AmpEnableSet(false);                                                       // Disable the axis.
                axis.ClearFaults();                                                             // Clear any faults so the axis is ready to be used again.
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.WriteLine("\nPress Any Key To Exit");                                       // Allow time to read Console.
            Console.ReadKey();
        }
Esempio n. 12
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();
        }
Esempio n. 13
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 TOTAL_POINTS = 4;                        // total number of points
            const int EMPTY_CT     = -1;                       // Number of points that remains in the buffer before an e-stop
            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

            double[] positions       = { 1.0, 2.0, 3.0, 4.0 }; // These will be the streaming motion 5 positions.
            double[] times           = { 0.5, 1.0, 2.0, 4.0 }; // These will be the streaming motion 5 positions' time.
            int      outputEnableID  = 2;                      // The motion element ID at which to set the output
            int      outputDisableID = 3;                      // The motion element ID at which to set the output

            // 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.PositionSet(0);                                                            // Make sure motor starts at position 0 everytime.
                axis.UserUnitsSet(USER_UNITS);                                                  // Change your user units.
                axis.Abort();                                                                   // If there is any motion happening, abort it.
                axis.ClearFaults();                                                             // Clear faults.
                axis.AmpEnableSet(true);                                                        // Enable the motor.

                // Set up the inputs

                //IOPoint output0 = IOPoint.CreateDigitalOutput(axis, RSIMotorGeneralIo.RSIMotorGeneralIo16);      // Retrieve DOUT 1, Method 1: requires you know the io adress in memory, slightly faster
                IOPoint output0 = IOPoint.CreateDigitalOutput(controller.IOGet(NODE_INDEX), OUTPUT_INDEX); // Retrieve DOUT 1  Method 2: only need to know node index
                output0.Set(false);                                                                        // Set the output low

                // Set up Sync Outputs

                axis.StreamingOutputsEnableSet(true);                                                               // Enable streaming output.

                // ENABLE the Sync Output(s)

                axis.StreamingOutputAdd(output0, true, outputEnableID);                                             // This will turn DOUT1 High when the streaming motion reaches its 3rd motion point.
                axis.StreamingOutputAdd(output0, false, outputDisableID);                                           // This will turn DOUT1 Low when the streaming motion reaches its 4th motion point.

                // DISABLE the Sync Output(s)

                //axis.StreamingOutputAdd(output0, false, outPutEnableID);

                axis.MovePT(RSIMotionType.RSIMotionTypePT, positions, times, TOTAL_POINTS, EMPTY_CT, false, true);  // Start Streaming Motion
                Console.WriteLine("Motion started. Waiting to complete.\n");

                axis.MotionDoneWait();                                                                              // What for Streaming Motion to be done.
                Console.WriteLine("Motion Complete. The outputs should have been set\n");

                axis.StreamingOutputsEnableSet(false);                                                              // Disable Sync Outputs.
                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();
        }
        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);
            }
        }
Esempio n. 15
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 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();
        }
Esempio n. 17
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();
        }
Esempio n. 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();
        }
Esempio n. 19
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();
        }