雷赛运动控制卡例子

        #region 自动运行流程
        private void AutoRunProcess()
        {
   
   
            AddLog(0, "系统归零完成,等待触发");

            //初始化当前步骤
            CurrentStep = RunStep.RunReady;

            bool fRun = false;

            bool fOver = false;

            int Error = 0;

            int CycleTimes = 0;

            while (true)
            {
   
   
                //检测是否按下启动信号
                int start = Dmc2410.d2410_read_inbit(0, 2);

                if (start == 0)
                {
   
   
                    fRun = true;
                    CurrentStep = RunStep.MoveToReclaimer;
                }

                if (fRun)
                {
   
   
                    AddLog(0, "系统开始生产...");

                    MySQLHelper.Log("系统开始生产...", 0, CommonMethods.objAdmin.LoginName);

                    fRun = false;

                    SysStatus = 1;

                    while (true)
                    {
   
   
                        switch (CurrentStep)
                        {
   
   
                            case RunStep.MoveToReclaimer:

                                UpdateStep("1:前往取料口");

                                if (CycleTimes == 0)
                                {
   
   
                                    Dmc2410.d2410_set_position(XAxis, 0); // 指定轴号, 绝对位置值
                                    Dmc2410.d2410_set_position(YAxis, 0);
                                    //设置直线插补的参数
                                    /*
                                     void d2410_set_vector_profile(double Min_Vel,double Max_Vel,double Tacc,
                                    double Tdec)
                                    功 能:设定插补矢量运动曲线的起始速度、运行速度、加速时间、减速时间
                                    参 数:Min_Vel  起始速度,单位 pps  pps,pulse per second ,用来表示步进电机的转速
                                    Max_Vel  运行速度,单位 pps
                                    Tacc  总加速时间,单位 s
                                    Tdec 总减速时间,单位 s
                                     */
                                    Dmc2410.d2410_set_vector_profile(objConfig.VelMin, objConfig.VelMax, objConfig.Tac, objConfig.Tac);
                                    //指定任意两轴以对称的梯形速度曲线做插补运动
                                    /*
                                    void d2410_t_line2(WORD axis1,long Dist1,WORD axis2,long Dist2,WORD
                                    posi_mode)
                                    功 能:指定任意两轴以对称的梯形速度曲线做插补运动
                                    参 数:axis1 指定两轴插补的第一轴
                                    axis2 指定两轴插补的第二轴
                                    Dist1 指定 axis1 的位移值,单位:脉冲数
                                    Dist2 指定 axis2 的位移值,单位:脉冲数
                                    posi_mode 位移模式设定:0 表示相对位移,1 表示绝对位移
                                    返回值:无
                                     */
                                    Dmc2410.d2410_t_line2(XAxis, objConfig.OrginX, YAxis, objConfig.OrginY, 0);

                                }
                                else
                                {
   
   
                                    //设置直线插补的参数
                                    Dmc2410.d2410_set_vector_profile(objConfig.VelMin, objConfig.VelMax, objConfig.Tac, objConfig.Tac);

                                    Dmc2410.d2410_t_line2(XAxis, objConfig.OutletX, YAxis, objConfig.OutletY, 0);
                                }
                                /*
                                 WORD d2410_check_done(WORD axis)
                                功 能:检测指定轴的运动状态,停止或是在运行中。
                                参 数:axis  指定轴号
                                返回值:0 表示指定轴正在运行,1 表示指定轴已停止。
                                 */
                                while (Dmc2410.d2410_check_done(XAxis) == 0 || Dmc2410.d2410_check_done(YAxis) == 0)
                                {
   
   
                                    if (IsAutoStop)
                                    {
   
   
                                        fOver = true;
                                        break;
                                    }
                                    Thread.Sleep(10);
                                }

                                if (CycleTimes > 0)
                                {
   
   
                                    Invoke(new Action(() =>
                                    {
   
   
                                        this.pointCurve1.ClearAllPoints();
                                    }));
                                
                                }

                                break;
                            case RunStep.ReclaimerWait:

                                //实际项目在这里需要检测是否有料

                                UpdateStep("2:检测是否有料");

                                Thread.Sleep(2000);

                                break;
                            case RunStep.ReclaimerDown:

                                UpdateStep("3:取料口下降");

                                Dmc2410.d2410_set_position(ZAxis, 0);

                                Dmc2410.d2410_set_st_profile(ZAxis, objConfig.VelMin, objConfig.VelMax, objConfig.Tac, objConfig.Tac, objConfig.STac, objConfig.STac);
                                /*
                                 void d2410_s_pmove(WORD axis,long Dist,WORD posi_mode)
                                功 能:使指定轴以对称 S 形速度曲线做定长位移运动
                                参 数:axis  指定轴号
                                Dist  (绝对/相对)位移值,单位:脉冲数
                                posi_mode 位移模式设定:0 表示相对位移,1 表示绝对位移
                                 */
                                Dmc2410.d2410_s_pmove(ZAxis, objConfig.DownZAxis, 0);

                                while (Dmc2410.d2410_check_done(ZAxis) == 0)
                                {
   
   
                                    if (IsAutoStop)
                                    {
   
   
                                        fOver = true;
                                        break;
                                    }
                                    Thread.Sleep(10);
                                }
                                break;
                            case RunStep.ReclaimerGrap:

                                UpdateStep(
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

潘诺西亚的火山

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值