Esempio n. 1
0
        public void MoveRelative(int x, int y)
        {
            double praAcc = 1000000;
            double praDec = 1000000;
            int    praVm  = 1000;
            int    pulseX = x;
            int    pulseY = y;

            if (IsInitialed == false)
            {
                return;
            }

            APS168.APS_set_axis_param_f(_selectAxisX, (Int32)APS_Define.PRA_ACC, praAcc); // Set acceleration rate
            APS168.APS_set_axis_param_f(_selectAxisX, (Int32)APS_Define.PRA_DEC, praDec); // Set deceleration rate

            APS168.APS_set_axis_param_f(_selectAxisY, (Int32)APS_Define.PRA_ACC, praAcc); // Set acceleration rate
            APS168.APS_set_axis_param_f(_selectAxisY, (Int32)APS_Define.PRA_DEC, praDec); // Set deceleration rate


            //if (_card0.IsLoadXmlFile)
            {
                Task task = new Task(() =>
                {
                    APS168.APS_relative_move(_selectAxisX, pulseX, praVm);
                    APS168.APS_relative_move(_selectAxisY, pulseY, praVm);

                    //等待Motion Down完成
                    int motionStatusMdn = 5;
                    while ((APS168.APS_motion_status(_selectAxisX) & 1 << motionStatusMdn) == 0 && (APS168.APS_motion_status(_selectAxisY) & 1 << motionStatusMdn) == 0)
                    {
                        Thread.Sleep(100);
                    }
                    //MessageBox.Show("运动完成!");
                });
                task.Start();
            }
        }
Esempio n. 2
0
        public override bool  Open()
        {
            int boardIdInBits = 0;
            // Card(Board) initial,mode bit0(0:By system assigned, 1:By dip switch)
            int ret = APS168.APS_initial(ref boardIdInBits, m_cardIdMode);

            if (ret >= 0)
            {
                APS168.APS_get_first_axisId(m_cardId, ref m_startAxisIndex, ref m_totalAxisCount);
                int CardName = 0;
                APS168.APS_get_card_name(m_cardId, ref CardName);
                if (CardName != (Int32)APS_Define.DEVICE_NAME_PCI_825458 && CardName != (Int32)APS_Define.DEVICE_NAME_AMP_20408C)
                {
                    throw new Exception("运动控制是型号不是204C或208C!");
                }
            }
            else
            {
                throw new Exception("运动控制卡初始化失败,请检查驱动是否装好或者MotionCreatePro已经开启!");
            }
            m_isInitialed = true;
            return(true);
        }
Esempio n. 3
0
        public int GetAllOutput(int startindex, int offset)
        {
            if (!m_isInitialed)
            {
                throw new Exception("请先初始化");
            }
            int data = 0;

            for (int i = 0; i < offset; i++)
            {
                int index   = startindex + i;
                int group   = index / 32;
                int channel = index % 32;
                int _data   = 0;
                int rtn     = APS168.APS_read_d_channel_output(m_cardId, group, channel, ref _data);
                if (rtn != 0)
                {
                    throw new Exception("GetMultiOutput 失败");
                }
                data = (data << 1) | _data;
            }
            return(data);
        }
Esempio n. 4
0
        public void MoveAbs(int x, int y)
        {
            //_selectAxis = Convert.ToInt32(cmbSelectAxis.SelectedItem);
            double praAcc = 1000000;
            double praDec = 1000000;
            int    praVm  = 1000;
            int    pulseX = x;
            int    pulseY = y;

            if (IsInitialed == false)
            {
                return;
            }

            APS168.APS_set_axis_param_f(_selectAxisX, (Int32)APS_Define.PRA_ACC, praAcc); // Set acceleration rate
            APS168.APS_set_axis_param_f(_selectAxisX, (Int32)APS_Define.PRA_DEC, praDec); // Set deceleration rate

            APS168.APS_set_axis_param_f(_selectAxisY, (Int32)APS_Define.PRA_ACC, praAcc); // Set acceleration rate
            APS168.APS_set_axis_param_f(_selectAxisY, (Int32)APS_Define.PRA_DEC, praDec); // Set deceleration rate

            //if (_card0.IsLoadXmlFile)
            {
                Task task = new Task(() =>
                {
                    APS168.APS_absolute_move(_selectAxisX, pulseX, praVm);
                    APS168.APS_absolute_move(_selectAxisY, pulseY, praVm);

                    //等待Motion Down完成
                    int motionStatusMdn = 5;
                    while ((APS168.APS_motion_status(_selectAxisX) & 1 << motionStatusMdn) == 0 && (APS168.APS_motion_status(_selectAxisY) & 1 << motionStatusMdn) == 0)
                    {
                        Thread.Sleep(100);
                    }
                });
                task.Start();
            }
        }
