Ejemplo n.º 1
0
        public bool StopMove(short Axis)
        {
            int rtn = 0;

            bHomeStop[Axis] = true;
            try
            {
                if (Axis < 8 && Axis > -1)
                {
                    lock (lockObj)
                    {
                        rtn = cmApi.Motion.Stop(Axis);
                        if (rtn != 0)
                        {
                            string errorCode = "";
                            errorCode = WMX3Api.ErrorToString(rtn);
                            //  Global.logger.ErrorFormat("WMX3 轴{0}停止失败!错误信息:{1}", Axis, errorCode);
                            return(false);
                        }
                    }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                //   Global.logger.ErrorFormat("WMX3 轴{0}停止异常!异常信息:{1}", Axis, ex.Message);
                return(false);
            }
        }
Ejemplo n.º 2
0
        public bool JogMove(short Axis, double dAcc, double dDec, double dVel)
        {
            if (!bInitOK)
            {
                return(false);
            }

            lock (lockObj)
            {
                s_JogCommand.Axis             = Axis;               //运动的轴号
                s_JogCommand.Profile.Type     = ProfileType.SCurve; //运动曲线类型,建议用SCurve
                s_JogCommand.Profile.Velocity = dVel;               //运动速度
                s_JogCommand.Profile.Acc      = dAcc / 0.001;       //运动加速度
                s_JogCommand.Profile.JerkAcc  = dAcc / 0.001;       //运动加加速(加速度的加速度)
                s_JogCommand.Profile.Dec      = dDec / 0.001;       //运动减速度
                s_JogCommand.Profile.JerkDec  = dDec / 0.001;       //运动减减速(减速度的加速度)
                int rtn = 0;
                rtn = cmApi.Motion.StartJog(s_JogCommand);

                if (rtn != 0)
                {
                    string errorCode = "";
                    errorCode = WMX3Api.ErrorToString(rtn);
                    //     Global.logger.ErrorFormat("WMX3初始化失败!错误信息:{0}", errorCode);
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 3
0
 public SoftservoControler()
 {
     wmx                   = new WMX3Api();
     status                = new CoreMotionStatus();
     s_JogCommand          = new Motion.JogCommand();
     fx_PosBlock           = new Motion.PosCommand();
     fx_LinearIntplCommand = new Motion.LinearIntplCommand();
     fx_CenterAndEndCir    = new Motion.CenterAndEndCircularIntplCommand();
     fx_ThroughAndEnd      = new Motion.ThroughAndEndCircularIntplCommand();
 }
Ejemplo n.º 4
0
        public override bool Init(HardWareInfoBase infoHardWare)
        {
            int ret = wmx.CreateDevice(@"C:\Program Files\SoftServo\WMX3\", DeviceType.DeviceTypeNormal, 0);

            if (ret != 0)
            {
                string errorCode = "";
                errorCode = WMX3Api.ErrorToString(ret);
                // Global.logger.ErrorFormat("WMX3初始化失败!错误信息:{0}", errorCode);
                //return false;
            }
            else
            {
                bInitOK = true;
            }
            //建立通讯
            Thread thread = new Thread(new ParameterizedThreadStart(EstablishCommunication));

            thread.IsBackground = true;
            thread.Start(infoHardWare);
            return(true);
        }
Ejemplo n.º 5
0
        public bool ArcMoveWithThroughAndEnd(short AxisX, short AxisY, short AxisZ, double dAcc, double dDec, double dSpeed, double endPosX, double endPosY, double throughPosX, double throughPosY)
        {
            try
            {
                int rtn = 0;
                fx_ThroughAndEnd.Axis[0]                  = AxisX;
                fx_ThroughAndEnd.Axis[1]                  = AxisY;
                fx_ThroughAndEnd.EndPos[0]                = endPosX;
                fx_ThroughAndEnd.EndPos[1]                = endPosY;
                fx_ThroughAndEnd.ThroughPos[0]            = throughPosX;
                fx_ThroughAndEnd.ThroughPos[1]            = throughPosY;
                fx_ThroughAndEnd.Profile.Acc              = dAcc / 0.001;
                fx_ThroughAndEnd.Profile.Dec              = dDec / 0.001;
                fx_ThroughAndEnd.Profile.Velocity         = dSpeed;
                fx_ThroughAndEnd.Profile.StartingVelocity = dSpeed;             //该参数确定加减速曲线的初始速度
                fx_ThroughAndEnd.Profile.SecondVelocity   = dSpeed;             //此参数确定加减速曲线的第二个速度
                fx_ThroughAndEnd.Profile.Type             = ProfileType.SCurve; //动作的曲线类型。SCurve:产生S形速度曲线。
                fx_ThroughAndEnd.Profile.EndVelocity      = dSpeed;
                fx_ThroughAndEnd.Profile.JerkAcc          = dAcc / 0.001;
                fx_ThroughAndEnd.Profile.JerkDec          = dDec / 0.001;
                rtn = cmApi.Motion.StartCircularIntplPos(fx_ThroughAndEnd);

                if (rtn != 0)
                {
                    string errorCode = "";
                    errorCode = WMX3Api.ErrorToString(rtn);
                    //   Global.logger.ErrorFormat("WMX3 执行 ThroughAndEndCircularIntplCommand 圆弧插补失败!错误信息:{0}", errorCode);
                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                //  Global.logger.ErrorFormat("WMX3 执行 ThroughAndEndCircularIntplCommand 圆弧插补出现异常!异常信息:{0}", ex.Message);
                return(false);
            }
        }
Ejemplo n.º 6
0
        public bool StartSearchLimit(short axis, double dAcc, double dDec, double dCatchSpeed)
        {
            bool sRtn;

            bHomeStop[axis] = false;
            bHomeDone[axis] = false;
            bHomeLast[axis] = false;
            if (axis < 8 && axis > -1)
            {
                lock (lockObj)
                {
                    s_JogCommand.Axis             = axis;               //运动的轴号
                    s_JogCommand.Profile.Type     = ProfileType.SCurve; //运动曲线类型,建议用SCurve
                    s_JogCommand.Profile.Velocity = dCatchSpeed;        //运动速度
                    s_JogCommand.Profile.Acc      = dAcc / 0.001;       //运动加速度
                    s_JogCommand.Profile.JerkAcc  = dAcc / 0.001;       //运动加加速(加速度的加速度)
                    s_JogCommand.Profile.Dec      = dDec / 0.001;       //运动减速度
                    s_JogCommand.Profile.JerkDec  = dDec / 0.001;       //运动减减速(减速度的加速度)
                    int rtn = 0;
                    rtn = cmApi.Motion.StartJog(s_JogCommand);

                    if (rtn != 0)
                    {
                        string errorCode = "";
                        errorCode = WMX3Api.ErrorToString(rtn);
                        //    Global.logger.ErrorFormat("WMX3初始化失败!错误信息:{0}", errorCode);
                        return(false);
                    }
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 建立通讯
        /// </summary>
        /// <param name="infoHardWare"></param>
        private void EstablishCommunication(object infoHardWare)
        {
            var softservoInfo = infoHardWare as SoftservoControlerInfo;
            int ret;

            Thread.Sleep(5000);

            cmApi           = new CoreMotion(wmx);
            fx_EventControl = new EventControl(wmx);
            fx_ApiBuffer    = new ApiBuffer(wmx);
            ecapi           = new EcApiLib(wmx);

            fx_ListMotion = new ListMotion(wmx);

            wmx_IO = new Io(wmx);
            //设置系统参数
            ret = cmApi.Config.ImportAndSetAll(softservoInfo.m_strConfigPath);
            if (ret != 0)
            {
                string errorCode = "";
                errorCode = WMX3Api.ErrorToString(ret);
                //  Global.logger.ErrorFormat("WMX3参数获取失败!错误信息:{0}", errorCode);
                //return false;
            }
            //开始进行通讯
            int wd_count = 0;

            do
            {
                ret = wmx.StartCommunication();//通讯函数
                Thread.Sleep(500);
                wd_count++;
                cmApi.GetStatus(ref status);
            } while ((status.EngineState == EngineState.Communicating) && (wd_count < 10));//确认是否通讯成功

            if (status.EngineState != EngineState.Communicating)
            {
                // string ErrorCode = "";
                // wmx.ErrorToString(ret, ref ErrorCode, 128);
                string errorCode = WMX3Api.ErrorToString(ret); //获取错误代码
                // Global.logger.ErrorFormat("WMX3通讯失败,错误信息:{0}!", errorCode);
                //return false;
            }

            //清除轴警信息
            for (int i = 0; i < 8; i++)
            {
                cmApi.AxisControl.ClearAmpAlarm(i);
                cmApi.AxisControl.ClearAxisAlarm(i);
            }

            //轴上使能
            for (int i = 0; i < 8; i++)
            {
                cmApi.AxisControl.SetServoOn(i, 1);
            }

            //检查所用到的轴有没上使能
            Thread.Sleep(1000);
            cmApi.GetStatus(ref status);
            for (int i = 0; i < 8; i++)
            {
                if (status.AxesStatus[i].ServoOn == false)
                {
                    //使用失败的处理。
                    //    Global.logger.ErrorFormat("WMX3 轴{0}使能失败!", i);
                    //return false;
                }
            }
            //timer1.Interval = 50;
            //timer1.Enabled = true;
            ret = cmApi.Motion.CreateSplineBuffer(5, 1024);
            if (ret != 0)
            {
                //     Global.logger.ErrorFormat("WMX3创建缓存出现错误!错误信息:{0}", WMX3Api.ErrorToString(ret));
            }

            while (bInitOK)
            {
                Thread.Sleep(10);
                GetAllMotionStatus();
                GetAllIOStatus();
            }
        }