Exemplo n.º 1
0
        /// <summary>
        /// 单轴绝对运动
        /// </summary>
        /// <param name="card"></param>
        /// <param name="axis"></param>
        /// <param name="postion">目标点位</param>
        /// <param name="speed">速度</param>
        /// <returns></returns>
        public short _SR_AbsoluteMove(AxisConfig axisC, PointModule point)
        {
            short shrResult = 0;

            if (point.dblPonitSpeed == 0.0)
            {
                MessageBoxLog.Show(axisC.AxisName + "速度设置位0,急停请设置");
                return(-1);
            }

            if (tag_CardCount < 1 || axisC.CardNum >= tag_CardCount)
            {
                return(-1);
            }
            LTDMC.dmc_set_s_profile((ushort)tag_cardids[axisC.CardNum], (ushort)axisC.AxisNum, 0, point.db_S_Time);                                                                          //设置S段时间(0-0.05s)
            LTDMC.dmc_set_profile((ushort)tag_cardids[axisC.CardNum], (ushort)axisC.AxisNum, axisC.StartSpeed, point.dblPonitSpeed, point.db_StopSpeed, point.dblAccTime, point.dblDecTime); //设置起始速度、运行速度、停止速度、加速时间、减速时间
            shrResult = LTDMC.dmc_pmove((ushort)tag_cardids[axisC.CardNum], (ushort)axisC.AxisNum, (int)(point.dblPonitValue * axisC.Eucf), 1);                                              //定长运动


            if (shrResult != shrGtsSuccess)
            {
                CommandResult("_SR_RelativeMove", shrResult);
                return(shrFail);
            }
            return(shrResult);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 轴运动并等待停止并判断位置
        /// </summary>
        /// <param name="stationName"></param>
        /// <param name="axisName"></param>
        /// <param name="pointName"></param>
        /// <param name="asxisIndex"></param>
        /// <returns></returns>
        public static short GT_AxisAbsoluteMoveAndWaitStopVrf(AxisConfig axisC, double pos, double speed)
        {
            if (GT_AbsoluteMove(axisC, pos, speed) != 0)
            {
                Global.WorkVar.tag_StopState = 2;
                if (MessageBoxLog.Show("轴名:\r\n" + axisC.AxisName + "\t移动异常,请检查伺服驱动!") == DialogResult.OK)
                {
                }
                return(shrFail);
            }
            if (WaitAxisStop(axisC) != 0)
            {
                return(shrFail);
            }
            double pos_loadY = 0;
            short  ret       = SR_GetPrfPos((int)axisC.tag_MotionCardManufacturer, axisC.CardNum, axisC.AxisNum, ref pos_loadY);

            if (Global.WorkVar.tag_SuspendState == 1 || (Global.WorkVar.bSuspendState_L && axisC.AxisName == "左Y轴") || (Global.WorkVar.bSuspendState_R && axisC.AxisName == "右Y轴"))
            {
            }
            else if (pos_loadY / axisC.Eucf < pos - 1 || pos_loadY / axisC.Eucf > pos + 1)
            {
                return(shrFail);
            }

            return(shrSuccess);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 等待轴停止
        /// </summary>
        /// <param name="card"></param>
        /// <param name="axis"></param>
        /// <returns></returns>
        public static short WaitAxisStop(AxisConfig axisC)
        {
            int   intAxisStatus = 0;
            short shrResult     = 0;

            NewCtrlCardBase Base_ = tag_NewCtrlCardBase[(int)axisC.tag_MotionCardManufacturer];

            if (Base_ == null)
            {
                MessageBoxLog.Show(NewCtrlCardBase.GetManufacturerName((int)axisC.tag_MotionCardManufacturer) + "控制卡初始化失败!");
                return(shrFail);
            }
            short ret = 0;

            do
            {
                //程序是否正常运行
                if (IsExit())
                {
                    Base_.SR_AxisEmgStop(axisC.CardNum, axisC.AxisNum);
                    return(shrFail);
                }
                //读轴状态
                shrResult = Base_.SR_GetAxisStatus(axisC.CardNum, axisC.AxisNum, out intAxisStatus);
                if (shrResult != shrGtsSuccess)
                {
                    return(shrFail);
                }
                Thread.Sleep(5);
            } while (intAxisStatus != 0);  //运动中
            return(shrSuccess);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 判断当前轴运动是否是本点的安全区 安全返回TRUE
        /// </summary>
        /// <returns></returns>
        public static bool IoAxisIsSafe(StationModule sm, AxisConfig _ac, double offset, double pos)
        {
            bool ret = true;

            if (sm.arrPoint.Count == 0)
            {
                return(true);
            }
            foreach (PointAggregate pa in sm.arrPoint)
            {
                if (isIOAxisHavePoint(_ac, pa, pos))
                {
                    if (pa.tag_AxisSafeManage.PointIsSafe(pa))
                    {
                        if (IOIsSafe(pa))
                        {
                            ret = true;
                            // break;
                        }
                        else
                        {
                            ret = false;
                            break;
                        }
                    }
                }
            }

            if (ret == false)
            {
                LogOutControl.OutLog(_ac.AxisName + "运动不安全", 0);
            }
            return(ret);
        }
Exemplo n.º 5
0
        private void button_Add_Click(object sender, EventArgs e)
        {
            try
            {
                AxisConfig axis = null;

                int i = 0;

                while (i < StationManage._Config.axisArray.Count)
                {
                    string axisFind = StationManage._Config.axisArray[i].AxisName;
                    if (axisFind == listBox_AllAxisConfig.SelectedItem.ToString())
                    {
                        axis = StationManage._Config.axisArray[i];
                        break;
                    }
                    i++;
                }



                foreach (AxisConfig ax in tag_StationManage.arrAxis)
                {
                    if (ax == axis)
                    {
                        return;
                    }
                }
                tag_StationManage.arrAxis.Add(axis);
                tag_StationManage.intUseAxisCount++;
                listBox_Axis.Items.Add(axis.AxisName);
            }
            catch
            { }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 单轴相对运动
        /// </summary>
        /// <param name="card"></param>
        /// <param name="axis"></param>
        /// <param name="postion">目标点位</param>
        /// <param name="speed">速度</param>
        /// <returns></returns>
        public short _SR_RelativeMove(AxisConfig axisC, PointModule point)
        {
            short shrResult = 0;

            if (point.dblPonitSpeed == 0.0)
            {
                MessageBoxLog.Show(axisC.AxisName + "速度设置位0,急停请设置");
                return(-1);
            }
            if (tag_CardCount < 1 || axisC.CardNum >= tag_CardCount)
            {
                return(-1);
            }

            Dmc1000.d1000_set_s_profile(axisC.CardNum * tag_AxisCount + axisC.AxisNum, point.db_S_Time);            //设置S段时间(0-0.05s)
            // Dmc1000.d1000_set_profile((ushort)axisC.CardNum, (ushort)axisC.AxisNum, dblPonitSpeed.StartSpeed, point.dblPonitSpeed, point.db_StopSpeed, point.dblAccTime, point.dblDecTime);//设置起始速度、运行速度、停止速度、加速时间、减速时间
            shrResult = (short)Dmc1000.d1000_start_t_move(axisC.CardNum * tag_AxisCount + axisC.AxisNum,
                                                          (int)(point.dblPonitValue * axisC.Eucf), (int)point.dblPonitStartSpeed, (int)point.dblPonitSpeed, point.dblAcc);//定长运动


            if (shrResult != shrGtsSuccess)
            {
                CommandResult("_SR_RelativeMove", shrResult);
                return(shrFail);
            }
            return(shrResult);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 运行第二段距离
        /// </summary>
        /// <param name="axisC"></param>
        /// <returns></returns>
        public short HomeMoveTwoDis(AxisConfig axisC)
        {
            short shrResult = 0;
            int   AxisState = 0;

            adt8940a1m.adt8940a1_set_startv(axisC.CardNum, axisC.AxisNum + 1, (int)axisC.StartSpeed);      //
            adt8940a1m.adt8940a1_set_speed(axisC.CardNum, axisC.AxisNum + 1, (int)axisC.Speed);            //
            adt8940a1m.adt8940a1_set_acc(axisC.CardNum, axisC.AxisNum + 1, (int)axisC.Acc);                //
            int pos = (int)(axisC.intSecondFindOriginDis * axisC.Eucf);

            if (axisC.HomeDir == 0)
            {
                pos = 0 - pos;
            }
            shrResult = (short)adt8940a1m.adt8940a1_symmetry_relative_move(axisC.CardNum, axisC.AxisNum + 1, pos, (int)axisC.StartSpeed, (int)axisC.HomeSpeedHight, (int)axisC.tag_accTime);
            if (shrResult == 1)
            {
                CommandResult("adt8940a1_symmetry_relative_move", shrResult);
                return(1);
            }
            Thread.Sleep(10);
            while (true)
            {
                if (_SR_GetAxisStatus(axisC.CardNum, (short)(axisC.AxisNum), out AxisState) != 0)
                {
                    _SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    return(1);
                }
                if (AxisState == 0)
                {
                    _SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    return(0);
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 寻找原点 多次来回寻找,如果向负方向找到返回0,向正方向找到放回1
        /// </summary>
        /// <param name="axisC"></param>
        /// <returns></returns>
        public short MutHomeFindHomeSinge(AxisConfig axisC1, int count)
        {
            int stepPos = (int)axisC1.intFirstFindOriginDis;

            if (HomeFindHomeSinge(axisC1, stepPos) == 0)
            {
                if (stepPos < 0)
                {
                    return(0);
                }
                else
                {
                    return(1);
                }
            }

            if (WorkBase.IsRestExit())
            {
                return(-1);
            }

            if (HomeFindHomeSinge(axisC1, 0 - 2 * stepPos) == 0)
            {
                if (stepPos < 0)
                {
                    return(0);
                }
                else
                {
                    return(1);
                }
            }
            return(-1);
        }
Exemplo n.º 9
0
        public static short set_io_mode(AxisConfig axisC)
        {
            NewCtrlCardBase Base_ = tag_NewCtrlCardBase[(int)axisC.tag_MotionCardManufacturer];

            if (Base_ == null)
            {
                MessageBoxLog.Show(NewCtrlCardBase.GetManufacturerName((int)axisC.tag_MotionCardManufacturer) + "控制卡初始化失败!");
                return(shrFail);
            }
            short ret = 0;

            if (axisC == null)
            {
                return(shrFail);
            }

            short shrResult = Base_.SR_set_io_mode(axisC.CardNum, 0, 0);

            if (shrResult != shrSuccess)
            {
                return(shrFail);
            }

            return(shrResult);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 轴,iO安全检查
        /// </summary>
        /// <returns></returns>
        public bool IoSafeCheck(StationModule sm)
        {
            try
            {
                int count = _Config.axisArray.Count;
                int i     = 0;

                int CountIo = _Config.arrWorkStation.Count;
                if (sm == null)
                {
                    return(true);
                }
                while (i < count)
                {
                    AxisConfig ac = _Config.axisArray[i];
                    if (ac.AxisNum >= 0 && NewCtrlCardV0.SR_GetAxisStatus(ac) == 1)
                    {
                        if (!AxisSafeManage.IoAxisIsSafe(sm, ac, 0, 0))
                        {
                            if (Global.WorkVar.tag_isFangDaiJieChu)
                            {
                                return(true);
                            }
                            return(false);
                        }
                    }
                    i++;
                }
                return(true);
            }
            catch
            {
                return(true);
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// 判断是否右轴报警 TRUE 报警
        /// </summary>
        public bool IsAxisAlarm()
        {
            bool axio = false;

            //NewCtrlCardV0.GetInputIoBitStatus("", "Z1报警", out axio);
            if (axio)
            {
                LogOutControl.OutLog("轴报警", 0);

                return(true);
            }
            int  CardIndex = 0;
            int  axisIndex = 0;
            bool ret       = false;

            for (MotionCardManufacturer i = 0; i < MotionCardManufacturer.MotionCardManufacturer_max; i++)
            {
                NewCtrlCardBase Base = NewCtrlCardV0.tag_NewCtrlCardBase[(int)i];
                short           j    = 0;
                short           n    = 0;
                if (Base == null || NewCtrlCardIO.tag_CardHave[(int)i] == 0)
                {
                    continue;
                }
                while (j < NewCtrlCardV0.tag_CardCount[(int)i])
                {
                    axisIndex = 0;
                    while (n < NewCtrlCardV0.tag_CardAxisCount[(int)i])
                    {
                        //tag_CardAxisAlarm[CardIndex]
                        AxisConfig name = IshaveAxis((int)i, j, n);
                        if (name != null)
                        {
                            if (name.tag_IoAlarmNHighEnable == 1)
                            {
                                if ((((int)NewCtrlCardIO.tag_CardAxisAlarm[CardIndex] & (1 << n)) > 0))
                                {
                                    LogOutControl.OutLog(NewCtrlCardBase.GetManufacturerName((int)i) + "第" + j + "卡" + n + "轴(" + name.AxisName + ")报警", 0);
                                    ret = true;
                                }
                            }
                            else
                            {
                                if ((((int)NewCtrlCardIO.tag_CardAxisAlarm[CardIndex] & (1 << n)) == 0))
                                {
                                    LogOutControl.OutLog(NewCtrlCardBase.GetManufacturerName((int)i) + "第" + j + "卡" + n + "轴(" + name.AxisName + ")报警", 0);
                                    ret = true;
                                }
                            }
                        }
                        axisIndex++;
                        n++;
                    }
                    CardIndex++;
                    j++;
                }
                //
            }
            return(ret);
        }
Exemplo n.º 12
0
        /// <summary>
        /// 判断当前轴运动是否是在PA 的安全 配置列表里面(pa.tag_AxisSafeManage.tag_AxisSafeList)  在返回TRUE
        /// </summary>
        /// <param name="_ac"></param>
        /// <param name="pa"></param>
        /// <returns></returns>
        public static bool isIOAxisHavePoint(AxisConfig _ac, PointAggregate pa, double pos)
        {
            int i = 0;

            if (pa == null || pa.tag_AxisSafeManage == null || pa.tag_AxisSafeManage.tag_AxisSafeList == null)
            {
                return(false);
            }
            while (i < pa.tag_AxisSafeManage.tag_AxisSafeList.Count)
            {
                AxisSafe currac = pa.tag_AxisSafeManage.tag_AxisSafeList[i];
                if ((int)_ac.tag_MotionCardManufacturer * 1000 + _ac.CardNum * 100 + _ac.AxisNum == currac.tag_AxisId)
                {
                    double poen_ac = 0.0;
                    NewCtrlCardV0.SR_GetPrfPos((int)_ac.tag_MotionCardManufacturer, _ac.CardNum, _ac.AxisNum, ref poen_ac);
                    //  if (i == 0)
                    {
                        poen_ac = poen_ac / _ac.Eucf;
                        if (poen_ac <= currac.tag_max && poen_ac >= currac.tag_min)
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
                i++;
            }
            return(false);
        }
Exemplo n.º 13
0
        /// <summary>
        /// 寻找原点 多次来回寻找,如果向负方向找到返回0,向正方向找到放回1
        /// </summary>
        /// <param name="axisC"></param>
        /// <returns></returns>
        public short MutHomeFindHomeSinge(AxisConfig axisC1, int count)
        {
            int stepPos = (int)axisC1.intFirstFindOriginDis;
            int pos     = stepPos / 2;
            int addPos  = stepPos / 2;
            int i       = 0;

            do
            {
                if (HomeFindHomeSinge(axisC1, stepPos) == 0)
                {
                    if (stepPos < 0)
                    {
                        return(0);
                    }
                    else
                    {
                        return(1);
                    }
                }
                stepPos = 0 - stepPos;
                if (stepPos < 0)
                {
                    stepPos = stepPos - addPos;
                    pos     = 0 - stepPos;
                }
                else
                {
                    stepPos = stepPos + addPos;
                    pos     = stepPos;
                }
                i++;
            }while (pos < axisC1.intFirstFindOriginDis + 1 && i < count);
            return(-1);
        }
Exemplo n.º 14
0
        /// <summary>
        /// 寻找原点 多次来回寻找,如果向负方向找到返回0,向正方向找到放回1
        /// </summary>
        /// <param name="axisC"></param>
        /// <returns></returns>
        public short MutHomeFindHomeSinge(AxisConfig axisC1)
        {
            int stepPos = 45;
            int pos     = 45;
            int i       = 0;

            do
            {
                if (HomeFindHomeSinge(axisC1, stepPos) == 0)
                {
                    if (stepPos < 0)
                    {
                        return(0);
                    }
                    else
                    {
                        return(1);
                    }
                }
                stepPos = 0 - stepPos;
                if (stepPos < 0)
                {
                    stepPos = stepPos - 45;
                    pos     = 0 - stepPos;
                }
                else
                {
                    stepPos = stepPos + 45;
                    pos     = stepPos;
                }
                i++;
            }while (pos < axisC1.intFirstFindOriginDis && i < 100);
            return(-1);
        }
Exemplo n.º 15
0
        private void button_Del_Click(object sender, EventArgs e)
        {
            try
            {
                AxisConfig axis = null;
                int        i    = 0;
                if (!string.IsNullOrEmpty(tag_StationManage.strStationName))
                {
                    for (i = 0; i < tag_StationManage.intUseAxisCount; i++)
                    {
                        string axisFind = tag_StationManage.arrAxis[i].AxisName;
                        if (axisFind == listBox_Axis.SelectedItem.ToString())
                        {
                            axis = tag_StationManage.arrAxis[i];
                            break;
                        }
                    }
                }

                if (axis == null)
                {
                    return;
                }
                tag_StationManage.arrAxis.Remove(axis);
                tag_StationManage.intUseAxisCount--;
                listBox_Axis.Items.Remove(axis.AxisName);
            }
            catch
            { }
        }
Exemplo n.º 16
0
 /// <summary>
 /// 高速比较器,取值范围:0~3(对应硬件 CMP0~CMP3 端口)
 /// </summary>
 /// <param name="axisC"></param>
 /// <param name="hcmp">高速比较器,取值范围:0~3(对应硬件 CMP0~CMP3 端口)</param>
 /// <returns></returns>
 public short _SR_dmc_hcmp_clear_points(AxisConfig axisC, ushort hcmp)
 {
     if (tag_CardCount < 1 || axisC.CardNum >= tag_CardCount)
     {
         return(-1);
     }
     return(LTDMC.dmc_hcmp_clear_points((ushort)tag_cardids[axisC.CardNum], (ushort)hcmp));
 }
Exemplo n.º 17
0
 /// <summary>
 /// 配置高速比较器 time参数(脉冲宽度)只对队列和线性比较模式起作用
 /// </summary>
 /// <param name="axisC"></param>
 /// <param name="hcmp">高速比较器,取值范围:0~3(对应硬件 CMP0~CMP3 端口)</param>
 /// <param name="cmp_source">比较位置源:0:指令位置计数器,1:编码器计数器</param>
 /// <param name="cmp_logic">有效电平:0:低电平,1:高电平</param>
 /// <param name="time">脉冲宽度,单位:us,取值范围:1us~20s</param>
 /// <returns></returns>
 public short _SR_dmc_hcmp_set_config(AxisConfig axisC, short hcmp, short cmp_source, short cmp_logic, long time)
 {
     if (tag_CardCount < 1 || axisC.CardNum >= tag_CardCount)
     {
         return(-1);
     }
     return(LTDMC.dmc_hcmp_set_config((ushort)tag_cardids[axisC.CardNum], (ushort)hcmp, (ushort)axisC.AxisNum, (ushort)cmp_source, (ushort)cmp_logic, (Int32)time));
 }
Exemplo n.º 18
0
 /// <summary>
 /// 控制指定 CMP 端口的输出
 /// </summary>
 /// <param name="axisC"></param>
 /// <param name="hcmp">高速比较器,取值范围:0~3(对应硬件 CMP0~CMP3 端口)</param>
 /// <param name="on_off">设置 CMP 端口电平,0:低电平,1:高电平</param>
 /// <returns></returns>
 public short _SR_dmc_write_cmp_pin(AxisConfig axisC, short hcmp, short on_off)
 {
     if (tag_CardCount < 1 || axisC.CardNum >= tag_CardCount)
     {
         return(-1);
     }
     return(LTDMC.dmc_write_cmp_pin((ushort)tag_cardids[axisC.CardNum], (ushort)hcmp, (ushort)on_off));
 }
Exemplo n.º 19
0
 /// <summary>
 /// 设置高速比较线性模式参数
 /// </summary>
 /// <param name="axisC"></param>
 /// <param name="hcmp">高速比较器,取值范围:0~3(对应硬件 CMP0~CMP3 端口)</param>
 /// <param name="Increment">位置增量值,单位:pulse(正值表示位置递增,负值表示位置递减)</param>
 /// <param name="Count">比较次数,取值范围:1~65535</param>
 /// <returns></returns>
 public short _SR_dmc_hcmp_set_liner(AxisConfig axisC, short hcmp, int Increment, int Count)
 {
     if (tag_CardCount < 1 || axisC.CardNum >= tag_CardCount)
     {
         return(-1);
     }
     return(LTDMC.dmc_hcmp_set_liner((ushort)tag_cardids[axisC.CardNum], (ushort)hcmp, (int)Increment, Count));
 }
Exemplo n.º 20
0
 /// <summary>
 /// 添加/更新高速比较位置
 /// </summary>
 /// <param name="axisC"></param>
 /// <param name="hcmp">高速比较器,取值范围:0~3(对应硬件 CMP0~CMP3 端口)</param>
 /// <param name="cmp_pos">队列模式下:添加比较位置,单位:pulse</param>
 /// <returns></returns>
 public short _SR_dmc_hcmp_add_point(AxisConfig axisC, short hcmp, int cmp_pos)
 {
     if (tag_CardCount < 1 || axisC.CardNum >= tag_CardCount)
     {
         return(-1);
     }
     return(LTDMC.dmc_hcmp_add_point((ushort)tag_cardids[axisC.CardNum], (ushort)hcmp, (int)cmp_pos));
 }
Exemplo n.º 21
0
 /// <summary>
 ///  功 能:设置高速比较模式
 ///  比较模式:
 /// 1)当选择模式 1 时,只有当前位置等于比较位置时,CMP 端口才输出有效电平
 ///2)当选择模式 2 时,只要当前位置小于比较位置时,CMP 端口就一直保持有效电平
 ///3)当选择模式 3 时,只要当前位置大于比较位置时,CMP 端口就一直保持有效电平
 ///4)当选择模式 4 或 5 时,CMP 端口输出有效电平的时间通过 dmc_hcmp_set_config函数的 time 参数(脉冲宽度)设置 5)DMC5C00 后四轴不支持高速位置比较功能
 /// </summary>
 /// <param name="axis"></param>
 /// <param name="hcmp">高速比较器,取值范围:0~3(对应硬件 CMP0~CMP3 端口)</param>
 /// <param name="cmp_mode">比较模式:0:禁止(默认值)1:等于2:小于3:大于</param>
 /// <returns></returns>
 public short _SR_dmc_hcmp_get_mode(AxisConfig axisC, short hcmp, ref ushort cmp_mode)
 {
     if (tag_CardCount < 1 || axisC.CardNum >= tag_CardCount)
     {
         return(-1);
     }
     return(LTDMC.dmc_hcmp_get_mode((ushort)tag_cardids[axisC.CardNum], (ushort)hcmp, ref cmp_mode));
 }
Exemplo n.º 22
0
        /// <summary>
        /// 单轴连续运动
        /// </summary>
        /// <param name="card"></param>
        /// <param name="axis"></param>
        /// <param name="postion">目标点位</param>
        /// <param name="speed">速度</param>
        /// <returns></returns>
        public short _SR_continue_move(AxisConfig axisC, PointModule point, int dir)
        {
            adt8960m.adt8960_set_startv(axisC.CardNum, axisC.AxisNum + 1, (int)point.dblPonitStartSpeed); //
            adt8960m.adt8960_set_speed(axisC.CardNum, axisC.AxisNum + 1, (int)point.dblPonitSpeed);       //
            adt8960m.adt8960_set_acc(axisC.CardNum, axisC.AxisNum + 1, (int)point.dblAcc);                //

            return((short)adt8960m.adt8960_continue_move(axisC.CardNum, axisC.AxisNum + 1, dir));
        }
Exemplo n.º 23
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="CardNo"></param>
 /// <param name="hcmp"></param>
 /// <param name="axis"></param>
 /// <param name="cmp_source"></param>
 /// <param name="cmp_logic"></param>
 /// <param name="time"></param>
 /// <returns></returns>
 public short _SR_dmc_hcmp_get_config(AxisConfig axisC, ushort hcmp, ref ushort axis, ref ushort cmp_source, ref ushort cmp_logic, ref int time)
 {
     if (tag_CardCount < 1 || axisC.CardNum >= tag_CardCount)
     {
         return(-1);
     }
     return(LTDMC.dmc_hcmp_get_config((ushort)tag_cardids[axisC.CardNum], (ushort)hcmp, ref axis, ref cmp_source, ref cmp_logic, ref time));
 }
Exemplo n.º 24
0
        /// <summary>
        /// 读取高速比较参数
        /// </summary>
        /// <param name="axisC"></param>
        /// <param name="hcmp">高速比较器,取值范围:0~3(对应硬件 CMP0~CMP3 端口)</param>
        /// <param name="remained_points">返回可添加比较点数</param>
        /// <param name="current_point">返回当前比较点位置,单位:pulse</param>
        /// <param name="runned_points">返回已比较点数</param>
        /// <returns></returns>
        public short _SR_dmc_hcmp_get_current_state(AxisConfig axisC, short hcmp, ref int remained_points, ref int current_point, ref int runned_points)
        {
            if (tag_CardCount < 1 || axisC.CardNum >= tag_CardCount)
            {
                return(-1);
            }

            return(LTDMC.dmc_hcmp_get_current_state((ushort)tag_cardids[axisC.CardNum], (ushort)hcmp, ref remained_points, ref current_point, ref runned_points));
        }
Exemplo n.º 25
0
        /// <summary>
        /// 单轴连续运动
        /// </summary>
        /// <param name="card"></param>
        /// <param name="axis"></param>
        /// <param name="postion">目标点位</param>
        /// <param name="speed">速度</param>
        /// <returns></returns>
        public short _SR_continue_move(AxisConfig axisC, PointModule point, int dir)
        {
            int ddir = 1;

            if (dir == 1)
            {
                ddir = -1;
            }
            return((short)Dmc1000.d1000_start_sv_move(axisC.CardNum * tag_AxisCount + axisC.AxisNum, (int)point.dblPonitStartSpeed,
                                                      (int)point.dblPonitSpeed * ddir, point.dblAccTime));//连续运动
        }
Exemplo n.º 26
0
        private void button_AddAxis_Click(object sender, EventArgs e)
        {
            AxisConfig axis = new AxisConfig();

            axis.AxisIndex = _Worker._Config.axisArray.Count;;
            _Worker._Config.axisArray.Add(axis);
            AxisSetConfigControl setC = new AxisSetConfigControl();

            Panel_SetAxis.Controls.Add((Control)setC);
            setC.Location = new Point(3, 32 + axis.AxisIndex * setC.Height + axis.AxisIndex * 5);
            setC.AxisSet  = axis;
        }
Exemplo n.º 27
0
        /// <summary>
        /// 寻找原点,一次寻找pos1 ,
        /// </summary>
        /// <param name="axisC"></param>
        /// <returns></returns>
        public short HomeFindHomeSinge(AxisConfig axisC, int pos1)
        {
            short       shrResult = 0;
            bool        pIo       = false;
            int         AxisState = 0;
            PointModule point     = new PointModule(true, false, 0, axisC.Speed, axisC.Acc, axisC.Dec, axisC.tag_accTime, axisC.tag_delTime, axisC.StartSpeed, axisC.tag_S_Time, axisC.tag_StopSpeed);

            point.dblPonitValue = pos1;
            shrResult           = SR_RelativeMove(axisC, point);
            if (shrResult != 0)
            {
                return(-1);
            }
            Thread.Sleep(10);
            while (true)
            {
                if (WorkBase.IsRestExit())
                {
                    SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    return(-1);
                }

                SR_GetOriginInput(axisC.CardNum, (short)(axisC.AxisNum), out pIo);                         //采集原点信号

                if (!axisC.tag_homeIoHighLow)                                                              //如果信号位高电平
                {
                    if (!pIo)
                    {
                        SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));                                      //停止轴
                        return(0);
                    }
                }
                else
                {
                    if (pIo)
                    {
                        SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                        return(0);
                    }
                }

                if (SR_GetAxisStatus(axisC.CardNum, (short)(axisC.AxisNum), out AxisState) != 0)
                {
                    SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    return(-2);
                }
                if (AxisState == 0)
                {
                    SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    return(-3);
                }
            }
        }
Exemplo n.º 28
0
 public short _SR_GoHome(AxisConfig _acf)
 {
     if (HomeFindLimit(_acf) == 0)
     {
         Thread.Sleep(1000);
         if (HomeMoveTwoDis(_acf) == 0)
         {
             return(HomeFindHomeIO(_acf));
         }
     }
     return(-5);
 }
Exemplo n.º 29
0
        /// <summary>
        /// 寻找原点,一次寻找pos1 ,
        /// </summary>
        /// <param name="axisC"></param>
        /// <returns></returns>
        public short HomeFindHomeSinge(AxisConfig axisC, int pos1)
        {
            short       shrResult = 0;
            bool        pIo       = false;
            int         AxisState = 0;
            PointModule point     = new PointModule();

            point.dblPonitSpeed = axisC.Speed;
            point.dblAcc        = axisC.Acc;
            point.dblDec        = axisC.Dec;
            point.dblDec        = axisC.tag_accTime;
            point.dblPonitValue = pos1;
            shrResult           = _SR_RelativeMove(axisC, point);
            if (shrResult != 0)
            {
                CommandResult("_SR_RelativeMove", shrResult);
                return(1);
            }
            Thread.Sleep(10);
            while (true)
            {
                _SR_GetOriginInput(axisC.CardNum, (short)(axisC.AxisNum), out pIo);

                if (!axisC.tag_homeIoHighLow)
                {
                    if (!pIo)
                    {
                        _SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                        return(0);
                    }
                }
                else
                {
                    if (pIo)
                    {
                        _SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                        return(0);
                    }
                }

                if (_SR_GetAxisStatus(axisC.CardNum, (short)(axisC.AxisNum), out AxisState) != 0)
                {
                    _SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    return(1);
                }
                if (AxisState == 0)
                {
                    _SR_AxisEmgStop(axisC.CardNum, (short)(axisC.AxisNum));
                    return(3);
                }
                Thread.Sleep(1);
            }
        }
Exemplo n.º 30
0
        /// <summary>
        /// 单原点回原,多次寻找
        /// </summary>
        /// <param name="_acf"></param>
        /// <returns></returns>
        public short _SR_GoOneHome(AxisConfig _acf)
        {
            short ret = MutHomeFindHomeSinge(_acf);

            if (ret >= 0)
            {
                if (HomeMoveTwoDis(_acf) == 0)
                {
                    return(HomeFindOneHomeIO(_acf));
                }
            }
            return(-5);
        }