Пример #1
0
        //绝对值移动
        public int  AbsoluteMove(int axisNo, double position, double maxSpeed)
        {
            SetAxisParam(axisNo, 36, maxSpeed);
            var wait = new ASYNCALL();
            var ret  = APS168.APS_ptp(axisNo, 0, position, ref wait);

            return(ret);
        }
Пример #2
0
        /// <summary>
        /// 两轴圆弧插补轨迹移动
        /// </summary>
        /// <param name="axisNo1">轴1ID</param>
        /// <param name="axisNo2">轴2ID</param>
        /// <param name="centreNum1">圆心1</param>
        /// <param name="centreNum2">圆心2</param>
        /// <param name="endNum1">终点1</param>
        /// <param name="endNum2">终点1</param>
        /// <param name="dir">方向</param>
        /// <param name="velocityCurveParams">速度参数</param>
        /// <param name="Option">位集指定选项,该选项可以启用指定的参数和函数。</param>
        public void MoveArc2(int axisNo1, int axisNo2, double centreNum1, double centreNum2, double endNum1, double endNum2, short dir, VelocityCurve velocityCurveParams, int Option)
        {
            var      axis     = new int[2];
            var      pos1     = new double[2];
            var      pos2     = new double[2];
            double   TranPara = 0;
            ASYNCALL wait     = new ASYNCALL();

            axis[0] = axisNo1;
            axis[1] = axisNo2;
            pos1[0] = centreNum1;
            pos1[1] = centreNum2;

            //设置速度
            SetAxisVelocity(axisNo1, velocityCurveParams);
            //启动运动
            APS168.APS_arc2_ce_all(axis, Option, pos1, pos2, dir, ref TranPara, velocityCurveParams.Strvel, velocityCurveParams.Maxvel, velocityCurveParams.Strvel, velocityCurveParams.Svacc, velocityCurveParams.Svdec, velocityCurveParams.Sfac, ref wait);
        }
Пример #3
0
        /// <summary>
        /// 两轴直线插补轨迹移动
        /// </summary>
        /// <param name="axisNo1">轴1ID</param>
        /// <param name="axisNo2">轴2ID</param>
        /// <param name="pulseNum1">坐标1</param>
        /// <param name="pulseNum2">坐标2</param>
        /// <param name="velocityCurveParams">速度参数</param>
        /// <param name="Option">位集指定选项,该选项可以启用指定的参数和函数。</param>
        public void MoveLine2(int axisNo1, int axisNo2, double pulseNum1, double pulseNum2,
                              VelocityCurve velocityCurveParams, int Option)
        {
            var      axis      = new int[2];
            var      pos       = new double[2];
            double   TransPara = 0;
            ASYNCALL wait      = new ASYNCALL(); //A waiting call

            axis[0] = axisNo1;
            axis[1] = axisNo2;
            pos[0]  = pulseNum1;
            pos[1]  = pulseNum2;

            //设置速度
            SetAxisVelocity(axisNo1, velocityCurveParams);
            //启动运动
            APS168.APS_line_all(2, axis, Option, pos, ref TransPara, velocityCurveParams.Strvel, velocityCurveParams.Maxvel, velocityCurveParams.Strvel, velocityCurveParams.Svacc, velocityCurveParams.Svdec, velocityCurveParams.Sfac, ref wait);
        }
