예제 #1
0
        /// <summary>
        ///     绝对坐标走位
        /// </summary>
        /// <param name="nCardNum"></param>
        /// <param name="nAxis">轴号</param>
        /// <param name="dPos">位置,脉冲为单位</param>
        /// <param name="dVel">速度</param>
        /// <param name="dAcce">加减速度</param>
        /// <returns></returns>
        public override short AbsMove(short nCardNum, short nAxis, int dPos, double dVel, double dAcce)
        {
            short nRtn = 0;

            if (nAxis > m_maxAxisNum)
            {
                return(-1);
            }

            //lock (m_lockMove)
            int sts;

            //获取标志位状态
            nRtn |= CMc.GT_GetSts(nCardNum, nAxis, out sts, 1, out m_oClk);


            if ((sts & 0x400) == 0) //该轴必须静止
            {
                //设定Trap运动模式,失败则返回

                int mode;
                nRtn |= CMc.GT_GetPrfMode(nCardNum, nAxis, out mode, 1, out m_oClk);


                if (mode != 0)
                {
                    nRtn |= CMc.GT_ClrSts(nCardNum, nAxis, 1);

                    nRtn |= CMc.GT_PrfTrap(nCardNum, nAxis);
                }
            }

            //设定Trap运动参数

            CMc.TRAP_PRM trap;
            trap.m_acc        = dAcce;
            trap.m_dec        = dAcce;
            trap.m_velStart   = 0;
            trap.m_smoothTime = 10;
            nRtn |= CMc.GT_SetTrapPrm(nCardNum, nAxis, ref trap);


            //开始运动

            nRtn |= CMc.GT_SetPos(nCardNum, nAxis, dPos);

            nRtn |= CMc.GT_SetVel(nCardNum, nAxis, dVel);

            nRtn |= CMc.GT_Update(nCardNum, 1 << (nAxis - 1));

            return(nRtn);
        }
예제 #2
0
        /// <summary>
        ///     JOG移动
        /// </summary>
        /// <param name="nCardNum"></param>
        /// <param name="nAxis">轴号</param>
        /// <param name="dVel"></param>
        /// <param name="dAcce"></param>
        /// <returns></returns>
        public override short JogMove(short nCardNum, short nAxis, double dVel, double dAcce)
        {
            short nRtn = 0;

            if (nCardNum < 0 || nAxis > m_maxAxisNum)
            {
                return(-1);
            }

            //获取标志位状态

            nRtn |= CMc.GT_ClrSts(nCardNum, 1, m_maxAxisNum);


            int sts;

            nRtn |= CMc.GT_GetSts(nCardNum, nAxis, out sts, 1, out m_oClk);

            int mode;

            nRtn |= CMc.GT_GetPrfMode(nCardNum, nAxis, out mode, 1,
                                      out m_oClk); //mode值  //0:trap 1:Jog 2:S 3:PT 4:PVS 5:interpolation 6:gear


            if ((sts & 0x400) != 0) //运动情况下可以改变速度和加速度
            {
                if (1 != mode)
                {
                    return(nRtn);
                }
            }
            else //静止情况下才能修改运动模式
            {
                if (1 != mode)
                {
                    nRtn |= CMc.GT_PrfJog(nCardNum, nAxis);
                }
            }

            //设置Jog运动参数
            CMc.JOG_PRM jogPrm;
            jogPrm.m_acc    = dAcce; //加速度,单位“脉冲/毫秒2”
            jogPrm.m_dec    = dAcce; //减速度,单位“脉冲/毫秒2”
            jogPrm.m_smooth = 0.625; //平滑系数,取值范围[0,1]
            nRtn           |= CMc.GT_SetJogPrm(nCardNum, nAxis, ref jogPrm);

            //启动运动
            nRtn |= CMc.GT_SetVel(nCardNum, nAxis, dVel); //设置目标速度,单位是“脉冲/毫秒”
            nRtn |= CMc.GT_Update(nCardNum, 1 << (nAxis - 1));
            return(nRtn);
        }