示例#1
0
        /// <summary>
        /// 获取单卡 正极限输入状态
        /// </summary>
        /// <param name="card"></param>
        /// <param name="pValue"></param>
        /// <returns></returns>
        public short _SR_GetLimitPInput(short card, short axisNum, out bool pValue)
        {
            pValue = false;
            if (tag_CardCount < 1 || card >= tag_CardCount)
            {
                return(-1);
            }
            uint status = LTDMC.dmc_axis_io_status((ushort)tag_cardids[card], (ushort)axisNum);

            if (card == 0 && axisNum == 0)
            {
            }

            int bit = (int)Math.Pow(2, 1);

            if ((status & bit) == bit)
            {
                pValue = true;
            }
            else
            {
                pValue = false;
            }
            return(0);
        }
示例#2
0
        //获取对应感应器信号
        public void Getsing(ref bool[] sing)
        {
            uint IoState = LTDMC.dmc_axis_io_status(_CardID, axis);

            if ((IoState & 2) == 2)//检测正限位信号
            {
                sing[0] = true;
            }
            else
            {
                sing[0] = false;
            }
            if ((IoState & 4) == 4)//检测负限位信号
            {
                sing[1] = true;
            }
            else
            {
                sing[1] = false;
            }
            if ((IoState & 16) == 16)//检测原点信号
            {
                sing[2] = true;
            }
            else
            {
                sing[2] = false;
            }
        }
示例#3
0
        private void AnalyseMotionIOStatus(ushort channel)
        {
            //轴 IO
            m_axisIO[channel] = LTDMC.dmc_axis_io_status(m_cardNo, channel);

            uint value = m_axisIO[channel];

            //报警
            if ((value & 0x1) > 0)
            {
                m_axisError[channel] = true;
                if (m_axisError[channel] ^ m_oldAxisError[channel])//^ 异或运算符,只有一个true结果才为true
                {
                    m_logFile.AppendText("轴伺服驱动器报警,请断电重启!");
                }
            }
            else
            {
                m_axisError[channel] = false;
            }

            m_oldAxisError[channel] = m_axisError[channel];

            //正限位
            if ((value & 0x2) > 0)
            {
                m_posTrigger[channel] = true;
                if (m_posTrigger[channel] ^ m_oldPosTrigger[channel])
                {
                    m_logFile.AppendText("轴正限位触发报警!");
                }
            }
            else
            {
                m_posTrigger[channel] = false;
            }
            m_oldPosTrigger[channel] = m_posTrigger[channel];

            //负限位
            if ((value & 0x4) > 0)
            {
                m_negTrigger[channel] = true;
                if (m_negTrigger[channel] ^ m_oldNegTrigger[channel])
                {
                    m_logFile.AppendText("轴负限位触发报警!");
                }
            }
            else
            {
                m_negTrigger[channel] = false;
            }

            m_oldNegTrigger[channel] = m_negTrigger[channel];
        }
        public void DoState()
        {
            uint rdy = 0;
            uint alm = 0;
            uint plt = 0;
            uint nlt = 0;
            uint org = 0;

            for (int axis = 0; axis < define_motion.wd_axis_count; axis++)
            {
                //位置
                mAxisPlace[axis] = LTDMC.dmc_get_position(pAxis[axis].AxisCard, pAxis[axis].AxisCode);

                //当前状态
                uint mask = pAxis[axis].AxisMask;
                if (LTDMC.dmc_check_done(pAxis[axis].AxisCard, pAxis[axis].AxisCode) != 0)
                {
                    rdy |= mask;                                                                        //轴已经停止。检测指定轴的运动状态,返回值: 0 指定轴正在运行, 1 指定轴已停止
                }
                //轴运动状态
                uint st = LTDMC.dmc_axis_io_status(pAxis[axis].AxisCard, pAxis[axis].AxisCode);//读取指定轴有关运动信号的状态

                if ((st & LTDMC.state_axis.state_org) > 0)
                {
                    org |= mask;
                }
                if ((st & LTDMC.state_axis.alarm_eln) > 0)
                {
                    nlt |= mask;
                }
                if ((st & LTDMC.state_axis.alarm_elp) > 0)
                {
                    plt |= mask;
                }
                if ((st & LTDMC.state_axis.state_alm) > 0)
                {
                    alm |= mask;
                }

                list.Add(new AxisStatus()
                {
                    IoReady = rdy,
                    IoAlarm = alm,
                    IoOrgin = org,
                    IoNegLt = nlt,
                    IoPosLt = plt
                });
            }
        }
