Esempio n. 1
0
 public static void GoSafetyPosition(short axi, short card)
 {
     AxiCondition.AxiSituation axiSituation = new AxiCondition.AxiSituation();
     axiSituation = AxiCondition.readCondition(axi, card);
     if (axiSituation.negativeLimit == true)
     {
         mc.TTrapPrm p_trap = new mc.TTrapPrm();
         p_trap.acc        = 0.25;
         p_trap.dec        = 0.25;
         p_trap.smoothTime = 25;
         TrapParameter setTrapParameter = new TrapParameter();
         setTrapParameter.position = 5000;
         setTrapParameter.sleep    = 20;
         Trap(true, p_trap, setTrapParameter, axi);
     }
     else if (axiSituation.positveLimit == true)
     {
         mc.TTrapPrm p_trap = new mc.TTrapPrm();
         p_trap.acc        = 0.25;
         p_trap.dec        = 0.25;
         p_trap.smoothTime = 25;
         TrapParameter setTrapParameter = new TrapParameter();
         setTrapParameter.position = -5000;
         setTrapParameter.sleep    = 20;
         Trap(true, p_trap, setTrapParameter, axi);
     }
 }
Esempio n. 2
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);
        }
Esempio n. 3
0
        //trap运动
        public static void Trap(bool positive, mc.TTrapPrm p_trap, TrapParameter setTrapParameter, short axi)
        {
            int   AxiStatus;
            uint  pClock;
            short sRtn = mc.GT_GetSts(0, axi, out AxiStatus, 1, out pClock);

            if ((AxiStatus & 0x2) == 0x2 && (AxiStatus & 0x20) == 0x20)
            {
                Config.commandhandler("伺服报警或处于正限位", sRtn);
            }
            else
            {
                mc.TTrapPrm trap = new mc.TTrapPrm();
                //清除各轴的报警和限位
                sRtn = mc.GT_ClrSts(0, axi, 1);
                if (sRtn != 0)
                {
                    Config.commandhandler("清除出错", sRtn);
                }
                // 伺服使能
                sRtn = mc.GT_AxisOn(0, axi);
                if (sRtn != 0)
                {
                    Config.commandhandler("使能出错", sRtn);
                }
                // 位置清零
                sRtn = mc.GT_ZeroPos(0, axi, 1);
                if (sRtn != 0)
                {
                    Config.commandhandler("位置清零出错", sRtn);
                }
                // AXIS轴规划位置清零
                sRtn = mc.GT_SetPrfPos(0, axi, 0);
                if (sRtn != 0)
                {
                    Config.commandhandler("规划出错", sRtn);
                }
                // 将AXIS轴设为点位模式
                sRtn = mc.GT_PrfTrap(0, axi);
                if (sRtn != 0)
                {
                    Config.commandhandler("设置模式出错", sRtn);
                }
                // 读取点位运动参数
                sRtn = mc.GT_GetTrapPrm(0, axi, out trap);
                if (sRtn != 0)
                {
                    Config.commandhandler("读取参数出错", sRtn);
                }
                trap.acc        = p_trap.acc;
                trap.dec        = p_trap.dec;
                trap.smoothTime = p_trap.smoothTime;
                // 设置点位运动参数
                sRtn = mc.GT_SetTrapPrm(0, axi, ref trap);
                if (sRtn != 0)
                {
                    Config.commandhandler("设置参数出错", sRtn);
                }
                // 设置AXIS轴的目标位置
                int posation = Convert.ToInt32(setTrapParameter.position);
                sRtn = mc.GT_SetPos(0, axi, posation);
                if (sRtn != 0)
                {
                    Config.commandhandler("设置位置出错", sRtn);
                }
                // 设置AXIS轴的目标速度
                double 速度 = Convert.ToDouble(setTrapParameter.sleep);
                sRtn = mc.GT_SetVel(0, axi, 速度);
                if (sRtn != 0)
                {
                    Config.commandhandler("设置速度出错", sRtn);
                }
                // 启动AXIS轴的运动
                sRtn = mc.GT_Update(0, 2 ^ axi);
                if (sRtn != 0)
                {
                    Config.commandhandler("启动运动出错", sRtn);
                }
            }
        }