Пример #4
0
        /// <summary>
        /// Velocity move(speed_1 = 200.0).
        /// </summary>
        /// <param name="dir">The direction.</param>
        public override void VelocityMove(Int32 dir)
        {
            Int32    Option = dir;   //0: Positive direction   1:negative direction
            ASYNCALL p      = new ASYNCALL();
            double   speed  = 200.0; //1000-2000 may be the final selection speed

            APS168.APS_set_axis_param_f(mCardPara.AxisID, (Int32)APS_Define.PRA_STP_DEC, 1000000.0);
            APS168.APS_set_axis_param_f(mCardPara.AxisID, (Int32)APS_Define.PRA_CURVE, 0.5);     //Set acceleration rate
            APS168.APS_set_axis_param_f(mCardPara.AxisID, (Int32)APS_Define.PRA_ACC, 1000000.0); //Set acceleration rate
            APS168.APS_set_axis_param_f(mCardPara.AxisID, (Int32)APS_Define.PRA_DEC, 1000000.0); //Set deceleration rate

            //go
            APS168.APS_vel(mCardPara.AxisID, Option, speed, ref p);
            if (dir == 0)
            {
                this.currentDirection = MotionDirection.Returning;
            }
            else
            {
                this.currentDirection = MotionDirection.Pressing;
            }
        }
Пример #5
0
        /// <summary>
        /// Point to point move.
        /// </summary>
        /// <param name="dir">The direction.</param>
        /// <param name="distance">The distance.</param>
        public override void PtpMove(Int32 dir, Int32 distance)
        {
            int      err    = -1;
            Int32    Option = dir;      //0: Positive direction   1:negative direction
            ASYNCALL p      = new ASYNCALL();

            //err = APS168.APS_set_axis_param_f(Axis_ID, (Int32)APS_Define.PRA_CURVE, 0.5);
            //if (err != (Int32)APS_Define.ERR_NoError) return;
            //err = APS168.APS_set_axis_param_f(Axis_ID, (Int32)APS_Define.PRA_ACC, 1000000.0);
            //if (err != (Int32)APS_Define.ERR_NoError) return;
            //err = APS168.APS_set_axis_param_f(Axis_ID, (Int32)APS_Define.PRA_DEC, 1000000.0);
            //if (err != (Int32)APS_Define.ERR_NoError) return;
            //err = APS168.APS_set_axis_param_f(Axis_ID, (Int32)APS_Define.PRA_VM, 100000.0);
            //if (err != (Int32)APS_Define.ERR_NoError) return err;

            int pos    = 0;
            int prePos = 0;
            int refPos = 0;

            if (Option == 0)
            {
                distance *= -1;
            }
            //System.Threading.Thread.Sleep(10);

            //if (dir == 0)
            //{
            //    int motionStatus = 0;
            //    do{
            //        motionStatus = APS168.APS_motion_io_status(Axis_ID);
            //        if (motionStatus!=128)
            //             motionStatus =0;
            //        motionStatus &= 0x40;
            //        motionStatus = motionStatus >> 6;
            //        } while (motionStatus != 1);
            //}

            //err = APS168.APS_get_position(Axis_ID, ref refPos);
            err = APS168.APS_get_position(mCardPara.AxisID, ref prePos);
            do
            {
                if (prePos != refPos)
                {
                    prePos = refPos;
                }
                APS168.APS_get_position(mCardPara.AxisID, ref refPos);
                System.Threading.Thread.Sleep(4);
            } while (prePos != refPos);


            if (err != (Int32)APS_Define.ERR_NoError)
            {
                return;
            }

            if (dir == 0)
            {
                this.currentDirection = MotionDirection.Returning;
            }
            else
            {
                this.currentDirection = MotionDirection.Pressing;
            }

            err = APS168.APS_ptp_all(mCardPara.AxisID, 0, refPos - distance, 0.0, 3000.0, 0.0, 10000000.0, 10000000.0, 0.5, ref p);
            //err = APS168.APS_absolute_move(Axis_ID, refPos - distance, 600);
            if (err != (Int32)APS_Define.ERR_NoError)
            {
                return;
            }

            if (this.currentDirection == MotionDirection.Returning)
            {
                do
                {
                    APS168.APS_get_position(mCardPara.AxisID, ref pos);
                    System.Threading.Thread.Sleep(1);
                } while (pos != refPos - distance && this.currentDirection != MotionDirection.Stop);
                this.currentDirection = MotionDirection.Stop;
            }

            return;
        }