示例#5
0
文件: Form1.cs 项目: mumushui/-1
        private void set_alm_Click_1(object sender, EventArgs e)//设置alm信号的有效电平为高电平
        {
            UInt16 enable, alm_logic, alm_action;

            for (UInt16 i = 0; i < 4; i++)
            {
                CardNo     = 0;
                axis       = i;
                enable     = 1;
                alm_logic  = 1;
                alm_action = 0;
                LTDMC.dmc_axis_io_status(0, i);
                LTDMC.dmc_set_alm_mode(CardNo, axis, enable, alm_logic, alm_action);
            }
        }
示例#6
0
        /// <summary>
        /// 获取急停 原点输入状态
        /// </summary>
        /// <param name="card"></param>
        /// <param name="pValue">原点状态值,按位取</param>
        /// <returns></returns>
        public short _SR_GetStopInput(short card, short axisNum, out bool pValue)
        {
            uint status = LTDMC.dmc_axis_io_status((ushort)tag_cardids[card], (ushort)axisNum);
            int  bit    = (int)Math.Pow(2, 3);

            if ((status & bit) == bit)

            {
                pValue = true;
            }
            else
            {
                pValue = false;
            }
            return(0);
        }
        public static void AxisReadStatus(ushort CardNo, ushort Axis, ref bool[] AxisStatusSignal)
        {
            //0:ALM:伺服報警,on报警为1
            //1:EL+:正硬限位,正极限on为1
            //2:EL_:负硬限位,负极限on为1
            //3:EMG:急停信号,急停on为1
            //4:ORG:原點信號,原点 on为1
            //6:SL+:軟正限位
            //7:SL-:軟負限位

            uint AxisStatusResult = LTDMC.dmc_axis_io_status(CardNo, Axis);

            for (int count = 0; count < 8; count++)
            {
                AxisStatusSignal[count] = (((AxisStatusResult >> count) & 1) == 1) ? (true) : (false);
            }
        }
示例#8
0
        /// <summary>
        /// 获取单卡 正极限输入状态
        /// </summary>
        /// <param name="card"></param>
        /// <param name="pValue"></param>
        /// <returns></returns>
        public short _SR_GetLimitPInput(short card, short axisNum, out bool pValue)
        {
            short shrResult;

            uint status = LTDMC.dmc_axis_io_status((ushort)tag_cardids[card], (ushort)axisNum);

            if (card == 0 && axisNum == 0)
            {
                int i = 0;
            }

            int bit = (int)Math.Pow(2, 1);

            if ((status & bit) == bit)
            {
                pValue = true;
            }
            else
            {
                pValue = false;
            }
            return(0);
        }
示例#9
0
        public bool IsAxisAstp(int index, int axis)
        {
            var sts = LTDMC.dmc_axis_io_status((ushort)Id, (ushort)axis);

            return((sts & (1 << 3)) > 0);
        }
示例#10
0
        public bool IsAxisOrg(int motionId, int axis)
        {
            var sts = LTDMC.dmc_axis_io_status((ushort)Id, (ushort)axis);

            return((sts & (1 << 4)) > 0);
        }
示例#11
0
        public bool LimitPel(int motionDevIndex, int axis)
        {
            var sts = LTDMC.dmc_axis_io_status((ushort)DevIndex, (ushort)axis);

            return((sts & (1 << 1)) > 0);
        }
示例#12
0
        public bool AxisIsAlarm(int index, int axis)
        {
            var sts = LTDMC.dmc_axis_io_status((ushort)DevIndex, (ushort)axis);

            return((sts & (1 << 0)) > 0);
        }
示例#13
0
        public bool AxisSingalEMG(int index, int axis)
        {
            var sts = LTDMC.dmc_axis_io_status((ushort)DevIndex, (ushort)axis);

            return((sts & (1 << 3)) > 0);
        }
示例#14
0
        public bool IsAxisMel(int index, int axis)
        {
            var sts = LTDMC.dmc_axis_io_status((ushort)DeviceId, (ushort)axis);

            return((sts & (1 << 2)) > 0);
        }
示例#15
0
 public uint Getsing()
 {
     return(LTDMC.dmc_axis_io_status(_CardID, axis));
 }
示例#16
0
        public bool IsAxisPel(int motionDeviceId, int axis)
        {
            var sts = LTDMC.dmc_axis_io_status((ushort)DeviceId, (ushort)axis);

            return((sts & (1 << 1)) > 0);
        }
