Example #1
0
        public static short initBoard()//初始化办卡  返回值:-1:没有卡号   0:正常
        {
            short m = RFIDControl.dmc_board_init();

            if (m <= 0)  //控制卡的初始化操作
            {
                //未找到控制卡
                Console.WriteLine("未找到控制卡");
                return(-1);
            }
            for (int i = 0; i < AXIS_NUM; ++i)
            {
                mAxis[i]                  = new AxisInfo();
                mAxis[i].m_card_num       = 0;
                mAxis[i].m_axis_num       = (ushort)i;
                mAxis[i].m_home_mode      = 1; //一次回零加回找
                mAxis[i].m_home_flag      = 0;
                mAxis[i].m_acc_time       = 0.4;
                mAxis[i].m_dcc_time       = 0.4;
                mAxis[i].m_home_dir       = MoveDir.FOR_WORD;
                mAxis[i].m_speed_max      = 10000; //dispenser_para.motor_speed;
                mAxis[i].m_speed_max_home = 2000;  //dispenser_para.go_home_speed;
                mAxis[i].m_pulse_mode     = 3;
                mAxis[i].m_speed_min      = 0;
                mAxis[i].m_speed_min_home = 0;
                mAxis[i].m_run_status     = STOP;//停止状态
                if (i < 2)
                {
                    RFIDControl.dmc_set_inp_mode(mAxis[i].m_card_num, mAxis[i].m_axis_num, HIGH, LOW);
                    RFIDControl.dmc_set_alm_mode(mAxis[i].m_card_num, mAxis[i].m_axis_num, HIGH, HIGH, 0); //设置 伺服ALM 高电平有效   松下伺服正常情况下输出低电平
                    RFIDControl.dmc_set_counter_inmode(mAxis[i].m_card_num, mAxis[i].m_axis_num, 1);       //设置编码器的计数方式   1倍频
                    RFIDControl.dmc_set_encoder(mAxis[i].m_card_num, mAxis[i].m_axis_num, 0);              //设置初始值为0
                }
            }

            //两轴查补
            mInpterplaType.axis_cout   = 2;                     //2个轴查补
            mInpterplaType.car_num     = 0;                     //坐标系号
            mInpterplaType.card_num    = 0;                     //卡号
            mInpterplaType.line_type   = 0;                     //线型
            mInpterplaType.posi_mode   = PositionMode.ABS_MODE; //位置模式
            mInpterplaType.m_acc_time  = 3;
            mInpterplaType.m_dcc_time  = 3;
            mInpterplaType.m_speed_max = X_AXIS_MAX_SPEED;
            mInpterplaType.arc_dir     = CCW;
            return(0);
        }
Example #2
0
        public static short singleAxisMove(ref AxisInfo axisInfo, long pos, ushort positionMode)
        {
            short m = 0;

            if (axisInfo.m_run_status == RUN)
            {
                return(-1);
            }
            RFIDControl.dmc_set_pulse_outmode(axisInfo.m_card_num, axisInfo.m_axis_num, axisInfo.m_pulse_mode);

            RFIDControl.dmc_set_profile(axisInfo.m_card_num, axisInfo.m_axis_num, axisInfo.m_speed_min, axisInfo.m_speed_max, axisInfo.m_acc_time, axisInfo.m_dcc_time, 100);
            //设定S段时间
            RFIDControl.dmc_set_s_profile(axisInfo.m_card_num, axisInfo.m_axis_num, 0, 0.4);
            m = RFIDControl.dmc_pmove(axisInfo.m_card_num, axisInfo.m_axis_num, pos, positionMode);

            checkDmcMessage(m);
            axisInfo.m_run_status = RUN;
            return(m);
        }
