⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 control.cpp

📁 上次我传的倒立摆的控制程序,不是我的最终的程序,本程序采用VC++编程,定时器为多媒体控制器,(控制时间可到达5ms),控制算法用的是最优控制,
💻 CPP
字号:
// Control.cpp : implementation file
//

#include "stdafx.h"
#include "Pend.h"
#include "Control.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CControl dialog


CControl::CControl(CWnd* pParent /*=NULL*/)
	: CDialog(CControl::IDD, pParent)
{
	//{{AFX_DATA_INIT(CControl)
	m_jiaodu = 0.0;
	m_sudu = 0.0;
	m_weizhi = 0.0;
	m_jiaosudu = 0.0;
	posdot=0.0;
    angledot=0.0;
	pos=0.0;
	angle=0.0;
	pos0=0.0;
	angle0=0.0;
	angle1=0.0;
	v=0;
	v_ctrl=0.0;
	//}}AFX_DATA_INIT
}


void CControl::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CControl)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CControl, CDialog)
	//{{AFX_MSG_MAP(CControl)
	ON_BN_CLICKED(IDC_BUTTON_MOVE, OnButtonMove)
	ON_BN_CLICKED(IDC_BUTTON_STOP, OnButtonStop)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CControl message handlers

void CControl::OnButtonMove() 
{
	   SetTimer(1,100,NULL);// TODO: Add your control notification handler code here
	
}

void CControl::OnButtonStop() 
{
		GT_AxisOff();
		GT_Close();	// TODO: Add your control notification handler code here
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -