Пример #1
0
        /// <summary>
        /// 輸入Robot設定PNS name, 讀取並執行PNS
        /// </summary>
        /// <param name="PNSname"></param>
        public bool ExecutePNS(string PNSname)
        {
            Array UI                 = new short[18];
            Array UOInfo             = new short[18];
            MvaRobotUIOParameter UIO = new MvaRobotUIOParameter();
            String PNScode;

            if (PNSname.Length == 7 && PNSname.Substring(0, 3) == "PNS")
            {
                PNScode = Convert.ToString(Convert.ToInt32(PNSname.Substring(5)), 2);
                PNScode = PNScode.PadLeft(8, '0');
            }
            else
            {
                throw new System.ArgumentException("PNS Name is NOT match Rule; PNS name:" + PNSname);
            }

            //Write Default UI Setting
            UI.SetValue(UIO.UI1_IMSTP, 0);
            UI.SetValue(UIO.UI2_HOLD, 1);
            UI.SetValue(UIO.UI3_SFSPD, 2);
            UI.SetValue(UIO.UI4_CycleStop, 3);
            UI.SetValue(UIO.UI5_FaultReset_NEGEDGE, 4);
            UI.SetValue(UIO.UI6_Start_NEGEDGE_NoUsed, 5);
            UI.SetValue(UIO.UI7_Home_NoUSed, 6);
            UI.SetValue(UIO.UI8_ENABLE, 7);
            // Select PNS Code
            for (int idx = 0; idx < PNScode.Length; idx++)
            {
                UI.SetValue(Convert.ToInt16(PNScode.Substring(7 - idx, 1)), 8 + idx);
            }

            #region Program Start UI Request
            //Program Start UI timing Request
            //1. Trobe = 1 keep 30ms -> PNS讀取(<130ms)
            //2. ProdStart = 1; trobe =1 and ProdStart keep > 100ms
            //3. ProdStart = 0; trobe =1 and ProdStart = 0 , PROGRUN start in 35 ms
            //4. trobe = 0; Finish All back to 0

            Array UI17_PNStrobe_ProgTiming = new short[4] {
                1, 1, 1, 0
            };
            Array UI18_PNSstart_ProgTiming = new short[4] {
                0, 1, 0, 0
            };

            for (int i = 0; i < 4; i++)
            {
                UI.SetValue(UI17_PNStrobe_ProgTiming.GetValue(i), 16); // PNStrobe
                UI.SetValue(UI18_PNSstart_ProgTiming.GetValue(i), 17); // ProdStart

                mobjCore.WriteSDO(1, ref UI, 18);
                Thread.Sleep(200);
            }
            #endregion

            // Excution Result alarm message
            return(PrgRunningCheck());
        }
