示例#1
0
文件: CMotor.cs 项目: zoro-008/Works
        /// <summary>
        /// 현재 파라미터들을 아진 함수를 이용하여 세팅함.
        /// </summary>
        public void ApplyPara(double _dPulsePerUnit)
        {
            m_dPulsePerUnit = _dPulsePerUnit;

            int iRet2;
            int iMode;

            //S-Curve 설정할때 가/감속을 Percentage로 변환해서 셋팅해야하는데 셋팅된 가/감속 가져오기 애매해서 주석처리.
            //if (Para.dSCurveAcPer == 0 && Para.dSCurveDcPer == 0)//커브 안쓸때.
            //{
            //    iMode = (int)MotnDefines._TCmSpeedMode.cmSMODE_T;//대칭
            //}
            //else
            //{
            //    iMode = (int)MotnDefines._TCmSpeedMode.cmSMODE_S;//비대칭
            //}
            ////S-Curve 설정
            //Cmmsdk.cmmCfgSetSpeedPattern(Para.iPhysicalNo, iMode, 2000, 10000, 10000 );

            //Use Inpos

            int iUse = Para.bUseInpos ? 1 : 0;
            int iRet = Cmmsdk.cmmCfgSetMioProperty(Para.iPhysicalNo, (int)MotnDefines._TCmMioPropId.cmINP_EN, iUse);

            //EncInputMode 설정
            Cmmsdk.cmmCfgSetInMode(Para.iPhysicalNo, (int)Para.eEncMulti, (int)Para.eEncInputMode);
            //Pulse Output 설정
            int iRst = Cmmsdk.cmmCfgSetOutMode(Para.iPhysicalNo, (int)Para.ePulseOutput);

            //하드웨어 리밋
            Cmmsdk.cmmCfgSetMioProperty(Para.iPhysicalNo, (int)MotnDefines._TCmMioPropId.cmEL_MODE, 1);     // 0-즉시정지,1-감속정지
            Cmmsdk.cmmCfgSetMioProperty(Para.iPhysicalNo, (int)MotnDefines._TCmMioPropId.cmEL_LOGIC, (int)Para.eLimPhase);

            Cmmsdk.cmmCfgSetMioProperty(Para.iPhysicalNo, (int)MotnDefines._TCmMioPropId.cmALM_MODE, 1);    // 0-즉시정지,1-감속정지
            Cmmsdk.cmmCfgSetMioProperty(Para.iPhysicalNo, (int)MotnDefines._TCmMioPropId.cmALM_LOGIC, (int)Para.eAlarmPhase);

            Cmmsdk.cmmCfgSetMioProperty(Para.iPhysicalNo, (int)MotnDefines._TCmMioPropId.cmEZ_LOGIC, (int)Para.eZphaPhase);
            Cmmsdk.cmmCfgSetMioProperty(Para.iPhysicalNo, (int)MotnDefines._TCmMioPropId.cmINP_LOGIC, (int)Para.eInposPhase);
            Cmmsdk.cmmCfgSetMioProperty(Para.iPhysicalNo, (int)MotnDefines._TCmMioPropId.cmORG_LOGIC, (int)Para.eHomePhase);
            Cmmsdk.cmmCfgSetMioProperty(Para.iPhysicalNo, (int)MotnDefines._TCmMioPropId.cmSVON_LOGIC, (int)Para.eServoPhase);

            //링카운터 (ex, 원으로 돌때 해당 포지션에서 0로 변경)
            //이 기능은 COMI-LX502 제품에서는 지원하지 않습니다. 대여받은게 하필 이거라 테스트 못해봄
            iUse = Para.dSetMaxPos == 0 ? 0 : 1;
            Cmmsdk.cmmCfgSetRingCntr(Para.iPhysicalNo, (int)MotnDefines._TCmCntr.cmCNT_COMM, iUse, Para.dSetMaxPos * m_dPulsePerUnit);
            Cmmsdk.cmmCfgSetRingCntr(Para.iPhysicalNo, (int)MotnDefines._TCmCntr.cmCNT_FEED, iUse, Para.dSetMaxPos * m_dPulsePerUnit);

            if (Para.bGantryEnable)
            {
                SetLinkEnable();
            }
            else
            {
                SetLinkDisable();
            }
        }