Esempio n. 5
0
        public void GetLineValues(int pxStart, int pyStart, int pxEnd, int pyEnd, ref List <LineData> data)
        {
            LineData tempDate = new LineData();

            int[] Axis_ID = new int[2] {
                _selectAxisX, _selectAxisY
            };
            double[] PositionStart = new double[2] {
                pxStart, pyStart
            };
            double[] PositionEnd = new double[2] {
                pxEnd, pyEnd
            };

            Class_8338.Interpolation_2D_line_move(Axis_ID, PositionStart, false);
            //add start
            tempDate.X = pxStart;
            tempDate.Y = pyStart;
            tempDate.Z = ReadSickValue();
            data.Add(tempDate);

            Class_8338.Interpolation_2D_line_moveNowait(Axis_ID, PositionEnd, false);
            int motionStatusMdn = 5;

            while ((APS168.APS_motion_status(Axis_ID[0]) & 1 << motionStatusMdn) == 0 && (APS168.APS_motion_status(Axis_ID[1]) & 1 << motionStatusMdn) == 0)
            {
                Thread.Sleep(300);
                tempDate.Z = ReadSickValue();
                GetPostionAbs(ref tempDate.X, ref tempDate.Y);
                data.Add(tempDate);
            }
            //add end
            tempDate.X = pxEnd;
            tempDate.Y = pyEnd;
            tempDate.Z = ReadSickValue();
            data.Add(tempDate);
        }
Esempio n. 6
0
        /// <summary>
        ///     检查回零是否完成
        /// </summary>
        /// <param name="axisNo"></param>
        /// <returns></returns>
        public int CheckHomeDone(int axisNo, double timeoutLimit)
        {
            var status = 0;

            var strtime = new Stopwatch();

            strtime.Start();

            do
            {
                //检查运动是否完成
                status = APS168.APS_motion_status(axisNo);
                if (((status >> (int)APS_Define.MTS_ASTP) & 1) == 1)
                {
                    return(-1);
                }
                status = (status >> (int)APS_Define.MTS_HMV) & 1;
                if (status == 0)
                {
                    break;
                }

                //检查是否超时
                strtime.Stop();
                if (strtime.ElapsedMilliseconds / 1000.0 > timeoutLimit)
                {
                    APS168.APS_emg_stop(axisNo);
                    return(-2);
                }
                strtime.Start();

                //延时
                Thread.Sleep(20);
            } while (true);

            return(0);
        }
Esempio n. 7
0
        public int SetDO(int index, bool isON)
        {
            Int32 do_group = 0;
            Int32 do_data  = 0;

            if (index < 0 || index >= DOCount)
            {
                throw new Exception(string.Format("SetDO(index = {0}, isON) index is out of range:0~{1}", index, DOCount - 1));
            }

            lock (asynLocker)
            {
                do_data = (isON ? 1 : 0);
                if (!IsOpen)
                {
                    return((int)ErrorDef.NotOpen);
                }
                if (APS168.APS_write_d_channel_output(BoardID, do_group, index + 8, do_data) != 0)
                {
                    return((int)ErrorDef.InvokeFailed);
                }
            }
            return((int)ErrorDef.Success);
        }
Esempio n. 8
0
        private void WaitInterrutp(int taskId, int interruptId)
        {
            // 显示对话框表示等待触发线程执行了
            MessageBox.Show("TaskId=" + taskId + "   interruptId= " + interruptId);

            while (_waitIntFlag[taskId])
            {
                if (APS168.APS_wait_single_int(interruptId, 0x0000ff) == 0) //Wait interrupt
                {
                    _interruptCount[taskId]++;
                    APS168.APS_reset_int(interruptId);

                    BeginInvoke((MethodInvoker) delegate
                    {
                        txtIntCount0.Text = _interruptCount[0].ToString();
                        txtIntCount1.Text = _interruptCount[1].ToString();
                        txtIntCount2.Text = _interruptCount[2].ToString();
                        txtIntCount3.Text = _interruptCount[3].ToString();
                        txtIntCount4.Text = _interruptCount[4].ToString();
                        txtIntCount5.Text = _interruptCount[5].ToString();
                    });
                }
            }
        }
