晶圆传输机器人振动分析与轨迹控制_第1页
晶圆传输机器人振动分析与轨迹控制_第2页
晶圆传输机器人振动分析与轨迹控制_第3页
晶圆传输机器人振动分析与轨迹控制_第4页
晶圆传输机器人振动分析与轨迹控制_第5页
已阅读5页,还剩92页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

-图3-3。图3-SEQ图3-\*ARABIC3电机调试界面电机详细程序如下://MOVEDlg.cpp:implementationfile//#include"stdafx.h"#include"MOVE.h"#include"MOVEDlg.h"#include<math.h>#include<fstream.h>#include<windows.h>//通讯方式#definePMD_W32SERIAL_INTERFACE#definePMD_ISA_INTERFACE#definepi3.1415926536#include"C-Motion.h"#include"PMDutil.h"#include"PMDMotorSetup_Magellan.h"#include"PMDMB.h"#include"PMDW32Ser.h"#ifdef_DEBUG#definenewDEBUG_NEW#undefTHIS_FILEstaticcharTHIS_FILE[]=__FILE__;#endif//theaxishandleobjectPMDAxisHandlehAxis1,hAxis2;//hAxis1.axis=1;doubleP,V,V0,A,D,J;//单位为counts、counts/cycle、counts/cycle^2、counts/cycle^3intloop_index=0,MoveStep=0;//扫描完成标志与插补步数doubleq2[4000]={0},q3[4000]={0},q2v[4000]={0},q3v[4000]={0},q2a=4E8,q3a=4E8;//两电机运动信息///////////////////////////////////////////////////////////////////////////////CAboutDlgdialogusedforAppAboutclassCAboutDlg:publicCDialog{public: CAboutDlg();//DialogData //{{AFX_DATA(CAboutDlg) enum{IDD=IDD_ABOUTBOX}; //}}AFX_DATA //ClassWizardgeneratedvirtualfunctionoverrides //{{AFX_VIRTUAL(CAboutDlg) protected: virtualvoidDoDataExchange(CDataExchange*pDX);//DDX/DDVsupport //}}AFX_VIRTUAL//Implementationprotected: //{{AFX_MSG(CAboutDlg) //}}AFX_MSG DECLARE_MESSAGE_MAP()};CAboutDlg::CAboutDlg():CDialog(CAboutDlg::IDD){ //{{AFX_DATA_INIT(CAboutDlg) //}}AFX_DATA_INIT}voidCAboutDlg::DoDataExchange(CDataExchange*pDX){ CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CAboutDlg) //}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(CAboutDlg,CDialog) //{{AFX_MSG_MAP(CAboutDlg) //Nomessagehandlers //}}AFX_MSG_MAPEND_MESSAGE_MAP()///////////////////////////////////////////////////////////////////////////////CMOVEDlgdialogCMOVEDlg::CMOVEDlg(CWnd*pParent/*=NULL*/) :CDialog(CMOVEDlg::IDD,pParent){ //{{AFX_DATA_INIT(CMOVEDlg) m_Kd=0; m_Axis=0; m_Prompt=_T(""); m_Ser=-1; m_MotorType=_T(""); m_Encoder=_T(""); m_MoveType=0; m_Ki=0; m_Kvff=0; m_Kaff=0; m_StopMode=1; m_Kp=0; m_EPID=FALSE; m_ETrajectory=FALSE; m_EMotor=FALSE; m_WorkStatus=_T(""); m_ActivityStatus=_T(""); m_EPID1=FALSE; m_EPID2=FALSE; m_ETrajectory1=FALSE; m_ETrajectory2=FALSE; m_EMotor1=FALSE; m_EMotor2=FALSE; m_ActivityStatus2=_T(""); m_Kaff1=0; m_Kaff2=0; m_Kd1=0; m_Kd2=0; m_Ki1=0; m_Ki2=0; m_Kp1=0; m_Kp2=0; m_Kvff1=0; m_Kvff2=0; m_Station2_X=0; m_Station2_Y=0; m_Station1_X=0; m_Station1_Y=0; m_Pulse=0; m_EncoderCounts=0; m_T2R=0; m_Zero1=0; m_Zero2=0; m_EncoderCounts2=0; m_T=-1; m_MoveTime=0; //}}AFX_DATA_INIT //NotethatLoadIcondoesnotrequireasubsequentDestroyIconinWin32 m_hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);}voidCMOVEDlg::DoDataExchange(CDataExchange*pDX){ CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CMOVEDlg) DDX_Text(pDX,IDC_Kd,m_Kd); DDX_Radio(pDX,IDC_Axis1,m_Axis); DDX_Text(pDX,IDC_Prompt,m_Prompt); DDX_Radio(pDX,IDC_Ser,m_Ser); DDX_CBString(pDX,IDC_MotorType,m_MotorType); DDX_CBString(pDX,IDC_Encoder,m_Encoder); DDX_Radio(pDX,IDC_Move_T,m_MoveType); DDX_Text(pDX,IDC_Ki,m_Ki); DDX_Text(pDX,IDC_Kvff,m_Kvff); DDX_Text(pDX,IDC_Kaff,m_Kaff); DDX_Radio(pDX,IDC_Stop_Smooth,m_StopMode); DDX_Text(pDX,IDC_Kp,m_Kp); DDX_Check(pDX,IDC_EPID,m_EPID); DDX_Check(pDX,IDC_ETrajectory,m_ETrajectory); DDX_Check(pDX,IDC_EMotor,m_EMotor); DDX_Text(pDX,IDC_WorkStatus,m_WorkStatus); DDX_Text(pDX,IDC_ActivityStatus,m_ActivityStatus); DDX_Check(pDX,IDC_EPID1,m_EPID1); DDX_Check(pDX,IDC_EPID2,m_EPID2); DDX_Check(pDX,IDC_ETrajectory1,m_ETrajectory1); DDX_Check(pDX,IDC_ETrajectory2,m_ETrajectory2); DDX_Check(pDX,IDC_EMotor1,m_EMotor1); DDX_Check(pDX,IDC_EMotor2,m_EMotor2); DDX_Text(pDX,IDC_ActivityStatus2,m_ActivityStatus2); DDX_Text(pDX,IDC_Kaff1,m_Kaff1); DDX_Text(pDX,IDC_Kaff2,m_Kaff2); DDX_Text(pDX,IDC_Kd1,m_Kd1); DDX_Text(pDX,IDC_Kd2,m_Kd2); DDX_Text(pDX,IDC_Ki1,m_Ki1); DDX_Text(pDX,IDC_Ki2,m_Ki2); DDX_Text(pDX,IDC_Kp1,m_Kp1); DDX_Text(pDX,IDC_Kp2,m_Kp2); DDX_Text(pDX,IDC_Kvff1,m_Kvff1); DDX_Text(pDX,IDC_Kvff2,m_Kvff2); DDX_Text(pDX,IDC_Station2_X,m_Station2_X); DDX_Text(pDX,IDC_Station2_Y,m_Station2_Y); DDX_Text(pDX,IDC_Station1_X,m_Station1_X); DDX_Text(pDX,IDC_Station1_Y,m_Station1_Y); DDX_Text(pDX,IDC_Pulse,m_Pulse); DDX_Text(pDX,IDC_EncoderCounts,m_EncoderCounts); DDX_Text(pDX,IDC_T2R,m_T2R); DDX_Text(pDX,IDC_Zero1,m_Zero1); DDX_Text(pDX,IDC_Zero2,m_Zero2); DDX_Text(pDX,IDC_EncoderCounts2,m_EncoderCounts2); DDX_Radio(pDX,IDC_T1,m_T); DDX_Text(pDX,IDC_MoveTime,m_MoveTime); //}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(CMOVEDlg,CDialog) //{{AFX_MSG_MAP(CMOVEDlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDC_Ser,OnSer) ON_BN_CLICKED(IDC_Axis1,OnAxis1) ON_BN_CLICKED(IDC_Axis2,OnAxis2) ON_BN_CLICKED(IDC_Axis3,OnAxis3) ON_BN_CLICKED(IDC_Axis4,OnAxis4) ON_BN_CLICKED(IDC_Disconnect,OnDisconnect) ON_BN_CLICKED(IDC_LoadSettings,OnLoadSettings) ON_BN_CLICKED(IDC_Move_T,OnMoveT) ON_BN_CLICKED(IDC_Move_S,OnMoveS) ON_BN_CLICKED(IDC_Move_V,OnMoveV) ON_BN_CLICKED(IDC_Stop_Smooth,OnStopSmooth) ON_BN_CLICKED(IDC_Stop_Sudden,OnStopSudden) ON_BN_CLICKED(IDC_MotorMove,OnMotorMove) ON_WM_TIMER() ON_BN_CLICKED(IDC_MotorStop,OnMotorStop) ON_BN_CLICKED(IDC_EPID,OnEpid) ON_BN_CLICKED(IDC_ETrajectory,OnETrajectory) ON_BN_CLICKED(IDC_EMotor,OnEMotor) ON_BN_CLICKED(IDC_Axis5,OnAxis5) ON_BN_CLICKED(IDC_PC104,OnPc104) ON_BN_CLICKED(IDC_MotorMove2,OnMotorMove2) ON_BN_CLICKED(IDC_EPID1,OnEpid1) ON_BN_CLICKED(IDC_ETrajectory1,OnETrajectory1) ON_BN_CLICKED(IDC_EMotor1,OnEMotor1) ON_BN_CLICKED(IDC_EPID2,OnEpid2) ON_BN_CLICKED(IDC_ETrajectory2,OnETrajectory2) ON_BN_CLICKED(IDC_EMotor2,OnEMotor2) ON_BN_CLICKED(IDC_T1,OnT1) ON_BN_CLICKED(IDC_T2,OnT2) ON_BN_CLICKED(IDC_T3,OnT3) ON_BN_CLICKED(IDC_MotorMove2_Reset,OnMotorMove2Reset) //}}AFX_MSG_MAPEND_MESSAGE_MAP()///////////////////////////////////////////////////////////////////////////////CMOVEDlgmessagehandlers//自己定义的权限释放函数,在此不用/*doeventc(floatxjs){ CTimetrw=CTime::GetCurrentTime(); while(1) { MSGmessage; while(PeekMessage(&message,NULL,0,0,PM_REMOVE)) { TranslateMessage(&message); DispatchMessage(&message); } if(CTime::GetCurrentTime()-trw>xjs) break; //Sleep(1); } }*///原机械手权限释放函数voidDoEvents(){ MSGmessage; while(PeekMessage(&message,NULL,0,0,PM_REMOVE)) { TranslateMessage(&message); DispatchMessage(&message); }}//精确定时函数boolXJStimer(floattime){ LARGE_INTEGERlitmp; LONGLONGQPart1,QPart2; doubledfMinus,dfFreq,dfTim; QueryPerformanceFrequency(&litmp); dfFreq=(double)litmp.QuadPart;//获得计数器的时钟频率 QueryPerformanceCounter(&litmp); QPart1=litmp.QuadPart;//获得初始值 do{ QueryPerformanceCounter(&litmp); QPart2=litmp.QuadPart;//获得终止值 dfMinus=(double)(QPart2-QPart1); dfTim=dfMinus/dfFreq;//获得对应的时间值,单位为秒 }while(dfTim<0.001*time); returnTRUE;}BOOLCMOVEDlg::OnInitDialog(){ CDialog::OnInitDialog(); //Add"About..."menuitemtosystemmenu. //IDM_ABOUTBOXmustbeinthesystemcommandrange. ASSERT((IDM_ABOUTBOX&0xFFF0)==IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX<0xF000); CMenu*pSysMenu=GetSystemMenu(FALSE); if(pSysMenu!=NULL) { CStringstrAboutMenu; strAboutMenu.LoadString(IDS_ABOUTBOX); if(!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING,IDM_ABOUTBOX,strAboutMenu); } } //Settheiconforthisdialog.Theframeworkdoesthisautomatically //whentheapplication'smainwindowisnotadialog SetIcon(m_hIcon,TRUE); //Setbigicon SetIcon(m_hIcon,FALSE); //Setsmallicon //TODO:Addextrainitializationhere SetDlgItemText(IDC_Prompt,"Pleaseselectaxisnumberfirst.");//先选择轴号 GetDlgItem(IDC_MotorMove)->EnableWindow(FALSE);//开始按钮无效 GetDlgItem(IDC_MotorMove2)->EnableWindow(FALSE); GetDlgItem(IDC_MotorMove2_Reset)->EnableWindow(FALSE); GetDlgItem(IDC_MotorStop)->EnableWindow(FALSE); GetDlgItem(IDC_LoadSettings)->EnableWindow(FALSE); GetDlgItem(IDC_Disconnect)->EnableWindow(FALSE); ((CComboBox*)GetDlgItem(IDC_MotorType))->AddString("BrushlessDC(3phase)");//电机选择 ((CComboBox*)GetDlgItem(IDC_MotorType))->AddString("BrushlessDC(2phase)"); ((CComboBox*)GetDlgItem(IDC_MotorType))->AddString("Microstepping(3phase)"); ((CComboBox*)GetDlgItem(IDC_MotorType))->AddString("Microstepping(2phase)"); ((CComboBox*)GetDlgItem(IDC_MotorType))->AddString("Pulse&Direction"); ((CComboBox*)GetDlgItem(IDC_MotorType))->AddString("DCBrush"); ((CComboBox*)GetDlgItem(IDC_Encoder))->AddString("Incremental");//编码器选择 ((CComboBox*)GetDlgItem(IDC_Encoder))->AddString("Absolute"); returnTRUE;//returnTRUEunlessyousetthefocustoacontrol}voidCMOVEDlg::OnSysCommand(UINTnID,LPARAMlParam){ if((nID&0xFFF0)==IDM_ABOUTBOX) { CAboutDlgdlgAbout; dlgAbout.DoModal(); } else { CDialog::OnSysCommand(nID,lParam); }}//Ifyouaddaminimizebuttontoyourdialog,youwillneedthecodebelow//todrawtheicon.ForMFCapplicationsusingthedocument/viewmodel,//thisisautomaticallydoneforyoubytheframework.voidCMOVEDlg::OnPaint(){ if(IsIconic()) { CPaintDCdc(this);//devicecontextforpainting SendMessage(WM_ICONERASEBKGND,(WPARAM)dc.GetSafeHdc(),0); //Centericoninclientrectangle intcxIcon=GetSystemMetrics(SM_CXICON); intcyIcon=GetSystemMetrics(SM_CYICON); CRectrect; GetClientRect(&rect); intx=(rect.Width()-cxIcon+1)/2; inty=(rect.Height()-cyIcon+1)/2; //Drawtheicon dc.DrawIcon(x,y,m_hIcon); } else { CDialog::OnPaint(); }}//Thesystemcallsthistoobtainthecursortodisplaywhiletheuserdrags//theminimizedwindow.HCURSORCMOVEDlg::OnQueryDragIcon(){ return(HCURSOR)m_hIcon;}voidCMOVEDlg::OnSer(){ //TODO:Addyourcontrolnotificationhandlercodehere//验证串口通信 intN_Axis=1; if(m_Axis==4) { N_Axis=PMDSetupAxisInterface_Serial(&hAxis1,PMDAxis1,0); PMDCopyAxisInterface(&hAxis2,&hAxis1,PMDAxis2); } elseif(m_Axis==0)N_Axis=PMDSetupAxisInterface_Serial(&hAxis1,PMDAxis1,0); elseif(m_Axis==1)N_Axis=PMDSetupAxisInterface_Serial(&hAxis1,PMDAxis2,0); elseif(m_Axis==2)N_Axis=PMDSetupAxisInterface_Serial(&hAxis1,PMDAxis3,0); elseif(m_Axis==3)N_Axis=PMDSetupAxisInterface_Serial(&hAxis1,PMDAxis4,0); if(PMD_NOERROR!=N_Axis){ MessageBox("Communicationinitializationfailed");} //optional:changeserialparametersherebeforeattemptingcommunication //PMDSerial_SetConfig(hAxis1.transport_data,460800,0);//波特率无法设定 //PMDSetSerialPortMode(&hAxis1,7,0,0,0,0); PMDSerial_Sync(hAxis1.transport_data); if(PMD_NOERROR!=PMDChipsetReset(&hAxis1)) { MessageBox("Resetfailed"); PMDCloseAxisInterface(&hAxis1); UpdateData(); m_Ser=-1; UpdateData(FALSE); SetDlgItemText(IDC_Prompt,"pleasecheckyourserialinterface."); } else { PMDResetEventStatus(&hAxis1,0);//状态清零 ((CComboBox*)GetDlgItem(IDC_MotorType))->SetCurSel(2);//默认直流无刷电机 ((CComboBox*)GetDlgItem(IDC_Encoder))->SetCurSel(1);//默认增量式编码器 GetDlgItem(IDC_Disconnect)->EnableWindow(TRUE);//打开按钮 GetDlgItem(IDC_LoadSettings)->EnableWindow(TRUE); GetDlgItem(IDC_Axis1)->EnableWindow(FALSE);//关掉四个轴 GetDlgItem(IDC_Axis2)->EnableWindow(FALSE); GetDlgItem(IDC_Axis3)->EnableWindow(FALSE); GetDlgItem(IDC_Axis4)->EnableWindow(FALSE); GetDlgItem(IDC_Axis5)->EnableWindow(FALSE); if(m_Axis==4) { PMDResetEventStatus(&hAxis2,0);//状态清零 GetDlgItem(IDC_J)->EnableWindow(FALSE); GetDlgItem(IDC_P)->EnableWindow(FALSE); GetDlgItem(IDC_V)->EnableWindow(FALSE); GetDlgItem(IDC_A)->EnableWindow(FALSE); GetDlgItem(IDC_D)->EnableWindow(FALSE); GetDlgItem(IDC_V0)->EnableWindow(FALSE); GetDlgItem(IDC_Kp)->EnableWindow(FALSE); GetDlgItem(IDC_Ki)->EnableWindow(FALSE); GetDlgItem(IDC_Kd)->EnableWindow(FALSE); GetDlgItem(IDC_Kaff)->EnableWindow(FALSE); GetDlgItem(IDC_Kvff)->EnableWindow(FALSE); GetDlgItem(IDC_EPID)->EnableWindow(FALSE); GetDlgItem(IDC_ETrajectory)->EnableWindow(FALSE); GetDlgItem(IDC_EMotor)->EnableWindow(FALSE); GetDlgItem(IDC_Move_S)->EnableWindow(FALSE); GetDlgItem(IDC_Move_T)->EnableWindow(FALSE); GetDlgItem(IDC_Move_V)->EnableWindow(FALSE); GetDlgItem(IDC_Stop_Smooth)->EnableWindow(FALSE); GetDlgItem(IDC_Stop_Sudden)->EnableWindow(FALSE); UpdateData(); m_Ser=0; m_EPID1=TRUE; m_EMotor1=TRUE; m_ETrajectory1=TRUE; m_EPID2=TRUE; m_EMotor2=TRUE; m_ETrajectory2=TRUE; m_MoveTime=4;//默认插补初始条件 m_Pulse=5; m_Station1_X=620; m_Station1_Y=0; m_Station2_X=180; m_Station2_Y=545; m_Zero1=0; m_Zero2=120; m_EncoderCounts=8192; m_EncoderCounts2=8192; UpdateData(FALSE); SetDlgItemInt(IDC_Kp1,1); SetDlgItemInt(IDC_Kd1,50); SetDlgItemInt(IDC_Kp2,1); SetDlgItemInt(IDC_Kd2,50); } else { GetDlgItem(IDC_Kp1)->EnableWindow(FALSE); GetDlgItem(IDC_Ki1)->EnableWindow(FALSE); GetDlgItem(IDC_Kd1)->EnableWindow(FALSE); GetDlgItem(IDC_Kaff1)->EnableWindow(FALSE); GetDlgItem(IDC_Kvff1)->EnableWindow(FALSE); GetDlgItem(IDC_Kp2)->EnableWindow(FALSE); GetDlgItem(IDC_Ki2)->EnableWindow(FALSE); GetDlgItem(IDC_Kd2)->EnableWindow(FALSE); GetDlgItem(IDC_Kaff2)->EnableWindow(FALSE); GetDlgItem(IDC_Kvff2)->EnableWindow(FALSE); GetDlgItem(IDC_EPID1)->EnableWindow(FALSE); GetDlgItem(IDC_ETrajectory1)->EnableWindow(FALSE); GetDlgItem(IDC_EMotor1)->EnableWindow(FALSE); GetDlgItem(IDC_EPID2)->EnableWindow(FALSE); GetDlgItem(IDC_ETrajectory2)->EnableWindow(FALSE); GetDlgItem(IDC_EMotor2)->EnableWindow(FALSE); GetDlgItem(IDC_T1)->EnableWindow(FALSE); GetDlgItem(IDC_T2)->EnableWindow(FALSE); GetDlgItem(IDC_T3)->EnableWindow(FALSE); GetDlgItem(IDC_MoveTime)->EnableWindow(FALSE); GetDlgItem(IDC_Pulse)->EnableWindow(FALSE); GetDlgItem(IDC_Station1_X)->EnableWindow(FALSE); GetDlgItem(IDC_Station1_Y)->EnableWindow(FALSE); GetDlgItem(IDC_Station2_X)->EnableWindow(FALSE); GetDlgItem(IDC_Station2_Y)->EnableWindow(FALSE); GetDlgItem(IDC_Zero1)->EnableWindow(FALSE); GetDlgItem(IDC_Zero2)->EnableWindow(FALSE); GetDlgItem(IDC_EncoderCounts)->EnableWindow(FALSE); GetDlgItem(IDC_EncoderCounts2)->EnableWindow(FALSE); GetDlgItem(IDC_J)->EnableWindow(FALSE);//默认梯形曲线,设定默认值 SetDlgItemInt(IDC_P,400000);//200转 SetDlgItemInt(IDC_V,60000);//最高30r/s SetDlgItemInt(IDC_A,30000);//两秒升到最高 SetDlgItemInt(IDC_Kp,10); SetDlgItemInt(IDC_Kd,500); UpdateData(); m_Ser=0; m_EPID=TRUE; m_EMotor=TRUE; m_ETrajectory=TRUE; UpdateData(FALSE); } GetDlgItem(IDC_Ser)->EnableWindow(FALSE);//只允许串口开一次 GetDlgItem(IDC_PC104)->EnableWindow(FALSE);//关掉并口 GetDlgItem(IDC_T2R)->EnableWindow(FALSE); SetDlgItemText(IDC_Prompt,"");//关闭提示 SetTimer(1,100,NULL);//状态显示刷新时间 }}voidCMOVEDlg::OnPc104(){ //TODO:Addyourcontrolnotificationhandlercodehere intN_Axis=1; if(m_Axis==4) { N_Axis=PMDSetupAxisInterface_ISA(&hAxis1,PMDAxis1,1); PMDCopyAxisInterface(&hAxis2,&hAxis1,PMDAxis2); } elseif(m_Axis==0)N_Axis=PMDSetupAxisInterface_ISA(&hAxis1,PMDAxis1,1); elseif(m_Axis==1)N_Axis=PMDSetupAxisInterface_ISA(&hAxis1,PMDAxis2,1); elseif(m_Axis==2)N_Axis=PMDSetupAxisInterface_ISA(&hAxis1,PMDAxis3,1); elseif(m_Axis==3)N_Axis=PMDSetupAxisInterface_ISA(&hAxis1,PMDAxis4,1); if(PMD_NOERROR!=N_Axis){ MessageBox("Communicationinitializationfailed");} if(PMD_NOERROR!=PMDChipsetReset(&hAxis1)) { MessageBox("Resetfailed"); PMDCloseAxisInterface(&hAxis1); UpdateData(); m_Ser=-1; UpdateData(FALSE); SetDlgItemText(IDC_Prompt,"pleasecheckyourparallelinterface."); } else { PMDResetEventStatus(&hAxis1,0);//状态清零 ((CComboBox*)GetDlgItem(IDC_MotorType))->SetCurSel(2);//默认直流无刷电机 ((CComboBox*)GetDlgItem(IDC_Encoder))->SetCurSel(1);//默认增量式编码器 GetDlgItem(IDC_Disconnect)->EnableWindow(TRUE);//打开按钮 GetDlgItem(IDC_LoadSettings)->EnableWindow(TRUE); GetDlgItem(IDC_Axis1)->EnableWindow(FALSE);//关掉四个轴 GetDlgItem(IDC_Axis2)->EnableWindow(FALSE); GetDlgItem(IDC_Axis3)->EnableWindow(FALSE); GetDlgItem(IDC_Axis4)->EnableWindow(FALSE); GetDlgItem(IDC_Axis5)->EnableWindow(FALSE); if(m_Axis==4) { PMDResetEventStatus(&hAxis2,0);//状态清零 GetDlgItem(IDC_J)->EnableWindow(FALSE); GetDlgItem(IDC_P)->EnableWindow(FALSE); GetDlgItem(IDC_V)->EnableWindow(FALSE); GetDlgItem(IDC_A)->EnableWindow(FALSE); GetDlgItem(IDC_D)->EnableWindow(FALSE); GetDlgItem(IDC_V0)->EnableWindow(FALSE); GetDlgItem(IDC_Kp)->EnableWindow(FALSE); GetDlgItem(IDC_Ki)->EnableWindow(FALSE); GetDlgItem(IDC_Kd)->EnableWindow(FALSE); GetDlgItem(IDC_Kaff)->EnableWindow(FALSE); GetDlgItem(IDC_Kvff)->EnableWindow(FALSE); GetDlgItem(IDC_EPID)->EnableWindow(FALSE); GetDlgItem(IDC_ETrajectory)->EnableWindow(FALSE); GetDlgItem(IDC_EMotor)->EnableWindow(FALSE); GetDlgItem(IDC_Move_S)->EnableWindow(FALSE); GetDlgItem(IDC_Move_T)->EnableWindow(FALSE); GetDlgItem(IDC_Move_V)->EnableWindow(FALSE); GetDlgItem(IDC_Stop_Smooth)->EnableWindow(FALSE); GetDlgItem(IDC_Stop_Sudden)->EnableWindow(FALSE); GetDlgItem(IDC_EPID)->EnableWindow(FALSE); GetDlgItem(IDC_ETrajectory)->EnableWindow(FALSE); GetDlgItem(IDC_EMotor)->EnableWindow(FALSE); UpdateData(); m_Ser=1; m_EPID1=TRUE; m_EMotor1=TRUE; m_ETrajectory1=TRUE; m_EPID2=TRUE; m_EMotor2=TRUE; m_ETrajectory2=TRUE; m_MoveTime=3;//默认插补初始条件 m_Pulse=5; m_Station1_X=620; m_Station1_Y=0; m_Station2_X=180; m_Station2_Y=545; m_Zero1=0; m_Zero2=120; m_EncoderCounts=8192; m_EncoderCounts2=8192; UpdateData(FALSE); SetDlgItemInt(IDC_Kp1,1); SetDlgItemInt(IDC_Kd1,50); SetDlgItemInt(IDC_Kp2,1); SetDlgItemInt(IDC_Kd2,50); } else { GetDlgItem(IDC_Kp1)->EnableWindow(FALSE); GetDlgItem(IDC_Ki1)->EnableWindow(FALSE); GetDlgItem(IDC_Kd1)->EnableWindow(FALSE); GetDlgItem(IDC_Kaff1)->EnableWindow(FALSE); GetDlgItem(IDC_Kvff1)->EnableWindow(FALSE); GetDlgItem(IDC_Kp2)->EnableWindow(FALSE); GetDlgItem(IDC_Ki2)->EnableWindow(FALSE); GetDlgItem(IDC_Kd2)->EnableWindow(FALSE); GetDlgItem(IDC_Kaff2)->EnableWindow(FALSE); GetDlgItem(IDC_Kvff2)->EnableWindow(FALSE); GetDlgItem(IDC_EPID1)->EnableWindow(FALSE); GetDlgItem(IDC_ETrajectory1)->EnableWindow(FALSE); GetDlgItem(IDC_EMotor1)->EnableWindow(FALSE); GetDlgItem(IDC_EPID2)->EnableWindow(FALSE); GetDlgItem(IDC_ETrajectory2)->EnableWindow(FALSE); GetDlgItem(IDC_EMotor2)->EnableWindow(FALSE); GetDlgItem(IDC_T1)->EnableWindow(FALSE); GetDlgItem(IDC_T2)->EnableWindow(FALSE); GetDlgItem(IDC_T3)->EnableWindow(FALSE); GetDlgItem(IDC_MoveTime)->EnableWindow(FALSE); GetDlgItem(IDC_Pulse)->EnableWindow(FALSE); GetDlgItem(IDC_Station1_X)->EnableWindow(FALSE); GetDlgItem(IDC_Station1_Y)->EnableWindow(FALSE); GetDlgItem(IDC_Station2_X)->EnableWindow(FALSE); GetDlgItem(IDC_Station2_Y)->EnableWindow(FALSE); GetDlgItem(IDC_Zero1)->EnableWindow(FALSE); GetDlgItem(IDC_Zero2)->EnableWindow(FALSE); GetDlgItem(IDC_EncoderCounts)->EnableWindow(FALSE); GetDlgItem(IDC_EncoderCounts2)->EnableWindow(FALSE); GetDlgItem(IDC_J)->EnableWindow(FALSE);//默认梯形曲线,设定默认值 SetDlgItemInt(IDC_P,400000);//200转 SetDlgItemInt(IDC_V,60000);//最高30r/s SetDlgItemInt(IDC_A,30000);//两秒升到最高 SetDlgItemInt(IDC_Kp,10); SetDlgItemInt(IDC_Kd,500); UpdateData(); m_Ser=1; m_EPID=TRUE; m_EMotor=TRUE; m_ETrajectory=TRUE; UpdateData(FALSE); } GetDlgItem(IDC_Ser)->EnableWindow(FALSE);//只允许串口开一次 GetDlgItem(IDC_PC104)->EnableWindow(FALSE);//关掉并口 GetDlgItem(IDC_T2R)->EnableWindow(FALSE); SetDlgItemText(IDC_Prompt,"");//关闭提示 SetTimer(1,100,NULL);//状态显示刷新时间 }}//轴号选择voidCMOVEDlg::OnAxis1(){ //TODO:Addyourcontrolnotificationhandlercodehere UpdateData(); m_Ser=-1; m_Axis=0; UpdateData(FALSE); SetDlgItemText(IDC_Prompt,"Pleaseselectcommunicationmode.");}voidCMOVEDlg::OnAxis2(){ //TODO:Addyourcontrolnotificationhandlercodehere UpdateData(); m_Ser=-1; m_Axis=1; UpdateData(FALSE); SetDlgItemText(IDC_Prompt,"Pleaseselectcommunicationmode.");}voidCMOVEDlg::OnAxis3(){ //TODO:Addyourcontrolnotificationhandlercodehere UpdateData(); m_Ser=-1; m_Axis=2; UpdateData(FALSE); SetDlgItemText(IDC_Prompt,"Pleaseselectcommunicationmode.");}voidCMOVEDlg::OnAxis4(){ //TODO:Addyourcontrolnotificationhandlercodehere UpdateData(); m_Ser=-1; m_Axis=3; UpdateData(FALSE); SetDlgItemText(IDC_Prompt,"Pleaseselectcommunicationmode.");}voidCMOVEDlg::OnAxis5(){ //TODO:Addyourcontrolnotificationhandlercodehere //TODO:Addyourcontrolnotificationhandlercodehere UpdateData(); m_Ser=-1; m_Axis=4; UpdateData(FALSE); SetDlgItemText(IDC_Prompt,"Pleaseselectcommunicationmode."); }//运动形式设置voidCMOVEDlg::OnMoveT(){ //TODO:Addyourcontrolnotificationhandlercodehere m_MoveType=0; GetDlgItem(IDC_P)->EnableWindow(TRUE); GetDlgItem(IDC_V0)->EnableWindow(TRUE); GetDlgItem(IDC_J)->EnableWindow(FALSE);}voidCMOVEDlg::OnMoveS(){ //TODO:Addyourcontrolnotificationhandlercodehere m_MoveType=1; GetDlgItem(IDC_P)->EnableWindow(TRUE); GetDlgItem(IDC_V0)->EnableWindow(FALSE); GetDlgItem(IDC_J)->EnableWindow(TRUE);}voidCMOVEDlg::OnMoveV(){ //TODO:Addyourcontrolnotificationhandlercodehere m_MoveType=2; GetDlgItem(IDC_P)->EnableWindow(FALSE); GetDlgItem(IDC_V0)->EnableWindow(TRUE); GetDlgItem(IDC_J)->EnableWindow(FALSE);}//停止方式设置voidCMOVEDlg::OnStopSmooth(){ //TODO:Addyourcontrolnotificationhandlercodehere m_StopMode=0;}voidCMOVEDlg::OnStopSudden(){ //TODO:Addyourcontrolnotificationhandlercodehere m_StopMode=1;}//插补轨迹选择voidCMOVEDlg::OnT1(){ //TODO:Addyourcontrolnotificationhandlercodehere m_T=0; GetDlgItem(IDC_T2R)->EnableWindow(FALSE);}voidCMOVEDlg::OnT2(){ //TODO:Addyourcontrolnotificationhandlercodehere m_T=1; GetDlgItem(IDC_T2R)->EnableWindow(TRUE); UpdateData(); m_T2R=1200; UpdateData(FALSE);}voidCMOVEDlg::OnT3(){ //TODO:Addyourcontrolnotificationhandlercodehere m_T=2; GetDlgItem(IDC_T2R)->EnableWindow(TRUE); UpdateData(); m_T2R=1200; UpdateData(FALSE);}//使能设置voidCMOVEDlg::OnEpid(){ //TODO:Addyourcontrolnotificationhandlercodehere m_EPID=!m_EPID; CMOVEDlg::OnLoadSettings();}voidCMOVEDlg::OnETrajectory(){ //TODO:Addyourcontrolnotificationhandlercodehere m_ETrajectory=!m_ETrajectory; CMOVEDlg::OnLoadSettings();}voidCMOVEDlg::OnEMotor(){ //TODO:Addyourcontrolnotificationhandlercodehere m_EMotor=!m_EMotor; CMOVEDlg::OnLoadSettings();}//使能设置(两轴插补轴1)voidCMOVEDlg::OnEpid1(){ //TODO:Addyourcontrolnotificationhandlercodehere m_EPID1=!m_EPID1; CMOVEDlg::OnLoadSettings();}voidCMOVEDlg::OnETrajectory1(){ //TODO:Addyourcontrolnotificationhandlercodehere m_ETrajectory1=!m_ETrajectory1; CMOVEDlg::OnLoadSettings();}voidCMOVEDlg::OnEMotor1(){ //TODO:Addyourcontrolnotificationhandlercodehere m_EMotor1=!m_EMotor1; CMOVEDlg::OnLoadSettings();}//使能设置(两轴插补轴2)voidCMOVEDlg::OnEpid2(){ //TODO:Addyourcontrolnotificationhandlercodehere m_EPID2=!m_EPID2; CMOVEDlg::OnLoadSettings();}voidCMOVEDlg::OnETrajectory2(){ //TODO:Addyourcontrolnotificationhandlercodehere m_ETrajectory2=!m_ETrajectory2; CMOVEDlg::OnLoadSettings();}voidCMOVEDlg::OnEMotor2(){ //TODO:Addyourcontrolnotificationhandlercodehere m_EMotor2=!m_EMotor2; CMOVEDlg::OnLoadSettings();}//载入设置voidCMOVEDlg::OnLoadSettings(){ //TODO:Addyourcontrolnotificationhandlercodehere //先使所有电机停止 loop_index=1;//循环指针置1 intindex;//判定电机和编码器的指针 if(PMDMotorInit(&hAxis1)!=PMD_NOERROR) { MessageBox("MotorInitfailed.\n"); } if(m_Axis==4) if(PMDMotorInit(&hAxis2)!=PMD_NOERROR) { MessageBox("Motor2Initfailed.\n"); }//电机类型选择 index=((CComboBox*)GetDlgItem(IDC_MotorType))->GetCurSel(); ((CComboBox*)GetDlgItem(IDC_MotorType))->GetLBText(index,m_MotorType); if(m_MotorType=="DCBrush") { PMDSetMotorType(&hAxis1,7);//直流无刷电机 if(m_Axis==4)PMDSetMotorType(&hAxis2,7); } else { MessageBox("TheMotorisundefined!PleaseselecttheDCBrush!"); SetDlgItemText(IDC_Prompt,"OnlytheDCBrushhasbeendefined."); //GetDlgItem(IDC_MotorMove)->EnableWindow(FALSE); //if(m_Axis==4)GetDlgItem(IDC_MotorMove2)->EnableWindow(FALSE); } PMDSetOutputMode(&hAxis1,0);//电机输出类型 if(m_Axis==4)PMDSetOutputMode(&hAxis2,0);//编码器选择 index=((CComboBox*)GetDlgItem(IDC_Encoder))->GetCurSel(); ((CComboBox*)GetDlgItem(IDC_Encoder))->GetLBText(index,m_Encoder); if(m_Encoder=="Incremental") { PMDSetEncoderSource(&hAxis1,0);//增量式编码器 if(m_Axis==4)PMDSetEncoderSource(&hAxis2,0);//增量式编码器 } elseif(m_Encoder=="Absolute") { PMDSetEncoderSource(&hAxis1,1);//绝对式编码器 if(m_Axis==4)PMDSetEncoderSource(&hAxis2,1); // PMDSetEncoderModulus(&hAxis1,4096); // PMDMBSetSSIRegister(&hAxis1,SSIRes25,SSIFreq550000); }//两轴插补 if(m_Axis==4) { UpdateData(); m_Station1_X; m_Station1_Y; m_Station2_X; m_Station2_Y; m_MoveTime; m_Pulse; m_T2R; m_EncoderCounts; m_EncoderCounts2; m_Zero1; m_Zero2; UpdateData(FALSE); if(m_T==-1)MessageBox("Pleaseselectthetrajectorytype!"); elseif(m_Station1_X<255||m_Station1_X>650||m_Station1_Y!=0) { MessageBox("TheStation1isnotcorrect!"); SetDlgItemText(IDC_Prompt,"TheXcoordinatemustbewithinthelimitof255and650,andtheYcoordinatemustbe0."); } elseif(sqrt(pow(m_Station2_X,2)+pow(m_Station2_Y,2))<255||sqrt(pow(m_Station2_X,2)+pow(m_Station2_Y,2))>650) { MessageBox("TheStation2isnotcorrect!"); SetDlgItemText(IDC_Prompt,"Theworkingradiusmustbewithinthelimitof255and650."); } else { PMDSetPositionLoop(&hAxis1,0,GetDlgItemInt(IDC_Kp1)); PMDSetPositionLoop(&hAxis1,1,GetDlgItemInt(IDC_Ki1)); PMDSetPositionLoop(&hAxis1,3,GetDlgItemInt(IDC_Kd1)); PMDSetPositionLoop(&hAxis1,6,GetDlgItemInt(IDC_Kvff1)); PMDSetPositionLoop(&hAxis1,7,GetDlgItemInt(IDC_Kaff1)); PMDSetPositionLoop(&hAxis2,0,GetDlgItemInt(IDC_Kp2)); PMDSetPositionLoop(&hAxis2,1,GetDlgItemInt(IDC_Ki2)); PMDSetPositionLoop(&hAxis2,3,GetDlgItemInt(IDC_Kd2)); PMDSetPositionLoop(&hAxis2,6,GetDlgItemInt(IDC_Kvff2)); PMDSetPositionLoop(&hAxis2,7,GetDlgItemInt(IDC_Kaff2)); unsignedshortOprt1,Oprt2; PMDSetOperatingMode(&hAxis1,1); PMDSetOperatingMode(&hAxis2,1); PMDGetOperatingMode(&hAxis1,&Oprt1); PMDGetOperatingMode(&hAxis2,&Oprt2); if(m_ETrajectory1)Oprt1|=32; if(m_ETrajectory2)Oprt2|=32; if(m_EMotor1)Oprt1|=2; if(m_EMotor2)Oprt2|=2; if(m_EPID1)Oprt1|=16; if(m_EPID2)Oprt2|=16; PMDSetOperatingMode(&hAxis1,Oprt1); PMDSetOperatingMode(&hAxis2,Oprt2); PMDMBSetDACOutputEnable(&hAxis1,1); PMDMBSetDACOutputEnable(&hAxis2,1); PMDUpdate(&hAxis1); PMDUpdate(&hAxis2); if(m_EPID1&&m_EPID2) { GetDlgItem(IDC_MotorMove2)->EnableWindow(TRUE);//打开运动按钮 SetDlgItemText(IDC_Prompt,""); } else { GetDlgItem(IDC_MotorMove2)->EnableWindow(FALS

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论