Exemplo n.º 1
0
 //-->函数:设置Y轴绝对位置
 public static void SetYPosition(double position, double speed, double acc)
 {
     if (Form_Rotate303.SerialRotate.IsOpen == false)
     {
         MessageBox.Show("请先打开串口!");
         return;
     }
     if (Form_Rotate303.Control_State == false)
     {
         MessageBox.Show("请先连接转台!");
         return;
     }
     if (Form_Rotate303.Y_IsZero == false)
     {
         MessageBox.Show("请先给Y轴寻零 !");
         return;
     }
     if ((Form_Rotate303.Y_SetRunWay != 1 && Form_Rotate303.Y_SetRunWay != 0) && Form_Rotate303.Y_Run == true)
     {
         MessageBox.Show("请先停止转台!");
         return;
     }
     Form_Rotate303.SerialRotate.Write(Form_Rotate303.Rotate.YSet(0, position, speed, acc), 0, 16); //设置绝对位置运行和方式
     Form_Rotate303.Delay(50);
     Form_Rotate303.SerialRotate.Write(Form_Rotate303.Rotate.YRun_Position(), 0, 16);               //设置绝对位置运行
     Form_Rotate303.Y_SetRunWay = 1;
     Form_Rotate303.Y_Run       = true;
 }
Exemplo n.º 2
0
        //-->函数:Y轴相对位置转动
        public static void RelYRun(double yPosToRun, double ySpeed, double yAcc)
        {
            double _rotatePosition = Form_Rotate303.Yposition;    //转台位置
            double _position       = yPosToRun + _rotatePosition; //
            int    _circleNum      = Convert.ToInt32(Math.Truncate(_position / 360));

            if (Math.Abs(_position) < 360) //不过360度切换点
            {
                Form_Rotate303.SerialRotate.Write(Form_Rotate303.Rotate.YSet(0, _position, ySpeed, yAcc), 0, 16);
                //设置绝对位置运行和方式
                Form_Rotate303.Delay(50);
                Form_Rotate303.SerialRotate.Write(Form_Rotate303.Rotate.YRun_Position(), 0, 16); //设置绝对位置运行
                Form_Rotate303.Delay(500);
                Form_Rotate303.Y_SetRunWay = 1;
                Form_Rotate303.Y_Run       = true;
                Form_Rotate303.Delay(1000);
                WaitYAxis(); //等待停止
                Form_Rotate303.Delay(500);
            }
            else //过360度切换点,需要转圈
            {
                for (int i = 1; i <= Math.Abs(_circleNum); i++) //转动几个360度
                {
                    Form_Rotate303.SerialRotate.Write(
                        Form_Rotate303.Rotate.YSet(0, Convert.ToDouble(_circleNum / Math.Abs(_circleNum) * 359.9999), ySpeed,
                                                   yAcc), 0, 16);                                    //设置绝对位置运行和方式
                    Form_Rotate303.Delay(50);
                    Form_Rotate303.SerialRotate.Write(Form_Rotate303.Rotate.YRun_Position(), 0, 16); //设置绝对位置运行
                    Form_Rotate303.Delay(500);
                    Form_Rotate303.Y_SetRunWay = 1;
                    Form_Rotate303.Y_Run       = true;
                    Form_Rotate303.Delay(1000);
                    WaitYAxis(); //等待停止
                    Form_Rotate303.Delay(500);
                }
                Form_Rotate303.SerialRotate.Write(Form_Rotate303.Rotate.YSet(0, _position % 360, ySpeed, yAcc), 0, 16);
                //设置绝对位置运行和方式
                Form_Rotate303.Delay(50);
                Form_Rotate303.SerialRotate.Write(Form_Rotate303.Rotate.YRun_Position(), 0, 16); //设置绝对位置运行
                Form_Rotate303.Delay(500);
                Form_Rotate303.Y_SetRunWay = 1;
                Form_Rotate303.Y_Run       = true;
                Form_Rotate303.Delay(1000);
                WaitYAxis(); //等待停止
                Form_Rotate303.Delay(500);
            }
        }