Esempio n. 9
0
        private void button7_Click(object sender, EventArgs e)
        {
            //重置触发计数
            APS168.APS_reset_trigger_count(_card0.CardId, 0);
            APS168.APS_reset_trigger_count(_card0.CardId, 1);

            //关闭触发
            APS168.APS_set_trigger_param(_card0.CardId, (short)APS_Define.TGR_TRG_EN, 0);

            //TRG 0 ~ 3 enable by bit
            APS168.APS_set_trigger_param(_card0.CardId, (short)APS_Define.TGR_TRG_EN, Convert.ToInt32("0001", 2));

            //Source Encoder0
            APS168.APS_set_trigger_param(_card0.CardId, (short)APS_Define.TGR_LCMP0_SRC, 0);

            //Trigger output 0 (TRG0) source Bit( 1:On, 0:Off)    Bit 0: Manual  Bit 1:Reserved Bit  2:TCMP0  Bit 3:TCMP1  Bit 4:LCMP0  Bit 5:LCMP1
            APS168.APS_set_trigger_param(_card0.CardId, (short)APS_Define.TGR_TRG0_SRC, Convert.ToInt32("10000", 2));
            //TRG1 pulse width
            APS168.APS_set_trigger_param(_card0.CardId, (short)APS_Define.TGR_TRG0_PWD, 250000);  //  pulse width=  value * 0.02 us
            //TRG 1 logic  0: Not inverse  1:Inverse
            APS168.APS_set_trigger_param(_card0.CardId, (short)APS_Define.TGR_TRG0_LOGIC, 1);

            APS168.APS_set_trigger_linear(_card0.CardId, 0, 0, 1000, 50);
        }
Esempio n. 10
0
        public bool InitialFixture(int cardId, int mode)
        {
            CardId = cardId;
            int boardIdInBits = 0;
            // Card(Board) initial,mode bit0(0:By system assigned, 1:By dip switch)
            int ret = APS168.APS_initial(ref boardIdInBits, mode);

            if (ret >= 0)
            {
                APS168.APS_get_first_axisId(cardId, ref StartAxisId, ref TotalAxis);
                APS168.APS_get_card_name(cardId, ref CardName);
                if (CardName != (Int32)APS_Define.DEVICE_NAME_PCI_825458 && CardName != (Int32)APS_Define.DEVICE_NAME_AMP_20408C)
                {
                    //MessageBox.Show("运动控制是型号不是204C或208C!");
                    return(false);
                }
            }
            else
            {
                //MessageBox.Show("运动控制卡初始化失败,请检查驱动是否装好或者MotionCreatePro已经开启!");
                return(false);
            }


            //判断配置文件是否存在
            if (File.Exists(txtXmlFilename))
            {
                if (LoadParamFromFile(txtXmlFilename) == false)
                {
                    return(false);
                }
            }

            IsInitialed = true;
            return(true);
        }
Esempio n. 11
0
        public void ServoOn(bool onOff)
        {
            bool status;

            if (IsInitialed == false)
            {
                return;
            }

            int motionIoStatusX = APS168.APS_motion_io_status(_selectAxisX);

            //if (motionIoStatusX == 0)
            {
                status = (motionIoStatusX & (1 << 7)) != 0;
                APS168.APS_set_servo_on(_selectAxisX, Convert.ToInt32(!status));
            }
            Thread.Sleep(100);
            int motionIoStatusY = APS168.APS_motion_io_status(_selectAxisY);
            //if (motionIoStatusY == 0)
            {
                status = (motionIoStatusY & (1 << 7)) != 0;
                APS168.APS_set_servo_on(_selectAxisY, Convert.ToInt32(!status));
            }
        }
