Exemplo n.º 1
0
        public void SetParamSetMachineParameter()
        {
            MCCL.SYS_MAC_PARAM      stMacParam   = new MCCL.SYS_MAC_PARAM();
            MCCL.SYS_ENCODER_CONFIG stENCConfig  = new MCCL.SYS_ENCODER_CONFIG();
            MCCL.SYS_HOME_CONFIG    stHomeConfig = new MCCL.SYS_HOME_CONFIG();

            //MCCL物件參數初始化_機構參數
            stMacParam.wPosToEncoderDir          = 0;
            stMacParam.dwPPR                     = 1048576;
            stMacParam.wRPM                      = 3000;
            stMacParam.dfPitch                   = 8.23;
            stMacParam.dfGearRatio               = 1.0;
            stMacParam.dfHighLimit               = 50000.0;
            stMacParam.dfLowLimit                = -50000.0;
            stMacParam.dfHighLimitOffset         = 0;
            stMacParam.dfLowLimitOffset          = 0;
            stMacParam.wPulseMode                = MCCL.DDA_FMT_PD;
            stMacParam.wPulseWidth               = 100;
            stMacParam.wCommandMode              = 0;
            stMacParam.wOverTravelUpSensorMode   = 0;
            stMacParam.wOverTravelDownSensorMode = 0;

            for (ushort wChannel = 0; wChannel < MaxAxis; wChannel++)
            {
                MCCL.MCC_SetMacParam(ref stMacParam, wChannel, 0);
            }

            MCCL.MCC_CloseAllGroups();
            Group = (ushort)MCCL.MCC_CreateGroup(0, 1, 2, -1, -1, -1, -1, -1, CardIndex);

            if (Group < 0)
            {
                Debug.WriteLine("Create Group Fail");
                MCCL.MCC_CloseAllGroups();
            }

            MCCL.MCC_SetSysMaxSpeed(MachineMaxSpeed);
        }
        public static void SetMachineParameter()
        {
            // MotorBox

            /*
             * //MCCL使用所需物件
             * MCCL.SYS_MAC_PARAM stMacParam = new MCCL.SYS_MAC_PARAM();
             * MCCL.SYS_ENCODER_CONFIG stENCConfig = new MCCL.SYS_ENCODER_CONFIG();
             * MCCL.SYS_HOME_CONFIG stHomeConfig = new MCCL.SYS_HOME_CONFIG();
             *
             * //MCCL物件參數初始化_機構參數
             * stMacParam.wPosToEncoderDir = 0;
             * stMacParam.dwPPR = 8192;
             * stMacParam.wRPM = 6000;
             * stMacParam.dfPitch = 1.0;
             * stMacParam.dfGearRatio = 1.0;
             * stMacParam.dfHighLimit = 50000.0;
             * stMacParam.dfLowLimit = -50000.0;
             * stMacParam.dfHighLimitOffset = 0;
             * stMacParam.dfLowLimitOffset = 0;
             * stMacParam.wPulseMode = MCCL.DDA_FMT_PD;
             * stMacParam.wPulseWidth = 100;
             * stMacParam.wCommandMode = 0;
             * stMacParam.wOverTravelUpSensorMode = 0;
             * stMacParam.wOverTravelDownSensorMode = 0;
             *
             * //MCCL物件參數初始化_編碼器參數
             * stENCConfig.wType = MCCL.ENC_TYPE_AB;
             * stENCConfig.wAInverse = MCCL._NO_;
             * stENCConfig.wBInverse = MCCL._NO_;
             * stENCConfig.wCInverse = MCCL._NO_;
             * stENCConfig.wABSwap = MCCL._NO_;
             * stENCConfig.wInputRate = 4;
             * //set encoder input rate : x4
             *
             * //MCCL物件參數初始化_原點復歸參數
             * stHomeConfig.wMode = 3;
             * stHomeConfig.wDirection = 1;
             * stHomeConfig.wSensorMode = MCCL.SL_NORMAL_CLOSE;
             * stHomeConfig.nIndexCount = 2;
             * stHomeConfig.dfAccTime = 300;
             * stHomeConfig.dfDecTime = 300;
             * stHomeConfig.dfHighSpeed = 10;
             * stHomeConfig.dfLowSpeed = 2;
             * stHomeConfig.dfOffset = 0;
             * stHomeConfig.wPaddel0 = 0;
             * stHomeConfig.nPaddel1 = 0;
             */
            //---------------------------------------------------------------------------------------------
            // CNC

            MCCL.SYS_MAC_PARAM      stMacParam   = new MCCL.SYS_MAC_PARAM();
            MCCL.SYS_ENCODER_CONFIG stENCConfig  = new MCCL.SYS_ENCODER_CONFIG();
            MCCL.SYS_HOME_CONFIG    stHomeConfig = new MCCL.SYS_HOME_CONFIG();

            //MCCL物件參數初始化_機構參數
            stMacParam.wPosToEncoderDir          = 0;
            stMacParam.dwPPR                     = 1048576;
            stMacParam.wRPM                      = 3000;
            stMacParam.dfPitch                   = 8.23;
            stMacParam.dfGearRatio               = 1.0;
            stMacParam.dfHighLimit               = 50000.0;
            stMacParam.dfLowLimit                = -50000.0;
            stMacParam.dfHighLimitOffset         = 0;
            stMacParam.dfLowLimitOffset          = 0;
            stMacParam.wPulseMode                = MCCL.DDA_FMT_PD;
            stMacParam.wPulseWidth               = 100;
            stMacParam.wCommandMode              = 0;
            stMacParam.wOverTravelUpSensorMode   = 0;
            stMacParam.wOverTravelDownSensorMode = 0;

            //MCCL物件參數初始化_編碼器參數
            stENCConfig.wType      = MCCL.ENC_TYPE_AB;
            stENCConfig.wAInverse  = MCCL._NO_;
            stENCConfig.wBInverse  = MCCL._NO_;
            stENCConfig.wCInverse  = MCCL._NO_;
            stENCConfig.wABSwap    = MCCL._NO_;
            stENCConfig.wInputRate = 4;
            //set encoder input rate : x4

            //MCCL物件參數初始化_原點復歸參數
            stHomeConfig.wMode       = 3;
            stHomeConfig.wDirection  = 1;
            stHomeConfig.wSensorMode = MCCL.SL_NORMAL_CLOSE;
            stHomeConfig.nIndexCount = 2;
            stHomeConfig.dfAccTime   = 300;
            stHomeConfig.dfDecTime   = 300;
            stHomeConfig.dfHighSpeed = 0.1;
            stHomeConfig.dfLowSpeed  = 0.0001;
            stHomeConfig.dfOffset    = 0;
            stHomeConfig.wPaddel0    = 0;
            stHomeConfig.nPaddel1    = 0;

            for (ushort wChannel = 0; wChannel <= 7; wChannel++)
            {
                MCCL.MCC_SetMacParam(ref stMacParam, wChannel, 0);
                //MCCL.MCC_SetEncoderConfig(ref stENCConfig, wChannel, 0);
                //MCCL.MCC_SetHomeConfig(ref stHomeConfig, wChannel, 0);
            }

            // 設定 Group
            MCCL.MCC_CloseAllGroups();
            nGroupIndex = (ushort)MCCL.MCC_CreateGroup(0, 1, 2, -1, -1, -1, -1, -1, MCCL.CARDINDEX0);

            if (nGroupIndex < 0)
            {
                MessageBox.Show("Create GroupIndex Fail");
                MCCL.MCC_CloseAllGroups();
                return;
            }

            //設定最大速度
            MCCL.MCC_SetSysMaxSpeed(100); // set max. feed rate
        }