Пример #2
0
        public void SystemRecoverAuto()
        {
            try
            {
                isUnderSystemRecoverAuto = true;
                //int UI1_IMSTP = 1;  //Always ON. ON:Normal, OFF:Emergent Stop
                //int UI2_HOLD = 1;  //Always ON. ON:Normal, OFF:PAUSE
                //int UI3_SFSPD = 1;  //Always ON, ON:Normal, OFF:Safty Speed
                //int UI4_CycleStop = 0;  //ON: [True]Abort, OFF: NA
                //int UI5_FaultReset_NEGEDGE = 1;  //Negtive Edge trigger(1 ->0)
                //int UI6_Start_NEGEDGE_NoUsed = 1;
                //int UI7_Home_NoUSed = 0;
                //int UI8_ENABLE = 1;  //Always ON, ON:ENavle Robot Action,OFF:Otherwise
                //Array UI9to16_PNS = new int[8];  //8bit PNS selection
                //int UI17_PNStrobe_POSEDGE = 0;  //Positive Edge trigger(0 ->1)
                //int UI18_ProdStart = 0;  //ON keep  >100ms, then Off tonegtive trigger

                Array UO3_ProgRunnungValue = new short[1];

                bool IsRestSUccess;
                //bool IsRWSucess = false;	// 移除未使用的變數。by YMWANGN, 2016/11/17。

                MvaRobotUIOParameter UIO = new MvaRobotUIOParameter();

                Array UI             = new short[18];
                Array UOInfo         = new short[18];
                Array UI18_ProdStart = new short[1];
                Array UI4_CycleStop  = new short[1];

                IsRestSUccess = AlarmReset();

                UIO.UI17_PNStrobe_POSEDGE = 0;            //UI[17]:________(30ms)Positive edge trigger(Keep 30ms ), then fetch PNS:10000000
                UI.SetValue(UIO.UI1_IMSTP, 0);
                UI.SetValue(UIO.UI2_HOLD, 1);
                UI.SetValue(UIO.UI3_SFSPD, 2);
                UI.SetValue(UIO.UI4_CycleStop, 3);
                UI.SetValue(UIO.UI5_FaultReset_NEGEDGE, 4);
                UI.SetValue(UIO.UI6_Start_NEGEDGE_NoUsed, 5);
                UI.SetValue(UIO.UI7_Home_NoUSed, 6);
                UI.SetValue(UIO.UI8_ENABLE, 7);
                UI.SetValue(UIO.UI9to16_PNS.GetValue(0), 8);   //PNS Code =10000000
                UI.SetValue(UIO.UI9to16_PNS.GetValue(1), 9);
                UI.SetValue(UIO.UI9to16_PNS.GetValue(2), 10);
                UI.SetValue(UIO.UI9to16_PNS.GetValue(3), 11);
                UI.SetValue(UIO.UI9to16_PNS.GetValue(4), 12);
                UI.SetValue(UIO.UI9to16_PNS.GetValue(5), 13);
                UI.SetValue(UIO.UI9to16_PNS.GetValue(6), 14);
                UI.SetValue(UIO.UI9to16_PNS.GetValue(7), 15);
                UI.SetValue(UIO.UI17_PNStrobe_POSEDGE, 16);   //UI[17]:___________      LOW first,  Positive edge trigger(Keep 30ms ), thenfetch PNS:10000000
                UI.SetValue(UIO.UI18_ProdStart, 17);          //       ___________
                //UI[18]: (100ms)HIGH firs, negedge edge trigger(posedge keep 100ms first)
                mobjCore.WriteSDO(1, ref UI, 18);             //Initial State
                mobjCore.ReadUO(1, ref UOInfo, 18);
                Thread.Sleep(200);

                UIO.UI6_Start_NEGEDGE_NoUsed = 1;         //No use
                UIO.UI7_Home_NoUSed          = 0;         //No use
                //                ________
                UIO.UI17_PNStrobe_POSEDGE = 1;            //UI[17]:________|(30ms)Positive edge trigger(Keep 30ms ), then fetch PNS:10000000
                UIO.UI18_ProdStart        = 1;            //       ________
                //UI[18]: (100ms)|________negedge edge trigger(posedge keep 100ms first)
                UI.SetValue(UIO.UI1_IMSTP, 0);
                UI.SetValue(UIO.UI2_HOLD, 1);
                UI.SetValue(UIO.UI3_SFSPD, 2);
                UI.SetValue(UIO.UI4_CycleStop, 3);
                UI.SetValue(UIO.UI5_FaultReset_NEGEDGE, 4);
                UI.SetValue(UIO.UI6_Start_NEGEDGE_NoUsed, 5);
                UI.SetValue(UIO.UI7_Home_NoUSed, 6);
                UI.SetValue(UIO.UI8_ENABLE, 7);
                UI.SetValue(UIO.UI17_PNStrobe_POSEDGE, 16);
                UI.SetValue(UIO.UI18_ProdStart, 17);

                mobjCore.WriteSDO(1, UI, 17);
                mobjCore.ReadUO(1, ref UOInfo, 18);
                Thread.Sleep(200);

                if (Convert.ToInt32(UOInfo.GetValue(2).ToString()) == 1 ||  //Program is runnung
                    Convert.ToInt32(UOInfo.GetValue(3).ToString()) == 1)    //Program is paused
                {
                    UI4_CycleStop.SetValue((short)1, 0);                    //Abort first
                    mobjCore.WriteSDO(4, ref UI4_CycleStop, 1);

                    Thread.Sleep(100);

                    UI4_CycleStop.SetValue((short)0, 0);
                    mobjCore.WriteSDO(4, ref UI4_CycleStop, 1);
                }

                UI18_ProdStart.SetValue((short)0, 0);  //negedge edge trigger(posedgekeep 100ms first)
                mobjCore.WriteSDO(18, ref UI18_ProdStart, 1);

                Thread.Sleep(35);
            }
            finally
            {
                isUnderSystemRecoverAuto = false;
            }
        }