Esempio n. 12
0
        private void buttonArc3_Click(object sender, EventArgs e)
        {
            var boardId = Convert.ToInt32(txtCardId.Text);

            //重置触发计数
            APS168.APS_reset_trigger_count(boardId, 0);
            APS168.APS_reset_trigger_count(boardId, 1);

            var ptbId     = 0; //Point table id 0
            var dimension = 3; //2D point table
            var ret       = 0;

            var Axis_ID_Array = new[] { 0, 1, 2 };

            var Status = new PTSTS();
            var Line   = new PTLINE();

            //Check servo on or not
            //for (i = 0; i < dimension; i++)
            //{
            //    ret = APS168.APS_set_servo_on(Axis_ID_Array, 1);
            //}
            //Thread.Sleep(500); // Wait stable.

            //Enable point table
            ret = APS168.APS_pt_disable(boardId, ptbId);
            /////////////////////////ret = APS168.APS_pt_enable(boardId, ptbId, dimension, Axis_ID_Array);
            ret = APS168.APS_pt_enable(boardId, ptbId, dimension, Axis_ID_Array);

            //Configuration
            ret = APS168.APS_pt_set_absolute(boardId, ptbId);       //Set to absolute mode
            ret = APS168.APS_pt_set_trans_buffered(boardId, ptbId); //Set to buffer mode
            ret = APS168.APS_pt_set_acc(boardId, ptbId, 5000000);   //Set acc
            ret = APS168.APS_pt_set_dec(boardId, ptbId, 5000000);   //Set dec

            ret = APS168.APS_get_pt_status(boardId, ptbId, ref Status);
            if ((Status.BitSts & 0x02) == 0) //Buffer is not Full
            {
                Line.Dim = 3;


                double vepoint = 100000;

                double Vquick = 1500000;
                double Vslow  = 300000;


                {
                    var pwdell = new PTDWL();
                    pwdell.DwTime = 2000;

                    //Line.Pos = new double[] { -206000, -20000, 0, 0, 0, 0 };
                    //ret = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);

                    //1st line


                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vquick);
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, Vquick);
                    Line.Pos = new double[] { -218000, -22000, 50, 0, 0, 0 };
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status); //1段起始点

                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vquick);
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, Vslow * 0.6);
                    Line.Pos = new double[] { -56000, -22000, 50, 0, 0, 0 };
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status); //high


                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vslow);
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, vepoint);
                    Line.Pos = new double[] { 114000, -22000, 50, 0, 0, 0 };
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status); //low

                    if (checkBoxOnly1.Checked)
                    {
                        ret = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);
                        ret = APS168.APS_pt_start(boardId, ptbId);
                        return;
                    }

                    //圆弧线段1
                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vquick);
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, vepoint);
                    Line.Pos = new double[] { -25000, 17000, 6250, 0, 0, 0 };
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);

                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vquick);
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, vepoint);
                    Line.Pos = new double[] { 35000, 17000, 6250, 0, 0, 0 };
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);

                    ////2nd line
                    ////bypass


                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vquick); //Delete by Tony
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, vepoint);
                    Line.Pos = new double[] { -126000, 14000, 12450, 0, 0, 0 };
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status); //2段起始点


                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vquick);  //Set vm to 10000
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, vepoint); //Set ve to 5000
                    Line.Pos = new double[] { 34000, 14000, 12450, 0, 0, 0 }; //触发2
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);

                    //圆弧线段2
                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vquick);
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, vepoint);
                    Line.Pos = new double[] { -125000, 18000, 18750, 0, 0, 0 };
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);

                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vquick);
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, vepoint);
                    Line.Pos = new double[] { -65000, 18000, 18750, 0, 0, 0 };
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);


                    //3 line slow
                    //bypass

                    //slow

                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vquick);
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, vepoint);
                    Line.Pos = new double[] { -205000, -22000, 25000, 0, 0, 0 };
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status); //第3段起始点


                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vslow);
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, vepoint);
                    Line.Pos = new double[] { -95000, -22000, 25000, 0, 0, 0 };
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);


                    //quick

                    ret = APS168.APS_pt_set_vm(boardId, ptbId, Vquick);  //ret = APS168.APS_pt_set_vm(boardId, ptbId, Vquick); //Set vm to 10000
                    ret = APS168.APS_pt_set_ve(boardId, ptbId, vepoint); //ret = APS168.APS_pt_set_ve(boardId, ptbId, vepointlow); //Set ve to 5000


                    //ret = APS168.APS_pt_set_vm(boardId, ptbId, Vslow);//ret = APS168.APS_pt_set_vm(boardId, ptbId, Vquick); //Set vm to 10000
                    //ret = APS168.APS_pt_set_ve(boardId, ptbId, Vslow * 2); //ret = APS168.APS_pt_set_ve(boardId, ptbId, vepointlow); //Set ve to 5000
                    Line.Pos = new double[] { 120000, -22000, 25000, 0, 0, 0 }; //触发3
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);


                    //圆弧线段3
                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vslow); //ret = APS168.APS_pt_set_vm(boardId, ptbId, Vquick);
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, vepoint);
                    Line.Pos = new double[] { -20000, 20500, 31250, 0, 0, 0 };
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);

                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vslow); //ret = APS168.APS_pt_set_vm(boardId, ptbId, Vquick);
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, vepoint);
                    Line.Pos = new double[] { 35000, 20500, 31250, 0, 0, 0 };
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);

                    ////4 line


                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vquick);  //Set vm to 10000
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, vepoint); //Set ve to 5000
                    Line.Pos = new double[] { -130000, 20000, 37600, 0, 0, 0 };
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);

                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vslow);   //Set vm to 10000
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, vepoint); //Set ve to 5000
                    Line.Pos = new double[] { 35000, 20000, 37600, 0, 0, 0 }; //触发4
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);

                    //圆弧线段4
                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vquick);
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, vepoint);
                    Line.Pos = new double[] { -125000, 23000, 43750, 0, 0, 0 };
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);

                    ret      = APS168.APS_pt_set_vm(boardId, ptbId, Vquick);
                    ret      = APS168.APS_pt_set_ve(boardId, ptbId, vepoint);
                    Line.Pos = new double[] { -90000, 23000, 43750, 0, 0, 0 };
                    ret      = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);
                }

                //Push 1st point to buffer
                ret = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);
            }

            ret = APS168.APS_pt_start(boardId, ptbId);
        }
