Exemplo n.º 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);
        }
Exemplo n.º 2
0
        /// <summary>
        ///     设置Trap运动参数
        /// </summary>
        /// <param name="nCardNum"></param>
        /// <param name="nAxis">轴号</param>
        /// <param name="acc">加速度 单位“脉冲/毫秒2”</param>
        /// <param name="dec">减速度 单位“脉冲/毫秒2”</param>
        /// <param name="smoothTime">平滑系数,取值范围[0,1]</param>
        /// <returns></returns>
        public override short SetTrapPrm(short nCardNum, short nAxis, double acc, double dec, short smoothTime = 5)
        {
            short nRtn = 0;
            //设置Jog运动参数
            var mytprfvel = new CMc.TRAP_PRM();

            mytprfvel.m_acc        = acc;        //加速度,单位“脉冲/毫秒2”
            mytprfvel.m_dec        = dec;        //减速度,单位“脉冲/毫秒2”
            mytprfvel.m_smoothTime = smoothTime; //平滑时间,取值范围[0,1]
            nRtn |= CMc.GT_SetTrapPrm(nCardNum, nAxis, ref mytprfvel);


            return(nRtn);
        }