Ejemplo n.º 1
0
        private void btnNmove_Click(object sender, EventArgs e)
        {
            double m_Tacc = Double.Parse(txtTacc.Text), m_Tdec = Double.Parse(txtTdec.Text);
            int    m_Rpm = Int16.Parse(txtRpm.Text);

            gnodeid = ushort.Parse(cmbNodeID.Text);

            rc = CPCI_DMC.CS_DMC_01_set_velocity_mode(gCardNo, gnodeid, 0, m_Tacc, m_Tdec);
            rc = CPCI_DMC.CS_DMC_01_set_velocity(gCardNo, gnodeid, 0, 0 - m_Rpm);
        }
Ejemplo n.º 2
0
        private void btnWork_Click(object sender, EventArgs e)
        {
            btnWork.Enabled   = false;
            btnFinish.Enabled = true;
            bool check_para = true;

            if (IfTime.Checked)
            {
                try
                {
                    timer1.Interval = int.Parse(TimeValue.Text) * 1000;
                    timer1.Tick    += new EventHandler(btnFinish_Click);
                    timer1.Enabled  = true;
                    LogOutput("定時功能啟動");
                }
                catch (Exception)
                {
                    timer1.Enabled = false;
                    LogOutput("時間設定錯誤");
                }
            }
            if (int.Parse(txtRpm2.Text) > ServoMaxSpeed)
            {
                check_para = false;
            }


            if (check_para)
            {
                LogOutput("實驗開始");
                ServoON(true);
                SetChartType();
                CleanChart();
                Set_Chart();
                ThWorking_PLC = new Thread(working_PLC);
                ThWorking_PLC.Start();



                double m_Tacc = Double.Parse(txtTacc.Text), m_Tdec = Double.Parse(txtTdec.Text);
                int    m_Rpm = Int16.Parse(txtRpm2.Text) * 10;
                gnodeid = ushort.Parse(cmbNodeID.Text);
                /* Set up Velocity mode parameter */
                rc = CPCI_DMC.CS_DMC_01_set_velocity_mode(gCardNo, node1, 0, m_Tacc, m_Tdec);
                //* Start Velocity move: rpm > 0 move forward , rpm < 0 move negative */
                rc = CPCI_DMC.CS_DMC_01_set_velocity(gCardNo, node1, 0, m_Rpm);

                //ThUpdateChart = new Thread(Update_Chart);
                //ThUpdateChart.Start();
            }
            else
            {
                LogOutput("設定有誤");
            }
        }
Ejemplo n.º 3
0
        private void btnNmove_Click_1(object sender, EventArgs e)
        {
            double m_Tacc = Double.Parse(txtTacc.Text), m_Tdec = Double.Parse(txtTdec.Text);
            int    m_Rpm = Int16.Parse(txtRpm1.Text);

            gnodeid = ushort.Parse(cmbNodeID.Text);
            /* Set up Velocity mode parameter */
            rc = CPCI_DMC.CS_DMC_01_set_velocity_mode(gCardNo, node2, 0, m_Tacc, m_Tdec);
            //* Start Velocity move: rpm > 0 move forward , rpm < 0 move negative */
            rc = CPCI_DMC.CS_DMC_01_set_velocity(gCardNo, node2, 0, -1 * m_Rpm);
        }
Ejemplo n.º 4
0
 private void AutoHome()
 {
     while (true)
     {
         homeSend("000000000006" + "010204000001");
         homeListen();
         showMotorState();
         if (label31.Text == "01-02-01-01")
         {
             rc = CPCI_DMC.CS_DMC_01_set_velocity_mode(gCardNo, node2, 0, 0.1, 0.1);
             rc = CPCI_DMC.CS_DMC_01_set_velocity(gCardNo, node2, 0, 1300);
         }
         else
         {
             rc = CPCI_DMC.CS_DMC_01_sd_stop(gCardNo, node2, 0, 0.01);
             CPCI_DMC.CS_DMC_01_set_position(gCardNo, node2, 0, 0);
             CPCI_DMC.CS_DMC_01_set_command(gCardNo, node2, 0, 0);
             break;
         }
     }
 }
Ejemplo n.º 5
0
        public void working()
        {
            int Amount = Convert.ToInt32(txtAmount.Text);

            for (int i = 0; i < Amount; i++)
            {
                //ktrRpm1.Clear();
                //ktrRpm2.Clear();
                //ktrTorque1.Clear();
                //ktrTorque2.Clear();
                //motorRpm1.Clear();
                //motorRpm2.Clear();
                //motorTorque1.Clear();
                //motorTorque2.Clear();
                chart1.Series[0].Points.Clear();
                chart2.Series[0].Points.Clear();
                chart3.Series[0].Points.Clear();
                chart4.Series[0].Points.Clear();
                chart5.Series[0].Points.Clear();
                chart6.Series[0].Points.Clear();
                chart7.Series[0].Points.Clear();
                chart8.Series[0].Points.Clear();
                bool boolGo = true;
                newturn = true;
                rc      = CPCI_DMC.CS_DMC_01_get_command(gCardNo, node2, 0, ref cmd1);
                rc      = CPCI_DMC.CS_DMC_01_start_tr_move(gCardNo, node2, 0, (int)(OneCirclePluse * TransmissionRate), 0, Convert.ToInt32(2133.3333 * -Int16.Parse(txtRpm1.Text)), 0.1, 0.1);
                while (true)
                {
                    showMotorState();
                    saveMotorData();
                    showChart();
                    limitSend("000000000006" + "010204000001");
                    limitX0Listen();
                    limitSend("000000000006" + "010204010001");
                    limitX1Listen();
                    label30.Text = X0Message;
                    if (X1Message == "01-02-01-01" & boolGo)
                    {
                        rc = CPCI_DMC.CS_DMC_01_set_velocity_mode(gCardNo, node1, 0, 0.1, 0.1);
                        rc = CPCI_DMC.CS_DMC_01_set_velocity(gCardNo, node1, 0, Int32.Parse(txtRpm2.Text));
                    }
                    else if (X1Message == "01-02-01-00")
                    {
                        rc     = CPCI_DMC.CS_DMC_01_set_velocity_mode(gCardNo, node1, 0, 0.1, 0.1);
                        rc     = CPCI_DMC.CS_DMC_01_set_velocity(gCardNo, node1, 0, 0);
                        boolGo = false;
                    }
                    else if (X1Message == "01-02-01-01" & !boolGo & X0Message != "01-02-01-00")
                    {
                        rc = CPCI_DMC.CS_DMC_01_set_velocity_mode(gCardNo, node1, 0, 0.1, 0.1);
                        rc = CPCI_DMC.CS_DMC_01_set_velocity(gCardNo, node1, 0, -Int32.Parse(txtRpm2.Text));
                    }
                    else if (X0Message == "01-02-01-00" & !boolGo)
                    {
                        KtrBoolClear = true;
                        label29.Text = "in";
                        showMotorState();
                        rc = CPCI_DMC.CS_DMC_01_set_velocity_mode(gCardNo, node1, 0, 0.1, 0.1);
                        rc = CPCI_DMC.CS_DMC_01_set_velocity(gCardNo, node1, 0, 0);
                        Thread.Sleep(500);
                        CPCI_DMC.CS_DMC_01_set_position(gCardNo, node1, 0, 0);
                        CPCI_DMC.CS_DMC_01_set_command(gCardNo, node1, 0, 0);
                        //CPCI_DMC.CS_DMC_01_set_position(gCardNo, node2, 0, 0);
                        //CPCI_DMC.CS_DMC_01_set_command(gCardNo, node2, 0, 0);
                        break;
                    }
                }
            }
        }