Esempio n. 13
0
        private void button7_Click(object sender, EventArgs e)
        {
            var boardId = Convert.ToInt32(txtCardId.Text);
            int motionStatusCstp = 0, motionStatusAstp = 16;

            APS168.APS_absolute_move(0, -220000, 50000);
            while ((APS168.APS_motion_status(0) & (1 << motionStatusCstp)) == 0)
            {
                Thread.Sleep(100);
            }

            if ((APS168.APS_motion_status(0) & (1 << motionStatusAstp)) == 0)
            {
                MessageBox.Show("轴" + "到位成功!");
            }
            else
            {
                MessageBox.Show("轴" + "到位失败!");
            }

            Thread.Sleep(500);

            APS168.APS_absolute_move(1, 30000, 10000);
            while ((APS168.APS_motion_status(1) & (1 << motionStatusCstp)) == 0)
            {
                Thread.Sleep(100);
            }

            if ((APS168.APS_motion_status(1) & (1 << motionStatusAstp)) == 0)
            {
                MessageBox.Show("轴" + "到位成功!");
            }
            else
            {
                MessageBox.Show("轴" + "到位失败!");
            }

            APS168.APS_absolute_move(2, 0, 10000);
            while ((APS168.APS_motion_status(2) & (1 << motionStatusCstp)) == 0)
            {
                Thread.Sleep(100);
            }

            if ((APS168.APS_motion_status(2) & (1 << motionStatusAstp)) == 0)
            {
                MessageBox.Show("轴" + "到位成功!");
            }
            else
            {
                MessageBox.Show("轴" + "到位失败!");
            }

            APS168.APS_absolute_move(1, -15000, 10000);

            //关闭触发
            APS168.APS_set_trigger_param(boardId, (short)APS_Define.TGR_TRG_EN, 0);
            //TRG 0 ~ 3 enable by bit
            APS168.APS_set_trigger_param(boardId, (short)APS_Define.TGR_TRG_EN, Convert.ToInt32("0001", 2));
            //Source Encoder0
            APS168.APS_set_trigger_param(boardId, (short)APS_Define.TGR_TCMP0_SRC, 0);
            //Bi-direction(No direction)
            APS168.APS_set_trigger_param(boardId, (short)APS_Define.TGR_TCMP0_DIR, 1);
            //Trigger output 0 (TRG0) source Bit( 1:On, 0:Off)    Bit 0: Manual  Bit 1:Reserved Bit  2:TCMP0  Bit 3:TCMP1  Bit 4:LCMP0  Bit 5:LCMP1
            APS168.APS_set_trigger_param(boardId, (short)APS_Define.TGR_TRG0_SRC, Convert.ToInt32("0100", 2));
            //TRG1 pulse width
            APS168.APS_set_trigger_param(boardId, (short)APS_Define.TGR_TRG0_PWD, 1500); //  pulse width=  value * 0.02 us
            //TRG 1 logic  0: Not inverse  1:Inverse
            APS168.APS_set_trigger_param(boardId, (short)APS_Define.TGR_TRG0_LOGIC, 0);

            //add points to 1th
            //int[] xPoint = new int[] { 100000, 90000, 80000 };


            var xPoint  = new int[330];
            var csvFile = new CsvReader("x1.csv");

            var xTable = csvFile.ReadIntoDataTable(new[] { typeof(int) });

            for (var i = 0; i < 330; i++)
            {
                xPoint[i] = Convert.ToInt32(xTable.Rows[i][0]);                           //表格行的数据
            }
            APS168.APS_set_trigger_table(boardId, 0, xPoint, 330);
        }
