直流电机转速控制系统报告解剖.docx

上传人:b****7 文档编号:11023607 上传时间:2023-02-24 格式:DOCX 页数:19 大小:324.40KB
下载 相关 举报
直流电机转速控制系统报告解剖.docx_第1页
第1页 / 共19页
直流电机转速控制系统报告解剖.docx_第2页
第2页 / 共19页
直流电机转速控制系统报告解剖.docx_第3页
第3页 / 共19页
直流电机转速控制系统报告解剖.docx_第4页
第4页 / 共19页
直流电机转速控制系统报告解剖.docx_第5页
第5页 / 共19页
点击查看更多>>
下载资源
资源描述

直流电机转速控制系统报告解剖.docx

《直流电机转速控制系统报告解剖.docx》由会员分享,可在线阅读,更多相关《直流电机转速控制系统报告解剖.docx(19页珍藏版)》请在冰豆网上搜索。

直流电机转速控制系统报告解剖.docx

直流电机转速控制系统报告解剖

微机系统与应用课程设计

实验报告

直流电机转速测量与控制系统设计与实现

评语:

 

 

教师:

年月日

班级:

学号:

姓名:

实验地点:

实验时间:

直流电机转速测量与控制系统设计与实现

一、应用系统设计方案设计目的:

Ø了解以微机为核心的闭环控制系统的组成原理。

掌握电机转速闭环控制系统的构成方法。

Ø了解霍尔器件的工作原理:

电机转速的测量与控制的基本原理。

掌握PWM调速原理和应用方法。

Ø掌握控制系统的设计与调试方法,提高分析问题和解决问题能力。

二、课程设计的内容:

设计一个对直流电机转速测量与转速控制的闭环控制系统。

微机控制中心在监控界面上设置电机转速。

电机转速测量利用霍尔传感器电路产生转速脉冲,定时/计数电路通过脉冲计数获得转速参量。

电机转速调整采用PWM(脉宽调节)方法,控制中心采样到电机转速参量,算得转速值同预定转速设置值进行比较,若不相同,则调整控制转速脉冲的占空比,来达到调速的目的。

(占空比=脉冲宽度/脉冲周期)

三、系统功能要求与设计要求:

1)系统监控界面设计:

监控系统具有转速参数设置窗口、采样的电机转速数据显示窗口、转速动态曲线显示窗口及强行干预系统运行的按钮功能或相应功能选择菜单。

2)监控程序设计要求:

Ø监控程序用查询方式获取转速数据。

Ø监控程序用中断方式获取转速数据。

3)硬件设计要求:

充分利用现有实验系统资源设计一个性能较好的直流电机转速闭环控制系统。

利用带锁存的I/O接口电路(如8255,74LS273,D/A-DA0832)输出控制电机转速的脉冲。

采样转速用霍尔传感器件提供电机转速脉冲。

利用定时/计数电路对电机转速脉冲计数。

微机可从定时/计数电路中获得电机转速数值,并产生控制电机转速的PWM脉冲。

四、设计详情:

1)闭环控制系统原理图

       图一电机转速测量与控制闭环系统基本功能图

2)电机控制及转速测量原理图

图二电机控制及转速测量原理图

3)硬件连线图

图三硬件连线图

4)操作步骤

直流电机在控制脉冲作用下转动,电机转盘上的永久磁铁随之旋转,霍尔传感器件3101T受磁场的影响,从端口OUT输出脉冲信号,电机旋转一圈,霍尔传感器输出一个脉冲,脉冲频率于电机转速成正比。

通过测出脉冲信号的频率(单位时间脉冲个数)就可以计算出电机的转速。

测量转速时,需要一个定时器,设定时间为T,还需要一个计数器,将霍尔传感器的(OUT端)输出脉冲引导计数器的输入端。

电机转动时,同时启动定时器和计数器,当定时器定时时间T到时,停止计数器的脉冲计数,并读出计数器的计数值S(即:

时间T内的转数),可以计算出主流电机的转速R=S/T。

