基于Verilog的FPGA步进电机控制

基于Verilog的FPGA步进电机控制

ID:40810509

大小:16.30 KB

页数:5页

时间:2019-08-08

基于Verilog的FPGA步进电机控制_第1页
基于Verilog的FPGA步进电机控制_第2页
基于Verilog的FPGA步进电机控制_第3页
基于Verilog的FPGA步进电机控制_第4页
基于Verilog的FPGA步进电机控制_第5页
资源描述:

《基于Verilog的FPGA步进电机控制》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、基于FPGA步进电机控制:电机为四相步进电机,单四拍工作.Speed为电机运行状态输入;Direct为电机转动方向输入;Out为电机控制信号输出;程序控制电机加速减速,采用计数原理,不同计数值控制电机旋转速度,再利用一个另外计数值控制特定速度运行时间,时间到则转到下一速度,设定有最大速度值,加速到最大速度自动进入匀速过程.modulemotor1(speed,rst,out,direct,clk,);//运行状态输入input[1:0]speed;//加速parameterups=2'b01;//减速paramet

2、erdns=2'b10;//停止parameterstop=2'b11;//最大速度parameteraver=4'b1000;//电机运行方向,复位,时钟输入inputdirect,rst,clk;//控制电机信号输出output[3:0]out;reg[3:0]out;//加速速度转换计数reg[3:0]count1;//减速速度转换计数reg[3:0]count2;//加速速度数字代表reg[3:0]countup;//减速速度数字代表reg[3:0]countdn;//特定速度运行时间计数reg[6:0]c

3、ount;//特定速度运行时间到标志parametercountmax=7'b1111111;always@(posedgeclkornegedgerst)if(!rst)begincountup<=4'b1111;count1<=4'b1111;count2<=4'b1000;countdn<=4'b1000;count<=7'b0;endelseif((speed==ups)

4、

5、(speed==dns))begincount<=count+1;if(speed==ups)beginif(count1==0)co

6、unt1<=countup;if(count1!=0)count1<=count1-1;if((countup>=4'b1001)&&(count==countmax))begincountup<=countup-1;count1<=countup-1;count=7'b0;endif((countup==aver)&&(count==countmax))begincount1<=aver;countdn<=aver;count<=7'b0;endendelseif(speed==dns)begincount1=4

7、'b1111;if(count2==0)count2<=countdn;if(count2!=0)count2<=count2-1;if((countdn<=4'b1110)&&(count==countmax))begincountdn<=countdn+1;count2<=countdn+1;count<=7'b0;endif((countdn==4'b1111)&&(count==countmax))begincount2<=4'b1111;count<=7'b0;endendendelseif(speed=

8、=stop)begincountup<=4'b1111;countdn<=aver;count1<=4'b1111;count<=7'b0;endalways@(count1orcount2orrst)if(!rst)out<=4'b1001;elseif((count1==0)

9、

10、(count2==0))beginif(speed==stop)out<=out;elseif((speed==ups)

11、

12、(speed==dns))beginif(direct==1)out<={out[2:0],out[3]};el

13、seif(direct==0)out<={out[0],out[3:1]};endendendmodule

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。