Esempio n. 14
0
        private void btnLineTrigTest_Click(object sender, EventArgs e)
        {
            int motionStatusCstp = 0, motionStatusAstp = 16;
            var boardId = Convert.ToInt32(txtCardId.Text);

            var praAcc = Convert.ToDouble(txtPraAcc.Text);
            var praDec = Convert.ToDouble(txtPraDec.Text);

            APS168.APS_set_axis_param_f(0, (int)APS_Define.PRA_ACC, praAcc); // Set acceleration rate
            APS168.APS_set_axis_param_f(0, (int)APS_Define.PRA_DEC, praDec); // Set deceleration rate

            //回起始点
            APS168.APS_absolute_move(0, -220000, 100000);
            APS168.APS_absolute_move(1, -15000, 100000);
            APS168.APS_absolute_move(2, 0, 10000);

            while ((APS168.APS_motion_status(0) & (1 << motionStatusCstp)) == 0)
            {
                Thread.Sleep(100);
            }

            if ((APS168.APS_motion_status(0) & (1 << motionStatusAstp)) == 0)
            {
            }

            APS168.APS_absolute_move(0, -62000, 50000);

            while ((APS168.APS_motion_status(0) & (1 << motionStatusCstp)) == 0)
            {
                Thread.Sleep(100);
            }

            if ((APS168.APS_motion_status(0) & (1 << motionStatusAstp)) == 0)
            {
            }

            //关闭触发
            APS168.APS_set_trigger_param(boardId, (short)APS_Define.TGR_TRG_EN, 0);
            //TRG 0 ~ 3 enable by bit
            APS168.APS_set_trigger_param(boardId, (short)APS_Define.TGR_TRG_EN, Convert.ToInt32("0001", 2));
            //Source Encoder0
            APS168.APS_set_trigger_param(boardId, (short)APS_Define.TGR_TCMP0_SRC, 0);
            //Bi-direction(No direction)
            APS168.APS_set_trigger_param(boardId, (short)APS_Define.TGR_TCMP0_DIR, 1);
            //Trigger output 0 (TRG0) source Bit( 1:On, 0:Off)    Bit 0: Manual  Bit 1:Reserved Bit  2:TCMP0  Bit 3:TCMP1  Bit 4:LCMP0  Bit 5:LCMP1
            APS168.APS_set_trigger_param(boardId, (short)APS_Define.TGR_TRG0_SRC, Convert.ToInt32("11000", 2));
            //TRG1 pulse width
            APS168.APS_set_trigger_param(boardId, (short)APS_Define.TGR_TRG0_PWD, 2000); //  pulse width=  value * 0.02 us
            //TRG 1 logic  0: Not inverse  1:Inverse
            APS168.APS_set_trigger_param(boardId, (short)APS_Define.TGR_TRG0_LOGIC, 0);

            //重置触发计数
            APS168.APS_reset_trigger_count(boardId, 0);
            APS168.APS_reset_trigger_count(boardId, 1);

            APS168.APS_set_trigger_linear(boardId, 0, -61000, 900, 11);
            APS168.APS_relative_move(0, 20000, 5000);

            //Int32 ptbId = 0;          //Point table id 0
            //Int32 dimension = 3;      //2D point table
            //Int32 i = 0;
            //Int32 ret = 0;

            //int[] Axis_ID_Array = new int[] { 0, 1, 2 };

            //PTSTS Status = new PTSTS();
            //PTLINE Line = new PTLINE();

            ////Enable point table
            //ret = APS168.APS_pt_disable(boardId, ptbId);
            ///////////////////////////ret = APS168.APS_pt_enable(boardId, ptbId, dimension, Axis_ID_Array);
            //ret = APS168.APS_pt_enable(boardId, ptbId, dimension, Axis_ID_Array);

            ////Configuration
            //ret = APS168.APS_pt_set_absolute(boardId, ptbId); //Set to absolute mode
            //ret = APS168.APS_pt_set_trans_buffered(boardId, ptbId); //Set to buffer mode
            //ret = APS168.APS_pt_set_acc(boardId, ptbId, 5000000); //Set acc
            //ret = APS168.APS_pt_set_dec(boardId, ptbId, 5000000); //Set dec

            //ret = APS168.APS_get_pt_status(boardId, ptbId, ref Status);
            //if ((Status.BitSts & 0x02) == 0) //Buffer is not Full
            //{

            //    Line.Dim = 3;
            //    double Vslow = 300000;

            //    {
            //        PTDWL pwdell = new PTDWL();
            //        pwdell.DwTime = 2000;

            //        //1st line


            //        ret = APS168.APS_pt_set_vm(boardId, ptbId, Vslow);
            //        ret = APS168.APS_pt_set_ve(boardId, ptbId, Vslow);
            //        Line.Pos = new double[] { -218000, -22000, 50, 0, 0, 0 };
            //        ret = APS168.APS_pt_line(boardId, ptbId, ref Line, ref Status);//1段起始点

            //        APS168.APS_set_trigger_linear(boardId, 0, -72000, 900, 11);

            //        double praAcc = Convert.ToDouble(txtPraAcc.Text);
            //        double praDec = Convert.ToDouble(txtPraDec.Text);

            //        APS168.APS_set_axis_param_f(1, (Int32)APS_Define.PRA_ACC, praAcc); // Set acceleration rate
            //        APS168.APS_set_axis_param_f(1, (Int32)APS_Define.PRA_DEC, praDec); // Set deceleration rate

            //        APS168.APS_relative_move(0, 20000, 100000);
            //    }
            //}
        }