直流电机转速调整:

首先确定控制脉冲占空比的调整方式,一种是设定正(或负)脉冲宽度,不断调整负脉(或正)冲宽度实现转速,当转速高于设定转速时,加大负脉冲(或减小正脉冲)的宽度。

另一种是同时调整正负脉冲的宽度实现直流电机转速调整。

在调整了脉冲占空比后,同时启动的定时器和计数器,进行转速测量,直流电机转速调整与测量交叉进行。

A.编制利用带锁存功能I/O端口(如8255,74LS273,D/A-DA0832)输出控制电机转速的PWM脉冲程序

B.编制利用定时器/计数器测量电机转速程序

C.A)程序和B)程序合并,实现电机转速测量与控制

D.编制系统监控界面的程序

E.电机转速测量与闭环控制系统的连调。

五、课程设计试验环境:

a)实验仪器

●微机一台(Pentium4)

●微机接口技术实验箱一个

●ISA–PCI转接卡一块

●连接电缆一条

●万用表一块

●微机接口技术实验讲义一本

●导线、剥线钳等

b)软件环境:

WindowsXP平台和VisualC++6.0编译器

六、实验主要代码

//ReaderDlg.cpp:

implementationfile

#include

#include"stdafx.h"

#include"Reader.h"

#include"ReaderDlg.h"

#include"PCI9052Dll.h"//总线转换

#ifdef_DEBUG

#definenewDEBUG_NEW

#undefTHIS_FILE

staticcharTHIS_FILE[]=__FILE__;

#endif

intiospeed;//设置转速

intrate;//实际转速

inttimes=0;//运行时间

doublekey=1.0;//占空比

intnormal=0;//异常判断

intstop=0;

/////////////////////////////////////////////////////////////////////////////

//CReaderDlgdialog

CReaderDlg:

:

CReaderDlg(CWnd*pParent/*=NULL*/)

:

CDialog(CReaderDlg:

:

IDD,pParent)

{

//{{AFX_DATA_INIT(CReaderDlg)

m_edit6=_T("");

m_edit4=_T("");

m_edit5=_T("");

m_speed=0;

m_edit3=_T("");

//}}AFX_DATA_INIT

//NotethatLoadIcondoesnotrequireasubsequentDestroyIconinWin32

m_hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);

}

voidCReaderDlg:

:

DoDataExchange(CDataExchange*pDX)

{

CDialog:

:

DoDataExchange(pDX);

//{{AFX_DATA_MAP(CReaderDlg)

DDX_Text(pDX,IDC_EDIT6,m_edit6);

DDX_Text(pDX,IDC_EDIT4,m_edit4);

DDX_Text(pDX,IDC_EDIT5,m_edit5);

DDX_Text(pDX,IDC_EDIT1,m_speed);

DDV_MinMaxInt(pDX,m_speed,0,2500);

DDX_Text(pDX,IDC_EDIT3,m_edit3);

//}}AFX_DATA_MAP

}

BEGIN_MESSAGE_MAP(CReaderDlg,CDialog)

//{{AFX_MSG_MAP(CReaderDlg)

ON_WM_PAINT()

ON_WM_QUERYDRAGICON()

ON_BN_CLICKED(IDC_BUTTON1,OnButton1)

ON_EN_CHANGE(IDC_EDIT1,OnChangeEdit1)

ON_BN_CLICKED(IDC_BUTTON2,OnButton2)

ON_BN_CLICKED(IDC_BUTTON3,OnButton3)

ON_EN_CHANGE(IDC_EDIT3,OnChangeEdit3)

ON_EN_CHANGE(IDC_EDIT6,OnChangeEdit6)

ON_EN_CHANGE(IDC_EDIT4,OnChangeEdit4)

ON_EN_CHANGE(IDC_EDIT5,OnChangeEdit5)

