Example #1
0
        static void Main(string[] args)
        {
            // Constants
            const int    AXIS_NUMBER             = 0;       // Specify which axis/motor to control.
            const double STOP_RATE_DEFAULT       = 1.0;     // Specify the default STOP rate in seconds.
            const double ESTOP_RATE_DEFAULT      = 0.05;    // Specify the default ESTOP rate in seconds.
            const double ESTOP_DECELERATION_RATE = 1000;    // Specify the default ESTOP deceleration rate in seconds.


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

            SampleAppsCS.HelperFunctions.CheckErrors(controller);                                    // [Helper Function] Verify the controller has started correctly.

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

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

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

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

                Console.WriteLine("NEW: StopRate = " + Math.Round(axis.StopTimeGet(), 4) + "\t\teStopRate = " + Math.Round(axis.EStopTimeGet(), 4) + "\n" + "\t\tDecelRate = " + Math.Round(axis.EStopDecelerationGet(), 4) + "\n");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.WriteLine("\nPress Any Key To Exit");                                         // Allow time to read Console.
            Console.ReadKey();
        }
Example #2
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();
        }