コード例 #1
0
        public short MoveJog(short cardId, short axisId, double vel, double acc)
        {
            //set jog move
            short rtn = mc.API_JogMode(axisId, cardId);

            if (rtn != 0)
            {
                return(rtn);
            }
            mc.TJogPrm jogPrm = new mc.TJogPrm();
            jogPrm.acc = acc;
            jogPrm.dec = acc;
            //set jog param
            rtn = mc.API_SetJogPrm(axisId, ref jogPrm, cardId);
            if (rtn != 0)
            {
                return(rtn);
            }
            //set vel
            rtn = mc.API_SetVel(axisId, vel, cardId);
            if (rtn != 0)
            {
                return(rtn);
            }
            //start move
            int mask = 1 << (axisId - 1);

            rtn = mc.API_Update(mask, cardId);
            if (rtn != 0)
            {
                return(rtn);
            }
            return(0);
        }
コード例 #2
0
        public short MoveJog(short cardId, short axisId, double vel, double acc)
        {
            //set jog move
            short rtn = mc.GT_PrfJog(cardId, axisId);

            if (rtn != 0)
            {
                return(rtn);
            }
            mc.TJogPrm jogPrm = new mc.TJogPrm();
            jogPrm.acc = acc;
            jogPrm.dec = acc;
            //set jog param
            rtn = mc.GT_SetJogPrm(cardId, axisId, ref jogPrm);
            if (rtn != 0)
            {
                return(rtn);
            }
            //set vel
            rtn = mc.GT_SetVel(cardId, axisId, vel);
            if (rtn != 0)
            {
                return(rtn);
            }
            //start move
            rtn = mc.GT_Update(cardId, 1 << (axisId - 1));
            if (rtn != 0)
            {
                return(rtn);
            }
            return(0);
        }
コード例 #3
0
        public static void GoHome(short axi, short card)
        {
            mc.TJogPrm jopPra = new mc.TJogPrm();
            jopPra.acc = 0.25;
            jopPra.dec = 0.25;
            double value = 20;

            AxiCondition.AxiSituation axiSituation = new AxiCondition.AxiSituation();
            JogMotin(0, 1, jopPra, -value);
            do
            {
                axiSituation = AxiCondition.JustReadCondition(axi, card);
            }while (axiSituation.negativeLimit == false);

            mc.TTrapPrm p_trap = new mc.TTrapPrm();
            p_trap.acc        = 0.25;
            p_trap.dec        = 0.25;
            p_trap.smoothTime = 25;
            p_trap.velStart   = 1;

            TrapParameter setTrapParameter = new TrapParameter();

            setTrapParameter.position = 10000;
            setTrapParameter.sleep    = 20;
            Trap(true, p_trap, setTrapParameter, axi);
        }
コード例 #4
0
        public static void JogMotin(short cardNumber, short AXIS, mc.TJogPrm p_jog, double velocity)
        {
            short sRtn;

            mc.TJogPrm jog = new mc.TJogPrm();
            long       sts;
            double     prfPos, prfVel;

            // 清除各轴的报警和限位
            sRtn = mc.GT_ClrSts(cardNumber, 1, 8);
            Config.commandhandler("GT_ClrSts", sRtn);

            // 伺服使能
            sRtn = mc.GT_AxisOn(cardNumber, AXIS);
            Config.commandhandler("GT_AxisOn", sRtn);

            // 将AXIS轴设为Jog模式
            sRtn = mc.GT_PrfJog(cardNumber, AXIS);
            Config.commandhandler("GT_PrfTrap", sRtn);
            // 读取Jog运动参数
            sRtn = mc.GT_GetJogPrm(cardNumber, AXIS, out jog);
            Config.commandhandler("GT_GetJogPrm", sRtn);
            jog.acc = p_jog.acc;
            jog.dec = p_jog.dec;
            // 设置Jog运动参数
            sRtn = mc.GT_SetJogPrm(cardNumber, AXIS, ref jog);
            Config.commandhandler("GT_SetJogPrm", sRtn);
            // 设置AXIS轴的目标速度
            sRtn = mc.GT_SetVel(cardNumber, AXIS, velocity);
            Config.commandhandler("GT_SetVel", sRtn);
            // 启动AXIS轴的运动
            sRtn = mc.GT_Update(cardNumber, 1 << (AXIS - 1));
            Config.commandhandler("GT_Update", sRtn);
        }
コード例 #5
0
        private void button5_MouseDown(object sender, MouseEventArgs e)
        {
            mc.TJogPrm jopPra = new mc.TJogPrm();
            jopPra.acc = 0.25;
            jopPra.dec = 0.25;
            double value = Convert.ToDouble(numericUpDown3.Value);

            MotionPunction.JogMotin(0, 1, jopPra, -value);
        }
コード例 #6
0
        private short JogHome(int nAxisNo, bool bPositive, double vel)
        {
            nAxisNo += 1;
            short sRtn = 0;

            sRtn |= gts.mc.GT_ClrSts((short)m_nCardIndex, (short)nAxisNo, 1);
            sRtn |= gts.mc.GT_Stop((short)m_nCardIndex, 1 << (nAxisNo - 1), 0);
            sRtn |= gts.mc.GT_PrfJog((short)m_nCardIndex, (short)nAxisNo);
            gts.mc.TJogPrm jogparam = new mc.TJogPrm();
            sRtn        |= gts.mc.GT_GetJogPrm((short)m_nCardIndex, (short)nAxisNo, out jogparam);
            jogparam.acc = 0.1;
            jogparam.dec = 0.1;
            sRtn        |= gts.mc.GT_SetJogPrm((short)m_nCardIndex, (short)nAxisNo, ref jogparam);
            sRtn        |= gts.mc.GT_SetVel((short)m_nCardIndex, (short)nAxisNo, bPositive ? (double)vel : (double)-vel);
            sRtn        |= gts.mc.GT_Update((short)m_nCardIndex, 1 << (nAxisNo - 1));
            return(sRtn);
        }
コード例 #7
0
        private void button7_Click(object sender, EventArgs e)
        {
            mc.TJogPrm jopPra = new mc.TJogPrm();
            jopPra.acc = 0.25;
            jopPra.dec = 0.25;
            double value = Convert.ToDouble(numericUpDown1.Value);

            while (true)
            {
                MotionPunction.JogMotin(0, 1, jopPra, value);
                AxiCondition.AxiSituation axiSituation = new AxiCondition.AxiSituation();
                axiSituation = AxiCondition.JustReadCondition(1, 0);
                if (axiSituation.negativeLimit || axiSituation.positveLimit)
                {
                    MotionPunction.GoSafetyPosition(1, 0);
                    break;
                }
            }
        }