Esempio n. 15
0
 public void GetPostionAbs(ref double x, ref double y)
 {
     APS168.APS_get_position_f(_selectAxisX, ref x);
     APS168.APS_get_position_f(_selectAxisY, ref y);
 }
Esempio n. 16
0
        /// <summary>
        ///     减速停止指定机构轴脉冲输出
        /// </summary>
        /// <param name="axisNo"></param>
        public int DecelStop(int axisNo)
        {
            var reult = APS168.APS_stop_move(axisNo);

            return(reult);
        }
Esempio n. 17
0
 public override int SetMotionPos(int cardId, int axisId, int pos)
 {
     return(APS168.APS_set_position(axisId, pos));
 }
Esempio n. 18
0
 public override int MoveAbs(int cardId, int axisId, int pos, int vel)
 {
     return(APS168.APS_absolute_move(axisId, pos, vel));
 }
Esempio n. 19
0
 public override int MoveRel(int cardId, int axisId, int distance, int vel)
 {
     return(APS168.APS_relative_move(axisId, distance, vel));
 }
Esempio n. 20
0
 /// <summary>
 ///     回零
 /// </summary>
 /// <param name="axisNo"></param>
 public void BackHome(int axisNo)
 {
     APS168.APS_home_move(axisNo);
 }
Esempio n. 21
0
        private void tmrUpdateUI_Tick(object sender, EventArgs e)
        {
            if (_primADLink._isInitialed)
            {
                _selectAxis = Convert.ToInt32(cmbSelectAxis.SelectedItem);
                double d = 0;
                _primADLink.GetAxisPositionF(_selectAxis, ref d);
                //APS168.APS_get_position_f(_selectAxis, ref d);
                txtFeedbackPos.Text      = d.ToString("f0");
                txtFeedbackPosition.Text = d.ToString("f0");

                switch (tabControl1.SelectedTab.Name)
                {
                case "tPageAxisMove":
                    int  index;
                    bool status;
                    int  motionIoStatus, motionStatus;
                    //刷新MotionIoStatus
                    //motionIoStatus = APS168.APS_motion_io_status(_selectAxis);
                    motionIoStatus = _primADLink.GetAxisMotionIOStatus(_selectAxis);
                    foreach (var label in grpMotionIo.Controls.OfType <Label>())
                    {
                        if (label.BorderStyle == BorderStyle.FixedSingle)
                        {
                            index           = Convert.ToInt32(label.Tag);
                            status          = (motionIoStatus & (1 << index)) != 0;
                            label.BackColor = status ? Color.LawnGreen : Color.DimGray;
                        }
                    }

                    //刷新MotionStatus
                    //motionStatus = APS168.APS_motion_status(_selectAxis);
                    motionStatus = _primADLink.GetAxisMotionStatus(_selectAxis);
                    foreach (var label in grpMotion.Controls.OfType <Label>())
                    {
                        if (label.BorderStyle == BorderStyle.FixedSingle)
                        {
                            index           = Convert.ToInt32(label.Tag);
                            status          = (motionStatus & (1 << index)) != 0;
                            label.BackColor = status ? Color.LawnGreen : Color.DimGray;
                        }
                    }

                    //刷新Feedback信息
                    double value = 0;
                    _primADLink.GetAxisCommandF(_selectAxis, ref value);
                    //APS168.APS_get_command_f(_selectAxis, ref value);
                    txtCommandPosition.Text = value.ToString("f0");

                    //APS168.APS_get_position_f(_selectAxis, ref value);
                    //txtFeedbackPos.Text = value.ToString("f0");
                    //txtFeedbackPosition.Text = value.ToString("f0");

                    _primADLink.GetAxisPositionF(_selectAxis, ref value);
                    //APS168.APS_get_target_position_f(_selectAxis, ref value);
                    txtTargetPosition.Text = value.ToString("f0");

                    _primADLink.GetAxisErrPositionF(_selectAxis, ref value);
                    //APS168.APS_get_error_position_f(_selectAxis, ref value);
                    txtErrorPosition.Text = value.ToString("f0");

                    _primADLink.GetAxisCommandVelocityF(_selectAxis, ref value);
                    //APS168.APS_get_command_velocity_f(_selectAxis, ref value);
                    txtCommandVelocity.Text = value.ToString("f0");

                    _primADLink.GetAxisFeedbackVelocityF(_selectAxis, ref value);
                    //APS168.APS_get_feedback_velocity_f(_selectAxis, ref value);
                    txtFeedbackVelocity.Text = value.ToString("f0");


                    //刷新ServoOn, motionIoStatus第7位
                    status = (motionIoStatus & (1 << 7)) != 0;
                    lblServoOn.BackColor = status ? Color.LawnGreen : Color.DimGray;

                    //刷新JOG正 和 JOG负
                    var jogPostive  = (motionStatus & (1 << 15)) != 0 && (motionStatus & (1 << 4)) != 0;
                    var jogNegative = (motionStatus & (1 << 15)) != 0 && (motionStatus & (1 << 4)) == 0;
                    lblJogPostive.BackColor  = jogPostive ? Color.LawnGreen : Color.DimGray;
                    lblJogNegative.BackColor = jogNegative ? Color.LawnGreen : Color.DimGray;
                    break;

                case "tPageIO":
                    var diValue = 0;

                    //APS168.APS_read_d_input(_card0.CardId, 0, ref diValue);
                    _primADLink.ReadMultiDInputFromAPI(_config.DevIndex, 0, ref diValue);
                    foreach (var label in grpDi.Controls.OfType <Label>())
                    {
                        if (label.BorderStyle == BorderStyle.FixedSingle)
                        {
                            index           = Convert.ToInt32(label.Tag);
                            status          = (diValue & (1 << index)) != 0;
                            label.BackColor = status ? Color.LawnGreen : Color.DimGray;
                        }
                    }


                    var doValue = 0;
                    //APS168.APS_read_d_output(_card0.CardId, 0, ref doValue);
                    _primADLink.ReadMultiDOutputFromAPI(_config.DevIndex, 0, ref doValue);
                    foreach (var label in grpDo.Controls.OfType <Label>())
                    {
                        if (label.BorderStyle == BorderStyle.FixedSingle)
                        {
                            index           = Convert.ToInt32(label.Tag);
                            status          = (doValue & (1 << index)) != 0;
                            label.BackColor = status ? Color.LawnGreen : Color.DimGray;
                        }
                    }

                    break;

                case "tPageCmpTrig":
                {
                    var count = 0;
                    APS168.APS_get_trigger_count(Convert.ToInt32(txtCardId.Text), 0, ref count);
                    lbTrigCntCH0.Text = count.ToString();

                    APS168.APS_get_trigger_count(Convert.ToInt32(txtCardId.Text), 1, ref count);
                    lbTrigCntCH1.Text = count.ToString();
                }
                break;

                case "tPageContinueMove":
                {
                    if (_ptEnabled)
                    {
                        txtTotalPoint.Text    = _bufTotalPoint.ToString();
                        txtBufFreeSpace.Text  = _bufFreeSpace.ToString();
                        txtbufUsageSpace.Text = _bufUsageSpace.ToString();
                        txtRunningCnt.Text    = _bufRunningCnt.ToString();
                    }
                }
                break;
                }
            }
        }