//}}AFX_MSG_MAP

END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////

//CReaderDlgmessagehandlers

BOOLCReaderDlg:

:

OnInitDialog()

{

CDialog:

:

OnInitDialog();

//Settheiconforthisdialog.Theframeworkdoesthisautomatically

//whentheapplication'smainwindowisnotadialog

SetIcon(m_hIcon,TRUE);//Setbigicon

SetIcon(m_hIcon,FALSE);//Setsmallicon

//TODO:

Addextrainitializationhere

returnTRUE;//returnTRUEunlessyousetthefocustoacontrol

}

//Ifyouaddaminimizebuttontoyourdialog,youwillneedthecodebelow

//todrawtheicon.ForMFCapplicationsusingthedocument/viewmodel,

//thisisautomaticallydoneforyoubytheframework.

voidCReaderDlg:

:

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.

HCURSORCReaderDlg:

:

OnQueryDragIcon()

{

return(HCURSOR)m_hIcon;

}

voidCReaderDlg:

:

OnButton1()//启动按钮

{

//TODO:

Addyourcontrolnotificationhandlercodehere

//初始化

unsignedshortiobase,addr;

OpenDevice();

GetIoBase(&iobase);//得到基地址

addr=iobase+3;//8255控制字

OutByte(addr,0x8a);

addr=iobase+11;//8253计数器0控制字

OutByte(addr,0x32);

addr=iobase+8;//计数器0初始化

OutByte(addr,0x09);

OutByte(addr,0x3d);

addr=iobase+11;//8253计数器1、2控制字

OutByte(addr,0x52);

OutByte(addr,0xa0);

addr=iobase+9;//计数器1初始化

OutByte(addr,100);//初始值为100

addr=iobase+10;//计数器2初始化

OutByte(addr,0x01);

addr=iobase+2;//PC口置1

OutByte(addr,0xff);

OutByte(iobase,0x01);//PA0置1,电机以最高速度转动

//闭环调节系统

chara11,a12;//辅助变量,调节占空比

intnum=1;//用来判断是否计时到1秒

unsignedcharspeed;

unsignedchartt;//判断PB口状态,辅助计时

while(stop==0)

{

Sleep

(1);

//转速

if(num==1)

{

times++;//运行时间

CReaderDlg:

:

OnChangeEdit3();//显示运行时间

addr=iobase+9;//计时器1初始化

OutByte(addr,100);

addr=iobase+2;//PC口控制计数器0、1的GATE,同步计数

OutByte(addr,0x00);

OutByte(addr,0xff);

num=0;

}

addr=iobase+1;//读PB状态,判断是否计时超过1秒

InByte(addr,&tt);

if(tt==1)//时间到,进入转速计算语句

{

addr=iobase+2;//PC口置零,GATE失效,停止计数

OutByte(addr,0x00);

addr=iobase+9;//读计数器1的计数值

InByte(addr,&speed);

if((int)speed<0)speed=0;

rate=60*(100-(int)speed);//转速计算

CReaderDlg:

:

OnChangeEdit6();//显示转速

num=1;

if(rate>iospeed&&key>=0.1)//修改占空比

key=key-0.1;

elseif(rate

key=key+0.1;

CReaderDlg:

:

OnChangeEdit4();//显示占空比

if(abs(rate-iospeed)/iospeed>0.1)//判断正常/异常

normal=0;//异常

else

normal=1;//正常

}

a11=(char)(100*key);//电机驱动脉冲高电平持续时间

OutByte(iobase,0x01);

addr=iobase+10;

OutByte(addr,0);

OutByte(addr,a11);

unsignedchara;

intb;

while

(1)//高电平倒计时

{

addr=iobase+2;

InByte(addr,&a);

b=(int)a;

if((b&0x10))

break;

}

a12=(char)(100*(1-key));//电机驱动脉冲低电平持续时间

OutByte(iobase,0x00);

addr=iobase+10;

OutByte(addr,0);

OutByte(addr,a12);

while

(1)//低电平倒计时

{

addr=iobase+2;

InByte(addr,&a);

b=(int)a;

if((b&0x10))

break;

}

}

//CloseDevice();

}

voidCReaderDlg:

:

OnChangeEdit1()

{

//TODO:

IfthisisaRICHEDITcontrol,thecontrolwillnot

//sendthisnotificationunlessyouoverridetheCDialog:

:

OnInitDialog()

//functionandcallCRichEditCtrl().SetEventMask()

//withtheENM_CHANGEflagORedintothemask.

//TODO:

Addyourcontrolnotificationhandlercodehere

}

voidCReaderDlg:

:

OnButton2()//停止按钮

{

stop=1;

//TODO:

Addyourcontrolnotificationhandlercodehere

unsignedshortiobase;

OpenDevice();

GetIoBase(&iobase);

OutByte(iobase,0x00);//置驱动脉冲无效

MessageBox("电机已停止工作!

");

CloseDevice();

}

voidCReaderDlg:

:

OnChangeEdit2()

{

//TODO:

IfthisisaRICHEDITcontrol,thecontrolwillnot

//sendthisnotificationunlessyouoverridetheCDialog:

:

OnInitDialog()

//functionandcallCRichEditCtrl().SetEventMask()

//withtheENM_CHANGEflagORedintothemask.

//TODO:

Addyourcontrolnotificationhandlercodehere

}

voidCReaderDlg:

:

OnButton3()//设置转速确认按钮

{

//TODO:

Addyourcontrolnotificationhandlercodehere

UpdateData();

//m_speed.GetDlgItemInt(iospeed);

iospeed=m_speed;

}

voidCReaderDlg:

:

OnChangeEdit3()//显示运行时间

{

//TODO:

IfthisisaRICHEDITcontrol,thecontrolwillnot

//sendthisnotificationunlessyouoverridetheCDialog:

:

OnInitDialog()

//functionandcallCRichEditCtrl().SetEventMask()

//withtheENM_CHANGEflagORedintothemask.

//TODO:

Addyourcontrolnotificationhandlercodehere

CStringtemp;

temp.Format("%d",times);

m_edit3=temp;

//m_edit3=times;

UpdateData(false);

UpdateWindow();

}

voidCReaderDlg:

:

OnChangeEdit6()//显示实测转速

{

//TODO:

IfthisisaRICHEDITcontrol,thecontrolwillnot

//sendthisnotificationunlessyouoverridetheCDialog:

:

OnInitDialog()

//functionandcallCRichEditCtrl().SetEventMask()

//withtheENM_CHANGEflagORedintothemask.

//TODO:

Addyourcontrolnotificationhandlercodehere

CStringtemp;

temp.Format("%d",rate);

m_edit6=temp;

UpdateData(false);

UpdateWindow();

}

voidCReaderDlg:

:

OnChangeEdit4()//显示占空比

{

//TODO:

IfthisisaRICHEDITcontrol,thecontrolwillnot

//sendthisnotificationunlessyouoverridetheCDialog:

:

OnInitDialog()

//functionandcallCRichEditCtrl().SetEventMask()

//withtheENM_CHANGEflagORedintothemask.

//TODO:

Addyourcontrolnotificationhandlercodehere

CStringtemp;

temp.Format("%lf",key);

m_edit4=temp;

UpdateData(false);

UpdateWindow();

}

voidCReaderDlg:

:

OnChangeEdit5()//显示异常状况

{

//TODO:

IfthisisaRICHEDITcontrol,thecontrolwillnot

//sendthisnotificationunlessyouoverridetheCDialog:

:

OnInitDialog()

//functionandcallCRichEditCtrl().SetEventMask()

//withtheENM_CHANGEflagORedintothemask.

//TODO:

Addyourcontrolnotificationhandlercodehere

CStringtemp;

if(no

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 历史学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1