示例#17
0
        /// <summary>
        /// 读取轴状态
        /// </summary>
        public void DoState()
        {
            bool rdy = false;
            bool alm = false;
            bool plt = false;
            bool nlt = false;
            bool org = false;

            //int place = 0;
            AxisStateList.Clear();
            for (int axis = 0; axis < define_AxisNum.wd_axis_count; axis++)
            {
                //位置
                AxisPlace[axis] = LTDMC.dmc_get_position(AxisInfoList[axis].AxisCard, AxisInfoList[axis].AxisCode);

                //当前状态
                //轴已经停止。检测指定轴的运动状态,返回值: 0 指定轴正在运行, 1 指定轴已停止
                if (LTDMC.dmc_check_done(AxisInfoList[axis].AxisCard, AxisInfoList[axis].AxisCode) == 0)
                {
                    rdy = true;
                }
                else
                {
                    rdy = false;
                }

                //轴运动状态
                uint st = LTDMC.dmc_axis_io_status(AxisInfoList[axis].AxisCard, AxisInfoList[axis].AxisCode);//读取指定轴有关运动信号的状态

                if ((st & LTDMC.state_axis.state_org) > 0)
                {
                    org = true;
                }
                else
                {
                    org = false;
                }
                if ((st & LTDMC.state_axis.alarm_eln) > 0)
                {
                    nlt = true;
                }
                else
                {
                    nlt = false;
                }
                if ((st & LTDMC.state_axis.alarm_elp) > 0)
                {
                    plt = true;
                }
                else
                {
                    plt = false;
                }
                if ((st & LTDMC.state_axis.state_alm) > 0)
                {
                    alm = true;
                }
                else
                {
                    alm = false;
                }

                AxisStateList.Add(new define_AxisState()
                {
                    isReady = rdy,
                    isAlarm = alm,
                    isOrgin = org,
                    isNegLt = nlt,
                    isPosLt = plt,
                });
            }
        }
示例#18
0
        // 更新状态位
        private void UpdateDMC3400Status()
        {
            if (Convert.ToBoolean(LTDMC.dmc_axis_io_status(m_dmc3400ACard.m_cardNo, 0) & 0x02))
            {
                el1.Image = m_redImg.Clone() as Image;
            }
            else
            {
                el1.Image = m_greenImg.Clone() as Image;
            }
            if (Convert.ToBoolean(LTDMC.dmc_axis_io_status(m_dmc3400ACard.m_cardNo, 1) & 0x02))
            {
                el2.Image = m_redImg.Clone() as Image;
            }
            else
            {
                el2.Image = m_greenImg.Clone() as Image;
            }
            if (Convert.ToBoolean(LTDMC.dmc_axis_io_status(m_dmc3400ACard.m_cardNo, 2) & 0x02))
            {
                el3.Image = m_redImg.Clone() as Image;
            }
            else
            {
                el3.Image = m_greenImg.Clone() as Image;
            }
            if (Convert.ToBoolean(LTDMC.dmc_axis_io_status(m_dmc3400ACard.m_cardNo, 3) & 0x02))
            {
                el4.Image = m_redImg.Clone() as Image;
            }
            else
            {
                el4.Image = m_greenImg.Clone() as Image;
            }

            if (Convert.ToBoolean(LTDMC.dmc_axis_io_status(m_dmc3400ACard.m_cardNo, 0) & 0x04))
            {
                el5.Image = m_redImg.Clone() as Image;
            }
            else
            {
                el5.Image = m_greenImg.Clone() as Image;
            }
            if (Convert.ToBoolean(LTDMC.dmc_axis_io_status(m_dmc3400ACard.m_cardNo, 1) & 0x04))
            {
                el6.Image = m_redImg.Clone() as Image;
            }
            else
            {
                el6.Image = m_greenImg.Clone() as Image;
            }
            if (Convert.ToBoolean(LTDMC.dmc_axis_io_status(m_dmc3400ACard.m_cardNo, 2) & 0x04))
            {
                el7.Image = m_redImg.Clone() as Image;
            }
            else
            {
                el7.Image = m_greenImg.Clone() as Image;
            }
            if (Convert.ToBoolean(LTDMC.dmc_axis_io_status(m_dmc3400ACard.m_cardNo, 3) & 0x04))
            {
                el8.Image = m_redImg.Clone() as Image;
            }
            else
            {
                el8.Image = m_greenImg.Clone() as Image;
            }
        }