Esempio n. 22
0
 public override int GetCommandPos(int cardId, int axisId, ref int pos)
 {
     return(APS168.APS_get_command(axisId, ref pos));
 }
Esempio n. 23
0
 /// <summary>
 ///     清除限位配置
 /// </summary>
 /// <param name="axisNo"></param>
 public void ClearSoftConfig(int axisNo)
 {
     APS168.APS_set_axis_param(axisNo, (int)APS_Define.PRA_SPEL_EN, 0);
     APS168.APS_set_axis_param(axisNo, (int)APS_Define.PRA_SMEL_EN, 0);
 }
Esempio n. 24
0
        public int MoveOrigin(int axisNo)
        {
            var ret = APS168.APS_home_move(axisNo);

            return(ret);
        }
Esempio n. 25
0
 public override int GetMotionPos(int cardId, int axisId, ref int pos)
 {
     return(APS168.APS_get_position(axisId, ref pos));
 }
Esempio n. 26
0
 public override void GetAxisStatue(uint axisindex, ref int value)
 {
     value = APS168.APS_motion_status((int)axisindex);
 }
Esempio n. 27
0
 public override void JogStop(uint axisindex)
 {
     APS168.APS_jog_start((int)axisindex, 0);
 }
Esempio n. 28
0
 public override int SetHome(int cardId, int axisId)
 {
     return(APS168.APS_home_move(axisId));
 }
Esempio n. 29
0
 public override void Close()
 {
     APS168.APS_close();
 }
Esempio n. 30
0
 public override int Stop(int cardId, int axisId)
 {
     return(APS168.APS_stop_move(axisId));
 }