Esempio n. 1
0
        // Servo On/Off
        public int ServoOnOff(AxisInfo _AxisInfo, bool bOn)
        {
            string strCommand = "", strRet = "";
            int    nRtn = -1;

            if (bOn)
            {
                switch (_AxisInfo.AxisType)
                {
                case AXIS_TYPE.SERVO:
                case AXIS_TYPE.STEPPING:
                    strCommand = string.Format("#{0}J/", _AxisInfo.AxisNo_1Base);
                    break;

                case AXIS_TYPE.LINEAR:
                    strCommand = string.Format("#{0}d$", _AxisInfo.AxisNo_1Base);
                    break;
                }
            }
            else
            {
                strCommand = string.Format("#{0}k", _AxisInfo.AxisNo_1Base);
            }

            nRtn = SendCommand(strCommand, ref strRet);

            return(nRtn);
        }
Esempio n. 2
0
        public int JogStop(AxisInfo _Axis)
        {
            string strCommand = "", strRet = "";
            int    nRtn = -1;

            strCommand = string.Format("#{0}J/", _Axis.AxisNo_1Base);
            nRtn       = SendCommand(strCommand, ref strRet);

            return(nRtn);
        }
Esempio n. 3
0
        // Axis 현재 값 읽어오기
        public int ReadAxisCurVal(AxisInfo _Axis)
        {
            string strCmd = "", strResData = "";
            int    nRet = 0;

            strCmd += string.Format("I{0}08 ", _Axis.AxisNo_1Base); //
            strCmd += string.Format("I{0}09 ", _Axis.AxisNo_1Base); //
            strCmd += string.Format("I10 ");                        //Hardware Interlock (
            strCmd += string.Format("M{0}74 ", _Axis.AxisNo_1Base); //Speed (Vel)
            strCmd += string.Format("M{0}62 ", _Axis.AxisNo_1Base); //Current Position (Encoder)
            strCmd += string.Format("M{0}69 ", _Axis.AxisNo_1Base); //Position Offset (보정값)
            strCmd += string.Format("M{0}68 ", _Axis.AxisNo_1Base); //Torque On/Off
            strCmd += string.Format("M{0}21 ", _Axis.AxisNo_1Base); //Plus Limit
            strCmd += string.Format("M{0}22 ", _Axis.AxisNo_1Base); //Minus Limit
            strCmd += string.Format("M{0}39 ", _Axis.AxisNo_1Base); //Servo On/Off
            strCmd += string.Format("M{0}40 ", _Axis.AxisNo_1Base); //In position Bit (모터 정지 확인 : Stop=1, Moving=0)
            strCmd += string.Format("M{0}42 ", _Axis.AxisNo_1Base); //Following err
            strCmd += string.Format("M{0}43 ", _Axis.AxisNo_1Base); //Amp Fault
            nRet    = SendCommand(strCmd, ref strResData);
            if (nRet > 0)
            {
                char[]   _CmdSplitter      = { '\r' };
                string[] strColInClipboard = strResData.Split(_CmdSplitter, StringSplitOptions.None);
                long     Ix08         = 0; long.TryParse(strColInClipboard[0], out Ix08);
                long     Ix09         = 0; long.TryParse(strColInClipboard[1], out Ix09);
                long     Ix10         = 0; long.TryParse(strColInClipboard[2], out Ix10);
                float    fSpeed       = 0; float.TryParse(strColInClipboard[3], out fSpeed);
                float    fCurPos      = 0; float.TryParse(strColInClipboard[4], out fCurPos);
                float    fPosOffset   = 0; float.TryParse(strColInClipboard[5], out fPosOffset);
                float    fTorque      = 0; float.TryParse(strColInClipboard[6], out fTorque);
                int      nPlusLimit   = 0; int.TryParse(strColInClipboard[7], out nPlusLimit);
                int      nMinusLimit  = 0; int.TryParse(strColInClipboard[8], out nMinusLimit);
                int      nServoOnOff  = 0; int.TryParse(strColInClipboard[9], out nServoOnOff);
                int      nInPosBit    = 0; int.TryParse(strColInClipboard[10], out nInPosBit);
                int      nFllowingErr = 0; int.TryParse(strColInClipboard[11], out nFllowingErr);
                int      nAmpFault    = 0; int.TryParse(strColInClipboard[12], out nAmpFault);

                //축 현재 정보 세팅.
                _Axis.CurInfo.Speed         = (fSpeed / (Ix09 * 32.0) * (8388608.0 / Ix10) * 1000.0) / _Axis.Scale;
                _Axis.CurInfo.Position      = (fCurPos + fPosOffset) / (Ix08 * 32.0) / _Axis.Scale;
                _Axis.CurInfo.Torque        = (float)((fTorque / 32767.0) * 100.0);
                _Axis.CurInfo.Plimit        = nPlusLimit;
                _Axis.CurInfo.Mlimit        = nMinusLimit;
                _Axis.CurInfo.ServoOnOff    = nServoOnOff;
                _Axis.CurInfo.InPositionBit = nInPosBit;
                _Axis.CurInfo.FollowingErr  = nFllowingErr;
                _Axis.CurInfo.AmpFault      = nAmpFault;
            }
            return(nRet);
        }
Esempio n. 4
0
        public int IsHomming(AxisInfo _Axisinfo)
        {
            string strCommand = "", strRet = "";
            int    nRtn = -1;

            if (_Axisinfo.HommingCmd == "")
            {
                return(nRtn);
            }

            strCommand = string.Format("{0}", _Axisinfo.HommingCmd);
            SendCommand(strCommand, ref strRet);
            nRtn = int.Parse(strRet);

            _Axisinfo.CurInfo.Homming = nRtn;
            return(nRtn);
        }
Esempio n. 5
0
        public int IsHomeDone(AxisInfo _Axisinfo)
        {
            string strCommand = "", strRet = "";
            int    nRtn = -1;

            if (_Axisinfo.HomeEndCmd == "")
            {
                return(nRtn);
            }

            //Pxx0(홈밍중) Pxx1(홈밍끝)을 의미한다.
            //strCmd.Format("P{0}0", nHomeCmdId);
            strCommand = string.Format("{0}", _Axisinfo.HomeEndCmd);
            SendCommand(strCommand, ref strRet);
            nRtn = int.Parse(strRet);

            _Axisinfo.CurInfo.HomeEnd = nRtn;
            return(nRtn);
        }
Esempio n. 6
0
        public int JogStart(AxisInfo _Axis, int nSpeed, bool bDirection)
        {
            string strCommand = "", strRet = "";
            int    nRtn   = -1;
            string strVel = GetMoveSpeed_Cmd(_Axis.AxisNo_1Base, nSpeed, _Axis.Scale); // 속도 설정
            string strAcc = GetMoveAccel_Cmd(_Axis.AxisNo_1Base, 200);                 // 가속도 설정

            if (bDirection)
            {
                strCommand = string.Format("{0} {1} #{2}J+", strVel, strAcc, _Axis.AxisNo_1Base);
            }
            else
            {
                strCommand = string.Format("{0} {1} #{2}J-", strVel, strAcc, _Axis.AxisNo_1Base);
            }

            nRtn = SendCommand(strCommand, ref strRet);

            return(nRtn);
        }