Example #3
0
        public static ushort startSearchHome(ref AxisInfo axisInfo)
        {
            ulong  axisStatus;
            ushort orignCount = 0;

            axisInfo.m_acc_time = 0.1;
            axisInfo.m_dcc_time = 0.1;
orign_begin:
            axisInfo.m_home_flag = 0;
            RFIDControl.dmc_set_home_pin_logic(axisInfo.m_card_num, axisInfo.m_axis_num, LOW, 0);                                                                                       //原点信号 低电平有效
            RFIDControl.dmc_set_pulse_outmode(axisInfo.m_card_num, axisInfo.m_axis_num, axisInfo.m_pulse_mode);                                                                         //设置脉冲输出模式
            RFIDControl.dmc_set_profile(axisInfo.m_card_num, axisInfo.m_axis_num, axisInfo.m_speed_min_home, axisInfo.m_speed_max_home, axisInfo.m_acc_time, axisInfo.m_dcc_time, 500); //设置速度曲线
            RFIDControl.dmc_set_homemode(axisInfo.m_card_num, axisInfo.m_axis_num, (ushort)axisInfo.m_home_dir, 1, (ushort)axisInfo.m_home_mode, 0);                                    //设置回零方式  反向回原点
            orignCount++;
            axisStatus = RFIDControl.dmc_axis_io_status(axisInfo.m_card_num, axisInfo.m_axis_num);                                                                                      //读取轴的状态
            if (getStatus(axisStatus, (int)AxisStatus.MOTOR_ORG) != 0)                                                                                                                  //开始回原点时正在原点位置上
            {
                //		dmc_set_profile(m_axis->m_card_num,m_axis->m_axis_num,m_axis->m_speed_min_home,m_axis->m_speed_max_home,m_axis->m_acc_time,m_axis->m_dcc_time,500);//设置速度曲线
                RFIDControl.dmc_vmove(axisInfo.m_card_num, axisInfo.m_axis_num, (ushort)(axisInfo.m_home_dir == MoveDir.FOR_WORD ? MoveDir.BACK_WORD : MoveDir.FOR_WORD)); //反向运动
                delayTime(WAIT_TIMER);                                                                                                                                     //延时

                do
                {
                    axisStatus = RFIDControl.dmc_axis_io_status(axisInfo.m_card_num, axisInfo.m_axis_num);//读取轴的状态
                    if (startGoHome == 0)
                    {
                        return(NO_ORG);
                    }
                } while (getStatus(axisStatus, (int)AxisStatus.MOTOR_ORG) != 0);//等到原点信号 变高
                RFIDControl.dmc_stop(axisInfo.m_card_num, axisInfo.m_axis_num, DIRECT_STOP);
            }

            if (getStatus(axisStatus, (int)AxisStatus.MOTOR_EL_B) != 0)                                                                                                    //开始时在负限位
            {
                RFIDControl.dmc_vmove(axisInfo.m_card_num, axisInfo.m_axis_num, (ushort)(axisInfo.m_home_dir == MoveDir.FOR_WORD ? MoveDir.BACK_WORD : MoveDir.FOR_WORD)); //反向运动
                delayTime(WAIT_TIMER);                                                                                                                                     //延时
                do
                {
                    axisStatus = RFIDControl.dmc_axis_io_status(axisInfo.m_card_num, axisInfo.m_axis_num);//读取轴的状态
                    if (startGoHome == 0)
                    {
                        return(NO_ORG);
                    }
                } while (getStatus(axisStatus, (int)AxisStatus.MOTOR_ORG) == 0);//查询原点信号

                do
                {
                    axisStatus = RFIDControl.dmc_axis_io_status(axisInfo.m_card_num, axisInfo.m_axis_num);//读取轴的状态
                    if (startGoHome == 0)
                    {
                        return(NO_ORG);
                    }
                } while (getStatus(axisStatus, (int)AxisStatus.MOTOR_ORG) != 0);//查询消失原点信号
                RFIDControl.dmc_stop(axisInfo.m_card_num, axisInfo.m_axis_num, DIRECT_STOP);
            }

            delayTime(100);                                                                     //延时

            RFIDControl.dmc_home_move(axisInfo.m_card_num, axisInfo.m_axis_num);                //回零动作
            delayTime(WAIT_TIMER);                                                              //延时
            while (RFIDControl.dmc_check_done(axisInfo.m_card_num, axisInfo.m_axis_num) == RUN) //判断当前轴状态
            {
                //遇到极限自动返回
                axisStatus = RFIDControl.dmc_axis_io_status(axisInfo.m_card_num, axisInfo.m_axis_num); //读取轴的状态
                if (getStatus(axisStatus, (int)AxisStatus.MOTOR_EL_B) != 0)                            //负向极限
                {
                    RFIDControl.dmc_stop(axisInfo.m_card_num, axisInfo.m_axis_num, DIRECT_STOP);
                    delayTime(WAIT_TIMER);                                                                                                                                      //延时
                    RFIDControl.dmc_vmove(axisInfo.m_card_num, axisInfo.m_axis_num, (ushort)(axisInfo.m_home_dir == MoveDir.BACK_WORD ? MoveDir.FOR_WORD : MoveDir.BACK_WORD)); //反向运动

                    delayTime(WAIT_TIMER);                                                                                                                                      //延时
                    do
                    {
                        axisStatus = RFIDControl.dmc_axis_io_status(axisInfo.m_card_num, axisInfo.m_axis_num);//读取轴的状态
                        if (startGoHome == 0)
                        {
                            return(NO_ORG);
                        }
                    } while (getStatus(axisStatus, (int)AxisStatus.MOTOR_ORG) == 0);//查询原点信号

                    do
                    {
                        axisStatus = RFIDControl.dmc_axis_io_status(axisInfo.m_card_num, axisInfo.m_axis_num);//读取轴的状态
                        if (startGoHome == 0)
                        {
                            return(NO_ORG);
                        }
                    } while (getStatus(axisStatus, (int)AxisStatus.MOTOR_ORG) != 0);     //查询消失原点信号
                    RFIDControl.dmc_stop(axisInfo.m_card_num, axisInfo.m_axis_num, DIRECT_STOP);
                    delayTime(100);                                                      //延时
                    RFIDControl.dmc_home_move(axisInfo.m_card_num, axisInfo.m_axis_num); //重新开始回零动作
                }
                if (getStatus(axisStatus, (int)AxisStatus.MOTOR_EL_F) != 0)              //负向极限
                {
                    if (orignCount < 3)
                    {
                        goto orign_begin;
                    }
                    RFIDControl.dmc_stop(axisInfo.m_card_num, axisInfo.m_axis_num, DIRECT_STOP);
                    return(NO_ORG);//没有原信号
                }
                if (startGoHome == 0)
                {
                    return(NO_ORG);
                }
            }
            if (startGoHome == 0)
            {
                return(NO_ORG);
            }
            delayTime(100);
            RFIDControl.dmc_set_position(axisInfo.m_card_num, axisInfo.m_axis_num, 0);         //设置零点
            axisInfo.m_home_flag = 1;


            //设定脉冲模式及逻辑方向(此处脉冲模式固定为P+D方向:脉冲+方向)
            RFIDControl.dmc_set_pulse_outmode(axisInfo.m_card_num, axisInfo.m_axis_num, axisInfo.m_pulse_mode);

            RFIDControl.dmc_set_profile(axisInfo.m_card_num, axisInfo.m_axis_num, axisInfo.m_speed_min, axisInfo.m_speed_max, axisInfo.m_acc_time, axisInfo.m_dcc_time, 0);
            //设定S段时间
            RFIDControl.dmc_set_s_profile(axisInfo.m_card_num, axisInfo.m_axis_num, 0, 0.4);


            RFIDControl.dmc_set_encoder(axisInfo.m_card_num, axisInfo.m_axis_num, 0);  //设置初始值为0
            RFIDControl.dmc_set_position(axisInfo.m_card_num, axisInfo.m_axis_num, 0); //初始位置设为零
            RFIDControl.dmc_set_equiv(axisInfo.m_card_num, axisInfo.m_axis_num, 1);
            axisInfo.m_pulse_mode = 3;
            axisInfo.m_home_flag  = 1;

            return(ORG_OK);
        }
Example #4
0
 public static void servoErc(ref AxisInfo axisInfo)
 {
     RFIDControl.dmc_write_erc_pin(axisInfo.m_card_num, axisInfo.m_axis_num, LOW);
     Thread.Sleep(100);
     RFIDControl.dmc_write_erc_pin(axisInfo.m_card_num, axisInfo.m_axis_num, HIGH);
 }
Example #5
0
 public static void motorStop(ref AxisInfo axisInfo)
 {
     RFIDControl.dmc_stop(axisInfo.m_card_num, axisInfo.m_axis_num, DIRECT_STOP);//直接停止
 }